Skip to content

[Blazor] Make component serialization metadata-first - #68295

Open
javiercn wants to merge 14 commits into
mainfrom
javiercn-aot-stack-1-stj
Open

javiercn wants to merge 14 commits into
mainfrom
javiercn-aot-stack-1-stj

Conversation

@javiercn

@javiercn javiercn commented Aug 8, 2026 •

Copy link
Copy Markdown
Member

Overview

This is stack layer 1/6 for #68332 — Aspire Dashboard Native AOT support, bounded to the live PR diff 66e8a029..9ca33ec5 (77 files, 14 commits). It makes Blazor’s serialization boundaries metadata-first: framework contracts are source-generated, application contracts compose ahead of compatibility reflection, and converter-owned JS types remain converter-backed. The cross-cutting constraint is host isolation: application resolvers are snapshotted per service provider/host and never mutate process-static serializer options; later stack layers build on this JSON foundation for JS dispatch, binding, component metadata, framework providers, and the final Native AOT proof.

Design

The application-facing JSON surface is deliberately narrow and experimental: one context property and one registration method. It does not expose component, binding, or JS-invokable descriptors owned by later layers.

// src/Components/Web/src/Metadata/RazorComponentsMetadataContext.cs
// Applications expose an STJ resolver without giving framework consumers direct access
// to JsonSerializerContext instances or to unrelated component metadata.
[Experimental("ASPNETCORE9004", UrlFormat = "https://aka.ms/aspnet/analyzer/{0}")]
public abstract class RazorComponentsMetadataContext
{
    protected RazorComponentsMetadataContext()
    {
    }

    public abstract IJsonTypeInfoResolver? JsonTypeInfoResolver { get; }
}

// src/Components/Web/src/Metadata/ComponentMetadataServiceCollectionExtensions.cs
// Each registration contributes to options used to construct an immutable provider snapshot.
public static IServiceCollection AddComponentMetadata<TContext>(this IServiceCollection services)
    where TContext : RazorComponentsMetadataContext, new()
{
    ArgumentNullException.ThrowIfNull(services);

    services.AddComponentJsonMetadata();
    var context = new TContext();
    if (context.JsonTypeInfoResolver is { } resolver)
    {
        services.Configure<ComponentJsonMetadataOptions>(options => options.Resolvers.Add(resolver));
    }
    services.AddSingleton<RazorComponentsMetadataContext>(context);

    return services;
}

Protected browser storage adds typed writes and an optional typed serializer while retaining the shipped object overloads, existing constructors, and JSON fallback behavior.

// src/Components/Server/src/ProtectedBrowserStorage/ProtectedBrowserStorage.cs
// Existing object overloads remain. The generic overload roots the closed TValue service lookup.
public ValueTask SetAsync<TValue>(string key, TValue value)
    => SetAsync(CreatePurposeFromKey(key), key, value);

public ValueTask SetAsync<TValue>(string purpose, string key, TValue value)
{
    ArgumentException.ThrowIfNullOrEmpty(purpose);
    ArgumentException.ThrowIfNullOrEmpty(key);

    return SetProtectedJsonAsync(key, Protect(purpose, value));
}

// src/Components/Server/src/ProtectedBrowserStorage/ProtectedBrowserStorageSerializer.cs
[Experimental("ASPNETCORE9004", UrlFormat = "https://aka.ms/aspnet/analyzer/{0}")]
public abstract class ProtectedBrowserStorageSerializer<T>
{
    public abstract string Serialize(T value);
    public abstract T Deserialize(string data);
}

Resolver ordering is intentional and consistent:

Boundary Resolver order
Fixed framework DTOs generated framework context → reflection when enabled
Marker/persistence/application payloads generated framework context → registered application resolver(s) → reflection when enabled
Web/JS interop fixed Web context → fixed JS context → converter-backed types → application resolver(s) → reflection when enabled
Protected storage application resolver(s) → reflection when enabled; custom ProtectedBrowserStorageSerializer<T> wins before JSON

The rejected alternative was process-static mutation of persistence or marker resolver chains. Instead, serializer/deserializer instances, ComponentStatePersistenceManager, renderers, and the WebAssembly host own their options snapshots. Therefore a provider already built is immutable; only providers built after another AddComponentMetadata<TContext>() call observe the new contracts.

Implementation

Framework-owned contracts. The same generated-contract pattern covers four equivalence classes; one representative is shown, with the remaining deltas listed rather than repeated:

