Skip to content

Commit

Permalink
Implemented latest ITemplateInfo interface and updated .NET analyzers.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikebattista committed Feb 11, 2023
1 parent 952b3a6 commit 68b5079
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 22 deletions.
2 changes: 1 addition & 1 deletion code/SharedFunctionality.Core/Gen/GenComposer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ private static void AddTemplates(IEnumerable<UserSelectionItem> 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);
Expand Down
2 changes: 1 addition & 1 deletion code/TemplateStudioForWPF/TemplateStudioForWPF.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
<Version>2.20.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers">
<Version>6.0.0</Version>
<Version>7.0.0</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
<Version>2.20.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers">
<Version>6.0.0</Version>
<Version>7.0.0</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
<Version>2.20.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers">
<Version>6.0.0</Version>
<Version>7.0.0</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -69,5 +71,11 @@ public void AddTag(string key, string value)
public string MountPointUri { get; set; }

public IReadOnlyList<string> ShortNameList { get; set; }

IParameterDefinitionSet ITemplateInfo.ParameterDefinitions { get; }

IReadOnlyList<Guid> ITemplateInfo.PostActions { get; }

IReadOnlyList<TemplateConstraintInfo> ITemplateInfo.Constraints { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -221,15 +221,15 @@

<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.20.0" />
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="6.0.0">
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="7.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.TemplateEngine.Edge" Version="6.0.200" />
<PackageReference Include="Microsoft.TemplateEngine.Orchestrator.RunnableProjects" Version="6.0.200" />
<PackageReference Include="Microsoft.TemplateEngine.Edge" Version="7.0.102" />
<PackageReference Include="Microsoft.TemplateEngine.Orchestrator.RunnableProjects" Version="7.0.102" />
<PackageReference Include="Microsoft.VisualStudio.TemplateWizardInterface" Version="17.2.32505.113" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="NuGet.Frameworks" Version="6.1.0" />
<PackageReference Include="NuGet.Frameworks" Version="6.3.1" />
<PackageReference Include="NuGet.VisualStudio" Version="6.0.0" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="6.0.0" />
<PackageReference Include="System.IO.FileSystem.Primitives" Version="4.3.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}");
}
Expand All @@ -718,10 +719,11 @@ private static void VerifyLicensesAndProjPostactions(ValidationTemplateInfo temp

private static void VerifyPostactionsPath(ValidationTemplateInfo template, List<string> 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<string> results)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -95,7 +97,13 @@ public class ValidationTemplateInfo : ITemplateInfo
public IReadOnlyDictionary<string, SymbolInfo> Symbols { get; set; }

[ApiAnalysisOptional]
public List<PostActionInfo> PostActions { get; set; }
public IReadOnlyList<TemplateConstraintInfo> Constraints { get; }

[ApiAnalysisOptional]
public IParameterDefinitionSet ParameterDefinitions { get; }

[ApiAnalysisOptional]
public IReadOnlyList<Guid> PostActions { get; set; }

public string SourceName { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@
<Version>3.1.4097</Version>
</PackageReference>
<PackageReference Include="Microsoft.TemplateEngine.Edge">
<Version>6.0.200</Version>
<Version>7.0.102</Version>
</PackageReference>
<PackageReference Include="Microsoft.TemplateEngine.Orchestrator.RunnableProjects">
<Version>6.0.200</Version>
<Version>7.0.102</Version>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.ProjectSystem">
<Version>17.0.1313-pre</Version>
Expand Down Expand Up @@ -226,4 +226,4 @@
<Import Project="..\..\SharedFunctionality.UI\SharedFunctionality.UI.projitems" Label="Shared" />
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
<Version>4.2.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers">
<Version>6.0.0</Version>
<Version>7.0.0</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
<Version>4.2.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers">
<Version>6.0.0</Version>
<Version>7.0.0</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
<Version>4.2.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers">
<Version>6.0.0</Version>
<Version>7.0.0</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
<Version>4.2.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers">
<Version>6.0.0</Version>
<Version>7.0.0</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion code/test/VsEmulator/VsEmulator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@
<Version>2.20.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers">
<Version>6.0.0</Version>
<Version>7.0.0</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down

0 comments on commit 68b5079

Please sign in to comment.