Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary discards #72925

Merged
merged 1 commit into from
Apr 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static bool CanRemoveParenthesesHelper(
ExpressionSyntax parentExpression;
switch (parenthesizedExpression.Parent)
{
case ConditionalExpressionSyntax _:
case ConditionalExpressionSyntax:
// If our parent is a conditional, then only remove parens if the inner
// expression is a primary. i.e. it's ok to remove any of the following:
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ private LocalizableString GetMessage(
// IDE0052 has a different message for method and property symbols.
switch (member)
{
case IMethodSymbol _:
case IMethodSymbol:
messageFormat = AnalyzersResources.Private_method_0_can_be_removed_as_it_is_never_invoked;
break;

Expand Down Expand Up @@ -663,8 +663,7 @@ private void AddDebuggerDisplayAttributeArguments(INamedTypeSymbol namedTypeSymb
AddDebuggerDisplayAttributeArguments(nestedType, builder);
break;

case IPropertySymbol _:
case IFieldSymbol _:
case IPropertySymbol or IFieldSymbol:
AddDebuggerDisplayAttributeArgumentsCore(member, builder);
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,10 @@ protected override bool IsCandidate(SyntaxNode node, SyntaxToken token, Diagnost
{
switch (node)
{
case QualifiedNameSyntax _:
case QualifiedNameSyntax or MemberAccessExpressionSyntax:
return true;
case SimpleNameSyntax simple:
return !simple.IsParentKind(SyntaxKind.QualifiedName);
case MemberAccessExpressionSyntax _:
return true;
}

return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ private static bool CheckTopLevel(SyntaxNode node, TextSpan span)
break;
}

case GlobalStatementSyntax _:
case GlobalStatementSyntax:
return true;
case ConstructorInitializerSyntax constructorInitializer:
return constructorInitializer.ContainsInArgument(span);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ protected override NullableFlowState GetNullabilityAnalysis(SemanticModel semant
case ILocalSymbol { HasConstantValue: true }: return default;

// Symbols with useful quick info
case IFieldSymbol _:
case ILocalSymbol _:
case IParameterSymbol _:
case IPropertySymbol _:
case IRangeVariableSymbol _:
case IFieldSymbol:
case ILocalSymbol:
case IParameterSymbol:
case IPropertySymbol:
case IRangeVariableSymbol:
break;

default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,8 @@ public bool TryGetTextUndoHistory(Workspace editorWorkspace, ITextBuffer textBuf

break;

case MiscellaneousFilesWorkspace _:

case MiscellaneousFilesWorkspace:
// Nothing to do in this case: textBuffer is correct!

break;

default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,11 @@ private static bool TryClassifySymbol(
token = name.GetNameToken();
classifiedSpan = new ClassifiedSpan(token.Span, GetClassificationForMethod(methodSymbol));
return true;
case IPropertySymbol _:
case IPropertySymbol:
token = name.GetNameToken();
classifiedSpan = new ClassifiedSpan(token.Span, ClassificationTypeNames.PropertyName);
return true;
case IEventSymbol _:
case IEventSymbol:
token = name.GetNameToken();
classifiedSpan = new ClassifiedSpan(token.Span, ClassificationTypeNames.EventName);
return true;
Expand All @@ -229,7 +229,7 @@ private static bool TryClassifySymbol(
token = name.GetNameToken();
classifiedSpan = new ClassifiedSpan(token.Span, GetClassificationForLocal(localSymbol));
return true;
case ILabelSymbol _:
case ILabelSymbol:
token = name.GetNameToken();
classifiedSpan = new ClassifiedSpan(token.Span, ClassificationTypeNames.LabelName);
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ public FindLiteralsSearchEngine(
_longValue = BitConverter.DoubleToInt64Bits(f);
_searchKind = SearchKind.NumericLiterals;
break;
case decimal _: // unsupported
case decimal: // unsupported
_searchKind = SearchKind.None;
break;
case char _:
case char:
_longValue = IntegerUtilities.ToInt64(value);
_searchKind = SearchKind.CharacterLiterals;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -660,9 +660,9 @@ SymbolUsageInfo GetSymbolUsageInfoCommon()
var operation = semanticModel.GetOperation(node, cancellationToken);
switch (operation?.Parent)
{
case INameOfOperation _:
case ITypeOfOperation _:
case ISizeOfOperation _:
case INameOfOperation:
case ITypeOfOperation:
case ISizeOfOperation:
return SymbolUsageInfo.Create(ValueUsageInfo.Name);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -739,16 +739,16 @@ public static OperatorPrecedence GetOperatorPrecedence(this PatternSyntax patter
{
switch (pattern)
{
case ConstantPatternSyntax _:
case DiscardPatternSyntax _:
case DeclarationPatternSyntax _:
case RecursivePatternSyntax _:
case TypePatternSyntax _:
case VarPatternSyntax _:
case ConstantPatternSyntax:
case DiscardPatternSyntax:
case DeclarationPatternSyntax:
case RecursivePatternSyntax:
case TypePatternSyntax:
case VarPatternSyntax:
return OperatorPrecedence.Primary;

case UnaryPatternSyntax _:
case RelationalPatternSyntax _:
case UnaryPatternSyntax:
case RelationalPatternSyntax:
return OperatorPrecedence.Unary;

case BinaryPatternSyntax binaryPattern:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public SyntaxNode GetImportContainer(SyntaxNode root, SyntaxNode? contextLocatio

switch (import)
{
case TExternSyntax _:
case TExternSyntax:
return externContainer;
case TUsingOrAliasSyntax u:
if (IsAlias(u))
Expand Down
Loading