Skip to content

fix: handle unresolvable assemblies during type loading - #502

Open
mak638 wants to merge 1 commit into
mainfrom
fix/handle-unresolvable-assemblies
Open

mak638 wants to merge 1 commit into
mainfrom
fix/handle-unresolvable-assemblies

Conversation

@mak638

@mak638 mak638 commented Sep 28, 2026

Copy link
Copy Markdown
Collaborator

Fixes #497

DotNetCoreAssemblyResolver.AddLib previously fell back to DefaultAssemblyResolver when an assembly couldn't be found. Since DefaultAssemblyResolver loads assemblies with itself as the resolver, later TypeReference.Resolve() calls threw AssemblyResolutionException instead of returning null.

The fallback now passes the original ReaderParameters so loaded assemblies keep using DotNetCoreAssemblyResolver. All .Resolve() call sites that didn't catch AssemblyResolutionException are switched to TryResolve helpers that return null on failure.

DotNetCoreAssemblyResolver.AddLib previously fell back to
DefaultAssemblyResolver when an assembly couldn't be found. Since
DefaultAssemblyResolver loads assemblies with itself as the resolver,
later TypeReference.Resolve() calls threw AssemblyResolutionException
instead of returning null.

The fallback now passes the original ReaderParameters so loaded
assemblies keep using DotNetCoreAssemblyResolver. All .Resolve() call
sites that didn't catch AssemblyResolutionException are switched to
TryResolve helpers that return null on failure.

Signed-off-by: Malte Kunath <malte.kunath@tngtech.com>
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 61.64384% with 28 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.20%. Comparing base (dcf76a3) to head (8475c94).

Files with missing lines Patch % Lines
ArchUnitNET/Loader/MonoCecilResolveExtensions.cs 45.00% 20 Missing and 2 partials ⚠️
ArchUnitNET/Loader/DotNetCoreAssemblyResolver.cs 76.19% 4 Missing and 1 partial ⚠️
ArchUnitNET/Loader/InstructionExtensions.cs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #502      +/-   ##
==========================================
- Coverage   86.33%   86.20%   -0.14%     
==========================================
  Files         260      261       +1     
  Lines       12496    12543      +47     
  Branches     1216     1221       +5     
==========================================
+ Hits        10789    10813      +24     
- Misses       1372     1392      +20     
- Partials      335      338       +3     

☔ 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.

This branch has not been deployed

No deployments
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.

[Bug]: Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'mscorlib, Version=4.0.0.0

2 participants