[System.Text.Json] Expose additional metadata in contract APIs. #102078
Labels
api-approved
API was approved in API review, it can be implemented
area-System.Text.Json
blocking
Marks issues that we want to fast track in order to unblock other important work
Milestone
Background and motivation
Contributes to #100159. The implementation of the https://github.com/eiriktsarpalis/stj-schema-mapper prototype revealed a number of gaps in the existing STJ contract metadata APIs which currently need to be filled manually using reflection or need to be extracted from private fields in the STJ implementation itself.
This proposal includes all the APIs necessary to make schema-related metadata available to end-users looking to export STJ schemas for .NET types, both for reflection and the source generator. The primary motivation is giving access to attribute metadata, via the
ICustomAttributeProvider
abstraction in a way that works well for both reflection and source generators/trimmed apps without compromising startup time or application size.API Proposal
API Usage
Consider the user defined-type:
Then the source generator would be able to give access to property attributes by generating the following code:
Factoring the attribute provider resolution logic into a delegate that uses a reflection literal expression this ensures that
cc @Jozkee @stephentoub @eerhardt @captainsafia
The text was updated successfully, but these errors were encountered: