Skip to content

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

Open

Description

@kotlarmilos

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.

Activity

  1. added
    untriaged
    on Apr 21, 2026
  2. dotnet-policy-service commented on Apr 21, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @dotnet/area-system-reflection-metadata
    See info in area-owners.md if you want to be subscribed.

  3. removed
    untriaged
    on Apr 21, 2026
  4. added this to the Future milestone on Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions