提交 87c7a6b5 编写于 作者: J JieCarolHu

fix PR comments

上级 363e2998
......@@ -134,21 +134,14 @@ protected override bool TryAnalyzeVariableDeclaration(TypeSyntax typeName, Seman
return true;
}
}
else if (typeName.Parent is ForEachStatementSyntax foreachStatement)
else if (typeName.Parent is ForEachStatementSyntax foreachStatement &&
IsExpressionSameAfterVarConversion(foreachStatement.Expression, semanticModel, cancellationToken))
{
if (IsExpressionSameAfterVarConversion(foreachStatement.Expression, semanticModel, cancellationToken))
var foreachStatementInfo = semanticModel.GetForEachStatementInfo(foreachStatement);
if (foreachStatementInfo.ElementConversion.IsIdentityOrImplicitReference())
{
var foreachStatementInfo = semanticModel.GetForEachStatementInfo(foreachStatement);
if (foreachStatementInfo.ElementConversion.IsIdentityOrImplicitReference())
{
issueSpan = candidateIssueSpan;
return true;
}
}
else
{
issueSpan = default;
return false;
issueSpan = candidateIssueSpan;
return true;
}
}
else if (typeName.Parent is DeclarationExpressionSyntax declarationExpression &&
......@@ -265,7 +258,7 @@ protected override bool TryAnalyzeVariableDeclaration(TypeSyntax typeName, Seman
return declaredType.Equals(initializerType);
}
private bool IsExpressionSameAfterVarConversion(
private static bool IsExpressionSameAfterVarConversion(
ExpressionSyntax expression,
SemanticModel semanticModel,
CancellationToken cancellationToken)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册