Skip to content

Commit

Permalink
Use existing property over linq operator (#76853)
Browse files Browse the repository at this point in the history
  • Loading branch information
CyrusNajmabadi authored Jan 22, 2025
2 parents 3c6bf92 + c202012 commit 390b425
Show file tree
Hide file tree
Showing 21 changed files with 68 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ await TestAsync(testHost, composition, source, async w =>

var items = await _aggregator.GetItemsAsync("GK");

Assert.Equal(expecteditems.Count(), items.Count());
Assert.Equal(expecteditems.Count, items.Count());

VerifyNavigateToResultItems(expecteditems, items);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ private static async Task AssertTagsOnBracesOrSemicolonsTokensAsync(string conte
var spans = await lineSeparatorService.GetLineSeparatorsAsync(document, root.FullSpan, CancellationToken.None);
var tokens = root.DescendantTokens().Where(t => t.Kind() is SyntaxKind.CloseBraceToken or SyntaxKind.SemicolonToken);

Assert.Equal(tokenIndices.Length, spans.Count());
Assert.Equal(tokenIndices.Length, spans.Length);

var i = 0;
foreach (var span in spans.OrderBy(t => t.Start))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,7 @@ await TestAsync(testHost, composition, source, async w =>

var items = await _aggregator.GetItemsAsync("GK");

Assert.Equal(expecteditems.Count(), items.Count());
Assert.Equal(expecteditems.Count, items.Count());

VerifyNavigateToResultItems(expecteditems, items);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ internal async Task TestWithMockedGenerateTypeDialog(
Assert.False(fixActions.IsDefault);

// Since the dialog option is always fed as the last CodeAction
var index = fixActions.Count() - 1;
var index = fixActions.Length - 1;
var action = fixActions.ElementAt(index);

Assert.Equal(action.Title, FeaturesResources.Generate_new_type);
Expand Down
14 changes: 7 additions & 7 deletions src/EditorFeatures/Test/Tagging/TagSpanIntervalTreeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ public void TestManySpansWithEdit()
buffer.Insert(0, new string('c', 100));

// We should have 50 spans if we start looking at just the end
Assert.Equal(50, GetIntersectingSpans(tree, new SnapshotSpan(buffer.CurrentSnapshot, 150, 50)).Count());
Assert.Equal(50, GetIntersectingSpans(tree, new SnapshotSpan(buffer.CurrentSnapshot, 150, 50)).Count);

// And we should have 26 here. We directly cover 25 spans, and we touch one more
Assert.Equal(26, GetIntersectingSpans(tree, new SnapshotSpan(buffer.CurrentSnapshot, 175, 25)).Count());
Assert.Equal(26, GetIntersectingSpans(tree, new SnapshotSpan(buffer.CurrentSnapshot, 175, 25)).Count);
}

[Fact]
Expand All @@ -98,11 +98,11 @@ public void TestManySpansWithEdit2()
buffer.Insert(0, new string('c', 100));

// We should see one span anywhere in the beginning of the buffer, since this is edge inclusive
Assert.Equal(1, GetIntersectingSpans(tree, new SnapshotSpan(buffer.CurrentSnapshot, 0, 1)).Count());
Assert.Equal(1, GetIntersectingSpans(tree, new SnapshotSpan(buffer.CurrentSnapshot, 50, 1)).Count());
Assert.Equal(1, GetIntersectingSpans(tree, new SnapshotSpan(buffer.CurrentSnapshot, 0, 1)).Count);
Assert.Equal(1, GetIntersectingSpans(tree, new SnapshotSpan(buffer.CurrentSnapshot, 50, 1)).Count);

// We should see two at position 100 (the first span that is now expanded, and the second of width 1)
Assert.Equal(2, GetIntersectingSpans(tree, new SnapshotSpan(buffer.CurrentSnapshot, 100, 1)).Count());
Assert.Equal(2, GetIntersectingSpans(tree, new SnapshotSpan(buffer.CurrentSnapshot, 100, 1)).Count);
}

[Fact]
Expand All @@ -116,7 +116,7 @@ public void TestManySpansWithDeleteAndEditAtStart()

// We should see 51 spans intersecting the start. When we did the delete, we contracted 50 spans to size
// zero, and then the insert will have expanded all of those, plus the span right next to it.
Assert.Equal(51, GetIntersectingSpans(tree, new SnapshotSpan(buffer.CurrentSnapshot, 0, 1)).Count());
Assert.Equal(51, GetIntersectingSpans(tree, new SnapshotSpan(buffer.CurrentSnapshot, 0, 1)).Count);
}

[Fact]
Expand All @@ -130,7 +130,7 @@ public void TestManySpansWithDeleteAndEditAtEnd()

// We should see 51 spans intersecting the end. When we did the delete, we contracted 50 spans to size zero,
// and then the insert will have expanded all of those, plus the span right next to it.
Assert.Equal(51, GetIntersectingSpans(tree, new SnapshotSpan(buffer.CurrentSnapshot, 99, 1)).Count());
Assert.Equal(51, GetIntersectingSpans(tree, new SnapshotSpan(buffer.CurrentSnapshot, 99, 1)).Count);
}

[Fact]
Expand Down
14 changes: 7 additions & 7 deletions src/EditorFeatures/Test2/CodeFixes/CodeFixServiceTests.vb
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.CodeFixes.UnitTests
Dim diagnostics = Await diagnosticService.GetDiagnosticsForSpanAsync(document,
range:=(Await document.GetSyntaxRootAsync()).FullSpan, DiagnosticKind.All, includeSuppressedDiagnostics:=False, CancellationToken.None)

Assert.Equal(1, diagnostics.Count())
Assert.Equal(1, diagnostics.Length)

' Verify available codefix with a global fixer
Dim fixes = Await codefixService.GetFixesAsync(
document,
(Await document.GetSyntaxRootAsync()).FullSpan,
CancellationToken.None)

Assert.Equal(0, fixes.Count())
Assert.Equal(0, fixes.Length)

' Verify available codefix with a global fixer + a project fixer
' We will use this assembly as a project fixer provider.
Expand All @@ -92,7 +92,7 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.CodeFixes.UnitTests
document,
(Await document.GetSyntaxRootAsync()).FullSpan,
CancellationToken.None)
Assert.Equal(1, fixes.Count())
Assert.Equal(1, fixes.Length)

