Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add [DebuggerDisplay] to AnalyzerResult #283

Merged
merged 1 commit into from
Aug 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion src/Buildalyzer/AnalyzerResult.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System.Collections;
using System.IO;
using Buildalyzer.Construction;
using Buildalyzer.Logging;

namespace Buildalyzer;

[DebuggerDisplay("{DebuggerDisplay}")]
public class AnalyzerResult : IAnalyzerResult
{
private readonly Dictionary<string, string> _properties = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
Expand Down Expand Up @@ -92,6 +92,41 @@
? items.Distinct(new ProjectItemItemSpecEqualityComparer()).ToDictionary(x => x.ItemSpec, x => x.Metadata)
: [];

[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private string DebuggerDisplay
{
get
{
var sb = new StringBuilder();

sb
.Append(Path.GetFileName(ProjectFilePath))
.Append($", TFM = {TargetFramework}")
.Append($", Properties = {Properties.Count}")
.Append($", Items = {Items.Count}")
.Append($", Source Files = {SourceFiles.Length}");

if (!Succeeded)
{
sb.Append(", Succeeded = false");
}

if (ProjectReferences.Any())
{
sb.Append($", Project References = {ProjectReferences.Count()}");
}
if (AdditionalFiles is { Length: > 0 } af)
{
sb.Append($", Additional Files = {af.Length}");
}
if (PackageReferences is { Count: > 0 } pr)
{
sb.Append($", Package References = {pr.Count}");
}
return sb.ToString();
}
}

internal void ProcessProject(PropertiesAndItems propertiesAndItems)
{
// Add properties
Expand Down Expand Up @@ -129,7 +164,7 @@

private class ProjectItemItemSpecEqualityComparer : IEqualityComparer<IProjectItem>
{
public bool Equals(IProjectItem x, IProjectItem y) => x.ItemSpec.Equals(y.ItemSpec, StringComparison.OrdinalIgnoreCase);

Check warning on line 167 in src/Buildalyzer/AnalyzerResult.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest)

Nullability of reference types in type of parameter 'x' of 'bool ProjectItemItemSpecEqualityComparer.Equals(IProjectItem x, IProjectItem y)' doesn't match implicitly implemented member 'bool IEqualityComparer<IProjectItem>.Equals(IProjectItem? x, IProjectItem? y)' (possibly because of nullability attributes).

Check warning on line 167 in src/Buildalyzer/AnalyzerResult.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest)

Nullability of reference types in type of parameter 'y' of 'bool ProjectItemItemSpecEqualityComparer.Equals(IProjectItem x, IProjectItem y)' doesn't match implicitly implemented member 'bool IEqualityComparer<IProjectItem>.Equals(IProjectItem? x, IProjectItem? y)' (possibly because of nullability attributes).

Check warning on line 167 in src/Buildalyzer/AnalyzerResult.cs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest)

Nullability of reference types in type of parameter 'x' of 'bool ProjectItemItemSpecEqualityComparer.Equals(IProjectItem x, IProjectItem y)' doesn't match implicitly implemented member 'bool IEqualityComparer<IProjectItem>.Equals(IProjectItem? x, IProjectItem? y)' (possibly because of nullability attributes).

Check warning on line 167 in src/Buildalyzer/AnalyzerResult.cs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest)

Nullability of reference types in type of parameter 'y' of 'bool ProjectItemItemSpecEqualityComparer.Equals(IProjectItem x, IProjectItem y)' doesn't match implicitly implemented member 'bool IEqualityComparer<IProjectItem>.Equals(IProjectItem? x, IProjectItem? y)' (possibly because of nullability attributes).

Check warning on line 167 in src/Buildalyzer/AnalyzerResult.cs

View workflow job for this annotation

GitHub Actions / Build (macos-12)

Nullability of reference types in type of parameter 'x' of 'bool ProjectItemItemSpecEqualityComparer.Equals(IProjectItem x, IProjectItem y)' doesn't match implicitly implemented member 'bool IEqualityComparer<IProjectItem>.Equals(IProjectItem? x, IProjectItem? y)' (possibly because of nullability attributes).

Check warning on line 167 in src/Buildalyzer/AnalyzerResult.cs

View workflow job for this annotation

GitHub Actions / Build (macos-12)

Nullability of reference types in type of parameter 'y' of 'bool ProjectItemItemSpecEqualityComparer.Equals(IProjectItem x, IProjectItem y)' doesn't match implicitly implemented member 'bool IEqualityComparer<IProjectItem>.Equals(IProjectItem? x, IProjectItem? y)' (possibly because of nullability attributes).

public int GetHashCode(IProjectItem obj) => obj.ItemSpec.ToLowerInvariant().GetHashCode();
}
Expand Down
Loading