Skip to content

Consolidate Assembly Loading (#r, nuget) into one AssemblyLoadContext#498

Merged
waf merged 4 commits into
mainfrom
nuget-restore-based-resolution
Jun 25, 2026
Merged

Consolidate Assembly Loading (#r, nuget) into one AssemblyLoadContext#498
waf merged 4 commits into
mainfrom
nuget-restore-based-resolution

Conversation

@waf

@waf waf commented Jun 25, 2026

Copy link
Copy Markdown
Owner

Clean up assembly loading and resolution.

  • Replace nuget resolve with the built-in NuGet.Commands.RestoreCommand.
  • Consolidate AssemblyLoadContexts - Pass all assembly loading through a new ReplAssemblyLoader class which manages a single AssemblyLoadContext. This fixes various issues that all arise from loading subtlety different versions across different contexts.

Fixes #355, #329, #184

waf added 4 commits June 22, 2026 23:34
- Nuget: Simplify restore algorithm to use NuGet.Commands.RestoreCommand. Before,
  I didn't think we could access this because it's internal, but we can
  actually get access to it via RestoreCommandProvidersCache. This
  allows us to get rid of much of our customer nuget logic.
- Pass all assembly loading through a new ReplAssemblyLoader class,
  which manages the AssemblyLoadContext. This makes sure we aren't
  loading subtley different DLL versions between roslyn scripting world and
  roslyn workspace world.
@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.89415% with 65 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.5%. Comparing base (d693e80) to head (708dc8c).

Files with missing lines Patch % Lines
CSharpRepl.Services/Nuget/NugetPackageInstaller.cs 81.2% 17 Missing and 12 partials ⚠️
...l.Services/Roslyn/References/ReplAssemblyLoader.cs 78.1% 21 Missing and 8 partials ⚠️
CSharpRepl.Services/Nuget/NugetHelper.cs 63.6% 1 Missing and 3 partials ⚠️
...vices/Roslyn/References/AssemblyLoadContextHook.cs 89.6% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main    #498     +/-   ##
=======================================
- Coverage   79.8%   79.5%   -0.3%     
=======================================
  Files        123     125      +2     
  Lines       9316    9358     +42     
  Branches    1385    1395     +10     
=======================================
+ Hits        7436    7445      +9     
- Misses      1406    1427     +21     
- Partials     474     486     +12     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@waf waf merged commit 37f9d5d into main Jun 25, 2026
3 checks passed
@waf waf deleted the nuget-restore-based-resolution branch June 25, 2026 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

How to use against a project with EF Core and Postgres?

1 participant