Injects Miniprofiler into your code use Fody.
https://nuget.org/packages/MiniProfiler.Fody/
PM> Install-Package MiniProfiler.Fody
namespace MyNamespace
{
public class MyClass
{
public void MyMethod()
{
Console.WriteLine("Hello");
}
}
}
namespace MyNamespace
{
public class MyClass
{
public void MyMethod()
{
IDisposable disposable = MiniProfiler.Current.Step("MyNamespace.MyClass.MyMethod()");
try
{
Console.WriteLine("Hello");
}
finally
{
if(disposable != null)
{
disposable.Dispose();
}
}
}
}
}
The idea and most of the code copy form tracer 😁, so configuration of control injection is similar, you can see about configuration detail here
<?xml version="1.0" encoding="utf-8"?>
<Weavers>
<AutoMiniProfiler profilerConstructors="false" profilerProperties="false">
<ProfilerOn namespace="Root+*" class="public" method="public" />
<NoProfiler namespace="Root.Generated" />
</AutoMiniProfiler>
</Weavers>
namespace MyNamespace
{
public class MyClass
{
[ProfilerOn]
public void MyMethod()
{
Console.WriteLine("Hello");
}
}
}
namespace MyNamespace
{
[NoProfiler]
public class MyClass
{
public void MyMethod()
{
Console.WriteLine("Hello");
}
}
}