// src/Components/Server/src/CircuitJavaScriptInitializationMiddleware.cs
// IList<string> is a closed framework payload, so the endpoint works even when STJ reflection is disabled.
public async Task InvokeAsync(HttpContext context)
{
    await context.Response.WriteAsJsonAsync(
        _initializers,
        JavaScriptInitializersJsonContext.Default.IListString);
}

[JsonSerializable(typeof(IList<string>))]
private sealed partial class JavaScriptInitializersJsonContext : JsonSerializerContext;
  • Static framework data: import maps, resource collections, JavaScript initializer manifests/responses, and prerender application-state dictionaries use generated JsonTypeInfo overloads.
  • Closed value families: TempData generates its supported primitive, nullable, collection, dictionary, object-array, and Dictionary<string, JsonElement> shapes; generic-interface reflection remains available only when JsonSerializer.IsReflectionEnabledByDefault.
  • Circuit/persistence DTOs: circuit root-operation batches, persisted marker dictionaries, persistent-service registrations, framework persistent primitives, and antiforgery state have generated contracts.
  • Marker/render-fragment DTOs: Server and WebAssembly envelopes, component parameter definitions, and serialized render-tree nodes are generated; application parameter values deliberately continue into the application/reflection portion of the chain.

Protocol options remain authoritative. Generated metadata is resolved through the protocol-owned options rather than serializing directly with a context property. This preserves camel-case field names and null omission while avoiding reflection.

// src/Shared/Components/ServerComponentSerializationSettings.cs
// Example wire shape remains {"type":"webassembly",...}, never {"Type":"webassembly",...}.
internal static JsonSerializerOptions CreateOptions(IJsonTypeInfoResolver? applicationResolver)
{
    var options = new JsonSerializerOptions
    {
        PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
        PropertyNameCaseInsensitive = true,
        DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
    };

    options.TypeInfoResolverChain.Add(ServerComponentJsonContext.Default);
    if (applicationResolver is not null)
    {
        options.TypeInfoResolverChain.Add(applicationResolver);
    }
    if (JsonSerializer.IsReflectionEnabledByDefault)
    {
        options.TypeInfoResolverChain.Add(CreateReflectionResolver());
    }

    return options;
}

// src/Components/Endpoints/src/Rendering/EndpointHtmlRenderer.Streaming.cs
var markerTypeInfo = ServerComponentSerializationSettings.JsonSerializationOptions
    .GetTypeInfo(typeof(ComponentMarker));
var serializedStartRecord = JsonSerializer.Serialize(marker, markerTypeInfo);

var endMarkerTypeInfo = ServerComponentSerializationSettings.JsonSerializationOptions
    .GetTypeInfo(typeof(ComponentEndMarker));
var serializedEndRecord = JsonSerializer.Serialize(endMarker, endMarkerTypeInfo);

The same options-owned contract rule applies to cached render fragments and marker serializers/deserializers. Raw marker tests assert lowercase type/prerenderId, absence of PascalCase names, and omission of null-only fields on both start and end comments.

Provider-scoped application composition. Registration is additive, but resolution snapshots the list once when the provider creates the singleton resolver.

// src/Components/Web/src/Metadata/ComponentJsonMetadataResolver.cs
internal sealed class ComponentJsonMetadataResolver : IComponentJsonMetadataResolver
{
    public ComponentJsonMetadataResolver(IOptions<ComponentJsonMetadataOptions> options)
    {
        var resolvers = options.Value.Resolvers;
        JsonTypeInfoResolver = resolvers.Count switch
        {
            0 => null,
            1 => resolvers[0],
            _ => System.Text.Json.Serialization.Metadata.JsonTypeInfoResolver.Combine([.. resolvers]),
        };
    }

    public IJsonTypeInfoResolver? JsonTypeInfoResolver { get; }
}

// src/Components/Components/src/PersistentState/PersistentStateSerializationOptions.cs
// Every manager gets fresh options: framework first, its provider's app contracts next, reflection last.
public static JsonSerializerOptions Create(IJsonTypeInfoResolver? applicationResolver)
{
    var options = new JsonSerializerOptions(JsonSerializerOptionsProvider.Options);
    options.TypeInfoResolverChain.Clear();
    options.TypeInfoResolverChain.Add(PersistentStateJsonContext.Default);

    if (applicationResolver is not null)
    {
        options.TypeInfoResolverChain.Add(applicationResolver);
    }
    if (JsonSerializer.IsReflectionEnabledByDefault)
    {
        options.TypeInfoResolverChain.Add(CreateReflectionResolver());
    }

    return options;
}

