提交 6ef27ac3 编写于 作者: V Victor Z

Fixed review notes.

上级 4fcd5a09
......@@ -282,8 +282,8 @@ protected override IMethodSymbol GetCurrentConstructor(SemanticModel semanticMod
protected override IMethodSymbol GetDelegatedConstructor(SemanticModel semanticModel, IMethodSymbol constructor, CancellationToken cancellationToken)
{
if (constructor.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken) is ConstructorDeclarationSyntax constructorDeclarationSyntax
&& constructorDeclarationSyntax.Initializer.IsKind(SyntaxKind.ThisConstructorInitializer))
if (constructor.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken) is ConstructorDeclarationSyntax constructorDeclarationSyntax &&
constructorDeclarationSyntax.Initializer.IsKind(SyntaxKind.ThisConstructorInitializer))
{
return semanticModel.GetSymbolInfo(constructorDeclarationSyntax.Initializer, cancellationToken).Symbol as IMethodSymbol;
}
......
......@@ -29,15 +29,15 @@ internal abstract partial class AbstractGenerateConstructorService<TService, TAr
protected bool CanDelegeteThisConstructor(State state, SemanticDocument document, IMethodSymbol delegatedConstructor, CancellationToken cancellationToken = default)
{
var constructorsCount = delegatedConstructor.ContainingType.Constructors.Length;
var currentConstructor = GetCurrentConstructor(document.SemanticModel, state.Token, cancellationToken);
if (currentConstructor == delegatedConstructor)
if (currentConstructor.Equals(delegatedConstructor))
{
return false;
}
// We need ensure that delegating constructor won't cause circular dependency.
// The chain of dependency can not exceed the number for constructors
var constructorsCount = delegatedConstructor.ContainingType.Constructors.Count(c => !c.IsStaticConstructor());
for (var i = 0; i < constructorsCount; i++)
{
delegatedConstructor = GetDelegatedConstructor(document.SemanticModel, delegatedConstructor, cancellationToken);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册