Skip to content

Commit c6fb31c

Browse files
authored
Actually use discards in places where intended (#12464)
This was just a Find/Replace from "out var _" to "out _"
1 parent 99893ed commit c6fb31c

File tree

9 files changed

+22
-22
lines changed

9 files changed

+22
-22
lines changed

src/Compiler/Microsoft.AspNetCore.Razor.Language/test/RazorLanguageVersionTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public void TryParseInvalid()
1919
var value = "not-version";
2020

2121
// Act
22-
var result = RazorLanguageVersion.TryParse(value, out var _);
22+
var result = RazorLanguageVersion.TryParse(value, out _);
2323

2424
// Assert
2525
Assert.False(result);

src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Legacy/HtmlMarkupParser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ private void ParseMarkupElement(in SyntaxListBuilder<RazorSyntaxNode> builder, P
514514
{
515515
// Parsing an end tag.
516516
var endTagStart = CurrentStart;
517-
var endTag = ParseEndTag(mode, out var endTagName, out var _);
517+
var endTag = ParseEndTag(mode, out var endTagName, out _);
518518

519519
if (string.Equals(CurrentStartTagName, endTagName, StringComparison.OrdinalIgnoreCase))
520520
{

src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Mvc.Version2_X/RazorPageDocumentClassifierPass.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ private void EnsureValidPageDirective(RazorCodeDocument codeDocument, PageDirect
126126
LeadingDirectiveParsingEngine.Engine.Process(leadingDirectiveCodeDocument);
127127

128128
var leadingDirectiveDocumentNode = leadingDirectiveCodeDocument.GetRequiredDocumentNode();
129-
if (!PageDirective.TryGetPageDirective(leadingDirectiveDocumentNode, out var _))
129+
if (!PageDirective.TryGetPageDirective(leadingDirectiveDocumentNode, out _))
130130
{
131131
// The page directive is not the leading directive. Add an error.
132132
pageDirective.DirectiveNode.AddDiagnostic(

src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Mvc/RazorPageDocumentClassifierPass.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public RazorPageDocumentClassifierPass(bool useConsolidatedMvcViews)
5050

5151
protected override bool IsMatch(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode)
5252
{
53-
return PageDirective.TryGetPageDirective(documentNode, out var _);
53+
return PageDirective.TryGetPageDirective(documentNode, out _);
5454
}
5555

5656
protected override void OnDocumentStructureCreated(
@@ -145,7 +145,7 @@ private void EnsureValidPageDirective(RazorCodeDocument codeDocument, PageDirect
145145
LeadingDirectiveParsingEngine.Engine.Process(leadingDirectiveCodeDocument);
146146

147147
var leadingDirectiveDocumentNode = leadingDirectiveCodeDocument.GetRequiredDocumentNode();
148-
if (!PageDirective.TryGetPageDirective(leadingDirectiveDocumentNode, out var _))
148+
if (!PageDirective.TryGetPageDirective(leadingDirectiveDocumentNode, out _))
149149
{
150150
// The page directive is not the leading directive. Add an error.
151151
pageDirective.DirectiveNode.AddDiagnostic(

src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DocumentMapping/AbstractDocumentMappingService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,13 +226,13 @@ public bool TryMapToCSharpDocumentRange(RazorCSharpDocument csharpDocument, Line
226226
}
227227

228228
if (!sourceText.TryGetAbsoluteIndex(range.Start, out var startIndex) ||
229-
!TryMapToCSharpDocumentPosition(csharpDocument, startIndex, out var generatedRangeStart, out var _))
229+
!TryMapToCSharpDocumentPosition(csharpDocument, startIndex, out var generatedRangeStart, out _))
230230
{
231231
return false;
232232
}
233233

234234
if (!sourceText.TryGetAbsoluteIndex(range.End, out var endIndex) ||
235-
!TryMapToCSharpDocumentPosition(csharpDocument, endIndex, out var generatedRangeEnd, out var _))
235+
!TryMapToCSharpDocumentPosition(csharpDocument, endIndex, out var generatedRangeEnd, out _))
236236
{
237237
return false;
238238
}

src/Razor/src/Microsoft.VisualStudioCode.RazorExtension/RazorWorkspaceListenerBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ project is not
186186
}
187187

188188
// Don't queue work for projects that don't have a dynamic file
189-
if (!_projectsWithDynamicFile.TryGetValue(project.Id, out var _))
189+
if (!_projectsWithDynamicFile.TryGetValue(project.Id, out _))
190190
{
191191
return;
192192
}
@@ -199,7 +199,7 @@ void RemoveProject(Project project)
199199
// Remove project is called from Workspace.Changed, while other notifications of _projectsWithDynamicFile
200200
// are handled with NotifyDynamicFile. Use ImmutableInterlocked here to be sure the updates happen
201201
// in a thread safe manner since those are not assumed to be the same thread.
202-
if (ImmutableInterlocked.TryRemove(ref _projectsWithDynamicFile, project.Id, out var _))
202+
if (ImmutableInterlocked.TryRemove(ref _projectsWithDynamicFile, project.Id, out _))
203203
{
204204
var intermediateOutputPath = Path.GetDirectoryName(project.CompilationOutputInfo.AssemblyPath);
205205
if (intermediateOutputPath is null)

src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/CodeActions/Razor/CreateComponentCodeActionResolverTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public async Task Handle_CreateComponent()
6666
Assert.Equal(1, workspaceEdit.DocumentChanges.Value.Count());
6767

6868
var createFileChange = workspaceEdit.DocumentChanges.Value.First();
69-
Assert.True(createFileChange.TryGetSecond(out var _));
69+
Assert.True(createFileChange.TryGetSecond(out _));
7070
}
7171

7272
[Fact]
@@ -97,7 +97,7 @@ @namespace Another.Namespace
9797
Assert.Equal(2, workspaceEdit.DocumentChanges.Value.Count());
9898

9999
var createFileChange = workspaceEdit.DocumentChanges.Value.First();
100-
Assert.True(createFileChange.TryGetSecond(out var _));
100+
Assert.True(createFileChange.TryGetSecond(out _));
101101

102102
var editNewComponentChange = workspaceEdit.DocumentChanges.Value.Last();
103103
var editNewComponentEdit = editNewComponentChange.First.Edits.First();

src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/CodeActions/Razor/ExtractToCodeBehindCodeActionResolverTest.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public async Task Handle_ExtractCodeBlock()
6060

6161
var documentChanges = workspaceEdit.DocumentChanges.Value.ToArray();
6262
var createFileChange = documentChanges[0];
63-
Assert.True(createFileChange.TryGetSecond(out var _));
63+
Assert.True(createFileChange.TryGetSecond(out _));
6464

6565
var editCodeDocumentChange = documentChanges[1];
6666
Assert.True(editCodeDocumentChange.TryGetFirst(out var textDocumentEdit1));
@@ -125,7 +125,7 @@ public async Task Handle_ExtractCodeBlock2()
125125

126126
var documentChanges = workspaceEdit.DocumentChanges.Value.ToArray();
127127
var createFileChange = documentChanges[0];
128-
Assert.True(createFileChange.TryGetSecond(out var _));
128+
Assert.True(createFileChange.TryGetSecond(out _));
129129

130130
var editCodeDocumentChange = documentChanges[1];
131131
Assert.True(editCodeDocumentChange.TryGetFirst(out var textDocumentEdit1));
@@ -198,7 +198,7 @@ private void M()
198198

199199
var documentChanges = workspaceEdit.DocumentChanges.Value.ToArray();
200200
var createFileChange = documentChanges[0];
201-
Assert.True(createFileChange.TryGetSecond(out var _));
201+
Assert.True(createFileChange.TryGetSecond(out _));
202202

203203
var editCodeDocumentChange = documentChanges[1];
204204
Assert.True(editCodeDocumentChange.TryGetFirst(out var textDocumentEdit1));
@@ -281,7 +281,7 @@ private void M()
281281

282282
var documentChanges = workspaceEdit.DocumentChanges.Value.ToArray();
283283
var createFileChange = documentChanges[0];
284-
Assert.True(createFileChange.TryGetSecond(out var _));
284+
Assert.True(createFileChange.TryGetSecond(out _));
285285

286286
var editCodeDocumentChange = documentChanges[1];
287287
Assert.True(editCodeDocumentChange.TryGetFirst(out var textDocumentEdit1));
@@ -366,7 +366,7 @@ private void M()
366366

367367
var documentChanges = workspaceEdit.DocumentChanges.Value.ToArray();
368368
var createFileChange = documentChanges[0];
369-
Assert.True(createFileChange.TryGetSecond(out var _));
369+
Assert.True(createFileChange.TryGetSecond(out _));
370370

371371
var editCodeDocumentChange = documentChanges[1];
372372
Assert.True(editCodeDocumentChange.TryGetFirst(out var textDocumentEdit1));
@@ -439,7 +439,7 @@ public async Task Handle_ExtractFunctionsBlock()
439439

440440
var documentChanges = workspaceEdit.DocumentChanges.Value.ToArray();
441441
var createFileChange = documentChanges[0];
442-
Assert.True(createFileChange.TryGetSecond(out var _));
442+
Assert.True(createFileChange.TryGetSecond(out _));
443443

444444
var editCodeDocumentChange = documentChanges[1];
445445
Assert.True(editCodeDocumentChange.TryGetFirst(out var editCodeDocument));
@@ -504,7 +504,7 @@ @using System.Diagnostics
504504

505505
var documentChanges = workspaceEdit.DocumentChanges.Value.ToArray();
506506
var createFileChange = documentChanges[0];
507-
Assert.True(createFileChange.TryGetSecond(out var _));
507+
Assert.True(createFileChange.TryGetSecond(out _));
508508

509509
var editCodeDocumentChange = documentChanges[1];
510510
Assert.True(editCodeDocumentChange.TryGetFirst(out var editCodeDocument));
@@ -571,7 +571,7 @@ public async Task Handle_ExtractCodeBlockWithDirectives()
571571

572572
var documentChanges = workspaceEdit.DocumentChanges.Value.ToArray();
573573
var createFileChange = documentChanges[0];
574-
Assert.True(createFileChange.TryGetSecond(out var _));
574+
Assert.True(createFileChange.TryGetSecond(out _));
575575

576576
var editCodeDocumentChange = documentChanges[1];
577577
Assert.True(editCodeDocumentChange.TryGetFirst(out var textDocumentEdit1));
@@ -642,7 +642,7 @@ public async Task Handle_ExtractCodeBlock_CallsRoslyn()
642642

643643
var documentChanges = workspaceEdit.DocumentChanges.Value.ToArray();
644644
var createFileChange = documentChanges[0];
645-
Assert.True(createFileChange.TryGetSecond(out var _));
645+
Assert.True(createFileChange.TryGetSecond(out _));
646646

647647
var editCodeDocumentChange = documentChanges[1];
648648
Assert.True(editCodeDocumentChange.TryGetFirst(out var textDocumentEdit1));

src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Hover/HoverFactoryTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,8 +534,8 @@ public async Task GetHoverAsync_TagHelper_Element_VSClient_ReturnVSHover()
534534

535535
// Assert
536536
Assert.NotNull(hover);
537-
Assert.False(hover.Contents.TryGetFourth(out var _));
538-
Assert.True(hover.Contents.TryGetThird(out var _) && !hover.Contents.Third.Any());
537+
Assert.False(hover.Contents.TryGetFourth(out _));
538+
Assert.True(hover.Contents.TryGetThird(out _) && !hover.Contents.Third.Any());
539539
var expectedRange = LspFactory.CreateSingleLineRange(line: 1, character: 1, length: 5);
540540
Assert.Equal(expectedRange, hover.Range);
541541

0 commit comments

Comments
 (0)