Skip to content
Merged
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 @@ -78,6 +78,28 @@ private static void AnalyzeObjectCreation(SyntaxNodeAnalysisContext context)
var usingStatement = variableDeclaration?.Parent as UsingStatementSyntax;
if (usingStatement != null) return;
statement = variableDeclaration.Parent as LocalDeclarationStatementSyntax;
if (statement != null)
{
//Check inline using
var isUsing = false;
var isSemicolon = false;
var firstToken = statement.GetFirstToken();
if (firstToken != null)
{
isUsing = firstToken.Text == "using";
}

var lastToken = statement.GetLastToken();
if (lastToken != null)
{
isSemicolon = lastToken.Text == ";";
}

var isVariableDeclaration = statement.ChildNodes().First() is VariableDeclarationSyntax;

if (isUsing && isVariableDeclaration && isSemicolon) return;
}

if ((statement?.FirstAncestorOrSelf<MethodDeclarationSyntax>()) == null) return;
}
else if (topSyntaxNode.Parent.IsAnyKind(SyntaxKind.SimpleLambdaExpression, SyntaxKind.ParenthesizedLambdaExpression))
Expand Down