Skip to content

Commit 2eeb888

Browse files
lewingCopilot
andcommitted
Fix MockTemplateInfo for System.Text.Json serialization
After the Newtonsoft.Json → System.Text.Json migration (#9956), MockTemplateInfo's explicit ITemplateInfo.Tags and CacheParameters implementations throw NotImplementedException. Newtonsoft never hit these during serialization, but System.Text.Json walks all interface properties, causing TemplateDiscoveryMetadata.ToJObject() to crash in the SDK's CacheSearchCoordinatorTests. Return empty dictionaries instead of throwing. Both properties are [Obsolete] and the mock's real data lives in TagsCollection. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 111ab68 commit 2eeb888

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

test/Microsoft.TemplateEngine.Mocks/MockTemplateInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ public string ShortName
9292
public bool PreferDefaultName => _preferDefaultName;
9393

9494
[Obsolete("Use ParameterDefinitionSet instead.")]
95-
IReadOnlyDictionary<string, ICacheTag> ITemplateInfo.Tags => throw new NotImplementedException();
95+
IReadOnlyDictionary<string, ICacheTag> ITemplateInfo.Tags => null!;
9696

9797
[Obsolete("Use ParameterDefinitionSet instead.")]
98-
IReadOnlyDictionary<string, ICacheParameter> ITemplateInfo.CacheParameters => throw new NotImplementedException();
98+
IReadOnlyDictionary<string, ICacheParameter> ITemplateInfo.CacheParameters => null!;
9999

100100
public IParameterDefinitionSet ParameterDefinitions
101101
{

0 commit comments

Comments
 (0)