Пример #1
0
        internal static IMethodInfoProvider Create(SyntaxNodeWrapper n)
        {
            var syntax = n.Node as MethodDeclarationSyntax;

            if (syntax != null)
            {
                return(new RoslynMethodInfoProvider(syntax));
            }

            var syntax2 = n.Node as PropertyDeclarationSyntax;

            if (syntax2 != null)
            {
                return(new RoslynMethodInfoProviderForProperty(syntax2, n.MethodType));
            }

            throw new InvalidOperationException("Please define info provider for the syntax node.");
        }
Пример #2
0
        private static bool NeedToDeleteWholeProperty(RoslynMethodLister methooLister, DeletionEvaluator evaluator, SyntaxNodeWrapper currentMethodNodeFromNewRoot, MethodType methodType)
        {
            var prop = (PropertyDeclarationSyntax)currentMethodNodeFromNewRoot.Node;

            if (prop.HasGetter() && prop.HasSetter())
            {
                MethodType otherAccessorType = methodType == MethodType.PropertyGetter ? MethodType.PropertySetter : MethodType.PropertyGetter;
                var        otherAccessorStr  = methooLister.GetMethodDeclarationString(new SyntaxNodeWrapper {
                    MethodType = otherAccessorType, Node = currentMethodNodeFromNewRoot.Node
                });
                bool needToDelete = evaluator.NeedToDeleteMethod(otherAccessorStr);
                return(needToDelete);
            }
            return(true);
        }
Пример #3
0
 public string GetMethodDeclarationString(SyntaxNodeWrapper m)
 {
     return(Stringifier.GetMethodDeclarationString(RoslynMethodInfoProviderFactory.Create(m)));
 }