Skip to content

[Blazor] Generate component metadata for Native AOT - #68299

Open
javiercn wants to merge 17 commits into
javiercn-aot-stack-3-bindingfrom
javiercn-component-metadata-aot
Open

javiercn wants to merge 17 commits into
javiercn-aot-stack-3-bindingfrom
javiercn-component-metadata-aot

Conversation

@javiercn

@javiercn javiercn commented Aug 9, 2026 •

Copy link
Copy Markdown
Member

Overview

This is layer 4 of 6 for #68332, stacked on #68297. It gives component activation, member access, routing/discovery, and Server root operations one shared ComponentTypeInfo model, then teaches the application metadata generator to produce that model at compile time. The governing constraint is generated first, reflection last: registered metadata avoids reflection, while applications without metadata continue to work unchanged; framework-owned descriptor providers and strict reflection disablement remain in later stack layers.

Design

The new experimental contract describes a component as executable metadata rather than as reflected members:

// src/Components/Components/src/Infrastructure/ComponentDescriptor.cs
// One complete application-component description: construction, bindable members, injection,
// and the attribute-shaped metadata already consumed by routing/rendering.
[Experimental("ASPNETCORE9004", UrlFormat = "https://aka.ms/aspnet/analyzer/{0}")]
public sealed class ComponentDescriptor
{
    [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
    public required Type Type { get; init; }
    public Func<IServiceProvider, IComponent>? CreateInstance { get; init; }
    public IReadOnlyList<ComponentParameterDescriptor> Parameters { get; init; } = [];
    public IReadOnlyList<ComponentInjectableDescriptor> Injectables { get; init; } = [];
    public IReadOnlyList<object> Metadata { get; init; } = [];
}

ComponentParameterDescriptor carries the declared type, role attribute, generated getter/setter delegates, and an optional closed persistent-state serializer factory. ComponentInjectableDescriptor is separate because injection has different semantics: service type, keyed [Inject] metadata, and a setter, but no getter or unmatched-value behavior. The open metadata bag carries route, layout, render-mode, endpoint, and future attributes without expanding the public API for each feature.

The existing application metadata context gains one capability and keeps the lower-layer JSON, JS-invokable, and bindable contracts:

// src/Components/Web/src/Metadata/RazorComponentsMetadataContext.cs
public abstract class RazorComponentsMetadataContext
{
    public abstract IReadOnlyList<ComponentDescriptor> Components { get; }
    public abstract IReadOnlyList<BindableTypeDescriptor> BindableTypes { get; }
    public abstract IReadOnlyList<JSInvokableMethodDescriptor> JSInvokableMethods { get; }
    public abstract IJsonTypeInfoResolver? JsonTypeInfoResolver { get; }
}
// src/Components/Web/src/Metadata/ComponentMetadataServiceCollectionExtensions.cs
public static IServiceCollection AddComponentMetadata<TContext>(this IServiceCollection services)
    where TContext : RazorComponentsMetadataContext, new()
{
    var context = new TContext();
    services.Configure<ComponentDescriptorOptions>(options =>
    {
        foreach (var component in context.Components)
        {
            options.Components.Add(component);
        }
    });

    services.AddSingleton<RazorComponentsMetadataContext>(context);
    services.TryAddSingleton<IComponentMetadataResolver>(
        static services => services.GetRequiredService<ComponentMetadataResolver>());
    services.TryAddSingleton<IComponentTypeInfoResolver>(ComponentTypeInfoResolverFactory.Create);
    return services;
}

Two decisions preserve compatibility:

