Skip to content

Annotate unsupported APIs in Serialization #118556

@StephenMolloy

Description

@StephenMolloy

Copied from #50526, since this issue references both Serialization and Xml APIs. This copy can be used to track the Xml API.


As part of #47228 i am running an analyzer to detect APIs throwing PNSE but not annotated with Obsolete/SupportedOSPlatform/UnsupportedOSPlatform attributes, we need to annotate them so that developers get warnings when they use them unexpectedly

For now, I have results only cross-platform builds, analysis of targeted builds are coming soon where more APIs could be detected

API Comment Suggestion Location
'XmlObjectSerializerReadContextComplex.ResolveDataContractTypeInSharedTypeMode(string, string, out Assembly)' unconditionally throws on all platforms add [Obsolete] libraries\System.Private.DataContractSerialization\src\System\Runtime\Serialization\XmlObjectSerializerReadContextComplex.cs(143,13)
'XsdDataContractExporter.Schemas.get' unconditionally throws on all platforms add [Obsolete] libraries\System.Private.DataContractSerialization\src\System\Runtime\Serialization\XsdDataContractExporter.cs(38,17)
'XsdDataContractExporter.DataContractSet.get' unconditionally throws on all platforms add [Obsolete] libraries\System.Private.DataContractSerialization\src\System\Runtime\Serialization\XsdDataContractExporter.cs(59,17)
'XmlDictionaryReader.CreateMtomReader(Stream, Encoding[], string?, XmlDictionaryReaderQuotas, int, OnXmlDictionaryReaderClose?)' unconditionally throws on all platforms add [Obsolete] libraries\System.Private.DataContractSerialization\src\System\Xml\XmlDictionaryReader.cs(153,13)
'XmlDictionaryReader.CreateMtomReader(byte[], int, int, Encoding[], string?, XmlDictionaryReaderQuotas, int, OnXmlDictionaryReaderClose?)' unconditionally throws on all platforms add [Obsolete] libraries\System.Private.DataContractSerialization\src\System\Xml\XmlDictionaryReader.cs(177,13)
'XmlDictionaryWriter.CreateMtomWriter(Stream, Encoding, int, string, string?, string?, bool, bool)' unconditionally throws on all platforms add [Obsolete] libraries\System.Private.DataContractSerialization\src\System\Xml\XmlDictionaryWriter.cs(68,13)
'XmlCollation.CreateSortKey(string)' Unsupported on Unux (AnyOS than windows) make XmlCollation.UpperFirst windows only libraries\System.Private.Xml\src\System\Xml\Xsl\Runtime\XmlCollation.Unix.cs(24,17)

Note: We are suggesting adding [Obsolete] for the APIs only supported in .Net framework but not supported in .NetCore, with the corresponding Message, DiagnosticId, and UrlFormat

[Obsolete(Obsoletions.AuthenticationManagerMessage, DiagnosticId = Obsoletions.AuthenticationManagerDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
You can claim the next available DiagnosticId from Obsoletions.cs .

cc @jeffhandley @terrajobst @GrabYourPitchforks

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions