Address CA1829 (Avoiding Count LINQ method calls when equivalent + more efficient properties exist) (#1961)

* Address CA1829 (Avoid Count LINQ Method Calls)

* Remove other change

* CA1829 removal

* CA1829 (remove whitespace)
This commit is contained in:
Chris LaFreniere
2023-03-23 21:06:49 -07:00
committed by GitHub
parent 3ef3a0f022
commit cccdbf0bef
15 changed files with 25 additions and 27 deletions

View File

@@ -183,7 +183,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
details.HostNameInCertificate = expectedForStrings + index++;
details.Port = expectedForInt + index++;
if (optionMetadata.Options.Count() != details.Options.Count)
if (optionMetadata.Options.Length != details.Options.Count)
{
var optionsNotInMetadata = details.Options.Where(o => !optionMetadata.Options.Any(m => m.Name == o.Key));
var optionNames = optionsNotInMetadata.Any() ? optionsNotInMetadata.Select(s => s.Key).Aggregate((i, j) => i + "," + j) : null;

View File

@@ -42,9 +42,9 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageServer
AutoCompletionResult result = completionService.CreateCompletions(connectionInfo, docInfo, useLowerCaseSuggestions);
Assert.NotNull(result);
var count = result.CompletionItems == null ? 0 : result.CompletionItems.Count();
var count = result.CompletionItems == null ? 0 : result.CompletionItems.Length;
Assert.That(count, Is.Not.EqualTo(defaultCompletionList.Count()));
Assert.That(count, Is.Not.EqualTo(defaultCompletionList.Length));
}
[Test]
@@ -65,7 +65,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageServer
AutoCompletionResult result = completionService.CreateCompletions(connectionInfo, docInfo, useLowerCaseSuggestions);
Assert.NotNull(result);
Assert.AreEqual(result.CompletionItems.Count(), defaultCompletionList.Count());
Assert.AreEqual(result.CompletionItems.Length, defaultCompletionList.Length);
Thread.Sleep(3000);
Assert.True(connectionInfo.IntellisenseMetrics.Quantile.Any());
}

View File

@@ -475,7 +475,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer
private void VerifyServerNodeChildren(NodeInfo[] children)
{
Assert.NotNull(children);
Assert.True(children.Count() == 3);
Assert.True(children.Length == 3);
Assert.True(children.All((x => x.NodeType == "Folder")));
}

View File

@@ -51,7 +51,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ResourceProvider.Azure
Assert.False(list.Any(x => x.Name == "db2" && x.ServerInstanceInfo.Name == ""));
Assert.True(list.Any(x => x.Name == "" && x.ServerInstanceInfo.Name == "server"));
Assert.False(list.Any(x => x.Name == "db4" && x.ServerInstanceInfo.Name == ""));
Assert.True(list.Count() == 2);
Assert.True(list.Count == 2);
}
[Test]
@@ -83,7 +83,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ResourceProvider.Azure
Assert.True(list.Any(x => x.Name == "db2" && x.ServerInstanceInfo.Name == "server1"));
Assert.True(list.Any(x => x.Name == "db4" && x.ServerInstanceInfo.Name == "server2"));
Assert.False(list.Any(x => x.Name == "db3" && x.ServerInstanceInfo.Name == "error"));
Assert.True(list.Count() == 3);
Assert.True(list.Count == 3);
Assert.NotNull(response.Errors);
Assert.True(response.Errors.Count() == 1);
}
@@ -147,7 +147,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ResourceProvider.Azure
Assert.True(result.Any(x => x.Name == databaseName && x.ServerInstanceInfo.Name == serverName));
}
}
Assert.True(result.Count() == numberOfDatabases);
Assert.True(result.Count == numberOfDatabases);
}
private void AddDatabases(Dictionary<string, List<string>> subscriptionToDatabaseMap, int numberOfDatabases)