private PluginInspector CreatePluginInspector(Common.ILogger logger)
        {
            string          tempDir   = TestUtils.CreateTestDirectory(this.TestContext, "pluginInsp");
            PluginInspector inspector = new PluginInspector(logger, tempDir);

            return(inspector);
        }
        private PluginInspector CreatePluginInspector(Common.ILogger logger)
        {
            string tempDir = TestUtils.CreateTestDirectory(this.TestContext, "pluginInsp");
            PluginInspector inspector = new PluginInspector(logger, tempDir);

            return inspector;
        }
        public void RoslynPlugin_GenerateForValidAnalyzer_Succeeds()
        {
            // Arrange
            TestLogger      logger    = new TestLogger();
            string          outputDir = TestUtils.CreateTestDirectory(this.TestContext, ".out");
            PluginInspector inspector = CreatePluginInspector(logger);

            // Create a valid analyzer package
            ExampleAnalyzer1.CSharpAnalyzer analyzer = new ExampleAnalyzer1.CSharpAnalyzer();

            string          packageId       = "analyzer1.id1";
            string          localNuGetDir   = TestUtils.CreateTestDirectory(this.TestContext, ".localNuGet");
            IPackageManager localNuGetStore = CreatePackageManager(localNuGetDir);

            AddPackage(localNuGetStore, packageId, "1.0", analyzer.GetType().Assembly.Location);

            // Act
            NuGetPackageHandler     nuGetHandler = new NuGetPackageHandler(localNuGetDir, logger);
            AnalyzerPluginGenerator apg          = new AnalyzerPluginGenerator(nuGetHandler, logger);
            bool result = apg.Generate(new Roslyn.CommandLine.NuGetReference(packageId, new SemanticVersion("1.0")), "cs", null, outputDir);

            // Assert
            Assert.IsTrue(result);
            string jarFilePath = AssertPluginJarExists(outputDir);

            JarInfo jarInfo = inspector.GetPluginDescription(jarFilePath);

            if (jarInfo != null)
            {
                this.TestContext.AddResultFile(jarInfo.FileName);
            }

            Assert.IsNotNull(jarInfo, "Failed to process the generated jar successfully");

            AssertPropertyDefinitionExists(packageId + "_sarif.AnalyzerId", jarInfo);
            AssertPropertyDefinitionExists(packageId + "_sarif.RuleNamespace", jarInfo);
            AssertPropertyDefinitionExists(packageId + "_sarif.nuget.packageId", jarInfo);
            AssertPropertyDefinitionExists(packageId + "_sarif.nuget.packageVersion", jarInfo);

            JarInfo.RulesDefinition rulesDefn = AssertRulesDefinitionExists(jarInfo);
            AssertRepositoryIsValid(rulesDefn.Repository);

            AssertExpectedRulesExist(analyzer, rulesDefn.Repository);

            Assert.AreEqual(5, jarInfo.Extensions.Count, "Unexpected number of extensions");
        }