Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -258,3 +258,4 @@ Microsoft.TemplateEngine.VC.db

#Rider
.idea/
.nuget/
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ private static IReadOnlyDictionary<string, PostActionLocalizationModel> LoadPost

foreach (var postActionParts in strings.GroupBy(p => p.NameParts.FirstOrDefault()))
{
if (string.IsNullOrEmpty(postActionParts.Key))
{
// Post action with no ID. Ignore.
continue;
}

string postActionId = postActionParts.Key;
string? description = postActionParts.SingleOrDefault(p => p.NameParts.Skip(1).FirstOrDefault() == "description").LocalizedString;
var instructions = LoadManualInstructionModels(postActionParts
Expand Down Expand Up @@ -162,6 +168,12 @@ private static IReadOnlyDictionary<string, string> LoadManualInstructionModels(I

foreach (var instructionParts in strings.GroupBy(p => p.NameParts.FirstOrDefault()))
{
if (string.IsNullOrEmpty(instructionParts.Key))
{
// Instruction with no ID. Ignore.
continue;
}

string id = instructionParts.Key;
string? text = instructionParts.SingleOrDefault(p => p.NameParts.Skip(1).FirstOrDefault() == "text").LocalizedString;
results[id] = text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ public void CanReadDescription(string fileContent, bool errorExpected, string? e
[InlineData(/*lang=json,strict*/ """{ "symbols/someSymbol/displayName": "localizedSymbol" }""", false, "someSymbol", "localizedSymbol", "(null)")]
[InlineData(/*lang=json,strict*/ """{ "symbols/someSymbol/description": "localizedSymbolDescription" }""", false, "someSymbol", "(null)", "localizedSymbolDescription")]
[InlineData(/*lang=json*/ """{ description: ""}""", false, null, null, null)]
// Test case for NullReferenceException fix: malformed symbol key with only "symbols/" prefix
[InlineData(/*lang=json,strict*/ """{ "symbols/": "test" }""", false, null, null, null)]
public void CanReadNonChoiceSymbol(
string fileContent,
bool errorExpected,
Expand Down Expand Up @@ -244,6 +246,10 @@ public void CanReadChoiceSymbol(
[InlineData(/*lang=json*/ """{ description: ""}""", false, null, null, null)]
[InlineData(/*lang=json,strict*/ """{ "postActions/pa0/description": "localizedDescription" }""", false, "pa0", "localizedDescription", "(null)")]
[InlineData(/*lang=json,strict*/ """{ "postActions/pa0/manualInstructions/first/text": "localizedDescription" }""", false, "pa0", "(null)", "first*localizedDescription")]
// Test case for NullReferenceException fix: malformed postAction key with only "postActions/" prefix
[InlineData(/*lang=json,strict*/ """{ "postActions/": "test" }""", false, null, null, null)]
// Test case for NullReferenceException fix: malformed manualInstruction key with missing instruction id
[InlineData(/*lang=json,strict*/ """{ "postActions/pa0/manualInstructions//text": "test" }""", false, "pa0", "(null)", "(null)")]
public void CanReadPostAction(
string fileContent,
bool errorExpected,
Expand Down