Closed RyuChigon closed 4 months ago
I think the reason for this is the same as #4624. The compiler attributes are emitted into the file as a polyfill and in packaging there are 2 versions of the dll put in the same folder. Those dlls are compatible on runtime, but they use different polyfills pointing at different types.
Duplicate of https://github.com/microsoft/vstest/issues/4624
Description
Hello, I have used
Microsoft.NET.Test.Sdk
for testing my service (.NET 6.0).In my service, reflection is used for finding specific custom attributes. It is okay until Microsoft.NET.Test.Sdk 17.3.3 version.
However, when using Microsoft.NET.Test.Sdk v17.4.0, I faced a problem about getting custom attributes by using
MethodInfo.GetCustomAttributes(Type, bool)
.The reason is
Microsoft.VisualStudio.TestPlatform.Common.Filtering.Condition::ThrownFormatExceptionForInvalidCondition(string)
hasDoesNotReturnAttribute
System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute
could not be loaded fromMicrosoft.TestPlatform.CoreUtilities
.This is the IL of
Void ThrowFormatExceptionForInvalidCondition(string)
. It refers toSystem.Diagnostics.CodeAnalysis.DoesNotReturnAttribute
of Microsoft.TestPlatform.CoreUtilities.I think
Microsoft.VisualStudio.TestPlatform.Common.dll
has wrong reference aboutSystem.Diagnostics.CodeAnalysis
.Could you solve this problem? Thank you :)
IL of Microsoft.TestPlatform.CoreUtilities v17.3.3
It includes
DoesNotReturnAttribute
IL of Microsoft.TestPlatform.CoreUtilities v17.4.0
not include
DoesNotReturnAttribute
Sample Code
Dependencies
Diagnostic logs
Environment