Skip to content

Commit f0190bf

Browse files
committed
Fix project warnings
1 parent e84799c commit f0190bf

1 file changed

Lines changed: 37 additions & 41 deletions

File tree

Roslyn.Testing/Analyzer/DiagnosticVerifier.cs

Lines changed: 37 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,6 @@ public static VerifyDiagnosticAnalyzerResult VerifyDiagnosticResults(this Diagno
250250

251251
if (expectedCount != actualCount)
252252
{
253-
254253
var diagnosticsOutput = diagnostics.Any()
255254
? FormatDiagnostics(analyzer, diagnostics)
256255
: " NONE.";
@@ -354,8 +353,7 @@ private static VerifyDiagnosticAnalyzerResult VerifyDiagnosticLocation(Diagnosti
354353
var actualSpan = actual.GetLineSpan();
355354

356355
var isInExpectedFile = actualSpan.Path == expected.Path
357-
|| (actualSpan.Path is not null
358-
&& actualSpan.Path.Contains("Test0.")
356+
|| (actualSpan.Path.Contains("Test0.")
359357
&& expected.Path.Contains("Test."));
360358

361359
if (!isInExpectedFile)
@@ -454,53 +452,51 @@ private static string FormatDiagnostics(DiagnosticAnalyzer analyzer, Diagnostic[
454452

455453
foreach (var rule in rules)
456454
{
457-
if (rule is not null
458-
&& rule.Id
459-
== diagnostics[i]
460-
.Id)
455+
if (rule.Id != diagnostics[i].Id)
461456
{
462-
var location = diagnostics[i]
463-
.Location;
457+
continue;
458+
}
464459

465-
if (location == Location.None)
466-
{
467-
builder.AppendFormat("GetGlobalResult({0}.{1})", analyzerType.Name, rule.Id);
468-
} else
469-
{
470-
if (!location.IsInSource)
471-
{
472-
var msg =
473-
$"Test base does not currently handle diagnostics in metadata locations. Diagnostic in metadata: {diagnostics[i]}{Environment.NewLine}";
460+
var location = diagnostics[i]
461+
.Location;
474462

475-
throw new(msg);
476-
}
463+
if (location == Location.None)
464+
{
465+
builder.AppendFormat("GetGlobalResult({0}.{1})", analyzerType.Name, rule.Id);
466+
} else
467+
{
468+
if (!location.IsInSource)
469+
{
470+
var msg =
471+
$"Test base does not currently handle diagnostics in metadata locations. Diagnostic in metadata: {diagnostics[i]}{Environment.NewLine}";
477472

478-
var resultMethodName = diagnostics[i]
479-
.Location.SourceTree.FilePath.EndsWith(".cs")
480-
? "GetCSharpResultAt"
481-
: "GetBasicResultAt";
482-
483-
var linePosition = diagnostics[i]
484-
.Location.GetLineSpan()
485-
.StartLinePosition;
486-
487-
builder.AppendFormat("{0}({1}, {2}, {3}.{4})",
488-
resultMethodName,
489-
linePosition.Line + 1,
490-
linePosition.Character + 1,
491-
analyzerType.Name,
492-
rule.Id);
473+
throw new(msg);
493474
}
494475

495-
if (i != diagnostics.Length - 1)
496-
{
497-
builder.Append(',');
498-
}
476+
var resultMethodName = location.SourceTree.FilePath.EndsWith(".cs")
477+
? "GetCSharpResultAt"
478+
: "GetBasicResultAt";
479+
480+
var linePosition = diagnostics[i]
481+
.Location.GetLineSpan()
482+
.StartLinePosition;
499483

500-
builder.AppendLine();
484+
builder.AppendFormat("{0}({1}, {2}, {3}.{4})",
485+
resultMethodName,
486+
linePosition.Line + 1,
487+
linePosition.Character + 1,
488+
analyzerType.Name,
489+
rule.Id);
490+
}
501491

502-
break;
492+
if (i != diagnostics.Length - 1)
493+
{
494+
builder.Append(',');
503495
}
496+
497+
builder.AppendLine();
498+
499+
break;
504500
}
505501
}
506502

0 commit comments

Comments
 (0)