fix: Assembly reading exception handling. Implement AssemblyUtils for type retrieval, refactor TypeUtils to utilize AssemblyUtils#51
Conversation
…r TypeUtils to utilize AssemblyUtils
…l loaded assemblies and update related tests
…ing methods in TypeUtils
…nvalidation checks
There was a problem hiding this comment.
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
AssemblyUtilsclass with exception-safe assembly and type enumeration - Refactored
TypeUtils.AllTypesto delegate toAssemblyUtils.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.
There was a problem hiding this comment.
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.
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
TypeUtilsclass. The core logic for discovering types has been moved fromTypeUtilsto a newAssemblyUtilsclass, which handles exceptions more gracefully. Additionally, many new XML documentation comments and utility methods have been added toTypeUtilsto improve usability and maintainability.Key changes include:
Robust Assembly and Type Enumeration
AssemblyUtilsclass that provides exception-safe enumeration of all loaded assemblies and types, replacing the previous approach inTypeUtils. This ensures that type discovery is resilient to partial loads and problematic assemblies.Reflector.FindMethodandTypeUtilsto useAssemblyUtils.AllTypesfor safer reflection. [1] [2] [3] [4] [5]Enhanced Type Utilities and Documentation
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]TypeUtilsfor 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
Version Update
3.3.1to3.4.0to reflect these enhancements.