Skip to content

Commit

Permalink
Refactor NUD analyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
maroontress-tomohisa committed Jan 30, 2025
1 parent 67625d2 commit 948e6f8
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ static bool IsNewOperatorUsed(ExpressionSyntax s)
|| s is ImplicitObjectCreationExpressionSyntax;

static ExpressionSyntax? ToNewExpr(VariableDeclaratorSyntax s)
=> ((s.Initializer?.Value is { } value)
=> ((s.Initializer?.Value is {} value)
&& IsNewOperatorUsed(value))
? value
: null;
Expand All @@ -119,7 +119,7 @@ static bool CanUseUsingPotentially(
IdentifierNameSyntax s,
SeparatedSyntaxList<VariableDeclaratorSyntax> variables,
Func<SyntaxNode, TypeInfo> toTypeInfo)
=> s.Identifier.Text is not "var"
=> !s.IsVar
/* Explicit declaration */
? !variables.All(i => ToNewExpr(i) is not null)
|| !IsTrulyDisposable(toTypeInfo(s))
Expand Down

0 comments on commit 948e6f8

Please sign in to comment.