dotnet / dotnet/runtime

Align System.Reflection.Metadata CustomAttributeDecoder tests with resource-embedded assembly scheme

Open
#127,208 1 comment 0 reactions 0 assignees View on GitHub
area-System.Reflection.Metadata
Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Description

## 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
https://github.com/dotnet/runtime/blob/f942875639cf93fce159b0c1f66aba59b8b2d942/src/libraries/System.Reflection.Metadata/tests/Resources/TestResources.cs#L19-L28

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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.