private static void WriteSearchMetadata(PackSourceCheckResult packSourceCheckResults, string outputFileName)
        {
            TemplateSearchCache searchMetadata = packSourceCheckResults.SearchCache;

            File.WriteAllText(outputFileName, searchMetadata.ToJObject().ToString(Formatting.None));
            Console.WriteLine($"Search cache file created: {outputFileName}");
        }
Exemplo n.º 2
0
        private string GenerateLocalCache()
        {
            ITemplatePackageInfo packOneInfo   = new MockTemplatePackageInfo("PackOne", "1.0.0");
            ITemplatePackageInfo packTwoInfo   = new MockTemplatePackageInfo("PackTwo", "1.6.0");
            ITemplatePackageInfo packThreeInfo = new MockTemplatePackageInfo("PackThree", "2.1");

            ITemplateInfo fooOneTemplate =
                new MockTemplateInfo("foo1", name: "MockFooTemplateOne", identity: "Mock.Foo.1", groupIdentity: "Mock.Foo", author: "TestAuthor")
                .WithClassifications("CSharp", "Library")
                .WithDescription("Mock Foo template one")
                .WithChoiceParameter("Framework", "netcoreapp3.0", "netcoreapp3.1")
                .WithTag("language", "C#")
                .WithTag("type", "project");

            ITemplateInfo fooTwoTemplate =
                new MockTemplateInfo("foo2", name: "MockFooTemplateTwo", identity: "Mock.Foo.2", groupIdentity: "Mock.Foo")
                .WithClassifications("CSharp", "Console")
                .WithDescription("Mock Foo template two")
                .WithChoiceParameter("Framework", "netcoreapp2.0", "netcoreapp2.1", "netcoreapp3.1")
                .WithTag("language", "C#");

            ITemplateInfo barCSharpTemplate =
                new MockTemplateInfo("barC", name: "MockBarCsharpTemplate", identity: "Mock.Bar.1.Csharp", groupIdentity: "Mock.Bar")
                .WithClassifications("CSharp")
                .WithDescription("Mock Bar CSharp template")
                .WithTag("language", "C#");

            ITemplateInfo barFSharpTemplate =
                new MockTemplateInfo("barF", name: "MockBarFSharpTemplate", identity: "Mock.Bar.1.FSharp", groupIdentity: "Mock.Bar")
                .WithClassifications("FSharp")
                .WithDescription("Mock Bar FSharp template")
                .WithTag("language", "F#");

            var fooOneTemplateData    = new TemplateSearchData(fooOneTemplate);
            var fooTwoTemplateData    = new TemplateSearchData(fooTwoTemplate);
            var barCSharpTemplateData = new TemplateSearchData(barCSharpTemplate);
            var barFSharpTemplateData = new TemplateSearchData(barFSharpTemplate);

            var packOne   = new TemplatePackageSearchData(packOneInfo, new[] { fooOneTemplateData });
            var packTwo   = new TemplatePackageSearchData(packTwoInfo, new[] { fooTwoTemplateData });
            var packThree = new TemplatePackageSearchData(packThreeInfo, new[] { barCSharpTemplateData, barFSharpTemplateData });

            var cache = new TemplateSearchCache(new[] { packOne, packTwo, packThree });

            string targetPath = Path.Combine(TestUtils.CreateTemporaryFolder(), "searchCacheV2.json");

            File.WriteAllText(targetPath, cache.ToJObject().ToString());
            return(targetPath);
        }