Skip to content

juanii/MiniProfiler.Fody

 
 

Repository files navigation

AutoMiniProfiler.Fody

Injects Miniprofiler into your code use Fody.

The nuget package NuGet Status

https://nuget.org/packages/MiniProfiler.Fody/

PM> Install-Package MiniProfiler.Fody

Your Code

namespace MyNamespace
{
    public class MyClass
    {
        public void MyMethod()
        {
            Console.WriteLine("Hello");
        }
    }
}

What gets compiled with MiniProfiler.Fody

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();
               }
            }
        }
    }
}

Inject Configuration

The idea and most of the code copy form tracer 😁, so configuration of control injection is similar, you can see about configuration detail here

Use FodyWeaver.xml configuration

<?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>

Use Attribute

ProfilerOnAttribute

namespace MyNamespace
{
    public class MyClass
    {
        [ProfilerOn]
        public void MyMethod()
        {
            Console.WriteLine("Hello");
        }
    }
}

NoProfilerAttribute

namespace MyNamespace
{
    [NoProfiler]
    public class MyClass
    {
        public void MyMethod()
        {
            Console.WriteLine("Hello");
        }
    }
}

About

Injects Miniprofiler into your code use Fody

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 95.2%
  • PowerShell 4.6%
  • Batchfile 0.2%