Skip to content

Commit 9ded966

Browse files
committed
Bang warnings.
1 parent 23cf44e commit 9ded966

5 files changed

Lines changed: 10 additions & 10 deletions

File tree

PropertyChangedAnalyzers/Analyzers/MutationAnalyzer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ private static void Handle(ExpressionSyntax mutation, ExpressionSyntax backing,
131131
continue;
132132
}
133133

134-
var properties = ImmutableDictionary.CreateRange(new[] { new KeyValuePair<string, string>(PropertyNameKey, property.Name), });
134+
var properties = ImmutableDictionary.CreateRange(new[] { new KeyValuePair<string, string?>(PropertyNameKey, property.Name), });
135135
context.ReportDiagnostic(Diagnostic.Create(Descriptors.INPC003NotifyForDependentProperty, context.Node.GetLocation(), properties, property.Name));
136136
}
137137
}

PropertyChangedAnalyzers/Analyzers/SetAccessorAnalyzer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ void HandleInvocation(InvocationExpressionSyntax invocation)
258258
invocation.GetLocation()));
259259
}
260260

261-
IPropertySymbol ContainingProperty() => (IPropertySymbol)((IMethodSymbol)context.ContainingSymbol).AssociatedSymbol!;
261+
IPropertySymbol ContainingProperty() => (IPropertySymbol)((IMethodSymbol)context.ContainingSymbol!).AssociatedSymbol!;
262262
}
263263

264264
bool ShouldUseObjectReferenceEquals(ExpressionSyntax x, ExpressionSyntax y)

PropertyChangedAnalyzers/CodeFixes/NotifyForDependentPropertyFix.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ semanticModel is { } &&
4747
$"Notify that property {propertyName} changes.",
4848
async (editor, cancellationToken) =>
4949
{
50-
var onPropertyChangedStatement = await editor.OnPropertyChangedInvocationStatementAsync(onPropertyChangedMethod, propertyName, cancellationToken)
50+
var onPropertyChangedStatement = await editor.OnPropertyChangedInvocationStatementAsync(onPropertyChangedMethod, propertyName!, cancellationToken)
5151
.ConfigureAwait(false);
5252
editor.ReplaceNode(
5353
expressionStatement,
@@ -67,7 +67,7 @@ semanticModel is { } &&
6767
$"Notify that property {propertyName} changes.",
6868
async (editor, cancellationToken) =>
6969
{
70-
var onPropertyChangedStatement = await editor.OnPropertyChangedInvocationStatementAsync(onPropertyChangedMethod, propertyName, cancellationToken)
70+
var onPropertyChangedStatement = await editor.OnPropertyChangedInvocationStatementAsync(onPropertyChangedMethod, propertyName!, cancellationToken)
7171
.ConfigureAwait(false);
7272
_ = editor.ReplaceNode(
7373
setter,
@@ -84,7 +84,7 @@ semanticModel is { } &&
8484
$"Notify that property {propertyName} changes.",
8585
async (editor, cancellationToken) =>
8686
{
87-
var onPropertyChangedStatement = await editor.OnPropertyChangedInvocationStatementAsync(onPropertyChangedMethod, propertyName, cancellationToken)
87+
var onPropertyChangedStatement = await editor.OnPropertyChangedInvocationStatementAsync(onPropertyChangedMethod, propertyName!, cancellationToken)
8888
.ConfigureAwait(false);
8989
editor.AddOnPropertyChanged(ifTrySet, onPropertyChangedStatement);
9090
},
@@ -98,7 +98,7 @@ when Gu.Roslyn.AnalyzerExtensions.Equality.IsNegated(trySet) &&
9898
$"Notify that property {propertyName} changes.",
9999
async (editor, cancellationToken) =>
100100
{
101-
var onPropertyChangedStatement = await editor.OnPropertyChangedInvocationStatementAsync(onPropertyChangedMethod, propertyName, cancellationToken)
101+
var onPropertyChangedStatement = await editor.OnPropertyChangedInvocationStatementAsync(onPropertyChangedMethod, propertyName!, cancellationToken)
102102
.ConfigureAwait(false);
103103
editor.AddOnPropertyChangedAfter(ifNotTrySetReturn, onPropertyChangedStatement);
104104
},
@@ -113,7 +113,7 @@ when Gu.Roslyn.AnalyzerExtensions.Equality.IsNegated(trySet) &&
113113
$"Notify that property {propertyName} changes.",
114114
async (editor, cancellationToken) =>
115115
{
116-
var onPropertyChangedStatement = await editor.OnPropertyChangedInvocationStatementAsync(onPropertyChangedMethod, propertyName, cancellationToken)
116+
var onPropertyChangedStatement = await editor.OnPropertyChangedInvocationStatementAsync(onPropertyChangedMethod, propertyName!, cancellationToken)
117117
.ConfigureAwait(false);
118118
editor.AddOnPropertyChanged(expression, onPropertyChangedStatement);
119119
},

PropertyChangedAnalyzers/Helpers/OnPropertyChanged.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ private static AnalysisResult IsMatch(IMethodSymbol method, Recursion recursion)
121121
}
122122

123123
// not using known symbol here as both jetbrains & mvvm cross defines a NotifyPropertyChangedInvocatorAttribute
124-
if (method.GetAttributes().TryFirst(x => x.AttributeClass.Name == "NotifyPropertyChangedInvocatorAttribute", out _))
124+
if (method.GetAttributes().TryFirst(x => x.AttributeClass?.Name == "NotifyPropertyChangedInvocatorAttribute", out _))
125125
{
126126
return AnalysisResult.Yes;
127127
}

PropertyChangedAnalyzers/Helpers/PropertyPath.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ internal static class PropertyPath
2020
internal static bool Uses(ExpressionSyntax assigned, ExpressionSyntax returned, SyntaxNodeAnalysisContext context, PooledSet<SyntaxNode>? visited = null)
2121
{
2222
using var assignedPath = MemberPath.PathWalker.Borrow(assigned);
23-
var containingType = context.ContainingSymbol.ContainingType;
23+
var containingType = context.ContainingSymbol!.ContainingType;
2424
if (UsedMemberWalker.Uses(returned, assignedPath, Search.TopLevel, containingType, context.SemanticModel, context.CancellationToken))
2525
{
2626
return true;
@@ -45,7 +45,7 @@ internal static bool Uses(ExpressionSyntax assigned, ExpressionSyntax returned,
4545

4646
internal static bool Uses(SyntaxNode scope, MemberPath.PathWalker memberPath, SyntaxNodeAnalysisContext context)
4747
{
48-
return UsedMemberWalker.Uses(scope, memberPath, Search.Recursive, context.ContainingSymbol.ContainingType, context.SemanticModel, context.CancellationToken);
48+
return UsedMemberWalker.Uses(scope, memberPath, Search.Recursive, context.ContainingSymbol!.ContainingType, context.SemanticModel, context.CancellationToken);
4949
}
5050

5151
private static bool Equals(MemberPath.PathWalker xWalker, MemberPath.PathWalker yWalker)

0 commit comments

Comments
 (0)