Skip to content

Commit 0964f68

Browse files
committed
Just a syntax refactoring
1 parent fb95ae4 commit 0964f68

12 files changed

+22
-21
lines changed

Roslyn.Testing/Analyzer/DiagnosticVerifier.Helpers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ private static Project CreateProject(string[] sources, string language = Languag
206206
.AddMetadataReference(projectId, CodeAnalysisReference)
207207
.AddMetadataReference(projectId, SystemDiagReference);
208208

209-
if (references != null)
209+
if (references is not null)
210210
{
211211
solution = solution.AddMetadataReferences(projectId, references);
212212
}

Roslyn.Testing/Analyzer/DiagnosticVerifier.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ private static Project CreateProject(string[] sources, string language, IEnumera
203203
.AddMetadataReference(projectId, CodeAnalysisReference)
204204
.AddMetadataReference(projectId, SystemDiagnosticReference);
205205

206-
if (references != null)
206+
if (references is not null)
207207
{
208208
solution = solution.AddMetadataReferences(projectId, references);
209209
}
@@ -348,7 +348,7 @@ private static VerifyDiagnosticAnalyzerResult VerifyDiagnosticLocation(Diagnosti
348348
var actualSpan = actual.GetLineSpan();
349349

350350
var isInExpectedFile = actualSpan.Path == expected.Path
351-
|| (actualSpan.Path != null
351+
|| (actualSpan.Path is not null
352352
&& actualSpan.Path.Contains("Test0.")
353353
&& expected.Path.Contains("Test."));
354354

@@ -448,7 +448,7 @@ private static string FormatDiagnostics(DiagnosticAnalyzer analyzer, Diagnostic[
448448

449449
foreach (var rule in rules)
450450
{
451-
if (rule != null
451+
if (rule is not null
452452
&& rule.Id
453453
== diagnostics[i]
454454
.Id)

Roslyn.Testing/CodeFix/CodeFixProviderTestExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public static VerifyCodeFixProviderResult VerifyFix(this CodeFixProvider codeFix
100100
break;
101101
}
102102

103-
if (codeFixIndex != null)
103+
if (codeFixIndex is not null)
104104
{
105105
document = document.ApplyFix(actions.ElementAt((int) codeFixIndex));
106106

System.IO.Abstractions.Analyzers/CodeActions/DirectoryInfoCodeAction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ protected override async Task<Document> GetChangedDocumentAsync(CancellationToke
4242
var editor = await DocumentEditor.CreateAsync(_document, cancellationToken)
4343
.ConfigureAwait(false);
4444

45-
if (_creationExpressionSyntax.ArgumentList == null)
45+
if (_creationExpressionSyntax.ArgumentList is null)
4646
{
4747
return _document;
4848
}

System.IO.Abstractions.Analyzers/CodeActions/FileInfoCodeAction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ protected override async Task<Document> GetChangedDocumentAsync(CancellationToke
4242
var editor = await DocumentEditor.CreateAsync(_document, cancellationToken)
4343
.ConfigureAwait(false);
4444

45-
if (_creationExpressionSyntax.ArgumentList == null)
45+
if (_creationExpressionSyntax.ArgumentList is null)
4646
{
4747
return _document;
4848
}

System.IO.Abstractions.Analyzers/CodeActions/FileServiceConstructorInitialCodeAction.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ protected override async Task<Document> GetChangedDocumentAsync(CancellationToke
5858

5959
var fileSystem = RoslynClassFileSystem.GetUsing(compilationUnitSyntax, Constants.FileSystemNameSpace);
6060

61-
if (fileSystem != null)
61+
if (fileSystem is not null)
6262
{
6363
return editor.GetChangedDocument();
6464
}
6565

6666
var systemIo = RoslynClassFileSystem.GetSystemIoUsing(compilationUnitSyntax);
6767

68-
if (systemIo == null)
68+
if (systemIo is null)
6969
{
7070
if (compilationUnitSyntax.Usings.Any())
7171
{

System.IO.Abstractions.Analyzers/CodeActions/FileServiceInterfaceInjectionCodeAction.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ protected override async Task<Document> GetChangedDocumentAsync(CancellationToke
5858

5959
var fileSystem = RoslynClassFileSystem.GetUsing(compilationUnitSyntax, Constants.FileSystemNameSpace);
6060

61-
if (fileSystem != null)
61+
if (fileSystem is not null)
6262
{
6363
return editor.GetChangedDocument();
6464
}
6565

6666
var systemIo = RoslynClassFileSystem.GetSystemIoUsing(compilationUnitSyntax);
6767

68-
if (systemIo == null)
68+
if (systemIo is null)
6969
{
7070
if (compilationUnitSyntax.Usings.Any())
7171
{

System.IO.Abstractions.Analyzers/CodeActions/FileStreamCodeAction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ protected override async Task<Document> GetChangedDocumentAsync(CancellationToke
4242
var editor = await DocumentEditor.CreateAsync(_document, cancellationToken)
4343
.ConfigureAwait(false);
4444

45-
if (_creationExpressionSyntax.ArgumentList == null)
45+
if (_creationExpressionSyntax.ArgumentList is null)
4646
{
4747
return _document;
4848
}

System.IO.Abstractions.Analyzers/CodeFixes/BaseInvokeCodeFix.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
3535
var root = await context.Document.GetSyntaxRootAsync(context.CancellationToken)
3636
.ConfigureAwait(false);
3737

38-
if (root == null)
38+
if (root is null)
3939
{
4040
return;
4141
}

System.IO.Abstractions.Analyzers/CodeFixes/FileServiceConstructorInitialCodeFix.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
4444
var root = await context.Document.GetSyntaxRootAsync(context.CancellationToken)
4545
.ConfigureAwait(false);
4646

47-
if (root == null)
47+
if (root is null)
4848
{
4949
return;
5050
}
@@ -55,7 +55,7 @@ public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
5555
var constructor = RoslynClassFileSystem.GetConstructor(classDeclarationSyntax);
5656

5757
if (!RoslynClassFileSystem.HasFileSystemField(classDeclarationSyntax)
58-
|| (constructor != null && !RoslynClassFileSystem.ConstructorHasFileSystemParameter(constructor)))
58+
|| (constructor is not null && !RoslynClassFileSystem.ConstructorHasFileSystemParameter(constructor)))
5959
{
6060
context.RegisterCodeFix(new FileServiceConstructorInitialCodeAction(Title,
6161
context.Document,

0 commit comments

Comments
 (0)