' Remove a project analyzer
project = project.RemoveAnalyzerReference(projectAnalyzerReference)
Expand All @@ -102,7 +102,7 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.CodeFixes.UnitTests
(Await document.GetSyntaxRootAsync()).FullSpan,
CancellationToken.None)

Assert.Equal(0, fixes.Count())
Assert.Equal(0, fixes.Length)
End Using
End Function

Expand Down Expand Up @@ -142,15 +142,15 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.CodeFixes.UnitTests
Dim diagnostics = Await diagnosticService.GetDiagnosticsForSpanAsync(document,
range:=(Await document.GetSyntaxRootAsync()).FullSpan, DiagnosticKind.All, includeSuppressedDiagnostics:=False, CancellationToken.None)

Assert.Equal(1, diagnostics.Count())
Assert.Equal(1, diagnostics.Length)

' Verify no codefix with a global fixer
Dim fixes = Await codefixService.GetFixesAsync(
document,
(Await document.GetSyntaxRootAsync()).FullSpan,
CancellationToken.None)

Assert.Equal(0, fixes.Count())
Assert.Equal(0, fixes.Length)

' Verify no codefix with a global fixer + a project fixer
' We will use this assembly as a project fixer provider.
Expand All @@ -165,7 +165,7 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.CodeFixes.UnitTests
(Await document.GetSyntaxRootAsync()).FullSpan,
CancellationToken.None)

Assert.Equal(0, fixes.Count())
Assert.Equal(0, fixes.Length)
End Using
End Function

Expand Down
Loading

0 comments on commit 390b425

Please sign in to comment.