├── Ionad ├── key.snk ├── StaticReplacementAttribute.cs └── Ionad.csproj ├── package_icon.png ├── global.json ├── .github ├── dependabot.yml └── workflows │ └── merge-dependabot.yml ├── AssemblyToProcess ├── StaticBasic.cs ├── ClassWithBrokenReplacement.cs ├── ClassWithGenericUsage.cs ├── StaticGeneric.cs ├── StaticWithGenericMethod.cs ├── ClassWithGenericMethodUsage.cs ├── DateTimeReplacement.cs ├── StaticGenericReplacement.cs ├── StaticBasicReplacementWithBrokenMethod.cs ├── StaticWithGenericMethodReplacement.cs ├── ClassWithDateTime.cs ├── AssemblyToProcess.csproj ├── ClassWithBaseAccess.cs ├── StaticWithBaseAccess.cs ├── StaticWithOverloadsReplacement.cs ├── ClassWithOverloads.cs ├── StaticWithOverloads.cs └── StaticWithBaseAccessReplacement.cs ├── Ionad.Fody ├── Ionad.Fody.csproj ├── CecilExtensions.cs └── ModuleWeaver.cs ├── Directory.Build.props ├── appveyor.yml ├── .gitattributes ├── Tests ├── ModuleWeaverTests.ClassWithBrokenReplacement.Core.verified.txt ├── ModuleWeaverTests.ClassWithBrokenReplacement.Net.Release.verified.txt ├── ModuleWeaverTests.ClassWithBrokenReplacement.Release.Net.verified.txt ├── ModuleWeaverTests.ClassWithBrokenReplacement.DotNet.Release.verified.txt ├── ModuleWeaverTests.ClassWithBrokenReplacement.Release.DotNet.verified.txt ├── ModuleWeaverTests.ClassWithGenericUsage.Core.verified.txt ├── ModuleWeaverTests.ClassWithGenericUsage.Net.Release.verified.txt ├── ModuleWeaverTests.ClassWithGenericUsage.Release.Net.verified.txt ├── ModuleWeaverTests.ClassWithGenericUsage.DotNet.Release.verified.txt ├── ModuleWeaverTests.ClassWithGenericUsage.Release.DotNet.verified.txt ├── ModuleWeaverTests.ClassWithGenericMethodUsage.Core.verified.txt ├── ModuleWeaverTests.ClassWithGenericMethodUsage.Net.Release.verified.txt ├── ModuleWeaverTests.ClassWithGenericMethodUsage.Release.Net.verified.txt ├── ModuleWeaverTests.ClassWithBrokenReplacement.Net.verified.txt ├── ModuleWeaverTests.ClassWithBrokenReplacement.Debug.Net.verified.txt ├── ModuleWeaverTests.ClassWithBrokenReplacement.Net.Debug.verified.txt ├── ModuleWeaverTests.ClassWithGenericMethodUsage.DotNet.Release.verified.txt ├── ModuleWeaverTests.ClassWithGenericMethodUsage.Release.DotNet.verified.txt ├── ModuleWeaverTests.ClassWithBrokenReplacement.DotNet.verified.txt ├── ModuleWeaverTests.ClassWithGenericUsage.Net.verified.txt ├── ModuleWeaverTests.ClassWithBrokenReplacement.Debug.DotNet.verified.txt ├── ModuleWeaverTests.ClassWithBrokenReplacement.DotNet.Debug.verified.txt ├── ModuleWeaverTests.ClassWithGenericMethodUsage.Net.verified.txt ├── ModuleWeaverTests.ClassWithGenericUsage.Debug.Net.verified.txt ├── ModuleWeaverTests.ClassWithGenericUsage.Net.Debug.verified.txt ├── ModuleWeaverTests.ClassWithGenericMethodUsage.Debug.Net.verified.txt ├── ModuleWeaverTests.ClassWithGenericMethodUsage.Net.Debug.verified.txt ├── ModuleWeaverTests.ClassWithGenericUsage.DotNet.verified.txt ├── ModuleWeaverTests.ClassWithGenericMethodUsage.DotNet.verified.txt ├── ModuleWeaverTests.ClassWithGenericUsage.Debug.DotNet.verified.txt ├── ModuleWeaverTests.ClassWithGenericUsage.DotNet.Debug.verified.txt ├── ModuleWeaverTests.ClassWithGenericMethodUsage.Debug.DotNet.verified.txt ├── ModuleWeaverTests.ClassWithGenericMethodUsage.DotNet.Debug.verified.txt ├── Tests.csproj ├── ModuleWeaverTests.ClassWithDateTime.Net.Release.verified.txt ├── ModuleWeaverTests.ClassWithDateTime.Release.Net.verified.txt ├── ModuleWeaverTests.ClassWithDateTime.Core.verified.txt ├── ModuleWeaverTests.ClassWithDateTime.DotNet.Release.verified.txt ├── ModuleWeaverTests.ClassWithDateTime.Release.DotNet.verified.txt ├── ModuleWeaverTests.ClassWithDateTime.Net.verified.txt ├── ModuleWeaverTests.ClassWithDateTime.Debug.Net.verified.txt ├── ModuleWeaverTests.ClassWithDateTime.Net.Debug.verified.txt ├── ModuleWeaverTests.ClassWithDateTime.DotNet.verified.txt ├── ModuleWeaverTests.ClassWithDateTime.Debug.DotNet.verified.txt ├── ModuleWeaverTests.ClassWithDateTime.DotNet.Debug.verified.txt └── ModuleWeaverTests.cs ├── readme.md ├── .editorconfig ├── Ionad.sln ├── .gitignore └── Ionad.sln.DotSettings /Ionad/key.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fody/Ionad/HEAD/Ionad/key.snk -------------------------------------------------------------------------------- /package_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fody/Ionad/HEAD/package_icon.png -------------------------------------------------------------------------------- /global.json: -------------------------------------------------------------------------------- 1 | { 2 | "sdk": { 3 | "version": "8.0.101", 4 | "allowPrerelease": true, 5 | "rollForward": "latestFeature" 6 | } 7 | } -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: nuget 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | open-pull-requests-limit: 10 -------------------------------------------------------------------------------- /AssemblyToProcess/StaticBasic.cs: -------------------------------------------------------------------------------- 1 | public class StaticBasic 2 | { 3 | public static void SomeMethod() 4 | { 5 | throw new NotImplementedException(); 6 | } 7 | } -------------------------------------------------------------------------------- /AssemblyToProcess/ClassWithBrokenReplacement.cs: -------------------------------------------------------------------------------- 1 | public class ClassWithBrokenReplacement 2 | { 3 | public void Method() 4 | { 5 | StaticBasic.SomeMethod(); 6 | } 7 | } -------------------------------------------------------------------------------- /AssemblyToProcess/ClassWithGenericUsage.cs: -------------------------------------------------------------------------------- 1 | public class ClassWithGenericUsage 2 | { 3 | public void Method() 4 | { 5 | StaticGeneric.SomeMethod(); 6 | } 7 | } -------------------------------------------------------------------------------- /AssemblyToProcess/StaticGeneric.cs: -------------------------------------------------------------------------------- 1 | public class StaticGeneric 2 | { 3 | public static void SomeMethod() 4 | { 5 | throw new NotImplementedException(); 6 | } 7 | } -------------------------------------------------------------------------------- /AssemblyToProcess/StaticWithGenericMethod.cs: -------------------------------------------------------------------------------- 1 | public class StaticWithGenericMethod 2 | { 3 | public static T Method() 4 | { 5 | throw new NotImplementedException(); 6 | } 7 | } -------------------------------------------------------------------------------- /AssemblyToProcess/ClassWithGenericMethodUsage.cs: -------------------------------------------------------------------------------- 1 | public class ClassWithGenericMethodUsage 2 | { 3 | public void Method() 4 | { 5 | StaticWithGenericMethod.Method(); 6 | } 7 | } -------------------------------------------------------------------------------- /AssemblyToProcess/DateTimeReplacement.cs: -------------------------------------------------------------------------------- 1 | using Ionad; 2 | 3 | [StaticReplacement(typeof(DateTime))] 4 | public static class DateTimeReplacement 5 | { 6 | public static DateTime Now => new(1978, 1, 13); 7 | } -------------------------------------------------------------------------------- /AssemblyToProcess/StaticGenericReplacement.cs: -------------------------------------------------------------------------------- 1 | using Ionad; 2 | 3 | [StaticReplacement(typeof(StaticGeneric<>))] 4 | public class StaticGenericReplacement 5 | { 6 | public static void SomeMethod() 7 | { 8 | } 9 | } -------------------------------------------------------------------------------- /AssemblyToProcess/StaticBasicReplacementWithBrokenMethod.cs: -------------------------------------------------------------------------------- 1 | using Ionad; 2 | 3 | [StaticReplacement(typeof(StaticBasic))] 4 | public class StaticBasicReplacementWithBrokenMethod 5 | { 6 | public void SomeMethod() 7 | { 8 | } 9 | } -------------------------------------------------------------------------------- /AssemblyToProcess/StaticWithGenericMethodReplacement.cs: -------------------------------------------------------------------------------- 1 | using Ionad; 2 | 3 | [StaticReplacement(typeof(StaticWithGenericMethod))] 4 | public static class StaticWithGenericMethodReplacement 5 | { 6 | public static T Method() 7 | { 8 | return default; 9 | } 10 | } -------------------------------------------------------------------------------- /Ionad.Fody/Ionad.Fody.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /AssemblyToProcess/ClassWithDateTime.cs: -------------------------------------------------------------------------------- 1 | public class ClassWithDateTime 2 | { 3 | public DateTime GetDateTime() 4 | { 5 | return DateTime.Now; 6 | } 7 | 8 | public DateTime SomeProperty => DateTime.Now; 9 | 10 | public DateTime MissingReplacement() 11 | { 12 | return DateTime.Today; 13 | } 14 | } -------------------------------------------------------------------------------- /AssemblyToProcess/AssemblyToProcess.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net48;net8.0 5 | true 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /AssemblyToProcess/ClassWithBaseAccess.cs: -------------------------------------------------------------------------------- 1 | public class ClassWithBaseAccess 2 | { 3 | public int ReplacedCount => StaticWithBaseAccess.ReplacedCount; 4 | public IEnumerable Yield => StaticWithBaseAccess.YieldMethod(); 5 | 6 | public Task AsyncWithLambdaReplacement => StaticWithBaseAccess.LambdaReplacementMethod(); 7 | 8 | public Task AsyncDecorator => StaticWithBaseAccess.AsyncMethod(); 9 | } -------------------------------------------------------------------------------- /.github/workflows/merge-dependabot.yml: -------------------------------------------------------------------------------- 1 | name: merge-dependabot 2 | on: 3 | pull_request: 4 | jobs: 5 | automerge: 6 | runs-on: ubuntu-latest 7 | if: github.actor == 'dependabot[bot]' 8 | steps: 9 | - name: Dependabot Auto Merge 10 | uses: ahmadnassri/action-dependabot-auto-merge@v2.6.6 11 | with: 12 | target: minor 13 | github-token: ${{ secrets.GITHUB_TOKEN }} 14 | command: squash and merge -------------------------------------------------------------------------------- /Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | true 5 | 2.2.0 6 | preview 7 | enable 8 | true 9 | all 10 | low 11 | 12 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | image: Visual Studio 2022 2 | environment: 3 | DOTNET_NOLOGO: true 4 | DOTNET_CLI_TELEMETRY_OPTOUT: true 5 | DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true 6 | build_script: 7 | - pwsh: | 8 | Invoke-WebRequest "https://dot.net/v1/dotnet-install.ps1" -OutFile "./dotnet-install.ps1" 9 | ./dotnet-install.ps1 -JSonFile global.json -Architecture x64 -InstallDir 'C:\Program Files\dotnet' 10 | - dotnet build --configuration Release 11 | - dotnet test --configuration Release --no-build --no-restore 12 | test: off 13 | artifacts: 14 | - path: nugets\*.nupkg -------------------------------------------------------------------------------- /AssemblyToProcess/StaticWithBaseAccess.cs: -------------------------------------------------------------------------------- 1 | public static class StaticWithBaseAccess 2 | { 3 | public static int ReplacedCount => 0; 4 | 5 | public static IEnumerable YieldMethod() 6 | { 7 | for (var i = 0; i < 10; i++) 8 | { 9 | yield return i; 10 | } 11 | } 12 | 13 | public static Task LambdaReplacementMethod() 14 | { 15 | return Task.FromResult(0); 16 | } 17 | 18 | public static async Task AsyncMethod() 19 | { 20 | await Task.Delay(1); 21 | return 0; 22 | } 23 | } -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text 3 | 4 | # Don't check these into the repo as LF to work around TeamCity bug 5 | *.xml -text 6 | *.targets -text 7 | 8 | # Custom for Visual Studio 9 | *.cs diff=csharp 10 | *.sln merge=union 11 | *.csproj merge=union 12 | *.vbproj merge=union 13 | *.fsproj merge=union 14 | *.dbproj merge=union 15 | 16 | # Denote all files that are truly binary and should not be modified. 17 | *.dll binary 18 | *.exe binary 19 | *.png binary 20 | *.ico binary 21 | *.snk binary 22 | *.pdb binary 23 | *.svg binary 24 | -------------------------------------------------------------------------------- /Ionad/StaticReplacementAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace Ionad; 2 | 3 | /// 4 | /// Marks a class as a replacement for a static class. 5 | /// 6 | [AttributeUsage(AttributeTargets.Class)] 7 | public class StaticReplacementAttribute : Attribute 8 | { 9 | /// 10 | /// Initializes a new instance of the with a System.Type. 11 | /// 12 | /// The System.Type to be replaced with this class. 13 | public StaticReplacementAttribute(Type replacementType) 14 | { 15 | } 16 | } -------------------------------------------------------------------------------- /Tests/ModuleWeaverTests.ClassWithBrokenReplacement.Core.verified.txt: -------------------------------------------------------------------------------- 1 | .class public auto ansi beforefieldinit ClassWithBrokenReplacement 2 | extends [netstandard]System.Object 3 | { 4 | .method public hidebysig instance void 5 | Method() cil managed 6 | { 7 | .maxstack 0 8 | IL_0000: call void StaticBasic::SomeMethod() 9 | IL_0005: ret 10 | } 11 | .method public hidebysig specialname rtspecialname 12 | instance void .ctor() cil managed 13 | { 14 | .maxstack 1 15 | IL_0000: ldarg.0 16 | IL_0001: call instance void [netstandard]System.Object::.ctor() 17 | IL_0006: ret 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Tests/ModuleWeaverTests.ClassWithBrokenReplacement.Net.Release.verified.txt: -------------------------------------------------------------------------------- 1 | .class public auto ansi beforefieldinit ClassWithBrokenReplacement 2 | extends [mscorlib]System.Object 3 | { 4 | .method public hidebysig instance void 5 | Method() cil managed 6 | { 7 | .maxstack 0 8 | IL_0000: call void StaticBasic::SomeMethod() 9 | IL_0005: ret 10 | } 11 | .method public hidebysig specialname rtspecialname 12 | instance void .ctor() cil managed 13 | { 14 | .maxstack 1 15 | IL_0000: ldarg.0 16 | IL_0001: call instance void [mscorlib]System.Object::.ctor() 17 | IL_0006: ret 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Tests/ModuleWeaverTests.ClassWithBrokenReplacement.Release.Net.verified.txt: -------------------------------------------------------------------------------- 1 | .class public auto ansi beforefieldinit ClassWithBrokenReplacement 2 | extends [mscorlib]System.Object 3 | { 4 | .method public hidebysig instance void 5 | Method() cil managed 6 | { 7 | .maxstack 0 8 | IL_0000: call void StaticBasic::SomeMethod() 9 | IL_0005: ret 10 | } 11 | .method public hidebysig specialname rtspecialname 12 | instance void .ctor() cil managed 13 | { 14 | .maxstack 1 15 | IL_0000: ldarg.0 16 | IL_0001: call instance void [mscorlib]System.Object::.ctor() 17 | IL_0006: ret 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Tests/ModuleWeaverTests.ClassWithBrokenReplacement.DotNet.Release.verified.txt: -------------------------------------------------------------------------------- 1 | .class public auto ansi beforefieldinit ClassWithBrokenReplacement 2 | extends [System.Runtime]System.Object 3 | { 4 | .method public hidebysig instance void 5 | Method() cil managed 6 | { 7 | .maxstack 0 8 | IL_0000: call void StaticBasic::SomeMethod() 9 | IL_0005: ret 10 | } 11 | .method public hidebysig specialname rtspecialname 12 | instance void .ctor() cil managed 13 | { 14 | .maxstack 1 15 | IL_0000: ldarg.0 16 | IL_0001: call instance void [System.Runtime]System.Object::.ctor() 17 | IL_0006: ret 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Tests/ModuleWeaverTests.ClassWithBrokenReplacement.Release.DotNet.verified.txt: -------------------------------------------------------------------------------- 1 | .class public auto ansi beforefieldinit ClassWithBrokenReplacement 2 | extends [System.Runtime]System.Object 3 | { 4 | .method public hidebysig instance void 5 | Method() cil managed 6 | { 7 | .maxstack 0 8 | IL_0000: call void StaticBasic::SomeMethod() 9 | IL_0005: ret 10 | } 11 | .method public hidebysig specialname rtspecialname 12 | instance void .ctor() cil managed 13 | { 14 | .maxstack 1 15 | IL_0000: ldarg.0 16 | IL_0001: call instance void [System.Runtime]System.Object::.ctor() 17 | IL_0006: ret 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Tests/ModuleWeaverTests.ClassWithGenericUsage.Core.verified.txt: -------------------------------------------------------------------------------- 1 | .class public auto ansi beforefieldinit ClassWithGenericUsage 2 | extends [netstandard]System.Object 3 | { 4 | .method public hidebysig instance void 5 | Method() cil managed 6 | { 7 | .maxstack 0 8 | IL_0000: call void class StaticGenericReplacement`1::SomeMethod() 9 | IL_0005: ret 10 | } 11 | .method public hidebysig specialname rtspecialname 12 | instance void .ctor() cil managed 13 | { 14 | .maxstack 1 15 | IL_0000: ldarg.0 16 | IL_0001: call instance void [netstandard]System.Object::.ctor() 17 | IL_0006: ret 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Tests/ModuleWeaverTests.ClassWithGenericUsage.Net.Release.verified.txt: -------------------------------------------------------------------------------- 1 | .class public auto ansi beforefieldinit ClassWithGenericUsage 2 | extends [mscorlib]System.Object 3 | { 4 | .method public hidebysig instance void 5 | Method() cil managed 6 | { 7 | .maxstack 0 8 | IL_0000: call void class StaticGenericReplacement`1::SomeMethod() 9 | IL_0005: ret 10 | } 11 | .method public hidebysig specialname rtspecialname 12 | instance void .ctor() cil managed 13 | { 14 | .maxstack 1 15 | IL_0000: ldarg.0 16 | IL_0001: call instance void [mscorlib]System.Object::.ctor() 17 | IL_0006: ret 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Tests/ModuleWeaverTests.ClassWithGenericUsage.Release.Net.verified.txt: -------------------------------------------------------------------------------- 1 | .class public auto ansi beforefieldinit ClassWithGenericUsage 2 | extends [mscorlib]System.Object 3 | { 4 | .method public hidebysig instance void 5 | Method() cil managed 6 | { 7 | .maxstack 0 8 | IL_0000: call void class StaticGenericReplacement`1::SomeMethod() 9 | IL_0005: ret 10 | } 11 | .method public hidebysig specialname rtspecialname 12 | instance void .ctor() cil managed 13 | { 14 | .maxstack 1 15 | IL_0000: ldarg.0 16 | IL_0001: call instance void [mscorlib]System.Object::.ctor() 17 | IL_0006: ret 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Tests/ModuleWeaverTests.ClassWithGenericUsage.DotNet.Release.verified.txt: -------------------------------------------------------------------------------- 1 | .class public auto ansi beforefieldinit ClassWithGenericUsage 2 | extends [System.Runtime]System.Object 3 | { 4 | .method public hidebysig instance void 5 | Method() cil managed 6 | { 7 | .maxstack 0 8 | IL_0000: call void class StaticGenericReplacement`1::SomeMethod() 9 | IL_0005: ret 10 | } 11 | .method public hidebysig specialname rtspecialname 12 | instance void .ctor() cil managed 13 | { 14 | .maxstack 1 15 | IL_0000: ldarg.0 16 | IL_0001: call instance void [System.Runtime]System.Object::.ctor() 17 | IL_0006: ret 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Tests/ModuleWeaverTests.ClassWithGenericUsage.Release.DotNet.verified.txt: -------------------------------------------------------------------------------- 1 | .class public auto ansi beforefieldinit ClassWithGenericUsage 2 | extends [System.Runtime]System.Object 3 | { 4 | .method public hidebysig instance void 5 | Method() cil managed 6 | { 7 | .maxstack 0 8 | IL_0000: call void class StaticGenericReplacement`1::SomeMethod() 9 | IL_0005: ret 10 | } 11 | .method public hidebysig specialname rtspecialname 12 | instance void .ctor() cil managed 13 | { 14 | .maxstack 1 15 | IL_0000: ldarg.0 16 | IL_0001: call instance void [System.Runtime]System.Object::.ctor() 17 | IL_0006: ret 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /AssemblyToProcess/StaticWithOverloadsReplacement.cs: -------------------------------------------------------------------------------- 1 | using Ionad; 2 | 3 | [StaticReplacement(typeof(StaticWithOverloads))] 4 | public static class StaticWithOverloadsReplacement 5 | { 6 | public static int Overloaded(long i) => -1; 7 | 8 | public static int Overloaded() => 0; 9 | 10 | public static int Overloaded(int i) => 1; 11 | 12 | public static int Overloaded(string i) => 2; 13 | 14 | public static Dictionary Overloaded() => new(); 15 | 16 | public static Dictionary Overloaded(TKey key, TValue value) => 17 | new() 18 | { {key, value }}; 19 | } -------------------------------------------------------------------------------- /Tests/ModuleWeaverTests.ClassWithGenericMethodUsage.Core.verified.txt: -------------------------------------------------------------------------------- 1 | .class public auto ansi beforefieldinit ClassWithGenericMethodUsage 2 | extends [netstandard]System.Object 3 | { 4 | .method public hidebysig instance void 5 | Method() cil managed 6 | { 7 | .maxstack 1 8 | IL_0000: call !!0 StaticWithGenericMethodReplacement::Method() 9 | IL_0005: pop 10 | IL_0006: ret 11 | } 12 | .method public hidebysig specialname rtspecialname 13 | instance void .ctor() cil managed 14 | { 15 | .maxstack 1 16 | IL_0000: ldarg.0 17 | IL_0001: call instance void [netstandard]System.Object::.ctor() 18 | IL_0006: ret 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Tests/ModuleWeaverTests.ClassWithGenericMethodUsage.Net.Release.verified.txt: -------------------------------------------------------------------------------- 1 | .class public auto ansi beforefieldinit ClassWithGenericMethodUsage 2 | extends [mscorlib]System.Object 3 | { 4 | .method public hidebysig instance void 5 | Method() cil managed 6 | { 7 | .maxstack 1 8 | IL_0000: call !!0 StaticWithGenericMethodReplacement::Method() 9 | IL_0005: pop 10 | IL_0006: ret 11 | } 12 | .method public hidebysig specialname rtspecialname 13 | instance void .ctor() cil managed 14 | { 15 | .maxstack 1 16 | IL_0000: ldarg.0 17 | IL_0001: call instance void [mscorlib]System.Object::.ctor() 18 | IL_0006: ret 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Tests/ModuleWeaverTests.ClassWithGenericMethodUsage.Release.Net.verified.txt: -------------------------------------------------------------------------------- 1 | .class public auto ansi beforefieldinit ClassWithGenericMethodUsage 2 | extends [mscorlib]System.Object 3 | { 4 | .method public hidebysig instance void 5 | Method() cil managed 6 | { 7 | .maxstack 1 8 | IL_0000: call !!0 StaticWithGenericMethodReplacement::Method() 9 | IL_0005: pop 10 | IL_0006: ret 11 | } 12 | .method public hidebysig specialname rtspecialname 13 | instance void .ctor() cil managed 14 | { 15 | .maxstack 1 16 | IL_0000: ldarg.0 17 | IL_0001: call instance void [mscorlib]System.Object::.ctor() 18 | IL_0006: ret 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Tests/ModuleWeaverTests.ClassWithBrokenReplacement.Net.verified.txt: -------------------------------------------------------------------------------- 1 | .class public auto ansi beforefieldinit ClassWithBrokenReplacement 2 | extends [mscorlib]System.Object 3 | { 4 | .method public hidebysig instance void 5 | Method() cil managed 6 | { 7 | .maxstack 0 8 | IL_0000: nop 9 | IL_0001: call void StaticBasic::SomeMethod() 10 | IL_0006: nop 11 | IL_0007: ret 12 | } 13 | .method public hidebysig specialname rtspecialname 14 | instance void .ctor() cil managed 15 | { 16 | .maxstack 1 17 | IL_0000: ldarg.0 18 | IL_0001: call instance void [mscorlib]System.Object::.ctor() 19 | IL_0006: nop 20 | IL_0007: ret 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Tests/ModuleWeaverTests.ClassWithBrokenReplacement.Debug.Net.verified.txt: -------------------------------------------------------------------------------- 1 | .class public auto ansi beforefieldinit ClassWithBrokenReplacement 2 | extends [mscorlib]System.Object 3 | { 4 | .method public hidebysig instance void 5 | Method() cil managed 6 | { 7 | .maxstack 0 8 | IL_0000: nop 9 | IL_0001: call void StaticBasic::SomeMethod() 10 | IL_0006: nop 11 | IL_0007: ret 12 | } 13 | .method public hidebysig specialname rtspecialname 14 | instance void .ctor() cil managed 15 | { 16 | .maxstack 1 17 | IL_0000: ldarg.0 18 | IL_0001: call instance void [mscorlib]System.Object::.ctor() 19 | IL_0006: nop 20 | IL_0007: ret 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Tests/ModuleWeaverTests.ClassWithBrokenReplacement.Net.Debug.verified.txt: -------------------------------------------------------------------------------- 1 | .class public auto ansi beforefieldinit ClassWithBrokenReplacement 2 | extends [mscorlib]System.Object 3 | { 4 | .method public hidebysig instance void 5 | Method() cil managed 6 | { 7 | .maxstack 0 8 | IL_0000: nop 9 | IL_0001: call void StaticBasic::SomeMethod() 10 | IL_0006: nop 11 | IL_0007: ret 12 | } 13 | .method public hidebysig specialname rtspecialname 14 | instance void .ctor() cil managed 15 | { 16 | .maxstack 1 17 | IL_0000: ldarg.0 18 | IL_0001: call instance void [mscorlib]System.Object::.ctor() 19 | IL_0006: nop 20 | IL_0007: ret 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Tests/ModuleWeaverTests.ClassWithGenericMethodUsage.DotNet.Release.verified.txt: -------------------------------------------------------------------------------- 1 | .class public auto ansi beforefieldinit ClassWithGenericMethodUsage 2 | extends [System.Runtime]System.Object 3 | { 4 | .method public hidebysig instance void 5 | Method() cil managed 6 | { 7 | .maxstack 1 8 | IL_0000: call !!0 StaticWithGenericMethodReplacement::Method() 9 | IL_0005: pop 10 | IL_0006: ret 11 | } 12 | .method public hidebysig specialname rtspecialname 13 | instance void .ctor() cil managed 14 | { 15 | .maxstack 1 16 | IL_0000: ldarg.0 17 | IL_0001: call instance void [System.Runtime]System.Object::.ctor() 18 | IL_0006: ret 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Tests/ModuleWeaverTests.ClassWithGenericMethodUsage.Release.DotNet.verified.txt: -------------------------------------------------------------------------------- 1 | .class public auto ansi beforefieldinit ClassWithGenericMethodUsage 2 | extends [System.Runtime]System.Object 3 | { 4 | .method public hidebysig instance void 5 | Method() cil managed 6 | { 7 | .maxstack 1 8 | IL_0000: call !!0 StaticWithGenericMethodReplacement::Method() 9 | IL_0005: pop 10 | IL_0006: ret 11 | } 12 | .method public hidebysig specialname rtspecialname 13 | instance void .ctor() cil managed 14 | { 15 | .maxstack 1 16 | IL_0000: ldarg.0 17 | IL_0001: call instance void [System.Runtime]System.Object::.ctor() 18 | IL_0006: ret 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Tests/ModuleWeaverTests.ClassWithBrokenReplacement.DotNet.verified.txt: -------------------------------------------------------------------------------- 1 | .class public auto ansi beforefieldinit ClassWithBrokenReplacement 2 | extends [System.Runtime]System.Object 3 | { 4 | .method public hidebysig instance void 5 | Method() cil managed 6 | { 7 | .maxstack 0 8 | IL_0000: nop 9 | IL_0001: call void StaticBasic::SomeMethod() 10 | IL_0006: nop 11 | IL_0007: ret 12 | } 13 | .method public hidebysig specialname rtspecialname 14 | instance void .ctor() cil managed 15 | { 16 | .maxstack 1 17 | IL_0000: ldarg.0 18 | IL_0001: call instance void [System.Runtime]System.Object::.ctor() 19 | IL_0006: nop 20 | IL_0007: ret 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Tests/ModuleWeaverTests.ClassWithGenericUsage.Net.verified.txt: -------------------------------------------------------------------------------- 1 | .class public auto ansi beforefieldinit ClassWithGenericUsage 2 | extends [mscorlib]System.Object 3 | { 4 | .method public hidebysig instance void 5 | Method() cil managed 6 | { 7 | .maxstack 0 8 | IL_0000: nop 9 | IL_0001: call void class StaticGenericReplacement`1::SomeMethod() 10 | IL_0006: nop 11 | IL_0007: ret 12 | } 13 | .method public hidebysig specialname rtspecialname 14 | instance void .ctor() cil managed 15 | { 16 | .maxstack 1 17 | IL_0000: ldarg.0 18 | IL_0001: call instance void [mscorlib]System.Object::.ctor() 19 | IL_0006: nop 20 | IL_0007: ret 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Tests/ModuleWeaverTests.ClassWithBrokenReplacement.Debug.DotNet.verified.txt: -------------------------------------------------------------------------------- 1 | .class public auto ansi beforefieldinit ClassWithBrokenReplacement 2 | extends [System.Runtime]System.Object 3 | { 4 | .method public hidebysig instance void 5 | Method() cil managed 6 | { 7 | .maxstack 0 8 | IL_0000: nop 9 | IL_0001: call void StaticBasic::SomeMethod() 10 | IL_0006: nop 11 | IL_0007: ret 12 | } 13 | .method public hidebysig specialname rtspecialname 14 | instance void .ctor() cil managed 15 | { 16 | .maxstack 1 17 | IL_0000: ldarg.0 18 | IL_0001: call instance void [System.Runtime]System.Object::.ctor() 19 | IL_0006: nop 20 | IL_0007: ret 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Tests/ModuleWeaverTests.ClassWithBrokenReplacement.DotNet.Debug.verified.txt: -------------------------------------------------------------------------------- 1 | .class public auto ansi beforefieldinit ClassWithBrokenReplacement 2 | extends [System.Runtime]System.Object 3 | { 4 | .method public hidebysig instance void 5 | Method() cil managed 6 | { 7 | .maxstack 0 8 | IL_0000: nop 9 | IL_0001: call void StaticBasic::SomeMethod() 10 | IL_0006: nop 11 | IL_0007: ret 12 | } 13 | .method public hidebysig specialname rtspecialname 14 | instance void .ctor() cil managed 15 | { 16 | .maxstack 1 17 | IL_0000: ldarg.0 18 | IL_0001: call instance void [System.Runtime]System.Object::.ctor() 19 | IL_0006: nop 20 | IL_0007: ret 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Tests/ModuleWeaverTests.ClassWithGenericMethodUsage.Net.verified.txt: -------------------------------------------------------------------------------- 1 | .class public auto ansi beforefieldinit ClassWithGenericMethodUsage 2 | extends [mscorlib]System.Object 3 | { 4 | .method public hidebysig instance void 5 | Method() cil managed 6 | { 7 | .maxstack 1 8 | IL_0000: nop 9 | IL_0001: call !!0 StaticWithGenericMethodReplacement::Method() 10 | IL_0006: pop 11 | IL_0007: ret 12 | } 13 | .method public hidebysig specialname rtspecialname 14 | instance void .ctor() cil managed 15 | { 16 | .maxstack 1 17 | IL_0000: ldarg.0 18 | IL_0001: call instance void [mscorlib]System.Object::.ctor() 19 | IL_0006: nop 20 | IL_0007: ret 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Tests/ModuleWeaverTests.ClassWithGenericUsage.Debug.Net.verified.txt: -------------------------------------------------------------------------------- 1 | .class public auto ansi beforefieldinit ClassWithGenericUsage 2 | extends [mscorlib]System.Object 3 | { 4 | .method public hidebysig instance void 5 | Method() cil managed 6 | { 7 | .maxstack 0 8 | IL_0000: nop 9 | IL_0001: call void class StaticGenericReplacement`1::SomeMethod() 10 | IL_0006: nop 11 | IL_0007: ret 12 | } 13 | .method public hidebysig specialname rtspecialname 14 | instance void .ctor() cil managed 15 | { 16 | .maxstack 1 17 | IL_0000: ldarg.0 18 | IL_0001: call instance void [mscorlib]System.Object::.ctor() 19 | IL_0006: nop 20 | IL_0007: ret 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Tests/ModuleWeaverTests.ClassWithGenericUsage.Net.Debug.verified.txt: -------------------------------------------------------------------------------- 1 | .class public auto ansi beforefieldinit ClassWithGenericUsage 2 | extends [mscorlib]System.Object 3 | { 4 | .method public hidebysig instance void 5 | Method() cil managed 6 | { 7 | .maxstack 0 8 | IL_0000: nop 9 | IL_0001: call void class StaticGenericReplacement`1::SomeMethod() 10 | IL_0006: nop 11 | IL_0007: ret 12 | } 13 | .method public hidebysig specialname rtspecialname 14 | instance void .ctor() cil managed 15 | { 16 | .maxstack 1 17 | IL_0000: ldarg.0 18 | IL_0001: call instance void [mscorlib]System.Object::.ctor() 19 | IL_0006: nop 20 | IL_0007: ret 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Tests/ModuleWeaverTests.ClassWithGenericMethodUsage.Debug.Net.verified.txt: -------------------------------------------------------------------------------- 1 | .class public auto ansi beforefieldinit ClassWithGenericMethodUsage 2 | extends [mscorlib]System.Object 3 | { 4 | .method public hidebysig instance void 5 | Method() cil managed 6 | { 7 | .maxstack 1 8 | IL_0000: nop 9 | IL_0001: call !!0 StaticWithGenericMethodReplacement::Method() 10 | IL_0006: pop 11 | IL_0007: ret 12 | } 13 | .method public hidebysig specialname rtspecialname 14 | instance void .ctor() cil managed 15 | { 16 | .maxstack 1 17 | IL_0000: ldarg.0 18 | IL_0001: call instance void [mscorlib]System.Object::.ctor() 19 | IL_0006: nop 20 | IL_0007: ret 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Tests/ModuleWeaverTests.ClassWithGenericMethodUsage.Net.Debug.verified.txt: -------------------------------------------------------------------------------- 1 | .class public auto ansi beforefieldinit ClassWithGenericMethodUsage 2 | extends [mscorlib]System.Object 3 | { 4 | .method public hidebysig instance void 5 | Method() cil managed 6 | { 7 | .maxstack 1 8 | IL_0000: nop 9 | IL_0001: call !!0 StaticWithGenericMethodReplacement::Method() 10 | IL_0006: pop 11 | IL_0007: ret 12 | } 13 | .method public hidebysig specialname rtspecialname 14 | instance void .ctor() cil managed 15 | { 16 | .maxstack 1 17 | IL_0000: ldarg.0 18 | IL_0001: call instance void [mscorlib]System.Object::.ctor() 19 | IL_0006: nop 20 | IL_0007: ret 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Tests/ModuleWeaverTests.ClassWithGenericUsage.DotNet.verified.txt: -------------------------------------------------------------------------------- 1 | .class public auto ansi beforefieldinit ClassWithGenericUsage 2 | extends [System.Runtime]System.Object 3 | { 4 | .method public hidebysig instance void 5 | Method() cil managed 6 | { 7 | .maxstack 0 8 | IL_0000: nop 9 | IL_0001: call void class StaticGenericReplacement`1::SomeMethod() 10 | IL_0006: nop 11 | IL_0007: ret 12 | } 13 | .method public hidebysig specialname rtspecialname 14 | instance void .ctor() cil managed 15 | { 16 | .maxstack 1 17 | IL_0000: ldarg.0 18 | IL_0001: call instance void [System.Runtime]System.Object::.ctor() 19 | IL_0006: nop 20 | IL_0007: ret 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Tests/ModuleWeaverTests.ClassWithGenericMethodUsage.DotNet.verified.txt: -------------------------------------------------------------------------------- 1 | .class public auto ansi beforefieldinit ClassWithGenericMethodUsage 2 | extends [System.Runtime]System.Object 3 | { 4 | .method public hidebysig instance void 5 | Method() cil managed 6 | { 7 | .maxstack 1 8 | IL_0000: nop 9 | IL_0001: call !!0 StaticWithGenericMethodReplacement::Method() 10 | IL_0006: pop 11 | IL_0007: ret 12 | } 13 | .method public hidebysig specialname rtspecialname 14 | instance void .ctor() cil managed 15 | { 16 | .maxstack 1 17 | IL_0000: ldarg.0 18 | IL_0001: call instance void [System.Runtime]System.Object::.ctor() 19 | IL_0006: nop 20 | IL_0007: ret 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Tests/ModuleWeaverTests.ClassWithGenericUsage.Debug.DotNet.verified.txt: -------------------------------------------------------------------------------- 1 | .class public auto ansi beforefieldinit ClassWithGenericUsage 2 | extends [System.Runtime]System.Object 3 | { 4 | .method public hidebysig instance void 5 | Method() cil managed 6 | { 7 | .maxstack 0 8 | IL_0000: nop 9 | IL_0001: call void class StaticGenericReplacement`1::SomeMethod() 10 | IL_0006: nop 11 | IL_0007: ret 12 | } 13 | .method public hidebysig specialname rtspecialname 14 | instance void .ctor() cil managed 15 | { 16 | .maxstack 1 17 | IL_0000: ldarg.0 18 | IL_0001: call instance void [System.Runtime]System.Object::.ctor() 19 | IL_0006: nop 20 | IL_0007: ret 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Tests/ModuleWeaverTests.ClassWithGenericUsage.DotNet.Debug.verified.txt: -------------------------------------------------------------------------------- 1 | .class public auto ansi beforefieldinit ClassWithGenericUsage 2 | extends [System.Runtime]System.Object 3 | { 4 | .method public hidebysig instance void 5 | Method() cil managed 6 | { 7 | .maxstack 0 8 | IL_0000: nop 9 | IL_0001: call void class StaticGenericReplacement`1::SomeMethod() 10 | IL_0006: nop 11 | IL_0007: ret 12 | } 13 | .method public hidebysig specialname rtspecialname 14 | instance void .ctor() cil managed 15 | { 16 | .maxstack 1 17 | IL_0000: ldarg.0 18 | IL_0001: call instance void [System.Runtime]System.Object::.ctor() 19 | IL_0006: nop 20 | IL_0007: ret 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Tests/ModuleWeaverTests.ClassWithGenericMethodUsage.Debug.DotNet.verified.txt: -------------------------------------------------------------------------------- 1 | .class public auto ansi beforefieldinit ClassWithGenericMethodUsage 2 | extends [System.Runtime]System.Object 3 | { 4 | .method public hidebysig instance void 5 | Method() cil managed 6 | { 7 | .maxstack 1 8 | IL_0000: nop 9 | IL_0001: call !!0 StaticWithGenericMethodReplacement::Method() 10 | IL_0006: pop 11 | IL_0007: ret 12 | } 13 | .method public hidebysig specialname rtspecialname 14 | instance void .ctor() cil managed 15 | { 16 | .maxstack 1 17 | IL_0000: ldarg.0 18 | IL_0001: call instance void [System.Runtime]System.Object::.ctor() 19 | IL_0006: nop 20 | IL_0007: ret 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Tests/ModuleWeaverTests.ClassWithGenericMethodUsage.DotNet.Debug.verified.txt: -------------------------------------------------------------------------------- 1 | .class public auto ansi beforefieldinit ClassWithGenericMethodUsage 2 | extends [System.Runtime]System.Object 3 | { 4 | .method public hidebysig instance void 5 | Method() cil managed 6 | { 7 | .maxstack 1 8 | IL_0000: nop 9 | IL_0001: call !!0 StaticWithGenericMethodReplacement::Method() 10 | IL_0006: pop 11 | IL_0007: ret 12 | } 13 | .method public hidebysig specialname rtspecialname 14 | instance void .ctor() cil managed 15 | { 16 | .maxstack 1 17 | IL_0000: ldarg.0 18 | IL_0001: call instance void [System.Runtime]System.Object::.ctor() 19 | IL_0006: nop 20 | IL_0007: ret 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /AssemblyToProcess/ClassWithOverloads.cs: -------------------------------------------------------------------------------- 1 | public class ClassWithOverloads 2 | { 3 | public int Overloaded0() 4 | { 5 | return StaticWithOverloads.Overloaded(0L); 6 | } 7 | 8 | public int Overloaded1() 9 | { 10 | return StaticWithOverloads.Overloaded(); 11 | } 12 | 13 | public int Overloaded2() 14 | { 15 | return StaticWithOverloads.Overloaded(0); 16 | } 17 | 18 | public int Overloaded3() 19 | { 20 | return StaticWithOverloads.Overloaded(""); 21 | } 22 | 23 | public Dictionary Overloaded4() 24 | { 25 | return StaticWithOverloads.Overloaded(); 26 | } 27 | 28 | public Dictionary Overloaded5() 29 | { 30 | return StaticWithOverloads.Overloaded(0, "Hello World"); 31 | } 32 | } -------------------------------------------------------------------------------- /AssemblyToProcess/StaticWithOverloads.cs: -------------------------------------------------------------------------------- 1 | public static class StaticWithOverloads 2 | { 3 | public static int Overloaded(long i) 4 | { 5 | throw new NotImplementedException(); 6 | } 7 | 8 | public static int Overloaded() 9 | { 10 | throw new NotImplementedException(); 11 | } 12 | 13 | public static int Overloaded(int i) 14 | { 15 | throw new NotImplementedException(); 16 | } 17 | 18 | public static int Overloaded(string i) 19 | { 20 | throw new NotImplementedException(); 21 | } 22 | 23 | public static Dictionary Overloaded() 24 | { 25 | throw new NotImplementedException(); 26 | } 27 | 28 | public static Dictionary Overloaded(TKey key, TValue value) 29 | { 30 | throw new NotImplementedException(); 31 | } 32 | } -------------------------------------------------------------------------------- /Tests/Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net48;net8.0 5 | true 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Ionad/Ionad.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net452;netstandard2.0;netstandard2.1 5 | true 6 | key.snk 7 | Cameron MacFarland, Simon Cropp 8 | Replaces static method calls. 9 | Static, ILWeaving, Fody, Cecil 10 | $(SolutionDir)nugets 11 | https://raw.githubusercontent.com/Fody/Ionad/master/package_icon.png 12 | MIT 13 | https://github.com/Fody/Ionad 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Tests/ModuleWeaverTests.ClassWithDateTime.Net.Release.verified.txt: -------------------------------------------------------------------------------- 1 | .class public auto ansi beforefieldinit ClassWithDateTime 2 | extends [mscorlib]System.Object 3 | { 4 | .method public hidebysig instance valuetype [mscorlib]System.DateTime 5 | GetDateTime() cil managed 6 | { 7 | .maxstack 1 8 | IL_0000: call valuetype [mscorlib]System.DateTime DateTimeReplacement::get_Now() 9 | IL_0005: ret 10 | } 11 | .method public hidebysig specialname instance valuetype [mscorlib]System.DateTime 12 | get_SomeProperty() cil managed 13 | { 14 | .maxstack 1 15 | IL_0000: call valuetype [mscorlib]System.DateTime DateTimeReplacement::get_Now() 16 | IL_0005: ret 17 | } 18 | .method public hidebysig instance valuetype [mscorlib]System.DateTime 19 | MissingReplacement() cil managed 20 | { 21 | .maxstack 1 22 | IL_0000: call valuetype [mscorlib]System.DateTime [mscorlib]System.DateTime::get_Today() 23 | IL_0005: ret 24 | } 25 | .method public hidebysig specialname rtspecialname 26 | instance void .ctor() cil managed 27 | { 28 | .maxstack 1 29 | IL_0000: ldarg.0 30 | IL_0001: call instance void [mscorlib]System.Object::.ctor() 31 | IL_0006: ret 32 | } 33 | .property instance valuetype [mscorlib]System.DateTime 34 | SomeProperty() 35 | { 36 | .get instance valuetype [mscorlib]System.DateTime ClassWithDateTime::get_SomeProperty() 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Tests/ModuleWeaverTests.ClassWithDateTime.Release.Net.verified.txt: -------------------------------------------------------------------------------- 1 | .class public auto ansi beforefieldinit ClassWithDateTime 2 | extends [mscorlib]System.Object 3 | { 4 | .method public hidebysig instance valuetype [mscorlib]System.DateTime 5 | GetDateTime() cil managed 6 | { 7 | .maxstack 1 8 | IL_0000: call valuetype [mscorlib]System.DateTime DateTimeReplacement::get_Now() 9 | IL_0005: ret 10 | } 11 | .method public hidebysig specialname instance valuetype [mscorlib]System.DateTime 12 | get_SomeProperty() cil managed 13 | { 14 | .maxstack 1 15 | IL_0000: call valuetype [mscorlib]System.DateTime DateTimeReplacement::get_Now() 16 | IL_0005: ret 17 | } 18 | .method public hidebysig instance valuetype [mscorlib]System.DateTime 19 | MissingReplacement() cil managed 20 | { 21 | .maxstack 1 22 | IL_0000: call valuetype [mscorlib]System.DateTime [mscorlib]System.DateTime::get_Today() 23 | IL_0005: ret 24 | } 25 | .method public hidebysig specialname rtspecialname 26 | instance void .ctor() cil managed 27 | { 28 | .maxstack 1 29 | IL_0000: ldarg.0 30 | IL_0001: call instance void [mscorlib]System.Object::.ctor() 31 | IL_0006: ret 32 | } 33 | .property instance valuetype [mscorlib]System.DateTime 34 | SomeProperty() 35 | { 36 | .get instance valuetype [mscorlib]System.DateTime ClassWithDateTime::get_SomeProperty() 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Tests/ModuleWeaverTests.ClassWithDateTime.Core.verified.txt: -------------------------------------------------------------------------------- 1 | .class public auto ansi beforefieldinit ClassWithDateTime 2 | extends [netstandard]System.Object 3 | { 4 | .method public hidebysig instance valuetype [netstandard]System.DateTime 5 | GetDateTime() cil managed 6 | { 7 | .maxstack 1 8 | IL_0000: call valuetype [netstandard]System.DateTime DateTimeReplacement::get_Now() 9 | IL_0005: ret 10 | } 11 | .method public hidebysig specialname instance valuetype [netstandard]System.DateTime 12 | get_SomeProperty() cil managed 13 | { 14 | .maxstack 1 15 | IL_0000: call valuetype [netstandard]System.DateTime DateTimeReplacement::get_Now() 16 | IL_0005: ret 17 | } 18 | .method public hidebysig instance valuetype [netstandard]System.DateTime 19 | MissingReplacement() cil managed 20 | { 21 | .maxstack 1 22 | IL_0000: call valuetype [netstandard]System.DateTime [netstandard]System.DateTime::get_Today() 23 | IL_0005: ret 24 | } 25 | .method public hidebysig specialname rtspecialname 26 | instance void .ctor() cil managed 27 | { 28 | .maxstack 1 29 | IL_0000: ldarg.0 30 | IL_0001: call instance void [netstandard]System.Object::.ctor() 31 | IL_0006: ret 32 | } 33 | .property instance valuetype [netstandard]System.DateTime 34 | SomeProperty() 35 | { 36 | .get instance valuetype [netstandard]System.DateTime ClassWithDateTime::get_SomeProperty() 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Tests/ModuleWeaverTests.ClassWithDateTime.DotNet.Release.verified.txt: -------------------------------------------------------------------------------- 1 | .class public auto ansi beforefieldinit ClassWithDateTime 2 | extends [System.Runtime]System.Object 3 | { 4 | .method public hidebysig instance valuetype [System.Runtime]System.DateTime 5 | GetDateTime() cil managed 6 | { 7 | .maxstack 1 8 | IL_0000: call valuetype [System.Runtime]System.DateTime DateTimeReplacement::get_Now() 9 | IL_0005: ret 10 | } 11 | .method public hidebysig specialname instance valuetype [System.Runtime]System.DateTime 12 | get_SomeProperty() cil managed 13 | { 14 | .maxstack 1 15 | IL_0000: call valuetype [System.Runtime]System.DateTime DateTimeReplacement::get_Now() 16 | IL_0005: ret 17 | } 18 | .method public hidebysig instance valuetype [System.Runtime]System.DateTime 19 | MissingReplacement() cil managed 20 | { 21 | .maxstack 1 22 | IL_0000: call valuetype [System.Runtime]System.DateTime [System.Runtime]System.DateTime::get_Today() 23 | IL_0005: ret 24 | } 25 | .method public hidebysig specialname rtspecialname 26 | instance void .ctor() cil managed 27 | { 28 | .maxstack 1 29 | IL_0000: ldarg.0 30 | IL_0001: call instance void [System.Runtime]System.Object::.ctor() 31 | IL_0006: ret 32 | } 33 | .property instance valuetype [System.Runtime]System.DateTime 34 | SomeProperty() 35 | { 36 | .get instance valuetype [System.Runtime]System.DateTime ClassWithDateTime::get_SomeProperty() 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Tests/ModuleWeaverTests.ClassWithDateTime.Release.DotNet.verified.txt: -------------------------------------------------------------------------------- 1 | .class public auto ansi beforefieldinit ClassWithDateTime 2 | extends [System.Runtime]System.Object 3 | { 4 | .method public hidebysig instance valuetype [System.Runtime]System.DateTime 5 | GetDateTime() cil managed 6 | { 7 | .maxstack 1 8 | IL_0000: call valuetype [System.Runtime]System.DateTime DateTimeReplacement::get_Now() 9 | IL_0005: ret 10 | } 11 | .method public hidebysig specialname instance valuetype [System.Runtime]System.DateTime 12 | get_SomeProperty() cil managed 13 | { 14 | .maxstack 1 15 | IL_0000: call valuetype [System.Runtime]System.DateTime DateTimeReplacement::get_Now() 16 | IL_0005: ret 17 | } 18 | .method public hidebysig instance valuetype [System.Runtime]System.DateTime 19 | MissingReplacement() cil managed 20 | { 21 | .maxstack 1 22 | IL_0000: call valuetype [System.Runtime]System.DateTime [System.Runtime]System.DateTime::get_Today() 23 | IL_0005: ret 24 | } 25 | .method public hidebysig specialname rtspecialname 26 | instance void .ctor() cil managed 27 | { 28 | .maxstack 1 29 | IL_0000: ldarg.0 30 | IL_0001: call instance void [System.Runtime]System.Object::.ctor() 31 | IL_0006: ret 32 | } 33 | .property instance valuetype [System.Runtime]System.DateTime 34 | SomeProperty() 35 | { 36 | .get instance valuetype [System.Runtime]System.DateTime ClassWithDateTime::get_SomeProperty() 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Tests/ModuleWeaverTests.ClassWithDateTime.Net.verified.txt: -------------------------------------------------------------------------------- 1 | .class public auto ansi beforefieldinit ClassWithDateTime 2 | extends [mscorlib]System.Object 3 | { 4 | .method public hidebysig instance valuetype [mscorlib]System.DateTime 5 | GetDateTime() cil managed 6 | { 7 | .maxstack 1 8 | .locals init (valuetype [mscorlib]System.DateTime V_0) 9 | IL_0000: nop 10 | IL_0001: call valuetype [mscorlib]System.DateTime DateTimeReplacement::get_Now() 11 | IL_0006: stloc.0 12 | IL_0007: br.s IL_0009 13 | IL_0009: ldloc.0 14 | IL_000a: ret 15 | } 16 | .method public hidebysig specialname instance valuetype [mscorlib]System.DateTime 17 | get_SomeProperty() cil managed 18 | { 19 | .maxstack 1 20 | IL_0000: call valuetype [mscorlib]System.DateTime DateTimeReplacement::get_Now() 21 | IL_0005: ret 22 | } 23 | .method public hidebysig instance valuetype [mscorlib]System.DateTime 24 | MissingReplacement() cil managed 25 | { 26 | .maxstack 1 27 | .locals init (valuetype [mscorlib]System.DateTime V_0) 28 | IL_0000: nop 29 | IL_0001: call valuetype [mscorlib]System.DateTime [mscorlib]System.DateTime::get_Today() 30 | IL_0006: stloc.0 31 | IL_0007: br.s IL_0009 32 | IL_0009: ldloc.0 33 | IL_000a: ret 34 | } 35 | .method public hidebysig specialname rtspecialname 36 | instance void .ctor() cil managed 37 | { 38 | .maxstack 1 39 | IL_0000: ldarg.0 40 | IL_0001: call instance void [mscorlib]System.Object::.ctor() 41 | IL_0006: nop 42 | IL_0007: ret 43 | } 44 | .property instance valuetype [mscorlib]System.DateTime 45 | SomeProperty() 46 | { 47 | .get instance valuetype [mscorlib]System.DateTime ClassWithDateTime::get_SomeProperty() 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Tests/ModuleWeaverTests.ClassWithDateTime.Debug.Net.verified.txt: -------------------------------------------------------------------------------- 1 | .class public auto ansi beforefieldinit ClassWithDateTime 2 | extends [mscorlib]System.Object 3 | { 4 | .method public hidebysig instance valuetype [mscorlib]System.DateTime 5 | GetDateTime() cil managed 6 | { 7 | .maxstack 1 8 | .locals init (valuetype [mscorlib]System.DateTime V_0) 9 | IL_0000: nop 10 | IL_0001: call valuetype [mscorlib]System.DateTime DateTimeReplacement::get_Now() 11 | IL_0006: stloc.0 12 | IL_0007: br.s IL_0009 13 | IL_0009: ldloc.0 14 | IL_000a: ret 15 | } 16 | .method public hidebysig specialname instance valuetype [mscorlib]System.DateTime 17 | get_SomeProperty() cil managed 18 | { 19 | .maxstack 1 20 | IL_0000: call valuetype [mscorlib]System.DateTime DateTimeReplacement::get_Now() 21 | IL_0005: ret 22 | } 23 | .method public hidebysig instance valuetype [mscorlib]System.DateTime 24 | MissingReplacement() cil managed 25 | { 26 | .maxstack 1 27 | .locals init (valuetype [mscorlib]System.DateTime V_0) 28 | IL_0000: nop 29 | IL_0001: call valuetype [mscorlib]System.DateTime [mscorlib]System.DateTime::get_Today() 30 | IL_0006: stloc.0 31 | IL_0007: br.s IL_0009 32 | IL_0009: ldloc.0 33 | IL_000a: ret 34 | } 35 | .method public hidebysig specialname rtspecialname 36 | instance void .ctor() cil managed 37 | { 38 | .maxstack 1 39 | IL_0000: ldarg.0 40 | IL_0001: call instance void [mscorlib]System.Object::.ctor() 41 | IL_0006: nop 42 | IL_0007: ret 43 | } 44 | .property instance valuetype [mscorlib]System.DateTime 45 | SomeProperty() 46 | { 47 | .get instance valuetype [mscorlib]System.DateTime ClassWithDateTime::get_SomeProperty() 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Tests/ModuleWeaverTests.ClassWithDateTime.Net.Debug.verified.txt: -------------------------------------------------------------------------------- 1 | .class public auto ansi beforefieldinit ClassWithDateTime 2 | extends [mscorlib]System.Object 3 | { 4 | .method public hidebysig instance valuetype [mscorlib]System.DateTime 5 | GetDateTime() cil managed 6 | { 7 | .maxstack 1 8 | .locals init (valuetype [mscorlib]System.DateTime V_0) 9 | IL_0000: nop 10 | IL_0001: call valuetype [mscorlib]System.DateTime DateTimeReplacement::get_Now() 11 | IL_0006: stloc.0 12 | IL_0007: br.s IL_0009 13 | IL_0009: ldloc.0 14 | IL_000a: ret 15 | } 16 | .method public hidebysig specialname instance valuetype [mscorlib]System.DateTime 17 | get_SomeProperty() cil managed 18 | { 19 | .maxstack 1 20 | IL_0000: call valuetype [mscorlib]System.DateTime DateTimeReplacement::get_Now() 21 | IL_0005: ret 22 | } 23 | .method public hidebysig instance valuetype [mscorlib]System.DateTime 24 | MissingReplacement() cil managed 25 | { 26 | .maxstack 1 27 | .locals init (valuetype [mscorlib]System.DateTime V_0) 28 | IL_0000: nop 29 | IL_0001: call valuetype [mscorlib]System.DateTime [mscorlib]System.DateTime::get_Today() 30 | IL_0006: stloc.0 31 | IL_0007: br.s IL_0009 32 | IL_0009: ldloc.0 33 | IL_000a: ret 34 | } 35 | .method public hidebysig specialname rtspecialname 36 | instance void .ctor() cil managed 37 | { 38 | .maxstack 1 39 | IL_0000: ldarg.0 40 | IL_0001: call instance void [mscorlib]System.Object::.ctor() 41 | IL_0006: nop 42 | IL_0007: ret 43 | } 44 | .property instance valuetype [mscorlib]System.DateTime 45 | SomeProperty() 46 | { 47 | .get instance valuetype [mscorlib]System.DateTime ClassWithDateTime::get_SomeProperty() 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Tests/ModuleWeaverTests.ClassWithDateTime.DotNet.verified.txt: -------------------------------------------------------------------------------- 1 | .class public auto ansi beforefieldinit ClassWithDateTime 2 | extends [System.Runtime]System.Object 3 | { 4 | .method public hidebysig instance valuetype [System.Runtime]System.DateTime 5 | GetDateTime() cil managed 6 | { 7 | .maxstack 1 8 | .locals init (valuetype [System.Runtime]System.DateTime V_0) 9 | IL_0000: nop 10 | IL_0001: call valuetype [System.Runtime]System.DateTime DateTimeReplacement::get_Now() 11 | IL_0006: stloc.0 12 | IL_0007: br.s IL_0009 13 | IL_0009: ldloc.0 14 | IL_000a: ret 15 | } 16 | .method public hidebysig specialname instance valuetype [System.Runtime]System.DateTime 17 | get_SomeProperty() cil managed 18 | { 19 | .maxstack 1 20 | IL_0000: call valuetype [System.Runtime]System.DateTime DateTimeReplacement::get_Now() 21 | IL_0005: ret 22 | } 23 | .method public hidebysig instance valuetype [System.Runtime]System.DateTime 24 | MissingReplacement() cil managed 25 | { 26 | .maxstack 1 27 | .locals init (valuetype [System.Runtime]System.DateTime V_0) 28 | IL_0000: nop 29 | IL_0001: call valuetype [System.Runtime]System.DateTime [System.Runtime]System.DateTime::get_Today() 30 | IL_0006: stloc.0 31 | IL_0007: br.s IL_0009 32 | IL_0009: ldloc.0 33 | IL_000a: ret 34 | } 35 | .method public hidebysig specialname rtspecialname 36 | instance void .ctor() cil managed 37 | { 38 | .maxstack 1 39 | IL_0000: ldarg.0 40 | IL_0001: call instance void [System.Runtime]System.Object::.ctor() 41 | IL_0006: nop 42 | IL_0007: ret 43 | } 44 | .property instance valuetype [System.Runtime]System.DateTime 45 | SomeProperty() 46 | { 47 | .get instance valuetype [System.Runtime]System.DateTime ClassWithDateTime::get_SomeProperty() 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Tests/ModuleWeaverTests.ClassWithDateTime.Debug.DotNet.verified.txt: -------------------------------------------------------------------------------- 1 | .class public auto ansi beforefieldinit ClassWithDateTime 2 | extends [System.Runtime]System.Object 3 | { 4 | .method public hidebysig instance valuetype [System.Runtime]System.DateTime 5 | GetDateTime() cil managed 6 | { 7 | .maxstack 1 8 | .locals init (valuetype [System.Runtime]System.DateTime V_0) 9 | IL_0000: nop 10 | IL_0001: call valuetype [System.Runtime]System.DateTime DateTimeReplacement::get_Now() 11 | IL_0006: stloc.0 12 | IL_0007: br.s IL_0009 13 | IL_0009: ldloc.0 14 | IL_000a: ret 15 | } 16 | .method public hidebysig specialname instance valuetype [System.Runtime]System.DateTime 17 | get_SomeProperty() cil managed 18 | { 19 | .maxstack 1 20 | IL_0000: call valuetype [System.Runtime]System.DateTime DateTimeReplacement::get_Now() 21 | IL_0005: ret 22 | } 23 | .method public hidebysig instance valuetype [System.Runtime]System.DateTime 24 | MissingReplacement() cil managed 25 | { 26 | .maxstack 1 27 | .locals init (valuetype [System.Runtime]System.DateTime V_0) 28 | IL_0000: nop 29 | IL_0001: call valuetype [System.Runtime]System.DateTime [System.Runtime]System.DateTime::get_Today() 30 | IL_0006: stloc.0 31 | IL_0007: br.s IL_0009 32 | IL_0009: ldloc.0 33 | IL_000a: ret 34 | } 35 | .method public hidebysig specialname rtspecialname 36 | instance void .ctor() cil managed 37 | { 38 | .maxstack 1 39 | IL_0000: ldarg.0 40 | IL_0001: call instance void [System.Runtime]System.Object::.ctor() 41 | IL_0006: nop 42 | IL_0007: ret 43 | } 44 | .property instance valuetype [System.Runtime]System.DateTime 45 | SomeProperty() 46 | { 47 | .get instance valuetype [System.Runtime]System.DateTime ClassWithDateTime::get_SomeProperty() 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Tests/ModuleWeaverTests.ClassWithDateTime.DotNet.Debug.verified.txt: -------------------------------------------------------------------------------- 1 | .class public auto ansi beforefieldinit ClassWithDateTime 2 | extends [System.Runtime]System.Object 3 | { 4 | .method public hidebysig instance valuetype [System.Runtime]System.DateTime 5 | GetDateTime() cil managed 6 | { 7 | .maxstack 1 8 | .locals init (valuetype [System.Runtime]System.DateTime V_0) 9 | IL_0000: nop 10 | IL_0001: call valuetype [System.Runtime]System.DateTime DateTimeReplacement::get_Now() 11 | IL_0006: stloc.0 12 | IL_0007: br.s IL_0009 13 | IL_0009: ldloc.0 14 | IL_000a: ret 15 | } 16 | .method public hidebysig specialname instance valuetype [System.Runtime]System.DateTime 17 | get_SomeProperty() cil managed 18 | { 19 | .maxstack 1 20 | IL_0000: call valuetype [System.Runtime]System.DateTime DateTimeReplacement::get_Now() 21 | IL_0005: ret 22 | } 23 | .method public hidebysig instance valuetype [System.Runtime]System.DateTime 24 | MissingReplacement() cil managed 25 | { 26 | .maxstack 1 27 | .locals init (valuetype [System.Runtime]System.DateTime V_0) 28 | IL_0000: nop 29 | IL_0001: call valuetype [System.Runtime]System.DateTime [System.Runtime]System.DateTime::get_Today() 30 | IL_0006: stloc.0 31 | IL_0007: br.s IL_0009 32 | IL_0009: ldloc.0 33 | IL_000a: ret 34 | } 35 | .method public hidebysig specialname rtspecialname 36 | instance void .ctor() cil managed 37 | { 38 | .maxstack 1 39 | IL_0000: ldarg.0 40 | IL_0001: call instance void [System.Runtime]System.Object::.ctor() 41 | IL_0006: nop 42 | IL_0007: ret 43 | } 44 | .property instance valuetype [System.Runtime]System.DateTime 45 | SomeProperty() 46 | { 47 | .get instance valuetype [System.Runtime]System.DateTime ClassWithDateTime::get_SomeProperty() 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /AssemblyToProcess/StaticWithBaseAccessReplacement.cs: -------------------------------------------------------------------------------- 1 | using Ionad; 2 | 3 | [StaticReplacement(typeof(StaticWithBaseAccess))] 4 | public static class StaticWithBaseAccessReplacement 5 | { 6 | public static int ReplacedCount 7 | { 8 | get 9 | { 10 | using(ThrowOnRecursion.Check()) 11 | { 12 | return StaticWithBaseAccess.ReplacedCount + 1; 13 | } 14 | } 15 | } 16 | 17 | public static IEnumerable YieldMethod() 18 | { 19 | using(ThrowOnRecursion.Check()) 20 | { 21 | foreach (var i in StaticWithBaseAccess.YieldMethod()) 22 | { 23 | yield return i + 10; 24 | } 25 | } 26 | } 27 | 28 | public static Task LambdaReplacementMethod() 29 | { 30 | using(ThrowOnRecursion.Check()) 31 | { 32 | return Task.Run(async () => await StaticWithBaseAccess.LambdaReplacementMethod() + 1); 33 | } 34 | } 35 | 36 | public static async Task AsyncMethod() 37 | { 38 | await Task.Delay(1); 39 | return await StaticWithBaseAccess.AsyncMethod() + 1; 40 | } 41 | } 42 | 43 | public static class ThrowOnRecursion 44 | { 45 | static AsyncLocal CallCount = new(); 46 | 47 | public static IDisposable Check() 48 | { 49 | if (CallCount.Value == 0) 50 | { 51 | CallCount.Value++; 52 | return new ExitRecursion(); 53 | 54 | } 55 | 56 | throw new InvalidOperationException("Recursion detected"); 57 | } 58 | 59 | class ExitRecursion : 60 | IDisposable 61 | { 62 | public void Dispose() 63 | { 64 | CallCount.Value--; 65 | } 66 | } 67 | } -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Ionad.Fody 2 | 3 | [![NuGet Status](https://img.shields.io/nuget/v/Ionad.Fody.svg)](https://www.nuget.org/packages/Ionad.Fody/) 4 | 5 | Ionad replaces static types with your own. 6 | 7 | **See [Milestones](../../milestones?state=closed) for release notes.** 8 | 9 | 10 | ### This is an add-in for [Fody](https://github.com/Fody/Home/) 11 | 12 | **It is expected that all developers using Fody [become a Patron on OpenCollective](https://opencollective.com/fody/contribute/patron-3059). [See Licensing/Patron FAQ](https://github.com/Fody/Home/blob/master/pages/licensing-patron-faq.md) for more information.** 13 | 14 | 15 | ## Usage 16 | 17 | See also [Fody usage](https://github.com/Fody/Home/blob/master/pages/usage.md). 18 | 19 | 20 | ### NuGet installation 21 | 22 | Install the [Ionad.Fody NuGet package](https://nuget.org/packages/Ionad.Fody/) and update the [Fody NuGet package](https://nuget.org/packages/Fody/): 23 | 24 | ```powershell 25 | PM> Install-Package Fody 26 | PM> Install-Package Ionad.Fody 27 | ``` 28 | 29 | The `Install-Package Fody` is required since NuGet always defaults to the oldest, and most buggy, version of any dependency. 30 | 31 | 32 | ### Your Code 33 | 34 | ```csharp 35 | [StaticReplacement(typeof(DateTime))] 36 | public static class DateTimeSubstitute 37 | { 38 | public static IDateTime Current { get; set; } 39 | 40 | public static DateTime Now { get { return Current.Now; } } 41 | } 42 | 43 | public void SomeMethod() 44 | { 45 | var time = DateTime.Now; 46 | // ... 47 | } 48 | ``` 49 | 50 | 51 | ### What gets compiled 52 | 53 | ```csharp 54 | public void SomeMethod() 55 | { 56 | var time = DateTimeSubstitute.Now; 57 | // ... 58 | } 59 | ``` 60 | 61 | You can also reference methods within the original static class to add defaults to optional parameters. For example: 62 | 63 | ```csharp 64 | [StaticReplacement(typeof(System.Reactive.Linq.Observable))] 65 | public static class QueryableSubstitute 66 | { 67 | public static IObservable> Delay(this IObservable source, TimeSpan timeSpan) 68 | { 69 | return Linq.Delay(source, timeSpan, RxApp.TaskpoolScheduler); 70 | } 71 | } 72 | 73 | public async Task SomeMethod() 74 | { 75 | return await Observable.Return(1).Delay(TimeSpan.FromSeconds(1)).ToTask(); 76 | } 77 | ``` 78 | 79 | 80 | ### What gets compiled 81 | 82 | ```csharp 83 | public async Task SomeMethod() 84 | { 85 | return await Observable.Return(1).Delay(TimeSpan.FromSeconds(1), RxApp.TaskpoolScheduler).ToTask(); 86 | } 87 | ``` 88 | 89 | 90 | ## Icon 91 | 92 | [Interchange](https://thenounproject.com/noun/interchange/#icon-No2031) designed by [Laurent Patain](https://thenounproject.com/____Lo) from [The Noun Project](https://thenounproject.com). 93 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig: http://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | [*] 7 | indent_style = space 8 | 9 | [*.cs] 10 | indent_size = 4 11 | 12 | # Sort using and Import directives with System.* appearing first 13 | dotnet_sort_system_directives_first = true 14 | 15 | # Avoid "this." and "Me." if not necessary 16 | dotnet_style_qualification_for_field = false:error 17 | dotnet_style_qualification_for_property = false:error 18 | dotnet_style_qualification_for_method = false:error 19 | dotnet_style_qualification_for_event = false:error 20 | 21 | # Use language keywords instead of framework type names for type references 22 | dotnet_style_predefined_type_for_locals_parameters_members = true:error 23 | dotnet_style_predefined_type_for_member_access = true:error 24 | 25 | # Suggest more modern language features when available 26 | dotnet_style_object_initializer = true:suggestion 27 | dotnet_style_collection_initializer = true:suggestion 28 | dotnet_style_coalesce_expression = false:suggestion 29 | dotnet_style_null_propagation = true:suggestion 30 | dotnet_style_explicit_tuple_names = true:suggestion 31 | 32 | # Prefer "var" everywhere 33 | csharp_style_var_for_built_in_types = true:error 34 | csharp_style_var_when_type_is_apparent = true:error 35 | csharp_style_var_elsewhere = true:error 36 | 37 | # Prefer method-like constructs to have a block body 38 | csharp_style_expression_bodied_methods = false:none 39 | csharp_style_expression_bodied_constructors = false:none 40 | csharp_style_expression_bodied_operators = false:none 41 | 42 | # Prefer property-like constructs to have an expression-body 43 | csharp_style_expression_bodied_properties = true:suggestion 44 | csharp_style_expression_bodied_indexers = true:suggestion 45 | csharp_style_expression_bodied_accessors = true:none 46 | 47 | # Suggest more modern language features when available 48 | csharp_style_pattern_matching_over_is_with_cast_check = true:error 49 | csharp_style_pattern_matching_over_as_with_null_check = true:error 50 | csharp_style_inlined_variable_declaration = true:suggestion 51 | csharp_style_throw_expression = true:suggestion 52 | csharp_style_conditional_delegate_call = true:suggestion 53 | 54 | # Newline settings 55 | #csharp_new_line_before_open_brace = all:error 56 | csharp_new_line_before_else = true 57 | csharp_new_line_before_catch = true 58 | csharp_new_line_before_finally = true 59 | csharp_new_line_before_members_in_object_initializers = true 60 | csharp_new_line_before_members_in_anonymous_types = true 61 | 62 | #braces 63 | #csharp_prefer_braces = true:error 64 | 65 | # msbuild 66 | [*.{csproj,targets,props}] 67 | indent_size = 2 68 | 69 | # Xml files 70 | [*.{xml,config,nuspec,resx,vsixmanifest}] 71 | indent_size = 2 72 | resharper_xml_wrap_tags_and_pi = true:error 73 | 74 | # JSON files 75 | [*.json] 76 | indent_size = 2 77 | -------------------------------------------------------------------------------- /Ionad.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 12.00 2 | # Visual Studio Version 16 3 | VisualStudioVersion = 16.0.29201.188 4 | MinimumVisualStudioVersion = 16.0.29201.188 5 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ionad.Fody", "Ionad.Fody\Ionad.Fody.csproj", "{CD3BB09A-7217-4409-B8D9-D33194048271}" 6 | EndProject 7 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AssemblyToProcess", "AssemblyToProcess\AssemblyToProcess.csproj", "{A99FCE99-5109-4082-A20B-CD60385C5E18}" 8 | EndProject 9 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tests", "Tests\Tests.csproj", "{204C7356-4534-4961-988B-DE09DA3956D8}" 10 | EndProject 11 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ionad", "Ionad\Ionad.csproj", "{6A65A688-9C9B-4422-B70D-4662F6D2A6A9}" 12 | ProjectSection(ProjectDependencies) = postProject 13 | {CD3BB09A-7217-4409-B8D9-D33194048271} = {CD3BB09A-7217-4409-B8D9-D33194048271} 14 | EndProjectSection 15 | EndProject 16 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{5F7A2A58-E5A9-426E-B54C-0179D7FF49BE}" 17 | ProjectSection(SolutionItems) = preProject 18 | Directory.Build.props = Directory.Build.props 19 | EndProjectSection 20 | EndProject 21 | Global 22 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 23 | Debug|Any CPU = Debug|Any CPU 24 | Release|Any CPU = Release|Any CPU 25 | EndGlobalSection 26 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 27 | {CD3BB09A-7217-4409-B8D9-D33194048271}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 28 | {CD3BB09A-7217-4409-B8D9-D33194048271}.Debug|Any CPU.Build.0 = Debug|Any CPU 29 | {CD3BB09A-7217-4409-B8D9-D33194048271}.Release|Any CPU.ActiveCfg = Release|Any CPU 30 | {CD3BB09A-7217-4409-B8D9-D33194048271}.Release|Any CPU.Build.0 = Release|Any CPU 31 | {A99FCE99-5109-4082-A20B-CD60385C5E18}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 32 | {A99FCE99-5109-4082-A20B-CD60385C5E18}.Debug|Any CPU.Build.0 = Debug|Any CPU 33 | {A99FCE99-5109-4082-A20B-CD60385C5E18}.Release|Any CPU.ActiveCfg = Release|Any CPU 34 | {A99FCE99-5109-4082-A20B-CD60385C5E18}.Release|Any CPU.Build.0 = Release|Any CPU 35 | {204C7356-4534-4961-988B-DE09DA3956D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 36 | {204C7356-4534-4961-988B-DE09DA3956D8}.Debug|Any CPU.Build.0 = Debug|Any CPU 37 | {204C7356-4534-4961-988B-DE09DA3956D8}.Release|Any CPU.ActiveCfg = Release|Any CPU 38 | {204C7356-4534-4961-988B-DE09DA3956D8}.Release|Any CPU.Build.0 = Release|Any CPU 39 | {6A65A688-9C9B-4422-B70D-4662F6D2A6A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 40 | {6A65A688-9C9B-4422-B70D-4662F6D2A6A9}.Debug|Any CPU.Build.0 = Debug|Any CPU 41 | {6A65A688-9C9B-4422-B70D-4662F6D2A6A9}.Release|Any CPU.ActiveCfg = Release|Any CPU 42 | {6A65A688-9C9B-4422-B70D-4662F6D2A6A9}.Release|Any CPU.Build.0 = Release|Any CPU 43 | EndGlobalSection 44 | GlobalSection(SolutionProperties) = preSolution 45 | HideSolutionNode = FALSE 46 | EndGlobalSection 47 | GlobalSection(ExtensibilityGlobals) = postSolution 48 | SolutionGuid = {A46FB18B-3E64-45AE-8D15-DBA5AE52D1D0} 49 | EndGlobalSection 50 | EndGlobal 51 | -------------------------------------------------------------------------------- /Ionad.Fody/CecilExtensions.cs: -------------------------------------------------------------------------------- 1 | using Mono.Cecil; 2 | 3 | public static class CecilExtensions 4 | { 5 | public static void RemoveStaticReplacementAttribute(this ICustomAttributeProvider definition) 6 | { 7 | var customAttributes = definition.CustomAttributes; 8 | 9 | var attribute = customAttributes.FirstOrDefault(_ => _.AttributeType.Name == "StaticReplacementAttribute"); 10 | 11 | if (attribute != null) 12 | { 13 | customAttributes.Remove(attribute); 14 | } 15 | } 16 | 17 | public static CustomAttribute GetStaticReplacementAttribute(this ICustomAttributeProvider value) => 18 | value.CustomAttributes.FirstOrDefault(a => a.AttributeType.Name == "StaticReplacementAttribute"); 19 | 20 | public static IEnumerable MethodsWithBody(this TypeDefinition type) => 21 | type.Methods.Where(_ => _.Body != null); 22 | 23 | public static IEnumerable ConcreteProperties(this TypeDefinition type) => 24 | type.Properties.Where(x => (x.GetMethod == null || !x.GetMethod.IsAbstract) && (x.SetMethod == null || !x.SetMethod.IsAbstract)); 25 | 26 | static MethodReference CloneMethodWithDeclaringType(MethodDefinition methodDef, TypeReference declaringTypeRef) 27 | { 28 | if (!declaringTypeRef.IsGenericInstance || methodDef == null) 29 | { 30 | return methodDef; 31 | } 32 | 33 | var methodRef = new MethodReference(methodDef.Name, methodDef.ReturnType, declaringTypeRef) 34 | { 35 | CallingConvention = methodDef.CallingConvention, 36 | HasThis = methodDef.HasThis, 37 | ExplicitThis = methodDef.ExplicitThis 38 | }; 39 | 40 | foreach (var paramDef in methodDef.Parameters) 41 | { 42 | methodRef.Parameters.Add(new(paramDef.Name, paramDef.Attributes, paramDef.ParameterType)); 43 | } 44 | 45 | foreach (var genParamDef in methodDef.GenericParameters) 46 | { 47 | methodRef.GenericParameters.Add(new(genParamDef.Name, methodRef)); 48 | } 49 | 50 | return methodRef; 51 | } 52 | 53 | public static MethodReference ReferenceMethod(this TypeReference typeRef, Func methodSelector) => 54 | CloneMethodWithDeclaringType(typeRef.Resolve().Methods.FirstOrDefault(methodSelector), typeRef); 55 | 56 | public static MethodReference ReferenceMethod(this TypeReference typeRef, MethodDefinition method) => 57 | ReferenceMethod( 58 | typeRef, 59 | _ => _.Name == method.Name && Matches(_, method) 60 | ); 61 | 62 | static bool Matches(IMethodSignature left, IMethodSignature right) => 63 | ReturnMatches(left, right) && 64 | left.Parameters.Count == right.Parameters.Count && 65 | left.Parameters.Zip(right.Parameters, Matches).All(_ => _); 66 | 67 | static bool Matches(ParameterDefinition left, ParameterDefinition right) => 68 | left.ParameterType == right.ParameterType || 69 | left.ParameterType.IsGenericParameter && 70 | right.ParameterType.IsGenericParameter; 71 | 72 | static bool Matches(TypeReference left, TypeReference right) => 73 | left.FullName == right.FullName || 74 | left.IsGenericParameter && 75 | right.IsGenericParameter; 76 | 77 | static bool ReturnMatches(IMethodSignature left, IMethodSignature right) => 78 | left.ReturnType.FullName == right.ReturnType.FullName && 79 | left.ReturnType.GenericParameters.Zip(right.ReturnType.GenericParameters, Matches).All(_ => _) || left.ReturnType.IsGenericParameter && right.ReturnType.IsGenericParameter; 80 | } -------------------------------------------------------------------------------- /Tests/ModuleWeaverTests.cs: -------------------------------------------------------------------------------- 1 | using Fody; 2 | #pragma warning disable CS0618 3 | 4 | public class ModuleWeaverTests 5 | { 6 | static TestResult testResult; 7 | 8 | static VerifySettings settings; 9 | 10 | static ModuleWeaverTests() 11 | { 12 | var weaver = new ModuleWeaver(); 13 | testResult = weaver.ExecuteTestRun("AssemblyToProcess.dll"); 14 | settings = new(); 15 | settings.UniqueForRuntime(); 16 | settings.UniqueForAssemblyConfiguration(); 17 | } 18 | 19 | [Fact] 20 | public Task ClassWithBrokenReplacement() => 21 | Verify(Ildasm.Decompile(testResult.AssemblyPath, "ClassWithBrokenReplacement"), settings); 22 | 23 | [Fact] 24 | public Task ClassWithDateTime() => 25 | Verify(Ildasm.Decompile(testResult.AssemblyPath, "ClassWithDateTime"), settings); 26 | 27 | [Fact] 28 | public Task ClassWithGenericMethodUsage() => 29 | Verify(Ildasm.Decompile(testResult.AssemblyPath, "ClassWithGenericMethodUsage"), settings); 30 | 31 | [Fact] 32 | public Task ClassWithGenericUsage() => 33 | Verify(Ildasm.Decompile(testResult.AssemblyPath, "ClassWithGenericUsage"), settings); 34 | 35 | [Fact] 36 | public void EnsureHasCanAccessBaseMethodsWithoutStackOverflow() 37 | { 38 | var instance = testResult.GetInstance("ClassWithBaseAccess"); 39 | Assert.Equal(1, instance.ReplacedCount); 40 | } 41 | 42 | [Fact] 43 | public void EnsureHasCanAccessBaseMethodsWithinAYield() 44 | { 45 | var instance = testResult.GetInstance("ClassWithBaseAccess"); 46 | Assert.Equal(Enumerable.Range(10, 10), instance.Yield); 47 | } 48 | 49 | [Fact] 50 | public async Task EnsureHasCanAccessBaseMethodViaLambda() 51 | { 52 | var instance = testResult.GetInstance("ClassWithBaseAccess"); 53 | Assert.Equal(1, await instance.AsyncWithLambdaReplacement); 54 | } 55 | 56 | [Fact] 57 | public async Task EnsureHasCanAccessBaseMethodWorksWithAsyncDecoration() 58 | { 59 | var instance = testResult.GetInstance("ClassWithBaseAccess"); 60 | Assert.Equal(1, await instance.AsyncDecorator); 61 | } 62 | 63 | [Fact] 64 | public void EnsureErrorReported() => 65 | Assert.Contains("Replacement method 'System.Void StaticBasicReplacementWithBrokenMethod::SomeMethod()' is not static", testResult.Errors.Select(_ => _.Text)); 66 | 67 | [Fact] 68 | public void MethodUsesDateTime() 69 | { 70 | var sample = testResult.GetInstance("ClassWithDateTime"); 71 | var now = sample.GetDateTime(); 72 | Assert.Equal(new DateTime(1978, 1, 13), now); 73 | } 74 | 75 | [Fact] 76 | public void PropertyUsesDateTime() 77 | { 78 | var sample = testResult.GetInstance("ClassWithDateTime"); 79 | var now = sample.SomeProperty; 80 | Assert.Equal(new DateTime(1978, 1, 13), now); 81 | } 82 | 83 | [Fact] 84 | public void MissingReplacementReportsError() => 85 | Assert.Contains("Missing 'System.DateTime.get_Today()' in 'DateTimeReplacement'", testResult.Errors.Select(_ => _.Text)); 86 | 87 | [Fact] 88 | public void EnsureGenericHasBeenReplace() 89 | { 90 | var instance = testResult.GetInstance("ClassWithGenericMethodUsage"); 91 | instance.Method(); 92 | } 93 | 94 | [Fact] 95 | public void EnsureFirstOverloadWithGetsReplaced() 96 | { 97 | var instance = testResult.GetInstance("ClassWithOverloads"); 98 | Assert.Equal(-1, instance.Overloaded0()); 99 | } 100 | 101 | [Fact] 102 | public void EnsureOverloadWithNoArgumentsWorks() 103 | { 104 | var instance = testResult.GetInstance("ClassWithOverloads"); 105 | Assert.Equal(0, instance.Overloaded1()); 106 | } 107 | 108 | [Fact] 109 | public void EnsureOverloadWithWithDifferentTypeWorks() 110 | { 111 | var instance = testResult.GetInstance("ClassWithOverloads"); 112 | Assert.Equal(1, instance.Overloaded2()); 113 | } 114 | 115 | [Fact] 116 | public void EnsureOverloadWithWithDifferentStringWorks() 117 | { 118 | var instance = testResult.GetInstance("ClassWithOverloads"); 119 | Assert.Equal(2, instance.Overloaded3()); 120 | } 121 | 122 | [Fact] 123 | public void EnsureOverloadGenericReturn() 124 | { 125 | var instance = testResult.GetInstance("ClassWithOverloads"); 126 | var ret = instance.Overloaded4(); 127 | Assert.Equal(0, ret.Count); 128 | } 129 | 130 | [Fact] 131 | public void EnsureOverloadGenericParamAndReturn() 132 | { 133 | var instance = testResult.GetInstance("ClassWithOverloads"); 134 | var ret = instance.Overloaded5(); 135 | Assert.Equal(1, ret.Count); 136 | } 137 | 138 | [Fact] 139 | public void EnsureHasBeenReplace() 140 | { 141 | var instance = testResult.GetInstance("ClassWithGenericUsage"); 142 | instance.Method(); 143 | } 144 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.suo 8 | *.user 9 | *.userosscache 10 | *.sln.docstates 11 | 12 | # User-specific files (MonoDevelop/Xamarin Studio) 13 | *.userprefs 14 | 15 | # Build results 16 | [Dd]ebug/ 17 | [Dd]ebugPublic/ 18 | [Rr]elease/ 19 | [Rr]eleases/ 20 | x64/ 21 | x86/ 22 | bld/ 23 | [Bb]in/ 24 | [Oo]bj/ 25 | [Ll]og/ 26 | 27 | # Visual Studio 2015 cache/options directory 28 | .vs/ 29 | # Uncomment if you have tasks that create the project's static files in wwwroot 30 | #wwwroot/ 31 | 32 | # MSTest test Results 33 | [Tt]est[Rr]esult*/ 34 | [Bb]uild[Ll]og.* 35 | 36 | # NUNIT 37 | *.VisualState.xml 38 | TestResult.xml 39 | 40 | # Build Results of an ATL Project 41 | [Dd]ebugPS/ 42 | [Rr]eleasePS/ 43 | dlldata.c 44 | 45 | # Benchmark Results 46 | BenchmarkDotNet.Artifacts/ 47 | 48 | # .NET Core 49 | project.lock.json 50 | project.fragment.lock.json 51 | artifacts/ 52 | **/Properties/launchSettings.json 53 | 54 | *_i.c 55 | *_p.c 56 | *_i.h 57 | *.ilk 58 | *.meta 59 | *.obj 60 | *.pch 61 | *.pdb 62 | *.pgc 63 | *.pgd 64 | *.rsp 65 | *.sbr 66 | *.tlb 67 | *.tli 68 | *.tlh 69 | *.tmp 70 | *.tmp_proj 71 | *.log 72 | *.vspscc 73 | *.vssscc 74 | .builds 75 | *.pidb 76 | *.svclog 77 | *.scc 78 | 79 | # Chutzpah Test files 80 | _Chutzpah* 81 | 82 | # Visual C++ cache files 83 | ipch/ 84 | *.aps 85 | *.ncb 86 | *.opendb 87 | *.opensdf 88 | *.sdf 89 | *.cachefile 90 | *.VC.db 91 | *.VC.VC.opendb 92 | 93 | # Visual Studio profiler 94 | *.psess 95 | *.vsp 96 | *.vspx 97 | *.sap 98 | 99 | # Visual Studio Trace Files 100 | *.e2e 101 | 102 | # TFS 2012 Local Workspace 103 | $tf/ 104 | 105 | # Guidance Automation Toolkit 106 | *.gpState 107 | 108 | # ReSharper is a .NET coding add-in 109 | _ReSharper*/ 110 | *.[Rr]e[Ss]harper 111 | *.DotSettings.user 112 | 113 | # JustCode is a .NET coding add-in 114 | .JustCode 115 | 116 | # TeamCity is a build add-in 117 | _TeamCity* 118 | 119 | # DotCover is a Code Coverage Tool 120 | *.dotCover 121 | 122 | # AxoCover is a Code Coverage Tool 123 | .axoCover/* 124 | !.axoCover/settings.json 125 | 126 | # Visual Studio code coverage results 127 | *.coverage 128 | *.coveragexml 129 | 130 | # NCrunch 131 | _NCrunch_* 132 | .*crunch*.local.xml 133 | nCrunchTemp_* 134 | 135 | # MightyMoose 136 | *.mm.* 137 | AutoTest.Net/ 138 | 139 | # Web workbench (sass) 140 | .sass-cache/ 141 | 142 | # Installshield output folder 143 | [Ee]xpress/ 144 | 145 | # DocProject is a documentation generator add-in 146 | DocProject/buildhelp/ 147 | DocProject/Help/*.HxT 148 | DocProject/Help/*.HxC 149 | DocProject/Help/*.hhc 150 | DocProject/Help/*.hhk 151 | DocProject/Help/*.hhp 152 | DocProject/Help/Html2 153 | DocProject/Help/html 154 | 155 | # Click-Once directory 156 | publish/ 157 | 158 | # Publish Web Output 159 | *.[Pp]ublish.xml 160 | *.azurePubxml 161 | # Note: Comment the next line if you want to checkin your web deploy settings, 162 | # but database connection strings (with potential passwords) will be unencrypted 163 | *.pubxml 164 | *.publishproj 165 | 166 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 167 | # checkin your Azure Web App publish settings, but sensitive information contained 168 | # in these scripts will be unencrypted 169 | PublishScripts/ 170 | 171 | # NuGet Packages 172 | *.nupkg 173 | # The packages folder can be ignored because of Package Restore 174 | **/[Pp]ackages/* 175 | # except build/, which is used as an MSBuild target. 176 | !**/[Pp]ackages/build/ 177 | # Uncomment if necessary however generally it will be regenerated when needed 178 | #!**/[Pp]ackages/repositories.config 179 | # NuGet v3's project.json files produces more ignorable files 180 | *.nuget.props 181 | *.nuget.targets 182 | nugets/ 183 | 184 | # Microsoft Azure Build Output 185 | csx/ 186 | *.build.csdef 187 | 188 | # Microsoft Azure Emulator 189 | ecf/ 190 | rcf/ 191 | 192 | # Windows Store app package directories and files 193 | AppPackages/ 194 | BundleArtifacts/ 195 | Package.StoreAssociation.xml 196 | _pkginfo.txt 197 | *.appx 198 | 199 | # Visual Studio cache files 200 | # files ending in .cache can be ignored 201 | *.[Cc]ache 202 | # but keep track of directories ending in .cache 203 | !*.[Cc]ache/ 204 | 205 | # Others 206 | ClientBin/ 207 | ~$* 208 | *~ 209 | *.dbmdl 210 | *.dbproj.schemaview 211 | *.jfm 212 | *.pfx 213 | *.publishsettings 214 | orleans.codegen.cs 215 | 216 | # Since there are multiple workflows, uncomment next line to ignore bower_components 217 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 218 | #bower_components/ 219 | 220 | # RIA/Silverlight projects 221 | Generated_Code/ 222 | 223 | # Backup & report files from converting an old project file 224 | # to a newer Visual Studio version. Backup files are not needed, 225 | # because we have git ;-) 226 | _UpgradeReport_Files/ 227 | Backup*/ 228 | UpgradeLog*.XML 229 | UpgradeLog*.htm 230 | 231 | # SQL Server files 232 | *.mdf 233 | *.ldf 234 | *.ndf 235 | 236 | # Business Intelligence projects 237 | *.rdl.data 238 | *.bim.layout 239 | *.bim_*.settings 240 | 241 | # Microsoft Fakes 242 | FakesAssemblies/ 243 | 244 | # GhostDoc plugin setting file 245 | *.GhostDoc.xml 246 | 247 | # Node.js Tools for Visual Studio 248 | .ntvs_analysis.dat 249 | node_modules/ 250 | 251 | # Typescript v1 declaration files 252 | typings/ 253 | 254 | # Visual Studio 6 build log 255 | *.plg 256 | 257 | # Visual Studio 6 workspace options file 258 | *.opt 259 | 260 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 261 | *.vbw 262 | 263 | # Visual Studio LightSwitch build output 264 | **/*.HTMLClient/GeneratedArtifacts 265 | **/*.DesktopClient/GeneratedArtifacts 266 | **/*.DesktopClient/ModelManifest.xml 267 | **/*.Server/GeneratedArtifacts 268 | **/*.Server/ModelManifest.xml 269 | _Pvt_Extensions 270 | 271 | # Paket dependency manager 272 | .paket/paket.exe 273 | paket-files/ 274 | 275 | # FAKE - F# Make 276 | .fake/ 277 | 278 | # JetBrains Rider 279 | .idea/ 280 | *.sln.iml 281 | 282 | # CodeRush 283 | .cr/ 284 | 285 | # Python Tools for Visual Studio (PTVS) 286 | __pycache__/ 287 | *.pyc 288 | 289 | # Cake - Uncomment if you are using it 290 | # tools/** 291 | # !tools/packages.config 292 | 293 | # Tabs Studio 294 | *.tss 295 | 296 | # Telerik's JustMock configuration file 297 | *.jmconfig 298 | 299 | # BizTalk build output 300 | *.btp.cs 301 | *.btm.cs 302 | *.odx.cs 303 | *.xsd.cs 304 | 305 | # OpenCover UI analysis results 306 | OpenCover/ 307 | 308 | *.received.txt -------------------------------------------------------------------------------- /Ionad.Fody/ModuleWeaver.cs: -------------------------------------------------------------------------------- 1 | using Fody; 2 | using Mono.Cecil; 3 | using Mono.Cecil.Cil; 4 | using Mono.Cecil.Rocks; 5 | 6 | public class ModuleWeaver: 7 | BaseModuleWeaver 8 | { 9 | public override void Execute() 10 | { 11 | var types = ModuleDefinition.GetTypes() 12 | .ToList(); 13 | var replacements = FindReplacements(types); 14 | 15 | if (replacements.Count == 0) 16 | { 17 | WriteInfo("No Static Replacements found"); 18 | } 19 | else 20 | { 21 | ProcessAssembly(types, replacements); 22 | RemoveAttributes(replacements.Values); 23 | } 24 | } 25 | 26 | public override IEnumerable GetAssembliesForScanning() 27 | { 28 | yield break; 29 | } 30 | 31 | static Dictionary FindReplacements(IEnumerable types) 32 | { 33 | var replacements = new Dictionary(); 34 | 35 | foreach (var type in types) 36 | { 37 | var replacement = type.GetStaticReplacementAttribute(); 38 | if (replacement == null) 39 | { 40 | continue; 41 | } 42 | 43 | var replacementType = ((TypeReference)replacement.ConstructorArguments[0].Value).Resolve(); 44 | 45 | replacements.Add(replacementType, type); 46 | } 47 | 48 | return replacements; 49 | } 50 | 51 | void ProcessAssembly(IEnumerable types, Dictionary replacements) 52 | { 53 | foreach (var type in types) 54 | { 55 | foreach (var method in type.MethodsWithBody()) 56 | { 57 | ReplaceCalls(method.Body, replacements); 58 | } 59 | 60 | foreach (var property in type.ConcreteProperties()) 61 | { 62 | if (property.GetMethod != null) 63 | { 64 | ReplaceCalls(property.GetMethod.Body, replacements); 65 | } 66 | 67 | if (property.SetMethod != null) 68 | { 69 | ReplaceCalls(property.SetMethod.Body, replacements); 70 | } 71 | } 72 | } 73 | } 74 | 75 | void ReplaceCalls(MethodBody body, Dictionary replacements) 76 | { 77 | body.SimplifyMacros(); 78 | 79 | var calls = body.Instructions.Where(_ => _.OpCode == OpCodes.Call); 80 | 81 | foreach (var call in calls) 82 | { 83 | var originalMethodReference = (MethodReference)call.Operand; 84 | var originalMethodDefinition = originalMethodReference.Resolve(); 85 | var declaringTypeReference = originalMethodReference.DeclaringType; 86 | var declaringTypeDefinition = declaringTypeReference.Resolve(); 87 | 88 | if (!originalMethodDefinition.IsStatic || !replacements.ContainsKey(declaringTypeDefinition)) 89 | { 90 | continue; 91 | } 92 | 93 | var replacementTargetType = replacements[declaringTypeDefinition]; 94 | if (IsReplacementOnSelf(body, replacementTargetType)) 95 | { 96 | // Skip replacement if the replacement call site is in the replacement target class 97 | // this allows the Replacement class to be able to call the original class methods 98 | // Allowing decorator style programming in Ionad. 99 | continue; 100 | } 101 | 102 | var replacementTypeReference = ModuleDefinition.ImportReference(replacementTargetType); 103 | if (declaringTypeReference.IsGenericInstance) 104 | { 105 | var declaringGenericType = (GenericInstanceType)declaringTypeReference; 106 | var genericType = new GenericInstanceType(replacementTypeReference); 107 | foreach (var arg in declaringGenericType.GenericArguments) 108 | { 109 | genericType.GenericArguments.Add(arg); 110 | } 111 | replacementTypeReference = ModuleDefinition.ImportReference(genericType); 112 | } 113 | 114 | var replacementMethod = replacementTypeReference.ReferenceMethod(originalMethodDefinition); 115 | 116 | if (replacementMethod == null) 117 | { 118 | WriteError($"Missing '{declaringTypeDefinition.FullName}.{originalMethodDefinition.Name}()' in '{replacementTypeReference.FullName}'"); 119 | continue; 120 | } 121 | 122 | if (!replacementMethod.Resolve().IsStatic) 123 | { 124 | WriteError($"Replacement method '{replacementMethod.FullName}' is not static"); 125 | continue; 126 | } 127 | 128 | if (originalMethodReference.IsGenericInstance) 129 | { 130 | var originalGenericInstanceMethod = (GenericInstanceMethod)originalMethodReference; 131 | var genericInstanceMethod = new GenericInstanceMethod(replacementMethod); 132 | foreach (var arg in originalGenericInstanceMethod.GenericArguments) 133 | { 134 | genericInstanceMethod.GenericArguments.Add(arg); 135 | } 136 | 137 | call.Operand = ModuleDefinition.ImportReference(genericInstanceMethod); 138 | } 139 | else 140 | { 141 | call.Operand = replacementMethod; 142 | } 143 | } 144 | 145 | body.InitLocals = true; 146 | body.OptimizeMacros(); 147 | } 148 | 149 | /// 150 | /// This method is to try to stop replacing calls to the base method from the replacement 151 | /// class. This allows the replacement class to decorate the base methods. 152 | /// 153 | static bool IsReplacementOnSelf(MethodBody body, TypeDefinition replacementTargetType) 154 | { 155 | var methodDeclaringType = body.Method.DeclaringType; 156 | 157 | // We don't want to replace calls in nested classes either, because 158 | // the C# compiler regularly generates nested classes for certain 159 | // state machine like methods. For examples: 160 | // 1) yield return xxx; 161 | // 2) await Task 162 | // 3) lambda variable captures 163 | bool IsNestedClassMethod(TypeDefinition methodType) 164 | { 165 | if (methodType == replacementTargetType) 166 | { 167 | return true; 168 | } 169 | 170 | if (methodType.IsNestedPrivate) 171 | { 172 | return IsNestedClassMethod(methodType.DeclaringType); 173 | } 174 | return false; 175 | } 176 | return IsNestedClassMethod(methodDeclaringType); 177 | } 178 | 179 | static void RemoveAttributes(IEnumerable types) 180 | { 181 | foreach (var typeDefinition in types) 182 | { 183 | typeDefinition.RemoveStaticReplacementAttribute(); 184 | } 185 | } 186 | 187 | public override bool ShouldCleanReference => true; 188 | } -------------------------------------------------------------------------------- /Ionad.sln.DotSettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | True 4 | True 5 | True 6 | False 7 | 8 | True 9 | SOLUTION 10 | SUGGESTION 11 | SUGGESTION 12 | DO_NOT_SHOW 13 | ERROR 14 | DO_NOT_SHOW 15 | DO_NOT_SHOW 16 | DO_NOT_SHOW 17 | DO_NOT_SHOW 18 | WARNING 19 | ERROR 20 | ERROR 21 | ERROR 22 | ERROR 23 | ERROR 24 | DO_NOT_SHOW 25 | DO_NOT_SHOW 26 | DO_NOT_SHOW 27 | DO_NOT_SHOW 28 | ERROR 29 | ERROR 30 | ERROR 31 | ERROR 32 | ERROR 33 | ERROR 34 | ERROR 35 | ERROR 36 | ERROR 37 | ERROR 38 | ERROR 39 | ERROR 40 | ERROR 41 | ERROR 42 | ERROR 43 | ERROR 44 | ERROR 45 | ERROR 46 | ERROR 47 | ERROR 48 | ERROR 49 | DO_NOT_SHOW 50 | DO_NOT_SHOW 51 | ERROR 52 | DO_NOT_SHOW 53 | DO_NOT_SHOW 54 | ERROR 55 | ERROR 56 | ERROR 57 | ERROR 58 | ERROR 59 | ERROR 60 | ERROR 61 | ERROR 62 | ERROR 63 | WARNING 64 | ERROR 65 | ERROR 66 | ERROR 67 | ERROR 68 | ERROR 69 | ERROR 70 | ERROR 71 | SUGGESTION 72 | SUGGESTION 73 | ERROR 74 | ERROR 75 | ERROR 76 | ERROR 77 | ERROR 78 | ERROR 79 | ERROR 80 | SUGGESTION 81 | ERROR 82 | ERROR 83 | ERROR 84 | ERROR 85 | ERROR 86 | ERROR 87 | ERROR 88 | ERROR 89 | ERROR 90 | ERROR 91 | ERROR 92 | WARNING 93 | ERROR 94 | ERROR 95 | ERROR 96 | DoHide 97 | DoHide 98 | DoHide 99 | DoHide 100 | DoHide 101 | DoHide 102 | DoHide 103 | DoHide 104 | DoHide 105 | DoHide 106 | DoHide 107 | DoHide 108 | DoHide 109 | DoHide 110 | DoHide 111 | DoHide 112 | DoHide 113 | DoHide 114 | ERROR 115 | ERROR 116 | ERROR 117 | ERROR 118 | ERROR 119 | ERROR 120 | ERROR 121 | ERROR 122 | ERROR 123 | ERROR 124 | ERROR 125 | ERROR 126 | ERROR 127 | ERROR 128 | DO_NOT_SHOW 129 | SUGGESTION 130 | WARNING 131 | WARNING 132 | ERROR 133 | HINT 134 | WARNING 135 | ERROR 136 | ERROR 137 | ERROR 138 | <?xml version="1.0" encoding="utf-16"?><Profile name="Format My Code Using &quot;Particular&quot; conventions"><CSMakeFieldReadonly>True</CSMakeFieldReadonly><CSUseVar><BehavourStyle>CAN_CHANGE_TO_IMPLICIT</BehavourStyle><LocalVariableStyle>ALWAYS_IMPLICIT</LocalVariableStyle><ForeachVariableStyle>ALWAYS_IMPLICIT</ForeachVariableStyle></CSUseVar><CSOptimizeUsings><OptimizeUsings>True</OptimizeUsings><EmbraceInRegion>False</EmbraceInRegion><RegionName></RegionName></CSOptimizeUsings><CSReformatCode>True</CSReformatCode><CSReorderTypeMembers>True</CSReorderTypeMembers><JsInsertSemicolon>True</JsInsertSemicolon><JsReformatCode>True</JsReformatCode><CssReformatCode>True</CssReformatCode><CSArrangeThisQualifier>True</CSArrangeThisQualifier><RemoveCodeRedundancies>True</RemoveCodeRedundancies><CSUseAutoProperty>True</CSUseAutoProperty><HtmlReformatCode>True</HtmlReformatCode><CSShortenReferences>True</CSShortenReferences><CSharpFormatDocComments>True</CSharpFormatDocComments><CssAlphabetizeProperties>True</CssAlphabetizeProperties></Profile> 139 | Default: Reformat Code 140 | Format My Code Using "Particular" conventions 141 | Implicit 142 | Implicit 143 | False 144 | False 145 | ALWAYS_ADD 146 | ALWAYS_ADD 147 | ALWAYS_ADD 148 | ALWAYS_ADD 149 | ALWAYS_ADD 150 | False 151 | NEVER 152 | False 153 | False 154 | False 155 | False 156 | CHOP_ALWAYS 157 | False 158 | CHOP_ALWAYS 159 | CHOP_ALWAYS 160 | True 161 | True 162 | ZeroIndent 163 | ZeroIndent 164 | <?xml version="1.0" encoding="utf-16"?> 165 | <Patterns xmlns="urn:schemas-jetbrains-com:member-reordering-patterns"> 166 | <TypePattern DisplayName="COM interfaces or structs"> 167 | <TypePattern.Match> 168 | <Or> 169 | <And> 170 | <Kind Is="Interface" /> 171 | <Or> 172 | <HasAttribute Name="System.Runtime.InteropServices.InterfaceTypeAttribute" /> 173 | <HasAttribute Name="System.Runtime.InteropServices.ComImport" /> 174 | </Or> 175 | </And> 176 | <Kind Is="Struct" /> 177 | </Or> 178 | </TypePattern.Match> 179 | </TypePattern> 180 | <TypePattern DisplayName="NUnit Test Fixtures" RemoveRegions="All"> 181 | <TypePattern.Match> 182 | <And> 183 | <Kind Is="Class" /> 184 | <HasAttribute Name="NUnit.Framework.TestFixtureAttribute" Inherited="True" /> 185 | <HasAttribute Name="NUnit.Framework.TestCaseFixtureAttribute" Inherited="True" /> 186 | </And> 187 | </TypePattern.Match> 188 | <Entry DisplayName="Setup/Teardown Methods"> 189 | <Entry.Match> 190 | <And> 191 | <Kind Is="Method" /> 192 | <Or> 193 | <HasAttribute Name="NUnit.Framework.SetUpAttribute" Inherited="True" /> 194 | <HasAttribute Name="NUnit.Framework.TearDownAttribute" Inherited="True" /> 195 | <HasAttribute Name="NUnit.Framework.FixtureSetUpAttribute" Inherited="True" /> 196 | <HasAttribute Name="NUnit.Framework.FixtureTearDownAttribute" Inherited="True" /> 197 | </Or> 198 | </And> 199 | </Entry.Match> 200 | </Entry> 201 | <Entry DisplayName="All other members" /> 202 | <Entry DisplayName="Test Methods" Priority="100"> 203 | <Entry.Match> 204 | <And> 205 | <Kind Is="Method" /> 206 | <HasAttribute Name="NUnit.Framework.TestAttribute" /> 207 | </And> 208 | </Entry.Match> 209 | <Entry.SortBy> 210 | <Name /> 211 | </Entry.SortBy> 212 | </Entry> 213 | </TypePattern> 214 | <TypePattern DisplayName="Default Pattern"> 215 | <Entry DisplayName="Public Delegates" Priority="100"> 216 | <Entry.Match> 217 | <And> 218 | <Access Is="Public" /> 219 | <Kind Is="Delegate" /> 220 | </And> 221 | </Entry.Match> 222 | <Entry.SortBy> 223 | <Name /> 224 | </Entry.SortBy> 225 | </Entry> 226 | <Entry DisplayName="Public Enums" Priority="100"> 227 | <Entry.Match> 228 | <And> 229 | <Access Is="Public" /> 230 | <Kind Is="Enum" /> 231 | </And> 232 | </Entry.Match> 233 | <Entry.SortBy> 234 | <Name /> 235 | </Entry.SortBy> 236 | </Entry> 237 | <Entry DisplayName="Constructors"> 238 | <Entry.Match> 239 | <Kind Is="Constructor" /> 240 | </Entry.Match> 241 | <Entry.SortBy> 242 | <Static /> 243 | </Entry.SortBy> 244 | </Entry> 245 | <Entry DisplayName="Properties, Indexers"> 246 | <Entry.Match> 247 | <Or> 248 | <Kind Is="Property" /> 249 | <Kind Is="Indexer" /> 250 | </Or> 251 | </Entry.Match> 252 | </Entry> 253 | <Entry DisplayName="Interface Implementations" Priority="100"> 254 | <Entry.Match> 255 | <And> 256 | <Kind Is="Member" /> 257 | <ImplementsInterface /> 258 | </And> 259 | </Entry.Match> 260 | <Entry.SortBy> 261 | <ImplementsInterface Immediate="True" /> 262 | </Entry.SortBy> 263 | </Entry> 264 | <Entry DisplayName="All other members" /> 265 | <Entry DisplayName="Fields"> 266 | <Entry.Match> 267 | <And> 268 | <Kind Is="Field" /> 269 | <Not> 270 | <Static /> 271 | </Not> 272 | </And> 273 | </Entry.Match> 274 | <Entry.SortBy> 275 | <Access /> 276 | <Readonly /> 277 | </Entry.SortBy> 278 | </Entry> 279 | <Entry DisplayName="Static Fields and Constants"> 280 | <Entry.Match> 281 | <Or> 282 | <Kind Is="Constant" /> 283 | <And> 284 | <Kind Is="Field" /> 285 | <Static /> 286 | </And> 287 | </Or> 288 | </Entry.Match> 289 | <Entry.SortBy> 290 | <Kind Order="Constant Field" /> 291 | </Entry.SortBy> 292 | </Entry> 293 | <Entry DisplayName="Nested Types"> 294 | <Entry.Match> 295 | <Kind Is="Type" /> 296 | </Entry.Match> 297 | </Entry> 298 | </TypePattern> 299 | </Patterns> 300 | <?xml version="1.0" encoding="utf-8" ?> 301 | 302 | <!-- 303 | I. Overall 304 | 305 | I.1 Each pattern can have <Match>....</Match> element. For the given type declaration, the pattern with the match, evaluated to 'true' with the largest weight, will be used 306 | I.2 Each pattern consists of the sequence of <Entry>...</Entry> elements. Type member declarations are distributed between entries 307 | I.3 If pattern has RemoveAllRegions="true" attribute, then all regions will be cleared prior to reordering. Otherwise, only auto-generated regions will be cleared 308 | I.4 The contents of each entry is sorted by given keys (First key is primary, next key is secondary, etc). Then the declarations are grouped and en-regioned by given property 309 | 310 | II. Available match operands 311 | 312 | Each operand may have Weight="..." attribute. This weight will be added to the match weight if the operand is evaluated to 'true'. 313 | The default weight is 1 314 | 315 | II.1 Boolean functions: 316 | II.1.1 <And>....</And> 317 | II.1.2 <Or>....</Or> 318 | II.1.3 <Not>....</Not> 319 | 320 | II.2 Operands 321 | II.2.1 <Kind Is="..."/>. Kinds are: class, struct, interface, enum, delegate, type, constructor, destructor, property, indexer, method, operator, field, constant, event, member 322 | II.2.2 <Name Is="..." [IgnoreCase="true/false"] />. The 'Is' attribute contains regular expression 323 | II.2.3 <HasAttribute CLRName="..." [Inherit="true/false"] />. The 'CLRName' attribute contains regular expression 324 | II.2.4 <Access Is="..."/>. The 'Is' values are: public, protected, internal, protected internal, private 325 | II.2.5 <Static/> 326 | II.2.6 <Abstract/> 327 | II.2.7 <Virtual/> 328 | II.2.8 <Override/> 329 | II.2.9 <Sealed/> 330 | II.2.10 <Readonly/> 331 | II.2.11 <ImplementsInterface CLRName="..."/>. The 'CLRName' attribute contains regular expression 332 | II.2.12 <HandlesEvent /> 333 | --> 334 | 335 | <Patterns xmlns="urn:shemas-jetbrains-com:member-reordering-patterns"> 336 | 337 | <!--Do not reorder COM interfaces and structs marked by StructLayout attribute--> 338 | <Pattern> 339 | <Match> 340 | <Or Weight="100"> 341 | <And> 342 | <Kind Is="interface"/> 343 | <Or> 344 | <HasAttribute CLRName="System.Runtime.InteropServices.InterfaceTypeAttribute"/> 345 | <HasAttribute CLRName="System.Runtime.InteropServices.ComImport"/> 346 | </Or> 347 | </And> 348 | <HasAttribute CLRName="System.Runtime.InteropServices.StructLayoutAttribute"/> 349 | </Or> 350 | </Match> 351 | </Pattern> 352 | 353 | <!--Special formatting of NUnit test fixture--> 354 | <Pattern RemoveAllRegions="true"> 355 | <Match> 356 | <And Weight="100"> 357 | <Kind Is="class"/> 358 | <HasAttribute CLRName="NUnit.Framework.TestFixtureAttribute" Inherit="true"/> 359 | </And> 360 | </Match> 361 | 362 | <!--Setup/Teardow--> 363 | <Entry> 364 | <Match> 365 | <And> 366 | <Kind Is="method"/> 367 | <Or> 368 | <HasAttribute CLRName="NUnit.Framework.SetUpAttribute" Inherit="true"/> 369 | <HasAttribute CLRName="NUnit.Framework.TearDownAttribute" Inherit="true"/> 370 | <HasAttribute CLRName="NUnit.Framework.FixtureSetUpAttribute" Inherit="true"/> 371 | <HasAttribute CLRName="NUnit.Framework.FixtureTearDownAttribute" Inherit="true"/> 372 | </Or> 373 | </And> 374 | </Match> 375 | </Entry> 376 | 377 | <!--All other members--> 378 | <Entry/> 379 | 380 | <!--Test methods--> 381 | <Entry> 382 | <Match> 383 | <And Weight="100"> 384 | <Kind Is="method"/> 385 | <HasAttribute CLRName="NUnit.Framework.TestAttribute" Inherit="false"/> 386 | </And> 387 | </Match> 388 | <Sort> 389 | <Name/> 390 | </Sort> 391 | </Entry> 392 | </Pattern> 393 | 394 | <!--Default pattern--> 395 | <Pattern> 396 | 397 | <!--public delegate--> 398 | <Entry> 399 | <Match> 400 | <And Weight="100"> 401 | <Access Is="public"/> 402 | <Kind Is="delegate"/> 403 | </And> 404 | </Match> 405 | <Sort> 406 | <Name/> 407 | </Sort> 408 | </Entry> 409 | 410 | <!--public enum--> 411 | <Entry> 412 | <Match> 413 | <And Weight="100"> 414 | <Access Is="public"/> 415 | <Kind Is="enum"/> 416 | </And> 417 | </Match> 418 | <Sort> 419 | <Name/> 420 | </Sort> 421 | </Entry> 422 | 423 | <!--Constructors. Place static one first--> 424 | <Entry> 425 | <Match> 426 | <Kind Is="constructor"/> 427 | </Match> 428 | <Sort> 429 | <Static/> 430 | </Sort> 431 | </Entry> 432 | 433 | <!--properties, indexers--> 434 | <Entry> 435 | <Match> 436 | <Or> 437 | <Kind Is="property"/> 438 | <Kind Is="indexer"/> 439 | </Or> 440 | </Match> 441 | </Entry> 442 | 443 | <!--interface implementations--> 444 | <Entry> 445 | <Match> 446 | <And Weight="100"> 447 | <Kind Is="member"/> 448 | <ImplementsInterface/> 449 | </And> 450 | </Match> 451 | <Sort> 452 | <ImplementsInterface Immediate="true"/> 453 | </Sort> 454 | </Entry> 455 | 456 | <!--all other members--> 457 | <Entry/> 458 | 459 | <!--static fields and constants--> 460 | <Entry> 461 | <Match> 462 | <Or> 463 | <Kind Is="constant"/> 464 | <And> 465 | <Kind Is="field"/> 466 | <Static/> 467 | </And> 468 | </Or> 469 | </Match> 470 | <Sort> 471 | <Kind Order="constant field"/> 472 | </Sort> 473 | </Entry> 474 | 475 | <!--instance fields--> 476 | <Entry> 477 | <Match> 478 | <And> 479 | <Kind Is="field"/> 480 | <Not> 481 | <Static/> 482 | </Not> 483 | </And> 484 | </Match> 485 | <Sort> 486 | <Readonly/> 487 | <Name/> 488 | </Sort> 489 | </Entry> 490 | 491 | <!--nested types--> 492 | <Entry> 493 | <Match> 494 | <Kind Is="type"/> 495 | </Match> 496 | <Sort> 497 | <Name/> 498 | </Sort> 499 | </Entry> 500 | </Pattern> 501 | 502 | </Patterns> 503 | 504 | CustomLayout 505 | True 506 | False 507 | True 508 | False 509 | True 510 | False 511 | False 512 | False 513 | True 514 | Automatic property 515 | True 516 | False 517 | False 518 | DB 519 | DTC 520 | ID 521 | NSB 522 | SLA 523 | $object$_On$event$ 524 | <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> 525 | <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> 526 | <Policy Inspect="True" Prefix="I" Suffix="" Style="AaBb" /> 527 | <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> 528 | <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> 529 | <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> 530 | <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> 531 | <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> 532 | <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> 533 | <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> 534 | <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> 535 | <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> 536 | <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> 537 | <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> 538 | <Policy Inspect="True" Prefix="T" Suffix="" Style="AaBb" /> 539 | <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> 540 | <Policy><Descriptor Staticness="Static" AccessRightKinds="Private" Description="Static readonly fields (private)"><ElementKinds><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></Policy> 541 | <Policy><Descriptor Staticness="Any" AccessRightKinds="Private" Description="Constant fields (private)"><ElementKinds><Kind Name="CONSTANT_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></Policy> 542 | <Policy><Descriptor Staticness="Any" AccessRightKinds="Any" Description="Type parameters"><ElementKinds><Kind Name="TYPE_PARAMETER" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="T" Suffix="" Style="AaBb" /></Policy> 543 | <Policy><Descriptor Staticness="Instance" AccessRightKinds="Private" Description="Instance fields (private)"><ElementKinds><Kind Name="FIELD" /><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></Policy> 544 | <Policy><Descriptor Staticness="Instance" AccessRightKinds="Protected, ProtectedInternal, Internal, Public, PrivateProtected" Description="Instance fields (not private)"><ElementKinds><Kind Name="FIELD" /><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></Policy> 545 | <Policy><Descriptor Staticness="Any" AccessRightKinds="Any" Description="Local variables"><ElementKinds><Kind Name="LOCAL_VARIABLE" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></Policy> 546 | <Policy><Descriptor Staticness="Any" AccessRightKinds="Protected, ProtectedInternal, Internal, Public, PrivateProtected" Description="Constant fields (not private)"><ElementKinds><Kind Name="CONSTANT_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></Policy> 547 | <Policy><Descriptor Staticness="Static" AccessRightKinds="Protected, ProtectedInternal, Internal, Public, PrivateProtected" Description="Static fields (not private)"><ElementKinds><Kind Name="FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></Policy> 548 | <Policy><Descriptor Staticness="Any" AccessRightKinds="Any" Description="Parameters"><ElementKinds><Kind Name="PARAMETER" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></Policy> 549 | <Policy><Descriptor Staticness="Any" AccessRightKinds="Any" Description="Enum members"><ElementKinds><Kind Name="ENUM_MEMBER" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></Policy> 550 | <Policy><Descriptor Staticness="Any" AccessRightKinds="Any" Description="Types and namespaces"><ElementKinds><Kind Name="NAMESPACE" /><Kind Name="CLASS" /><Kind Name="STRUCT" /><Kind Name="ENUM" /><Kind Name="DELEGATE" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></Policy> 551 | <Policy><Descriptor Staticness="Any" AccessRightKinds="Any" Description="Local constants"><ElementKinds><Kind Name="LOCAL_CONSTANT" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></Policy> 552 | <Policy><Descriptor Staticness="Any" AccessRightKinds="Any" Description="Interfaces"><ElementKinds><Kind Name="INTERFACE" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="I" Suffix="" Style="AaBb" /></Policy> 553 | <Policy><Descriptor Staticness="Static" AccessRightKinds="Protected, ProtectedInternal, Internal, Public, PrivateProtected" Description="Static readonly fields (not private)"><ElementKinds><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></Policy> 554 | <Policy><Descriptor Staticness="Static" AccessRightKinds="Private" Description="Static fields (private)"><ElementKinds><Kind Name="FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></Policy> 555 | <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> 556 | <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> 557 | <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> 558 | <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> 559 | <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> 560 | <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> 561 | <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> 562 | <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> 563 | <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> 564 | <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> 565 | <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> 566 | <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> 567 | <Policy Inspect="True" Prefix="I" Suffix="" Style="AaBb" /> 568 | <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> 569 | <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> 570 | <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> 571 | <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> 572 | <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> 573 | <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> 574 | <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> 575 | <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> 576 | <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> 577 | <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> 578 | <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> 579 | <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> 580 | <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> 581 | <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> 582 | <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> 583 | <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> 584 | <Policy Inspect="True" Prefix="T" Suffix="" Style="AaBb" /> 585 | $object$_On$event$ 586 | <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> 587 | <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> 588 | <Policy Inspect="True" Prefix="I" Suffix="" Style="AaBb" /> 589 | <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> 590 | <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> 591 | <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> 592 | <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> 593 | <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> 594 | <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> 595 | <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> 596 | <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> 597 | <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> 598 | <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> 599 | <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> 600 | <Policy Inspect="True" Prefix="T" Suffix="" Style="AaBb" /> 601 | <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> 602 | <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> 603 | <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> 604 | <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> 605 | <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> 606 | <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> 607 | <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> 608 | <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> 609 | True 610 | True 611 | True 612 | True 613 | True 614 | True 615 | True 616 | True 617 | True 618 | True 619 | True 620 | True 621 | True 622 | True 623 | True 624 | True 625 | True 626 | True 627 | 628 | 629 | 630 | <data /> 631 | <data><IncludeFilters /><ExcludeFilters /></data> --------------------------------------------------------------------------------