diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index ff75308..0c58700 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -27,6 +27,7 @@ jobs:
dotnet-version: |
6.0.x
7.0.x
+ 8.0.x
- name: Restore
run: dotnet restore ${{ env.SOLUTION }} -v q
diff --git a/InterfaceBaseInvoke.sln.DotSettings b/InterfaceBaseInvoke.sln.DotSettings
index dc1d346..f524c8d 100644
--- a/InterfaceBaseInvoke.sln.DotSettings
+++ b/InterfaceBaseInvoke.sln.DotSettings
@@ -34,6 +34,8 @@
IL
<Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" />
<Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" />
+ <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>
+ <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>
<Policy><Descriptor Staticness="Static, Instance" AccessRightKinds="Protected" Description="Protected field"><ElementKinds><Kind Name="FIELD" /><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /></Policy>
True
@@ -50,6 +52,7 @@
True
True
True
+ True
True
<data />
<data><IncludeFilters /><ExcludeFilters><Filter ModuleMask="InlineIL.Tests.*" ModuleVersionMask="*" ClassMask="*" FunctionMask="*" IsEnabled="True" /><Filter ModuleMask="InlineIL.Examples" ModuleVersionMask="*" ClassMask="*" FunctionMask="*" IsEnabled="True" /><Filter ModuleMask="InlineIL" ModuleVersionMask="*" ClassMask="*" FunctionMask="*" IsEnabled="True" /></ExcludeFilters></data>
diff --git a/NuGet.Config b/NuGet.Config
index 115e571..ec32754 100644
--- a/NuGet.Config
+++ b/NuGet.Config
@@ -8,6 +8,6 @@
-
+
diff --git a/build/pkg.version b/build/pkg.version
index b1e80bb..845639e 100644
--- a/build/pkg.version
+++ b/build/pkg.version
@@ -1 +1 @@
-0.1.3
+0.1.4
diff --git a/src/InterfaceBaseInvoke.Example/FodyWeavers.xml b/src/InterfaceBaseInvoke.Example/FodyWeavers.xml
index 50c27f1..6fd1f1e 100644
--- a/src/InterfaceBaseInvoke.Example/FodyWeavers.xml
+++ b/src/InterfaceBaseInvoke.Example/FodyWeavers.xml
@@ -1,3 +1,3 @@
-
+
\ No newline at end of file
diff --git a/src/InterfaceBaseInvoke.Example/InterfaceBaseInvoke.Example.csproj b/src/InterfaceBaseInvoke.Example/InterfaceBaseInvoke.Example.csproj
index ba0aefa..3fcb250 100644
--- a/src/InterfaceBaseInvoke.Example/InterfaceBaseInvoke.Example.csproj
+++ b/src/InterfaceBaseInvoke.Example/InterfaceBaseInvoke.Example.csproj
@@ -2,11 +2,11 @@
Exe
- net6.0
+ net8.0
-
+
@@ -21,4 +21,14 @@
+
+
+
+
+
+
+
diff --git a/src/InterfaceBaseInvoke.Fody/Extensions/CecilExtensions.cs b/src/InterfaceBaseInvoke.Fody/Extensions/CecilExtensions.cs
deleted file mode 100644
index 5aa427c..0000000
--- a/src/InterfaceBaseInvoke.Fody/Extensions/CecilExtensions.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-using System.Reflection;
-
-namespace InterfaceBaseInvoke.Fody.Extensions;
-
-internal static partial class CecilExtensions
-{
-
- public static GenericInstanceMethod MakeGenericMethod(this MethodReference self, IEnumerable args)
- {
- if (!self.HasGenericParameters)
- throw new WeavingException($"Not a generic method: {self.FullName}");
-
- var arguments = args.ToArray();
-
- if (arguments.Length == 0)
- throw new WeavingException("No generic arguments supplied");
-
- if (self.GenericParameters.Count != arguments.Length)
- throw new ArgumentException($"Incorrect number of generic arguments supplied for method {self.FullName} - expected {self.GenericParameters.Count}, but got {arguments.Length}");
-
- var instance = new GenericInstanceMethod(self);
- foreach (var argument in arguments)
- instance.GenericArguments.Add(argument);
-
- return instance;
- }
-
- public static MethodDefinition GetInterfaceDefaultMethod(this TypeDefinition typeDef, MethodReference methodRef)
- {
- var elementMethod = methodRef.GetElementMethod();
- var methods = typeDef.Methods.Where(m => m.Overrides.Any(x => x.IsEqualTo(elementMethod))).ToList();
- return methods.Count switch
- {
- 0 => throw new MissingMethodException(methodRef.Name),
- > 1 => throw new AmbiguousMatchException($"Found more than one method in type {typeDef.Name} by name " + methodRef.Name),
- _ => methods[0]
- };
- }
-}
diff --git a/src/InterfaceBaseInvoke.Fody/GlobalUsings.cs b/src/InterfaceBaseInvoke.Fody/GlobalUsings.cs
index 26e757b..c16de2c 100644
--- a/src/InterfaceBaseInvoke.Fody/GlobalUsings.cs
+++ b/src/InterfaceBaseInvoke.Fody/GlobalUsings.cs
@@ -12,3 +12,4 @@
global using MoreFodyHelpers.Building;
global using MoreFodyHelpers.Extensions;
global using MoreFodyHelpers.Processing;
+global using MoreFodyHelpers.Support;
diff --git a/src/InterfaceBaseInvoke.Fody/InterfaceBaseInvoke.Fody.csproj b/src/InterfaceBaseInvoke.Fody/InterfaceBaseInvoke.Fody.csproj
index 1f3576b..8fed891 100644
--- a/src/InterfaceBaseInvoke.Fody/InterfaceBaseInvoke.Fody.csproj
+++ b/src/InterfaceBaseInvoke.Fody/InterfaceBaseInvoke.Fody.csproj
@@ -8,9 +8,6 @@
true
-
-
- PreserveNewest
-
+
\ No newline at end of file
diff --git a/src/InterfaceBaseInvoke.Fody/ModuleWeaver.cs b/src/InterfaceBaseInvoke.Fody/ModuleWeaver.cs
index 7a25a2b..f15966e 100644
--- a/src/InterfaceBaseInvoke.Fody/ModuleWeaver.cs
+++ b/src/InterfaceBaseInvoke.Fody/ModuleWeaver.cs
@@ -1,40 +1,52 @@
-namespace InterfaceBaseInvoke.Fody
+namespace InterfaceBaseInvoke.Fody;
+
+public class ModuleWeaver : BaseModuleWeaver
{
- public class ModuleWeaver : BaseModuleWeaver
+ private readonly IWeaverLogger _log;
+
+ public ModuleWeaver()
{
- private readonly IWeaverLogger _log;
+ _log = new WeaverLogger(this);
+ }
- public ModuleWeaver()
- {
- _log = new WeaverLogger(this);
- }
+ public override void Execute()
+ {
+ using var context = new ModuleWeavingContext(ModuleDefinition, WeaverAnchors.AssemblyName, ProjectDirectoryPath);
- public override void Execute()
+ var processed = false;
+ foreach (var type in ModuleDefinition.GetTypes())
{
- foreach (var type in ModuleDefinition.GetTypes())
+ foreach (var method in type.Methods)
{
- foreach (var method in type.Methods)
+ if (method.HasBody == false)
+ continue;
+
+ _log.Debug($"Processing: {method.FullName}");
+
+ try
{
- if (ModuleDefinition.IsAssemblyReferenced(method, WeaverAnchors.AssemblyName) == false)
- continue;
-
- _log.Debug($"Processing: {method.FullName}");
-
- try
- {
- new MethodWeaver(ModuleDefinition, method, _log).Process();
- }
- catch (WeavingException ex)
- {
- AddError(ex.Message, ex.SequencePoint);
- }
+ processed = new MethodWeaver(context, method, _log).Process() || processed;
+ }
+ catch (WeavingException ex)
+ {
+ var terminate = AddError(ex.ToString(), ex.SequencePoint);
+ if (terminate)
+ return;
}
}
}
- public override IEnumerable GetAssembliesForScanning() => Enumerable.Empty();
+ if (processed == false)
+ {
+ _log.Warning("No type is processed.", null);
+ }
+ }
+
+ public override IEnumerable GetAssembliesForScanning() => [];
- protected virtual void AddError(string message, SequencePoint? sequencePoint)
- => _log.Error(message, sequencePoint);
+ protected virtual bool AddError(string message, SequencePoint? sequencePoint)
+ {
+ _log.Error(message, sequencePoint);
+ return true;
}
}
diff --git a/src/InterfaceBaseInvoke.Fody/Processing/MethodWeaver.cs b/src/InterfaceBaseInvoke.Fody/Processing/MethodWeaver.cs
index 09ddf61..49f24b2 100644
--- a/src/InterfaceBaseInvoke.Fody/Processing/MethodWeaver.cs
+++ b/src/InterfaceBaseInvoke.Fody/Processing/MethodWeaver.cs
@@ -4,35 +4,36 @@ namespace InterfaceBaseInvoke.Fody.Processing;
internal sealed class MethodWeaver
{
- private readonly ModuleDefinition _module;
private readonly MethodDefinition _method;
private readonly MethodWeaverLogger _log;
private readonly WeaverILProcessor _il;
private readonly References _references;
+ private readonly SequencePointMapper _sequencePoints;
+
private Collection Instructions => _method.Body.Instructions;
private TypeReferences Types => _references.Types;
private MethodReferences Methods => _references.Methods;
- public MethodWeaver(ModuleDefinition module, MethodDefinition method, IWeaverLogger log)
+ public MethodWeaver(ModuleWeavingContext context, MethodDefinition method, IWeaverLogger log)
{
- _module = module;
_method = method;
_il = new WeaverILProcessor(method);
_log = new MethodWeaverLogger(log, _method);
- _references = new References(module);
+ _references = new References(context);
+ _sequencePoints = new SequencePointMapper(method, true);
}
- public void Process()
+ public bool Process()
{
try
{
- ProcessImpl();
+ return ProcessImpl();
}
catch (InstructionWeavingException ex)
{
throw new WeavingException(_log.QualifyMessage(ex.Message, ex.Instruction))
{
- SequencePoint = ex.Instruction.GetInputSequencePoint(_method)
+ SequencePoint = _sequencePoints.GetInputSequencePoint(ex.Instruction)
};
}
catch (WeavingException ex)
@@ -62,8 +63,9 @@ private static bool IsAnchorMethodCall(Instruction instruction)
};
}
- private void ProcessImpl()
+ private bool ProcessImpl()
{
+ var processed = false;
var instruction = Instructions.FirstOrDefault();
Instruction? nextInstruction;
@@ -77,6 +79,7 @@ private void ProcessImpl()
try
{
nextInstruction = ProcessAnchorMethod(instruction);
+ processed = true;
}
catch (InstructionWeavingException)
{
@@ -91,6 +94,7 @@ private void ProcessImpl()
throw new InstructionWeavingException(instruction, $"Unexpected error occured while processing method {_method.FullName} at instruction {instruction}: {ex}");
}
}
+ return processed;
}
private Instruction? ProcessAnchorMethod(Instruction instruction)
diff --git a/src/InterfaceBaseInvoke.Fody/Processing/References.cs b/src/InterfaceBaseInvoke.Fody/Processing/References.cs
index 951e001..7fe5d64 100644
--- a/src/InterfaceBaseInvoke.Fody/Processing/References.cs
+++ b/src/InterfaceBaseInvoke.Fody/Processing/References.cs
@@ -1,48 +1,47 @@
-namespace InterfaceBaseInvoke.Fody.Processing
+namespace InterfaceBaseInvoke.Fody.Processing;
+
+public sealed class References
{
- public sealed class References
- {
- public TypeReferences Types { get; }
- public MethodReferences Methods { get; }
+ public TypeReferences Types { get; }
+ public MethodReferences Methods { get; }
- public References(ModuleDefinition module)
- {
- Types = new TypeReferences(module);
- Methods = new MethodReferences(module, Types);
- }
+ public References(ModuleWeavingContext context)
+ {
+ Types = new TypeReferences(context);
+ Methods = new MethodReferences(context, Types);
}
+}
- public sealed class TypeReferences
- {
- public TypeReference RuntimeMethodHandle { get; }
- public TypeReference IntPtr { get; }
- public TypeReference Int32 { get; }
- public TypeReference Environment { get; }
- public TypeReference Boolean { get; }
+public sealed class TypeReferences
+{
+ public TypeReference RuntimeMethodHandle { get; }
+ public TypeReference IntPtr { get; }
+ public TypeReference Int32 { get; }
+ public TypeReference Environment { get; }
+ public TypeReference Boolean { get; }
- public TypeReferences(ModuleDefinition module)
- {
- Environment = module.ImportReference(typeof(Environment));
- IntPtr = module.ImportReference(typeof(IntPtr));
- Int32 = module.ImportReference(typeof(int));
- RuntimeMethodHandle = module.ImportReference(typeof(RuntimeMethodHandle));
- Boolean = module.ImportReference(typeof(bool));
- }
+ public TypeReferences(ModuleWeavingContext context)
+ {
+ Environment = context.ImportReference(typeof(Environment));
+ IntPtr = context.ImportReference(typeof(IntPtr));
+ Int32 = context.ImportReference(typeof(int));
+ RuntimeMethodHandle = context.ImportReference(typeof(RuntimeMethodHandle));
+ Boolean = context.ImportReference(typeof(bool));
}
+}
- public sealed class MethodReferences
- {
- public MethodReference FunctionPointer { get; }
- public MethodReference ToInt32 { get; }
- public MethodReference ToInt64 { get; }
- public MethodReference Is64BitProcess { get; }
+public sealed class MethodReferences
+{
+ public MethodReference FunctionPointer { get; }
+ public MethodReference ToInt32 { get; }
+ public MethodReference ToInt64 { get; }
+ public MethodReference Is64BitProcess { get; }
- public MethodReferences(ModuleDefinition module, TypeReferences types)
- {
- FunctionPointer = MethodRefBuilder.MethodByNameAndSignature(module, types.RuntimeMethodHandle, nameof(RuntimeMethodHandle.GetFunctionPointer), 0, types.IntPtr, Enumerable.Empty()).Build();
- ToInt32 = MethodRefBuilder.MethodByName(module, types.IntPtr, nameof(IntPtr.ToInt32)).Build();
- ToInt64 = MethodRefBuilder.MethodByName(module, types.IntPtr, nameof(IntPtr.ToInt64)).Build();
- Is64BitProcess = MethodRefBuilder.PropertyGet(module, types.Environment, nameof(Environment.Is64BitProcess)).Build();
- }
+ public MethodReferences(ModuleWeavingContext context, TypeReferences types)
+ {
+ FunctionPointer = MethodRefBuilder.MethodByNameAndSignature(context, types.RuntimeMethodHandle, nameof(RuntimeMethodHandle.GetFunctionPointer), 0, types.IntPtr.ToTypeRefBuilder(context), []).Build();
+ ToInt32 = MethodRefBuilder.MethodByName(context, types.IntPtr, nameof(IntPtr.ToInt32)).Build();
+ ToInt64 = MethodRefBuilder.MethodByName(context, types.IntPtr, nameof(IntPtr.ToInt64)).Build();
+ Is64BitProcess = MethodRefBuilder.PropertyGet(context, types.Environment, nameof(Environment.Is64BitProcess)).Build();
}
}
diff --git a/src/InterfaceBaseInvoke/InterfaceBaseInvoke.csproj b/src/InterfaceBaseInvoke/InterfaceBaseInvoke.csproj
index 428f427..97570de 100644
--- a/src/InterfaceBaseInvoke/InterfaceBaseInvoke.csproj
+++ b/src/InterfaceBaseInvoke/InterfaceBaseInvoke.csproj
@@ -9,8 +9,8 @@
InterfaceBaseInvoke.Fody
-
-
+
+
@@ -18,5 +18,4 @@
-
\ No newline at end of file
diff --git a/src/InterfaceBaseInvoke/ObjectExtension.cs b/src/InterfaceBaseInvoke/ObjectExtension.cs
index 5987b40..a37ecfc 100644
--- a/src/InterfaceBaseInvoke/ObjectExtension.cs
+++ b/src/InterfaceBaseInvoke/ObjectExtension.cs
@@ -1,4 +1,5 @@
using System;
+using System.Runtime.CompilerServices;
namespace InterfaceBaseInvoke;
@@ -13,6 +14,7 @@ public static class ObjectExtension
///
///
///
+ [MethodImpl(MethodImplOptions.NoInlining)]
public static TInterface Base(this TInterface instance) =>
throw new InvalidOperationException("This method is meant to be replaced at compile time by InterfaceBaseInvoke.Fody, but the weaver has not been executed correctly.");
}
diff --git a/test/InterfaceBaseInvoke.Tests.AssemblyToProcess/InterfaceBaseInvoke.Tests.AssemblyToProcess.csproj b/test/InterfaceBaseInvoke.Tests.AssemblyToProcess/InterfaceBaseInvoke.Tests.AssemblyToProcess.csproj
index 872fc02..ac46d87 100644
--- a/test/InterfaceBaseInvoke.Tests.AssemblyToProcess/InterfaceBaseInvoke.Tests.AssemblyToProcess.csproj
+++ b/test/InterfaceBaseInvoke.Tests.AssemblyToProcess/InterfaceBaseInvoke.Tests.AssemblyToProcess.csproj
@@ -13,7 +13,7 @@
-
+
diff --git a/test/InterfaceBaseInvoke.Tests.AssemblyToProcess/OverridedGenericMethodTestCases.cs b/test/InterfaceBaseInvoke.Tests.AssemblyToProcess/OverridedGenericMethodTestCases.cs
index b4bbe56..3c3b6a7 100644
--- a/test/InterfaceBaseInvoke.Tests.AssemblyToProcess/OverridedGenericMethodTestCases.cs
+++ b/test/InterfaceBaseInvoke.Tests.AssemblyToProcess/OverridedGenericMethodTestCases.cs
@@ -1,36 +1,36 @@
namespace InterfaceBaseInvoke.Tests.AssemblyToProcess;
-public class OverridedGenericMethodTestCases
+public class OverrideGenericMethodTestCases
{
[Fact]
public void Method_Invoke()
{
- var obj = new HasOverridedGenericMethod();
- var result = obj.Base().Method(1, "a");
+ var obj = new HasOverrideGenericMethod();
+ var result = obj.Base().Method(1, "a");
Assert.Equal("Method(1, a)", result);
}
[Fact]
public void Method_InvokeTwice()
{
- var obj = new HasOverridedGenericMethod();
- var a = obj.Base().Method(1, "a");
- var b = obj.Base().Method(2, "b");
+ var obj = new HasOverrideGenericMethod();
+ var a = obj.Base().Method(1, "a");
+ var b = obj.Base().Method(2, "b");
var result = a + "----" + b;
Assert.Equal("Method(1, a)----Method(2, b)", result);
}
[Fact]
public void GenericMethod_Invoke()
{
- var obj = new HasOverridedGenericMethod();
- var result = obj.Base().Method(2, "b");
+ var obj = new HasOverrideGenericMethod();
+ var result = obj.Base().Method(2, "b");
Assert.Equal("Method(2, b)", result);
}
[Fact]
public void GenericMethod_InvokeTwice()
{
- var obj = new HasOverridedGenericMethod();
- var a = obj.Base().Method(1, "a");
- var b = obj.Base().Method(2, "b");
+ var obj = new HasOverrideGenericMethod();
+ var a = obj.Base().Method(1, "a");
+ var b = obj.Base().Method(2, "b");
var result = a + "----" + b;
Assert.Equal("Method(1, a)----Method(2, b)", result);
}
diff --git a/test/InterfaceBaseInvoke.Tests.AssemblyToProcess/OverridedMethodTestCases.cs b/test/InterfaceBaseInvoke.Tests.AssemblyToProcess/OverridedMethodTestCases.cs
index d43087f..49286be 100644
--- a/test/InterfaceBaseInvoke.Tests.AssemblyToProcess/OverridedMethodTestCases.cs
+++ b/test/InterfaceBaseInvoke.Tests.AssemblyToProcess/OverridedMethodTestCases.cs
@@ -1,27 +1,27 @@
namespace InterfaceBaseInvoke.Tests.AssemblyToProcess;
-public class OverridedMethodTestCases
+public class OverrideMethodTestCases
{
[Fact]
public void Property_Invoke()
{
- var obj = new HasOverridedMethod();
- var result = obj.Base().Property;
+ var obj = new HasOverrideMethod();
+ var result = obj.Base().Property;
Assert.Equal("Property", result);
}
[Fact]
- public void OverridedMethod_Invoke()
+ public void OverrideMethod_Invoke()
{
- var obj = new HasOverridedMethod();
- var result = obj.Base().Method(1, "a");
+ var obj = new HasOverrideMethod();
+ var result = obj.Base().Method(1, "a");
Assert.Equal("Method(1, a)", result);
}
[Fact]
- public void OverridedMethod_InvokeTwice()
+ public void OverrideMethod_InvokeTwice()
{
- var obj = new HasOverridedMethod();
- var a = obj.Base().Method(1, "a");
- var b = obj.Base().Method(2, "b");
+ var obj = new HasOverrideMethod();
+ var a = obj.Base().Method(1, "a");
+ var b = obj.Base().Method(2, "b");
var result = a + "----" + b;
Assert.Equal("Method(1, a)----Method(2, b)", result);
}
diff --git a/test/InterfaceBaseInvoke.Tests.AssemblyToProcess/ReoverridedMethodTestCases.cs b/test/InterfaceBaseInvoke.Tests.AssemblyToProcess/ReoverridedMethodTestCases.cs
index b074b58..985539c 100644
--- a/test/InterfaceBaseInvoke.Tests.AssemblyToProcess/ReoverridedMethodTestCases.cs
+++ b/test/InterfaceBaseInvoke.Tests.AssemblyToProcess/ReoverridedMethodTestCases.cs
@@ -1,22 +1,22 @@
namespace InterfaceBaseInvoke.Tests.AssemblyToProcess;
-public class ReoverridedMethodTestCases
+public class ReOverrideMethodTestCases
{
[Fact]
public void Property_InvokeTwice()
{
- var obj = new HasReoverridedMethod();
- var result = obj.Base().Property + "----" + obj.Base().Property;
- Assert.Equal("Property----IHasReoverridedMethod.Property", result);
+ var obj = new HasReOverrideMethod();
+ var result = obj.Base().Property + "----" + obj.Base().Property;
+ Assert.Equal("Property----IHasReOverrideMethod.Property", result);
}
[Fact]
- public void ReoverrideMethod_InvokeTwice()
+ public void ReOverrideMethod_InvokeTwice()
{
- var obj = new HasReoverridedMethod();
- var a = obj.Base().Method(1, "a");
- var b = obj.Base().Method(2, "b");
+ var obj = new HasReOverrideMethod();
+ var a = obj.Base().Method(1, "a");
+ var b = obj.Base().Method(2, "b");
var result = a + "----" + b;
- Assert.Equal("Method(1, a)----IHasReoverridedMethod.Method(2, b)", result);
+ Assert.Equal("Method(1, a)----IHasReOverrideMethod.Method(2, b)", result);
}
}
diff --git a/test/InterfaceBaseInvoke.Tests.AssemblyToProcess/StructTestCases.cs b/test/InterfaceBaseInvoke.Tests.AssemblyToProcess/StructTestCases.cs
index 448c2f9..5a05574 100644
--- a/test/InterfaceBaseInvoke.Tests.AssemblyToProcess/StructTestCases.cs
+++ b/test/InterfaceBaseInvoke.Tests.AssemblyToProcess/StructTestCases.cs
@@ -1,6 +1,6 @@
namespace InterfaceBaseInvoke.Tests.AssemblyToProcess;
-public struct HasOverridedMethodStruct : IHasOverridedMethod
+public struct HasOverrideMethodStruct : IHasOverrideMethod
{
public string Property => throw new InvalidOperationException();
public string Method(int x, string y) => throw new InvalidOperationException();
@@ -11,25 +11,25 @@ public class StructTestCases
[Fact]
public void Property_Invoke()
{
- var obj = new HasOverridedMethodStruct();
- var result = obj.Base().Property;
+ var obj = new HasOverrideMethodStruct();
+ var result = obj.Base().Property;
Assert.Equal("Property", result);
}
[Fact]
- public void OverridedMethod_Invoke()
+ public void OverrideMethod_Invoke()
{
- var obj = new HasOverridedMethodStruct();
- var result = obj.Base().Method(1, "a");
+ var obj = new HasOverrideMethodStruct();
+ var result = obj.Base().Method(1, "a");
Assert.Equal("Method(1, a)", result);
}
[Fact]
- public void OverridedMethod_InvokeTwice()
+ public void OverrideMethod_InvokeTwice()
{
- var obj = new HasOverridedMethodStruct();
- var a = obj.Base().Method(1, "a");
- var b = obj.Base().Method(2, "b");
+ var obj = new HasOverrideMethodStruct();
+ var a = obj.Base().Method(1, "a");
+ var b = obj.Base().Method(2, "b");
var result = a + "----" + b;
Assert.Equal("Method(1, a)----Method(2, b)", result);
}
diff --git a/test/InterfaceBaseInvoke.Tests.AssemblyToProcess/~TestTypes/GenericInterface.cs b/test/InterfaceBaseInvoke.Tests.AssemblyToProcess/~TestTypes/GenericInterface.cs
index 95bf136..5cec6f1 100644
--- a/test/InterfaceBaseInvoke.Tests.AssemblyToProcess/~TestTypes/GenericInterface.cs
+++ b/test/InterfaceBaseInvoke.Tests.AssemblyToProcess/~TestTypes/GenericInterface.cs
@@ -29,7 +29,7 @@ public interface IGenericHasEmptyGenericMethod
string Method(T x, TParameter y);
}
-public interface IGenericHasOverridedGenericMethod : IGenericHasEmptyGenericMethod
+public interface IGenericHasOverrideGenericMethod : IGenericHasEmptyGenericMethod
{
string IGenericHasEmptyGenericMethod.Method(int x, string y) => $"{nameof(Method)}({x}, {y})";
string IGenericHasEmptyGenericMethod.Method(T x, string y) => $"{nameof(Method)}({typeof(T).Name} {x}, {y})";
@@ -38,7 +38,7 @@ public interface IGenericHasOverridedGenericMethod : IGenericHasEmptyGener
string IGenericHasEmptyGenericMethod.Method(T x, TParameter y) => $"{nameof(Method)}<{typeof(TParameter).Name}>({typeof(T).Name} {x}, {typeof(TParameter).Name} {y})";
}
-public class GenericHasOverridedGenericMethod : IGenericHasOverridedGenericMethod
+public class GenericHasOverrideGenericMethod : IGenericHasOverrideGenericMethod
{
string IGenericHasEmptyGenericMethod.Method(int x, string y) => throw new InvalidOperationException();
string IGenericHasEmptyGenericMethod.Method(T x, string y) => throw new InvalidOperationException();
diff --git a/test/InterfaceBaseInvoke.Tests.AssemblyToProcess/~TestTypes/GenericMethod.cs b/test/InterfaceBaseInvoke.Tests.AssemblyToProcess/~TestTypes/GenericMethod.cs
index 6e6273c..4f02491 100644
--- a/test/InterfaceBaseInvoke.Tests.AssemblyToProcess/~TestTypes/GenericMethod.cs
+++ b/test/InterfaceBaseInvoke.Tests.AssemblyToProcess/~TestTypes/GenericMethod.cs
@@ -18,13 +18,13 @@ public interface IHasEmptyGenericMethod
string Method(int x, string y);
}
-public interface IHasOverridedGenericMethod : IHasEmptyGenericMethod
+public interface IHasOverrideGenericMethod : IHasEmptyGenericMethod
{
string IHasEmptyGenericMethod.Method(int x, string y) => $"{nameof(Method)}({x}, {y})";
string IHasEmptyGenericMethod.Method(int x, string y) => $"{nameof(Method)}<{typeof(T).Name}>({x}, {y})";
}
-public class HasOverridedGenericMethod : IHasOverridedGenericMethod
+public class HasOverrideGenericMethod : IHasOverrideGenericMethod
{
public string Method(int x, string y) => throw new InvalidOperationException();
public string Method(int x, string y) => throw new InvalidOperationException();
diff --git a/test/InterfaceBaseInvoke.Tests.AssemblyToProcess/~TestTypes/Method.cs b/test/InterfaceBaseInvoke.Tests.AssemblyToProcess/~TestTypes/Method.cs
index a3b702c..f301db9 100644
--- a/test/InterfaceBaseInvoke.Tests.AssemblyToProcess/~TestTypes/Method.cs
+++ b/test/InterfaceBaseInvoke.Tests.AssemblyToProcess/~TestTypes/Method.cs
@@ -23,25 +23,25 @@ public interface IHasEmptyMethod
string Method(int x, string y);
}
-public interface IHasOverridedMethod : IHasEmptyMethod
+public interface IHasOverrideMethod : IHasEmptyMethod
{
string IHasEmptyMethod.Property => $"{nameof(Property)}";
string IHasEmptyMethod.Method(int x, string y) => $"{nameof(Method)}({x}, {y})";
}
-public class HasOverridedMethod : IHasOverridedMethod
+public class HasOverrideMethod : IHasOverrideMethod
{
public string Property => throw new InvalidOperationException();
public string Method(int x, string y) => throw new InvalidOperationException();
}
-public interface IHasReoverridedMethod : IHasOverridedMethod
+public interface IHasReOverrideMethod : IHasOverrideMethod
{
- string IHasEmptyMethod.Property => $"{nameof(IHasReoverridedMethod)}.{nameof(Property)}";
- string IHasEmptyMethod.Method(int x, string y) => $"{nameof(IHasReoverridedMethod)}.{nameof(Method)}({x}, {y})";
+ string IHasEmptyMethod.Property => $"{nameof(IHasReOverrideMethod)}.{nameof(Property)}";
+ string IHasEmptyMethod.Method(int x, string y) => $"{nameof(IHasReOverrideMethod)}.{nameof(Method)}({x}, {y})";
}
-public class HasReoverridedMethod : IHasReoverridedMethod
+public class HasReOverrideMethod : IHasReOverrideMethod
{
public string Property => throw new InvalidOperationException();
public string Method(int x, string y) => throw new InvalidOperationException();
diff --git a/test/InterfaceBaseInvoke.Tests.InvalidAssemblyToProcess/InvokeAbstractMethodTestCases.cs b/test/InterfaceBaseInvoke.Tests.InvalidAssemblyToProcess/InvokeAbstractMethodTestCases.cs
index dd9fe44..0448fd9 100644
--- a/test/InterfaceBaseInvoke.Tests.InvalidAssemblyToProcess/InvokeAbstractMethodTestCases.cs
+++ b/test/InterfaceBaseInvoke.Tests.InvalidAssemblyToProcess/InvokeAbstractMethodTestCases.cs
@@ -10,7 +10,7 @@ private class InheritIEmptyMethod : IHasEmptyMethod
public string Method(int x, string y) => throw new InvalidOperationException();
}
- private class InheritIOverridedMethod : IHasOverridedMethod
+ private class InheritIOverrideMethod : IHasOverrideMethod
{
public string Method(int x, string y) => throw new InvalidOperationException();
}
@@ -23,7 +23,7 @@ public string EmptyMethod_Invoke()
public string EmptyMethod_Invoke_MultiLevel()
{
- var obj = new InheritIOverridedMethod();
+ var obj = new InheritIOverrideMethod();
return obj.Base().Method(0, string.Empty);
}
}
diff --git a/test/InterfaceBaseInvoke.Tests.SourceGenerator/InterfaceBaseInvoke.Tests.SourceGenerator.csproj b/test/InterfaceBaseInvoke.Tests.SourceGenerator/InterfaceBaseInvoke.Tests.SourceGenerator.csproj
index ed93a2f..63f7835 100644
--- a/test/InterfaceBaseInvoke.Tests.SourceGenerator/InterfaceBaseInvoke.Tests.SourceGenerator.csproj
+++ b/test/InterfaceBaseInvoke.Tests.SourceGenerator/InterfaceBaseInvoke.Tests.SourceGenerator.csproj
@@ -6,7 +6,7 @@
-
+
diff --git a/test/InterfaceBaseInvoke.Tests.StandardAssemblyToProcess/InterfaceBaseInvoke.Tests.StandardAssemblyToProcess.csproj b/test/InterfaceBaseInvoke.Tests.StandardAssemblyToProcess/InterfaceBaseInvoke.Tests.StandardAssemblyToProcess.csproj
index b24aa01..23df537 100644
--- a/test/InterfaceBaseInvoke.Tests.StandardAssemblyToProcess/InterfaceBaseInvoke.Tests.StandardAssemblyToProcess.csproj
+++ b/test/InterfaceBaseInvoke.Tests.StandardAssemblyToProcess/InterfaceBaseInvoke.Tests.StandardAssemblyToProcess.csproj
@@ -18,7 +18,7 @@
-
+
diff --git a/test/InterfaceBaseInvoke.Tests/AssemblyTests.cs b/test/InterfaceBaseInvoke.Tests/AssemblyTests.cs
index ce1399d..0ba8da9 100644
--- a/test/InterfaceBaseInvoke.Tests/AssemblyTests.cs
+++ b/test/InterfaceBaseInvoke.Tests/AssemblyTests.cs
@@ -1,8 +1,6 @@
using System.IO;
using System.Reflection.Metadata;
using System.Reflection.PortableExecutable;
-using InterfaceBaseInvoke.Tests.Support;
-using Xunit;
namespace InterfaceBaseInvoke.Tests
{
diff --git a/test/InterfaceBaseInvoke.Tests/GlobalUsings.cs b/test/InterfaceBaseInvoke.Tests/GlobalUsings.cs
index 1f4ffb8..43a5971 100644
--- a/test/InterfaceBaseInvoke.Tests/GlobalUsings.cs
+++ b/test/InterfaceBaseInvoke.Tests/GlobalUsings.cs
@@ -5,6 +5,9 @@
global using System.Text;
global using Fody;
global using InterfaceBaseInvoke.Fody;
+global using InterfaceBaseInvoke.Tests.Support;
global using Mono.Cecil;
global using Mono.Cecil.Cil;
-global using MoreFodyHelpers.Extensions;
\ No newline at end of file
+global using MoreFodyHelpers.Extensions;
+global using Xunit;
+global using Xunit.Abstractions;
\ No newline at end of file
diff --git a/test/InterfaceBaseInvoke.Tests/InterfaceBaseInvoke.Tests.csproj b/test/InterfaceBaseInvoke.Tests/InterfaceBaseInvoke.Tests.csproj
index db31afa..d0ac828 100644
--- a/test/InterfaceBaseInvoke.Tests/InterfaceBaseInvoke.Tests.csproj
+++ b/test/InterfaceBaseInvoke.Tests/InterfaceBaseInvoke.Tests.csproj
@@ -1,14 +1,14 @@
- net6.0;net7.0
+ net6.0;net7.0;net8.0
true
-
-
-
+
+
+
diff --git a/test/InterfaceBaseInvoke.Tests/Support/AssemblyToProcessFixture.cs b/test/InterfaceBaseInvoke.Tests/Support/AssemblyToProcessFixture.cs
index 235020b..5e69711 100644
--- a/test/InterfaceBaseInvoke.Tests/Support/AssemblyToProcessFixture.cs
+++ b/test/InterfaceBaseInvoke.Tests/Support/AssemblyToProcessFixture.cs
@@ -2,83 +2,54 @@
#pragma warning disable 618
-namespace InterfaceBaseInvoke.Tests.Support
-{
- public static class AssemblyToProcessFixture
- {
- public static TestResult TestResult { get; }
+namespace InterfaceBaseInvoke.Tests.Support;
- public static ModuleDefinition OriginalModule { get; }
- public static ModuleDefinition ResultModule { get; }
-
- static AssemblyToProcessFixture()
- {
- (TestResult, OriginalModule, ResultModule) = Process();
- }
+public static class AssemblyToProcessFixture
+{
+ public static TestResult TestResult { get; }
- internal static (TestResult testResult, ModuleDefinition originalModule, ModuleDefinition resultModule) Process()
- {
- var assemblyPath = FixtureHelper.IsolateAssembly();
+ public static ModuleDefinition OriginalModule { get; }
+ public static ModuleDefinition ResultModule { get; }
- var weavingTask = new GuardedWeaver();
+ static AssemblyToProcessFixture()
+ {
+ (TestResult, OriginalModule, ResultModule) = Process();
+ }
- var testResult = weavingTask.ExecuteTestRun(
- assemblyPath,
- ignoreCodes: new[]
- {
- "0x801312da" // VLDTR_E_MR_VARARGCALLINGCONV
- },
- writeSymbols: true,
- beforeExecuteCallback: BeforeExecuteCallback,
- runPeVerify: false
- );
+ internal static (TestResult testResult, ModuleDefinition originalModule, ModuleDefinition resultModule) Process()
+ {
+ var assemblyPath = FixtureHelper.IsolateAssembly();
- using var assemblyResolver = new TestAssemblyResolver();
+ var weavingTask = new GuardedWeaver();
- var readerParams = new ReaderParameters(ReadingMode.Immediate)
+ var testResult = weavingTask.ExecuteTestRun(
+ assemblyPath,
+ ignoreCodes: new[]
{
- ReadSymbols = true,
- AssemblyResolver = assemblyResolver
- };
-
- var originalModule = ModuleDefinition.ReadModule(assemblyPath, readerParams);
- var resultModule = ModuleDefinition.ReadModule(testResult.AssemblyPath, readerParams);
+ "0x801312da" // VLDTR_E_MR_VARARGCALLINGCONV
+ },
+ writeSymbols: true,
+ beforeExecuteCallback: BeforeExecuteCallback,
+ runPeVerify: false
+ );
- return (testResult, originalModule, resultModule);
- }
-
- internal static void BeforeExecuteCallback(ModuleDefinition module)
- {
- // This reference is added by Fody, it's not supposed to be there
- module.AssemblyReferences.RemoveWhere(i => string.Equals(i.Name, "System.Private.CoreLib", StringComparison.OrdinalIgnoreCase));
- }
+ using var assemblyResolver = new TestAssemblyResolver();
- internal class GuardedWeaver : ModuleWeaver
+ var readerParams = new ReaderParameters(ReadingMode.Immediate)
{
- private readonly List _errors = new();
+ ReadSymbols = true,
+ AssemblyResolver = assemblyResolver
+ };
- public override void Execute()
- {
- try
- {
- base.Execute();
- }
- catch (Exception ex)
- {
- var str = new StringBuilder();
- foreach (var error in _errors)
- str.AppendLine(error);
+ var originalModule = ModuleDefinition.ReadModule(assemblyPath, readerParams);
+ var resultModule = ModuleDefinition.ReadModule(testResult.AssemblyPath, readerParams);
- str.AppendLine(ex.Message);
- throw new InvalidOperationException(str.ToString());
- }
- }
+ return (testResult, originalModule, resultModule);
+ }
- protected override void AddError(string message, SequencePoint? sequencePoint)
- {
- _errors.Add(message);
- base.AddError(message, sequencePoint);
- }
- }
+ internal static void BeforeExecuteCallback(ModuleDefinition module)
+ {
+ // This reference is added by Fody, it's not supposed to be there
+ module.AssemblyReferences.RemoveWhere(i => string.Equals(i.Name, "System.Private.CoreLib", StringComparison.OrdinalIgnoreCase));
}
}
diff --git a/test/InterfaceBaseInvoke.Tests/Support/AssertionExtensions.cs b/test/InterfaceBaseInvoke.Tests/Support/AssertionExtensions.cs
index 3685dcf..d295285 100644
--- a/test/InterfaceBaseInvoke.Tests/Support/AssertionExtensions.cs
+++ b/test/InterfaceBaseInvoke.Tests/Support/AssertionExtensions.cs
@@ -1,22 +1,25 @@
-using Xunit;
+using System.Diagnostics;
-namespace InterfaceBaseInvoke.Tests.Support
+namespace InterfaceBaseInvoke.Tests.Support;
+
+internal static class AssertionExtensions
{
- internal static class AssertionExtensions
+ [DebuggerStepThrough]
+ public static T ShouldNotBeNull(this T? actual) where T : class
{
- public static T ShouldNotBeNull(this T? actual) where T : class
- {
- Assert.NotNull(actual);
- return actual;
- }
+ Assert.NotNull(actual);
+ return actual;
+ }
- public static void ShouldNotContain(this IEnumerable items, Func predicate)
- => Assert.DoesNotContain(items, item => predicate(item));
+ [DebuggerStepThrough]
+ public static void ShouldNotContain(this IEnumerable items, Func predicate)
+ => Assert.DoesNotContain(items, item => predicate(item));
- public static void ShouldNotContain(this string str, string expectedSubstring)
- => Assert.DoesNotContain(expectedSubstring, str);
+ [DebuggerStepThrough]
+ public static void ShouldNotContain(this string str, string expectedSubstring)
+ => Assert.DoesNotContain(expectedSubstring, str);
- public static void ShouldContain(this string str, string expectedSubstring)
- => Assert.Contains(expectedSubstring, str);
- }
+ [DebuggerStepThrough]
+ public static void ShouldContain(this string str, string expectedSubstring)
+ => Assert.Contains(expectedSubstring, str);
}
diff --git a/test/InterfaceBaseInvoke.Tests/Support/FixtureHelper.cs b/test/InterfaceBaseInvoke.Tests/Support/FixtureHelper.cs
index 0ee3d2b..015fe51 100644
--- a/test/InterfaceBaseInvoke.Tests/Support/FixtureHelper.cs
+++ b/test/InterfaceBaseInvoke.Tests/Support/FixtureHelper.cs
@@ -9,16 +9,16 @@ internal static class FixtureHelper
public static string IsolateAssembly()
{
var assembly = typeof(T).Assembly;
- var assemblyPath = assembly.Location!;
+ var assemblyPath = assembly.Location;
var assemblyDir = Path.GetDirectoryName(assemblyPath)!;
var rootTestDir = Path.Combine(assemblyDir, "WeavingTest");
- var asmTestDir = Path.Combine(rootTestDir, Path.GetFileNameWithoutExtension(assemblyPath)!);
+ var asmTestDir = Path.Combine(rootTestDir, Path.GetFileNameWithoutExtension(assemblyPath));
EmptyDirectory(asmTestDir);
Directory.CreateDirectory(asmTestDir);
var destFile = CopyFile(assemblyPath, asmTestDir);
- CopyFile(Path.ChangeExtension(assemblyPath, ".pdb")!, asmTestDir);
+ CopyFile(Path.ChangeExtension(assemblyPath, ".pdb"), asmTestDir);
CopyFile(Path.Combine(assemblyDir, "InterfaceBaseInvoke.dll"), asmTestDir);
return destFile;
diff --git a/test/InterfaceBaseInvoke.Tests/Support/GuardedWeaver.cs b/test/InterfaceBaseInvoke.Tests/Support/GuardedWeaver.cs
new file mode 100644
index 0000000..631e481
--- /dev/null
+++ b/test/InterfaceBaseInvoke.Tests/Support/GuardedWeaver.cs
@@ -0,0 +1,13 @@
+namespace InterfaceBaseInvoke.Tests.Support;
+
+///
+/// Used to collect all errors.
+///
+internal class GuardedWeaver : ModuleWeaver
+{
+ protected override bool AddError(string message, SequencePoint? sequencePoint)
+ {
+ base.AddError(message, sequencePoint);
+ return false;
+ }
+}
diff --git a/test/InterfaceBaseInvoke.Tests/Support/InvalidAssemblyOnlyDebugFactAttribute.cs b/test/InterfaceBaseInvoke.Tests/Support/InvalidAssemblyOnlyDebugFactAttribute.cs
index fb0e3f0..9ca88bb 100644
--- a/test/InterfaceBaseInvoke.Tests/Support/InvalidAssemblyOnlyDebugFactAttribute.cs
+++ b/test/InterfaceBaseInvoke.Tests/Support/InvalidAssemblyOnlyDebugFactAttribute.cs
@@ -1,6 +1,5 @@
using System.Diagnostics;
using System.Reflection;
-using Xunit;
namespace InterfaceBaseInvoke.Tests.Support
{
diff --git a/test/InterfaceBaseInvoke.Tests/Support/InvalidAssemblyToProcessFixture.cs b/test/InterfaceBaseInvoke.Tests/Support/InvalidAssemblyToProcessFixture.cs
index ccd529d..f0175ff 100644
--- a/test/InterfaceBaseInvoke.Tests/Support/InvalidAssemblyToProcessFixture.cs
+++ b/test/InterfaceBaseInvoke.Tests/Support/InvalidAssemblyToProcessFixture.cs
@@ -14,7 +14,7 @@ public static class InvalidAssemblyToProcessFixture
static InvalidAssemblyToProcessFixture()
{
- var weavingTask = new ModuleWeaver();
+ var weavingTask = new GuardedWeaver();
TestResult = weavingTask.ExecuteTestRun(
FixtureHelper.IsolateAssembly(),
false,
@@ -25,7 +25,7 @@ static InvalidAssemblyToProcessFixture()
ResultModule = ModuleDefinition.ReadModule(TestResult.AssemblyPath, new ReaderParameters(ReadingMode.Immediate)
{
- AssemblyResolver = assemblyResolver
+ AssemblyResolver = assemblyResolver,
});
var typeName = TestResult.Assembly.GetName().Name + "." + nameof(InvalidAssemblyToProcessReference);
diff --git a/test/InterfaceBaseInvoke.Tests/Support/ModuleDefinitionExtensions.cs b/test/InterfaceBaseInvoke.Tests/Support/ModuleDefinitionExtensions.cs
new file mode 100644
index 0000000..b2c92c7
--- /dev/null
+++ b/test/InterfaceBaseInvoke.Tests/Support/ModuleDefinitionExtensions.cs
@@ -0,0 +1,15 @@
+using System.IO;
+using InterfaceBaseInvoke.Fody.Processing;
+using MoreFodyHelpers.Processing;
+
+namespace InterfaceBaseInvoke.Tests.Support;
+
+public static class ModuleDefinitionExtensions
+{
+ public static ModuleWeavingContext CreateWeavingContext(this ModuleDefinition module)
+ {
+ var path = module.Assembly.MainModule.FileName;
+ var dir = Path.GetDirectoryName(path);
+ return new(module, WeaverAnchors.AssemblyName, dir);
+ }
+}
diff --git a/test/InterfaceBaseInvoke.Tests/Weaving/ClassTestsBase.cs b/test/InterfaceBaseInvoke.Tests/Weaving/ClassTestsBase.cs
index 2c4c822..de48001 100644
--- a/test/InterfaceBaseInvoke.Tests/Weaving/ClassTestsBase.cs
+++ b/test/InterfaceBaseInvoke.Tests/Weaving/ClassTestsBase.cs
@@ -1,8 +1,6 @@
using System.Reflection;
using InterfaceBaseInvoke.Tests.AssemblyToProcess;
using InterfaceBaseInvoke.Tests.InvalidAssemblyToProcess;
-using InterfaceBaseInvoke.Tests.Support;
-using Xunit;
namespace InterfaceBaseInvoke.Tests.Weaving
{
diff --git a/test/InterfaceBaseInvoke.Tests/Weaving/ModuleWeaverTests.cs b/test/InterfaceBaseInvoke.Tests/Weaving/ModuleWeaverTests.cs
new file mode 100644
index 0000000..a2538c4
--- /dev/null
+++ b/test/InterfaceBaseInvoke.Tests/Weaving/ModuleWeaverTests.cs
@@ -0,0 +1,57 @@
+#pragma warning disable CS0618 // Type or member is obsolete
+
+using System.IO;
+using System.Linq;
+using InterfaceBaseInvoke.Fody.Processing;
+using MoreFodyHelpers.Processing;
+
+namespace InterfaceBaseInvoke.Tests.Weaving;
+
+public class ModuleWeaverTests
+{
+ private readonly ITestOutputHelper _output;
+
+ public ModuleWeaverTests(ITestOutputHelper output)
+ {
+ _output = output;
+ }
+
+ [Fact]
+ public void Execute_Test()
+ {
+ var modules = new[]
+ {
+ AssemblyToProcessFixture.OriginalModule,
+ StandardAssemblyToProcessFixture.OriginalModule,
+ };
+ foreach (var module in modules)
+ {
+ _output.WriteLine("ModuleWeaver is executing: " + module.Assembly.MainModule.FileName);
+ var wearer = new ModuleWeaver
+ {
+ ModuleDefinition = module,
+ LogError = m => throw new InvalidOperationException(m),
+ LogErrorPoint = (m, p) => throw new InvalidOperationException(m),
+ };
+ wearer.Execute();
+ }
+ }
+
+ [Fact]
+ public void IsWeaverReferenced_Test()
+ {
+ var modules = new[]
+ {
+ AssemblyToProcessFixture.OriginalModule,
+ StandardAssemblyToProcessFixture.OriginalModule,
+ };
+ foreach (var module in modules)
+ {
+ using var context = module.CreateWeavingContext();
+ foreach (var type in module.GetTypes().Where(m => m.Name.EndsWith("TestCases")))
+ {
+ Assert.True(type.IsWeaverReferencedDeep(context));
+ }
+ }
+ }
+}
diff --git a/test/InterfaceBaseInvoke.Tests/Weaving/~InvalidTests/AnchorMethodTests.cs b/test/InterfaceBaseInvoke.Tests/Weaving/~InvalidTests/AnchorMethodTests.cs
index a83488b..465ec37 100644
--- a/test/InterfaceBaseInvoke.Tests/Weaving/~InvalidTests/AnchorMethodTests.cs
+++ b/test/InterfaceBaseInvoke.Tests/Weaving/~InvalidTests/AnchorMethodTests.cs
@@ -1,6 +1,4 @@
using InterfaceBaseInvoke.Tests.InvalidAssemblyToProcess;
-using InterfaceBaseInvoke.Tests.Support;
-using Xunit;
namespace InterfaceBaseInvoke.Tests.Weaving
{
diff --git a/test/InterfaceBaseInvoke.Tests/Weaving/~InvalidTests/InvokeAbstractMethodTests.cs b/test/InterfaceBaseInvoke.Tests/Weaving/~InvalidTests/InvokeAbstractMethodTests.cs
index f804c63..5d7be4f 100644
--- a/test/InterfaceBaseInvoke.Tests/Weaving/~InvalidTests/InvokeAbstractMethodTests.cs
+++ b/test/InterfaceBaseInvoke.Tests/Weaving/~InvalidTests/InvokeAbstractMethodTests.cs
@@ -1,8 +1,6 @@
using System.Linq;
using System.Threading.Tasks;
using InterfaceBaseInvoke.Tests.InvalidAssemblyToProcess;
-using InterfaceBaseInvoke.Tests.Support;
-using Xunit;
namespace InterfaceBaseInvoke.Tests.Weaving
{
diff --git a/test/InterfaceBaseInvoke.Tests/Weaving/~InvalidTests/InvokeMethodFluentllyTests.cs b/test/InterfaceBaseInvoke.Tests/Weaving/~InvalidTests/InvokeMethodFluentllyTests.cs
index 2943db1..79c91a3 100644
--- a/test/InterfaceBaseInvoke.Tests/Weaving/~InvalidTests/InvokeMethodFluentllyTests.cs
+++ b/test/InterfaceBaseInvoke.Tests/Weaving/~InvalidTests/InvokeMethodFluentllyTests.cs
@@ -1,6 +1,4 @@
using InterfaceBaseInvoke.Tests.InvalidAssemblyToProcess;
-using InterfaceBaseInvoke.Tests.Support;
-using Xunit;
namespace InterfaceBaseInvoke.Tests.Weaving
{