Skip to content

Commit de25315

Browse files
committed
Final fixes after rebasing
1 parent de3dbee commit de25315

4 files changed

Lines changed: 13 additions & 16 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1130CodeFixProvider.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,7 @@ private static ImmutableArray<string> GetEqualsArgumentList(SemanticModel semant
209209
private static ImmutableArray<string> GetMemberReturnTypeArgumentList(SemanticModel semanticModel, AnonymousMethodExpressionSyntax anonymousMethod)
210210
{
211211
var enclosingSymbol = semanticModel.GetEnclosingSymbol(anonymousMethod.Parent.SpanStart);
212-
var returnType = ((IMethodSymbol)enclosingSymbol).ReturnType as INamedTypeSymbol;
213-
return (returnType == null) ? ImmutableArray<string>.Empty : returnType.DelegateInvokeMethod.Parameters.Select(ps => ps.Name).ToImmutableArray();
212+
return !(((IMethodSymbol)enclosingSymbol).ReturnType is INamedTypeSymbol returnType) ? ImmutableArray<string>.Empty : returnType.DelegateInvokeMethod.Parameters.Select(ps => ps.Name).ToImmutableArray();
214213
}
215214

216215
private static List<ParameterSyntax> GenerateUniqueParameterNames(SemanticModel semanticModel, AnonymousMethodExpressionSyntax anonymousMethod, ImmutableArray<string> argumentNames)

StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SyntaxFactsEx.cs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,17 @@ internal static class SyntaxFactsEx
1616

1717
static SyntaxFactsEx()
1818
{
19-
Func<SyntaxNode, string> fallbackAccessor =
20-
syntax =>
19+
string FallbackAccessor(SyntaxNode syntax)
20+
{
21+
if (syntax == null)
2122
{
22-
if (syntax == null)
23-
{
24-
// Unlike an extension method which would throw ArgumentNullException here, the light-up
25-
// behavior needs to match behavior of the underlying property.
26-
throw new NullReferenceException();
27-
}
23+
// Unlike an extension method which would throw ArgumentNullException here, the light-up
24+
// behavior needs to match behavior of the underlying property.
25+
throw new NullReferenceException();
26+
}
2827

29-
return null;
30-
};
28+
return null;
29+
}
3130

3231
var tryGetInferredMemberNameMethod = typeof(SyntaxFacts).GetTypeInfo().GetDeclaredMethod(nameof(TryGetInferredMemberName));
3332
if (tryGetInferredMemberNameMethod is object)
@@ -41,7 +40,7 @@ static SyntaxFactsEx()
4140
}
4241
else
4342
{
44-
TryGetInferredMemberNameAccessor = fallbackAccessor;
43+
TryGetInferredMemberNameAccessor = FallbackAccessor;
4544
}
4645

4746
var isReservedTupleElementNameMethod = typeof(SyntaxFacts).GetTypeInfo().GetDeclaredMethod(nameof(IsReservedTupleElementName));

StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1316TupleElementNamesShouldUseCorrectCasing.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ private static void CheckName(SyntaxNodeAnalysisContext context, StyleCopSetting
108108
{
109109
var firstCharacterIsLower = char.IsLower(tupleElementName[0]);
110110

111-
bool reportDiagnostic = false;
111+
bool reportDiagnostic;
112112
string fixedName;
113113

114114
switch (settings.NamingRules.TupleElementNameCasing)

StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1142ReferToTupleElementsByName.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ private static void HandleSimpleMemberAccessExpression(SyntaxNodeAnalysisContext
5151

5252
var memberAccessExpression = (MemberAccessExpressionSyntax)context.Node;
5353

54-
var fieldSymbol = context.SemanticModel.GetSymbolInfo(memberAccessExpression).Symbol as IFieldSymbol;
55-
if (fieldSymbol == null)
54+
if (!(context.SemanticModel.GetSymbolInfo(memberAccessExpression).Symbol is IFieldSymbol fieldSymbol))
5655
{
5756
return;
5857
}

0 commit comments

Comments
 (0)