Skip to content

Remove legacy formatter serialization from custom exceptions - #55889

Merged
dsplaisted merged 1 commit into
mainfrom
marcpopmsft-remove-exception-serialization
Aug 25, 2026
Merged

dsplaisted merged 1 commit into
mainfrom
marcpopmsft-remove-exception-serialization

Conversation

@marcpopMSFT

Copy link
Copy Markdown
Member

Summary

Remove legacy formatter-based serialization support from:

  • TemplateVerificationException
  • SdkDirectoryWorkloadManifestProvider.JsonFormatException

This removes [Serializable], the protected SerializationInfo constructors, 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 or global.json parsing.

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.

  • TemplateVerificationException results were limited to dotnet/sdk, the dotnet/dotnet VMR mirror, and repositories containing copied/forked SDK sources.
  • Qualified searches for SdkDirectoryWorkloadManifestProvider.JsonFormatException found no external GitHub consumers.
  • dnceng results were limited to dotnet-sdk and its dotnet-dotnet mirror: definitions, normal throw/catch sites, and tests.
  • DevDiv returned no results for either exception.
  • No external subclasses or calls to either serialization constructor were found.

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

  • Full Debug repository build
  • SdkDirectoryWorkloadManifestProviderTests.ItFailsIfGlobalJsonIsMalformed
  • VerificationEngineTests.ExecuteFailsOnInstantiationFailure

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
Copilot AI lite review requested due to automatic review settings August 20, 2026 22:43
@marcpopMSFT
marcpopMSFT requested a review from a team as a code owner August 20, 2026 22:43
@azure-pipelines

Copy link
Copy Markdown
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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@marcpopMSFT
marcpopMSFT requested a review from dsplaisted August 25, 2026 20:27
@dsplaisted
dsplaisted merged commit e16b808 into main Aug 25, 2026
23 checks passed
@dsplaisted
dsplaisted deleted the marcpopmsft-remove-exception-serialization branch August 25, 2026 20:37
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Aug 26, 2026

This branch had an error being deployed

1 failed deployment
copilot-pat-pool — 08104730 Deployed Aug 25, 2026 by dsplaisted via pre_activation #939
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants