Skip to content

Update MetadataReferenceCache to stop using reflection #14792

Closed
NuGet/NuGet.Client
#7193

Description

@Nigusu-Allehu

NuGet Product(s) Affected

NuGet SDK

Current Behavior

MetadataReferenceCache.GetObject<T>() uses runtime reflection (PropertyInfo, MethodInfo.Invoke, DeclaredProperties) to discover and cache string properties on package metadata objects. This approach:

  • Is incompatible with Native AOT

Desired Behavior

Replace the reflection-based property discovery in MetadataReferenceCache.GetObject<T>() with an explicit ICacheable interface. Types that need string deduplication implement
CacheStrings(MetadataReferenceCache cache) directly, calling cache.GetString() on each string property at compile time rather than discovering them via reflection at runtime.

Activity

  1. added
    Priority:2
    Type:DCR
    Type:Tracking
    on Mar 6, 2026
  2. self-assigned this
    on Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Priority:2Type:DCRType:Tracking

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions