Skip to content

Commit 752dba3

Browse files
authored
Add [DebuggerDisplay] to AnalyzerResult (Buildalyzer#283)
1 parent 3b28375 commit 752dba3

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/Buildalyzer/AnalyzerResult.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Buildalyzer;
66

7+
[DebuggerDisplay("{DebuggerDisplay}")]
78
public class AnalyzerResult : IAnalyzerResult
89
{
910
private readonly Dictionary<string, string> _properties = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
@@ -91,6 +92,41 @@ public string GetProperty(string name) =>
9192
? items.Distinct(new ProjectItemItemSpecEqualityComparer()).ToDictionary(x => x.ItemSpec, x => x.Metadata)
9293
: [];
9394

95+
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
96+
private string DebuggerDisplay
97+
{
98+
get
99+
{
100+
var sb = new StringBuilder();
101+
102+
sb
103+
.Append(Path.GetFileName(ProjectFilePath))
104+
.Append($", TFM = {TargetFramework}")
105+
.Append($", Properties = {Properties.Count}")
106+
.Append($", Items = {Items.Count}")
107+
.Append($", Source Files = {SourceFiles.Length}");
108+
109+
if (!Succeeded)
110+
{
111+
sb.Append(", Succeeded = false");
112+
}
113+
114+
if (ProjectReferences.Any())
115+
{
116+
sb.Append($", Project References = {ProjectReferences.Count()}");
117+
}
118+
if (AdditionalFiles is { Length: > 0 } af)
119+
{
120+
sb.Append($", Additional Files = {af.Length}");
121+
}
122+
if (PackageReferences is { Count: > 0 } pr)
123+
{
124+
sb.Append($", Package References = {pr.Count}");
125+
}
126+
return sb.ToString();
127+
}
128+
}
129+
94130
internal void ProcessProject(PropertiesAndItems propertiesAndItems)
95131
{
96132
// Add properties

0 commit comments

Comments
 (0)