Consumers fall into three identical ownership groups: persistence (ComponentStatePersistenceManager/PersistentComponentState), Server/Endpoints markers and Session (serializer/deserializer instances), and protected storage (DI-owned options). Directly constructed legacy instances retain shared compatibility options; DI-created instances snapshot the current provider.

JS payloads. JSRuntime now installs reflection explicitly only when available and serializes outbound arguments through the existing object[] type-info contract. Web renderers place fixed contracts and converter-backed references ahead of application contracts.

// src/Components/Web/src/WebRenderer.cs
// Fixed wire types are first; converter-owned object/stream references do not need reflected members;
// app payloads follow; JSRuntime's compatibility reflection resolver remains last.
var resolvers = jsonOptions.TypeInfoResolverChain;
PlaceResolverAt(resolvers, WebRendererSerializerContext.Default, 0);
PlaceResolverAt(resolvers, WebJSInteropSerializerContext.Default, 1);
PlaceResolverAt(resolvers, ConverterBackedTypeInfoResolver.Instance, 2);
if (serviceProvider.GetService<IComponentJsonMetadataResolver>()?.JsonTypeInfoResolver is { } applicationResolver)
{
    PlaceResolverAt(resolvers, applicationResolver, 3);
}

// src/JSInterop/Microsoft.JSInterop/src/JSRuntime.cs
var argsJson = args is not null && args.Length != 0
    ? JsonSerializer.Serialize(args, JsonSerializerOptions.GetTypeInfo(typeof(object[])))
    : "[]";

The equivalent inbound deltas are explicit type-info overloads for custom events and JS component parameters; EventArgs.Empty needs no contract. Navigation payloads send the Server renderer ID as its integer wire representation.

WebAssembly host timing and order. Initial prerender parameter deserialization is deferred until after service-provider creation, so it can use that host's resolver snapshot. Root-update operations use the same host-owned context. Registered marker-backed roots are then inserted before manual mappings, retaining historical startup precedence and preserving order within both groups.

// src/Components/WebAssembly/WebAssembly/src/Services/WebAssemblyHostSerializationContext.cs
public WebAssemblyHostSerializationContext(RootTypeCache rootComponentCache, IServiceProvider services)
{
    _rootComponentCache = rootComponentCache;
    var resolver = ComponentJsonMetadata.GetApplicationResolver(services);
    ComponentOptions = WebAssemblyComponentSerializationSettings.CreateOptions(resolver);
    JSInteropOptions = DefaultWebAssemblyJSRuntime.Instance.CreateHostJsonSerializerOptions(resolver);
    _parameterDeserializer = new WebAssemblyComponentParameterDeserializer(
        new ComponentParametersTypeCache(),
        ComponentOptions);
}

// src/Components/WebAssembly/WebAssembly/src/Hosting/WebAssemblyHostBuilder.cs
var registeredMappings = new RootComponentMapping[registeredComponents.Length];
for (var i = 0; i < registeredComponents.Length; i++)
{
    var registeredComponent = registeredComponents[i];
    var componentType = _rootComponentCache!.GetRootType(
        registeredComponent.Assembly!,
        registeredComponent.TypeName!)
        ?? throw new InvalidOperationException("Registered root component type was not found.");

    var parameters = serializationContext.DeserializeComponentParameters(registeredComponent);
    registeredMappings[i] = new RootComponentMapping(
        componentType,
        registeredComponent.PrerenderId!,
        parameters.Parameters);
}

for (var i = 0; i < registeredMappings.Length; i++)
{
    RootComponents.Insert(i, registeredMappings[i]);
}

Protected storage dispatch. The generic path first looks for a closed typed serializer; otherwise it resolves generated JSON metadata from the provider-owned options. Protection and browser I/O are unchanged.

// src/Components/Server/src/ProtectedBrowserStorage/ProtectedBrowserStorage.cs
private string Protect<TValue>(string purpose, TValue value)
{
    var serializer = _services?.GetService<ProtectedBrowserStorageSerializer<TValue>>();
    var data = serializer is null
        ? JsonSerializer.Serialize(
            value,
            _serializerOptions.GetTypeInfo(value?.GetType() ?? typeof(TValue)))
        : serializer.Serialize(value);
    var protector = GetOrCreateCachedProtector(purpose);

    return protector.Protect(data);
}

