---
src/Build/BackEnd/BuildManager/BuildManager.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Build/BackEnd/BuildManager/BuildManager.cs b/src/Build/BackEnd/BuildManager/BuildManager.cs
index add133142c2..7cc9da07664 100644
--- a/src/Build/BackEnd/BuildManager/BuildManager.cs
+++ b/src/Build/BackEnd/BuildManager/BuildManager.cs
@@ -1259,7 +1259,7 @@ private ProjectCacheService GetProjectCacheService()
private void AutomaticallyDetectAndInstantiateProjectCacheServiceForVisualStudio()
{
if (BuildEnvironmentHelper.Instance.RunningInVisualStudio &&
- ProjectCacheItems.IsEmpty &&
+ !ProjectCacheItems.IsEmpty &&
_projectCacheService == null &&
_buildParameters.ProjectCacheDescriptor == null)
{
From 14e50befa9ec0360edbac856a8251734c07f73bb Mon Sep 17 00:00:00 2001
From: elachlan <2433737+elachlan@users.noreply.github.com>
Date: Sat, 8 Jan 2022 14:52:50 +1000
Subject: [PATCH 4/9] Revert CodeAnalysis.ruleset
---
eng/CodeAnalysis.ruleset | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/eng/CodeAnalysis.ruleset b/eng/CodeAnalysis.ruleset
index 11e924e10ca..2078c42fe6c 100644
--- a/eng/CodeAnalysis.ruleset
+++ b/eng/CodeAnalysis.ruleset
@@ -106,7 +106,7 @@
-
+
From bb127270f01a449f1fdc85485ba0811a173edea0 Mon Sep 17 00:00:00 2001
From: elachlan <2433737+elachlan@users.noreply.github.com>
Date: Sat, 8 Jan 2022 14:53:47 +1000
Subject: [PATCH 5/9] enable warning on CA1836
---
eng/Common.globalconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/eng/Common.globalconfig b/eng/Common.globalconfig
index fd878420d57..bca53055002 100644
--- a/eng/Common.globalconfig
+++ b/eng/Common.globalconfig
@@ -313,7 +313,7 @@ dotnet_diagnostic.CA1834.severity = suggestion
dotnet_diagnostic.CA1835.severity = suggestion
# Prefer IsEmpty over Count
-dotnet_diagnostic.CA1836.severity = suggestion
+dotnet_diagnostic.CA1836.severity = warning
# Use 'Environment.ProcessId'
dotnet_diagnostic.CA1837.severity = suggestion
From ecff315122e569858c5dd77b018a3e373a30a537 Mon Sep 17 00:00:00 2001
From: elachlan <2433737+elachlan@users.noreply.github.com>
Date: Sat, 8 Jan 2022 14:57:29 +1000
Subject: [PATCH 6/9] Fix remaining occurrences of CA1836 violations
---
src/Tasks/GetSDKReferenceFiles.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Tasks/GetSDKReferenceFiles.cs b/src/Tasks/GetSDKReferenceFiles.cs
index 59f3cb155ae..0c99f76c565 100644
--- a/src/Tasks/GetSDKReferenceFiles.cs
+++ b/src/Tasks/GetSDKReferenceFiles.cs
@@ -273,7 +273,7 @@ internal bool Execute(GetAssemblyName getAssemblyName, GetAssemblyRuntimeVersion
GenerateOutputItems();
- if (_exceptions.Count > 0 && LogCacheFileExceptions)
+ if (!_exceptions.IsEmpty && LogCacheFileExceptions)
{
foreach (string exceptionMessage in _exceptions)
{
From 8b78e45281b63a65d879a4c0027d193d729f3a1a Mon Sep 17 00:00:00 2001
From: elachlan <2433737+elachlan@users.noreply.github.com>
Date: Tue, 11 Jan 2022 08:48:23 +1000
Subject: [PATCH 7/9] convert !.IsEmpty to .Any()
---
src/Build/BackEnd/BuildManager/BuildManager.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Build/BackEnd/BuildManager/BuildManager.cs b/src/Build/BackEnd/BuildManager/BuildManager.cs
index 696efaa8571..370bad8dfa6 100644
--- a/src/Build/BackEnd/BuildManager/BuildManager.cs
+++ b/src/Build/BackEnd/BuildManager/BuildManager.cs
@@ -1261,7 +1261,7 @@ private ProjectCacheService GetProjectCacheService()
private void AutomaticallyDetectAndInstantiateProjectCacheServiceForVisualStudio()
{
if (BuildEnvironmentHelper.Instance.RunningInVisualStudio &&
- !ProjectCacheItems.IsEmpty &&
+ ProjectCacheItems.Any() &&
_projectCacheService == null &&
_buildParameters.ProjectCacheDescriptor == null)
{
From 69e207ebc95ef97538464470a45c80a19da654ce Mon Sep 17 00:00:00 2001
From: elachlan <2433737+elachlan@users.noreply.github.com>
Date: Tue, 11 Jan 2022 10:01:02 +1000
Subject: [PATCH 8/9] Change from code review
---
src/Build/BackEnd/BuildManager/BuildManager.cs | 2 +-
src/Tasks/GetSDKReferenceFiles.cs | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/Build/BackEnd/BuildManager/BuildManager.cs b/src/Build/BackEnd/BuildManager/BuildManager.cs
index 370bad8dfa6..c73477e11ec 100644
--- a/src/Build/BackEnd/BuildManager/BuildManager.cs
+++ b/src/Build/BackEnd/BuildManager/BuildManager.cs
@@ -1202,7 +1202,7 @@ bool ProjectCacheIsPresent()
private static bool ProjectCachePresentViaVisualStudioWorkaround()
{
- return BuildEnvironmentHelper.Instance.RunningInVisualStudio && !ProjectCacheItems.IsEmpty;
+ return BuildEnvironmentHelper.Instance.RunningInVisualStudio && ProjectCacheItems.Any();
}
// Cache requests on configuration N do not block future build submissions depending on configuration N.
diff --git a/src/Tasks/GetSDKReferenceFiles.cs b/src/Tasks/GetSDKReferenceFiles.cs
index 0c99f76c565..bb9833debda 100644
--- a/src/Tasks/GetSDKReferenceFiles.cs
+++ b/src/Tasks/GetSDKReferenceFiles.cs
@@ -273,7 +273,7 @@ internal bool Execute(GetAssemblyName getAssemblyName, GetAssemblyRuntimeVersion
GenerateOutputItems();
- if (!_exceptions.IsEmpty && LogCacheFileExceptions)
+ if (_exceptions.Any() && LogCacheFileExceptions)
{
foreach (string exceptionMessage in _exceptions)
{
From c71ba2cf4678f6528fc980954d743035e0d225fb Mon Sep 17 00:00:00 2001
From: elachlan <2433737+elachlan@users.noreply.github.com>
Date: Tue, 11 Jan 2022 10:16:57 +1000
Subject: [PATCH 9/9] Fix Additional usages of IsEmpty
---
.../BackEnd/Components/RequestBuilder/RequestBuilder.cs | 2 +-
src/Build/BackEnd/Components/RequestBuilder/TargetBuilder.cs | 5 +++--
src/Build/Evaluation/LazyItemEvaluator.RemoveOperation.cs | 4 ++--
src/Build/Logging/ProfilerLogger.cs | 2 +-
4 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/src/Build/BackEnd/Components/RequestBuilder/RequestBuilder.cs b/src/Build/BackEnd/Components/RequestBuilder/RequestBuilder.cs
index 812474cec31..467bde90af6 100644
--- a/src/Build/BackEnd/Components/RequestBuilder/RequestBuilder.cs
+++ b/src/Build/BackEnd/Components/RequestBuilder/RequestBuilder.cs
@@ -238,7 +238,7 @@ public void ContinueRequestWithResources(ResourceResponse response)
{
ErrorUtilities.VerifyThrow(HasActiveBuildRequest, "Request not building");
ErrorUtilities.VerifyThrow(!_terminateEvent.WaitOne(0), "Request already terminated");
- ErrorUtilities.VerifyThrow(!_pendingResourceRequests.IsEmpty, "No pending resource requests");
+ ErrorUtilities.VerifyThrow(_pendingResourceRequests.Any(), "No pending resource requests");
VerifyEntryInActiveOrWaitingState();
_pendingResourceRequests.Dequeue()(response);
diff --git a/src/Build/BackEnd/Components/RequestBuilder/TargetBuilder.cs b/src/Build/BackEnd/Components/RequestBuilder/TargetBuilder.cs
index da6d63a7d76..87604dfba2e 100644
--- a/src/Build/BackEnd/Components/RequestBuilder/TargetBuilder.cs
+++ b/src/Build/BackEnd/Components/RequestBuilder/TargetBuilder.cs
@@ -15,6 +15,7 @@
using ElementLocation = Microsoft.Build.Construction.ElementLocation;
using BuildAbortedException = Microsoft.Build.Exceptions.BuildAbortedException;
using TaskItem = Microsoft.Build.Execution.ProjectItemInstance.TaskItem;
+using System.Linq;
#nullable disable
@@ -405,7 +406,7 @@ private async Task ProcessTargetStack(ITaskBuilder taskBuilder)
(
!_cancellationToken.IsCancellationRequested &&
!stopProcessingStack &&
- !_targetsToBuild.IsEmpty
+ _targetsToBuild.Any()
)
{
TargetEntry currentTargetEntry = _targetsToBuild.Peek();
@@ -613,7 +614,7 @@ private void PopDependencyTargetsOnTargetFailure(TargetEntry topEntry, TargetRes
// Pop down to our parent, since any other dependencies our parent had should no longer
// execute. If we encounter an error target on the way down, also stop since the failure
// of one error target in a set declared in OnError should not cause the others to stop running.
- while ((!_targetsToBuild.IsEmpty) && (_targetsToBuild.Peek() != topEntry.ParentEntry) && !_targetsToBuild.Peek().ErrorTarget)
+ while ((_targetsToBuild.Any()) && (_targetsToBuild.Peek() != topEntry.ParentEntry) && !_targetsToBuild.Peek().ErrorTarget)
{
TargetEntry entry = _targetsToBuild.Pop();
entry.LeaveLegacyCallTargetScopes();
diff --git a/src/Build/Evaluation/LazyItemEvaluator.RemoveOperation.cs b/src/Build/Evaluation/LazyItemEvaluator.RemoveOperation.cs
index 7d1e2679c7d..b742bb23311 100644
--- a/src/Build/Evaluation/LazyItemEvaluator.RemoveOperation.cs
+++ b/src/Build/Evaluation/LazyItemEvaluator.RemoveOperation.cs
@@ -30,7 +30,7 @@ public RemoveOperation(RemoveOperationBuilder builder, LazyItemEvaluator(builder.MatchOnMetadataOptions, _matchOnMetadata, _itemSpec);
}
@@ -49,7 +49,7 @@ protected override void ApplyImpl(OrderedItemDataCollection.Builder listBuilder,
return;
}
- bool matchingOnMetadata = !_matchOnMetadata.IsEmpty;
+ bool matchingOnMetadata = _matchOnMetadata.Any();
if (!matchingOnMetadata)
{
if (ItemspecContainsASingleBareItemReference(_itemSpec, _itemElement.ItemType))
diff --git a/src/Build/Logging/ProfilerLogger.cs b/src/Build/Logging/ProfilerLogger.cs
index ac43bd7f3fb..a2338b8f051 100644
--- a/src/Build/Logging/ProfilerLogger.cs
+++ b/src/Build/Logging/ProfilerLogger.cs
@@ -134,7 +134,7 @@ internal ProfilerResult GetAggregatedResult(bool pruneSmallItems = true)
// So keeping that map here
var originalLocations = new Dictionary(EvaluationLocationIdAgnosticComparer.Singleton);
- while (!_profiledResults.IsEmpty)
+ while (_profiledResults.Any())
{
ProfilerResult profiledResult;
var result = _profiledResults.TryDequeue(out profiledResult);