Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a565f84

Browse files
committedFeb 21, 2025··
changes from review
1 parent bc42448 commit a565f84

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed
 

‎tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/TestAssemblyInfoRunAssemblyInitializeIntegration.cs

+6-4
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,18 @@ internal static CallTargetState OnMethodBegin<TTarget, TContext>(TTarget instanc
5454
instance.AssemblyCleanupMethod ??= EmptyCleanUpMethodInfo;
5555
}
5656

57-
string? assemblyName;
57+
string? assemblyName = null;
5858
if (testContext.TryDuckCast<TestContextStruct>(out var context) && context.TestMethod is { AssemblyName: { } contextAssemblyName })
5959
{
6060
assemblyName = contextAssemblyName;
6161
}
62-
else if (instance.Instance?.TryDuckCast<ITestAssemblyInfoWithAssembly>(out var instanceWithAssembly) == true)
62+
63+
if (string.IsNullOrEmpty(assemblyName) && instance.Instance?.TryDuckCast<ITestAssemblyInfoWithAssembly>(out var instanceWithAssembly) == true)
6364
{
6465
assemblyName = instanceWithAssembly.Assembly.GetName().Name;
6566
}
66-
else
67+
68+
if (string.IsNullOrEmpty(assemblyName))
6769
{
6870
Common.Log.Warning("Module name cannot be extracted!");
6971
return CallTargetState.GetDefault();
@@ -95,7 +97,7 @@ private static void EmptyCleanUpMethod()
9597
}
9698

9799
#pragma warning disable SA1201
98-
internal interface ITestAssemblyInfoWithAssembly : ITestAssemblyInfo
100+
internal interface ITestAssemblyInfoWithAssembly
99101
#pragma warning restore SA1201
100102
{
101103
Assembly Assembly { get; }

‎tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/TestMethodRunnerExecuteIntegration3_8.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public static class TestMethodRunnerExecuteIntegration3_8
4646
return new CallTargetReturn<TReturn?>(returnValue);
4747
}
4848

49-
if (returnValue is IList { Count: > 0 } lstResults)
49+
if (returnValue is ICollection { Count: > 0 } lstResults)
5050
{
5151
foreach (var testResultObject in lstResults)
5252
{

‎tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/UnitTestRunnerRunSingleTestAsyncIntegration3_8.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ internal static CallTargetState OnMethodBegin<TTarget, TTestMethod, TMessageLogg
5555
}
5656

5757
MethodInfoCacheItem? methodInfoCacheItem;
58-
if (state.State is StrongBox<MethodInfoCacheItem?> box)
58+
if (state.State is StrongBox<MethodInfoCacheItem?> { Value: { } value })
5959
{
60-
methodInfoCacheItem = box.Value ?? MsTestIntegration.IsTestMethodRunnableThreadLocal.Value;
60+
methodInfoCacheItem = value;
6161
}
6262
else
6363
{

0 commit comments

Comments
 (0)
Please sign in to comment.