Inoculator.Net
0.0.9.2
dotnet add package Inoculator.Net --version 0.0.9.2
NuGet\Install-Package Inoculator.Net -Version 0.0.9.2
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.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Inoculator.Net --version 0.0.9.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Inoculator.Net, 0.0.9.2"
#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.
// Install Inoculator.Net as a Cake Addin
#addin nuget:?package=Inoculator.Net&version=0.0.9.2
// Install Inoculator.Net as a Cake Tool
#tool nuget:?package=Inoculator.Net&version=0.0.9.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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 | Versions 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. |
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.