  • A component is generated completely or not at all. A partial descriptor could silently omit a parameter or injected property because runtime consumers trust the descriptor's member lists. Unsupported/inaccessible application components receive a diagnostic and remain on reflection.
  • The runtime owns the component-reflection feature switch, but its default stays true. This layer defines generated-only resolver/failure semantics; the final strict layer is responsible for setting the switch to false.
// src/Components/Components/src/ComponentTypeInfoResolverFactory.cs
internal static IComponentTypeInfoResolver Create(IServiceProvider services)
{
    var resolvers = new List<IComponentTypeInfoResolver>();
    if (services.GetService<IComponentMetadataResolver>() is { } metadataResolver)
    {
        resolvers.Add(new SourceGeneratedComponentTypeInfoResolver(metadataResolver));
    }

    if (ComponentMetadataFeature.IsReflectionEnabledByDefault)
    {
        resolvers.Add(new ReflectionComponentTypeInfoResolver());
    }

    return new CompositeComponentTypeInfoResolver(resolvers);
}

Framework assemblies are intentionally skipped by the application collector. The next stack layer supplies owner-authored framework descriptors and factories; this PR only establishes the resolver/merge contract they consume.

Implementation

A renderer creates one resolver chain and gives it to activation, property injection, parameter binding, cascading state, persistence, discovery, and root operations. The source-generated resolver is first; the composite caches type/name/assembly lookups, can fill a missing generated construction factory from a later resolver, and invalidates caches for hot reload. If both generated and reflection resolvers exist, hot reload disables stale generated descriptors and continues through reflection.

// src/Components/Components/src/RenderTree/Renderer.cs
var registeredTypeInfoResolver = serviceProvider.GetService<IComponentTypeInfoResolver>();
ComponentTypeInfoResolver = registeredTypeInfoResolver
    ?? ComponentTypeInfoResolverFactory.Create(serviceProvider);

componentActivator ??= serviceProvider.GetService<IComponentActivator>()
    ?? new DefaultComponentActivator(serviceProvider, ComponentTypeInfoResolver);
var propertyActivator = serviceProvider.GetService<IComponentPropertyActivator>()
    ?? new DefaultComponentPropertyActivator(ComponentTypeInfoResolver);
_componentFactory = new ComponentFactory(componentActivator, propertyActivator, this);

The generator walks referenced application types with private metadata imported because Razor-generated @inject properties and render-mode attributes are not visible under Roslyn's default import mode. It preserves most-derived member semantics, reconstructs component attributes, and rejects the whole component if any required member cannot be reached.

// src/Components/Endpoints/gen/RazorComponentsMetadataGenerator.Components.cs
// A partial descriptor is unsafe: consumers would trust incomplete parameter/injection lists.
if (!TryDescribeComponent(type, types, generatedIn, diagnostics, out var model, out var reason))
{
    if (!string.IsNullOrEmpty(reason))
    {
        diagnostics.Add(new DiagnosticInfo(
            DiagnosticDescriptors.ComponentNotFullyDescribed.Id,
            type.FullName(),
            reason));
    }

    continue;
}

Generated parameter descriptors cover ordinary, cascading/query/session/TempData, and persistent parameters. Their deltas are only the reconstructed attribute and optional serializer/accessor bridge:

// src/Components/Endpoints/gen/Emitters/RazorComponentsMetadataGenerator.Emitter.cs
writer.WriteLine($"Name = {SymbolHelpers.ToStringLiteral(parameter.Name)},");
writer.WriteLine($"ParameterType = typeof({parameter.PropertyTypeFullyQualifiedName}),");
writer.WriteLine($"Attribute = {parameter.AttributeExpression},");
writer.WriteLine($"SetValue = static (__target, __value) => {write},");
writer.WriteLine($"GetValue = static __target => {read},");

if (parameter.IsPersistentState)
{
    // T is known at compile time, avoiding MakeGenericType at runtime.
    writer.WriteLine(
        $"GetStateSerializer = static __services => __services.GetService(" +
        $"typeof({StateSerializerType}<{parameter.PropertyTypeFullyQualifiedName}>)),");
}

Runtime entry points retain renderer-scoped type info instead of rediscovering members. ComponentBase binds through the renderer; ComponentFactory uses descriptor render modes, activation, and injection; Session and TempData share descriptor-first value access instead of maintaining independent reflection caches.

// src/Components/Components/src/ComponentBase.cs
public virtual Task SetParametersAsync(ParameterView parameters)
{
    parameters.SetParameterProperties(this, _renderHandle);
    if (!_initialized)
    {
        _initialized = true;
        return RunInitAndSetParametersAsync();
    }

    return CallOnParametersSetAsync();
}
// src/Components/Endpoints/src/ComponentParameterValueGetter.cs
internal static Func<object?> Create(object component, ComponentTypeInfo typeInfo, string propertyName)
{
    var descriptor = FindParameter(typeInfo, propertyName);
    if (descriptor is null && ComponentMetadataFeature.IsReflectionEnabledByDefault)
    {
        descriptor = FindParameter(
            ComponentTypeInfoResolverFactory.Default.GetRequiredTypeInfo(component.GetType()),
            propertyName);
    }

    if (descriptor is null)
    {
        throw new InvalidOperationException(
            $"A property '{propertyName}' on component type '{component.GetType().FullName}' wasn't found.");
    }

    return () => descriptor.GetValue(component);
}

Discovery is the assembly-enumeration equivalence class. Routing and endpoint discovery enumerate ComponentTypeInfo, route-cache identity includes the resolver, and endpoint metadata is the descriptor metadata minus RouteAttribute. Layout and render-mode consumers read the same metadata bag, so the old assembly/component/page builder graph is removed.

// src/Components/Endpoints/src/Discovery/ComponentApplicationBuilder.cs
public ComponentApplicationBuilder AddAssembly(Assembly assembly)
{
    ArgumentNullException.ThrowIfNull(assembly);
    AddLibrary(assembly.FullName!, _typeInfoResolver.GetRequiredTypeInfos(assembly));
    return this;
}

Server roots are the lifetime equivalence class. Initial marker deserialization resolves and stores ComponentTypeInfo; dynamic add/update operations pass that object into the renderer; resumed circuits retain (typeInfo, parameters) rather than discarding metadata and resolving by Type again.

// src/Components/Shared/src/WebRootComponentManager.cs
public Task AddRootComponentAsync(
    int ssrComponentId,
    [DynamicallyAccessedMembers(Component)] Type componentType,
    ComponentMarkerKey? key,
    WebRootComponentParameters parameters)
    => AddRootComponentAsync(
        ssrComponentId,
        renderer.ComponentTypeInfoResolver.GetRequiredTypeInfo(componentType),
        key,
        parameters);

PR4's feature application and browser scenarios now consume the Native AOT Components.Testing harness from main (#68289) and the shared MSTest/MTP infrastructure from #67083. The upstream harness owns publish/source-generation plumbing; this PR contributes only its application, ServerFactory fixture/routing integration, and component-metadata scenarios. The separate JitDefault category proves undescribed component, JS method, and JSON payload fallbacks remain compatible.

Outcome

Equivalence class What is covered Validation
Runtime type-info consumers Reflection/generated activation and injection, ordinary/cascading/query/session/TempData parameters, unmatched values, persistence, render modes, resolver ordering/caches/hot reload, activator substitution, and reflection-disabled fail-fast behavior Focused Components: 124 passed
Discovery and endpoint value access Type-info route/endpoint discovery, metadata propagation, descriptor-first Session/TempData getters, reflection compatibility, and missing-metadata failure Focused Endpoints: 35 passed
Server root lifetime Initial markers, dynamic roots, resumed roots, parameter deserialization, circuit persistence, and service registration retain ComponentTypeInfo Focused Server: 123 passed
Application generation Factories, inherited/public/private accessors, attributes, diagnostics, persistent serializer closure, typed JSON/JS serialization, and DynamicallyAccessedMembers bridges Shared MSTest generator Test target: 40 passed
Feature integration The PR4 feature project builds on the upstream Components.Testing harness and exercises generated activation plus default reflection compatibility under JIT MSTest/MTP JIT smoke: 2 passed

Stack note: this PR depends on #68297. Framework-owned component descriptor providers are added by the next stack layer; strict reflection-disabled Native AOT proof follows after that.

@javiercn
javiercn force-pushed the javiercn-component-metadata-aot branch from a0b2f1b to 73ba69c Compare August 9, 2026 11:47
@javiercn
javiercn force-pushed the javiercn-component-metadata-aot branch from 73ba69c to cdc58e7 Compare August 9, 2026 12:36
@javiercn
javiercn force-pushed the javiercn-component-metadata-aot branch from cdc58e7 to 1afdfb0 Compare August 9, 2026 19:26
@javiercn
javiercn force-pushed the javiercn-component-metadata-aot branch from c98e962 to eba8437 Compare August 9, 2026 21:47
@javiercn

javiercn commented Aug 9, 2026

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).
3 pipeline(s) were filtered out due to trigger conditions.

