-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test to ensure all wrapper methods have the last "int opCode" par…
…ameter
- Loading branch information
1 parent
2f28ef3
commit ba059d4
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
test/Datadog.Trace.ClrProfiler.Managed.Tests/IntegrationSignatureTests.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,37 @@ | ||
using System.Collections.Generic; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Linq; | ||
using System.Reflection; | ||
using Xunit; | ||
|
||
namespace Datadog.Trace.ClrProfiler.Managed.Tests | ||
{ | ||
public class IntegrationSignatureTests | ||
{ | ||
[SuppressMessage("StyleCop.CSharp.SpacingRules", "SA1009:ClosingParenthesisMustBeSpacedCorrectly", Justification = "Reviewed.")] | ||
public static IEnumerable<object[]> GetWrapperMethods() | ||
{ | ||
var integrationsAssembly = typeof(Instrumentation).Assembly; | ||
|
||
// find all methods in Datadog.Trace.ClrProfiler.Managed.dll with [InterceptMethod] | ||
var integrations = from wrapperType in integrationsAssembly.GetTypes() | ||
from wrapperMethod in wrapperType.GetRuntimeMethods() | ||
let attributes = wrapperMethod.GetCustomAttributes<InterceptMethodAttribute>(inherit: false) | ||
where attributes.Any() | ||
select new object[] { wrapperMethod }; | ||
|
||
return integrations; | ||
} | ||
|
||
[Theory] | ||
[MemberData(nameof(GetWrapperMethods))] | ||
public void WrapperMethodHasOpCodeArgument(MethodInfo wrapperMethod) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
{ | ||
// all wrapper methods should have an additional Int32 | ||
// parameter for the original method call's opcode | ||
ParameterInfo lastParameter = wrapperMethod.GetParameters().Last(); | ||
Assert.Equal(typeof(int), lastParameter.ParameterType); | ||
Assert.Equal("opCode", lastParameter.Name); | ||
} | ||
} | ||
} |
Beautiful!