You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
JExtensions.cs (src/Shared/JExtensions.cs) — Most significant change. This shared file (linked into multiple projects) was the central Newtonsoft.Json helper. Completely rewritten to use System.Text.Json.Nodes (JsonNode, JsonObject, JsonArray, JsonValue) instead of JObject/JToken/JArray. Key changes:
All extension methods now operate on JsonObject/JsonNode/JsonArray instead of Newtonsoft types
ParseJsonNode() / ParseJsonObject() helpers with JsonDocumentOptions configured for comment handling and trailing commas
ToJsonString() for serialization using JsonSerializer
JsonNodeComparer and JsonNodeEqualityComparer utility classes added
2. Package References (5 files)
Directory.Packages.props — Removed Newtonsoft.Json package reference; added System.Text.Json and JsonSchema.Net (for JSON schema validation in tests).
4 csproj files — Replaced Newtonsoft.Json with System.Text.Json, conditioned with Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'" to avoid NU1510 package pruning warnings (System.Text.Json is inbox for .NET 10+, but still needed for net472/netstandard2.0):
STJ serializes through interface types (ICacheTag, ICacheParameter, ITemplateParameter), ignoring [JsonIgnore] on the concrete class. Newtonsoft used runtime types and respected [JsonIgnore]. Changed ~15 throwing properties to return safe defaults.
4. TemplateDiscoveryTests.CanReadAuthor — array vs scalar
V1 format serializes Owners (an IReadOnlyList<string>) as a JSON array. The migration incorrectly used .GetValue<string>() (scalar only); fixed to .AsArray().Select(...).Single() matching the original .Values().Single().
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
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 of changes
1. Core Shared Infrastructure (1 file)
src/Shared/JExtensions.cs) — Most significant change. This shared file (linked into multiple projects) was the central Newtonsoft.Json helper. Completely rewritten to useSystem.Text.Json.Nodes(JsonNode,JsonObject,JsonArray,JsonValue) instead ofJObject/JToken/JArray. Key changes:JsonObject/JsonNode/JsonArrayinstead of Newtonsoft typesParseJsonNode()/ParseJsonObject()helpers withJsonDocumentOptionsconfigured for comment handling and trailing commasToJsonString()for serialization usingJsonSerializerToString(),ToInt32(),Get<T>(), etc.) rewritten for STJ APIsJsonNodeComparerandJsonNodeEqualityComparerutility classes added2. Package References (5 files)
Newtonsoft.Jsonpackage reference; addedSystem.Text.JsonandJsonSchema.Net(for JSON schema validation in tests).Newtonsoft.JsonwithSystem.Text.Json, conditioned withCondition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'"to avoid NU1510 package pruning warnings (System.Text.Json is inbox for .NET 10+, but still needed fornet472/netstandard2.0):src/Microsoft.TemplateEngine.Edge/Microsoft.TemplateEngine.Edge.csprojsrc/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.csprojsrc/Microsoft.TemplateEngine.Utils/Microsoft.TemplateEngine.Utils.csprojsrc/Microsoft.TemplateSearch.Common/Microsoft.TemplateSearch.Common.csprojNewtonsoft.Jsonreference.Newtonsoft.JsonwithJsonSchema.Netfor schema validation tests.3. Production Source Files (62 files)
Microsoft.TemplateEngine.Edge (6 files)
JObject/JTokentoJsonObject/JsonNodeMicrosoft.TemplateEngine.Orchestrator.RunnableProjects (32 files)
Microsoft.TemplateSearch.Common (11 files)
Tools/TemplateDiscovery (12 files)
JsonEncodeValueFormFactory.cs
Added
JavaScriptEncoder.UnsafeRelaxedJsonEscapingso"encodes as\"(matching Newtonsoft behavior) instead of STJ's default\u0022.4. Test Files (24 files)
All test files updated to use
System.Text.JsonAPIs instead of Newtonsoft:5. Test Data Fixes (4 files)
Removed duplicate
$schemaproperties from template.json files that Newtonsoft silently tolerated but STJ/JsonSchema.Net rejects:test_templates/TemplateConditionalProcessing/.template.config/template.jsontest_templates/Invalid/InvalidHostData/.template.config/template.jsontest_templates/SourceWithExcludeAndWithout/With/.template.config/template.jsontest_templates/SourceWithExcludeAndWithout/Without/.template.config/template.json6. Behavioral Differences Addressed
"True"/"False""true"/"false""encoding in JSON strings\"\u0022UnsafeRelaxedJsonEscapingArgumentExceptionJsonNode.ToString()formatToJsonString()is compact)ToJsonString()in assertions7. Validation
VMR build