javiercn and others added 16 commits August 11, 2026 12:28
…pe info

Route component activation, injection, parameters, cascades, and persistent members through a shared reflection-backed type-info model. Keep the descriptor implementation internal until generated metadata is introduced.

Co-authored-by: Copilot App <[email protected]>
Verify reflection-backed activation, injection, ordinary parameters, cascading parameters, and persistent members before generated metadata is introduced.

Co-authored-by: Copilot App <[email protected]>
Carry component type info through route discovery, route cache identity, endpoint metadata, and page descriptors. Preserve dynamically accessed type flow and include the donor's final route-table annotation fix.

Co-authored-by: Copilot App <[email protected]>
Delete the assembly-scan builder graph now that route and endpoint discovery resolve component type info directly.

Co-authored-by: Copilot App <[email protected]>
Cover route-table metadata, endpoint discovery, hot reload, and page descriptor propagation using normalized component type info with reflection fallback.

Co-authored-by: Copilot App <[email protected]>
Carry resolved component type info through initial markers, dynamic root operations, resumed circuits, renderer attachment, and parameter deserialization.

Co-authored-by: Copilot App <[email protected]>
Cover metadata-aware root component deserialization, renderer attachment, dynamic operations, circuit persistence, and Server service registration.

Co-authored-by: Copilot App <[email protected]>
Expose component, parameter, and injectable descriptors when the existing metadata context first carries Components. Generate application component factories, attributes, accessors, and diagnostics, then resolve generated type info before the default reflection fallback without adding framework provider machinery.

