Repository navigation
Apply the version rule to the resource fallback (fixes CI on #76) - #77
Merged
Conversation
…urce once With s_assembliesWithResources populated, the resource fallback runs, and it had two problems that the lookup above it does not: - It returned whatever it extracted, regardless of version: a request for 2.0.0.0 got the 1.0.0.0 copy. That is what fails Request_For_A_Newer_Version_Does_Not_Resolve_To_An_Older_One in CI. - Assembly.Load(byte[]) loads a new copy on every call and none unloads, so every unsatisfied request added another copy of an assembly that was already loaded. The fallback now skips a copy that does not satisfy the request (same Satisfies rule as the lookup), and a resource is unpacked at most once, whether by AddAssembly or by the fallback (s_extractedResources). Also removes the unused 'alreadyLoaded' local (CS0168). Tests: an unsatisfied request does not load the assembly again; the fallback unpacks a resource AddAssembly has not reached yet (the window another generator initialising on another thread can hit), and does not hand back an older version from there. Each fails with its guard removed. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
ByronMayne
merged commit Oct 4, 2026
ea49e0c
into
ByronMayne:75-resolvemissingassembly-fallback-ineffective-because-s_assemblieswithresources-was-never-populated
4 checks passed
This was referenced Oct 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Targets the branch of #76, so merging this makes #76 green.
Why #76 fails CI
Populating
s_assembliesWithResourcesbrings the resource fallback inResolveMissingAssemblyto life. That fallback returns whatever it extracts, with no version check. SoRequest_For_A_Newer_Version_Does_Not_Resolve_To_An_Older_One(from #74) now gets the 1.0.0.0 copy for a 2.0.0.0 request:There is a second problem behind it:
Assembly.Load(byte[])loads a new copy on every call, and none of them unload. Each unsatisfied request adds another copy of an assembly that is already loaded. In a compiler server that lives for hours, that is a slow leak plus duplicate type identities.Change
Satisfies: same name, at least the requested version). A copy that does not satisfy the request is still registered, but not returned.AddAssemblyor by the fallback, whichever comes first (s_extractedResources, under the existings_assembliesWithResourcesLock).alreadyLoadedlocal is removed (CS0168 in the generated hoist; it shows up as a warning in every consumer's build).The fallback still does what #75 asks for: it reaches a resource that
AddAssemblyhas not unpacked yet. That can happen while another generator initialises on another thread, betweens_assembliesWithResources.Addand the extract loop.Tests
This also covers the Copilot note on #76: nothing exercised the fallback.
Request_For_A_Newer_Version_Does_Not_Resolve_To_An_Older_One(existing)Unsatisfied_Request_Does_Not_Load_The_Embedded_Assembly_AgainResource_Fallback_Unpacks_An_Embedded_Assembly_Not_Unpacked_YetResource_Fallback_Does_Not_Resolve_To_An_Older_VersionThe last two put the resolver in that window: they forget that one resource was unpacked, so only the fallback can reach it. Each guard was removed once to confirm its test fails:
Resource_Fallback_Does_Not_Resolve_To_An_Older_Versionfails;Unsatisfied_Request_…fails;s_assembliesWithResources.Addremoved (the state on master) →Resource_Fallback_Unpacks_…fails.Locally, Release as in CI (.NET SDK 10.0.300): Sandbox tests 11/11,
SourceGenerator.Foundations.Tests3/3 (net6.0, rolled forward to 8.0), 0 warnings.🤖 Generated with Claude Code