Repository navigation
Remove legacy formatter serialization from custom exceptions - #55889
Merged
Merged
Conversation
Remove formatter-based serialization support from TemplateVerificationException and JsonFormatException. Neither exception has external usage in GitHub, DevDiv, or dnceng code search, and validation in these constructors cannot make unsafe formatter deserialization safe. Co-authored-by: Copilot App <[email protected]> Copilot-Session: d7bec675-d7a8-41b0-ac79-34c9da739dab
|
Azure Pipelines: Successfully started running 1 pipeline(s). 2 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
Pull request overview
Removes obsolete formatter-based serialization hooks from two SDK exceptions and updates the template verifier’s unshipped API baseline.
Changes:
- Removes serialization attributes, constructors, and imports.
- Removes the obsolete constructor from
PublicAPI.Unshipped.txt.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/TemplateEngine/Tools/Microsoft.TemplateEngine.Authoring.TemplateVerifier/TemplateVerificationException.cs | Updated as part of this pull request. |
| src/TemplateEngine/Tools/Microsoft.TemplateEngine.Authoring.TemplateVerifier/PublicAPI.Unshipped.txt | Updated as part of this pull request. |
| src/Resolvers/Microsoft.NET.Sdk.WorkloadManifestReader/SdkDirectoryWorkloadManifestProvider.JsonReader.cs | Updated as part of this pull request. |
dsplaisted
approved these changes
Aug 25, 2026
dsplaisted
had a problem deploying
to
copilot-pat-pool
August 25, 2026 20:37 — with
GitHub Actions
Failure
This branch had an error being deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Remove legacy formatter-based serialization support from:
TemplateVerificationExceptionSdkDirectoryWorkloadManifestProvider.JsonFormatExceptionThis removes
[Serializable], the protectedSerializationInfoconstructors, and the now-unused serialization imports. The template verifier's unshipped public API baseline is updated accordingly.Rationale
A security scanner flagged these automatically invoked deserialization constructors and recommended validating input before calling dangerous methods. Validation in the constructor cannot mitigate unsafe formatter deserialization: the formatter reconstructs the object graph and invokes the base
Exception(SerializationInfo, StreamingContext)constructor before the derived constructor body can validate anything. Neither constructor is involved in normal template verification orglobal.jsonparsing.The serialization support only enabled obsolete formatter scenarios such as
BinaryFormatter, remoting, or cross-AppDomain exception transport. Normal construction, throwing, and catching are unchanged.Compatibility assessment
We checked public GitHub code search and the internal DevDiv and dnceng Azure DevOps code indexes for both exception names, their qualified names, and serialization-constructor usage.
TemplateVerificationExceptionresults were limited todotnet/sdk, thedotnet/dotnetVMR mirror, and repositories containing copied/forked SDK sources.SdkDirectoryWorkloadManifestProvider.JsonFormatExceptionfound no external GitHub consumers.dotnet-sdkand itsdotnet-dotnetmirror: definitions, normal throw/catch sites, and tests.This cannot prove the absence of closed-source or reflection-based consumers, but it provides strong evidence that removing these obsolete hooks is an acceptable compatibility risk.
Validation
SdkDirectoryWorkloadManifestProviderTests.ItFailsIfGlobalJsonIsMalformedVerificationEngineTests.ExecuteFailsOnInstantiationFailure