Пример #1
0
        private async Task <Document> ImplementNotifyPropertyChangedAsync(Document document, CompilationUnitSyntax root, SemanticModel model, IEnumerable <ExpandablePropertyInfo> properties, CancellationToken cancellationToken)
        {
            document = document.WithSyntaxRoot(CodeGeneration.ImplementINotifyPropertyChanged(root, model, properties, document.Project.Solution.Workspace));
            document = await Simplifier.ReduceAsync(document, Simplifier.Annotation, cancellationToken : cancellationToken).ConfigureAwait(false);

            document = await Formatter.FormatAsync(document, Formatter.Annotation, cancellationToken : cancellationToken).ConfigureAwait(false);

            return(document);
        }
Пример #2
0
        public static bool IsAvailable(IText text, TextSpan span)
        {
            var document = GetDocument(text);

            return(document.GetSyntaxRoot()
                   .DescendantNodes(span)
                   .OfType <PropertyDeclarationSyntax>()
                   .Where(p => CodeGeneration.IsExpandableProperty(p, document))
                   .Any());
        }
        public override SyntaxNode VisitPropertyDeclaration(PropertyDeclarationSyntax property)
        {
            if (span.IntersectsWith(property.Span) && CodeGeneration.IsExpandableProperty(property, document))
            {
                var annotation = new SyntaxAnnotation();
                annotations.Add(annotation);

                return(property.WithAdditionalAnnotations(annotation));
            }

            return(base.VisitPropertyDeclaration(property));
        }