예제 #1
0
        public static void CreateStubFiles(ProjectKind kind, string target, string analyzer, IList <CheckData> checks, Dictionary <string, IEnumerable <string> > categories)
        {
            if (kind == ProjectKind.Setup || kind == ProjectKind.NuGet)
            {
                return;
            }

            foreach (var check in checks)
            {
                if (kind == ProjectKind.Core)
                {
                    Utilities.CreateFile(CodeTemplates.GenerateAnalyzer(analyzer, check),
                                         target,
                                         CodeTemplates.GenerateAnalyzerFileName(check));
                    Utilities.CreateFile(CodeTemplates.GenerateCodeFix(analyzer, check),
                                         target,
                                         CodeTemplates.GenerateCodeFixFileName(check));
                    Utilities.CreateFile(CodeTemplates.GenerateCategory(analyzer, categories[analyzer]),
                                         target,
                                         CodeTemplates.CategoryFileName);
                }
                else if (kind == ProjectKind.CSharp)
                {
                    Utilities.CreateFile(CodeTemplates.GenerateCSharpAnalyzer(analyzer, check),
                                         target,
                                         CodeTemplates.GenerateCSharpAnalyzerFileName(check));
                    Utilities.CreateFile(CodeTemplates.GenerateCSharpCodeFix(analyzer, check),
                                         target,
                                         CodeTemplates.GenerateCSharpCodeFixFileName(check));
                }
                else if (kind == ProjectKind.VisualBasic)
                {
                    Utilities.CreateFile(CodeTemplates.GenerateBasicAnalyzer(analyzer, check),
                                         target,
                                         CodeTemplates.GenerateBasicAnalyzerFileName(check));
                    Utilities.CreateFile(CodeTemplates.GenerateBasicCodeFix(analyzer, check),
                                         target,
                                         CodeTemplates.GenerateBasicCodeFixFileName(check));
                }
                else if (kind == ProjectKind.UnitTests)
                {
                    Utilities.CreateFile(CodeTemplates.GenerateAnalyzerTests(analyzer, check),
                                         target,
                                         CodeTemplates.GenerateAnalyzerTestsFileName(check));
                    Utilities.CreateFile(CodeTemplates.GenerateCodeFixTests(analyzer, check),
                                         target,
                                         CodeTemplates.GenerateCodeFixTestsFileName(check));
                }
            }
        }
예제 #2
0
        private static void AddNewChecksToCoreProject(string analyzer, List <CheckData> checks)
        {
            var analyzerFullName = analyzer + ".Analyzers";
            var analyzerDir      = Path.Combine(_sourceFilesDirectory, analyzerFullName, "Core");
            var coreProjFile     = Path.Combine(analyzerDir, analyzerFullName + ".csproj");

            foreach (var check in checks)
            {
                AddCompileItemsToProjectFile(coreProjFile, ProjectKind.Core, check);

                Utilities.CreateFile(CodeTemplates.GenerateAnalyzer(analyzer, check),
                                     analyzerDir,
                                     CodeTemplates.GenerateAnalyzerFileName(check));

                Utilities.CreateFile(CodeTemplates.GenerateCodeFix(analyzer, check),
                                     analyzerDir,
                                     CodeTemplates.GenerateCodeFixFileName(check));
            }
        }