Repository navigation
Conversation
14cc38b to
7f60778
Compare
7f60778 to
7274404
Compare
Disable the STJ, component metadata, and JS-invokable reflection fallbacks in the strict feature app, promote incomplete generated metadata to errors, and require ILC warnings as errors. Keep unsupported HTTP form mapping outside the proof image through a strict-test-only substitution. Co-authored-by: Copilot App <[email protected]>
7274404 to
43c0eb4
Compare
There was a problem hiding this comment.
Pull request overview
This PR completes the final “strict Native AOT proof” layer for the Blazor component metadata stack by making the test assets and generator diagnostics capable of running with reflection fallbacks disabled and with ILC warnings promoted to errors, without introducing new product-facing APIs.
Changes:
- Updates the dedicated Blazor AOT feature E2E test asset to publish/run in Native AOT mode via the shared compiled-harness pipeline, including forwarding strict-mode properties and a required RID.
- Extends
RazorComponentsMetadataGeneratorto readRazorComponentsReflectionEnabledByDefaultfrom analyzer config and escalate selected diagnostics (BLAZORAOT001/BLAZORAOT004) to errors when reflection is disabled by default. - Adds strict-mode ILC substitution for the unsupported HTTP form mapper in the proof image, plus local suppressions for trimming warnings in the test app.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/Components/Testing/testassets/BlazorAotFeatures.E2E.Tests/BlazorAotFeatures.E2E.Tests.csproj | Switches the E2E project reference to publish-mode with Native AOT compiled harness and forwards strict-mode properties/RID. |
| src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample/Program.cs | Uses CreateSlimBuilder + UseStaticWebAssets, registers the compiled E2E harness, and adds trimming suppressions at call sites. |
| src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample/BlazorServerAotSample.ILLink.Substitutions.xml | Adds strict-mode linker substitutions to disable HTTP form mapping implementation in the proof image. |
| src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample/BlazorServerAotSample.csproj | Enables Native AOT publishing for the asset, disables reflection by default for generated component metadata, and wires strict-mode host config + substitutions. |
| src/Components/Endpoints/test/Microsoft.AspNetCore.Components.Endpoints.Generators.Tests/RazorComponentsMetadataGeneratorTestBase.cs | Adds a test analyzer-config options provider to simulate RazorComponentsReflectionEnabledByDefault for generator tests. |
| src/Components/Endpoints/test/Microsoft.AspNetCore.Components.Endpoints.Generators.Tests/RazorComponentsMetadataGeneratorDiagnosticTests.cs | Expands diagnostic tests to validate warning vs error severity depending on reflection-default mode. |
| src/Components/Endpoints/gen/RazorComponentsMetadataGenerator.cs | Reads build property via analyzer config and routes severity selection into diagnostic creation. |
| src/Components/Endpoints/gen/Emitters/RazorComponentsMetadataGenerator.Emitter.cs | Plumbs reflection-default mode into diagnostic reporting. |
| src/Components/Endpoints/gen/DiagnosticDescriptors.cs | Adds “Error” variants of key descriptors by cloning existing descriptors with DiagnosticSeverity.Error. |
Suppressed comments (1)
src/Components/test/testassets/BlazorAotFeatures/BlazorServerAotSample/Program.cs:80
AddSession()is explicitly annotated with[RequiresUnreferencedCode("Session State middleware does not currently support trimming or native AOT.")](seesrc/Middleware/Session/src/SessionServiceCollectionExtensions.cs:21-28). Suppressing IL2026 here makes the strict Native AOT lane claim to be warning-free while still relying on a feature the framework marks as unsupported for Native AOT. Consider removing session usage from the strict matrix (or gating it out whenBlazorAotStrictMode=true) so the proof image doesn’t depend on Session, or update the scenario to use an AOT-supported persistence mechanism.
[UnconditionalSuppressMessage("Trimming", "IL2026",
Justification = "This sample only stores generated-contract values through the session-backed component state feature.")]
static void AddSessionSupport(IServiceCollection services)
{
services.AddDistributedMemoryCache();
services.AddSession();
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
|
Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime. |
Overview
Layer 6 of 6 for the Native AOT metadata stack; depends on #68300 and completes the umbrella feature tracked by #68332. It turns the existing feature matrix into a strict Native AOT proof without adding a product API, runtime feature, provider, root, or scenario. The cross-cutting constraint is that the app must publish and run with the STJ, component-metadata, and JS-invokable reflection fallbacks disabled; incomplete generated metadata or any ILC warning fails the build.
Design
There are no public API changes. The new contract is build-time and test-app-local: the application exposes
RazorComponentsReflectionEnabledByDefaultto the metadata generator, and the generator escalates only diagnostics whose runtime recovery requires component reflection.The dedicated feature app enables Native AOT analysis, requires complete generated component metadata, and promotes ILC warnings to errors. Runtime fallback removal remains separately gated by
BlazorAotStrictMode, so the same scenarios retain ordinary compatibility coverage.A broad
NoWarnor product suppression was deliberately rejected because it would weaken the zero-warning proof. HTTP form mapping is not exercised by this matrix and is not Native-AOT-supported here, so the strict test image removes only that private implementation through an app-owned ILC substitution; product assemblies and non-strict behavior are unchanged.Implementation
The test project uses the shared MSTest/Components.Testing harness introduced by #68289 and #67083. The app reference selects published Native AOT mode, provides the RID required by the shared target, and forwards strict mode through the standard
AdditionalPropertiescontract.The shared target turns
E2ENativeAotintoE2ECompileTestHarness=truefor the nested publish. In the source tree, the app references the shared Native AOT generator as an analyzer unconditionally so clean restore sees the project; generation itself remains property-gated.CreateSlimBuilderdeliberately skips hosting startups, so the app invokes the shared generated extension explicitly only in that nested publish.The only excluded behavior class is the unsupported HTTP form mapper. The target is doubly gated on strict mode and Native AOT, and the substitution has three exact deltas:
CanMapreturnsfalse;MapandCreateDeserializerhave no bodies. This makes the code unreachable in the proof image without suppressing a warning code or claiming form-mapping support.Outcome
E2ENativeAotpublishing removes all three supported reflection fallbacks without hiding warning codes.JitDefaultwitness is excluded.