예제 #1
0
        private static void Main(string[] args)
        {
            if (args == null || args.Length == 0)
            {
#if DEBUG
                args = new string[] { @"..\..\..\.." };
#else
                args = new string[] { Environment.CurrentDirectory };
#endif
            }

            string dirPath = args[0];

            RefactoringInfo[] refactorings = RefactoringInfo
                                             .LoadFromFile(Path.Combine(dirPath, @"Refactorings\Refactorings.xml"))
                                             .OrderBy(f => f.Identifier, StringComparer.InvariantCulture)
                                             .ToArray();

            var writer = new CodeFileWriter();

            var refactoringIdentifiersGenerator = new RefactoringIdentifiersGenerator();
            writer.SaveCode(
                Path.Combine(dirPath, @"Refactorings\RefactoringIdentifiers.cs"),
                refactoringIdentifiersGenerator.Generate(refactorings));

            var optionsPagePropertiesGenerator = new OptionsPagePropertiesGenerator();
            writer.SaveCode(
                Path.Combine(dirPath, @"VisualStudio.Common\RefactoringsOptionsPage.Generated.cs"),
                optionsPagePropertiesGenerator.Generate(refactorings));

#if DEBUG
            Console.WriteLine("DONE");
            Console.ReadKey();
#endif
        }
 private PropertyDeclarationSyntax CreateRefactoringProperty(RefactoringInfo refactoring)
 {
     return(PropertyDeclaration(BoolType(), refactoring.Identifier)
            .WithAttributeLists(
                AttributeList(Attribute("Category", IdentifierName("RefactoringCategory"))),
                AttributeList(Attribute("DisplayName", StringLiteralExpression(refactoring.Title))),
                AttributeList(Attribute("Description", StringLiteralExpression(CreateDescription(refactoring)))),
                AttributeList(Attribute("TypeConverter", TypeOfExpression(IdentifierName("EnabledDisabledConverter")))))
            .WithModifiers(Modifiers.Public())
            .WithAccessorList(
                AutoGetter(),
                AutoSetter()));
 }
        private static string CreateDescription(RefactoringInfo refactoring)
        {
            string s = "";

            if (refactoring.Syntaxes.Count > 0)
            {
                s = "Syntax: " + string.Join(", ", refactoring.Syntaxes.Select(f => f.Name));
            }

            if (!string.IsNullOrEmpty(refactoring.Scope))
            {
                if (!string.IsNullOrEmpty(s))
                {
                    s += "\r\n";
                }

                s += "Scope: " + refactoring.Scope;
            }

            return(s);
        }
예제 #4
0
        private static void Main(string[] args)
        {
            if (args == null || args.Length == 0)
            {
#if DEBUG
                args = new string[] { @"..\..\..\.." };
#else
                args = new string[] { Environment.CurrentDirectory };
#endif
            }

            string dirPath = args[0];

            SortRefactoringsInFile(Path.Combine(dirPath, @"Refactorings\Refactorings.xml"));

            var generator = new Generator();

            foreach (RefactoringInfo refactoring in RefactoringInfo
                     .LoadFromFile(Path.Combine(dirPath, @"Refactorings\Refactorings.xml"))
                     .OrderBy(f => f.Identifier, StringComparer.InvariantCulture))
            {
                generator.Refactorings.Add(refactoring);
            }

            Console.WriteLine($"number of refactorings: {generator.Refactorings.Count}");

            foreach (AnalyzerInfo analyzer in AnalyzerInfo
                     .LoadFromFile(Path.Combine(dirPath, @"Analyzers\Analyzers.xml"))
                     .OrderBy(f => f.Id, StringComparer.InvariantCulture))
            {
                generator.Analyzers.Add(analyzer);
            }

            Console.WriteLine($"number of analyzers: {generator.Analyzers.Count}");

            var writer = new CodeFileWriter();

            writer.SaveCode(
                Path.Combine(dirPath, @"Analyzers\Analyzers.xml"),
                generator.CreateAnalyzersXml());

            writer.SaveCode(
                Path.Combine(dirPath, @"VisualStudio\description.txt"),
                generator.CreateAnalyzersExtensionDescription());

            writer.SaveCode(
                Path.Combine(dirPath, @"VisualStudio.Refactorings\description.txt"),
                generator.CreateRefactoringsExtensionDescription());

            writer.SaveCode(
                Path.Combine(Path.GetDirectoryName(dirPath), @"README.md"),
                generator.CreateReadMeMarkDown());

            foreach (string imagePath in generator.FindMissingImages(Path.Combine(Path.GetDirectoryName(dirPath), @"images\refactorings")))
            {
                Console.WriteLine($"missing image: {imagePath}");
            }

            writer.SaveCode(
                Path.Combine(dirPath, @"Refactorings\README.md"),
                generator.CreateRefactoringsMarkDown());

            writer.SaveCode(
                Path.Combine(dirPath, @"Analyzers\README.md"),
                generator.CreateAnalyzersMarkDown());

            writer.SaveCode(
                Path.Combine(dirPath, @"Analyzers\AnalyzersByCategory.md"),
                generator.CreateAnalyzersByCategoryMarkDown());

#if DEBUG
            Console.WriteLine("DONE");
            Console.ReadKey();
#endif
        }
예제 #5
0
        private static string CreateImageMarkDown(RefactoringInfo info, string fileName)
        {
            string url = "../../images/refactorings/" + fileName + ".png";

            return("![" + info.Title + "](" + url + ")");
        }