Co-authored-by: Copilot App <[email protected]>
Cover component activation metadata, parameters, cascading and persistent members, injection, inherited metadata, accessibility diagnostics, unique contexts, and runtime registration while preserving lower-layer JSON, JS, and binding contexts.

Co-authored-by: Copilot App <[email protected]>
Wire the E2E manifest task, add the native-capable source-generated harness and targets, and introduce runnable JIT feature applications with metadata registration and browser fixtures. Native testing remains available to later layers but is not enabled here.

Co-authored-by: Copilot App <[email protected]>
Drive activation, injection, parameters, cascades, binding graphs, JS dispatch, JSON composition, custom events, persistence, Session, protected storage, dynamic roots, and endpoint metadata through the JIT feature application.

Co-authored-by: Copilot App <[email protected]>
Keep a dedicated JIT witness for undescribed components, JS-invokable methods, and JSON payloads using the default reflection fallbacks.

Co-authored-by: Copilot App <[email protected]>
Route ComponentBase parameter assignment through renderer-scoped type info and add the compatibility-preserving reflection switch infrastructure and fail-fast branches required when a later layer disables reflection.

Co-authored-by: Copilot App <[email protected]>
Resolve Session and TempData component getters from component parameter descriptors first, preserving reflection fallback compatibility and eliminating their independent reflection caches.

Co-authored-by: Copilot App <[email protected]>
Cover cascading state, activation, injection, resolver ordering and caches, ParameterView, persistent members, generated render modes, activator substitution, and reflection-disabled fail-fast behavior.

Co-authored-by: Copilot App <[email protected]>
Verify descriptor precedence, reflection compatibility, reflection-disabled failure, and Session and TempData subscription parity.

Co-authored-by: Copilot App <[email protected]>
Verify persistent-state serializer closure, JSON resolver composition, typed JS serialization contracts, and generated parameter bridges for DynamicallyAccessedMembers annotations.

Co-authored-by: Copilot App <[email protected]>
@javiercn
javiercn force-pushed the javiercn-component-metadata-aot branch from eba8437 to 103b080 Compare August 11, 2026 10:50
@javiercn
javiercn marked this pull request as ready for review August 11, 2026 14:07
@javiercn
javiercn requested a review from a team as a code owner August 11, 2026 14:07
Copilot AI lite review requested due to automatic review settings 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 advances the Blazor Native AOT “generated first, reflection last” strategy by adding an application-supplied component descriptor surface (ComponentDescriptor via RazorComponentsMetadataContext.Components), wiring up DI to expose component metadata/type-info resolvers, and updating runtime consumers (routing, parameter binding, discovery, server roots) to preferentially consume generated component type info while preserving reflection fallback by default.

Changes:

  • Introduces the ComponentDescriptor/ComponentTypeInfo model and resolver chain (IComponentTypeInfoResolver) and pushes parameter binding/routing/discovery to consume type info rather than ad-hoc reflection caches.
  • Extends RazorComponentsMetadataContext with Components and adds registration plumbing in AddComponentMetadata<TContext>() to feed descriptors into a runtime resolver.
  • Adds/updates tests and test assets (including a Blazor Server AOT feature matrix app + E2E tests) and improves Components.Testing proxy routing to support WebSocket handshakes.

Reviewed changes

