예제 #1
0
            private async Task <bool> TryInitializeAsync(
                TService service,
                SemanticDocument document,
                SyntaxNode node,
                CancellationToken cancellationToken)
            {
                if (service.IsConstructorInitializerGeneration(document, node, cancellationToken))
                {
                    if (!await TryInitializeConstructorInitializerGenerationAsync(service, document, node, cancellationToken).ConfigureAwait(false))
                    {
                        return(false);
                    }
                }
                else if (service.IsSimpleNameGeneration(document, node, cancellationToken))
                {
                    if (!await TryInitializeSimpleNameGenerationAsync(service, document, node, cancellationToken).ConfigureAwait(false))
                    {
                        return(false);
                    }
                }
                else if (service.IsClassDeclarationGeneration(document, node, cancellationToken))
                {
                    if (!await TryInitializeClassDeclarationGenerationAsync(service, document, node, cancellationToken).ConfigureAwait(false))
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }

                if (!CodeGenerator.CanAdd(document.Project.Solution, this.TypeToGenerateIn, cancellationToken))
                {
                    return(false);
                }

                this.ParameterTypes = this.ParameterTypes.IsDefault
                    ? GetParameterTypes(service, document, cancellationToken)
                    : this.ParameterTypes;
                this.ParameterRefKinds = this.ParameterRefKinds ?? this.Arguments.Select(service.GetRefKind).ToList();

                return(!ClashesWithExistingConstructor(document, cancellationToken));
            }