From 3671bc1b1c4d4d183c3bfa3be52e5134c8c80b83 Mon Sep 17 00:00:00 2001 From: Mariana Garces Dematte Date: Mon, 5 Dec 2022 21:55:57 -0800 Subject: [PATCH 01/17] Base of PreferDefaultName --- src/Microsoft.TemplateEngine.Abstractions/ITemplateInfo.cs | 5 +++++ .../PublicAPI.Unshipped.txt | 4 +++- .../FilterableTemplateInfo.cs | 3 +++ src/Microsoft.TemplateEngine.Edge/PublicAPI.Unshipped.txt | 3 ++- src/Microsoft.TemplateEngine.Edge/Settings/TemplateInfo.cs | 3 +++ .../Template/TemplateCreator.cs | 1 + .../ConfigModel/TemplateConfigModel.cs | 7 ++++++- .../RunnableProjectConfig.ITemplateInfo.cs | 4 +++- .../Abstractions/TemplateSearchData.cs | 2 ++ .../PublicAPI.Unshipped.txt | 2 +- .../TemplateDiscoveryMetadata/BlobStorageTemplateInfo.cs | 3 +++ test/Microsoft.TemplateEngine.Mocks/MockTemplateInfo.cs | 4 ++++ .../Serialization/TemplateConfigModelJsonConverter.cs | 5 +---- .../Results/LegacyBlobTemplateInfo.cs | 3 +++ 14 files changed, 40 insertions(+), 9 deletions(-) diff --git a/src/Microsoft.TemplateEngine.Abstractions/ITemplateInfo.cs b/src/Microsoft.TemplateEngine.Abstractions/ITemplateInfo.cs index c910b06829b..76ed4b7d425 100644 --- a/src/Microsoft.TemplateEngine.Abstractions/ITemplateInfo.cs +++ b/src/Microsoft.TemplateEngine.Abstractions/ITemplateInfo.cs @@ -133,5 +133,10 @@ public interface ITemplateInfo IReadOnlyList PostActions { get; } IReadOnlyList Constraints { get; } + + /// + /// Gets template's preference for using the default name on creation. + /// + bool PreferDefaultName { get; } } } diff --git a/src/Microsoft.TemplateEngine.Abstractions/PublicAPI.Unshipped.txt b/src/Microsoft.TemplateEngine.Abstractions/PublicAPI.Unshipped.txt index 9ec8d8b6688..2520fd6f947 100644 --- a/src/Microsoft.TemplateEngine.Abstractions/PublicAPI.Unshipped.txt +++ b/src/Microsoft.TemplateEngine.Abstractions/PublicAPI.Unshipped.txt @@ -1,4 +1,6 @@ Microsoft.TemplateEngine.Abstractions.ITemplate.TemplateSourceRoot.get -> Microsoft.TemplateEngine.Abstractions.Mount.IDirectory! Microsoft.TemplateEngine.Abstractions.IVariableCollection Microsoft.TemplateEngine.Abstractions.IVariableCollection.Parent.get -> Microsoft.TemplateEngine.Abstractions.IVariableCollection? -Microsoft.TemplateEngine.Abstractions.IVariableCollection.Parent.set -> void \ No newline at end of file +Microsoft.TemplateEngine.Abstractions.IVariableCollection.Parent.set -> void +Microsoft.TemplateEngine.Abstractions.ITemplate.TemplateSourceRoot.get -> Microsoft.TemplateEngine.Abstractions.Mount.IDirectory! +Microsoft.TemplateEngine.Abstractions.ITemplateInfo.PreferDefaultName.get -> bool \ No newline at end of file diff --git a/src/Microsoft.TemplateEngine.Edge/FilterableTemplateInfo.cs b/src/Microsoft.TemplateEngine.Edge/FilterableTemplateInfo.cs index b7796943ec7..d521bac9c06 100644 --- a/src/Microsoft.TemplateEngine.Edge/FilterableTemplateInfo.cs +++ b/src/Microsoft.TemplateEngine.Edge/FilterableTemplateInfo.cs @@ -47,6 +47,8 @@ private FilterableTemplateInfo(ITemplateInfo source) public IReadOnlyList GroupShortNameList { get; set; } + public bool PreferDefaultName { get; private set; } + public IReadOnlyDictionary Tags { get; private set; } public IReadOnlyDictionary CacheParameters { get; private set; } @@ -92,6 +94,7 @@ public static FilterableTemplateInfo FromITemplateInfo(ITemplateInfo source) Precedence = source.Precedence, Name = source.Name, ShortName = source.ShortName, + PreferDefaultName = source.PreferDefaultName, Tags = source.Tags, CacheParameters = source.CacheParameters, ParameterDefinitions = source.ParameterDefinitions, diff --git a/src/Microsoft.TemplateEngine.Edge/PublicAPI.Unshipped.txt b/src/Microsoft.TemplateEngine.Edge/PublicAPI.Unshipped.txt index 99f040ccaf6..e96edbf6280 100644 --- a/src/Microsoft.TemplateEngine.Edge/PublicAPI.Unshipped.txt +++ b/src/Microsoft.TemplateEngine.Edge/PublicAPI.Unshipped.txt @@ -1 +1,2 @@ -Microsoft.TemplateEngine.Edge.Settings.ITemplateInfoHostJsonCache.HostData.get -> string? \ No newline at end of file +Microsoft.TemplateEngine.Edge.Settings.ITemplateInfoHostJsonCache.HostData.get -> string? +Microsoft.TemplateEngine.Edge.FilterableTemplateInfo.PreferDefaultName.get -> bool \ No newline at end of file diff --git a/src/Microsoft.TemplateEngine.Edge/Settings/TemplateInfo.cs b/src/Microsoft.TemplateEngine.Edge/Settings/TemplateInfo.cs index fcba11e8e0d..b3b11aef203 100644 --- a/src/Microsoft.TemplateEngine.Edge/Settings/TemplateInfo.cs +++ b/src/Microsoft.TemplateEngine.Edge/Settings/TemplateInfo.cs @@ -188,6 +188,9 @@ string ITemplateInfo.ShortName public IReadOnlyList ShortNameList { get; } = new List(); + [JsonProperty] + public bool PreferDefaultName { get; } + [JsonIgnore] [Obsolete] IReadOnlyDictionary ITemplateInfo.Tags diff --git a/src/Microsoft.TemplateEngine.Edge/Template/TemplateCreator.cs b/src/Microsoft.TemplateEngine.Edge/Template/TemplateCreator.cs index 482a5918519..986bb89b288 100644 --- a/src/Microsoft.TemplateEngine.Edge/Template/TemplateCreator.cs +++ b/src/Microsoft.TemplateEngine.Edge/Template/TemplateCreator.cs @@ -104,6 +104,7 @@ public async Task InstantiateAsync( } string? realName = name ?? fallbackName ?? template.DefaultName; + // TODO: add template validation here if (string.IsNullOrWhiteSpace(realName)) { return new TemplateCreationResult(CreationResultStatus.MissingMandatoryParam, template.Name, "--name"); diff --git a/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/ConfigModel/TemplateConfigModel.cs b/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/ConfigModel/TemplateConfigModel.cs index 85b4d242bcf..1603332b316 100644 --- a/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/ConfigModel/TemplateConfigModel.cs +++ b/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/ConfigModel/TemplateConfigModel.cs @@ -250,7 +250,12 @@ public string? Name /// /// Indicates whether to create a directory for the template if name is specified but an output directory is not set (instead of creating the content directly in the current directory) ("preferNameDirectory" JSON property). /// - public bool PreferNameDirectory { get; internal init; } + public bool? PreferNameDirectory { get; internal init; } + + /// + /// Indicates whether to use the template's default name or parent folder's name for template name ("preferDefaultName: JSON property). + /// + public bool? PreferDefaultName { get; internal init; } /// /// Gets the collection of template tags ("tags" JSON property). diff --git a/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/RunnableProjectConfig.ITemplateInfo.cs b/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/RunnableProjectConfig.ITemplateInfo.cs index 10c17b5253b..3890ade55fa 100644 --- a/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/RunnableProjectConfig.ITemplateInfo.cs +++ b/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/RunnableProjectConfig.ITemplateInfo.cs @@ -52,6 +52,8 @@ string ITemplateInfo.ShortName IReadOnlyList ITemplateInfo.ShortNameList => ConfigurationModel.ShortNameList ?? new List(); + bool ITemplateInfo.PreferDefaultName => ConfigurationModel.PreferDefaultName ?? true; + [Obsolete] IReadOnlyDictionary ITemplateInfo.Tags { @@ -109,7 +111,7 @@ IReadOnlyDictionary ITemplateInfo.CacheParameters string? ITemplateInfo.LocaleConfigPlace => _localeConfigFile?.FullPath; //read in simple template model instead - bool ITemplate.IsNameAgreementWithFolderPreferred => ConfigurationModel.PreferNameDirectory; + bool ITemplate.IsNameAgreementWithFolderPreferred => ConfigurationModel.PreferNameDirectory ?? true; string? ITemplateInfo.HostConfigPlace => _hostConfigFile?.FullPath; diff --git a/src/Microsoft.TemplateSearch.Common/Abstractions/TemplateSearchData.cs b/src/Microsoft.TemplateSearch.Common/Abstractions/TemplateSearchData.cs index 4c5c88af7f2..bacc5f28eac 100644 --- a/src/Microsoft.TemplateSearch.Common/Abstractions/TemplateSearchData.cs +++ b/src/Microsoft.TemplateSearch.Common/Abstractions/TemplateSearchData.cs @@ -48,6 +48,8 @@ public TemplateSearchData(ITemplateInfo templateInfo, IDictionary public IReadOnlyList ShortNameList => TemplateInfo.ShortNameList; + public bool PreferDefaultName => TemplateInfo.PreferDefaultName; + /// public string? Author => TemplateInfo.Author; diff --git a/src/Microsoft.TemplateSearch.Common/PublicAPI.Unshipped.txt b/src/Microsoft.TemplateSearch.Common/PublicAPI.Unshipped.txt index 5f282702bb0..1aba194c003 100644 --- a/src/Microsoft.TemplateSearch.Common/PublicAPI.Unshipped.txt +++ b/src/Microsoft.TemplateSearch.Common/PublicAPI.Unshipped.txt @@ -1 +1 @@ - \ No newline at end of file +Microsoft.TemplateSearch.Common.TemplateSearchData.PreferDefaultName.get -> bool \ No newline at end of file diff --git a/src/Microsoft.TemplateSearch.Common/TemplateDiscoveryMetadata/BlobStorageTemplateInfo.cs b/src/Microsoft.TemplateSearch.Common/TemplateDiscoveryMetadata/BlobStorageTemplateInfo.cs index d75fca1e4a4..7fdb2516707 100644 --- a/src/Microsoft.TemplateSearch.Common/TemplateDiscoveryMetadata/BlobStorageTemplateInfo.cs +++ b/src/Microsoft.TemplateSearch.Common/TemplateDiscoveryMetadata/BlobStorageTemplateInfo.cs @@ -121,6 +121,9 @@ private BlobStorageTemplateInfo(string identity, string name, IEnumerable ShortNameList { get; private set; } + [JsonProperty] + public bool PreferDefaultName { get; private set; } + [JsonIgnore] [Obsolete] public IReadOnlyDictionary Tags { get; private set; } = new Dictionary(); diff --git a/test/Microsoft.TemplateEngine.Mocks/MockTemplateInfo.cs b/test/Microsoft.TemplateEngine.Mocks/MockTemplateInfo.cs index e3d9bb49c6a..be480f3850e 100644 --- a/test/Microsoft.TemplateEngine.Mocks/MockTemplateInfo.cs +++ b/test/Microsoft.TemplateEngine.Mocks/MockTemplateInfo.cs @@ -29,6 +29,8 @@ public class MockTemplateInfo : ITemplateInfo, IXunitSerializable private string[] _shortNameList = Array.Empty(); + private readonly bool _preferDefaultName = true; + private Guid[] _postActions = Array.Empty(); private TemplateConstraintInfo[] _constraints = Array.Empty(); @@ -88,6 +90,8 @@ public string ShortName public IReadOnlyList ShortNameList => _shortNameList; + public bool PreferDefaultName => _preferDefaultName; + [Obsolete("Use ParameterDefinitionSet instead.")] IReadOnlyDictionary ITemplateInfo.Tags => throw new NotImplementedException(); diff --git a/test/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/Serialization/TemplateConfigModelJsonConverter.cs b/test/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/Serialization/TemplateConfigModelJsonConverter.cs index a174030d3a6..96738d9f749 100644 --- a/test/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/Serialization/TemplateConfigModelJsonConverter.cs +++ b/test/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/Serialization/TemplateConfigModelJsonConverter.cs @@ -1,9 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using System.Collections.Generic; -using System.Linq; using Microsoft.TemplateEngine.Orchestrator.RunnableProjects.ConfigModel; using Newtonsoft.Json; @@ -94,7 +91,7 @@ public override void WriteJson(JsonWriter writer, TemplateConfigModel? value, Js writer.WritePropertyName("generatorVersions"); writer.WriteValue(value.GeneratorVersions); } - if (value.PreferNameDirectory) + if (value.PreferDefaultName is not null && value.PreferNameDirectory == true) { writer.WritePropertyName("preferNameDirectory"); writer.WriteValue(value.PreferNameDirectory); diff --git a/tools/Microsoft.TemplateSearch.TemplateDiscovery/Results/LegacyBlobTemplateInfo.cs b/tools/Microsoft.TemplateSearch.TemplateDiscovery/Results/LegacyBlobTemplateInfo.cs index ce15749efd2..69ff7ff1d20 100644 --- a/tools/Microsoft.TemplateSearch.TemplateDiscovery/Results/LegacyBlobTemplateInfo.cs +++ b/tools/Microsoft.TemplateSearch.TemplateDiscovery/Results/LegacyBlobTemplateInfo.cs @@ -102,6 +102,9 @@ public LegacyBlobTemplateInfo(ITemplateInfo templateInfo) [JsonProperty] public string Name { get; private set; } + [JsonProperty] + public bool PreferDefaultName { get; private set; } + [JsonProperty] public string ShortName { From e29391b0ec75f3f222ef71e0400460088f6fac9b Mon Sep 17 00:00:00 2001 From: Mariana Garces Dematte Date: Thu, 8 Dec 2022 21:53:06 -0800 Subject: [PATCH 02/17] Code cleanup --- src/Microsoft.TemplateEngine.Edge/Template/TemplateCreator.cs | 3 ++- .../ConfigModel/TemplateConfigModel.cs | 2 +- .../PublicAPI.Shipped.txt | 1 - .../PublicAPI.Unshipped.txt | 2 ++ .../RunnableProjectConfig.ITemplateInfo.cs | 4 ++-- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.TemplateEngine.Edge/Template/TemplateCreator.cs b/src/Microsoft.TemplateEngine.Edge/Template/TemplateCreator.cs index 986bb89b288..0fa6b2e76c8 100644 --- a/src/Microsoft.TemplateEngine.Edge/Template/TemplateCreator.cs +++ b/src/Microsoft.TemplateEngine.Edge/Template/TemplateCreator.cs @@ -103,7 +103,8 @@ public async Task InstantiateAsync( return new TemplateCreationResult(CreationResultStatus.NotFound, templateInfo.Name, LocalizableStrings.TemplateCreator_TemplateCreationResult_Error_CouldNotLoadTemplate); } - string? realName = name ?? fallbackName ?? template.DefaultName; + string? realName = name is not null ? name : templateInfo.PreferDefaultName ? templateInfo.DefaultName : fallbackName; + // TODO: add template validation here if (string.IsNullOrWhiteSpace(realName)) { diff --git a/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/ConfigModel/TemplateConfigModel.cs b/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/ConfigModel/TemplateConfigModel.cs index 1603332b316..7d17ac99121 100644 --- a/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/ConfigModel/TemplateConfigModel.cs +++ b/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/ConfigModel/TemplateConfigModel.cs @@ -250,7 +250,7 @@ public string? Name /// /// Indicates whether to create a directory for the template if name is specified but an output directory is not set (instead of creating the content directly in the current directory) ("preferNameDirectory" JSON property). /// - public bool? PreferNameDirectory { get; internal init; } + public bool PreferNameDirectory { get; internal init; } /// /// Indicates whether to use the template's default name or parent folder's name for template name ("preferDefaultName: JSON property). diff --git a/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/PublicAPI.Shipped.txt b/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/PublicAPI.Shipped.txt index 30d46c8f08d..349e155b8c8 100644 --- a/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/PublicAPI.Shipped.txt +++ b/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/PublicAPI.Shipped.txt @@ -100,7 +100,6 @@ Microsoft.TemplateEngine.Orchestrator.RunnableProjects.ConfigModel.TemplateConfi Microsoft.TemplateEngine.Orchestrator.RunnableProjects.ConfigModel.TemplateConfigModel.PlaceholderFilename.get -> string? Microsoft.TemplateEngine.Orchestrator.RunnableProjects.ConfigModel.TemplateConfigModel.PostActionModels.get -> System.Collections.Generic.IReadOnlyList! Microsoft.TemplateEngine.Orchestrator.RunnableProjects.ConfigModel.TemplateConfigModel.Precedence.get -> int -Microsoft.TemplateEngine.Orchestrator.RunnableProjects.ConfigModel.TemplateConfigModel.PreferNameDirectory.get -> bool Microsoft.TemplateEngine.Orchestrator.RunnableProjects.ConfigModel.TemplateConfigModel.PrimaryOutputs.get -> System.Collections.Generic.IReadOnlyList! Microsoft.TemplateEngine.Orchestrator.RunnableProjects.ConfigModel.TemplateConfigModel.ShortNameList.get -> System.Collections.Generic.IReadOnlyList! Microsoft.TemplateEngine.Orchestrator.RunnableProjects.ConfigModel.TemplateConfigModel.SourceName.get -> string? diff --git a/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/PublicAPI.Unshipped.txt b/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/PublicAPI.Unshipped.txt index ac33cddfbb3..964f994fe7a 100644 --- a/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/PublicAPI.Unshipped.txt +++ b/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/PublicAPI.Unshipped.txt @@ -7,3 +7,5 @@ Microsoft.TemplateEngine.Orchestrator.RunnableProjects.Abstractions.IMacro Microsoft.TemplateEngine.Orchestrator.RunnableProjects.Abstractions.IMacro.Evaluate(Microsoft.TemplateEngine.Abstractions.IEngineEnvironmentSettings! environmentSettings, Microsoft.TemplateEngine.Abstractions.IVariableCollection! variables, T config) -> void Microsoft.TemplateEngine.Orchestrator.RunnableProjects.ConfigModel.ConditionedConfigurationElement.EvaluateCondition(Microsoft.Extensions.Logging.ILogger! logger, Microsoft.TemplateEngine.Abstractions.IVariableCollection! variables) -> bool Microsoft.TemplateEngine.Orchestrator.RunnableProjects.ConfigModel.TemplateConfigModel.Identity.get -> string! +Microsoft.TemplateEngine.Orchestrator.RunnableProjects.ConfigModel.TemplateConfigModel.PreferDefaultName.get -> bool? +Microsoft.TemplateEngine.Orchestrator.RunnableProjects.ConfigModel.TemplateConfigModel.PreferNameDirectory.get -> bool diff --git a/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/RunnableProjectConfig.ITemplateInfo.cs b/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/RunnableProjectConfig.ITemplateInfo.cs index 3890ade55fa..9360577b383 100644 --- a/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/RunnableProjectConfig.ITemplateInfo.cs +++ b/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/RunnableProjectConfig.ITemplateInfo.cs @@ -52,7 +52,7 @@ string ITemplateInfo.ShortName IReadOnlyList ITemplateInfo.ShortNameList => ConfigurationModel.ShortNameList ?? new List(); - bool ITemplateInfo.PreferDefaultName => ConfigurationModel.PreferDefaultName ?? true; + bool ITemplateInfo.PreferDefaultName => ConfigurationModel.PreferDefaultName ?? false; [Obsolete] IReadOnlyDictionary ITemplateInfo.Tags @@ -111,7 +111,7 @@ IReadOnlyDictionary ITemplateInfo.CacheParameters string? ITemplateInfo.LocaleConfigPlace => _localeConfigFile?.FullPath; //read in simple template model instead - bool ITemplate.IsNameAgreementWithFolderPreferred => ConfigurationModel.PreferNameDirectory ?? true; + bool ITemplate.IsNameAgreementWithFolderPreferred => ConfigurationModel.PreferNameDirectory; string? ITemplateInfo.HostConfigPlace => _hostConfigFile?.FullPath; From e3e2091cdeaccfa586b8af5b1c427a11edbdd82c Mon Sep 17 00:00:00 2001 From: Mariana Dematte Date: Thu, 8 Dec 2022 23:10:40 -0800 Subject: [PATCH 03/17] Some missed stuff after rebase --- .../PublicAPI.Unshipped.txt | 1 - .../ConfigModel/TemplateConfigModel.cs | 2 +- .../PublicAPI.Shipped.txt | 1 + .../PublicAPI.Unshipped.txt | 3 +-- .../RunnableProjectConfig.ITemplateInfo.cs | 2 +- .../Serialization/TemplateConfigModelJsonConverter.cs | 7 ++++++- 6 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Microsoft.TemplateEngine.Abstractions/PublicAPI.Unshipped.txt b/src/Microsoft.TemplateEngine.Abstractions/PublicAPI.Unshipped.txt index 2520fd6f947..58288a4d860 100644 --- a/src/Microsoft.TemplateEngine.Abstractions/PublicAPI.Unshipped.txt +++ b/src/Microsoft.TemplateEngine.Abstractions/PublicAPI.Unshipped.txt @@ -2,5 +2,4 @@ Microsoft.TemplateEngine.Abstractions.IVariableCollection Microsoft.TemplateEngine.Abstractions.IVariableCollection.Parent.get -> Microsoft.TemplateEngine.Abstractions.IVariableCollection? Microsoft.TemplateEngine.Abstractions.IVariableCollection.Parent.set -> void -Microsoft.TemplateEngine.Abstractions.ITemplate.TemplateSourceRoot.get -> Microsoft.TemplateEngine.Abstractions.Mount.IDirectory! Microsoft.TemplateEngine.Abstractions.ITemplateInfo.PreferDefaultName.get -> bool \ No newline at end of file diff --git a/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/ConfigModel/TemplateConfigModel.cs b/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/ConfigModel/TemplateConfigModel.cs index 7d17ac99121..b8adabe1eca 100644 --- a/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/ConfigModel/TemplateConfigModel.cs +++ b/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/ConfigModel/TemplateConfigModel.cs @@ -255,7 +255,7 @@ public string? Name /// /// Indicates whether to use the template's default name or parent folder's name for template name ("preferDefaultName: JSON property). /// - public bool? PreferDefaultName { get; internal init; } + public bool PreferDefaultName { get; internal init; } /// /// Gets the collection of template tags ("tags" JSON property). diff --git a/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/PublicAPI.Shipped.txt b/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/PublicAPI.Shipped.txt index 349e155b8c8..ad1c8d98db7 100644 --- a/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/PublicAPI.Shipped.txt +++ b/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/PublicAPI.Shipped.txt @@ -101,6 +101,7 @@ Microsoft.TemplateEngine.Orchestrator.RunnableProjects.ConfigModel.TemplateConfi Microsoft.TemplateEngine.Orchestrator.RunnableProjects.ConfigModel.TemplateConfigModel.PostActionModels.get -> System.Collections.Generic.IReadOnlyList! Microsoft.TemplateEngine.Orchestrator.RunnableProjects.ConfigModel.TemplateConfigModel.Precedence.get -> int Microsoft.TemplateEngine.Orchestrator.RunnableProjects.ConfigModel.TemplateConfigModel.PrimaryOutputs.get -> System.Collections.Generic.IReadOnlyList! +Microsoft.TemplateEngine.Orchestrator.RunnableProjects.ConfigModel.TemplateConfigModel.PreferNameDirectory.get -> bool Microsoft.TemplateEngine.Orchestrator.RunnableProjects.ConfigModel.TemplateConfigModel.ShortNameList.get -> System.Collections.Generic.IReadOnlyList! Microsoft.TemplateEngine.Orchestrator.RunnableProjects.ConfigModel.TemplateConfigModel.SourceName.get -> string? Microsoft.TemplateEngine.Orchestrator.RunnableProjects.ConfigModel.TemplateConfigModel.Sources.get -> System.Collections.Generic.IReadOnlyList! diff --git a/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/PublicAPI.Unshipped.txt b/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/PublicAPI.Unshipped.txt index 964f994fe7a..de93076c3d7 100644 --- a/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/PublicAPI.Unshipped.txt +++ b/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/PublicAPI.Unshipped.txt @@ -7,5 +7,4 @@ Microsoft.TemplateEngine.Orchestrator.RunnableProjects.Abstractions.IMacro Microsoft.TemplateEngine.Orchestrator.RunnableProjects.Abstractions.IMacro.Evaluate(Microsoft.TemplateEngine.Abstractions.IEngineEnvironmentSettings! environmentSettings, Microsoft.TemplateEngine.Abstractions.IVariableCollection! variables, T config) -> void Microsoft.TemplateEngine.Orchestrator.RunnableProjects.ConfigModel.ConditionedConfigurationElement.EvaluateCondition(Microsoft.Extensions.Logging.ILogger! logger, Microsoft.TemplateEngine.Abstractions.IVariableCollection! variables) -> bool Microsoft.TemplateEngine.Orchestrator.RunnableProjects.ConfigModel.TemplateConfigModel.Identity.get -> string! -Microsoft.TemplateEngine.Orchestrator.RunnableProjects.ConfigModel.TemplateConfigModel.PreferDefaultName.get -> bool? -Microsoft.TemplateEngine.Orchestrator.RunnableProjects.ConfigModel.TemplateConfigModel.PreferNameDirectory.get -> bool +Microsoft.TemplateEngine.Orchestrator.RunnableProjects.ConfigModel.TemplateConfigModel.PreferDefaultName.get -> bool diff --git a/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/RunnableProjectConfig.ITemplateInfo.cs b/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/RunnableProjectConfig.ITemplateInfo.cs index 9360577b383..b333a1f6c27 100644 --- a/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/RunnableProjectConfig.ITemplateInfo.cs +++ b/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/RunnableProjectConfig.ITemplateInfo.cs @@ -52,7 +52,7 @@ string ITemplateInfo.ShortName IReadOnlyList ITemplateInfo.ShortNameList => ConfigurationModel.ShortNameList ?? new List(); - bool ITemplateInfo.PreferDefaultName => ConfigurationModel.PreferDefaultName ?? false; + bool ITemplateInfo.PreferDefaultName => ConfigurationModel.PreferDefaultName; [Obsolete] IReadOnlyDictionary ITemplateInfo.Tags diff --git a/test/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/Serialization/TemplateConfigModelJsonConverter.cs b/test/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/Serialization/TemplateConfigModelJsonConverter.cs index 96738d9f749..d54b49fe173 100644 --- a/test/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/Serialization/TemplateConfigModelJsonConverter.cs +++ b/test/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/Serialization/TemplateConfigModelJsonConverter.cs @@ -91,11 +91,16 @@ public override void WriteJson(JsonWriter writer, TemplateConfigModel? value, Js writer.WritePropertyName("generatorVersions"); writer.WriteValue(value.GeneratorVersions); } - if (value.PreferDefaultName is not null && value.PreferNameDirectory == true) + if (value.PreferNameDirectory) { writer.WritePropertyName("preferNameDirectory"); writer.WriteValue(value.PreferNameDirectory); } + if (value.PreferDefaultName) + { + writer.WritePropertyName("prefer"); + writer.WriteValue(value.PreferNameDirectory); + } if (value.Classifications.Any()) { From fbf82d693c7d53c8f246268a8ca067e6e415f239 Mon Sep 17 00:00:00 2001 From: Mariana Dematte Date: Wed, 14 Dec 2022 14:37:09 -0800 Subject: [PATCH 04/17] Stash changes --- .../Settings/TemplateInfo.cs | 2 +- .../Settings/TemplateInfoReader.cs | 1 + .../TemplateCreatorTests.cs | 98 +++++++++++++++++++ .../TemplateConfigModelJsonConverter.cs | 2 +- 4 files changed, 101 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.TemplateEngine.Edge/Settings/TemplateInfo.cs b/src/Microsoft.TemplateEngine.Edge/Settings/TemplateInfo.cs index b3b11aef203..deee79f8857 100644 --- a/src/Microsoft.TemplateEngine.Edge/Settings/TemplateInfo.cs +++ b/src/Microsoft.TemplateEngine.Edge/Settings/TemplateInfo.cs @@ -189,7 +189,7 @@ string ITemplateInfo.ShortName public IReadOnlyList ShortNameList { get; } = new List(); [JsonProperty] - public bool PreferDefaultName { get; } + public bool PreferDefaultName { get; private set; } [JsonIgnore] [Obsolete] diff --git a/src/Microsoft.TemplateEngine.Edge/Settings/TemplateInfoReader.cs b/src/Microsoft.TemplateEngine.Edge/Settings/TemplateInfoReader.cs index ee1e7e481ae..b9209caee29 100644 --- a/src/Microsoft.TemplateEngine.Edge/Settings/TemplateInfoReader.cs +++ b/src/Microsoft.TemplateEngine.Edge/Settings/TemplateInfoReader.cs @@ -41,6 +41,7 @@ internal static TemplateInfo FromJObject(JObject entry) } info.DefaultName = entry.ToString(nameof(DefaultName)); + info.PreferDefaultName = entry.ToBool(nameof(PreferDefaultName)); info.Description = entry.ToString(nameof(Description)); info.GeneratorId = Guid.Parse(entry.ToString(nameof(GeneratorId))); info.GroupIdentity = entry.ToString(nameof(GroupIdentity)); diff --git a/test/Microsoft.TemplateEngine.Edge.UnitTests/TemplateCreatorTests.cs b/test/Microsoft.TemplateEngine.Edge.UnitTests/TemplateCreatorTests.cs index 2161c9d55a9..28488d7f9e1 100644 --- a/test/Microsoft.TemplateEngine.Edge.UnitTests/TemplateCreatorTests.cs +++ b/test/Microsoft.TemplateEngine.Edge.UnitTests/TemplateCreatorTests.cs @@ -480,6 +480,46 @@ await InstantiateAsyncHelper( parameters2: parameters); } + private const string TemplateConfigPreferDefaultNameWithDefaultName = /*lang=json*/ """ + { + "identity": "test.template", + "name": "tst", + "shortName": "tst", + "preferDefaultName": true, + "defaultName": "defaultName", + "sourceName": "sourceFile" + } + """; + + private const string TemplateConfigPreferDefaultNameWithoutDefaultName = /*lang=json*/ """ + { + "identity": "test.template", + "name": "tst", + "shortName": "tst", + "preferDefaultName": true, + "sourceName": "sourceFile" + } + """; + + [Theory] + [InlineData(TemplateConfigPreferDefaultNameWithDefaultName, "thisIsAName", "./thisIsAName.cs")] + [InlineData(TemplateConfigPreferDefaultNameWithDefaultName, null, "./defaultName.cs")] + [InlineData(TemplateConfigPreferDefaultNameWithoutDefaultName, null, "./tst2.cs")] + public async void InstantiateAsync_PreferDefaultName(string templateConfig, string? name, string expectedOutputName) + { + string sourceSnippet = """ + using System; + + Console.log("Hello there, this is a test!"); + """; + + await InstantiateAsyncNameHelper( + templateConfig, + sourceSnippet, + name, + expectedOutputName); + } + private async Task InstantiateAsyncHelper( string templateSnippet, string sourceSnippet, @@ -586,6 +626,64 @@ private async Task InstantiateAsyncHelper( } } + // This is a helper focused on testing the final name of the template during creation + private async Task InstantiateAsyncNameHelper( + string templateSnippet, + string sourceSnippet, + string? name, + string expectedOutputName, + string sourceExtension = ".cs") + { + // + // Template content preparation + // + + IDictionary templateSourceFiles = new Dictionary + { + // template.json + { TestFileSystemUtils.DefaultConfigRelativePath, templateSnippet } + }; + + string sourceFileName = "sourceFile" + sourceExtension; + + //content + templateSourceFiles.Add(sourceFileName, sourceSnippet); + + // + // Dependencies preparation and mounting + // + + string sourceBasePath = _engineEnvironmentSettings.GetTempVirtualizedPath(); + + TestFileSystemUtils.WriteTemplateSource(_engineEnvironmentSettings, sourceBasePath, templateSourceFiles); + using IMountPoint sourceMountPoint = _engineEnvironmentSettings.MountPath(sourceBasePath); + RunnableProjectGenerator rpg = new(); + // cannot use SimpleConfigModel dirrectly - due to missing easy way of creating ParameterSymbols + IFile? templateConfig = sourceMountPoint.FileInfo(TestFileSystemUtils.DefaultConfigRelativePath); + Assert.NotNull(templateConfig); + var runnableConfig = new RunnableProjectConfig(_engineEnvironmentSettings, rpg, templateConfig); + + TemplateCreator creator = new TemplateCreator(_engineEnvironmentSettings); + + string targetDir = _engineEnvironmentSettings.GetTempVirtualizedPath(); + + InputDataSet parameters = new InputDataSet(runnableConfig); + + ITemplateCreationResult res = await creator.InstantiateAsync( + templateInfo: runnableConfig, + name: name, + fallbackName: "tst2", + inputParameters: parameters, + outputPath: targetDir); + + res.ErrorMessage.Should().BeNull(); + res.OutputBaseDirectory.Should().NotBeNullOrEmpty(); + + res.CreationEffects.Should().NotBeNull(); + res.CreationEffects!.FileChanges.Should().NotBeNullOrEmpty().And.HaveCount(1); + res.CreationEffects.FileChanges[0].TargetRelativePath.Should().Be(expectedOutputName); + } + private class InputDataBag { public InputDataBag(string name, bool? value, bool? isEnabledConditionResult = null, bool? isRequiredConditionResult = null) diff --git a/test/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/Serialization/TemplateConfigModelJsonConverter.cs b/test/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/Serialization/TemplateConfigModelJsonConverter.cs index d54b49fe173..026c0124e6d 100644 --- a/test/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/Serialization/TemplateConfigModelJsonConverter.cs +++ b/test/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/Serialization/TemplateConfigModelJsonConverter.cs @@ -98,7 +98,7 @@ public override void WriteJson(JsonWriter writer, TemplateConfigModel? value, Js } if (value.PreferDefaultName) { - writer.WritePropertyName("prefer"); + writer.WritePropertyName("preferefaultName"); writer.WriteValue(value.PreferNameDirectory); } From 8c9792a7bb7b990795b7f4faf901086c55678516 Mon Sep 17 00:00:00 2001 From: Mariana Dematte Date: Thu, 15 Dec 2022 13:16:29 -0800 Subject: [PATCH 05/17] Added integration tests --- .../PublicAPI.Unshipped.txt | 1 - .../Settings/TemplateInfo.cs | 1 + .../Template/TemplateCreator.cs | 4 +- .../ConfigModel/TemplateConfigModel.cs | 1 + .../End2EndTests.cs | 56 +++++++++++++++++++ ...rosoft.TemplateEngine.TestTemplates.csproj | 4 ++ .../.template.config/template.json | 14 +++++ .../TemplateWithPreferDefaultName/toChange.cs | 3 + .../.template.config/template.json | 13 +++++ .../toChange.cs | 3 + 10 files changed, 97 insertions(+), 3 deletions(-) create mode 100644 test/Microsoft.TemplateEngine.TestTemplates/test_templates/TemplateWithPreferDefaultName/.template.config/template.json create mode 100644 test/Microsoft.TemplateEngine.TestTemplates/test_templates/TemplateWithPreferDefaultName/toChange.cs create mode 100644 test/Microsoft.TemplateEngine.TestTemplates/test_templates/TemplateWithPreferDefaultNameButNoDefaultName/.template.config/template.json create mode 100644 test/Microsoft.TemplateEngine.TestTemplates/test_templates/TemplateWithPreferDefaultNameButNoDefaultName/toChange.cs diff --git a/src/Microsoft.TemplateEngine.Edge/PublicAPI.Unshipped.txt b/src/Microsoft.TemplateEngine.Edge/PublicAPI.Unshipped.txt index 83963325734..f505b2bf69b 100644 --- a/src/Microsoft.TemplateEngine.Edge/PublicAPI.Unshipped.txt +++ b/src/Microsoft.TemplateEngine.Edge/PublicAPI.Unshipped.txt @@ -3,5 +3,4 @@ Microsoft.TemplateEngine.Edge.Settings.ITemplateInfoHostJsonCache.HostData.get - Microsoft.TemplateEngine.Edge.VirtualEnvironment Microsoft.TemplateEngine.Edge.VirtualEnvironment.VirtualEnvironment(System.Collections.Generic.IReadOnlyDictionary? virtualEnvironemnt, bool includeRealEnvironment) -> void static Microsoft.TemplateEngine.Edge.DefaultEnvironment.FetchEnvironmentVariables() -> System.Collections.Generic.IReadOnlyDictionary! -Microsoft.TemplateEngine.Edge.Settings.ITemplateInfoHostJsonCache.HostData.get -> string? Microsoft.TemplateEngine.Edge.FilterableTemplateInfo.PreferDefaultName.get -> bool \ No newline at end of file diff --git a/src/Microsoft.TemplateEngine.Edge/Settings/TemplateInfo.cs b/src/Microsoft.TemplateEngine.Edge/Settings/TemplateInfo.cs index deee79f8857..281b9e0eb0d 100644 --- a/src/Microsoft.TemplateEngine.Edge/Settings/TemplateInfo.cs +++ b/src/Microsoft.TemplateEngine.Edge/Settings/TemplateInfo.cs @@ -89,6 +89,7 @@ internal TemplateInfo(ITemplate template, ILocalizationLocator? localizationInfo Precedence = template.Precedence; Identity = template.Identity; DefaultName = template.DefaultName; + PreferDefaultName = template.PreferDefaultName; HostConfigPlace = template.HostConfigPlace; ThirdPartyNotices = template.ThirdPartyNotices; BaselineInfo = template.BaselineInfo; diff --git a/src/Microsoft.TemplateEngine.Edge/Template/TemplateCreator.cs b/src/Microsoft.TemplateEngine.Edge/Template/TemplateCreator.cs index 019b2609430..2a06d60abb8 100644 --- a/src/Microsoft.TemplateEngine.Edge/Template/TemplateCreator.cs +++ b/src/Microsoft.TemplateEngine.Edge/Template/TemplateCreator.cs @@ -103,9 +103,9 @@ public async Task InstantiateAsync( return new TemplateCreationResult(CreationResultStatus.NotFound, templateInfo.Name, LocalizableStrings.TemplateCreator_TemplateCreationResult_Error_CouldNotLoadTemplate); } - string? realName = name is not null ? name : templateInfo.PreferDefaultName ? templateInfo.DefaultName : fallbackName; + string? realName = name is not null ? name : templateInfo.PreferDefaultName ? templateInfo.DefaultName : null; + realName = realName is null ? fallbackName : realName; - // TODO: add template validation here if (string.IsNullOrWhiteSpace(realName)) { return new TemplateCreationResult(CreationResultStatus.MissingMandatoryParam, template.Name, "--name"); diff --git a/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/ConfigModel/TemplateConfigModel.cs b/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/ConfigModel/TemplateConfigModel.cs index ac274da6008..47771580f35 100644 --- a/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/ConfigModel/TemplateConfigModel.cs +++ b/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/ConfigModel/TemplateConfigModel.cs @@ -60,6 +60,7 @@ private TemplateConfigModel(JObject source, ILogger? logger, string? baselineNam Author = source.ToString(nameof(Author)); Classifications = source.ArrayAsStrings(nameof(Classifications)); DefaultName = source.ToString(nameof(DefaultName)); + PreferDefaultName = source.ToBool(nameof(PreferDefaultName)); Description = source.ToString(nameof(Description)) ?? string.Empty; GroupIdentity = source.ToString(nameof(GroupIdentity)); Precedence = source.ToInt32(nameof(Precedence)); diff --git a/test/Microsoft.TemplateEngine.IDE.IntegrationTests/End2EndTests.cs b/test/Microsoft.TemplateEngine.IDE.IntegrationTests/End2EndTests.cs index 06cce90445c..12aee428754 100644 --- a/test/Microsoft.TemplateEngine.IDE.IntegrationTests/End2EndTests.cs +++ b/test/Microsoft.TemplateEngine.IDE.IntegrationTests/End2EndTests.cs @@ -336,5 +336,61 @@ common text """.UnixifyLineBreaks(), File.ReadAllText(targetFile).UnixifyLineBreaks()); } + + [Theory] + [InlineData(null, "theDefaultName.cs")] + [InlineData("fileName", "fileName.cs")] + internal async Task Test_CreateAsync_PreferDefaultNameValidParameters(string? name, string expectedFileName) + { + using Bootstrapper bootstrapper = GetBootstrapper(); + string templateLocation = GetTestTemplateLocation("TemplateWithPreferDefaultName"); + await InstallTemplateAsync(bootstrapper, templateLocation).ConfigureAwait(false); + + string output = TestUtils.CreateTemporaryFolder(); + + IReadOnlyList foundTemplates = await bootstrapper + .GetTemplatesAsync(new[] { WellKnownSearchFilters.NameFilter("TestAssets.TemplateWithPreferDefaultName") }) + .ConfigureAwait(false); + + // Using this parameter with no real info so bootstrapper.CreateAsync is not an ambiguous call + Dictionary parameters = new() + { + { "some", "parameter" }, + }; + + ITemplateCreationResult result = await bootstrapper + .CreateAsync(foundTemplates[0].Info, name, output, parameters) + .ConfigureAwait(false); + + Assert.Equal(CreationResultStatus.Success, result.Status); + string expectedName = Path.Combine(output, expectedFileName); + Assert.True(File.Exists(expectedName)); + } + + [Fact] + internal async Task Test_CreateAsync_PreferDefaultNameInvalidParameters() + { + using Bootstrapper bootstrapper = GetBootstrapper(); + string templateLocation = GetTestTemplateLocation("TemplateWithPreferDefaultNameButNoDefaultName"); + await InstallTemplateAsync(bootstrapper, templateLocation).ConfigureAwait(false); + + string output = TestUtils.CreateTemporaryFolder(); + + IReadOnlyList foundTemplates = await bootstrapper + .GetTemplatesAsync(new[] { WellKnownSearchFilters.NameFilter("TestAssets.TemplateWithPreferDefaultName") }) + .ConfigureAwait(false); + + // Using this parameter with no real info so bootstrapper.CreateAsync is not an ambiguous call + Dictionary parameters = new() + { + { "some", "parameter" }, + }; + + ITemplateCreationResult result = await bootstrapper + .CreateAsync(foundTemplates[0].Info, null, output, parameters) + .ConfigureAwait(false); + + Assert.Equal(CreationResultStatus.MissingMandatoryParam, result.Status); + } } } diff --git a/test/Microsoft.TemplateEngine.TestTemplates/Microsoft.TemplateEngine.TestTemplates.csproj b/test/Microsoft.TemplateEngine.TestTemplates/Microsoft.TemplateEngine.TestTemplates.csproj index 776bb344f60..6761602af97 100644 --- a/test/Microsoft.TemplateEngine.TestTemplates/Microsoft.TemplateEngine.TestTemplates.csproj +++ b/test/Microsoft.TemplateEngine.TestTemplates/Microsoft.TemplateEngine.TestTemplates.csproj @@ -21,4 +21,8 @@ + + + + diff --git a/test/Microsoft.TemplateEngine.TestTemplates/test_templates/TemplateWithPreferDefaultName/.template.config/template.json b/test/Microsoft.TemplateEngine.TestTemplates/test_templates/TemplateWithPreferDefaultName/.template.config/template.json new file mode 100644 index 00000000000..3f4c6c6d040 --- /dev/null +++ b/test/Microsoft.TemplateEngine.TestTemplates/test_templates/TemplateWithPreferDefaultName/.template.config/template.json @@ -0,0 +1,14 @@ +{ + "$schema": "https://json.schemastore.org/template.json", + "author": "Test Asset", + "classifications": [ "Test Asset" ], + "name": "TemplateWithPreferDefaultName", + "tags": { "type": "project" }, + "generatorVersions": "[1.0.0.0-*)", + "groupIdentity": "TestAssets.TemplateWithPreferDefaultName", + "identity": "TestAssets.TemplateWithPreferDefaultName", + "shortName": "TestAssets.TemplateWithPreferDefaultName", + "preferDefaultName": true, + "sourceName": "toChange", + "defaultName": "theDefaultName" +} diff --git a/test/Microsoft.TemplateEngine.TestTemplates/test_templates/TemplateWithPreferDefaultName/toChange.cs b/test/Microsoft.TemplateEngine.TestTemplates/test_templates/TemplateWithPreferDefaultName/toChange.cs new file mode 100644 index 00000000000..d43b1f38161 --- /dev/null +++ b/test/Microsoft.TemplateEngine.TestTemplates/test_templates/TemplateWithPreferDefaultName/toChange.cs @@ -0,0 +1,3 @@ +using System; + +Console.log("Hello there! This is a test"); diff --git a/test/Microsoft.TemplateEngine.TestTemplates/test_templates/TemplateWithPreferDefaultNameButNoDefaultName/.template.config/template.json b/test/Microsoft.TemplateEngine.TestTemplates/test_templates/TemplateWithPreferDefaultNameButNoDefaultName/.template.config/template.json new file mode 100644 index 00000000000..3b862c88dbf --- /dev/null +++ b/test/Microsoft.TemplateEngine.TestTemplates/test_templates/TemplateWithPreferDefaultNameButNoDefaultName/.template.config/template.json @@ -0,0 +1,13 @@ +{ + "$schema": "https://json.schemastore.org/template.json", + "author": "Test Asset", + "classifications": [ "Test Asset" ], + "name": "TemplateWithPreferDefaultName", + "tags": { "type": "project" }, + "generatorVersions": "[1.0.0.0-*)", + "groupIdentity": "TestAssets.TemplateWithPreferDefaultName", + "identity": "TestAssets.TemplateWithPreferDefaultName", + "shortName": "TestAssets.TemplateWithPreferDefaultName", + "preferDefaultName": true, + "sourceName": "toChange" +} diff --git a/test/Microsoft.TemplateEngine.TestTemplates/test_templates/TemplateWithPreferDefaultNameButNoDefaultName/toChange.cs b/test/Microsoft.TemplateEngine.TestTemplates/test_templates/TemplateWithPreferDefaultNameButNoDefaultName/toChange.cs new file mode 100644 index 00000000000..d43b1f38161 --- /dev/null +++ b/test/Microsoft.TemplateEngine.TestTemplates/test_templates/TemplateWithPreferDefaultNameButNoDefaultName/toChange.cs @@ -0,0 +1,3 @@ +using System; + +Console.log("Hello there! This is a test"); From 2ffe982e40b3ca63502f115e8edc566f2859f141 Mon Sep 17 00:00:00 2001 From: Mariana Dematte Date: Thu, 15 Dec 2022 14:22:35 -0800 Subject: [PATCH 06/17] Added docs --- docs/Reference-for-template.json.md | 3 ++- .../Schemas/JSON/template.json | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/Reference-for-template.json.md b/docs/Reference-for-template.json.md index f9191437dd4..6c7275a8673 100644 --- a/docs/Reference-for-template.json.md +++ b/docs/Reference-for-template.json.md @@ -492,11 +492,12 @@ See [the article](Binding-and-project-context-evaluation.md#bind-symbols). |Name|Description|Default|Mandatory| |---|---|---|---| |`sourceName`| The text in the source content to replace with the name the user specifies. The value to be replaced with can be given using the `-n` `--name` options while running a template. The template engine will look for any occurrence of the `sourceName` present in the config file and replace it in file names and file contents. If no name is specified by the host, the current directory is used. The value of the `sourceName` is available in built-in `name` symbol and can be used as the source for creating other symbols and condition expressions. Due to implicit forms applied to `sourceName` it is important to select the replacement that doesn't cause the conflicts. See more details about `sourceName` in [the article](Naming-and-default-value-forms.md)||no| +|`preferDefaultName`| Boolean value that decides which name will be used if no `--name` is specified during creation. If `false` it will use the fallback name, if `true` it will use the template's `defaultName`. If no `defaultName` is specified, the template creation will not succeed. | If not specified, `false` is used. | no |`preferNameDirectory`| Boolean value, indicates whether to create a directory for the template if name is specified but an output directory is not set (instead of creating the content directly in the current directory).|If not specified, `false` is used.|no| |`placeholderFilename`|A filename that will be completely ignored, used to indicate that its containing directory should be copied. This allows creation of empty directory in the created template, by having a corresponding source directory containing just the placeholder file. By default, empty directories are ignored.|If not specified, a default value of `"-.-"` is used.|no| |`primaryOutputs`|A list of template files for further processing by the host (including post-actions). The path should contain the relative path to the file prior to the symbol based renaming that may happen during template generation. It is defined as an array of [Primary Outputs](#primary-output-definition)||no| -#### Primary Output Definition +### Primary Output Definition Primary outputs define the list of template files for further processing, usually post actions. |Name|Description|Mandatory| |---|---|---| diff --git a/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/Schemas/JSON/template.json b/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/Schemas/JSON/template.json index 95124e0c41b..8300645ef95 100644 --- a/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/Schemas/JSON/template.json +++ b/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/Schemas/JSON/template.json @@ -739,6 +739,10 @@ "pattern": "^([0-9]+)$", "default": 0 }, + "preferDefaultName": { + "description": "Indicated which behaviour to use when no `--name` is specified during template creation.", + "type": ["boolean"] + }, "preferNameDirectory": { "description": "Indicates whether to create a directory for the template if name is specified but an output directory is not set (instead of creating the content directly in the current directory).", "type": "boolean" From b507aab451d83ac984ec105bad81577ecb674742 Mon Sep 17 00:00:00 2001 From: Mariana Dematte Date: Thu, 15 Dec 2022 15:32:28 -0800 Subject: [PATCH 07/17] Address comments --- .../TemplateDiscoveryMetadata/BlobStorageTemplateInfo.cs | 2 +- .../Serialization/TemplateConfigModelJsonConverter.cs | 4 ++-- .../Results/LegacyBlobTemplateInfo.cs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.TemplateSearch.Common/TemplateDiscoveryMetadata/BlobStorageTemplateInfo.cs b/src/Microsoft.TemplateSearch.Common/TemplateDiscoveryMetadata/BlobStorageTemplateInfo.cs index 7fdb2516707..69b431d13e6 100644 --- a/src/Microsoft.TemplateSearch.Common/TemplateDiscoveryMetadata/BlobStorageTemplateInfo.cs +++ b/src/Microsoft.TemplateSearch.Common/TemplateDiscoveryMetadata/BlobStorageTemplateInfo.cs @@ -121,7 +121,7 @@ private BlobStorageTemplateInfo(string identity, string name, IEnumerable ShortNameList { get; private set; } - [JsonProperty] + [JsonIgnore] public bool PreferDefaultName { get; private set; } [JsonIgnore] diff --git a/test/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/Serialization/TemplateConfigModelJsonConverter.cs b/test/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/Serialization/TemplateConfigModelJsonConverter.cs index 026c0124e6d..dd3b0486d2a 100644 --- a/test/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/Serialization/TemplateConfigModelJsonConverter.cs +++ b/test/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/Serialization/TemplateConfigModelJsonConverter.cs @@ -98,8 +98,8 @@ public override void WriteJson(JsonWriter writer, TemplateConfigModel? value, Js } if (value.PreferDefaultName) { - writer.WritePropertyName("preferefaultName"); - writer.WriteValue(value.PreferNameDirectory); + writer.WritePropertyName("preferDefaultName"); + writer.WriteValue(value.PreferDefaultName); } if (value.Classifications.Any()) diff --git a/tools/Microsoft.TemplateSearch.TemplateDiscovery/Results/LegacyBlobTemplateInfo.cs b/tools/Microsoft.TemplateSearch.TemplateDiscovery/Results/LegacyBlobTemplateInfo.cs index 69ff7ff1d20..179ee089233 100644 --- a/tools/Microsoft.TemplateSearch.TemplateDiscovery/Results/LegacyBlobTemplateInfo.cs +++ b/tools/Microsoft.TemplateSearch.TemplateDiscovery/Results/LegacyBlobTemplateInfo.cs @@ -102,7 +102,7 @@ public LegacyBlobTemplateInfo(ITemplateInfo templateInfo) [JsonProperty] public string Name { get; private set; } - [JsonProperty] + [JsonIgnore] public bool PreferDefaultName { get; private set; } [JsonProperty] From e8fdd1a568782750655bb56051931c81deb30666 Mon Sep 17 00:00:00 2001 From: Jan Krivanek Date: Tue, 20 Dec 2022 16:10:42 +0100 Subject: [PATCH 08/17] Add sample tests with TemplateVerifier --- ...estAssets.TemplateWithPreferDefaultName.cs | 3 ++ ...TemplateEngine.IDE.IntegrationTests.csproj | 9 +++- .../SnapshotTests.cs | 43 +++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 test/Microsoft.TemplateEngine.IDE.IntegrationTests/Approvals/PreferDefaultNameTest.TestAssets.TemplateWithPreferDefaultName._.verified/TestAssets.TemplateWithPreferDefaultName/TestAssets.TemplateWithPreferDefaultName.cs create mode 100644 test/Microsoft.TemplateEngine.IDE.IntegrationTests/SnapshotTests.cs diff --git a/test/Microsoft.TemplateEngine.IDE.IntegrationTests/Approvals/PreferDefaultNameTest.TestAssets.TemplateWithPreferDefaultName._.verified/TestAssets.TemplateWithPreferDefaultName/TestAssets.TemplateWithPreferDefaultName.cs b/test/Microsoft.TemplateEngine.IDE.IntegrationTests/Approvals/PreferDefaultNameTest.TestAssets.TemplateWithPreferDefaultName._.verified/TestAssets.TemplateWithPreferDefaultName/TestAssets.TemplateWithPreferDefaultName.cs new file mode 100644 index 00000000000..bc19d484bae --- /dev/null +++ b/test/Microsoft.TemplateEngine.IDE.IntegrationTests/Approvals/PreferDefaultNameTest.TestAssets.TemplateWithPreferDefaultName._.verified/TestAssets.TemplateWithPreferDefaultName/TestAssets.TemplateWithPreferDefaultName.cs @@ -0,0 +1,3 @@ +using System; + +Console.log("Hello there! This is a test"); diff --git a/test/Microsoft.TemplateEngine.IDE.IntegrationTests/Microsoft.TemplateEngine.IDE.IntegrationTests.csproj b/test/Microsoft.TemplateEngine.IDE.IntegrationTests/Microsoft.TemplateEngine.IDE.IntegrationTests.csproj index 387c08709f7..22f098b0aa3 100644 --- a/test/Microsoft.TemplateEngine.IDE.IntegrationTests/Microsoft.TemplateEngine.IDE.IntegrationTests.csproj +++ b/test/Microsoft.TemplateEngine.IDE.IntegrationTests/Microsoft.TemplateEngine.IDE.IntegrationTests.csproj @@ -19,11 +19,18 @@ + + + + + - + + + diff --git a/test/Microsoft.TemplateEngine.IDE.IntegrationTests/SnapshotTests.cs b/test/Microsoft.TemplateEngine.IDE.IntegrationTests/SnapshotTests.cs new file mode 100644 index 00000000000..333638dc3e2 --- /dev/null +++ b/test/Microsoft.TemplateEngine.IDE.IntegrationTests/SnapshotTests.cs @@ -0,0 +1,43 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +#if NET + +using Microsoft.Extensions.Logging; +using Microsoft.TemplateEngine.Authoring.TemplateApiVerifier; +using Microsoft.TemplateEngine.Authoring.TemplateVerifier; +using Microsoft.TemplateEngine.TestHelper; +using Microsoft.TemplateEngine.Tests; +using Xunit.Abstractions; + +namespace Microsoft.TemplateEngine.IDE.IntegrationTests +{ + public class SnapshotTests : TestBase + { + private readonly ILogger _log; + + public SnapshotTests(ITestOutputHelper log) + { + _log = new XunitLoggerProvider(log).CreateLogger("TestRun"); + } + + [Fact] + public Task PreferDefaultNameTest() + { + string templateLocation = GetTestTemplateLocation("TemplateWithPreferDefaultName"); + + TemplateVerifierOptions options = + new TemplateVerifierOptions(templateName: "TestAssets.TemplateWithPreferDefaultName") + { + TemplatePath = templateLocation, + SnapshotsDirectory = "Approvals" + } + .WithInstantiationThroughTemplateCreatorApi(new Dictionary()); + + VerificationEngine engine = new VerificationEngine(_log); + return engine.Execute(options); + } + } +} + +#endif From 08d551ab80cf95d55535541c22a024922d7ee5da Mon Sep 17 00:00:00 2001 From: Mariana Dematte Date: Tue, 20 Dec 2022 18:10:17 -0800 Subject: [PATCH 09/17] addressed some PR comments --- docs/Reference-for-template.json.md | 4 ++-- .../Schemas/JSON/template.json | 4 ++-- .../TemplateCreatorTests.cs | 11 +++++++++++ .../Microsoft.TemplateEngine.TestTemplates.csproj | 4 ---- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/docs/Reference-for-template.json.md b/docs/Reference-for-template.json.md index 6c7275a8673..bbcc1e69a9a 100644 --- a/docs/Reference-for-template.json.md +++ b/docs/Reference-for-template.json.md @@ -492,12 +492,12 @@ See [the article](Binding-and-project-context-evaluation.md#bind-symbols). |Name|Description|Default|Mandatory| |---|---|---|---| |`sourceName`| The text in the source content to replace with the name the user specifies. The value to be replaced with can be given using the `-n` `--name` options while running a template. The template engine will look for any occurrence of the `sourceName` present in the config file and replace it in file names and file contents. If no name is specified by the host, the current directory is used. The value of the `sourceName` is available in built-in `name` symbol and can be used as the source for creating other symbols and condition expressions. Due to implicit forms applied to `sourceName` it is important to select the replacement that doesn't cause the conflicts. See more details about `sourceName` in [the article](Naming-and-default-value-forms.md)||no| -|`preferDefaultName`| Boolean value that decides which name will be used if no `--name` is specified during creation. If `false` it will use the fallback name, if `true` it will use the template's `defaultName`. If no `defaultName` is specified, the template creation will not succeed. | If not specified, `false` is used. | no +|`preferDefaultName`| Boolean value that decides which name will be used if no `--name` is specified during creation. If `false` it will use the fallback name (output folder name), if `true` it will use the template's `defaultName`. If no `defaultName` is specified and `preferDefaultName` is set to `true`, the template creation will not succeed. | If not specified, `false` is used. | no |`preferNameDirectory`| Boolean value, indicates whether to create a directory for the template if name is specified but an output directory is not set (instead of creating the content directly in the current directory).|If not specified, `false` is used.|no| |`placeholderFilename`|A filename that will be completely ignored, used to indicate that its containing directory should be copied. This allows creation of empty directory in the created template, by having a corresponding source directory containing just the placeholder file. By default, empty directories are ignored.|If not specified, a default value of `"-.-"` is used.|no| |`primaryOutputs`|A list of template files for further processing by the host (including post-actions). The path should contain the relative path to the file prior to the symbol based renaming that may happen during template generation. It is defined as an array of [Primary Outputs](#primary-output-definition)||no| -### Primary Output Definition +#### Primary Output Definition Primary outputs define the list of template files for further processing, usually post actions. |Name|Description|Mandatory| |---|---|---| diff --git a/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/Schemas/JSON/template.json b/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/Schemas/JSON/template.json index 8300645ef95..e78f820130c 100644 --- a/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/Schemas/JSON/template.json +++ b/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/Schemas/JSON/template.json @@ -740,8 +740,8 @@ "default": 0 }, "preferDefaultName": { - "description": "Indicated which behaviour to use when no `--name` is specified during template creation.", - "type": ["boolean"] + "description": "Indicated which behaviour to use when no `--name` is specified during template creation. If `true` it will use the template's `defaultName`. If no `defaultName` is found, or `preferDefaultName` is `false` it uses the fallback (output folder).", + "type": [ "boolean" ] }, "preferNameDirectory": { "description": "Indicates whether to create a directory for the template if name is specified but an output directory is not set (instead of creating the content directly in the current directory).", diff --git a/test/Microsoft.TemplateEngine.Edge.UnitTests/TemplateCreatorTests.cs b/test/Microsoft.TemplateEngine.Edge.UnitTests/TemplateCreatorTests.cs index f121b72a1b0..9d20b233597 100644 --- a/test/Microsoft.TemplateEngine.Edge.UnitTests/TemplateCreatorTests.cs +++ b/test/Microsoft.TemplateEngine.Edge.UnitTests/TemplateCreatorTests.cs @@ -691,10 +691,21 @@ await InstantiateAsyncHelper( } """; + private const string TemplateConfigNoPreferDefaultNameWithDefaultName = /*lang=json*/ """ + { + "identity": "test.template", + "name": "tst", + "shortName": "tst", + "preferDefaultName": false, + "sourceName": "sourceFile" + } + """; + [Theory] [InlineData(TemplateConfigPreferDefaultNameWithDefaultName, "thisIsAName", "./thisIsAName.cs")] [InlineData(TemplateConfigPreferDefaultNameWithDefaultName, null, "./defaultName.cs")] [InlineData(TemplateConfigPreferDefaultNameWithoutDefaultName, null, "./tst2.cs")] + [InlineData(TemplateConfigNoPreferDefaultNameWithDefaultName, null, "./tst2.cs")] public async void InstantiateAsync_PreferDefaultName(string templateConfig, string? name, string expectedOutputName) { string sourceSnippet = """ diff --git a/test/Microsoft.TemplateEngine.TestTemplates/Microsoft.TemplateEngine.TestTemplates.csproj b/test/Microsoft.TemplateEngine.TestTemplates/Microsoft.TemplateEngine.TestTemplates.csproj index 6761602af97..776bb344f60 100644 --- a/test/Microsoft.TemplateEngine.TestTemplates/Microsoft.TemplateEngine.TestTemplates.csproj +++ b/test/Microsoft.TemplateEngine.TestTemplates/Microsoft.TemplateEngine.TestTemplates.csproj @@ -21,8 +21,4 @@ - - - - From 934c44932d76f1fb305dce6ea08fcdb95a2a180f Mon Sep 17 00:00:00 2001 From: Mariana Dematte Date: Tue, 20 Dec 2022 19:22:32 -0800 Subject: [PATCH 10/17] Added more tests and some details to the docs --- docs/Reference-for-template.json.md | 2 +- .../Abstractions/TemplateSearchData.cs | 3 +- .../PublicAPI.Unshipped.txt | 2 +- .../TemplateCacheTests.cs | 40 +++++++++++++++++++ 4 files changed, 44 insertions(+), 3 deletions(-) diff --git a/docs/Reference-for-template.json.md b/docs/Reference-for-template.json.md index bbcc1e69a9a..7b8d1a157e5 100644 --- a/docs/Reference-for-template.json.md +++ b/docs/Reference-for-template.json.md @@ -492,7 +492,7 @@ See [the article](Binding-and-project-context-evaluation.md#bind-symbols). |Name|Description|Default|Mandatory| |---|---|---|---| |`sourceName`| The text in the source content to replace with the name the user specifies. The value to be replaced with can be given using the `-n` `--name` options while running a template. The template engine will look for any occurrence of the `sourceName` present in the config file and replace it in file names and file contents. If no name is specified by the host, the current directory is used. The value of the `sourceName` is available in built-in `name` symbol and can be used as the source for creating other symbols and condition expressions. Due to implicit forms applied to `sourceName` it is important to select the replacement that doesn't cause the conflicts. See more details about `sourceName` in [the article](Naming-and-default-value-forms.md)||no| -|`preferDefaultName`| Boolean value that decides which name will be used if no `--name` is specified during creation. If `false` it will use the fallback name (output folder name), if `true` it will use the template's `defaultName`. If no `defaultName` is specified and `preferDefaultName` is set to `true`, the template creation will not succeed. | If not specified, `false` is used. | no +|`preferDefaultName`| Boolean value that decides which name will be used if no `--name` is specified during creation. If `false` it will use the fallback name (output folder name), if `true` it will use the template's `defaultName`. If no `defaultName` and no fallback name is specified and `preferDefaultName` is set to `true`, the template creation will not succeed with a `MissingMandatoryParam` exception. | If not specified, `false` is used. | no |`preferNameDirectory`| Boolean value, indicates whether to create a directory for the template if name is specified but an output directory is not set (instead of creating the content directly in the current directory).|If not specified, `false` is used.|no| |`placeholderFilename`|A filename that will be completely ignored, used to indicate that its containing directory should be copied. This allows creation of empty directory in the created template, by having a corresponding source directory containing just the placeholder file. By default, empty directories are ignored.|If not specified, a default value of `"-.-"` is used.|no| |`primaryOutputs`|A list of template files for further processing by the host (including post-actions). The path should contain the relative path to the file prior to the symbol based renaming that may happen during template generation. It is defined as an array of [Primary Outputs](#primary-output-definition)||no| diff --git a/src/Microsoft.TemplateSearch.Common/Abstractions/TemplateSearchData.cs b/src/Microsoft.TemplateSearch.Common/Abstractions/TemplateSearchData.cs index bacc5f28eac..e1547d6ca66 100644 --- a/src/Microsoft.TemplateSearch.Common/Abstractions/TemplateSearchData.cs +++ b/src/Microsoft.TemplateSearch.Common/Abstractions/TemplateSearchData.cs @@ -48,7 +48,8 @@ public TemplateSearchData(ITemplateInfo templateInfo, IDictionary public IReadOnlyList ShortNameList => TemplateInfo.ShortNameList; - public bool PreferDefaultName => TemplateInfo.PreferDefaultName; + /// + bool ITemplateInfo.PreferDefaultName => TemplateInfo.PreferDefaultName; /// public string? Author => TemplateInfo.Author; diff --git a/src/Microsoft.TemplateSearch.Common/PublicAPI.Unshipped.txt b/src/Microsoft.TemplateSearch.Common/PublicAPI.Unshipped.txt index 1aba194c003..5f282702bb0 100644 --- a/src/Microsoft.TemplateSearch.Common/PublicAPI.Unshipped.txt +++ b/src/Microsoft.TemplateSearch.Common/PublicAPI.Unshipped.txt @@ -1 +1 @@ -Microsoft.TemplateSearch.Common.TemplateSearchData.PreferDefaultName.get -> bool \ No newline at end of file + \ No newline at end of file diff --git a/test/Microsoft.TemplateEngine.Edge.UnitTests/TemplateCacheTests.cs b/test/Microsoft.TemplateEngine.Edge.UnitTests/TemplateCacheTests.cs index 62fd4be63e5..6da46da4275 100644 --- a/test/Microsoft.TemplateEngine.Edge.UnitTests/TemplateCacheTests.cs +++ b/test/Microsoft.TemplateEngine.Edge.UnitTests/TemplateCacheTests.cs @@ -210,6 +210,46 @@ public void CanHandleParameters() Assert.Equal(2, readTemplate.ParameterDefinitions["param3"].Choices!.Count); } + [Theory] + [InlineData(true, "defaultName")] + [InlineData(true, null)] + [InlineData(false, "anotherDefault")] + public void CanHandleDefaultName(bool preferDefaultName, string? defaultName) + { + IEngineEnvironmentSettings environmentSettings = _environmentSettingsHelper.CreateEnvironment(virtualize: true); + SettingsFilePaths paths = new SettingsFilePaths(environmentSettings); + + ITemplate template = A.Fake(); + A.CallTo(() => template.Identity).Returns("testIdentity"); + A.CallTo(() => template.Name).Returns("testName"); + A.CallTo(() => template.ShortNameList).Returns(new[] { "testShort" }); + A.CallTo(() => template.PreferDefaultName).Returns(preferDefaultName); + A.CallTo(() => template.DefaultName).Returns(defaultName); + A.CallTo(() => template.MountPointUri).Returns("testMount"); + A.CallTo(() => template.ConfigPlace).Returns(".template.config/template.json"); + IMountPoint mountPoint = A.Fake(); + A.CallTo(() => mountPoint.MountPointUri).Returns("testMount"); + + ScanResult result = new ScanResult(mountPoint, new[] { template }, Array.Empty(), Array.Empty<(string AssemblyPath, Type InterfaceType, IIdentifiedComponent Instance)>()); + TemplateCache templateCache = new TemplateCache(new[] { result }, new Dictionary(), NullLogger.Instance); + + WriteObject(environmentSettings.Host.FileSystem, paths.TemplateCacheFile, templateCache); + var readCache = new TemplateCache(ReadObject(environmentSettings.Host.FileSystem, paths.TemplateCacheFile), NullLogger.Instance); + + Assert.Single(readCache.TemplateInfo); + var readTemplate = readCache.TemplateInfo[0]; + if (preferDefaultName) + { + Assert.True(readTemplate.PreferDefaultName); + + } + else + { + Assert.False(readTemplate.PreferDefaultName); + } + Assert.Equal(defaultName, readTemplate.DefaultName); + } + private static JObject ReadObject(IPhysicalFileSystem fileSystem, string path) { using (var fileStream = fileSystem.OpenRead(path)) From cdb3f5203229a68d46254ca6ca120e8b75199314 Mon Sep 17 00:00:00 2001 From: Mariana Dematte Date: Wed, 21 Dec 2022 11:43:32 -0800 Subject: [PATCH 11/17] adjusted some tests and changed exception --- docs/Reference-for-template.json.md | 2 +- .../Template/TemplateCreator.cs | 2 +- .../TemplateCacheTests.cs | 10 +- .../TemplateCreatorTests.cs | 101 ++++++------------ 4 files changed, 37 insertions(+), 78 deletions(-) diff --git a/docs/Reference-for-template.json.md b/docs/Reference-for-template.json.md index 7b8d1a157e5..f9786f64751 100644 --- a/docs/Reference-for-template.json.md +++ b/docs/Reference-for-template.json.md @@ -492,7 +492,7 @@ See [the article](Binding-and-project-context-evaluation.md#bind-symbols). |Name|Description|Default|Mandatory| |---|---|---|---| |`sourceName`| The text in the source content to replace with the name the user specifies. The value to be replaced with can be given using the `-n` `--name` options while running a template. The template engine will look for any occurrence of the `sourceName` present in the config file and replace it in file names and file contents. If no name is specified by the host, the current directory is used. The value of the `sourceName` is available in built-in `name` symbol and can be used as the source for creating other symbols and condition expressions. Due to implicit forms applied to `sourceName` it is important to select the replacement that doesn't cause the conflicts. See more details about `sourceName` in [the article](Naming-and-default-value-forms.md)||no| -|`preferDefaultName`| Boolean value that decides which name will be used if no `--name` is specified during creation. If `false` it will use the fallback name (output folder name), if `true` it will use the template's `defaultName`. If no `defaultName` and no fallback name is specified and `preferDefaultName` is set to `true`, the template creation will not succeed with a `MissingMandatoryParam` exception. | If not specified, `false` is used. | no +|`preferDefaultName`| Boolean value that decides which name will be used if no `--name` is specified during creation. If `false` it will use the fallback name (output folder name), if `true` it will use the template's `defaultName`. If no `defaultName` and no fallback name is specified and `preferDefaultName` is set to `true`, the template creation will not succeed with a `TemplateIssueDetected` exception. | If not specified, `false` is used. | no |`preferNameDirectory`| Boolean value, indicates whether to create a directory for the template if name is specified but an output directory is not set (instead of creating the content directly in the current directory).|If not specified, `false` is used.|no| |`placeholderFilename`|A filename that will be completely ignored, used to indicate that its containing directory should be copied. This allows creation of empty directory in the created template, by having a corresponding source directory containing just the placeholder file. By default, empty directories are ignored.|If not specified, a default value of `"-.-"` is used.|no| |`primaryOutputs`|A list of template files for further processing by the host (including post-actions). The path should contain the relative path to the file prior to the symbol based renaming that may happen during template generation. It is defined as an array of [Primary Outputs](#primary-output-definition)||no| diff --git a/src/Microsoft.TemplateEngine.Edge/Template/TemplateCreator.cs b/src/Microsoft.TemplateEngine.Edge/Template/TemplateCreator.cs index 2a06d60abb8..383242fd9cc 100644 --- a/src/Microsoft.TemplateEngine.Edge/Template/TemplateCreator.cs +++ b/src/Microsoft.TemplateEngine.Edge/Template/TemplateCreator.cs @@ -108,7 +108,7 @@ public async Task InstantiateAsync( if (string.IsNullOrWhiteSpace(realName)) { - return new TemplateCreationResult(CreationResultStatus.MissingMandatoryParam, template.Name, "--name"); + return new TemplateCreationResult(CreationResultStatus.TemplateIssueDetected, template.Name, "--name"); } if (template.IsNameAgreementWithFolderPreferred && string.IsNullOrEmpty(outputPath)) { diff --git a/test/Microsoft.TemplateEngine.Edge.UnitTests/TemplateCacheTests.cs b/test/Microsoft.TemplateEngine.Edge.UnitTests/TemplateCacheTests.cs index 6da46da4275..c7a68f4636f 100644 --- a/test/Microsoft.TemplateEngine.Edge.UnitTests/TemplateCacheTests.cs +++ b/test/Microsoft.TemplateEngine.Edge.UnitTests/TemplateCacheTests.cs @@ -238,15 +238,7 @@ public void CanHandleDefaultName(bool preferDefaultName, string? defaultName) Assert.Single(readCache.TemplateInfo); var readTemplate = readCache.TemplateInfo[0]; - if (preferDefaultName) - { - Assert.True(readTemplate.PreferDefaultName); - - } - else - { - Assert.False(readTemplate.PreferDefaultName); - } + Assert.Equal(preferDefaultName, readTemplate.PreferDefaultName); Assert.Equal(defaultName, readTemplate.DefaultName); } diff --git a/test/Microsoft.TemplateEngine.Edge.UnitTests/TemplateCreatorTests.cs b/test/Microsoft.TemplateEngine.Edge.UnitTests/TemplateCreatorTests.cs index 9d20b233597..cc11a4fa99d 100644 --- a/test/Microsoft.TemplateEngine.Edge.UnitTests/TemplateCreatorTests.cs +++ b/test/Microsoft.TemplateEngine.Edge.UnitTests/TemplateCreatorTests.cs @@ -112,6 +112,7 @@ await InstantiateAsyncHelper( string.Empty, false, sourceExtension: ".csproj", + expectedOutputName: "./sourceFile.csproj", parameters1: parameters); } @@ -714,11 +715,14 @@ public async void InstantiateAsync_PreferDefaultName(string templateConfig, stri Console.log("Hello there, this is a test!"); """; - await InstantiateAsyncNameHelper( + await InstantiateAsyncHelper( templateConfig, sourceSnippet, - name, - expectedOutputName); + sourceSnippet, + string.Empty, + false, + name: name, + expectedOutputName: expectedOutputName); } private async Task InstantiateAsyncHelper( @@ -727,6 +731,8 @@ private async Task InstantiateAsyncHelper( string expectedOutput, string expectedErrorMessage, bool instantiateShouldFail, + string? name = "sourceFile", + string expectedOutputName = "./sourceFile.cs", string sourceExtension = ".cs", IReadOnlyDictionary? parameters1 = null, IReadOnlyList? parameters2 = null) @@ -741,7 +747,7 @@ private async Task InstantiateAsyncHelper( { TestFileSystemUtils.DefaultConfigRelativePath, templateSnippet } }; - string sourceFileName = "sourceFile" + sourceExtension; + string sourceFileName = name is null ? "sourceFile" + sourceExtension : name + sourceExtension; //content templateSourceFiles.Add(sourceFileName, sourceSnippet); @@ -769,12 +775,12 @@ private async Task InstantiateAsyncHelper( { res = await creator.InstantiateAsync( templateInfo: runnableConfig, - name: "tst", + name: name, fallbackName: "tst2", inputParameters: parameters1!, outputPath: targetDir); } - else + else if (parameters2 != null) { IParameterDefinitionSet parameters = runnableConfig.ParameterDefinitions; @@ -796,7 +802,7 @@ private async Task InstantiateAsyncHelper( res = await creator.InstantiateAsync( templateInfo: runnableConfig, - name: "tst", + name: name, fallbackName: "tst2", inputParameters: data, outputPath: targetDir); @@ -809,6 +815,17 @@ private async Task InstantiateAsyncHelper( return; } } + else + { + InputDataSet parameters = new InputDataSet(runnableConfig); + + res = await creator.InstantiateAsync( + templateInfo: runnableConfig, + name: name, + fallbackName: "tst2", + inputParameters: parameters, + outputPath: targetDir); + } if (instantiateShouldFail) { @@ -821,68 +838,18 @@ private async Task InstantiateAsyncHelper( { res.ErrorMessage.Should().BeNull(); res.OutputBaseDirectory.Should().NotBeNullOrEmpty(); - string resultContent = _engineEnvironmentSettings.Host.FileSystem - .ReadAllText(Path.Combine(res.OutputBaseDirectory!, sourceFileName)).Trim(); - resultContent.Should().BeEquivalentTo(expectedOutput.Trim()); - } - } - - // This is a helper focused on testing the final name of the template during creation - private async Task InstantiateAsyncNameHelper( - string templateSnippet, - string sourceSnippet, - string? name, - string expectedOutputName, - string sourceExtension = ".cs") - { - // - // Template content preparation - // - IDictionary templateSourceFiles = new Dictionary - { - // template.json - { TestFileSystemUtils.DefaultConfigRelativePath, templateSnippet } - }; + res.CreationEffects.Should().NotBeNull(); + res.CreationEffects!.FileChanges.Should().NotBeNullOrEmpty().And.HaveCount(1); + res.CreationEffects.FileChanges[0].TargetRelativePath.Should().Be(expectedOutputName); - string sourceFileName = "sourceFile" + sourceExtension; - - //content - templateSourceFiles.Add(sourceFileName, sourceSnippet); - - // - // Dependencies preparation and mounting - // - - string sourceBasePath = _engineEnvironmentSettings.GetTempVirtualizedPath(); - - TestFileSystemUtils.WriteTemplateSource(_engineEnvironmentSettings, sourceBasePath, templateSourceFiles); - using IMountPoint sourceMountPoint = _engineEnvironmentSettings.MountPath(sourceBasePath); - RunnableProjectGenerator rpg = new(); - // cannot use SimpleConfigModel dirrectly - due to missing easy way of creating ParameterSymbols - IFile? templateConfig = sourceMountPoint.FileInfo(TestFileSystemUtils.DefaultConfigRelativePath); - Assert.NotNull(templateConfig); - var runnableConfig = new RunnableProjectConfig(_engineEnvironmentSettings, rpg, templateConfig); - - TemplateCreator creator = new TemplateCreator(_engineEnvironmentSettings); - - string targetDir = _engineEnvironmentSettings.GetTempVirtualizedPath(); - - InputDataSet parameters = new InputDataSet(runnableConfig); - - ITemplateCreationResult res = await creator.InstantiateAsync( - templateInfo: runnableConfig, - name: name, - fallbackName: "tst2", - inputParameters: parameters, - outputPath: targetDir); - - res.ErrorMessage.Should().BeNull(); - res.OutputBaseDirectory.Should().NotBeNullOrEmpty(); - - res.CreationEffects.Should().NotBeNull(); - res.CreationEffects!.FileChanges.Should().NotBeNullOrEmpty().And.HaveCount(1); - res.CreationEffects.FileChanges[0].TargetRelativePath.Should().Be(expectedOutputName); + string resultContent = File.Exists(Path.Combine(res.OutputBaseDirectory!, sourceFileName)) + ? _engineEnvironmentSettings.Host.FileSystem + .ReadAllText(Path.Combine(res.OutputBaseDirectory!, sourceFileName)).Trim() + : _engineEnvironmentSettings.Host.FileSystem + .ReadAllText(Path.Combine(res.OutputBaseDirectory!, expectedOutputName)).Trim(); + resultContent.Should().BeEquivalentTo(expectedOutput.Trim()); + } } private class InputDataBag From 705595ae461e881cb2a6678a06524e18b503f6df Mon Sep 17 00:00:00 2001 From: Mariana Dematte Date: Tue, 27 Dec 2022 23:00:48 -0800 Subject: [PATCH 12/17] Changed base logic for naming and modified necessary tests --- .../Template/TemplateCreator.cs | 28 ++++++++++++++++++- .../TemplateCreatorTests.cs | 14 +++++----- .../End2EndTests.cs | 2 +- 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/src/Microsoft.TemplateEngine.Edge/Template/TemplateCreator.cs b/src/Microsoft.TemplateEngine.Edge/Template/TemplateCreator.cs index 383242fd9cc..34712489446 100644 --- a/src/Microsoft.TemplateEngine.Edge/Template/TemplateCreator.cs +++ b/src/Microsoft.TemplateEngine.Edge/Template/TemplateCreator.cs @@ -105,10 +105,36 @@ public async Task InstantiateAsync( string? realName = name is not null ? name : templateInfo.PreferDefaultName ? templateInfo.DefaultName : null; realName = realName is null ? fallbackName : realName; + if (!string.IsNullOrEmpty(name)) + { + realName = name; + } + else if (templateInfo.PreferDefaultName) + { + if (string.IsNullOrEmpty(templateInfo.DefaultName)) + { + return new TemplateCreationResult(CreationResultStatus.TemplateIssueDetected, template.Name, "--name"); + } + realName = templateInfo.DefaultName; + } + else + { + if (string.IsNullOrEmpty(fallbackName)) + { + if (!string.IsNullOrEmpty(templateInfo.DefaultName)) + { + realName = templateInfo.DefaultName; + } + } + else + { + realName = fallbackName; + } + } if (string.IsNullOrWhiteSpace(realName)) { - return new TemplateCreationResult(CreationResultStatus.TemplateIssueDetected, template.Name, "--name"); + return new TemplateCreationResult(CreationResultStatus.MissingMandatoryParam, template.Name, "--name"); } if (template.IsNameAgreementWithFolderPreferred && string.IsNullOrEmpty(outputPath)) { diff --git a/test/Microsoft.TemplateEngine.Edge.UnitTests/TemplateCreatorTests.cs b/test/Microsoft.TemplateEngine.Edge.UnitTests/TemplateCreatorTests.cs index cc11a4fa99d..5b148a639d7 100644 --- a/test/Microsoft.TemplateEngine.Edge.UnitTests/TemplateCreatorTests.cs +++ b/test/Microsoft.TemplateEngine.Edge.UnitTests/TemplateCreatorTests.cs @@ -703,11 +703,11 @@ await InstantiateAsyncHelper( """; [Theory] - [InlineData(TemplateConfigPreferDefaultNameWithDefaultName, "thisIsAName", "./thisIsAName.cs")] - [InlineData(TemplateConfigPreferDefaultNameWithDefaultName, null, "./defaultName.cs")] - [InlineData(TemplateConfigPreferDefaultNameWithoutDefaultName, null, "./tst2.cs")] - [InlineData(TemplateConfigNoPreferDefaultNameWithDefaultName, null, "./tst2.cs")] - public async void InstantiateAsync_PreferDefaultName(string templateConfig, string? name, string expectedOutputName) + [InlineData(TemplateConfigPreferDefaultNameWithDefaultName, "thisIsAName", "./thisIsAName.cs", false, "")] + [InlineData(TemplateConfigPreferDefaultNameWithDefaultName, null, "./defaultName.cs", false, "")] + [InlineData(TemplateConfigNoPreferDefaultNameWithDefaultName, null, "./tst2.cs", false, "")] + [InlineData(TemplateConfigPreferDefaultNameWithoutDefaultName, null, "./tst2.cs", true, "--name")] + public async void InstantiateAsync_PreferDefaultName(string templateConfig, string? name, string expectedOutputName, bool instanceFailure, string errorMessage) { string sourceSnippet = """ using System; @@ -719,8 +719,8 @@ await InstantiateAsyncHelper( templateConfig, sourceSnippet, sourceSnippet, - string.Empty, - false, + errorMessage, + instanceFailure, name: name, expectedOutputName: expectedOutputName); } diff --git a/test/Microsoft.TemplateEngine.IDE.IntegrationTests/End2EndTests.cs b/test/Microsoft.TemplateEngine.IDE.IntegrationTests/End2EndTests.cs index 12aee428754..205df145c19 100644 --- a/test/Microsoft.TemplateEngine.IDE.IntegrationTests/End2EndTests.cs +++ b/test/Microsoft.TemplateEngine.IDE.IntegrationTests/End2EndTests.cs @@ -390,7 +390,7 @@ internal async Task Test_CreateAsync_PreferDefaultNameInvalidParameters() .CreateAsync(foundTemplates[0].Info, null, output, parameters) .ConfigureAwait(false); - Assert.Equal(CreationResultStatus.MissingMandatoryParam, result.Status); + Assert.Equal(CreationResultStatus.TemplateIssueDetected, result.Status); } } } From 03607cc63d2011cb96ddce14f4bb0d4a2733e461 Mon Sep 17 00:00:00 2001 From: Mariana Dematte Date: Wed, 28 Dec 2022 00:13:48 -0800 Subject: [PATCH 13/17] Added PreferDefaultName to generator tests --- test/Microsoft.TemplateEngine.Edge.UnitTests/GeneratorTests.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/Microsoft.TemplateEngine.Edge.UnitTests/GeneratorTests.cs b/test/Microsoft.TemplateEngine.Edge.UnitTests/GeneratorTests.cs index d32fd7649e2..0e0866703f2 100644 --- a/test/Microsoft.TemplateEngine.Edge.UnitTests/GeneratorTests.cs +++ b/test/Microsoft.TemplateEngine.Edge.UnitTests/GeneratorTests.cs @@ -142,6 +142,8 @@ public Template(IGenerator generator, IMountPoint mountPoint) public string? DefaultName => null; + public bool PreferDefaultName => false; + public string Identity => "Static.Test.Template"; public Guid GeneratorId => Generator.Id; From 34cfd89b32ccb0f62100cb8f438bf338e825708b Mon Sep 17 00:00:00 2001 From: Mariana Dematte Date: Thu, 29 Dec 2022 01:22:23 -0800 Subject: [PATCH 14/17] Changed error message when there is no DefaultName --- .../LocalizableStrings.Designer.cs | 9 +++++++++ .../LocalizableStrings.resx | 6 +++++- .../Template/TemplateCreator.cs | 6 +++--- .../xlf/LocalizableStrings.cs.xlf | 5 +++++ .../xlf/LocalizableStrings.de.xlf | 5 +++++ .../xlf/LocalizableStrings.es.xlf | 5 +++++ .../xlf/LocalizableStrings.fr.xlf | 5 +++++ .../xlf/LocalizableStrings.it.xlf | 5 +++++ .../xlf/LocalizableStrings.ja.xlf | 5 +++++ .../xlf/LocalizableStrings.ko.xlf | 5 +++++ .../xlf/LocalizableStrings.pl.xlf | 5 +++++ .../xlf/LocalizableStrings.pt-BR.xlf | 5 +++++ .../xlf/LocalizableStrings.ru.xlf | 5 +++++ .../xlf/LocalizableStrings.tr.xlf | 5 +++++ .../xlf/LocalizableStrings.zh-Hans.xlf | 5 +++++ .../xlf/LocalizableStrings.zh-Hant.xlf | 5 +++++ .../TemplateCreatorTests.cs | 2 +- 17 files changed, 83 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.TemplateEngine.Edge/LocalizableStrings.Designer.cs b/src/Microsoft.TemplateEngine.Edge/LocalizableStrings.Designer.cs index 64d1c97bae8..3c1d784b9d4 100644 --- a/src/Microsoft.TemplateEngine.Edge/LocalizableStrings.Designer.cs +++ b/src/Microsoft.TemplateEngine.Edge/LocalizableStrings.Designer.cs @@ -670,6 +670,15 @@ internal static string TemplateCreator_TemplateCreationResult_Error_DestructiveC } } + /// + /// Looks up a localized string similar to Failed to create template due naming issues. + /// + internal static string TemplateCreator_TemplateCreationResult_Error_NoDefaultName { + get { + return ResourceManager.GetString("TemplateCreator_TemplateCreationResult_Error_NoDefaultName", resourceCulture); + } + } + /// /// Looks up a localized string similar to Failed to load host data in {0} at {1}.. /// diff --git a/src/Microsoft.TemplateEngine.Edge/LocalizableStrings.resx b/src/Microsoft.TemplateEngine.Edge/LocalizableStrings.resx index 8d5ef6ff681..e650f9ce0e7 100644 --- a/src/Microsoft.TemplateEngine.Edge/LocalizableStrings.resx +++ b/src/Microsoft.TemplateEngine.Edge/LocalizableStrings.resx @@ -351,6 +351,10 @@ Details: {1}. Failed to create template. Details: {0} + + Failed to create template due naming issues + Template does not contain a DefaultName that can be used when --name is not passed + Destructive changes detected. @@ -392,4 +396,4 @@ Template cache will be recreated on the next run. 'IWorkloadsInfoProvider' component provided by host provided some duplicated workloads (duplicates: {0}). Duplicates will be skipped. {0} is the list of duplicates - \ No newline at end of file + diff --git a/src/Microsoft.TemplateEngine.Edge/Template/TemplateCreator.cs b/src/Microsoft.TemplateEngine.Edge/Template/TemplateCreator.cs index 34712489446..ec0b97de404 100644 --- a/src/Microsoft.TemplateEngine.Edge/Template/TemplateCreator.cs +++ b/src/Microsoft.TemplateEngine.Edge/Template/TemplateCreator.cs @@ -103,8 +103,7 @@ public async Task InstantiateAsync( return new TemplateCreationResult(CreationResultStatus.NotFound, templateInfo.Name, LocalizableStrings.TemplateCreator_TemplateCreationResult_Error_CouldNotLoadTemplate); } - string? realName = name is not null ? name : templateInfo.PreferDefaultName ? templateInfo.DefaultName : null; - realName = realName is null ? fallbackName : realName; + string? realName = null; if (!string.IsNullOrEmpty(name)) { realName = name; @@ -113,7 +112,8 @@ public async Task InstantiateAsync( { if (string.IsNullOrEmpty(templateInfo.DefaultName)) { - return new TemplateCreationResult(CreationResultStatus.TemplateIssueDetected, template.Name, "--name"); + return new TemplateCreationResult( + CreationResultStatus.TemplateIssueDetected, template.Name, LocalizableStrings.TemplateCreator_TemplateCreationResult_Error_NoDefaultName); } realName = templateInfo.DefaultName; } diff --git a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.cs.xlf b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.cs.xlf index 0af46f17bf7..7ad64fb7786 100644 --- a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.cs.xlf +++ b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.cs.xlf @@ -354,6 +354,11 @@ Podrobnosti: {0}. Rozpoznaly se destruktivní změny. + + Failed to create template due naming issues + Failed to create template due naming issues + Template does not contain a DefaultName that can be used when --name is not passed + Failed to load host data in {0} at {1}. Nepovedlo se načíst data hostitele v {0} v {1}. diff --git a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.de.xlf b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.de.xlf index f3687350519..e078398dc4b 100644 --- a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.de.xlf +++ b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.de.xlf @@ -354,6 +354,11 @@ Details: {0}. Es wurden destruktive Änderungen erkannt. + + Failed to create template due naming issues + Failed to create template due naming issues + Template does not contain a DefaultName that can be used when --name is not passed + Failed to load host data in {0} at {1}. Fehler beim Laden von Host Daten in {0} bei {1}. diff --git a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.es.xlf b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.es.xlf index d4ab64220cc..8d0fd3d2e65 100644 --- a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.es.xlf +++ b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.es.xlf @@ -354,6 +354,11 @@ Detalles: {0}. Cambios destructivos detectados. + + Failed to create template due naming issues + Failed to create template due naming issues + Template does not contain a DefaultName that can be used when --name is not passed + Failed to load host data in {0} at {1}. No se pudieron cargar los datos de host en {0} en {1}. diff --git a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.fr.xlf b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.fr.xlf index aca1cef018c..77262a38cc5 100644 --- a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.fr.xlf +++ b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.fr.xlf @@ -354,6 +354,11 @@ Détails : {0}. Modifications destructrices détectées. + + Failed to create template due naming issues + Failed to create template due naming issues + Template does not contain a DefaultName that can be used when --name is not passed + Failed to load host data in {0} at {1}. Échec du chargement des données de l’hôte dans la {0} à {1}. diff --git a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.it.xlf b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.it.xlf index 3f0c29e229f..941dac10bc4 100644 --- a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.it.xlf +++ b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.it.xlf @@ -354,6 +354,11 @@ Dettagli: {0}. Rilevate modifiche distruttive. + + Failed to create template due naming issues + Failed to create template due naming issues + Template does not contain a DefaultName that can be used when --name is not passed + Failed to load host data in {0} at {1}. Non è stato possibile caricare i dati dell'host in {0} in {1}. diff --git a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.ja.xlf b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.ja.xlf index 4c7d477dc71..74d1af6b918 100644 --- a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.ja.xlf +++ b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.ja.xlf @@ -354,6 +354,11 @@ Details: {0} 重大な変更が検出されました。 + + Failed to create template due naming issues + Failed to create template due naming issues + Template does not contain a DefaultName that can be used when --name is not passed + Failed to load host data in {0} at {1}. {1} の {0} でホスト データを読み込めませんでした。 diff --git a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.ko.xlf b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.ko.xlf index 4cfb208ea43..7b89c6bd801 100644 --- a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.ko.xlf +++ b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.ko.xlf @@ -354,6 +354,11 @@ Details: {0} 파괴적 변경이 감지되었습니다. + + Failed to create template due naming issues + Failed to create template due naming issues + Template does not contain a DefaultName that can be used when --name is not passed + Failed to load host data in {0} at {1}. {0}에서 {1}의 호스트 데이터를 로드하지 못했습니다. diff --git a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.pl.xlf b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.pl.xlf index 959d29a0beb..42bdb39733e 100644 --- a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.pl.xlf +++ b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.pl.xlf @@ -354,6 +354,11 @@ Szczegóły: {0}. Wykryto niszczące zmiany. + + Failed to create template due naming issues + Failed to create template due naming issues + Template does not contain a DefaultName that can be used when --name is not passed + Failed to load host data in {0} at {1}. Nie udało się załadować danych hosta w klasie {0} z {1}. diff --git a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.pt-BR.xlf b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.pt-BR.xlf index 7fde36bb02b..f9ddb800c4b 100644 --- a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.pt-BR.xlf +++ b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.pt-BR.xlf @@ -354,6 +354,11 @@ Detalhes: {0} Alterações destrutivas detectadas. + + Failed to create template due naming issues + Failed to create template due naming issues + Template does not contain a DefaultName that can be used when --name is not passed + Failed to load host data in {0} at {1}. Falha ao carregar os dados do host em {0} às {1}. diff --git a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.ru.xlf b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.ru.xlf index d4454a2d710..1272814dadb 100644 --- a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.ru.xlf +++ b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.ru.xlf @@ -354,6 +354,11 @@ Details: {0} Обнаружены необратимые изменения. + + Failed to create template due naming issues + Failed to create template due naming issues + Template does not contain a DefaultName that can be used when --name is not passed + Failed to load host data in {0} at {1}. Не удалось загрузить данные узла в {0} в {1}. diff --git a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.tr.xlf b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.tr.xlf index 91a4a0ea263..69c0ea9f7a6 100644 --- a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.tr.xlf +++ b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.tr.xlf @@ -354,6 +354,11 @@ Ayrıntılar: {0}. Zararlı değişiklikler algılandı. + + Failed to create template due naming issues + Failed to create template due naming issues + Template does not contain a DefaultName that can be used when --name is not passed + Failed to load host data in {0} at {1}. {1} konumundaki {0} içinde yer alan konak verileri yüklenemedi. diff --git a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.zh-Hans.xlf b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.zh-Hans.xlf index 4219df9809a..5fafbf40439 100644 --- a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.zh-Hans.xlf +++ b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.zh-Hans.xlf @@ -354,6 +354,11 @@ Details: {0} 检测到破坏性更改。 + + Failed to create template due naming issues + Failed to create template due naming issues + Template does not contain a DefaultName that can be used when --name is not passed + Failed to load host data in {0} at {1}. 无法在 {1} 的 {0} 中加载主机数据。 diff --git a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.zh-Hant.xlf b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.zh-Hant.xlf index a92b82b1dab..2e8c247219e 100644 --- a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.zh-Hant.xlf +++ b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.zh-Hant.xlf @@ -354,6 +354,11 @@ Details: {0} 偵測到破壞性變更。 + + Failed to create template due naming issues + Failed to create template due naming issues + Template does not contain a DefaultName that can be used when --name is not passed + Failed to load host data in {0} at {1}. 無法在 {1} 的 {0} 處載入主機資料。 diff --git a/test/Microsoft.TemplateEngine.Edge.UnitTests/TemplateCreatorTests.cs b/test/Microsoft.TemplateEngine.Edge.UnitTests/TemplateCreatorTests.cs index 5b148a639d7..53d022db006 100644 --- a/test/Microsoft.TemplateEngine.Edge.UnitTests/TemplateCreatorTests.cs +++ b/test/Microsoft.TemplateEngine.Edge.UnitTests/TemplateCreatorTests.cs @@ -706,7 +706,7 @@ await InstantiateAsyncHelper( [InlineData(TemplateConfigPreferDefaultNameWithDefaultName, "thisIsAName", "./thisIsAName.cs", false, "")] [InlineData(TemplateConfigPreferDefaultNameWithDefaultName, null, "./defaultName.cs", false, "")] [InlineData(TemplateConfigNoPreferDefaultNameWithDefaultName, null, "./tst2.cs", false, "")] - [InlineData(TemplateConfigPreferDefaultNameWithoutDefaultName, null, "./tst2.cs", true, "--name")] + [InlineData(TemplateConfigPreferDefaultNameWithoutDefaultName, null, "./tst2.cs", true, "Failed to create template due naming issues")] public async void InstantiateAsync_PreferDefaultName(string templateConfig, string? name, string expectedOutputName, bool instanceFailure, string errorMessage) { string sourceSnippet = """ From b15f24ea9bf0d2aa216528c697b7f4c386b1fa44 Mon Sep 17 00:00:00 2001 From: Mariana Dematte Date: Thu, 29 Dec 2022 01:49:24 -0800 Subject: [PATCH 15/17] Changed error message to be clearer --- src/Microsoft.TemplateEngine.Edge/LocalizableStrings.resx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.TemplateEngine.Edge/LocalizableStrings.resx b/src/Microsoft.TemplateEngine.Edge/LocalizableStrings.resx index e650f9ce0e7..95a96ba1a92 100644 --- a/src/Microsoft.TemplateEngine.Edge/LocalizableStrings.resx +++ b/src/Microsoft.TemplateEngine.Edge/LocalizableStrings.resx @@ -353,7 +353,7 @@ Details: {0} Failed to create template due naming issues - Template does not contain a DefaultName that can be used when --name is not passed + Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating Destructive changes detected. From 3cf0e7626824d789e0bf7a5cae227aca64c4298b Mon Sep 17 00:00:00 2001 From: Mariana Dematte Date: Thu, 29 Dec 2022 16:09:17 -0800 Subject: [PATCH 16/17] Addressed PR comments --- .../PublicAPI.Unshipped.txt | 4 ++-- .../LocalizableStrings.Designer.cs | 2 +- src/Microsoft.TemplateEngine.Edge/LocalizableStrings.resx | 3 +-- .../xlf/LocalizableStrings.cs.xlf | 6 +++--- .../xlf/LocalizableStrings.de.xlf | 6 +++--- .../xlf/LocalizableStrings.es.xlf | 6 +++--- .../xlf/LocalizableStrings.fr.xlf | 6 +++--- .../xlf/LocalizableStrings.it.xlf | 6 +++--- .../xlf/LocalizableStrings.ja.xlf | 6 +++--- .../xlf/LocalizableStrings.ko.xlf | 6 +++--- .../xlf/LocalizableStrings.pl.xlf | 6 +++--- .../xlf/LocalizableStrings.pt-BR.xlf | 6 +++--- .../xlf/LocalizableStrings.ru.xlf | 6 +++--- .../xlf/LocalizableStrings.tr.xlf | 6 +++--- .../xlf/LocalizableStrings.zh-Hans.xlf | 6 +++--- .../xlf/LocalizableStrings.zh-Hant.xlf | 6 +++--- .../TemplateCreatorTests.cs | 2 +- .../End2EndTests.cs | 3 +++ 18 files changed, 47 insertions(+), 45 deletions(-) diff --git a/src/Microsoft.TemplateEngine.Abstractions/PublicAPI.Unshipped.txt b/src/Microsoft.TemplateEngine.Abstractions/PublicAPI.Unshipped.txt index 789c5301cb6..5262fc4a789 100644 --- a/src/Microsoft.TemplateEngine.Abstractions/PublicAPI.Unshipped.txt +++ b/src/Microsoft.TemplateEngine.Abstractions/PublicAPI.Unshipped.txt @@ -1,4 +1,4 @@ -Microsoft.TemplateEngine.Abstractions.ITemplate.TemplateSourceRoot.get -> Microsoft.TemplateEngine.Abstractions.Mount.IDirectory! +Microsoft.TemplateEngine.Abstractions.ITemplate.TemplateSourceRoot.get -> Microsoft.TemplateEngine.Abstractions.Mount.IDirectory! Microsoft.TemplateEngine.Abstractions.IVariableCollection Microsoft.TemplateEngine.Abstractions.IVariableCollection.Parent.get -> Microsoft.TemplateEngine.Abstractions.IVariableCollection? Microsoft.TemplateEngine.Abstractions.IVariableCollection.Parent.set -> void @@ -6,4 +6,4 @@ Microsoft.TemplateEngine.Abstractions.ITemplateInfo.PreferDefaultName.get -> boo Microsoft.TemplateEngine.Abstractions.Parameters.ParameterSetDataExtensions static Microsoft.TemplateEngine.Abstractions.Parameters.ParameterSetData.Empty.get -> Microsoft.TemplateEngine.Abstractions.Parameters.IParameterSetData! static Microsoft.TemplateEngine.Abstractions.Parameters.ParameterSetDataExtensions.GetValue(this Microsoft.TemplateEngine.Abstractions.Parameters.IParameterSetData! data, string! parameterName) -> Microsoft.TemplateEngine.Abstractions.Parameters.ParameterData! -static Microsoft.TemplateEngine.Abstractions.Parameters.ParameterSetDataExtensions.TryGetValue(this Microsoft.TemplateEngine.Abstractions.Parameters.IParameterSetData! data, string! parameterName, out Microsoft.TemplateEngine.Abstractions.Parameters.ParameterData? parameterData) -> bool +static Microsoft.TemplateEngine.Abstractions.Parameters.ParameterSetDataExtensions.TryGetValue(this Microsoft.TemplateEngine.Abstractions.Parameters.IParameterSetData! data, string! parameterName, out Microsoft.TemplateEngine.Abstractions.Parameters.ParameterData? parameterData) -> bool \ No newline at end of file diff --git a/src/Microsoft.TemplateEngine.Edge/LocalizableStrings.Designer.cs b/src/Microsoft.TemplateEngine.Edge/LocalizableStrings.Designer.cs index 3c1d784b9d4..2aa55578f79 100644 --- a/src/Microsoft.TemplateEngine.Edge/LocalizableStrings.Designer.cs +++ b/src/Microsoft.TemplateEngine.Edge/LocalizableStrings.Designer.cs @@ -671,7 +671,7 @@ internal static string TemplateCreator_TemplateCreationResult_Error_DestructiveC } /// - /// Looks up a localized string similar to Failed to create template due naming issues. + /// Looks up a localized string similar to Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration.. /// internal static string TemplateCreator_TemplateCreationResult_Error_NoDefaultName { get { diff --git a/src/Microsoft.TemplateEngine.Edge/LocalizableStrings.resx b/src/Microsoft.TemplateEngine.Edge/LocalizableStrings.resx index 95a96ba1a92..ceb3b61906d 100644 --- a/src/Microsoft.TemplateEngine.Edge/LocalizableStrings.resx +++ b/src/Microsoft.TemplateEngine.Edge/LocalizableStrings.resx @@ -352,8 +352,7 @@ Details: {1}. Details: {0} - Failed to create template due naming issues - Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating + Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. Destructive changes detected. diff --git a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.cs.xlf b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.cs.xlf index 7ad64fb7786..d1f09c3194b 100644 --- a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.cs.xlf +++ b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.cs.xlf @@ -355,9 +355,9 @@ Podrobnosti: {0}. - Failed to create template due naming issues - Failed to create template due naming issues - Template does not contain a DefaultName that can be used when --name is not passed + Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to load host data in {0} at {1}. diff --git a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.de.xlf b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.de.xlf index e078398dc4b..4223f53f814 100644 --- a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.de.xlf +++ b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.de.xlf @@ -355,9 +355,9 @@ Details: {0}. - Failed to create template due naming issues - Failed to create template due naming issues - Template does not contain a DefaultName that can be used when --name is not passed + Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to load host data in {0} at {1}. diff --git a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.es.xlf b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.es.xlf index 8d0fd3d2e65..f33f7a8c94d 100644 --- a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.es.xlf +++ b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.es.xlf @@ -355,9 +355,9 @@ Detalles: {0}. - Failed to create template due naming issues - Failed to create template due naming issues - Template does not contain a DefaultName that can be used when --name is not passed + Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to load host data in {0} at {1}. diff --git a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.fr.xlf b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.fr.xlf index 77262a38cc5..e6a861e1be2 100644 --- a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.fr.xlf +++ b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.fr.xlf @@ -355,9 +355,9 @@ Détails : {0}. - Failed to create template due naming issues - Failed to create template due naming issues - Template does not contain a DefaultName that can be used when --name is not passed + Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to load host data in {0} at {1}. diff --git a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.it.xlf b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.it.xlf index 941dac10bc4..b615186adc9 100644 --- a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.it.xlf +++ b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.it.xlf @@ -355,9 +355,9 @@ Dettagli: {0}. - Failed to create template due naming issues - Failed to create template due naming issues - Template does not contain a DefaultName that can be used when --name is not passed + Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to load host data in {0} at {1}. diff --git a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.ja.xlf b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.ja.xlf index 74d1af6b918..b58bd4dc39d 100644 --- a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.ja.xlf +++ b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.ja.xlf @@ -355,9 +355,9 @@ Details: {0} - Failed to create template due naming issues - Failed to create template due naming issues - Template does not contain a DefaultName that can be used when --name is not passed + Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to load host data in {0} at {1}. diff --git a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.ko.xlf b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.ko.xlf index 7b89c6bd801..00940836f0c 100644 --- a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.ko.xlf +++ b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.ko.xlf @@ -355,9 +355,9 @@ Details: {0} - Failed to create template due naming issues - Failed to create template due naming issues - Template does not contain a DefaultName that can be used when --name is not passed + Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to load host data in {0} at {1}. diff --git a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.pl.xlf b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.pl.xlf index 42bdb39733e..565485c6c73 100644 --- a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.pl.xlf +++ b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.pl.xlf @@ -355,9 +355,9 @@ Szczegóły: {0}. - Failed to create template due naming issues - Failed to create template due naming issues - Template does not contain a DefaultName that can be used when --name is not passed + Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to load host data in {0} at {1}. diff --git a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.pt-BR.xlf b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.pt-BR.xlf index f9ddb800c4b..c40eab07e25 100644 --- a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.pt-BR.xlf +++ b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.pt-BR.xlf @@ -355,9 +355,9 @@ Detalhes: {0} - Failed to create template due naming issues - Failed to create template due naming issues - Template does not contain a DefaultName that can be used when --name is not passed + Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to load host data in {0} at {1}. diff --git a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.ru.xlf b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.ru.xlf index 1272814dadb..26b290bbb8f 100644 --- a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.ru.xlf +++ b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.ru.xlf @@ -355,9 +355,9 @@ Details: {0} - Failed to create template due naming issues - Failed to create template due naming issues - Template does not contain a DefaultName that can be used when --name is not passed + Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to load host data in {0} at {1}. diff --git a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.tr.xlf b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.tr.xlf index 69c0ea9f7a6..59bceab1d0c 100644 --- a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.tr.xlf +++ b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.tr.xlf @@ -355,9 +355,9 @@ Ayrıntılar: {0}. - Failed to create template due naming issues - Failed to create template due naming issues - Template does not contain a DefaultName that can be used when --name is not passed + Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to load host data in {0} at {1}. diff --git a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.zh-Hans.xlf b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.zh-Hans.xlf index 5fafbf40439..500ed4ca719 100644 --- a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.zh-Hans.xlf +++ b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.zh-Hans.xlf @@ -355,9 +355,9 @@ Details: {0} - Failed to create template due naming issues - Failed to create template due naming issues - Template does not contain a DefaultName that can be used when --name is not passed + Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to load host data in {0} at {1}. diff --git a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.zh-Hant.xlf b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.zh-Hant.xlf index 2e8c247219e..4d909c33bcc 100644 --- a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.zh-Hant.xlf +++ b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.zh-Hant.xlf @@ -355,9 +355,9 @@ Details: {0} - Failed to create template due naming issues - Failed to create template due naming issues - Template does not contain a DefaultName that can be used when --name is not passed + Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to load host data in {0} at {1}. diff --git a/test/Microsoft.TemplateEngine.Edge.UnitTests/TemplateCreatorTests.cs b/test/Microsoft.TemplateEngine.Edge.UnitTests/TemplateCreatorTests.cs index 53d022db006..8159c664d73 100644 --- a/test/Microsoft.TemplateEngine.Edge.UnitTests/TemplateCreatorTests.cs +++ b/test/Microsoft.TemplateEngine.Edge.UnitTests/TemplateCreatorTests.cs @@ -706,7 +706,7 @@ await InstantiateAsyncHelper( [InlineData(TemplateConfigPreferDefaultNameWithDefaultName, "thisIsAName", "./thisIsAName.cs", false, "")] [InlineData(TemplateConfigPreferDefaultNameWithDefaultName, null, "./defaultName.cs", false, "")] [InlineData(TemplateConfigNoPreferDefaultNameWithDefaultName, null, "./tst2.cs", false, "")] - [InlineData(TemplateConfigPreferDefaultNameWithoutDefaultName, null, "./tst2.cs", true, "Failed to create template due naming issues")] + [InlineData(TemplateConfigPreferDefaultNameWithoutDefaultName, null, "./tst2.cs", true, "Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration.")] public async void InstantiateAsync_PreferDefaultName(string templateConfig, string? name, string expectedOutputName, bool instanceFailure, string errorMessage) { string sourceSnippet = """ diff --git a/test/Microsoft.TemplateEngine.IDE.IntegrationTests/End2EndTests.cs b/test/Microsoft.TemplateEngine.IDE.IntegrationTests/End2EndTests.cs index db830fc7f82..d50191e36a4 100644 --- a/test/Microsoft.TemplateEngine.IDE.IntegrationTests/End2EndTests.cs +++ b/test/Microsoft.TemplateEngine.IDE.IntegrationTests/End2EndTests.cs @@ -422,6 +422,9 @@ internal async Task Test_CreateAsync_PreferDefaultNameInvalidParameters() .ConfigureAwait(false); Assert.Equal(CreationResultStatus.TemplateIssueDetected, result.Status); + Assert.Equal( + "Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration.", + result.ErrorMessage); } } } From cf9f182deaf9a0b1655458b57c2baec74decf93a Mon Sep 17 00:00:00 2001 From: Mariana Dematte Date: Fri, 30 Dec 2022 21:04:50 -0800 Subject: [PATCH 17/17] Fixed capitalization --- .../LocalizableStrings.Designer.cs | 2 +- src/Microsoft.TemplateEngine.Edge/LocalizableStrings.resx | 4 ++-- .../xlf/LocalizableStrings.cs.xlf | 4 ++-- .../xlf/LocalizableStrings.de.xlf | 4 ++-- .../xlf/LocalizableStrings.es.xlf | 4 ++-- .../xlf/LocalizableStrings.fr.xlf | 4 ++-- .../xlf/LocalizableStrings.it.xlf | 4 ++-- .../xlf/LocalizableStrings.ja.xlf | 4 ++-- .../xlf/LocalizableStrings.ko.xlf | 4 ++-- .../xlf/LocalizableStrings.pl.xlf | 4 ++-- .../xlf/LocalizableStrings.pt-BR.xlf | 4 ++-- .../xlf/LocalizableStrings.ru.xlf | 4 ++-- .../xlf/LocalizableStrings.tr.xlf | 4 ++-- .../xlf/LocalizableStrings.zh-Hans.xlf | 4 ++-- .../xlf/LocalizableStrings.zh-Hant.xlf | 4 ++-- .../TemplateCreatorTests.cs | 2 +- .../End2EndTests.cs | 2 +- 17 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/Microsoft.TemplateEngine.Edge/LocalizableStrings.Designer.cs b/src/Microsoft.TemplateEngine.Edge/LocalizableStrings.Designer.cs index 2aa55578f79..433ce0f1cd3 100644 --- a/src/Microsoft.TemplateEngine.Edge/LocalizableStrings.Designer.cs +++ b/src/Microsoft.TemplateEngine.Edge/LocalizableStrings.Designer.cs @@ -671,7 +671,7 @@ internal static string TemplateCreator_TemplateCreationResult_Error_DestructiveC } /// - /// Looks up a localized string similar to Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration.. + /// Looks up a localized string similar to Failed to create template: the template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration.. /// internal static string TemplateCreator_TemplateCreationResult_Error_NoDefaultName { get { diff --git a/src/Microsoft.TemplateEngine.Edge/LocalizableStrings.resx b/src/Microsoft.TemplateEngine.Edge/LocalizableStrings.resx index ceb3b61906d..642be236001 100644 --- a/src/Microsoft.TemplateEngine.Edge/LocalizableStrings.resx +++ b/src/Microsoft.TemplateEngine.Edge/LocalizableStrings.resx @@ -352,7 +352,7 @@ Details: {1}. Details: {0} - Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to create template: the template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. Destructive changes detected. @@ -395,4 +395,4 @@ Template cache will be recreated on the next run. 'IWorkloadsInfoProvider' component provided by host provided some duplicated workloads (duplicates: {0}). Duplicates will be skipped. {0} is the list of duplicates - + \ No newline at end of file diff --git a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.cs.xlf b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.cs.xlf index d1f09c3194b..1eb2dd05a69 100644 --- a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.cs.xlf +++ b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.cs.xlf @@ -355,8 +355,8 @@ Podrobnosti: {0}. - Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. - Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to create template: the template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to create template: the template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. diff --git a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.de.xlf b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.de.xlf index 4223f53f814..922e5ab8d5f 100644 --- a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.de.xlf +++ b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.de.xlf @@ -355,8 +355,8 @@ Details: {0}. - Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. - Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to create template: the template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to create template: the template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. diff --git a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.es.xlf b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.es.xlf index f33f7a8c94d..8e914cff20e 100644 --- a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.es.xlf +++ b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.es.xlf @@ -355,8 +355,8 @@ Detalles: {0}. - Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. - Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to create template: the template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to create template: the template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. diff --git a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.fr.xlf b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.fr.xlf index e6a861e1be2..faee6fe9a7c 100644 --- a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.fr.xlf +++ b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.fr.xlf @@ -355,8 +355,8 @@ Détails : {0}. - Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. - Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to create template: the template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to create template: the template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. diff --git a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.it.xlf b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.it.xlf index b615186adc9..599c11a798c 100644 --- a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.it.xlf +++ b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.it.xlf @@ -355,8 +355,8 @@ Dettagli: {0}. - Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. - Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to create template: the template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to create template: the template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. diff --git a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.ja.xlf b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.ja.xlf index b58bd4dc39d..56bb07be653 100644 --- a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.ja.xlf +++ b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.ja.xlf @@ -355,8 +355,8 @@ Details: {0} - Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. - Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to create template: the template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to create template: the template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. diff --git a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.ko.xlf b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.ko.xlf index 00940836f0c..d2507d66469 100644 --- a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.ko.xlf +++ b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.ko.xlf @@ -355,8 +355,8 @@ Details: {0} - Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. - Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to create template: the template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to create template: the template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. diff --git a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.pl.xlf b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.pl.xlf index 565485c6c73..c5366681fed 100644 --- a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.pl.xlf +++ b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.pl.xlf @@ -355,8 +355,8 @@ Szczegóły: {0}. - Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. - Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to create template: the template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to create template: the template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. diff --git a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.pt-BR.xlf b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.pt-BR.xlf index c40eab07e25..5b7adc22cb0 100644 --- a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.pt-BR.xlf +++ b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.pt-BR.xlf @@ -355,8 +355,8 @@ Detalhes: {0} - Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. - Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to create template: the template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to create template: the template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. diff --git a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.ru.xlf b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.ru.xlf index 26b290bbb8f..ad305ffe309 100644 --- a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.ru.xlf +++ b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.ru.xlf @@ -355,8 +355,8 @@ Details: {0} - Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. - Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to create template: the template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to create template: the template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. diff --git a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.tr.xlf b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.tr.xlf index 59bceab1d0c..335ca909e73 100644 --- a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.tr.xlf +++ b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.tr.xlf @@ -355,8 +355,8 @@ Ayrıntılar: {0}. - Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. - Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to create template: the template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to create template: the template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. diff --git a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.zh-Hans.xlf b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.zh-Hans.xlf index 500ed4ca719..8771dabf285 100644 --- a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.zh-Hans.xlf +++ b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.zh-Hans.xlf @@ -355,8 +355,8 @@ Details: {0} - Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. - Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to create template: the template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to create template: the template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. diff --git a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.zh-Hant.xlf b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.zh-Hant.xlf index 4d909c33bcc..3eea5b18f60 100644 --- a/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.zh-Hant.xlf +++ b/src/Microsoft.TemplateEngine.Edge/xlf/LocalizableStrings.zh-Hant.xlf @@ -355,8 +355,8 @@ Details: {0} - Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. - Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to create template: the template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. + Failed to create template: the template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration. diff --git a/test/Microsoft.TemplateEngine.Edge.UnitTests/TemplateCreatorTests.cs b/test/Microsoft.TemplateEngine.Edge.UnitTests/TemplateCreatorTests.cs index 8159c664d73..abf87ce2812 100644 --- a/test/Microsoft.TemplateEngine.Edge.UnitTests/TemplateCreatorTests.cs +++ b/test/Microsoft.TemplateEngine.Edge.UnitTests/TemplateCreatorTests.cs @@ -706,7 +706,7 @@ await InstantiateAsyncHelper( [InlineData(TemplateConfigPreferDefaultNameWithDefaultName, "thisIsAName", "./thisIsAName.cs", false, "")] [InlineData(TemplateConfigPreferDefaultNameWithDefaultName, null, "./defaultName.cs", false, "")] [InlineData(TemplateConfigNoPreferDefaultNameWithDefaultName, null, "./tst2.cs", false, "")] - [InlineData(TemplateConfigPreferDefaultNameWithoutDefaultName, null, "./tst2.cs", true, "Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration.")] + [InlineData(TemplateConfigPreferDefaultNameWithoutDefaultName, null, "./tst2.cs", true, "Failed to create template: the template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration.")] public async void InstantiateAsync_PreferDefaultName(string templateConfig, string? name, string expectedOutputName, bool instanceFailure, string errorMessage) { string sourceSnippet = """ diff --git a/test/Microsoft.TemplateEngine.IDE.IntegrationTests/End2EndTests.cs b/test/Microsoft.TemplateEngine.IDE.IntegrationTests/End2EndTests.cs index d50191e36a4..621ef0d2dca 100644 --- a/test/Microsoft.TemplateEngine.IDE.IntegrationTests/End2EndTests.cs +++ b/test/Microsoft.TemplateEngine.IDE.IntegrationTests/End2EndTests.cs @@ -423,7 +423,7 @@ internal async Task Test_CreateAsync_PreferDefaultNameInvalidParameters() Assert.Equal(CreationResultStatus.TemplateIssueDetected, result.Status); Assert.Equal( - "Failed to create template: the Template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration.", + "Failed to create template: the template name is not specified. Template configuration does not configure a default name that can be used when name is not specified. Specify the name for the template when instantiating or configure a default name in the template configuration.", result.ErrorMessage); } }