private TValue Unprotect<TValue>(string purpose, string protectedJson)
{
    var protector = GetOrCreateCachedProtector(purpose);
    var data = protector.Unprotect(protectedJson);
    var serializer = _services?.GetService<ProtectedBrowserStorageSerializer<TValue>>();

    return serializer is null
        ? (TValue)JsonSerializer.Deserialize(data, _serializerOptions.GetTypeInfo(typeof(TValue)))!
        : serializer.Deserialize(data);
}

Outcome

Equivalence class Validation/proof
Fixed framework contracts and reflection-last fallback Reflection-disabled remote tests; persistent-state/TempData/initializer coverage; LinkabilityChecker build succeeded with 0 warnings/errors
Marker and render-fragment protocol Full Endpoints suite 813/0; focused marker/cache tests 75/0; raw start/end JSON assertions; representative Server interactive E2E passed
Provider composition and isolation Tests compose multiple contexts and prove an existing provider cannot observe later registrations; Web suite 316/0, Server suite 405/0
Web/JS payloads Explicit outbound/inbound type-info coverage, converter-backed reference coverage, and focused JSInterop serialization tests
WebAssembly host ownership and ordering WebAssembly suite 55/0; two registered + two manual mapping order test; targeted ClientRenderingMultpleComponentsTest.CanRenderMultipleRootComponents passed in Debug JIT
Protected storage Typed serializer, runtime-type fallback, direct-construction compatibility, failure behavior, and API baseline coverage
Cross-project integration Dependency-aware Components E2ETest Debug and Release builds succeeded with 0 warnings/errors; shared nullable contexts compile when linked into nullable-disabled projects

Restack verification against current main: all 14/14 commits are patch-identical (range-diff = and matching stable patch IDs), with no dropped or repaired PR patches. Post-restack validation passed Components 36/0, Web 9/0, Endpoints 45/0, Server 51/0, WebAssembly 5/0, JSInterop 56/0, plus the dependency-aware Components E2ETest compile gate with 0 warnings/errors.

This PR remains independently reviewable against main; subsequent stack layers depend on its application JSON registration and host-isolated serializer composition.

javiercn and others added 14 commits August 11, 2026 11:49
Resolve framework-owned import map, resource, initializer, TempData, circuit, and persistence payloads through generated contracts.

Behavior: changed: fixed framework payloads no longer require reflection metadata
State: incomplete - ServerComponentJsonContext is completed by #2
Review hint: application-owned values are deliberately unchanged

Co-authored-by: Copilot App <[email protected]>
Generate the server and WebAssembly marker envelopes and route fixed render-fragment wire DTOs through JsonTypeInfo overloads. Application parameter values continue to use the reflection compatibility resolver.

Behavior: changed: framework marker envelopes resolve without reflection
State: complete
Review hint: contracts stop at the application parameter-value boundary

Co-authored-by: Copilot App <[email protected]>
Make JSRuntime's reflection fallback explicit, serialize outbound object arrays through JsonTypeInfo, and compose Web renderer and converter-backed contracts before that fallback. Custom events now use the JsonTypeInfo overload.

Behavior: changed: framework JS payloads resolve generated or converter-backed contracts first
State: builds; focused coverage follows in #4
Review hint: no JS-invokable dispatch metadata is included

Co-authored-by: Copilot App <[email protected]>
Exercise reflection-disabled fixed payloads, generated-before-reflection ordering, converter-backed Web renderer arguments, and the corrected custom-event JsonTypeInfo path.

Behavior: preserved
State: complete for fixed framework serialization
Review hint: remote tests prove behavior with STJ reflection disabled

Co-authored-by: Copilot App <[email protected]>
Add the minimal RazorComponentsMetadataContext JSON surface and compose registered resolvers into provider-owned persistence, marker, Session, custom-event, Web renderer, and WebAssembly host options. Prerendered and updated WebAssembly markers now deserialize after provider creation through immutable host state.

Behavior: changed: application contracts resolve before reflection without crossing service-provider boundaries
State: builds; host-isolation coverage follows in #6
Review hint: resolver snapshots are instance-owned; no application resolver mutates a process static

Co-authored-by: Copilot App <[email protected]>
Verify resolver composition is additive, existing providers and serializers remain immutable, reflection-disabled marker values use only registered contracts, and WebAssembly host options snapshot each provider.

