Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion eng/CodeAnalysis.ruleset
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
<Rule Id="CA1825" Action="Info" /> <!-- Avoid zero-length array allocations. -->
<Rule Id="CA1827" Action="Warning" /> <!-- Do not use Count() or LongCount() when Any() can be used -->
<Rule Id="CA1828" Action="Warning" /> <!-- Do not use CountAsync() or LongCountAsync() when AnyAsync() can be used -->
<Rule Id="CA1829" Action="Info" /> <!-- Use Length/Count property instead of Count() when available -->
<Rule Id="CA1829" Action="Warning" /> <!-- Use Length/Count property instead of Count() when available -->
<Rule Id="CA1830" Action="Warning" /> <!-- Prefer strongly-typed Append and Insert method overloads on StringBuilder. -->
<Rule Id="CA1831" Action="Warning" /> <!-- Use AsSpan or AsMemory instead of Range-based indexers when appropriate -->
<Rule Id="CA1832" Action="Warning" /> <!-- Use AsSpan or AsMemory instead of Range-based indexers when appropriate -->
Expand Down
4 changes: 2 additions & 2 deletions src/Build.OM.UnitTests/Definition/Project_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2284,7 +2284,7 @@ public void RemoveSeveralItemsOfVariousTypes()

project.RemoveItems(list);

project.Items.Count().ShouldBe(2);
project.Items.Count.ShouldBe(2);
}

/// <summary>
Expand All @@ -2304,7 +2304,7 @@ public void RemoveSeveralItemsExpandExpression()
Project project = new Project(XmlReader.Create(new StringReader(projectOriginalContents)));

project.RemoveItems(project.GetItems("j").Take(2));
project.Items.Count().ShouldBe(3);
project.Items.Count.ShouldBe(3);

StringWriter writer = new EncodingStringWriter();
project.Save(writer);
Expand Down
4 changes: 2 additions & 2 deletions src/Build.UnitTests/BackEnd/IntrinsicTask_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2012,7 +2012,7 @@ public void RemoveWithMatchingMultipleMetadata()
Lookup lookup = LookupHelpers.CreateEmptyLookup();
ExecuteTask(task, lookup);
ICollection<ProjectItemInstance> items = lookup.GetItems("I2");
items.Count().ShouldBe(3);
items.Count.ShouldBe(3);
items.ElementAt(0).EvaluatedInclude.ShouldBe("a2");
items.ElementAt(1).EvaluatedInclude.ShouldBe("c2");
items.ElementAt(2).EvaluatedInclude.ShouldBe("d2");
Expand Down Expand Up @@ -3478,7 +3478,7 @@ public void PhoenixBatchingIssue()
ProjectInstance instance = new ProjectInstance(xml);
instance.Build();

Assert.Equal(2, instance.Items.Count());
Assert.Equal(2, instance.Items.Count);
Assert.Equal("gen.obj", instance.GetItems("CppCompile").First().GetMetadataValue("ObjectFile"));
Assert.Equal("def.obj", instance.GetItems("CppCompile").Last().GetMetadataValue("ObjectFile"));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Build.UnitTests/BackEnd/SdkResolverService_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ private void ValidateExpectedPropertiesAndItems(bool includePropertiesAndItems,
result.PropertiesToAdd.Count.ShouldBe(1);
result.PropertiesToAdd["PropertyFromSdkResolver"].ShouldBe("ValueFromSdkResolver");

result.ItemsToAdd.Count().ShouldBe(1);
result.ItemsToAdd.Count.ShouldBe(1);
result.ItemsToAdd.Keys.Single().ShouldBe("ItemNameFromSdkResolver");
result.ItemsToAdd.Values.Single().ItemSpec.ShouldBe("ItemValueFromSdkResolver");
var metadata = result.ItemsToAdd.Values.Single().Metadata;
Expand Down
4 changes: 2 additions & 2 deletions src/Build.UnitTests/BackEnd/TaskBuilderTestTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -550,8 +550,8 @@ public TaskPropertyInfo[] GetTaskParameters()
propertyInfos[i] = new TaskPropertyInfo(
infos[i].Name,
infos[i].PropertyType,
infos[i].GetCustomAttributes(typeof(OutputAttribute), false).Count() > 0,
infos[i].GetCustomAttributes(typeof(RequiredAttribute), false).Count() > 0);
infos[i].GetCustomAttributes(typeof(OutputAttribute), false).Length > 0,
infos[i].GetCustomAttributes(typeof(RequiredAttribute), false).Length > 0);
}

return propertyInfos;
Expand Down
16 changes: 8 additions & 8 deletions src/Build.UnitTests/Evaluation/Evaluator_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1886,7 +1886,7 @@ public void AllEvaluatedItems()

Project project = new Project(XmlReader.Create(new StringReader(content)));

Assert.Equal(6, project.AllEvaluatedItems.Count());
Assert.Equal(6, project.AllEvaluatedItems.Count);
Assert.Equal("i1", project.AllEvaluatedItems.ElementAt(0).EvaluatedInclude);
Assert.Equal(String.Empty, project.AllEvaluatedItems.ElementAt(0).GetMetadataValue("m"));
Assert.Equal("j1", project.AllEvaluatedItems.ElementAt(1).EvaluatedInclude);
Expand All @@ -1902,12 +1902,12 @@ public void AllEvaluatedItems()
project.AddItem("i", "i7");
project.RemoveItem(project.AllEvaluatedItems.ElementAt(1));

