Skip to content

Commit daab868

Browse files
committed
Fix warnings.
1 parent 55e7f17 commit daab868

25 files changed

Lines changed: 64 additions & 64 deletions

WpfAnalyzers/Analyzers/AttributeAnalyzer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ private static bool TryFindMethodRecursive(ITypeSymbol? type, string name, Func<
382382

383383
private static bool IsMarkupExtensionHandler(IMethodSymbol candidate)
384384
{
385-
return candidate is { ReturnsVoid: true, Parameters: { Length: 2 } } &&
385+
return candidate is { ReturnsVoid: true, Parameters.Length: 2 } &&
386386
candidate.Parameters.TryElementAt<IParameterSymbol>(0, out var parameter) &&
387387
parameter.Type == KnownSymbols.Object &&
388388
candidate.Parameters.TryElementAt<IParameterSymbol>(1, out parameter) &&
@@ -391,7 +391,7 @@ private static bool IsMarkupExtensionHandler(IMethodSymbol candidate)
391391

392392
private static bool IsTypeConverterHandler(IMethodSymbol candidate)
393393
{
394-
return candidate is { ReturnsVoid: true, Parameters: { Length: 2 } } &&
394+
return candidate is { ReturnsVoid: true, Parameters.Length: 2 } &&
395395
candidate.Parameters.TryElementAt<IParameterSymbol>(0, out var parameter) &&
396396
parameter.Type == KnownSymbols.Object &&
397397
candidate.Parameters.TryElementAt<IParameterSymbol>(1, out parameter) &&

WpfAnalyzers/Analyzers/ClrMethodDeclarationAnalyzer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ context.Node is MethodDeclarationSyntax methodDeclaration &&
3737
method.Parameters.TryElementAt(0, out var element) &&
3838
element.Type.IsAssignableTo(KnownSymbols.DependencyObject, context.SemanticModel.Compilation))
3939
{
40-
if (GetAttached.Match(methodDeclaration, context.SemanticModel, context.CancellationToken) is { GetValue: { Invocation: { } getValue }, Backing: { } backingGet })
40+
if (GetAttached.Match(methodDeclaration, context.SemanticModel, context.CancellationToken) is { GetValue.Invocation: { } getValue, Backing: { } backingGet })
4141
{
4242
if (backingGet.RegisteredName(context.SemanticModel, context.CancellationToken) is { Value: { } registeredName })
4343
{
@@ -147,7 +147,7 @@ argument.Expression is TypeOfExpressionSyntax typeOf &&
147147
}
148148
}
149149
else if (method.Parameters.TryElementAt(1, out var value) &&
150-
SetAttached.Match(methodDeclaration, context.SemanticModel, context.CancellationToken) is { SetValue: { Invocation: { } setValue }, Backing: { } backingSet })
150+
SetAttached.Match(methodDeclaration, context.SemanticModel, context.CancellationToken) is { SetValue.Invocation: { } setValue, Backing: { } backingSet })
151151
{
152152
if (backingSet.RegisteredName(context.SemanticModel, context.CancellationToken) is { Value: { } registeredName })
153153
{
@@ -253,7 +253,7 @@ private static bool TryGetSideEffect(BlockSyntax body, InvocationExpressionSynta
253253
case IfStatementSyntax { Condition: { } condition, Statement: ThrowStatementSyntax { }, Else: null }
254254
when NullCheck.IsNullCheck(condition, null, CancellationToken.None, out _):
255255
continue;
256-
case IfStatementSyntax { Condition: { } condition, Statement: BlockSyntax { Statements: { Count: 0 } }, Else: null }
256+
case IfStatementSyntax { Condition: { } condition, Statement: BlockSyntax { Statements.Count: 0 }, Else: null }
257257
when NullCheck.IsNullCheck(condition, null, CancellationToken.None, out _):
258258
continue;
259259
case IfStatementSyntax { Condition: { } condition, Statement: BlockSyntax { Statements: { Count: 1 } statements }, Else: null }

WpfAnalyzers/Analyzers/GetTemplateChildAnalyzer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ public override void Initialize(AnalysisContext context)
2626
private static void Handle(SyntaxNodeAnalysisContext context)
2727
{
2828
if (!context.IsExcludedFromAnalysis() &&
29-
context.Node is InvocationExpressionSyntax { ArgumentList: { Arguments: { Count: 1 } arguments } } invocation &&
29+
context.Node is InvocationExpressionSyntax { ArgumentList.Arguments: { Count: 1 } arguments } invocation &&
3030
invocation.TryGetMethodName(out var name) &&
3131
name == "GetTemplateChild" &&
3232
arguments.TrySingle(out var argument) &&
3333
argument.Expression is { } expression &&
3434
context.SemanticModel.TryGetConstantValue<string>(expression, context.CancellationToken, out var partName) &&
35-
context.ContainingSymbol is IMethodSymbol { Name: "OnApplyTemplate", IsOverride: true, Parameters: { Length: 0 } } containingMethod)
35+
context.ContainingSymbol is IMethodSymbol { Name: "OnApplyTemplate", IsOverride: true, Parameters.Length: 0 } containingMethod)
3636
{
3737
if (FindAttribute(containingMethod.ContainingType, partName) is { } attribute)
3838
{

WpfAnalyzers/Analyzers/RoutedEventEventDeclarationAnalyzer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,11 @@ internal static bool TryGetRegistration(TypeDeclarationSyntax typeDeclaration, s
173173
using var walker = Borrow(() => new BackingFieldWalker());
174174
walker.memberName = memberName;
175175
walker.Visit(typeDeclaration);
176-
if (walker.backingField is { Initializer: { Value: InvocationExpressionSyntax fieldRegistration } })
176+
if (walker.backingField is { Initializer.Value: InvocationExpressionSyntax fieldRegistration })
177177
{
178178
registration = fieldRegistration;
179179
}
180-
else if (walker.backingProperty is { Initializer: { Value: InvocationExpressionSyntax propertyRegistration } })
180+
else if (walker.backingProperty is { Initializer.Value: InvocationExpressionSyntax propertyRegistration })
181181
{
182182
registration = propertyRegistration;
183183
}
@@ -186,7 +186,7 @@ internal static bool TryGetRegistration(TypeDeclarationSyntax typeDeclaration, s
186186
return false;
187187
}
188188

189-
return registration is { ArgumentList: { Arguments: { Count: 4 } } } &&
189+
return registration is { ArgumentList.Arguments.Count: 4 } &&
190190
registration.TryGetMethodName(out var name) &&
191191
name == "RegisterRoutedEvent";
192192
}

WpfAnalyzers/CodeFixes/AttachedPropertyBrowsableForTypeArgumentFix.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ protected override async Task RegisterCodeFixesAsync(DocumentEditorCodeFixContex
2626
{
2727
if (syntaxRoot is { } &&
2828
syntaxRoot.TryFindNode(diagnostic, out AttributeArgumentSyntax? argument) &&
29-
argument is { Expression: TypeOfExpressionSyntax { Type: { } type }, Parent: AttributeArgumentListSyntax { Parent: AttributeSyntax { Parent: AttributeListSyntax { Parent: MethodDeclarationSyntax { ParameterList: { Parameters: { Count: 1 } parameters } } } } } } &&
29+
argument is { Expression: TypeOfExpressionSyntax { Type: { } type }, Parent: AttributeArgumentListSyntax { Parent: AttributeSyntax { Parent: AttributeListSyntax { Parent: MethodDeclarationSyntax { ParameterList.Parameters: { Count: 1 } parameters } } } } } &&
3030
parameters[0] is { Type: { } toType })
3131
{
3232
context.RegisterCodeFix(

WpfAnalyzers/CodeFixes/ComponentResourceKeyFix.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ protected override async Task RegisterCodeFixesAsync(DocumentEditorCodeFixContex
2727
if (syntaxRoot is { } &&
2828
diagnostic.Id == Descriptors.WPF0140UseContainingTypeComponentResourceKey.Id &&
2929
syntaxRoot.TryFindNodeOrAncestor(diagnostic, out ObjectCreationExpressionSyntax? objectCreation) &&
30-
objectCreation.ArgumentList is { Arguments: { Count: 0 } } argumentList &&
30+
objectCreation.ArgumentList is { Arguments.Count: 0 } argumentList &&
3131
diagnostic.Properties.TryGetValue(nameof(ArgumentListSyntax), out var argumentListString))
3232
{
3333
context.RegisterCodeFix(

WpfAnalyzers/CodeFixes/ConvertToLambdaFix.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,17 +133,17 @@ parameters[1] is { } parameter2 &&
133133
{
134134
return declaration switch
135135
{
136-
{ ExpressionBody: { Expression: { } expression } } => expression,
137-
{ Body: { Statements: { Count: 1 } statements } } =>
136+
{ ExpressionBody.Expression: { } expression } => expression,
137+
{ Body.Statements: { Count: 1 } statements } =>
138138
statements[0] switch
139139
{
140140
ReturnStatementSyntax { Expression: { } expression } => expression,
141141
ExpressionStatementSyntax { Expression: { } expression } => expression,
142142
_ => null,
143143
},
144-
{ Body: { Statements: { Count: 2 } statements } }
145-
when statements[0] is LocalDeclarationStatementSyntax { Declaration: { Variables: { Count: 1 } variables } } &&
146-
variables[0] is { Identifier: { } identifier, Initializer: { Value: CastExpressionSyntax cast } }
144+
{ Body.Statements: { Count: 2 } statements }
145+
when statements[0] is LocalDeclarationStatementSyntax { Declaration.Variables: { Count: 1 } variables } &&
146+
variables[0] is { Identifier: { } identifier, Initializer.Value: CastExpressionSyntax cast }
147147
=>
148148
statements[1] switch
149149
{

WpfAnalyzers/CodeFixes/ImplementValueConverterFix.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ private static bool HasInterface(ClassDeclarationSyntax classDeclaration, Qualif
100100
switch (typeSyntax.Type)
101101
{
102102
case SimpleNameSyntax name when name.Identifier.ValueText == type.Type:
103-
case QualifiedNameSyntax { Right: { Identifier: { } right } } when right.ValueText == type.Type:
103+
case QualifiedNameSyntax { Right.Identifier: { } right } when right.ValueText == type.Type:
104104
return true;
105105
}
106106
}

WpfAnalyzers/CodeFixes/UseRegisteredTypeFix.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ typeText is { } &&
4646
nameof(UseRegisteredTypeFix),
4747
diagnostic);
4848
}
49-
else if (typeSyntax.Parent is MethodDeclarationSyntax { ParameterList: { Parameters: { Count: 1 } } } method &&
49+
else if (typeSyntax.Parent is MethodDeclarationSyntax { ParameterList.Parameters.Count: 1 } method &&
5050
method.Identifier.ValueText.StartsWith("Get", StringComparison.Ordinal))
5151
{
5252
context.RegisterCodeFix(

WpfAnalyzers/CodeFixes/UseSetCurrentValueFix.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ semanticModel is { } &&
4747
}
4848
else if (syntaxRoot is { } &&
4949
syntaxRoot.TryFindNodeOrAncestor(diagnostic, out InvocationExpressionSyntax? setValue) &&
50-
Name(setValue) is { Identifier: { ValueText: "SetValue" } } name)
50+
Name(setValue) is { Identifier.ValueText: "SetValue" } name)
5151
{
5252
context.RegisterCodeFix(
5353
setValue.ToString().Replace("SetValue", "SetCurrentValue"),

0 commit comments

Comments
 (0)