Behavior: preserved
State: complete for application JSON composition
Review hint: each test builds distinct providers from one service collection to expose resolver leakage

Co-authored-by: Copilot App <[email protected]>
Add generic SetAsync overloads and ProtectedBrowserStorageSerializer<T>, while JSON fallback uses the provider-scoped application contract snapshot and preserves shipped constructors.

Behavior: changed: applications can provide typed protected-storage serializers or generated JSON contracts
State: builds; API and runtime coverage follows in #8
Review hint: direct construction retains the shared compatibility options; DI instances are provider-isolated

Co-authored-by: Copilot App <[email protected]>
Cover provider-scoped JSON options, multiple contexts, custom typed serializers, runtime-type fallback, direct-construction compatibility, and failure behavior for protected browser storage.

Behavior: preserved
State: complete
Review hint: the tests exercise both DI-created and shipped-constructor instances

Co-authored-by: Copilot App <[email protected]>
Generate the remaining initializer and prerender-state contracts, use explicit JsonTypeInfo overloads for JS component parameters, normalize Server renderer IDs to their integer wire shape, and correct the Endpoints linker substitution target.

Behavior: changed: remaining framework-owned payloads no longer depend on reflection or enum wire conversion
State: builds; linker descriptor coverage follows in #10
Review hint: these are the final serialization-owned hunks from the frozen donor audit

Co-authored-by: Copilot App <[email protected]>
Verify the embedded substitution descriptor targets the assembly that owns the HotReloadManager use so future moves cannot silently reintroduce the Forms assembly name.

Behavior: preserved
State: complete

Co-authored-by: Copilot App <[email protected]>
Create the provider-owned WebAssembly marker serializer on demand when a manually assembled renderer service provider does not register it, while normal hosts continue to reuse the DI singleton.

Behavior: preserved: standalone renderer construction continues to emit WebAssembly markers
State: complete
Review hint: the fallback still snapshots resolver contexts from the current request provider

Co-authored-by: Copilot App <[email protected]>
Shared marker settings are linked into nullable-disabled projects, so establish their annotation context locally before declaring nullable application resolvers.

Behavior: preserved
State: complete
Review hint: both files are shared source; the E2ETest compile gate is the regression witness

Co-authored-by: Copilot App <[email protected]>
Resolve generated marker and cached render-fragment contracts through ServerComponentSerializationSettings so camelCase naming and null omission remain part of the wire protocol.

Behavior: changed: emitted component comments again use lowercase protocol names and omit null-only fields
State: complete
Review hint: raw start/end marker assertions cover the browser parser contract; direct generated contexts remain only where no custom protocol options apply

Co-authored-by: Copilot App <[email protected]>
Materialize provider-deserialized SSR root mappings and insert them before manually configured roots, preserving historical startup precedence without restoring pre-provider deserialization.

Behavior: changed: registered marker-backed roots start before manual mappings again
State: complete
Review hint: two registered and two manual mappings prove order is stable within and across both groups

Co-authored-by: Copilot App <[email protected]>
@javiercn
javiercn force-pushed the javiercn-aot-stack-1-stj branch from f0a0f88 to 9ca33ec Compare August 11, 2026 09:55
@javiercn
javiercn marked this pull request as ready for review August 11, 2026 14:07
Copilot AI lite review requested due to automatic review settings August 11, 2026 14:07
@javiercn
javiercn requested a review from a team as a code owner August 11, 2026 14:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR is the first layer of the Blazor “metadata-first” serialization stack for Native AOT scenarios. It introduces an experimental application metadata registration surface and refactors several Blazor serialization boundaries to prefer source-generated JsonTypeInfo/resolvers (with reflection fallback only when enabled), while keeping serializer option snapshots host/service-provider scoped.

Changes:

  • Adds an experimental application metadata API (RazorComponentsMetadataContext + AddComponentMetadata<TContext>) and resolver composition plumbing.
  • Switches multiple framework serialization call sites (markers, temp data, JS payloads, persisted state, import maps/resources) to use generated JsonTypeInfo/resolver chains with reflection-last fallback.
  • Extends Protected Browser Storage with typed SetAsync<T> overloads and an opt-in per-type ProtectedBrowserStorageSerializer<T>.

Reviewed changes

