Skip to content

fix: Assembly reading exception handling. Implement AssemblyUtils for type retrieval, refactor TypeUtils to utilize AssemblyUtils#51

Merged
IvanMurzak merged 11 commits intomainfrom
fix/exception-handling-for-optional-dlls
Jan 8, 2026
Merged

fix: Assembly reading exception handling. Implement AssemblyUtils for type retrieval, refactor TypeUtils to utilize AssemblyUtils#51
IvanMurzak merged 11 commits intomainfrom
fix/exception-handling-for-optional-dlls

Conversation

@IvanMurzak
Copy link
Copy Markdown
Owner

@IvanMurzak IvanMurzak commented Jan 8, 2026

This pull request introduces significant improvements to the reflection utilities in ReflectorNet, focusing on safer and more robust enumeration of assemblies and types, as well as greatly enhancing the documentation and introspection capabilities of the TypeUtils class. The core logic for discovering types has been moved from TypeUtils to a new AssemblyUtils class, which handles exceptions more gracefully. Additionally, many new XML documentation comments and utility methods have been added to TypeUtils to improve usability and maintainability.

Key changes include:

Robust Assembly and Type Enumeration

  • Introduced a new AssemblyUtils class that provides exception-safe enumeration of all loaded assemblies and types, replacing the previous approach in TypeUtils. This ensures that type discovery is resilient to partial loads and problematic assemblies.
  • Updated all usages of type enumeration in Reflector.FindMethod and TypeUtils to use AssemblyUtils.AllTypes for safer reflection. [1] [2] [3] [4] [5]

Enhanced Type Utilities and Documentation

  • Added comprehensive XML documentation comments to all major methods in TypeUtils, clarifying their usage and behavior for future maintainers and users. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14]
  • Introduced new utility methods in TypeUtils for clearing the type cache, checking if a type is castable, determining inheritance distance, checking for primitive types, and recursively extracting generic type arguments. [1] [2] [3] [4] [5]

Description Extraction Improvements

  • Expanded and documented methods for extracting descriptions from types, members, parameters, fields, and properties, including overloads for JSON schema exporter contexts and by name. This improves support for generating documentation and schema metadata. [1] [2] [3] [4] [5] [6] [7]

Version Update

  • Bumped the NuGet package version from 3.3.1 to 3.4.0 to reflect these enhancements.

@IvanMurzak IvanMurzak self-assigned this Jan 8, 2026
@IvanMurzak IvanMurzak added bug Something isn't working enhancement New feature or request labels Jan 8, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 8, 2026

Test Results

    2 files  ± 0      2 suites  ±0   3m 13s ⏱️ +4s
1 067 tests +34  1 067 ✅ +34  0 💤 ±0  0 ❌ ±0 
2 134 runs  +68  2 134 ✅ +68  0 💤 ±0  0 ❌ ±0 

Results for commit a917985. ± Comparison against base commit 114166f.

♻️ This comment has been updated with latest results.

@IvanMurzak IvanMurzak requested a review from Copilot January 8, 2026 09:41
@IvanMurzak IvanMurzak changed the title feat: Implement AssemblyUtils for type retrieval and caching, refactor TypeUtils to utilize AssemblyUtils fix: Assembly reading exception handling. Implement AssemblyUtils for type retrieval, refactor TypeUtils to utilize AssemblyUtils Jan 8, 2026
Copy link
Copy Markdown
Contributor

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 pull request introduces a new AssemblyUtils utility class to centralize type enumeration across all loaded assemblies with improved exception handling. The refactoring updates TypeUtils.AllTypes to delegate to AssemblyUtils.AllTypes, and all direct usages are migrated to use the new utility. Comprehensive test coverage is added for the new functionality.

Key changes:

  • New AssemblyUtils class with exception-safe assembly and type enumeration
  • Refactored TypeUtils.AllTypes to delegate to AssemblyUtils.AllTypes
  • Added extensive documentation for existing TypeUtils methods
  • Version bump from 3.3.1 to 3.4.0

Reviewed changes

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

Show a summary per file
File Description
ReflectorNet/src/Utils/AssemblyUtils.cs New utility class providing exception-safe enumeration of assemblies and types with AllAssemblies, AllTypes, and GetAssemblyTypes methods
ReflectorNet/src/Utils/TypeUtils.cs Delegates AllTypes to AssemblyUtils, adds ClearTypeCache() method, and enhances documentation for multiple existing methods
ReflectorNet/src/Reflector/Reflector.FindMethod.cs Updates AllMethods and FindMethod to use AssemblyUtils.AllTypes instead of TypeUtils.AllTypes
ReflectorNet/ReflectorNet.csproj Version bump to 3.4.0 reflecting the feature addition
ReflectorNet.Tests/src/Utils/AssemblyUtilsTests.cs Comprehensive test suite with 30+ tests covering basic functionality, thread safety, and edge cases

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ReflectorNet/src/Utils/AssemblyUtils.cs
Comment thread ReflectorNet/src/Utils/AssemblyUtils.cs Outdated
Comment thread ReflectorNet.Tests/src/Utils/AssemblyUtilsTests.cs Outdated
Comment thread ReflectorNet/src/Utils/AssemblyUtils.cs
Comment thread ReflectorNet/src/Utils/AssemblyUtils.cs
Comment thread ReflectorNet.Tests/src/Utils/AssemblyUtilsTests.cs Outdated
Copy link
Copy Markdown
Contributor

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

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


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ReflectorNet.Tests/src/Utils/AssemblyUtilsTests.cs
Comment thread ReflectorNet/src/Utils/TypeUtils.cs
@IvanMurzak IvanMurzak merged commit f5ab41d into main Jan 8, 2026
1 check passed
@IvanMurzak IvanMurzak deleted the fix/exception-handling-for-optional-dlls branch January 8, 2026 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants