Prune proxy generator handler discovery to relevant assemblies - #2545
Conversation
The artifacts pinned net8.0;net9.0;net10.0 unconditionally, but Directory.Build.props builds net10.0 only in Debug. Arc.Core, which CommandResponseHandlerDependency references, is therefore net10.0-only in Debug and restore failed with NU1201, so ProxyGenerator.Specs could not be built or run in Debug at all. Let both artifacts inherit the target frameworks like every other project, so they follow Arc.Core in both configurations.
Moving the well-known type checks to name-based comparison left seven cached Type fields assigned but never read. Each one still cost a metadata type load on every initialization.
Handler discovery metadata-loaded every managed dependency of the application and called GetTypes on each one, on every generator run. Declaring a handler means implementing its contracts, so an assembly that does not reference Cratis.Arc.Core cannot contribute a declaration and does not need its type metadata materialized. Skipping those assemblies also means the counterfeit-contract defense is no longer what rejects a look-alike dependency in the end to end path, so the assembly identity matching is now pinned directly by its own specs.
Publishing the assembly name cache and loading the well known types ran after the guarded region, so a failure there escaped with the metadata load context published and the assembly resolving handler still attached, leaving both to leak until the next initialization. Also stop throwing from the runtime fallback when more than one copy of the contracts assembly is loaded, and take a single snapshot of the loaded assemblies instead of enumerating them twice.
|
Reviewer context (kept out of the description, which becomes the release notes). Origin. Follow-ups from reviewing #2540. Items 1–3 of that review; the remaining two (splitting the 1,677-line Internal changes with no user-facing effect:
On the specs. The new assembly filter means a dependency shipping look-alike contracts is skipped before the identity check runs, so Verification (local, net10.0 unless noted):
Not separately spec'd: the widened guard around |
Summary
Follow-up cleanup to the command response value handler declarations. Build-time handler discovery no longer materializes the type metadata of every dependency an application references, which is work every Release build paid for.
Changed
Cratis.Arc.Corewhen discovering declared response value handlers, instead of every managed dependency of the applicationFixed
Cratis.Arc.Coreis loaded while resolving handler declarations outside the current project graph