Skip to content

Commit cbf9fa9

Browse files
Copilotjaviercn
andcommitted
Implement explicit interface implementation for custom serializers and remove XML comments from internal interface
Co-authored-by: javiercn <[email protected]>
1 parent c1fefc5 commit cbf9fa9

File tree

2 files changed

+2
-24
lines changed

2 files changed

+2
-24
lines changed

src/Components/Components/src/IPersistentComponentStateSerializer.cs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,8 @@
55

66
namespace Microsoft.AspNetCore.Components;
77

8-
/// <summary>
9-
/// Provides custom serialization logic for persistent component state values.
10-
/// </summary>
118
internal interface IPersistentComponentStateSerializer
129
{
13-
/// <summary>
14-
/// Serializes the provided <paramref name="value"/> and writes it to the <paramref name="writer"/>.
15-
/// </summary>
16-
/// <param name="type">The type of the value to serialize.</param>
17-
/// <param name="value">The value to serialize.</param>
18-
/// <param name="writer">The buffer writer to write the serialized data to.</param>
19-
/// <returns>A task that represents the asynchronous serialization operation.</returns>
2010
Task PersistAsync(Type type, object value, IBufferWriter<byte> writer);
21-
22-
/// <summary>
23-
/// Deserializes a value from the provided <paramref name="data"/>.
24-
/// This method must be synchronous to avoid UI tearing during component state restoration.
25-
/// </summary>
26-
/// <param name="type">The type of the value to deserialize.</param>
27-
/// <param name="data">The serialized data to deserialize.</param>
28-
/// <returns>The deserialized value.</returns>
2911
object Restore(Type type, ReadOnlySequence<byte> data);
3012
}

src/Components/Components/src/PersistentStateValueProvider.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -375,16 +375,12 @@ internal bool TryTake<TValue>(string key, IPersistentComponentStateSerializer<TV
375375
}
376376
}
377377

378-
/// <summary>
379-
/// Adapter class to bridge between the public generic interface and the internal interface.
380-
/// </summary>
381-
/// <typeparam name="T">The type of the value to serialize.</typeparam>
382378
private sealed class SerializerAdapter<T>(IPersistentComponentStateSerializer<T> serializer) : IPersistentComponentStateSerializer
383379
{
384-
public Task PersistAsync(Type type, object value, IBufferWriter<byte> writer)
380+
Task IPersistentComponentStateSerializer.PersistAsync(Type type, object value, IBufferWriter<byte> writer)
385381
=> serializer.PersistAsync((T)value, writer);
386382

387-
public object Restore(Type type, ReadOnlySequence<byte> data)
383+
object IPersistentComponentStateSerializer.Restore(Type type, ReadOnlySequence<byte> data)
388384
=> serializer.Restore(data)!;
389385
}
390386
}

0 commit comments

Comments
 (0)