Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Localization model validation #3216

Merged
merged 11 commits into from
Jun 10, 2021
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#nullable enable

using System.IO;
using Microsoft.TemplateEngine.Abstractions.Mount;

namespace Microsoft.TemplateEngine.Orchestrator.RunnableProjects
{
internal static class IFileSystemInfoExtensions
{
/// <summary>
/// Returns full path to <paramref name="fileSystemInfo"/> including mount point URI in a format
/// that is suitable for displaying in the CLI or printing to logs.
/// This method wraps the path with quotes if it contains spaces.
/// </summary>
/// <param name="fileSystemInfo">the file system info to get full path for.</param>
/// <returns>
/// Full path to <paramref name="fileSystemInfo"/> including mount point URI.
/// If mount point is not a directory, the path is returned as 'mount point URI(path inside mount point)'.
/// </returns>
internal static string GetDisplayPath(this IFileSystemInfo fileSystemInfo)
{
string result = string.Empty;
if (fileSystemInfo.MountPoint.EnvironmentSettings.Host.FileSystem.DirectoryExists(fileSystemInfo.MountPoint.MountPointUri))
{
//mount point is a directory, combine paths
result = Path.Combine(fileSystemInfo.MountPoint.MountPointUri, fileSystemInfo.FullPath.Trim('/', '\\'));
bekir-ozturk marked this conversation as resolved.
Show resolved Hide resolved
}
else
{
//assuming file or anything else
result = $"{fileSystemInfo.MountPoint.MountPointUri}({fileSystemInfo.FullPath})";
}

if (result.Contains(" "))
bekir-ozturk marked this conversation as resolved.
Show resolved Hide resolved
{
result = '"' + result + '"';
}

return result;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ internal interface IRunnableProjectConfig

IReadOnlyList<string> IgnoreFileNames { get; }

IReadOnlyList<IPostActionModel> PostActionModel { get; }
IReadOnlyList<IPostActionModel> PostActionModels { get; }

IReadOnlyList<ICreationPathModel> PrimaryOutputs { get; }

string GeneratorVersions { get; }

IReadOnlyDictionary<string, IBaselineInfo> BaselineInfo { get; }

void Evaluate(IParameterSet parameters, IVariableCollection rootVariableCollection, IFileSystemInfo configFile);
void Evaluate(IParameterSet parameters, IVariableCollection rootVariableCollection);
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,40 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#nullable enable

using System.Collections.Generic;

namespace Microsoft.TemplateEngine.Orchestrator.RunnableProjects
{
/// <summary>
/// Model, representing the data of a symbol.
/// </summary>
internal interface ISymbolModel
{
/// <summary>
/// Gets the type of the symbol.
/// </summary>
string Type { get; }

string Binding { get; set; }
/// <summary>
/// Gets the name of the host property or the environment variable which will provide the value of this symbol.
/// </summary>
string? Binding { get; }

string Replaces { get; set; }
/// <summary>
/// Gets the text that should be replaced by the value of this symbol.
/// </summary>
string? Replaces { get; }

/// <summary>
/// Gets the replacement contexts that determine when this symbol is allowed to do replacement operations.
/// </summary>
IReadOnlyList<IReplacementContext> ReplacementContexts { get; }

string FileRename { get; set; }
/// <summary>
/// Gets the part of the file name that should be replaced with the value of this symbol.
/// </summary>
string? FileRename { get; }
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading