Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to MiniProfiler 3.2.0.157 #4

Merged
merged 1 commit into from
Sep 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,13 @@
<CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
</PropertyGroup>
<ItemGroup>
<Reference Include="Fasterflect">
<HintPath>..\MiniProfiler.Windows\packages\fasterflect.2.0.2\lib\net40\Fasterflect.dll</HintPath>
<Reference Include="Fasterflect, Version=2.1.3.0, Culture=neutral, PublicKeyToken=38d18473284c1ca7, processorArchitecture=MSIL">
<HintPath>..\MiniProfiler.Windows\packages\fasterflect.2.1.3\lib\net40\Fasterflect.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MiniProfiler">
<HintPath>..\MiniProfiler.Windows\packages\MiniProfiler.2.0.2\lib\net40\MiniProfiler.dll</HintPath>
<Reference Include="MiniProfiler, Version=3.2.0.157, Culture=neutral, PublicKeyToken=b44f9351044011a3, processorArchitecture=MSIL">
<HintPath>..\MiniProfiler.Windows\packages\MiniProfiler.3.2.0.157\lib\net40\MiniProfiler.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down
2 changes: 1 addition & 1 deletion ConsoleApplicationSimpleExample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private static void Main()
}

//Stop profiling and show results
Console.WriteLine(ConsoleProfiling.StopAndGetConsoleFriendlyOutputStringWithSqlTimings());
Console.WriteLine(ConsoleProfiling.StopAndGetConsoleFriendlyOutputString());

//Allow viewing of results
Console.WriteLine("... press 'Enter' to exit process ...");
Expand Down
4 changes: 2 additions & 2 deletions ConsoleApplicationSimpleExample/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="fasterflect" version="2.0.2" />
<package id="MiniProfiler" version="2.0.2" />
<package id="fasterflect" version="2.1.3" targetFramework="net40" />
<package id="MiniProfiler" version="3.2.0.157" targetFramework="net40" />
</packages>
78 changes: 78 additions & 0 deletions ConsoleApplicationWithIocAndAop/AutofacAopSample.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
using System;
using System.Reflection;
using Autofac;
using Castle.DynamicProxy;
using Snap;
using Snap.Autofac;