Copilot reviewed 77 out of 77 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/Shared/Components/WebAssemblyComponentSerializationSettings.cs Adds CreateOptions and a generated JsonSerializerContext for WebAssembly marker/render-fragment contracts with reflection-last fallback.
src/Shared/Components/ServerComponentSerializer.cs Snapshots per-provider JSON options and serializes via JsonTypeInfo to avoid reflection dependency.
src/Shared/Components/ServerComponentSerializationSettings.cs Adds CreateOptions and a generated JsonSerializerContext for server marker/DTO contracts with reflection-last fallback.
src/Shared/Components/PrerenderComponentApplicationStore.cs Uses generated JsonTypeInfo when serializing prerender persisted state.
src/Shared/Components/ComponentJsonMetadata.cs Introduces a shared helper to compose application resolvers from registered metadata contexts.
src/JSInterop/Microsoft.JSInterop/src/JSRuntime.cs Makes resolver fallback explicit (reflection only when enabled) and switches arg serialization to object[] type-info overloads; adds host option replacement hook.
src/Components/WebAssembly/WebAssembly/test/TestInternalJSImportMethods.cs Enhances test JSImport methods to return registered root component metadata from a provided list.
src/Components/WebAssembly/WebAssembly/test/Services/WebAssemblyHostSerializationContextTest.cs Adds test validating resolver snapshot isolation per service provider.
src/Components/WebAssembly/WebAssembly/test/Hosting/WebAssemblyHostBuilderTest.cs Adds test asserting registered root components are inserted before manual mappings.
src/Components/WebAssembly/WebAssembly/src/Services/WebAssemblyHostSerializationContext.cs Adds a host-owned serialization context to snapshot component + JSInterop serializer options and parameter deserialization.
src/Components/WebAssembly/WebAssembly/src/Services/DefaultWebAssemblyJSRuntime.cs Creates per-host JSInterop JsonSerializerOptions (ordered resolvers, reflection-last) and installs them via unsafe accessor; uses host context for root updates.
src/Components/WebAssembly/WebAssembly/src/Rendering/WebAssemblyRenderer.cs Switches renderer to use host-scoped JSInterop options rather than process-static options.
src/Components/WebAssembly/WebAssembly/src/Prerendering/WebAssemblyComponentParameterDeserializer.cs Uses host-scoped options and explicit JsonTypeInfo overloads for fragment/union/parameter deserialization.
src/Components/WebAssembly/WebAssembly/src/Microsoft.AspNetCore.Components.WebAssembly.csproj Links in shared converter-backed resolver + fixed JSInterop context + shared component metadata helper.
src/Components/WebAssembly/WebAssembly/src/Hosting/WebAssemblyHostBuilder.cs Defers registered root component parameter deserialization until after service-provider creation; inserts registered mappings ahead of manual ones; installs host serialization context.
src/Components/Web/test/WebEventData/WebEventDataTest.cs Adds tests verifying custom event parsing uses app contracts and base EventArgs doesn’t require contracts.
src/Components/Web/test/Rendering/WebRendererJsonResolverTest.cs Adds tests for resolver ordering, duplication avoidance, and read-only option behavior in out-of-process web renderer scenarios.
src/Components/Web/test/Metadata/ComponentMetadataServiceCollectionExtensionsTest.cs Adds tests for resolver composition, enumerable contexts, provider isolation, and null-argument validation.
src/Components/Web/src/WebRenderer.cs Ensures fixed JSInterop resolver ordering (framework first, converter-backed types before app, reflection last) and uses object[] type-info serialization for in-process attach.
src/Components/Web/src/WebEventData/WebEventData.cs Uses JsonTypeInfo overloads for custom event arg deserialization and handles EventArgs.Empty without contracts.
src/Components/Web/src/PublicAPI.Unshipped.txt Adds new experimental public API entries for metadata registration surface.
src/Components/Web/src/Microsoft.AspNetCore.Components.Web.csproj Switches linked shared resolver from JsonConverterFactoryTypeInfoResolver to ConverterBackedTypeInfoResolver.
src/Components/Web/src/Metadata/RazorComponentsMetadataContext.cs Adds experimental public base type for application-supplied JSON contracts.
src/Components/Web/src/Metadata/ComponentMetadataServiceCollectionExtensions.cs Adds experimental AddComponentMetadata<TContext> registration and internal metadata services wiring.
src/Components/Web/src/Metadata/ComponentJsonMetadataResolver.cs Adds per-provider resolver snapshot composition from configured resolvers.
src/Components/Web/src/Metadata/ComponentJsonMetadataOptions.cs Introduces resolver list options with a default framework persistent-state context.
src/Components/Web/src/JSComponents/JSComponentInterop.cs Uses explicit JsonTypeInfo overloads when deserializing JS component parameters and JS object references.
src/Components/Web/src/Internal/WebPersistentStateJsonContext.cs Adds a generated context for web persistent-state DTO(s).
src/Components/Web/src/Internal/WebJSInteropSerializerContext.cs Adds a generated context for fixed JSInterop payload types (primitives, arrays, navigation options, etc.).
src/Components/Shared/src/RenderFragmentSerializer.cs Switches fragment attribute/value deserialization to JsonTypeInfo overloads.
src/Components/Shared/src/JsonSerializerOptionsProvider.cs Makes reflection resolver inclusion explicit/conditional when constructing shared options.
src/Components/Shared/src/JsonSerialization/JsonConverterFactoryTypeInfoResolver.cs Removes the previous generic converter-factory-backed resolver implementation.
src/Components/Shared/src/JsonSerialization/ConverterBackedTypeInfoResolver.cs Adds a converter-backed resolver that produces JsonTypeInfo for converter-handled types.
src/Components/Server/test/ProtectedBrowserStorageSerializerTest.cs Adds tests for typed protected storage writes/reads and custom serializer precedence/fallback.
src/Components/Server/test/ProtectedBrowserStorageSerializerOptionsTest.cs Adds tests for protected storage options snapshotting and resolver ordering behavior.
src/Components/Server/test/Circuits/CircuitOptionsJavaScriptInitializersConfigurationTest.cs Adds tests for manifest-driven initializer configuration including reflection-disabled behavior.
src/Components/Server/src/PublicAPI.Unshipped.txt Adds new public API entries for typed protected storage and ProtectedBrowserStorageSerializer<T>.
src/Components/Server/src/ProtectedBrowserStorage/ProtectedSessionStorage.cs Adds internal ctor to flow serializer options + services provider into base.
src/Components/Server/src/ProtectedBrowserStorage/ProtectedLocalStorage.cs Adds internal ctor to flow serializer options + services provider into base.
src/Components/Server/src/ProtectedBrowserStorage/ProtectedBrowserStorageSerializerOptions.cs Adds DI-owned options snapshot builder for protected storage (app resolver first, reflection last).
src/Components/Server/src/ProtectedBrowserStorage/ProtectedBrowserStorageSerializer.cs Adds experimental public per-type serializer abstraction for protected storage.
src/Components/Server/src/ProtectedBrowserStorage/ProtectedBrowserStorage.cs Adds typed SetAsync<T> overloads and DI-based typed serializer lookup; snapshots serializer options per instance.
src/Components/Server/src/Microsoft.AspNetCore.Components.Server.csproj Links shared component metadata helper into Server build.
src/Components/Server/src/DependencyInjection/ComponentServiceCollectionExtensions.cs Wires protected storage DI to use provider-scoped serializer options and enable typed serializer resolution.
src/Components/Server/src/Circuits/ServerComponentJsonContext.Server.cs Extends server component generated context with root operation batch contracts.
src/Components/Server/src/Circuits/ServerComponentDeserializer.cs Snapshots per-provider JSON options and uses explicit JsonTypeInfo overloads for markers and DTOs.
src/Components/Server/src/Circuits/RemoteNavigationManager.cs Sends renderer id as int wire representation for location-changing listener call.
src/Components/Server/src/Circuits/RemoteNavigationInterception.cs Sends renderer id as int wire representation for enable interception call.
src/Components/Server/src/Circuits/ComponentParameterDeserializer.cs Snapshots per-provider options and uses explicit JsonTypeInfo overloads for fragment/union/parameter deserialization.
src/Components/Server/src/Circuits/CircuitPersistenceManager.cs Deserializes persisted marker dictionaries via generated type-info contract.
src/Components/Server/src/Circuits/CircuitOptionsJavaScriptInitializersConfiguration.cs Uses generated string-array contract for module manifest deserialization.
src/Components/Server/src/CircuitJavaScriptInitializationMiddleware.cs Writes initializer payload using generated IList<string> contract to work when reflection serialization is disabled.
src/Components/Endpoints/test/TempData/JsonTempDataSerializerTest.cs Adds reflection-disabled test coverage for “generated-contract-only” temp data serialization support.
src/Components/Endpoints/test/LinkerDescriptorTest.cs Adds test asserting linker substitutions target the Endpoints assembly.
src/Components/Endpoints/test/EndpointHtmlRendererTest.cs Adds raw JSON shape assertions ensuring camelCase/omitted-null protocol markers remain stable.
src/Components/Endpoints/test/DependencyInjection/ComponentJsonMetadataIsolationTest.cs Adds test proving serializer/provider isolation with reflection disabled.
src/Components/Endpoints/test/ComponentSerializationSettingsTest.cs Adds tests verifying generated marker contracts precede reflection and reflection-disabled uses generated-only.
src/Components/Endpoints/src/TempData/SessionStorageTempDataProvider.cs Switches session temp data deserialization to generated JsonTypeInfo.
src/Components/Endpoints/src/TempData/JsonTempDataSerializer.cs Makes generic-interface reflection compatibility path conditional; switches serialization/deserialization to generated JsonTypeInfo.
src/Components/Endpoints/src/TempData/CookieTempDataProvider.cs Switches cookie temp data deserialization to generated JsonTypeInfo.
src/Components/Endpoints/src/SessionCascadingValueSupplier.cs Introduces provider-scoped JSON options with app resolver + conditional reflection fallback and uses JsonTypeInfo overloads.
src/Components/Endpoints/src/Rendering/SSRRenderModeBoundary.cs Uses provider-scoped WebAssembly component serializer instance (or creates one with provider) to include app resolver snapshot.
src/Components/Endpoints/src/Rendering/EndpointHtmlRenderer.Streaming.cs Serializes start/end markers using options-owned JsonTypeInfo to preserve protocol options and avoid reflection.
src/Components/Endpoints/src/Properties/ILLink.Substitutions.xml Updates linker substitutions target assembly to Endpoints.
src/Components/Endpoints/src/Microsoft.AspNetCore.Components.Endpoints.csproj Links shared component metadata helper into Endpoints build.
src/Components/Endpoints/src/DependencyInjection/WebAssemblyComponentSerializer.cs Converts serializer to instance type with provider-scoped options snapshot and explicit JsonTypeInfo serialization.
src/Components/Endpoints/src/DependencyInjection/RazorComponentsServiceCollectionExtensions.cs Registers ServerComponentSerializer via DI constructor injection (provider-scoped options snapshot).
src/Components/Endpoints/src/DependencyInjection/DefaultRazorComponentsServiceOptionsConfiguration.cs Uses generated contract when parsing JavaScript initializer JSON strings.
src/Components/Endpoints/src/CacheView/SerializedRenderFragmentHybridCacheSerializer.cs Uses explicit JsonTypeInfo in hybrid-cache fragment serializer.
src/Components/Endpoints/src/Builder/ResourceCollectionUrlEndpoint.cs Serializes resource collections using options-owned type-info.
src/Components/Endpoints/src/Assets/ImportMapDefinition.cs Serializes import map with options-owned type-info to avoid reflection.
src/Components/Components/test/PersistentState/PersistentStateSerializationOptionsTest.cs Adds tests for independent ordered option snapshots and reflection-disabled behavior.
src/Components/Components/src/PersistentState/PersistentStateSerializationOptions.cs Adds helper to create ordered per-manager persistent-state options (framework first, app, reflection-last).
src/Components/Components/src/PersistentState/PersistentServicesRegistry.cs Uses generated type-info for registry persistence and adds non-serializable property logging + filtering.
src/Components/Components/src/PersistentState/ComponentStatePersistenceManager.cs Creates PersistentComponentState with per-provider serialization options snapshot and app resolver from DI.
src/Components/Components/src/PersistentComponentState.cs Adds option snapshot support, typed JsonTypeInfo persist/take helpers, and a CanSerialize(Type) check.
src/Components/Components/src/Infrastructure/IComponentJsonMetadataResolver.cs Adds internal abstraction for accessing composed application resolver snapshots.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@Youssef1313 Youssef1313 added the area-blazor Includes: Blazor, Razor Components label Sep 2, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime.
To make sure no conflicting changes have occurred, please rerun validation before merging. You can do this by leaving an /azp run comment here (requires commit rights), or by simply closing and reopening.

@dotnet-policy-service dotnet-policy-service Bot added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Sep 26, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-blazor Includes: Blazor, Razor Components pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants