Exemplo n.º 1
0
        private void DeleteMethodsIfNeeded(
            IEnumerable <string> typeMethods,
            DeletionEvaluator deletionEvaluator,
            IDocument document,
            ref CompilationUnitSyntax newDocumentRoot,
            RoslynMethodLister methodLister,
            ref int methodsDeleted)
        {
            if (typeMethods == null || _options.Act == Act.DeleteWholeTypesOnly)
            {
                return;
            }

            foreach (var method in typeMethods)
            {
                bool needToDelete = deletionEvaluator.NeedToDeleteMethod(method);
                if (needToDelete)
                {
                    methodsDeleted++;
                    if (_options.Act == Act.Delete && !_options.DryRun)
                    {
                        // Transform the syntax tree of the document and get the root of the new tree
                        newDocumentRoot = DeleteMethod(newDocumentRoot ?? (CompilationUnitSyntax)document.GetSyntaxRoot(), methodLister, deletionEvaluator, method);
                    }
                }
                else if (!deletionEvaluator.MethodFoundInWeavedLibs(method) && _options.Verbose)
                {
                    _logger.Log(string.Format("not found in dlls, skipping {0}", method), displayTime: false);
                }
                if (needToDelete || _options.Verbose)
                {
                    _logger.Log(string.Format("{0} {1}", needToDelete ? "--" : "++", method), displayTime: false);
                }
            }
        }
Exemplo n.º 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);
        }