Skip to content

Commit 7f61b89

Browse files
committed
Use is null.
Consistency.
1 parent 704780e commit 7f61b89

15 files changed

Lines changed: 36 additions & 39 deletions

IDisposableAnalyzers.Benchmarks/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ private static IEnumerable<Summary> RunSingle<T>()
6969
private static void CopyResult(Summary summary)
7070
{
7171
var name = summary.Title.Split('.').LastOrDefault()?.Split('-').FirstOrDefault();
72-
if (name == null)
72+
if (name is null)
7373
{
7474
Console.WriteLine("Did not find name in: " + summary.Title);
7575
Console.WriteLine("Press any key to exit.");
@@ -80,7 +80,7 @@ private static void CopyResult(Summary summary)
8080
var pattern = $"{summary.Title.Split('-').First()}-report-github.md";
8181
var sourceFileName = Directory.EnumerateFiles(summary.ResultsDirectoryPath, pattern)
8282
.SingleOrDefault();
83-
if (sourceFileName == null)
83+
if (sourceFileName is null)
8484
{
8585
Console.WriteLine("Did not find a file matching the pattern: " + pattern);
8686
Console.WriteLine("Press any key to exit.");

IDisposableAnalyzers.Test/IDisposableAnalyzers.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project Sdk="Microsoft.NET.Sdk">
33
<PropertyGroup>
4-
<TargetFramework>net472</TargetFramework>
4+
<TargetFramework>net48</TargetFramework>
55
<LangVersion>latest</LangVersion>
66
<CodeAnalysisRuleSet>IDisposableAnalyzers.Test.ruleset</CodeAnalysisRuleSet>
77
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>

IDisposableAnalyzers/Analyzers/DisposeCallAnalyzer.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ context.Node is InvocationExpressionSyntax invocation &&
3838
context.ReportDiagnostic(Diagnostic.Create(Descriptors.IDISP007DoNotDisposeInjected, invocation.FirstAncestorOrSelf<StatementSyntax>()?.GetLocation() ?? invocation.GetLocation()));
3939
}
4040

41-
if (invocation.Expression is MemberAccessExpressionSyntax memberAccess &&
42-
memberAccess.Expression is IdentifierNameSyntax &&
41+
if (invocation.Expression is MemberAccessExpressionSyntax { Expression: IdentifierNameSyntax _ } &&
4342
context.SemanticModel.TryGetSymbol(root, context.CancellationToken, out ILocalSymbol? local))
4443
{
4544
if (IsUsedAfter(local, invocation, context, out var locations))
@@ -71,7 +70,7 @@ private static bool IsUsedAfter(ILocalSymbol local, InvocationExpressionSyntax i
7170
!IsAssigned(identifierName) &&
7271
!IsReassigned(identifierName))
7372
{
74-
if (temp == null)
73+
if (temp is null)
7574
{
7675
temp = new List<Location>();
7776
}

IDisposableAnalyzers/Analyzers/ReturnValueAnalyzer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ private static bool IsLazyEnumerable(InvocationExpressionSyntax invocation, Recu
178178

179179
private static bool IsDisposableReturnTypeOrIgnored(ITypeSymbol? type, Compilation compilation)
180180
{
181-
if (type == null ||
181+
if (type is null ||
182182
type == KnownSymbol.Void)
183183
{
184184
return true;

IDisposableAnalyzers/CodeFixes/Helpers/MethodFactory.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ internal static class MethodFactory
100100

101101
internal static MethodDeclarationSyntax Dispose(ExpressionSyntax disposedField)
102102
{
103-
if (disposedField == null)
103+
if (disposedField is null)
104104
{
105105
return EmptyDispose;
106106
}
@@ -118,7 +118,7 @@ internal static MethodDeclarationSyntax Dispose(ExpressionSyntax disposedField)
118118

119119
internal static MethodDeclarationSyntax VirtualDispose(ExpressionSyntax disposedField)
120120
{
121-
if (disposedField == null)
121+
if (disposedField is null)
122122
{
123123
return DefaultVirtualDispose;
124124
}
@@ -221,7 +221,7 @@ static ExpressionStatementSyntax BaseDispose(IParameterSymbol parameter)
221221

222222
internal static MethodDeclarationSyntax ProtectedVirtualDispose(ExpressionSyntax disposedField)
223223
{
224-
if (disposedField == null)
224+
if (disposedField is null)
225225
{
226226
return DefaultProtectedVirtualDispose;
227227
}

IDisposableAnalyzers/Helpers/Disposable.IsCreation.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ internal static Result IsAssignedWithCreated(ISymbol symbol, ExpressionSyntax lo
144144
/// </summary>
145145
internal static Result IsCreation(ExpressionSyntax candidate, SemanticModel semanticModel, CancellationToken cancellationToken)
146146
{
147-
if (candidate == null)
147+
if (candidate is null)
148148
{
149149
return Result.Unknown;
150150
}
@@ -229,7 +229,7 @@ internal static Result IsAnyCreation(RecursiveValues values, SemanticModel seman
229229
/// </summary>
230230
private static Result IsCreationCore(ExpressionSyntax candidate, SemanticModel semanticModel, CancellationToken cancellationToken)
231231
{
232-
if (candidate == null ||
232+
if (candidate is null ||
233233
candidate.IsMissing)
234234
{
235235
return Result.Unknown;
@@ -277,7 +277,7 @@ candidate is ImplicitArrayCreationExpressionSyntax ||
277277

278278
private static Result IsCreationCore(ISymbol candidate, Compilation compilation)
279279
{
280-
if (candidate == null)
280+
if (candidate is null)
281281
{
282282
return Result.Unknown;
283283
}

IDisposableAnalyzers/Helpers/Disposable.IsInjected.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ internal static bool IsAssignedWithInjected(ISymbol symbol, ExpressionSyntax loc
9999

100100
private static Result IsInjectedCore(ISymbol symbol)
101101
{
102-
if (symbol == null)
102+
if (symbol is null)
103103
{
104104
return Result.Unknown;
105105
}
@@ -143,7 +143,7 @@ private static Result IsInjectedCore(ISymbol symbol)
143143
}
144144

145145
if (property.IsReadOnly ||
146-
property.SetMethod == null)
146+
property.SetMethod is null)
147147
{
148148
return Result.No;
149149
}

IDisposableAnalyzers/Helpers/Disposable.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ internal static bool IsPotentiallyAssignableFrom(ExpressionSyntax candidate, Sem
2525

2626
internal static bool IsPotentiallyAssignableFrom(ITypeSymbol type, Compilation compilation)
2727
{
28-
if (type == null ||
28+
if (type is null ||
2929
type is IErrorTypeSymbol)
3030
{
3131
return false;
@@ -48,7 +48,7 @@ internal static bool IsPotentiallyAssignableFrom(ITypeSymbol type, Compilation c
4848

4949
internal static bool IsAssignableFrom(ITypeSymbol type, Compilation compilation)
5050
{
51-
if (type == null)
51+
if (type is null)
5252
{
5353
return false;
5454
}

IDisposableAnalyzers/Helpers/DisposableMember.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ internal static Result IsDisposed(FieldOrPropertyAndDeclaration member, Semantic
1313

1414
internal static Result IsDisposed(FieldOrProperty member, INamedTypeSymbol context, SemanticModel semanticModel, CancellationToken cancellationToken)
1515
{
16-
if (context == null)
16+
if (context is null)
1717
{
1818
return Result.Unknown;
1919
}
@@ -38,7 +38,7 @@ internal static Result IsDisposed(FieldOrProperty member, INamedTypeSymbol conte
3838

3939
internal static bool IsDisposed(FieldOrProperty member, IMethodSymbol disposeMethod, SemanticModel semanticModel, CancellationToken cancellationToken)
4040
{
41-
if (disposeMethod == null)
41+
if (disposeMethod is null)
4242
{
4343
return false;
4444
}

IDisposableAnalyzers/Helpers/Pooled/RecursiveValues.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ internal static RecursiveValues Borrow(IReadOnlyList<ExpressionSyntax> rawValues
8282

8383
private bool AddRecursiveValues(ExpressionSyntax assignedValue)
8484
{
85-
if (assignedValue == null ||
85+
if (assignedValue is null ||
8686
assignedValue.IsMissing ||
8787
!this.checkedLocations.Add(assignedValue))
8888
{

0 commit comments

Comments
 (0)