Skip to content

Commit c2de3bb

Browse files
committed
Fix TypeLoadException warnings and empty Breaking Changes section
- 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
1 parent eccf9c6 commit c2de3bb

File tree

3 files changed

+42
-5
lines changed

3 files changed

+42
-5
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,5 @@ node_modules/
9292

9393
# Local History for Visual Studio
9494
.localhistory/test-report/
95+
96+
glide-testing/

src/DotNetApiDiff/ApiExtraction/TypeAnalyzer.cs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -541,9 +541,9 @@ private List<string> GetTypeAttributes(Type type)
541541
{
542542
try
543543
{
544-
return type.GetCustomAttributes(true)
544+
return type.GetCustomAttributesData()
545545
.Where(a => !IsCompilerGeneratedAttribute(a))
546-
.Select(a => a.GetType().Name)
546+
.Select(a => a.AttributeType.Name)
547547
.ToList();
548548
}
549549
catch (Exception ex)
@@ -562,9 +562,9 @@ private List<string> GetMemberAttributes(MemberInfo member)
562562
{
563563
try
564564
{
565-
return member.GetCustomAttributes(true)
565+
return member.GetCustomAttributesData()
566566
.Where(a => !IsCompilerGeneratedAttribute(a))
567-
.Select(a => a.GetType().Name)
567+
.Select(a => a.AttributeType.Name)
568568
.ToList();
569569
}
570570
catch (Exception ex)
@@ -587,6 +587,19 @@ private bool IsCompilerGeneratedAttribute(object attribute)
587587
typeName == "DebuggerNonUserCodeAttribute";
588588
}
589589

590+
/// <summary>
591+
/// Checks if an attribute is compiler-generated
592+
/// </summary>
593+
/// <param name="attributeData">Attribute data to check</param>
594+
/// <returns>True if compiler-generated, false otherwise</returns>
595+
private bool IsCompilerGeneratedAttribute(CustomAttributeData attributeData)
596+
{
597+
var typeName = attributeData.AttributeType.Name;
598+
return typeName == "CompilerGeneratedAttribute" ||
599+
typeName == "DebuggerHiddenAttribute" ||
600+
typeName == "DebuggerNonUserCodeAttribute";
601+
}
602+
590603
/// <summary>
591604
/// Checks if a method is public or an override of a public method
592605
/// </summary>

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

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,29 @@
9696
<div class="alert alert-danger">
9797
<strong>Warning:</strong> The following changes may break compatibility with existing code.
9898
</div>
99-
{{ include "breaking-changes" result.breaking_changes }}
99+
<!-- Breaking changes content directly inline for debugging -->
100+
<div class="breaking-changes-table">
101+
<table>
102+
<thead>
103+
<tr>
104+
<th>Severity</th>
105+
<th>Type</th>
106+
<th>Element</th>
107+
<th>Description</th>
108+
</tr>
109+
</thead>
110+
<tbody>
111+
{{for change in result.breaking_changes}}
112+
<tr>
113+
<td><span class="severity {{ change.severity_class }}">{{ change.severity }}</span></td>
114+
<td>{{ change.element_type }}</td>
115+
<td><code>{{ change.element_name }}</code></td>
116+
<td>{{ change.description }}</td>
117+
</tr>
118+
{{end}}
119+
</tbody>
120+
</table>
121+
</div>
100122
</section>
101123
{{end}}
102124

0 commit comments

Comments
 (0)