namespace ConsoleApplication1
{
//
// NOTE: Use this sample as follows: SampleAutofacAopConfig.Intercept()
//

public static class SampleAutofacAopConfig
{
private readonly static ContainerBuilder _builder;

static SampleAutofacAopConfig()
{
_builder = new ContainerBuilder();

SnapConfiguration.For(new AutofacAspectContainer(_builder)).Configure(c =>
{
c.IncludeNamespace("ConsoleApplication1");
c.Bind<SampleInterceptor>().To<SampleAttribute>();
});

_builder.Register(r => new SampleClass()).As<ISampleClass>();
}

public static void Intercept()
{
using (var container = _builder.Build())
{
var instance = container.Resolve<ISampleClass>();
instance.Run();
}
}
}

public interface ISampleClass
{
void Run();
}

public class SampleClass : ISampleClass
{
[Sample] // Don't forget your attribute!
public void Run()
{
Console.WriteLine("inside the method");
}
}

public class SampleInterceptor : MethodInterceptor
{
public override void BeforeInvocation()
{
Console.WriteLine("this is executed before your method");
base.BeforeInvocation();
}

public override void InterceptMethod(IInvocation invocation, MethodBase method, Attribute attribute)
{
// Just keep running for this demo.
invocation.Proceed(); // the underlying method call
}

public override void AfterInvocation()
{
Console.WriteLine("this is executed after your method");
base.AfterInvocation();
}
}

public class SampleAttribute : MethodInterceptAttribute
{ }
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,30 +68,36 @@
<CodeAnalysisRuleDirectories>;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
</PropertyGroup>
<ItemGroup>
<Reference Include="Autofac, Version=2.6.3.862, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
<HintPath>..\MiniProfiler.Windows\packages\Autofac.2.6.3.862\lib\NET40\Autofac.dll</HintPath>
<Reference Include="Autofac, Version=3.0.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
<HintPath>..\MiniProfiler.Windows\packages\Autofac.3.3.0\lib\net40\Autofac.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Autofac.Configuration, Version=2.6.3.862, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
<HintPath>..\MiniProfiler.Windows\packages\Autofac.2.6.3.862\lib\NET40\Autofac.Configuration.dll</HintPath>
</Reference>
<Reference Include="Castle.Core, Version=3.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
<HintPath>..\MiniProfiler.Windows\packages\Castle.Core.3.0.0.4001\lib\net40-client\Castle.Core.dll</HintPath>
<Reference Include="Castle.Core, Version=3.3.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
<HintPath>..\MiniProfiler.Windows\packages\Castle.Core.3.3.3\lib\net40-client\Castle.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Fasterflect, Version=2.1.0.8328, Culture=neutral, PublicKeyToken=38d18473284c1ca7, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\MiniProfiler.Windows\packages\fasterflect.2.0.2\lib\net40\Fasterflect.dll</HintPath>
<Reference Include="Fasterflect, Version=2.1.3.0, Culture=neutral, PublicKeyToken=38d18473284c1ca7, processorArchitecture=MSIL">
<HintPath>..\MiniProfiler.Windows\packages\fasterflect.2.1.3\lib\net40\Fasterflect.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Practices.ServiceLocation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\MiniProfiler.Windows\packages\CommonServiceLocator.1.0\lib\NET35\Microsoft.Practices.ServiceLocation.dll</HintPath>
<Reference Include="Microsoft.Practices.ServiceLocation, Version=1.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\MiniProfiler.Windows\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MiniProfiler">
<HintPath>..\MiniProfiler.Windows\packages\MiniProfiler.2.0.2\lib\net40\MiniProfiler.dll</HintPath>
<Reference Include="MiniProfiler, Version=3.2.0.157, Culture=neutral, PublicKeyToken=b44f9351044011a3, processorArchitecture=MSIL">
<HintPath>..\MiniProfiler.Windows\packages\MiniProfiler.3.2.0.157\lib\net40\MiniProfiler.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Snap, Version=1.7.4517.28477, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\MiniProfiler.Windows\packages\SNAP.1.7.7\lib\net40\Snap.dll</HintPath>
<Reference Include="Snap, Version=1.7.5121.23330, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\MiniProfiler.Windows\packages\SNAP.1.8.3\lib\net40\Snap.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Snap.Autofac, Version=1.7.4517.28478, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\MiniProfiler.Windows\packages\SNAP.Autofac.1.7.7\lib\net40\Snap.Autofac.dll</HintPath>
<Reference Include="Snap.Autofac, Version=1.7.5121.23571, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\MiniProfiler.Windows\packages\SNAP.Autofac.1.8.3\lib\net40\Snap.Autofac.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand All @@ -104,6 +110,7 @@
<ItemGroup>
<Compile Include="AOP\ProfileMethodAttribute.cs" />
<Compile Include="AOP\ProfileMethodInterceptor.cs" />
<Compile Include="AutofacAopSample.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Workers\ConsoleApplication.cs" />
Expand Down
6 changes: 5 additions & 1 deletion ConsoleApplicationWithIocAndAop/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ private static void Main(string[] args)
app.Run();

//Stop profiling and show results
Console.WriteLine(ConsoleProfiling.StopAndGetConsoleFriendlyOutputStringWithSqlTimings());
Console.WriteLine(ConsoleProfiling.StopAndGetConsoleFriendlyOutputString());

//Allow viewing of results
Console.WriteLine("... press 'Enter' to exit process ...");
Expand Down Expand Up @@ -66,6 +66,10 @@ private static void ConfigureIocAndAop()
builder.RegisterType<DoSlowWork>().AsImplementedInterfaces();
builder.RegisterType<ConsoleApplication>().AsImplementedInterfaces();

//Do you want to use this profiler to monitor your database or link connection?
//Make sure you are using a connection provider (or factory) and wrap your connections
//with the use of ConsoleProfiling.WrapDatabaseConnection().

//Ensure we get useful type load exceptions: http://stackoverflow.com/a/8978721/281177
try
{
Expand Down
14 changes: 13 additions & 1 deletion ConsoleApplicationWithIocAndAop/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,19 @@
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Autofac" publicKeyToken="17863af14b0044da" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.3.862" newVersion="2.6.3.862" />
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Castle.Core" publicKeyToken="407dd0808d44fbdc" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.3.0.0" newVersion="3.3.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Fasterflect" publicKeyToken="38d18473284c1ca7" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.1.2.0" newVersion="2.1.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Practices.ServiceLocation" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
Expand Down
14 changes: 7 additions & 7 deletions ConsoleApplicationWithIocAndAop/packages.config
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Autofac" version="2.6.3.862" />
<package id="Castle.Core" version="3.0.0.4001" />
<package id="CommonServiceLocator" version="1.0" />
<package id="fasterflect" version="2.1.0" />
<package id="MiniProfiler" version="2.0.2" />
<package id="SNAP" version="1.7.7" />
<package id="SNAP.Autofac" version="1.7.7" />
<package id="Autofac" version="3.3.0" targetFramework="net40" />
<package id="Castle.Core" version="3.3.3" targetFramework="net40" />
<package id="CommonServiceLocator" version="1.3" targetFramework="net40" />
<package id="fasterflect" version="2.1.3" targetFramework="net40" />
<package id="MiniProfiler" version="3.2.0.157" targetFramework="net40" />
<package id="SNAP" version="1.8.3" targetFramework="net40" />
<package id="SNAP.Autofac" version="1.8.3" targetFramework="net40" />
</packages>
41 changes: 24 additions & 17 deletions MiniProfiler.Windows/ConsoleProfiling.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using System.Security.Principal;
using System.Text;
using StackExchange.Profiling;
using System.Data.Common;

namespace MiniProfiler.Windows
{
Expand Down Expand Up @@ -52,6 +53,15 @@ public static void Start(BaseProfilerProvider profilerProvider)
StackExchange.Profiling.MiniProfiler.Start();
}

/// <summary>
/// Wrap the connection with a profiling connection that tracks timings
/// </summary>
/// <param name="connection"></param>
public static DbConnection WrapDatabaseConnection(DbConnection connection)
{
return new StackExchange.Profiling.Data.ProfiledDbConnection(connection, StackExchange.Profiling.MiniProfiler.Current);
}

/// <summary>
/// Stops profiling and returns the profiler
/// </summary>
Expand All @@ -69,31 +79,28 @@ public static StackExchange.Profiling.MiniProfiler StopAndGetProfiler()
/// <param name="includeSqlWithDurationMoreThanMilliseconds"> Only include sql queries with a duration of more than the supplied number of milliseconds </param>
/// <param name="takeTopNumberOfQueries"> Only show this number of queries </param>
/// <returns> A string that can be rendered to a console, debug window or text file which is human readable. The SQL timings are in the format: *[duration(ms)]*["(D)" if duplicate, else empty] [stack trace snippet] [Formatted command string] </returns>
[Obsolete("Please use the StopAndGetConsoleFriendlyOutputString() instead of this one. Database timings are included automatically when using the WrapDatabaseConnection() connection for database calls.")]
public static string StopAndGetConsoleFriendlyOutputStringWithSqlTimings(
int includeSqlWithDurationMoreThanMilliseconds = 100, int takeTopNumberOfQueries = 10)
{
var output = new StringBuilder();
output.Append(StopAndGetConsoleFriendlyOutputString());
output.AppendLine("*** MiniProfiler SQL Timings:");
output.AppendLine("No native Sql Timing support anymore");
return output.ToString();
}

/// <summary>
/// Stops the profiler and returns a console friendly output representation.
/// </summary>
/// <returns> A string that can be rendered to a console, debug window or text file which is human readable.</returns>
public static string StopAndGetConsoleFriendlyOutputString()
{
var mp = StopAndGetProfiler();
var output = new StringBuilder();
output.AppendLine("*** MiniProfiler Output:");
output.AppendLine(mp.Render().ToString());
output.AppendLine();
if (!mp.HasSqlTimings) return output.ToString();
output.AppendLine("*** MiniProfiler SQL Timings:");

//Get the top 10 SQL queries that were over 100 milliseconds unless otherwise specified
foreach (
var currTiming in
mp.GetSqlTimings().Where(i => i.DurationMilliseconds > includeSqlWithDurationMoreThanMilliseconds).
OrderByDescending(
i => i.DurationMilliseconds).Take(takeTopNumberOfQueries))
{
output.AppendLine();
output.AppendFormat("*{1}*{0} {2}{3}{4}{3}", (currTiming.IsDuplicate ? "(D)" : " "),
Convert.ToInt32(currTiming.DurationMilliseconds),
currTiming.StackTraceSnippet, Environment.NewLine,
currTiming.FormattedCommandString.Replace(Environment.NewLine, ""));
}

return output.ToString();
}
}
Expand Down
12 changes: 10 additions & 2 deletions MiniProfiler.Windows/ConsoleProfilingProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// */

using StackExchange.Profiling;
using System;

namespace MiniProfiler.Windows
{
Expand All @@ -21,9 +22,16 @@ public override StackExchange.Profiling.MiniProfiler GetCurrentProfiler()
return _profiler;
}

public override StackExchange.Profiling.MiniProfiler Start(ProfileLevel level)
[Obsolete("Please use the Start(string sessionName) overload instead of this one. ProfileLevel is going away.")]
public override StackExchange.Profiling.MiniProfiler Start(ProfileLevel level, string sessionName = null)
{
_profiler = new StackExchange.Profiling.MiniProfiler(ConsoleProfiling.ProfilingUrl(), level);
return this.Start(sessionName: sessionName);
}

public override StackExchange.Profiling.MiniProfiler Start(string sessionName = null)
{
_profiler = new StackExchange.Profiling.MiniProfiler(ConsoleProfiling.ProfilingUrl());
_profiler.Name = sessionName;
SetProfilerActive(_profiler);
_profiler.User = ConsoleProfiling.CurrentUser();
return _profiler;
Expand Down
6 changes: 4 additions & 2 deletions MiniProfiler.Windows/MiniProfiler.Windows.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="MiniProfiler">
<HintPath>packages\MiniProfiler.2.0.2\lib\net40\MiniProfiler.dll</HintPath>
<Reference Include="MiniProfiler, Version=3.2.0.157, Culture=neutral, PublicKeyToken=b44f9351044011a3, processorArchitecture=MSIL">
<HintPath>packages\MiniProfiler.3.2.0.157\lib\net40\MiniProfiler.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Web" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions MiniProfiler.Windows/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]
2 changes: 1 addition & 1 deletion MiniProfiler.Windows/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MiniProfiler" version="2.0.2" />
<package id="MiniProfiler" version="3.2.0.157" targetFramework="net40" />
</packages>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading