Skip to content

Commit

Permalink
leverage FrozenDictionary
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Jan 7, 2024
1 parent 61c52c2 commit 9df0a65
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/Verify.Tests/CultureToDateBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public Task BuildCultureToDate()
// <auto-generated />
static partial class DateScrubber
{
static Dictionary<string, CultureDate> cultureDates = new()
static IReadOnlyDictionary<string, CultureDate> cultureDates = new Dictionary<string, CultureDate>()
{
""");
Expand Down Expand Up @@ -45,7 +45,11 @@ static partial class DateScrubber

builder.AppendLine(
"""
};
}
#if NET8_0_OR_GREATER
.ToFrozenDictionary()
#endif
;
}
""");
var file = Path.Combine(AttributeReader.GetSolutionDirectory(), "Verify/Serialization/Scrubbers/DateScrubber_Generated.cs");
Expand Down
4 changes: 4 additions & 0 deletions src/Verify/GlobalUsings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@
global using System.Runtime.InteropServices;
global using CharSpan = System.ReadOnlySpan<char>;
global using Culture = System.Globalization.CultureInfo;

#if NET8_0_OR_GREATER
global using System.Collections.Frozen;
#endif
8 changes: 6 additions & 2 deletions src/Verify/Serialization/Scrubbers/DateScrubber_Generated.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// <auto-generated />
static partial class DateScrubber
{
static Dictionary<string, CultureDate> cultureDates = new()
static IReadOnlyDictionary<string, CultureDate> cultureDates = new Dictionary<string, CultureDate>()
{
{
"",
Expand Down Expand Up @@ -1653,5 +1653,9 @@ static partial class DateScrubber
new(2023, 2, 22, 12, 10, 10, 10),
new(2023, 5, 7, 1, 0, 0))
},
};
}
#if NET8_0_OR_GREATER
.ToFrozenDictionary()
#endif
;
}

0 comments on commit 9df0a65

Please sign in to comment.