Skip to content

[Blazor] Support serialization extensibility for declarative persistent component state #60716

Open
@javiercn

Description

@javiercn

Currently we only serialize things as json. Ideally, we need an interface or something that you can implement (or pass as a parameter in the attribute) to provide a custom serialization mechanism.

The interface will be something like

public interface IPersistentComponentStateSerializer
{
    Task Persist(Type type, object instance, IBufferWriter buffer);
    void Restore(Type type, ReadOnlySequence<byte> data);
}
  • Restore needs to be synchronous to avoid tearing on the UI.
  • We don't want byte[] based APIs, as we want to minimize additional allocations if possible and we don't want to give the serializer the responsibility of allocating buffers.

Metadata

Metadata

Assignees

Labels

area-blazorIncludes: Blazor, Razor Components

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions