Skip to content

Commit 3478be9

Browse files
committed
Added support for DateTimeOffset keys
1 parent adc065e commit 3478be9

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

src/Components/Components/src/SupplyParameterFromPersistentComponentStateValueProvider.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ private static bool IsSerializableKey(object key)
262262
var keyType = key.GetType();
263263
var result = Type.GetTypeCode(keyType) != TypeCode.Object
264264
|| keyType == typeof(Guid)
265+
|| keyType == typeof(DateTimeOffset)
265266
|| keyType == typeof(DateOnly)
266267
|| keyType == typeof(TimeOnly);
267268

src/Components/Components/test/SupplyParameterFromPersistentComponentStateValueProviderTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ public async Task PersistAsync_CanPersistMultipleComponentsOfSameType_WhenParent
228228
{ Math.PI, -Math.PI },
229229
{ 123456.789m, -123456.789m },
230230
{ new DateTime(2023, 1, 1), new DateTime(2023, 12, 31) },
231+
{ new DateTimeOffset(2023, 1, 1, 0, 0, 0, TimeSpan.FromSeconds(0)), new DateTimeOffset(2023, 12, 31, 0, 0, 0, TimeSpan.FromSeconds(0)) },
231232
{ "key1", "key2" },
232233
// Include a very long key to validate logic around growing buffers
233234
{ new string('a', 10000), new string('b', 10000) },

0 commit comments

Comments
 (0)