-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[release/10.0] Fix ObsoleteAttribute incorrectly causing XML serialization to ignore properties with AppContext switch and SR resources #119916
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+233
−2
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Co-authored-by: StephenMolloy <[email protected]>
Co-authored-by: StephenMolloy <[email protected]>
Co-authored-by: StephenMolloy <[email protected]>
…ttribute behavior Co-authored-by: StephenMolloy <[email protected]>
…- which surface as errors in our build pipelines.
…izerTests.cs Co-authored-by: Copilot <[email protected]>
StephenMolloy
approved these changes
Sep 22, 2025
Added When you commit this breaking change:
Tagging @dotnet/compat for awareness of the breaking change. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area-Serialization
breaking-change
Issue or PR that represents a breaking API or functional change over a prerelease.
needs-breaking-change-doc-created
Breaking changes need an issue opened with https://github.com/dotnet/docs/issues/new?template=dotnet
Servicing-approved
Approved for servicing release
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport of #119865 to release/10.0
/cc @StephenMolloy @copilot
Customer Impact
XmlSerializer silently omits public members marked with [Obsolete], even though the attribute’s documented purpose is only to signal planned removal and guide developers at compile time. Because teams often stage deprecation by first adding [Obsolete] (with or without a warning-as-error) before later removing a member, this hidden coupling between deprecation metadata and runtime serialization creates a correctness and data loss risk: persisted XML stops containing the member’s data even though the member still exists and application code still reads it. This behavior is also inconsistent with the explicit opt out model already provided by [XmlIgnore].
Regression
Testing
Tests are added in this PR.
Risk
This is a low risk approach that prevents silent data omission while providing an escape hatch for existing applications. The risk of exceptions being thrown (for data that was being silently lost previously) is mitigated by an AppContext switch opt-out along with the increased awareness of the fact that XmlSerialzier was silently losing data before. :/
IMPORTANT: If this backport is for a servicing release, please verify that:
release/X.0-staging
, notrelease/X.0
.Package authoring no longer needed in .NET 9
IMPORTANT: Starting with .NET 9, you no longer need to edit a NuGet package's csproj to enable building and bump the version.
Keep in mind that we still need package authoring in .NET 8 and older versions.