From 68b50792edb782be9589bcbb6462e41f5122681f Mon Sep 17 00:00:00 2001 From: Mike Battista <13860912+mikebattista@users.noreply.github.com> Date: Sat, 11 Feb 2023 11:59:25 -0800 Subject: [PATCH] Implemented latest ITemplateInfo interface and updated .NET analyzers. --- code/SharedFunctionality.Core/Gen/GenComposer.cs | 2 +- .../TemplateStudioForWPF/TemplateStudioForWPF.csproj | 2 +- .../TemplateStudioForWinUICpp.csproj | 2 +- .../TemplateStudioForWinUICs.csproj | 2 +- .../Composition/FakeTemplateInfo.cs | 8 ++++++++ .../SharedFunctionality.Core.Tests.csproj | 8 ++++---- .../TemplateValidator/TemplateJsonVerifier.cs | 12 +++++++----- .../TemplateValidator/ValidationTemplateInfo.cs | 10 +++++++++- .../SharedFunctionality.UI.Tests.csproj | 6 +++--- .../TemplateStudioForUWP.Tests.csproj | 2 +- .../TemplateStudioForWPF.Tests.csproj | 2 +- .../TemplateStudioForWinUICpp.Tests.csproj | 2 +- .../TemplateStudioForWinUICs.Tests.csproj | 2 +- code/test/VsEmulator/VsEmulator.csproj | 2 +- 14 files changed, 40 insertions(+), 22 deletions(-) diff --git a/code/SharedFunctionality.Core/Gen/GenComposer.cs b/code/SharedFunctionality.Core/Gen/GenComposer.cs index bb7278704c..0e8336c815 100644 --- a/code/SharedFunctionality.Core/Gen/GenComposer.cs +++ b/code/SharedFunctionality.Core/Gen/GenComposer.cs @@ -132,7 +132,7 @@ private static void AddTemplates(IEnumerable selectedTemplate foreach (var dependency in genInfo?.Template.GetDependencyList()) { - if (genInfo.Template.Parameters.Any(p => p.Name == dependency)) + if (genInfo.Template.ParameterDefinitions.Any(p => p.Name == dependency)) { var dependencyName = genQueue.FirstOrDefault(t => t.Template.Identity == dependency).Name; genInfo.Parameters.Add(dependency, dependencyName); diff --git a/code/TemplateStudioForWPF/TemplateStudioForWPF.csproj b/code/TemplateStudioForWPF/TemplateStudioForWPF.csproj index 4d0b59b736..e06da824a7 100644 --- a/code/TemplateStudioForWPF/TemplateStudioForWPF.csproj +++ b/code/TemplateStudioForWPF/TemplateStudioForWPF.csproj @@ -84,7 +84,7 @@ 2.20.0 - 6.0.0 + 7.0.0 runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/code/TemplateStudioForWinUICpp/TemplateStudioForWinUICpp.csproj b/code/TemplateStudioForWinUICpp/TemplateStudioForWinUICpp.csproj index 4901df524b..6add130c45 100644 --- a/code/TemplateStudioForWinUICpp/TemplateStudioForWinUICpp.csproj +++ b/code/TemplateStudioForWinUICpp/TemplateStudioForWinUICpp.csproj @@ -83,7 +83,7 @@ 2.20.0 - 6.0.0 + 7.0.0 runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/code/TemplateStudioForWinUICs/TemplateStudioForWinUICs.csproj b/code/TemplateStudioForWinUICs/TemplateStudioForWinUICs.csproj index b741a924ad..25f1c3517d 100644 --- a/code/TemplateStudioForWinUICs/TemplateStudioForWinUICs.csproj +++ b/code/TemplateStudioForWinUICs/TemplateStudioForWinUICs.csproj @@ -84,7 +84,7 @@ 2.20.0 - 6.0.0 + 7.0.0 runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/code/test/SharedFunctionality.Core.Tests/Composition/FakeTemplateInfo.cs b/code/test/SharedFunctionality.Core.Tests/Composition/FakeTemplateInfo.cs index 0b436c5a7d..86e57c9bb5 100644 --- a/code/test/SharedFunctionality.Core.Tests/Composition/FakeTemplateInfo.cs +++ b/code/test/SharedFunctionality.Core.Tests/Composition/FakeTemplateInfo.cs @@ -5,6 +5,8 @@ using System; using System.Collections.Generic; using Microsoft.TemplateEngine.Abstractions; +using Microsoft.TemplateEngine.Abstractions.Constraints; +using Microsoft.TemplateEngine.Abstractions.Parameters; namespace Microsoft.Templates.Core.Test.Composition { @@ -69,5 +71,11 @@ public void AddTag(string key, string value) public string MountPointUri { get; set; } public IReadOnlyList ShortNameList { get; set; } + + IParameterDefinitionSet ITemplateInfo.ParameterDefinitions { get; } + + IReadOnlyList ITemplateInfo.PostActions { get; } + + IReadOnlyList ITemplateInfo.Constraints { get; } } } diff --git a/code/test/SharedFunctionality.Core.Tests/SharedFunctionality.Core.Tests.csproj b/code/test/SharedFunctionality.Core.Tests/SharedFunctionality.Core.Tests.csproj index c4ca34af23..b276c259ee 100644 --- a/code/test/SharedFunctionality.Core.Tests/SharedFunctionality.Core.Tests.csproj +++ b/code/test/SharedFunctionality.Core.Tests/SharedFunctionality.Core.Tests.csproj @@ -221,15 +221,15 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + - + diff --git a/code/test/SharedFunctionality.Tests/TemplateValidator/TemplateJsonVerifier.cs b/code/test/SharedFunctionality.Tests/TemplateValidator/TemplateJsonVerifier.cs index cb2dc34d5a..04e2e45ef0 100644 --- a/code/test/SharedFunctionality.Tests/TemplateValidator/TemplateJsonVerifier.cs +++ b/code/test/SharedFunctionality.Tests/TemplateValidator/TemplateJsonVerifier.cs @@ -13,6 +13,7 @@ using Microsoft.Templates.Core; using Microsoft.Templates.Core.Composition; using Microsoft.Templates.Core.Gen; +using Microsoft.Templates.Core.PostActions; using Newtonsoft.Json; namespace TemplateValidator @@ -709,7 +710,7 @@ private static void VerifyLicensesAndProjPostactions(ValidationTemplateInfo temp } else { - if (template.PostActions != null && template.PostActions.Any(p => p.ActionId == "0B814718-16A3-4F7F-89F1-69C0F9170EAD")) + if (template.PostActions != null && template.PostActions.Any(p => p.ToString("D") == "0B814718-16A3-4F7F-89F1-69C0F9170EAD")) { results.Add($"Missing license on template {template.Identity}"); } @@ -718,10 +719,11 @@ private static void VerifyLicensesAndProjPostactions(ValidationTemplateInfo temp private static void VerifyPostactionsPath(ValidationTemplateInfo template, List results) { - if (template.PostActions != null && template.PostActions.Any(p => p.Args.Any(a => a.Key == "projectPath" && a.Value.Contains("/")))) - { - results.Add("Post-action projectPath should use '\\' instead of '/' to indicate the project file path"); - } + // TODO: TemplateEngine 7.x packages changed PostActions to just a list of GUIDs. Unclear how to implement this. + //if (template.PostActions != null && template.PostActions.Any(p => p.Args.Any(a => a.Key == "projectPath" && a.Value.Contains("/")))) + //{ + // results.Add("Post-action projectPath should use '\\' instead of '/' to indicate the project file path"); + //} } private static void EnsureValidPrimaryOutputPaths(ValidationTemplateInfo template, List results) diff --git a/code/test/SharedFunctionality.Tests/TemplateValidator/ValidationTemplateInfo.cs b/code/test/SharedFunctionality.Tests/TemplateValidator/ValidationTemplateInfo.cs index ef194364ea..b38c0f83d6 100644 --- a/code/test/SharedFunctionality.Tests/TemplateValidator/ValidationTemplateInfo.cs +++ b/code/test/SharedFunctionality.Tests/TemplateValidator/ValidationTemplateInfo.cs @@ -6,6 +6,8 @@ using System.Collections.Generic; using ApiAnalysis; using Microsoft.TemplateEngine.Abstractions; +using Microsoft.TemplateEngine.Abstractions.Constraints; +using Microsoft.TemplateEngine.Abstractions.Parameters; using Newtonsoft.Json; namespace TemplateValidator @@ -95,7 +97,13 @@ public class ValidationTemplateInfo : ITemplateInfo public IReadOnlyDictionary Symbols { get; set; } [ApiAnalysisOptional] - public List PostActions { get; set; } + public IReadOnlyList Constraints { get; } + + [ApiAnalysisOptional] + public IParameterDefinitionSet ParameterDefinitions { get; } + + [ApiAnalysisOptional] + public IReadOnlyList PostActions { get; set; } public string SourceName { get; set; } diff --git a/code/test/SharedFunctionality.UI.Tests/SharedFunctionality.UI.Tests.csproj b/code/test/SharedFunctionality.UI.Tests/SharedFunctionality.UI.Tests.csproj index b225cb4347..48560e75c0 100644 --- a/code/test/SharedFunctionality.UI.Tests/SharedFunctionality.UI.Tests.csproj +++ b/code/test/SharedFunctionality.UI.Tests/SharedFunctionality.UI.Tests.csproj @@ -96,10 +96,10 @@ 3.1.4097 - 6.0.200 + 7.0.102 - 6.0.200 + 7.0.102 17.0.1313-pre @@ -226,4 +226,4 @@ - + \ No newline at end of file diff --git a/code/test/TemplateStudioForUWP.Tests/TemplateStudioForUWP.Tests.csproj b/code/test/TemplateStudioForUWP.Tests/TemplateStudioForUWP.Tests.csproj index 565b2e6f21..dc64e86666 100644 --- a/code/test/TemplateStudioForUWP.Tests/TemplateStudioForUWP.Tests.csproj +++ b/code/test/TemplateStudioForUWP.Tests/TemplateStudioForUWP.Tests.csproj @@ -135,7 +135,7 @@ 4.2.0 - 6.0.0 + 7.0.0 runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/code/test/TemplateStudioForWPF.Tests/TemplateStudioForWPF.Tests.csproj b/code/test/TemplateStudioForWPF.Tests/TemplateStudioForWPF.Tests.csproj index 2db6fdd9df..42e469b330 100644 --- a/code/test/TemplateStudioForWPF.Tests/TemplateStudioForWPF.Tests.csproj +++ b/code/test/TemplateStudioForWPF.Tests/TemplateStudioForWPF.Tests.csproj @@ -131,7 +131,7 @@ 4.2.0 - 6.0.0 + 7.0.0 runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/code/test/TemplateStudioForWinUICpp.Tests/TemplateStudioForWinUICpp.Tests.csproj b/code/test/TemplateStudioForWinUICpp.Tests/TemplateStudioForWinUICpp.Tests.csproj index 0d709a979e..eb31477841 100644 --- a/code/test/TemplateStudioForWinUICpp.Tests/TemplateStudioForWinUICpp.Tests.csproj +++ b/code/test/TemplateStudioForWinUICpp.Tests/TemplateStudioForWinUICpp.Tests.csproj @@ -94,7 +94,7 @@ 4.2.0 - 6.0.0 + 7.0.0 runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/code/test/TemplateStudioForWinUICs.Tests/TemplateStudioForWinUICs.Tests.csproj b/code/test/TemplateStudioForWinUICs.Tests/TemplateStudioForWinUICs.Tests.csproj index a5965f7953..c7327e1511 100644 --- a/code/test/TemplateStudioForWinUICs.Tests/TemplateStudioForWinUICs.Tests.csproj +++ b/code/test/TemplateStudioForWinUICs.Tests/TemplateStudioForWinUICs.Tests.csproj @@ -104,7 +104,7 @@ 4.2.0 - 6.0.0 + 7.0.0 runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/code/test/VsEmulator/VsEmulator.csproj b/code/test/VsEmulator/VsEmulator.csproj index afc127f6ab..2fda492133 100644 --- a/code/test/VsEmulator/VsEmulator.csproj +++ b/code/test/VsEmulator/VsEmulator.csproj @@ -312,7 +312,7 @@ 2.20.0 - 6.0.0 + 7.0.0 runtime; build; native; contentfiles; analyzers; buildtransitive all