Skip to content

fix: ignore assemblies where GetTypes() throws an exception#628

Merged
vbreuss merged 3 commits intomainfrom
topic/catch-assembly-notloading-types
May 26, 2025
Merged

fix: ignore assemblies where GetTypes() throws an exception#628
vbreuss merged 3 commits intomainfrom
topic/catch-assembly-notloading-types

Conversation

@vbreuss
Copy link
Copy Markdown
Member

@vbreuss vbreuss commented May 26, 2025

This PR modifies framework detection to skip assemblies that throw a ReflectionTypeLoadException and updates the fallback behavior to return null when no adapter is found.

Changed DetectFramework signature to return nullable and updated its fallback from a concrete adapter to null
Wrapped the assembly scanning loop in a try/catch to ignore ReflectionTypeLoadException
Updated the unit test to expect null instead of the fallback adapter

@vbreuss vbreuss self-assigned this May 26, 2025
Copilot AI review requested due to automatic review settings May 26, 2025 08:58
@vbreuss vbreuss added the bug Something isn't working label May 26, 2025

This comment was marked as outdated.

@vbreuss vbreuss enabled auto-merge (squash) May 26, 2025 08:59
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 26, 2025

Test Results

    14 files   - 24      14 suites   - 24   2m 5s ⏱️ -30s
11 512 tests  - 26  11 510 ✅  - 26  2 💤 ±0  0 ❌ ±0 
31 581 runs   - 72  31 579 ✅  - 72  2 💤 ±0  0 ❌ ±0 

Results for commit a8d1274. ± Comparison against base commit 3b46875.

♻️ This comment has been updated with latest results.

@vbreuss vbreuss requested a review from Copilot May 26, 2025 09:13
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR modifies framework detection to skip assemblies that throw ReflectionTypeLoadException and updates the fallback behavior to return null when no adapter is found.

  • Changed DetectFramework signature to return nullable and updated its fallback from a concrete adapter to null
  • Wrapped the assembly scanning loop in a try/catch to ignore ReflectionTypeLoadException
  • Updated the unit test to expect null instead of the fallback adapter

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
Tests/aweXpect.Core.Tests/Core/Initialization/AweXpectInitializationTests.cs Updated test to assert null result instead of fallback
Source/aweXpect.Core/Core/Initialization/AweXpectInitialization.cs Made DetectFramework nullable, added exception handling, and adjusted the final fallback in Initialize()
Comments suppressed due to low confidence (1)

Tests/aweXpect.Core.Tests/Core/Initialization/AweXpectInitializationTests.cs:11

  • Add a unit test that simulates an assembly throwing ReflectionTypeLoadException to verify it is skipped and does not break the initialization sequence.
public async Task DetectFramework_WhenAllFrameworksAreNotAvailable_ShouldReturnNull()

Comment thread Source/aweXpect.Core/Core/Initialization/AweXpectInitialization.cs
Comment thread Source/aweXpect.Core/Core/Initialization/AweXpectInitialization.cs Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@vbreuss vbreuss force-pushed the topic/catch-assembly-notloading-types branch from 98b7579 to a8c334f Compare May 26, 2025 09:23
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 26, 2025

👽 Mutation Results

Mutation testing badge

aweXpect

Details
File Score Killed Survived Timeout No Coverage Ignored Compile Errors Total Detected Total Undetected Total Mutants

The final mutation score is NaN%

Coverage Thresholds: high:80 low:60 break:0

aweXpect.Core

Details
File Score Killed Survived Timeout No Coverage Ignored Compile Errors Total Detected Total Undetected Total Mutants
Core/Initialization/AweXpectInitialization.cs 62.50% 25 9 0 6 25 1 25 15 66

The final mutation score is 62.50%

Coverage Thresholds: high:80 low:60 break:0

@sonarqubecloud
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 26, 2025

🚀 Benchmark Results

Details

BenchmarkDotNet v0.14.0, Ubuntu 24.04.2 LTS (Noble Numbat)
AMD EPYC 7763, 1 CPU, 4 logical and 2 physical cores
.NET SDK 8.0.410
[Host] : .NET 8.0.16 (8.0.1625.21506), X64 RyuJIT AVX2

Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15
LaunchCount=1 WarmupCount=10

Method Mean Error StdDev Gen0 Gen1 Allocated
Bool_aweXpect 171.8 ns 2.56 ns 2.40 ns 0.0281 - 472 B
Bool_FluentAssertions 236.4 ns 1.82 ns 1.61 ns 0.0567 - 952 B
Bool_TUnit 892.6 ns 11.44 ns 10.70 ns 0.1440 - 2416 B
Equivalency_aweXpect 279,712.1 ns 2,437.09 ns 2,279.66 ns 16.6016 0.4883 284940 B
Equivalency_FluentAssertions 2,179,303.7 ns 24,111.62 ns 22,554.02 ns 273.4375 46.8750 4584416 B
Equivalency_TUnit 650,662.4 ns 2,658.79 ns 2,220.21 ns 51.7578 2.9297 866777 B
Int_GreaterThan_aweXpect 209.6 ns 1.68 ns 1.58 ns 0.0467 - 784 B
Int_GreaterThan_FluentAssertions 250.1 ns 1.94 ns 1.81 ns 0.0730 - 1224 B
Int_GreaterThan_TUnit 1,201.6 ns 5.27 ns 4.93 ns 0.1774 - 2992 B
ItemsCount_AtLeast_aweXpect 447.6 ns 3.16 ns 2.95 ns 0.0830 - 1392 B
ItemsCount_AtLeast_FluentAssertions 461.5 ns 7.12 ns 6.66 ns 0.1197 - 2008 B
ItemsCount_AtLeast_TUnit 14,587.7 ns 161.27 ns 150.86 ns 1.6327 - 27488 B
String_aweXpect 334.9 ns 1.89 ns 1.77 ns 0.0672 - 1128 B
String_FluentAssertions 451.6 ns 2.39 ns 2.00 ns 0.1292 - 2168 B
String_TUnit 1,278.0 ns 6.20 ns 5.80 ns 0.1850 - 3096 B
StringArray_aweXpect 1,295.6 ns 15.93 ns 14.90 ns 0.1602 - 2712 B
StringArray_FluentAssertions 1,287.5 ns 15.43 ns 14.43 ns 0.2480 - 4152 B
StringArray_TUnit 2,822.5 ns 8.89 ns 7.42 ns 0.2708 - 4576 B
StringArrayInAnyOrder_aweXpect 1,458.8 ns 8.32 ns 7.37 ns 0.1717 - 2872 B
StringArrayInAnyOrder_FluentAssertions 153,567.5 ns 344.23 ns 305.15 ns 3.4180 - 63787 B
StringArrayInAnyOrder_TUnit 4,738.0 ns 32.46 ns 30.37 ns 0.3967 - 6744 B

@vbreuss vbreuss disabled auto-merge May 26, 2025 09:57
@vbreuss vbreuss merged commit 9269583 into main May 26, 2025
21 of 22 checks passed
@vbreuss vbreuss deleted the topic/catch-assembly-notloading-types branch May 26, 2025 09:58
github-actions Bot added a commit that referenced this pull request May 26, 2025
github-actions Bot added a commit that referenced this pull request May 26, 2025
@github-actions
Copy link
Copy Markdown
Contributor

This is addressed in release v2.15.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working state: released The issue is released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants