Inoculator.Net 0.0.9

There is a newer version of this package available.
See the version list below for details.
dotnet add package Inoculator.Net --version 0.0.9
                    
NuGet\Install-Package Inoculator.Net -Version 0.0.9
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Inoculator.Net" Version="0.0.9" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Inoculator.Net" Version="0.0.9" />
                    
Directory.Packages.props
<PackageReference Include="Inoculator.Net" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Inoculator.Net --version 0.0.9
                    
#r "nuget: Inoculator.Net, 0.0.9"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Inoculator.Net@0.0.9
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Inoculator.Net&version=0.0.9
                    
Install as a Cake Addin
#tool nuget:?package=Inoculator.Net&version=0.0.9
                    
Install as a Cake Tool

Innoculator

An IL code Injector using Ilasm and Ildasm

Plan

* Needs Excessive Testing
* Automatically Add MSbuild PostBuild event handler

Usage

  • Reference Inoculator.Injecter
  • Add to Msbuild :
    <Target Name="InjectionStep" BeforeTargets="AfterBuild">
         <Exec Command="$(MSbuildProjectDirectory)\$(BaseOutputPath)$(Configuration)\$(TargetFramework)\Inoculator.Injector.exe   $(MSbuildProjectDirectory)\$(BaseOutputPath)$(Configuration)\$(TargetFramework)\$(AssemblyName).dll" />
    </Target>
    
  • Inherit InterceptorAttribute and override Function lifecycle nodes :
public class ElapsedTimeAttribute : InterceptorAttribute
{
    private Stopwatch watch = new();
    public override void OnEntry(MethodData method)
        => watch.Start();

    public override void OnExit(MethodData method)
        => Console.WriteLine($"Method {method.Name(false)} took {watch.ElapsedMilliseconds}ms");
}
  • Flag function to be injected with code :
async static Task Main(string[] args) {
            // Gen region
    _ = SumIntervalIsEven(7, 23, out _);
    foreach(var kvp in CallCountAttribute.CallCounter) {
        Console.WriteLine($"{kvp.Key}: called {kvp.Value}: times");
    }
}


[ElapsedTime, LogEntrency, CallCount]
public static bool SumIntervalIsEven(int start, int end, out int r) {
    int result = 0;
    for (int j = start; j < end; j++) {
        result += j;
    }
    r = result;
    return r % 2 == 0;
}
  • Output :
Before: {
  "MethodName": "SumIntervalIsEven",
  "TypeSignature": "(int32, int32, int32 & -> bool)",
  "TypeParameters": [],
  "Parameters": [
    7,
    23,
    0
  ]
}

Success: True

Method SumIntervalIsEven took 93ms

After: {
  "MethodName": "SumIntervalIsEven",
  "TypeSignature": "(int32, int32, int32 & -> bool)",
  "TypeParameters": [],
  "Parameters": [
    7,
    23,
    232
  ],
  "ReturnValue": true
}

SumIntervalIsEven: called 1: times
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net7.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.9.2 253 2/5/2023
0.0.9.1 233 2/5/2023
0.0.9 234 2/5/2023