-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implemented support for method info caching also for open generic types
- Loading branch information
dd
committed
Oct 20, 2021
1 parent
a7080eb
commit a21c3cc
Showing
6 changed files
with
100 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/MethodBoundaryAspect.Fody.UnitTests.NetFramework/GenericClassWithOpenTypeTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System; | ||
using FluentAssertions; | ||
using MethodBoundaryAspect.Fody.UnitTests.TestAssembly.NetFramework; | ||
using Xunit; | ||
|
||
namespace MethodBoundaryAspect.Fody.UnitTests.NetFramework | ||
{ | ||
public class GenericClassWithOpenTypeTests : MethodBoundaryAspectNetFrameworkTestBase | ||
{ | ||
[Fact] | ||
public void IfCGenericClassWithOpenType_ThenTheAssemblyShouldBeValid() | ||
{ | ||
// Arrange | ||
const string testMethodName = nameof(GenericClassWithOpenType.CallOpenTypeMethod); | ||
var testClassType = typeof(GenericClassWithOpenType); | ||
|
||
// Act | ||
WeaveAssemblyMethodAndLoad(testClassType, nameof(GenericClassWithOpenType.OpenTypeMethod)); | ||
var result = AssemblyLoader.InvokeMethod(testClassType.TypeInfo(), testMethodName, 42); | ||
|
||
// Assert | ||
result.Should().Be("OpenTypeMethod"); | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...itTests.TestAssembly.NetFramework/Aspects/GenericClassWithOpenTypeSetReturnValueAspect.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using MethodBoundaryAspect.Fody.Attributes; | ||
|
||
namespace MethodBoundaryAspect.Fody.UnitTests.TestAssembly.NetFramework.Aspects | ||
{ | ||
public class GenericClassWithOpenTypeSetReturnValueAspect : OnMethodBoundaryAspect | ||
{ | ||
public override void OnExit(MethodExecutionArgs arg) | ||
{ | ||
GenericClassWithOpenType.Result = arg.Method.Name; | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...MethodBoundaryAspect.Fody.UnitTests.TestAssembly.NetFramework/GenericClassWithOpenType.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using MethodBoundaryAspect.Fody.UnitTests.TestAssembly.NetFramework.Aspects; | ||
|
||
namespace MethodBoundaryAspect.Fody.UnitTests.TestAssembly.NetFramework | ||
{ | ||
public class GenericClassWithOpenType | ||
{ | ||
public static object Result { get; set; } | ||
|
||
[GenericClassWithOpenTypeSetReturnValueAspect] | ||
public static T OpenTypeMethod<T>(T arg) | ||
{ | ||
return default; | ||
} | ||
|
||
public static void CallOpenTypeMethod(int value) | ||
{ | ||
OpenTypeMethod(value); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters