Description
System.Reflection.Metadata.Tests uses two schemes for exercising its APIs. Most tests embed the assemblies under test as resources and read their metadata through TestResources
|
internal static class Misc |
|
{ |
|
public static readonly byte[] CPPClassLibrary2 = ResourceHelper.GetResource("Misc.CPPClassLibrary2.obj"); |
|
public static readonly byte[] EmptyType = ResourceHelper.GetResource("Misc.EmptyType.dll"); |
|
public static readonly byte[] Members = ResourceHelper.GetResource("Misc.Members.dll"); |
|
public static readonly byte[] Deterministic = ResourceHelper.GetResource("Misc.Deterministic.dll"); |
|
public static readonly byte[] Debug = ResourceHelper.GetResource("Misc.Debug.dll"); |
|
public static readonly byte[] KeyPair = ResourceHelper.GetResource("Misc.KeyPair.snk"); |
|
public static readonly byte[] Signed = ResourceHelper.GetResource("Misc.Signed.exe"); |
|
public static readonly byte[] Satellite = ResourceHelper.GetResource("Misc.SatelliteAssembly.resources.dll"); |
CustomAttributeDecoderTests instead introspects the running test assembly, which does not work under
single-file, trimming, or NativeAOT, and is sensitive to how the host resolves BCL type references (e.g. System.Runtime vs. System.Private.CoreLib). As a result the tests are guarded with ConditionalFact(NotSingleFile) and workarounds for assembly-identity differences.
Proposal
Convert CustomAttributeDecoderTests to the embedded-resource scheme used by the rest of the suite. Add a helper assembly containing the types and custom attributes the decoder needs to examine, embed it as a resource, and load its metadata through TestResources. Drop ConditionalFact(NotSingleFile) and the assembly-identity workarounds, since the tests would assert against fixed metadata in the embedded resource. This aligns the tests with the rest of System.Reflection.Metadata.Tests and makes them runnable under single-file, trimming, and NativeAOT.
Description
System.Reflection.Metadata.Tests uses two schemes for exercising its APIs. Most tests embed the assemblies under test as resources and read their metadata through TestResources
runtime/src/libraries/System.Reflection.Metadata/tests/Resources/TestResources.cs
Lines 19 to 28 in f942875
CustomAttributeDecoderTests instead introspects the running test assembly, which does not work under
single-file, trimming, or NativeAOT, and is sensitive to how the host resolves BCL type references (e.g. System.Runtime vs. System.Private.CoreLib). As a result the tests are guarded with ConditionalFact(NotSingleFile) and workarounds for assembly-identity differences.
Proposal
Convert CustomAttributeDecoderTests to the embedded-resource scheme used by the rest of the suite. Add a helper assembly containing the types and custom attributes the decoder needs to examine, embed it as a resource, and load its metadata through TestResources. Drop ConditionalFact(NotSingleFile) and the assembly-identity workarounds, since the tests would assert against fixed metadata in the embedded resource. This aligns the tests with the rest of System.Reflection.Metadata.Tests and makes them runnable under single-file, trimming, and NativeAOT.