Skip to content

[release/11.0.1xx-preview3] Backport MockTemplateInfo fix for STJ serialization#5947

Merged
akoeplinger merged 1 commit intodotnet:release/11.0.1xx-preview3from
dsplaisted:fix/templating-mock-tags-preview3
Apr 9, 2026
Merged

[release/11.0.1xx-preview3] Backport MockTemplateInfo fix for STJ serialization#5947
akoeplinger merged 1 commit intodotnet:release/11.0.1xx-preview3from
dsplaisted:fix/templating-mock-tags-preview3

Conversation

@dsplaisted
Copy link
Copy Markdown
Member

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 explicit ITemplateInfo.Tags and ITemplateInfo.CacheParameters implementations throw NotImplementedException. Newtonsoft.Json never visited these during serialization, but System.Text.Json walks all interface properties, causing TemplateDiscoveryMetadata.ToJObject() to crash:

System.NotImplementedException : The method or operation is not implemented.
  at MockTemplateInfo.ITemplateInfo.get_Tags()
  at System.Text.Json.Serialization...JsonPropertyInfo1.GetMemberAndWriteJson

This breaks all TemplateSearchCoordinatorTests in the SDK CI (dotnet/sdk#53708).

Fix

Return null! instead of throwing, matching what dotnet/templating main has. Both properties are [Obsolete] — the mock's real tag data lives in the TagsCollection property.

Why direct VMR change

The dotnet/templating repo does not have a release/11.0.1xx-preview3 branch (the automated backport attempt failed), so the normal forward-flow path is not available. This is a test-only change in Microsoft.TemplateEngine.Mocks.

cc @dotnet/product-construction @lewing

…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>
@dotnet-policy-service dotnet-policy-service bot requested a review from a team April 9, 2026 10:15
@dsplaisted dsplaisted requested a review from MichaelSimons April 9, 2026 10:17
@akoeplinger akoeplinger enabled auto-merge (squash) April 9, 2026 10:18
@akoeplinger akoeplinger merged commit 4634c52 into dotnet:release/11.0.1xx-preview3 Apr 9, 2026
11 checks passed
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.

2 participants