Assert.Equal(6, project.AllEvaluatedItems.Count());
Assert.Equal(6, project.AllEvaluatedItems.Count);

project.MarkDirty();
project.ReevaluateIfNecessary();

Assert.Equal(7, project.AllEvaluatedItems.Count());
Assert.Equal(7, project.AllEvaluatedItems.Count);
}
finally
{
Expand Down Expand Up @@ -2002,15 +2002,15 @@ public void AllEvaluatedPropertiesSetProperty()

Project project = new Project(XmlReader.Create(new StringReader(content)));

int initial = project.AllEvaluatedProperties.Count();
int initial = project.AllEvaluatedProperties.Count;

project.SetProperty("p", "1");

Assert.Equal(initial, project.AllEvaluatedProperties.Count());
Assert.Equal(initial, project.AllEvaluatedProperties.Count);

project.ReevaluateIfNecessary();

Assert.Equal(initial + 1, project.AllEvaluatedProperties.Count());
Assert.Equal(initial + 1, project.AllEvaluatedProperties.Count);
}

/// <summary>
Expand Down Expand Up @@ -2038,13 +2038,13 @@ public void AllEvaluatedItemDefinitionMetadata()

Project project = new Project(XmlReader.Create(new StringReader(content)));

Assert.Equal(4, project.AllEvaluatedItemDefinitionMetadata.Count());
Assert.Equal(4, project.AllEvaluatedItemDefinitionMetadata.Count);

Assert.Equal("2", project.AllEvaluatedItemDefinitionMetadata.ElementAt(1).EvaluatedValue);
Assert.Equal("1;2", project.AllEvaluatedItemDefinitionMetadata.ElementAt(3).EvaluatedValue);

// Verify lists are cleared on reevaluation
Assert.Equal(4, project.AllEvaluatedItemDefinitionMetadata.Count());
Assert.Equal(4, project.AllEvaluatedItemDefinitionMetadata.Count);
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/MSBuild/OutOfProcTaskAppDomainWrapperBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ IDictionary<string, TaskParameter> taskParams
foreach (PropertyInfo value in finalPropertyValues)
{
// only record outputs
if (value.GetCustomAttributes(typeof(OutputAttribute), true).Count() > 0)
if (value.GetCustomAttributes(typeof(OutputAttribute), true).Length > 0)
{
try
{
Expand Down
6 changes: 3 additions & 3 deletions src/Tasks.UnitTests/ResourceManagement_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void SingleCoreRequest()
}", "<UseCores />");

var filteredMessages = messages.Where(m => m.Message.StartsWith("Number of cores acquired: ")).ToArray();
filteredMessages.Count().ShouldBe(1);
filteredMessages.Length.ShouldBe(1);
GetTrailingIntegerFromMessage(filteredMessages[0]).ShouldBeGreaterThan(0);
}

Expand All @@ -38,7 +38,7 @@ public void SingleCoreRequestWithNoRelease()
}", "<UseCores /> <UseCores />");

var filteredMessages = messages.Where(m => m.Message.StartsWith("Number of cores acquired: ")).ToArray();
filteredMessages.Count().ShouldBe(2);
filteredMessages.Length.ShouldBe(2);

int grantedCores1 = GetTrailingIntegerFromMessage(filteredMessages[0]);
int grantedCores2 = GetTrailingIntegerFromMessage(filteredMessages[1]);
Expand All @@ -65,7 +65,7 @@ public void SingleCoreRequestWithReacquire()
}", "<UseCores />");

var filteredMessages = messages.Where(m => m.Message.StartsWith("Number of cores acquired: ")).ToArray();
filteredMessages.Count().ShouldBe(2);
filteredMessages.Length.ShouldBe(2);

int grantedCores1 = GetTrailingIntegerFromMessage(filteredMessages[0]);
int grantedCores2 = GetTrailingIntegerFromMessage(filteredMessages[1]);
Expand Down
2 changes: 1 addition & 1 deletion src/Tasks.UnitTests/RoslynCodeTaskFactory_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void RoslynCodeTaskFactory_ReuseCompilation()

// with broken cache we get two Compiling messages
// as we fail to reuse the first assembly
messages.Count().ShouldBe(1);
messages.Length.ShouldBe(1);
}

[Fact]
Expand Down
2 changes: 1 addition & 1 deletion src/Utilities.UnitTests/ToolLocationHelper_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4202,7 +4202,7 @@ public void VerifyFindRootFolderWhereAllFilesExist()
string testDirectoryRoot = Path.Combine(Path.GetTempPath(), "VerifyFindRootFolderWhereAllFilesExist");
string[] rootDirectories = new string[] { Path.Combine(testDirectoryRoot, "Root1"), Path.Combine(testDirectoryRoot, "Root2") };

for(int i = 0; i < rootDirectories.Count(); i++)
for(int i = 0; i < rootDirectories.Length; i++)
{
// create directory
string subdir = Path.Combine(rootDirectories[i], "Subdir");
Expand Down