Copilot reviewed 183 out of 183 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/Components/WebAssembly/WebAssembly/test/Services/WebAssemblyHostSerializationContextTest.cs Updates test contexts to implement new Components metadata property.
src/Components/Web/test/Metadata/ComponentMetadataServiceCollectionExtensionsTest.cs Validates component descriptor + type-info resolver registrations across multiple metadata contexts.
src/Components/Web/src/WebRenderer.cs Switches root component add-path to flow ComponentTypeInfo; expands JSON serializer context types.
src/Components/Web/src/PublicAPI.Unshipped.txt Records new RazorComponentsMetadataContext.Components public API.
src/Components/Web/src/Microsoft.AspNetCore.Components.Web.csproj Adds IVT for Server to consume Web’s internal metadata resolver.
src/Components/Web/src/Metadata/RazorComponentsMetadataContext.cs Adds abstract Components collection to metadata context.
src/Components/Web/src/Metadata/ComponentMetadataServiceCollectionExtensions.cs Registers component descriptors/options + component/type-info resolvers in DI.
src/Components/Web/src/Metadata/ComponentMetadataResolver.cs New: DI-facing IComponentMetadataResolver implementation backed by options.
src/Components/Web/src/Metadata/ComponentDescriptorOptions.cs New: options container for collected ComponentDescriptor instances.
src/Components/Testing/testassets/BlazorAotFeatures.E2E.Tests/Tests/BlazorServerStateTests.cs New E2E coverage for Session/TempData metadata-first behavior.
src/Components/Testing/testassets/BlazorAotFeatures.E2E.Tests/Tests/BlazorReflectionCompatibilityTests.cs New E2E coverage ensuring reflection fallbacks remain compatible under JIT defaults.
src/Components/Testing/testassets/BlazorAotFeatures.E2E.Tests/Tests/BlazorJsonResolverTests.cs New E2E coverage for JSON resolver composition order/precedence.
src/Components/Testing/testassets/BlazorAotFeatures.E2E.Tests/Tests/BlazorJsInvokableTests.cs New E2E coverage for generated JS-invokable dispatch and payload handling.
src/Components/Testing/testassets/BlazorAotFeatures.E2E.Tests/Tests/BlazorGeneratedMetadataTests.cs New E2E coverage for generated activation + inherited member assignment.
src/Components/Testing/testassets/BlazorAotFeatures.E2E.Tests/Tests/BlazorEndpointMetadataTests.cs New E2E coverage for route/layout/render-mode metadata propagation.
src/Components/Testing/testassets/BlazorAotFeatures.E2E.Tests/Tests/BlazorDynamicRootTests.cs New E2E coverage for dynamic root add/update/remove using metadata.
src/Components/Testing/testassets/BlazorAotFeatures.E2E.Tests/Tests/BlazorCustomEventTests.cs New E2E coverage for custom event args deserialization via unified resolver.
src/Components/Testing/testassets/BlazorAotFeatures.E2E.Tests/Tests/BlazorBindingGraphTests.cs New E2E coverage for binding graph accessors (fields/properties/indexers/arrays).
src/Components/Testing/testassets/BlazorAotFeatures.E2E.Tests/Fixtures/TestRoot.cs New assembly-level server factory lifecycle for E2E tests.
src/Components/Testing/testassets/BlazorAotFeatures.E2E.Tests/Fixtures/FeatureAppServer.cs New shared server start options (timeouts, env vars) for feature app.
src/Components/Testing/testassets/BlazorAotFeatures.E2E.Tests/Fixtures/E2ETestAssembly.cs New marker type for manifest/test assembly discovery.
src/Components/Testing/testassets/BlazorAotFeatures.E2E.Tests/BlazorAotFeatures.E2E.Tests.csproj New E2E test project using Components.Testing harness + publish mode.
src/Components/Testing/src/Infrastructure/ServerFactory.cs Adds cookie-based proxy routing fallback for WebSocket handshakes.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample/SampleMetadata.cs New host-level metadata context composing multiple JSON contexts.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample/Properties/launchSettings.json New launch settings for sample host.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample/Program.cs New slim host wiring: registers component metadata, services, session, harness.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample/JsonContexts.ServerState.cs New JSON context for server-state sample contracts.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample/JsonContexts.JsMatrix.cs New JSON context for JS interop payload contracts.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample/JsonContexts.GeneratedMetadata.cs New JSON context for generated-metadata persistence payloads.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample/JsonContexts.DynamicRoots.cs New JSON context for dynamic root parameter payloads.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample/JsonContexts.CustomEvents.cs New JSON context for custom event payloads/polymorphism.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample/JsonContexts.Composition.cs New JSON contexts for resolver composition/precedence scenarios.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample/JsonContexts.Composition.CoreSecond.cs New JSON context for composition “core” contracts (second).
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample/JsonContexts.Composition.CoreFirst.cs New JSON context for composition “core” contracts (first).
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample/FeatureApp.cs New marker type for harness to identify host assembly.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample/appsettings.json New sample app configuration.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample.Pages/TypedList.razor New generic/templated component for open-generic descriptor coverage.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample.Pages/ThemeStorage.cs New protected storage custom serializer scenario (no JSON contract).
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample.Pages/StorageParameterCoverage.razor New minimal [SupplyParameterFromSession]/[SupplyParameterFromTempData] coverage component.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample.Pages/Routes.razor New router setup with trimming suppressions justified by metadata binding.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample.Pages/Pages/Virtualization.razor New sample page exercising Virtualize + JS interop contract needs.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample.Pages/Pages/Templates.razor New sample page exercising templates, generics, and @key diffing.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample.Pages/Pages/Storage.razor New sample page exercising protected storage JSON + custom serializer paths.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample.Pages/Pages/ServerStateSeed.razor New seed page for session/tempdata server-state scenario.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample.Pages/Pages/ServerState.razor New server-state page exercising session/tempdata/query parameter binding.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample.Pages/Pages/ReflectionFallbacks.razor New page asserting reflection fallback compatibility for components/JS/JSON.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample.Pages/Pages/Query.razor New query parameter page for metadata-first parameter binding coverage.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample.Pages/Pages/Persistence.razor New persistent component state scenario (prerender-to-circuit round trip).
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample.Pages/Pages/Parameters.razor New parameters + cascading values scenario for descriptor-first binding.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample.Pages/Pages/JsonResolverComposition.razor New JSON resolver composition and precedence scenario.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample.Pages/Pages/JsInterop.razor New JS interop page exercising [JSInvokable] without reflection dispatch.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample.Pages/Pages/Home.razor New navigation index for feature matrix pages.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample.Pages/Pages/GeneratedMetadata.razor New page driving generated activation/parameter/cascade/inject/state paths.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample.Pages/Pages/Forms.razor New forms/validation page exercising binding expression evaluation via metadata.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample.Pages/Pages/EndpointMetadata.razor New page exercising endpoint metadata propagation and persistence.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample.Pages/Pages/DynamicRoots.razor New page for JS-driven dynamic root add/update/remove scenarios.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample.Pages/Pages/DataBinding.razor New binding page ensuring expressions resolve without compilation.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample.Pages/Pages/CustomEvents.razor New custom event page using unified JSON resolver for event args payload.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample.Pages/Pages/Counter.razor New baseline interactive counter page.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample.Pages/Pages/BindingGraph.razor New binding graph page for arrays/indexers/fields/properties.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample.Pages/Layout/MetadataLayout.razor New layout used to validate [Layout] metadata propagation.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample.Pages/Layout/MainLayout.razor New main layout/navigation for sample pages.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample.Pages/JsInvokableTargets.cs New JS-invokable target types (static/instance/inherited/return kinds).
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample.Pages/InteropContracts.cs New interop contracts including polymorphic STJ configuration.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample.Pages/InteractiveServerAttribute.cs New attribute-form render mode to keep metadata reconstructable cross-project.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample.Pages/GreetingService.cs New injectable service used to validate generated [Inject] behavior.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample.Pages/GeneratedMetadataChild.razor New child component for inheritance/private setter/persistence coverage.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample.Pages/GeneratedMetadataBase.cs New base component for inherited parameters/cascades/keyed inject tests.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample.Pages/EventHandlers.cs New custom event args + [EventHandler] wiring for event tests.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample.Pages/EndpointMetadataBase.cs New base page type with inherited layout/render-mode/custom metadata.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample.Pages/EndpointMetadataAttributes.cs New custom endpoint metadata attribute type.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample.Pages/ChildCard.razor New component for parameter/cascade/inject binding coverage.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample.Pages/BlazorServerAotSample.Pages.csproj New RCL project for sample pages/components.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample.Pages/BindingModels.cs New binding model graph for metadata-driven binding evaluator tests.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample.Pages/App.razor New app shell hosting Routes + error UI + script.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample.Pages/AotDynamicRoot.razor New dynamic root component for JS root-components API coverage.
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample.Pages/_Imports.razor New shared imports for sample pages.
src/Components/Shared/src/RootComponentOperation.cs Updates root descriptor to carry ComponentTypeInfo on Server builds.
src/Components/Shared/src/Reflection/PropertySetter.cs Adds delegate-based setter constructor and updates nullability for setter delegates.
src/Components/Server/test/ProtectedBrowserStorageSerializerOptionsTest.cs Updates stub contexts to implement Components.
src/Components/Server/test/Microsoft.AspNetCore.Components.Server.Tests.csproj Suppresses experimental analyzer warning for updated tests.
src/Components/Server/test/DependencyInjection/ComponentServiceCollectionExtensionsTest.cs Adds test ensuring IComponentTypeInfoResolver is singleton and usable.
src/Components/Server/test/Circuits/RemoteRendererTest.cs Adds tests for preserving ComponentTypeInfo across root operations and strict missing-metadata failure.
src/Components/Server/test/Circuits/RemoteJSRuntimeMetadataTest.cs Updates test contexts to implement Components.
src/Components/Server/test/Circuits/CircuitPersistenceManagerTest.cs Updates persistence tests to use ComponentTypeInfo-based descriptors/resolution.
src/Components/Server/test/Circuits/CircuitHostTest.cs Updates circuit root operations to pass ComponentTypeInfo through.
src/Components/Server/src/Microsoft.AspNetCore.Components.Server.csproj Removes RootTypeCache compilation input (replaced by type-info resolver).
src/Components/Server/src/DependencyInjection/ComponentServiceCollectionExtensions.cs Registers IComponentTypeInfoResolver instead of RootTypeCache.
src/Components/Server/src/Circuits/ServerComponentDeserializer.cs Switches marker deserialization to resolve ComponentTypeInfo via resolver.
src/Components/Server/src/Circuits/RemoteRenderer.cs Widens some virtual members to protected internal for metadata-aware paths and adjusts log nesting.
src/Components/Server/src/Circuits/RemoteComponentState.cs Widens component key hook to protected internal.
src/Components/Server/src/Circuits/ComponentDescriptor.cs Stores ComponentTypeInfo instead of Type for root component descriptors.
src/Components/Server/src/Circuits/CircuitPersistenceManager.cs Updates persistence serialization loop to handle ComponentTypeInfo tuples.
src/Components/Server/src/Circuits/CircuitJSComponentInterop.cs Widens JS root operations hooks to protected internal.
src/Components/Server/src/Circuits/CircuitHost.cs Uses ComponentTypeInfo when adding/updating root components.
src/Components/Endpoints/test/TempData/TempDataSubscriptionTest.cs Adds attribute on test component to match new descriptor-first getter path.
src/Components/Endpoints/test/Session/SessionSubscriptionTest.cs Adds attribute on test component to match new descriptor-first getter path.
src/Components/Endpoints/test/RazorComponentEndpointFactoryTest.cs Updates tests to use PageComponentDescriptor naming.
src/Components/Endpoints/test/RazorComponentEndpointDataSourceTest.cs Updates builder usage and injects default component type-info resolver into data source creation.
src/Components/Endpoints/test/HotReloadServiceTests.cs Updates builder APIs to AddLibrary/RemoveLibrary using ComponentTypeInfo-based descriptors.
src/Components/Endpoints/test/EndpointHtmlRendererTest.cs Registers WebAssemblyComponentSerializer in test DI setup.
src/Components/Endpoints/test/Discovery/DescribedComponentDiscoveryTest.cs New tests for discovery via normalized ComponentTypeInfo + reflection fill behavior.
src/Components/Endpoints/test/DependencyInjection/ComponentJsonMetadataIsolationTest.cs Updates test contexts to implement Components.
src/Components/Endpoints/test/ComponentParameterValueGetterTest.cs New tests validating descriptor-first value getter and reflection fallback/strict behavior.
src/Components/Endpoints/test/Builder/RazorComponentsEndpointConventionBuilderExtensionsTest.cs Updates test builder setup to AddLibrary with ComponentDescriptor metadata.
src/Components/Endpoints/src/TempData/TempDataCascadingValueSupplier.cs Replaces reflection getter cache with descriptor-first ComponentParameterValueGetter.
src/Components/Endpoints/src/SessionCascadingValueSupplier.cs Replaces reflection getter cache with descriptor-first ComponentParameterValueGetter.
src/Components/Endpoints/src/Rendering/EndpointHtmlRenderer.Prerendering.cs Widens render-mode hooks to protected internal.
src/Components/Endpoints/src/Rendering/EndpointHtmlRenderer.cs Widens Assets property to protected internal.
src/Components/Endpoints/src/Rendering/EndpointComponentState.cs Stops using reflection cache/hot-reload handler for StreamRendering; reads from ComponentTypeInfo.Metadata.
src/Components/Endpoints/src/Microsoft.AspNetCore.Components.Endpoints.csproj Suppresses experimental analyzer warning for endpoints assembly.
src/Components/Endpoints/src/Discovery/RazorComponentApplication.cs Shifts discovery model to ComponentDescriptor/PageComponentDescriptor and reads render mode from metadata bag.
src/Components/Endpoints/src/Discovery/PageComponentDescriptor.cs Renames PageComponentInfo to PageComponentDescriptor.
src/Components/Endpoints/src/Discovery/PageComponentBuilder.cs Removed legacy page builder used by reflection scanning.
src/Components/Endpoints/src/Discovery/PageCollectionBuilder.cs Removed legacy page collection builder.
src/Components/Endpoints/src/Discovery/IRazorComponentApplication.cs Removed legacy reflection-scanning application builder interface.
src/Components/Endpoints/src/Discovery/DefaultRazorComponentApplication.cs Removed legacy default application implementation.
src/Components/Endpoints/src/Discovery/ComponentInfo.cs Removed legacy component info model that carried render mode as a member.
src/Components/Endpoints/src/Discovery/ComponentCollectionBuilder.cs Removed legacy component collection builder.
src/Components/Endpoints/src/Discovery/ComponentBuilder.cs Removed legacy component builder model.
src/Components/Endpoints/src/Discovery/AssemblyComponentLibraryDescriptor.cs Removed legacy assembly library descriptor model.
src/Components/Endpoints/src/DependencyInjection/RazorComponentsServiceCollectionExtensions.cs Registers IComponentTypeInfoResolver for endpoints DI.
src/Components/Endpoints/src/ComponentParameterValueGetter.cs New helper for descriptor-first parameter value reads with reflection fallback.
src/Components/Endpoints/src/Builder/RazorComponentsEndpointConventionBuilderExtensions.cs Adjusts remarks wording away from “scanned” to “searched”.
src/Components/Endpoints/src/Builder/RazorComponentEndpointFactory.cs Updates factory signature to accept PageComponentDescriptor.
src/Components/Endpoints/src/Builder/RazorComponentEndpointDataSourceFactory.cs Uses ComponentApplicationBuilder.AddAssembly and injects type-info resolver into data source.
src/Components/Endpoints/src/Builder/RazorComponentEndpointDataSource.cs Constructs ComponentApplicationBuilder with resolver and updates endpoint build pipeline.
src/Components/Endpoints/src/Builder/RazorComponentApplicationAttribute.cs Removed legacy attribute-based application model hook.
src/Components/Endpoints/gen/WellKnownTypes.cs Extends generator well-known type set for component/attribute discovery.
src/Components/Endpoints/gen/DiagnosticDescriptors.cs Adds diagnostics for incomplete component/attribute description.
src/Components/Components/test/ReflectionComponentTypeInfoResolverTest.cs New tests covering reflection resolver output and activator/property binder consumption.
src/Components/Components/test/Microsoft.AspNetCore.Components.Tests.csproj Suppresses experimental analyzer warning for new tests.
src/Components/Components/src/Sections/SectionOutlet.cs Routes parameter binding through render-handle aware overload.
src/Components/Components/src/Routing/RouteTable.cs Keys route-entry cache by resolver to keep cache correctness across resolver chains.
src/Components/Components/src/Routing/Router.cs Uses ComponentTypeInfo metadata for NotFound route validation and route parameter processing.
src/Components/Components/src/RouteView.cs Uses ComponentTypeInfo metadata for layout resolution and render-handle aware parameter binding.
src/Components/Components/src/Rendering/ComponentState.cs Captures ComponentTypeInfo per component and flows resolver/type-info into parameter supply pipeline.
src/Components/Components/src/RenderHandle.cs Exposes ComponentTypeInfoResolver from renderer to support metadata-first binding paths.
src/Components/Components/src/PublicAPI.Unshipped.txt Records new experimental component descriptor public APIs.
src/Components/Components/src/ParameterView.cs Carries optional resolver/type-info and adds render-handle aware SetParameterProperties overload.
src/Components/Components/src/Microsoft.AspNetCore.Components.csproj Adds IVT for Endpoints/Server to consume internal metadata plumbing.
src/Components/Components/src/LayoutView.cs Uses ComponentTypeInfo metadata for parent layout resolution and render-handle aware binding.
src/Components/Components/src/Infrastructure/IComponentMetadataResolver.cs New internal abstraction for enumerating/looking up generated component descriptors.
src/Components/Components/src/Infrastructure/ComponentParameterDescriptor.cs New experimental descriptor for parameter/cascading/persistent properties with delegates.
src/Components/Components/src/Infrastructure/ComponentInjectableDescriptor.cs New experimental descriptor for [Inject] properties with setter delegates.
src/Components/Components/src/Infrastructure/ComponentDescriptor.cs New experimental top-level component descriptor model.
src/Components/Components/src/IComponentTypeInfoResolver.cs New internal resolver abstraction + “GetRequired” helper extensions.
src/Components/Components/src/DefaultComponentActivator.cs Updates activation to use ComponentTypeInfo (generated-first) with reflection fallback/strict behavior.
src/Components/Components/src/ComponentTypeInfoResolverFactory.cs New resolver factory + feature switch controlling reflection fallback default.
src/Components/Components/src/ComponentTypeInfo.cs New internal normalized type-info wrapper around descriptor with cached sets and convenience APIs.
src/Components/Components/src/ComponentBase.cs Routes parameter binding through render-handle aware overload.
src/Components/Components/src/CascadingParameterState.cs Removes reflection cache and reads cascading parameter info from ComponentTypeInfo.Parameters.

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

Comment on lines +847 to +861
private sealed class StaticComponentTypeInfoResolver(ComponentTypeInfo typeInfo = null)
: IComponentTypeInfoResolver
{
public ComponentTypeInfo GetTypeInfo(Type componentType)
=> typeInfo?.Type == componentType ? typeInfo : null;

public ComponentTypeInfo GetTypeInfo(string assemblyName, string typeName)
=> typeInfo?.Type.Assembly.GetName().Name == assemblyName &&
typeInfo.Type.FullName == typeName
? typeInfo
: null;

public IReadOnlyList<ComponentTypeInfo> GetTypeInfos(Assembly assembly)
=> typeInfo?.Type.Assembly == assembly ? [typeInfo] : [];
}
var backend = context.Request.Headers["X-Test-Backend"].ToString();
if (!string.IsNullOrEmpty(backend) && context.Request.Cookies[BackendCookieName] != backend)
{
context.Response.Cookies.Append(BackendCookieName, backend, new CookieOptions { Path = "/" });
@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