Пример #1
0
        public async Task <InconsistentAccessibilityInfo> GetInconsistentAccessibilityInfoAsync(Document document, Diagnostic diagnostic, CancellationToken cancellationToken)
        {
            var result     = new InconsistentAccessibilityInfo();
            var syntaxRoot = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);

            var indexerThatRaisedError = syntaxRoot.FindNode(diagnostic.Location.SourceSpan).AncestorsAndSelf().OfType <IndexerDeclarationSyntax>().FirstOrDefault();

            if (indexerThatRaisedError != null)
            {
                var parameterType = ExtractParameterTypeFromDiagnosticMessage(diagnostic);

                result.TypeToChangeAccessibility = indexerThatRaisedError.ParameterList.Parameters.FindTypeInParametersList(parameterType);
                result.CodeActionMessage         = string.Format(CodeActionMessage.ToString(), result.TypeToChangeAccessibility, indexerThatRaisedError.ParameterList.Parameters.ToString());
                result.NewAccessibilityModifiers = indexerThatRaisedError.Modifiers.CloneAccessibilityModifiers();
            }

            return(result);
        }