Skip to content

Commit

Permalink
Handle Types with multiple generic arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
asafcyclops authored and byme8 committed Jul 14, 2024
1 parent 1071214 commit e6e1f3b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Dapper.Json.SourceGenerator/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ public static string ToSafeGlobalName(this ISymbol symbol)
.Replace("[]", "Array")
.Replace("<", "Of")
.Replace(">", "")
.Replace(",", "And")
.Replace(" ", "")
.Replace(".", "");
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[
Dictionary`2
]
11 changes: 11 additions & 0 deletions src/Dapper.Json.Tests/MainTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ public async Task TypeMappingForTuplesAreGenerated()

await Verify(handlers);
}

[Fact]
public async Task TypeMappingForDictionariesAreGenerated()
{
var newProject = await TestProject.Project.ReplacePartsOfDocumentAsync("Program.cs",
("public Json<string[]> Emails { get; set; }", "public Json<System.Collections.Generic.Dictionary<string,string>> Dict { get; set; }"));

var handlers = await Execute(newProject);

await Verify(handlers);
}

[Fact]
public async Task TypeMappingForGenericsAreIgnored()
Expand Down

0 comments on commit e6e1f3b

Please sign in to comment.