Background and motivation
Following up on #76540, this tracks the proposal to add user browsable locking APIs for the System.Text.Json metadata types. It follows the API shape applied to JsonSerializerOptions in #74431.
API Proposal
namespaceSystem.Text.Json.Metadata;publicpartialstaticclassJsonTypeInfo{publicboolIsReadOnly{get;}publicvoidMakeReadOnly();}API Usage
varresolver=newDefaultJsonTypeInfoResolver{Modifiers={static typeInfo =>{if(typeInfo.IsReadOnly){// type is locked for further modification, exit the modifierreturn;}if(typeInfo.Type==typeof(MySpecialPoco)){typeInfo.CreateObject=()=>newMySpecialPoco("defaultValue");// prevent subsequent modifiers/resolvers from further modifying this contracttypeInfo.MakeReadOnly();}}}};Alternative Designs
No response
Risks
No response
Background and motivation
Following up on #76540, this tracks the proposal to add user browsable locking APIs for the System.Text.Json metadata types. It follows the API shape applied to
JsonSerializerOptionsin #74431.API Proposal
API Usage
Alternative Designs
No response
Risks
No response