Add tests for assembly resolution downgrading via extension mechanisms#118040
Merged
elinor-fung merged 7 commits intomainfrom Aug 6, 2025
Merged
Add tests for assembly resolution downgrading via extension mechanisms#118040elinor-fung merged 7 commits intomainfrom
elinor-fung merged 7 commits intomainfrom
Conversation
Co-authored-by: elinor-fung <47805090+elinor-fung@users.noreply.github.com>
Co-authored-by: elinor-fung <47805090+elinor-fung@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add tests for downgrading assembly resolution via resolution extensions
Add tests for assembly resolution downgrading via extension mechanisms
Jul 24, 2025
This was referenced Jul 25, 2025
elinor-fung
reviewed
Jul 25, 2025
…rivate Co-authored-by: elinor-fung <47805090+elinor-fung@users.noreply.github.com>
elinor-fung
reviewed
Jul 25, 2025
Co-authored-by: elinor-fung <47805090+elinor-fung@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds comprehensive tests to validate that assembly resolution extension mechanisms can successfully downgrade assembly version requests from higher to lower versions, while normal runtime resolution cannot perform such downgrades.
Key changes:
- Creates test infrastructure with two test assemblies having the same name but different versions (1.0.0 and 3.0.0)
- Adds test methods validating downgrade behavior across three extension mechanisms: AppDomain.AssemblyResolve, AssemblyLoadContext.Resolving, and custom AssemblyLoadContext.Load override
- Includes platform-specific testing for normal resolution behavior differences between CoreCLR and Mono
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| System.Runtime.Loader.Tests.csproj | Adds the new test class and references to the version test assemblies as embedded resources |
| AssemblyResolutionDowngradeTest.cs | Main test class with four test methods validating downgrade scenarios and helper classes |
| System.Runtime.Loader.Test.AssemblyVersion1.csproj | Test assembly project configured for version 1.0.0 with shared assembly name |
| VersionTestClass.cs (Version1) | Test class providing version identification methods for the 1.0.0 assembly |
| System.Runtime.Loader.Test.AssemblyVersion3.csproj | Test assembly project configured for version 3.0.0 with shared assembly name |
| VersionTestClass.cs (Version3) | Test class providing version identification methods for the 3.0.0 assembly |
elinor-fung
reviewed
Jul 28, 2025
Co-authored-by: elinor-fung <47805090+elinor-fung@users.noreply.github.com>
AaronRobinsonMSFT
approved these changes
Aug 5, 2025
elinor-fung
reviewed
Aug 5, 2025
…r.Test.AssemblyVersion1/VersionTestClass.cs
AaronRobinsonMSFT
approved these changes
Aug 5, 2025
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
This PR adds comprehensive tests to validate that assembly resolution extension mechanisms can successfully downgrade assembly version requests, while normal runtime resolution cannot.
cc @dotnet/appmodel @AaronRobinsonMSFT
What was missing
The .NET runtime supports assembly version downgrading (resolving a request for
A, Version=3.0withA, Version=1.0) but only through extension mechanisms:AppDomain.AssemblyResolveevent handlerAssemblyLoadContext.Resolvingevent handlerAssemblyLoadContext.LoadoverrideHowever, there were no tests specifically validating this downgrading behavior.
What this PR adds
New test assemblies:
System.Runtime.Loader.Test.AssemblyVersion1- produces assembly with version 1.0.0New test class
AssemblyResolutionDowngradeTestwith 4 test methods:AppDomainAssemblyResolve_CanDowngradeVersion- Validates thatAppDomain.AssemblyResolvecan resolve a version 3.0.0 request with version 1.0.0 assemblyAssemblyLoadContextResolving_CanDowngradeVersion- Validates thatAssemblyLoadContext.Resolvingevent can perform the same downgradeCustomAssemblyLoadContextLoad_CanDowngradeVersion- Validates that customAssemblyLoadContext.Loadoverride can perform downgradesNormalResolution_CannotDowngradeVersion- Validates baseline behavior that normal runtime resolution cannot downgrade versionsTest approach
Each test:
System.Runtime.Loader.Test.VersionDowngrade, Version=3.0.0.0The tests use
RemoteExecutorto isolate assembly loading behavior and prevent interference between test runs.Fixes #84039.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.