Skip to content

Conversation

@jbrinkman
Copy link
Owner

Overview

This PR fixes two issues related to API analysis and HTML report generation:

  1. TypeLoadException warnings when analyzing assemblies with missing attribute dependencies (Fix TypeLoadException when analyzing assemblies with missing attribute dependencies #25)
  2. Empty Breaking Changes section in HTML reports despite correct detection and counting (Fix empty Breaking Changes section in HTML reports #26)

Changes Made

🔧 Fix TypeLoadException in TypeAnalyzer (#25)

Problem: When analyzing assemblies with custom attributes that reference types that cannot be loaded, the tool throws TypeLoadException warnings.

Root Cause: GetCustomAttributes(true) instantiates attribute objects, causing dependency loading issues.

Solution:

  • Replace GetCustomAttributes(true) with GetCustomAttributesData() in both GetTypeAttributes() and GetMemberAttributes() methods
  • Change attribute name extraction from a.GetType().Name to a.AttributeType.Name
  • Add IsCompilerGeneratedAttribute(CustomAttributeData) overload to work with metadata

Files Changed:

  • src/DotNetApiDiff/ApiExtraction/TypeAnalyzer.cs

🔧 Fix Empty Breaking Changes Section (#26)

Problem: HTML reports correctly detect and count breaking changes but the dedicated Breaking Changes section table remains empty.

Root Cause: Scriban template include statement {{ include "breaking-changes" result.breaking_changes }} was not properly passing data to the template.

Solution:

  • Replace problematic include statement with inline template code
  • Direct access to result.breaking_changes data in the main layout template

Files Changed:

  • src/DotNetApiDiff/Reporting/HtmlTemplates/main-layout.scriban

🧹 Minor Cleanup

  • Add glide-testing/ directory to .gitignore

Testing

TypeLoadException Fix:

  • Tested with StackExchange.Redis.dll that previously threw TypeLoadException warnings
  • No more warnings generated while maintaining full API extraction functionality
  • All 1734 API members successfully extracted

Breaking Changes Display Fix:

  • Verified with comparison showing 132 breaking changes
  • Breaking Changes section now displays all detected changes in properly formatted table
  • Table includes: Severity, Type, Element Name, and Description columns

Benefits

  • 🚫 Eliminates TypeLoadException warnings during API analysis
  • 📊 Breaking Changes section now properly displays all detected breaking changes
  • 🔄 Maintains backward compatibility and existing functionality
  • ⚡ No performance impact

Closes

- Replace GetCustomAttributes(true) with GetCustomAttributesData() in TypeAnalyzer
  to avoid instantiating attribute objects when dependencies are missing
- Add CustomAttributeData overload for IsCompilerGeneratedAttribute method
- Fix empty Breaking Changes table in HTML reports by replacing problematic
  Scriban template include with inline template code
- Add glide-testing directory to .gitignore

Fixes #25: TypeLoadException when analyzing assemblies with missing attribute dependencies
Fixes #26: Empty Breaking Changes section in HTML reports
@jbrinkman jbrinkman merged commit c2de3bb into main Jul 28, 2025
7 checks passed
@jbrinkman jbrinkman deleted the fix/attribute-loading-and-breaking-changes-display branch July 28, 2025 02:02
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.

Fix empty Breaking Changes section in HTML reports Fix TypeLoadException when analyzing assemblies with missing attribute dependencies

2 participants