Created
February 21, 2023 12:55
-
-
Save tiesmaster/0d898ed7ca023aa415ca95314669ab66 to your computer and use it in GitHub Desktop.
Failing serialization of stronglytyped id in dictionary
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
| public class TestClass | |
| { | |
| [Fact] | |
| public void MyTestMethod() | |
| { | |
| var dict = new Dictionary<UserId, string>(); | |
| var userId = UserId.New(); | |
| dict[userId] = "Yolo"; | |
| System.Text.Json.JsonSerializer.Serialize(dict); | |
| } | |
| } | |
| [StronglyTypedId(backingType: StronglyTypedIdBackingType.Guid)] | |
| public readonly partial struct UserId | |
| { | |
| public static UserId From(string id) | |
| => new(Guid.Parse(id)); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment