[release/11.0.1xx-preview3] Backport MockTemplateInfo fix for STJ serialization#5947
Merged
akoeplinger merged 1 commit intodotnet:release/11.0.1xx-preview3from Apr 9, 2026
Conversation
…J serialization Backport of dotnet/templating#10066 to release/11.0.1xx-preview3. After the Newtonsoft.Json to System.Text.Json migration, MockTemplateInfo's explicit ITemplateInfo.Tags and ITemplateInfo.CacheParameters implementations throw NotImplementedException. System.Text.Json walks all interface properties during serialization, causing TemplateSearchCoordinator tests to crash. Return null! instead of throwing, matching what dotnet/templating main has. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
akoeplinger
approved these changes
Apr 9, 2026
4634c52
into
dotnet:release/11.0.1xx-preview3
11 checks passed
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
Backport of dotnet/templating#10066 to
release/11.0.1xx-preview3.Problem
After the Newtonsoft.Json → System.Text.Json migration (dotnet/templating#9956),
MockTemplateInfo's explicitITemplateInfo.TagsandITemplateInfo.CacheParametersimplementations throwNotImplementedException. Newtonsoft.Json never visited these during serialization, but System.Text.Json walks all interface properties, causingTemplateDiscoveryMetadata.ToJObject()to crash:This breaks all
TemplateSearchCoordinatorTestsin the SDK CI (dotnet/sdk#53708).Fix
Return
null!instead of throwing, matching whatdotnet/templatingmain has. Both properties are[Obsolete]— the mock's real tag data lives in theTagsCollectionproperty.Why direct VMR change
The
dotnet/templatingrepo does not have arelease/11.0.1xx-preview3branch (the automated backport attempt failed), so the normal forward-flow path is not available. This is a test-only change inMicrosoft.TemplateEngine.Mocks.cc @dotnet/product-construction @lewing