Skip to content

Commit

Permalink
Update PR.
Browse files Browse the repository at this point in the history
  • Loading branch information
Corniel committed Mar 5, 2024
1 parent eddd909 commit fb61481
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 21 deletions.
14 changes: 4 additions & 10 deletions src/Buildalyzer/AnalyzerResult.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Buildalyzer.Construction;
using Buildalyzer.Logging;
using Microsoft.Build.Framework;

namespace Buildalyzer;

Expand Down Expand Up @@ -162,15 +156,15 @@ public string GetProperty(string name) =>
internal void ProcessProject(PropertiesAndItems propertiesAndItems)
{
// Add properties
foreach (DictionaryEntry entry in propertiesAndItems.Properties.ToDictionaryEntries())
foreach (var entry in propertiesAndItems.Properties)

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

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest)

([deprecated] Use RCS1264 instead) Use explicit type instead of 'var' (https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1009)

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

View workflow job for this annotation

GitHub Actions / Build (macos-latest)

([deprecated] Use RCS1264 instead) Use explicit type instead of 'var' (https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1009)
{
_properties[entry.Key.ToString()] = entry.Value.ToString();
_properties[entry.Key] = entry.StringValue;
}

// Add items
foreach (IGrouping<string, DictionaryEntry> itemGroup in propertiesAndItems.Items.ToDictionaryEntries().GroupBy(x => x.Key.ToString()))
foreach (var items in propertiesAndItems.Items)

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

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest)

([deprecated] Use RCS1264 instead) Use explicit type instead of 'var' (https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1009)

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

View workflow job for this annotation

GitHub Actions / Build (macos-latest)

([deprecated] Use RCS1264 instead) Use explicit type instead of 'var' (https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1009)
{
_items[itemGroup.Key] = itemGroup.Select(x => new ProjectItem((ITaskItem)x.Value)).ToArray();
_items[items.Key] = items.Values.Select(task => new ProjectItem(task)).ToArray();
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Buildalyzer/Compiler/CompilerProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public sealed class CompilerProperties : IReadOnlyCollection<CompilerProperty>
#pragma warning restore CA1710 // Identifiers should have correct suffix
{
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private readonly Dictionary<string, object> _values = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
private readonly Dictionary<string, object> _values = new(StringComparer.OrdinalIgnoreCase);

private CompilerProperties()
{
Expand Down
18 changes: 8 additions & 10 deletions src/Buildalyzer/Logging/EventProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ private void StatusEventRaised(object sender, BuildStatusEventArgs e)
{
_evalulationResults[slEv.BuildEventContext.EvaluationId] = new PropertiesAndItems
{
Properties = slEv.Properties,
Items = slEv.Items
Properties = CompilerProperties.FromDictionaryEntries(slEv.Properties),
Items = CompilerItemsCollection.FromDictionaryEntries(slEv.Items),
};
}
}
Expand All @@ -94,17 +94,15 @@ private void ProjectStarted(object sender, ProjectStartedEventArgs e)
: null)
: new PropertiesAndItems
{
Properties = e.Properties,
Items = e.Items
Properties = CompilerProperties.FromDictionaryEntries(e.Properties),
Items = CompilerItemsCollection.FromDictionaryEntries(e.Items),
};

// Get the TFM for this project
string tfm = propertiesAndItems
?.Properties
?.ToDictionaryEntries()
.FirstOrDefault(x => string.Equals(x.Key.ToString(), "TargetFrameworkMoniker", StringComparison.OrdinalIgnoreCase))
.Value
?.ToString() ?? string.Empty; // use an empty string if no target framework was found, for example in case of C++ projects with VS >= 2022
// use an empty string if no target framework was found, for example in case of C++ projects with VS >= 2022
var tfm = propertiesAndItems?.Properties.TryGet("TargetFrameworkMoniker")?.StringValue

Check warning on line 103 in src/Buildalyzer/Logging/EventProcessor.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest)

([deprecated] Use RCS1264 instead) Use explicit type instead of 'var' (https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1008)

Check warning on line 103 in src/Buildalyzer/Logging/EventProcessor.cs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest)

([deprecated] Use RCS1264 instead) Use explicit type instead of 'var' (https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1008)

Check warning on line 103 in src/Buildalyzer/Logging/EventProcessor.cs

View workflow job for this annotation

GitHub Actions / Build (macos-latest)

([deprecated] Use RCS1264 instead) Use explicit type instead of 'var' (https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1008)
?? string.Empty;

if (propertiesAndItems != null && propertiesAndItems.Properties != null && propertiesAndItems.Items != null)
{
if (!_results.TryGetValue(tfm, out AnalyzerResult result))
Expand Down
1 change: 1 addition & 0 deletions src/Buildalyzer/Properties/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
global using System;
global using System.Collections;
global using System.Collections.Generic;
global using System.Collections.Immutable;
global using System.Diagnostics;
Expand Down

0 comments on commit fb61481

Please sign in to comment.