Use one namespace for the three client code generation projects
- also cleared out most uses of `GetDocument` and `GenerationTasks` in MSBuild and strings - temporarily fixed up T4 templates, adding Resources.tt (will remove custom generation soon)
This commit is contained in:
parent
95b4dc8ca0
commit
25d0916b49
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
using System;
|
||||
|
||||
namespace GetDocument
|
||||
namespace Microsoft.Extensions.ApiDescription.Client
|
||||
{
|
||||
internal class AnsiConsole
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
namespace GetDocument
|
||||
namespace Microsoft.Extensions.ApiDescription.Client
|
||||
{
|
||||
internal static class AnsiConstants
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ using System.Diagnostics;
|
|||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace GetDocument
|
||||
namespace Microsoft.Extensions.ApiDescription.Client
|
||||
{
|
||||
internal class AnsiTextWriter
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
using System;
|
||||
|
||||
namespace GetDocument
|
||||
namespace Microsoft.Extensions.ApiDescription.Client
|
||||
{
|
||||
internal class CommandException : Exception
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using GetDocument.Properties;
|
||||
using Microsoft.DotNet.Cli.CommandLine;
|
||||
using Microsoft.Extensions.ApiDescription.Client.Properties;
|
||||
|
||||
namespace GetDocument.Commands
|
||||
namespace Microsoft.Extensions.ApiDescription.Client.Commands
|
||||
{
|
||||
internal abstract class CommandBase
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,17 +8,17 @@ using System.Reflection;
|
|||
#if NETCOREAPP2_0
|
||||
using System.Runtime.Loader;
|
||||
#endif
|
||||
using GetDocument.Properties;
|
||||
using Microsoft.DotNet.Cli.CommandLine;
|
||||
using Microsoft.Extensions.ApiDescription.Client.Properties;
|
||||
|
||||
namespace GetDocument.Commands
|
||||
namespace Microsoft.Extensions.ApiDescription.Client.Commands
|
||||
{
|
||||
internal class GetDocumentCommand : ProjectCommandBase
|
||||
{
|
||||
internal const string FallbackDocumentName = "v1";
|
||||
internal const string FallbackMethod = "Generate";
|
||||
internal const string FallbackService = "Microsoft.Extensions.ApiDescription.IDocumentProvider";
|
||||
private const string WorkerType = "GetDocument.Commands.GetDocumentCommandWorker";
|
||||
private const string WorkerType = "Microsoft.Extensions.ApiDescription.Client.Commands.GetDocumentCommandWorker";
|
||||
|
||||
private CommandOption _documentName;
|
||||
private CommandOption _method;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
|
||||
namespace GetDocument.Commands
|
||||
namespace Microsoft.Extensions.ApiDescription.Client.Commands
|
||||
{
|
||||
[Serializable]
|
||||
public class GetDocumentCommandContext
|
||||
|
|
|
|||
|
|
@ -4,14 +4,13 @@ using System.IO;
|
|||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using GenerationTasks;
|
||||
using GetDocument.Properties;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.TestHost;
|
||||
using Microsoft.Extensions.ApiDescription.Client.Properties;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace GetDocument.Commands
|
||||
namespace Microsoft.Extensions.ApiDescription.Client.Commands
|
||||
{
|
||||
internal class GetDocumentCommandWorker
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
using Microsoft.DotNet.Cli.CommandLine;
|
||||
|
||||
namespace GetDocument.Commands
|
||||
namespace Microsoft.Extensions.ApiDescription.Client.Commands
|
||||
{
|
||||
internal class HelpCommandBase : CommandBase
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using GetDocument.Properties;
|
||||
using Microsoft.DotNet.Cli.CommandLine;
|
||||
using Microsoft.Extensions.ApiDescription.Client.Properties;
|
||||
|
||||
namespace GetDocument.Commands
|
||||
namespace Microsoft.Extensions.ApiDescription.Client.Commands
|
||||
{
|
||||
internal abstract class ProjectCommandBase : HelpCommandBase
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<Description>GetDocument Command-line Tool inside man</Description>
|
||||
<IsPackable>false</IsPackable>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>GetDocument</RootNamespace>
|
||||
<RootNamespace>Microsoft.Extensions.ApiDescription.Client</RootNamespace>
|
||||
<TargetFrameworks>netcoreapp2.0;net461</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using GetDocument.Properties;
|
||||
using Microsoft.DotNet.Cli.CommandLine;
|
||||
using Microsoft.Extensions.ApiDescription.Client.Properties;
|
||||
|
||||
namespace GetDocument
|
||||
namespace Microsoft.Extensions.ApiDescription.Client
|
||||
{
|
||||
internal static class Json
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
using System;
|
||||
using GenerationTasks;
|
||||
|
||||
namespace GetDocument
|
||||
namespace Microsoft.Extensions.ApiDescription.Client
|
||||
{
|
||||
public class LogWrapper : ILogWrapper
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,18 +3,10 @@
|
|||
|
||||
using System.Reflection;
|
||||
|
||||
namespace GetDocument
|
||||
namespace Microsoft.Extensions.ApiDescription.Client
|
||||
{
|
||||
/// <summary>
|
||||
/// This API supports the GetDocument infrastructure and is not intended to be used
|
||||
/// directly from your code. This API may change or be removed in future releases.
|
||||
/// </summary>
|
||||
public static class ProductInfo
|
||||
internal static class ProductInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// This API supports the GetDocument infrastructure and is not intended to be used
|
||||
/// directly from your code. This API may change or be removed in future releases.
|
||||
/// </summary>
|
||||
public static string GetVersion()
|
||||
=> typeof(ProductInfo)
|
||||
.Assembly
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@
|
|||
|
||||
using System;
|
||||
using System.Text;
|
||||
using GetDocument.Commands;
|
||||
using Microsoft.DotNet.Cli.CommandLine;
|
||||
using Microsoft.Extensions.ApiDescription.Client.Commands;
|
||||
|
||||
namespace GetDocument
|
||||
namespace Microsoft.Extensions.ApiDescription.Client
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
|
|
@ -33,7 +33,7 @@ namespace GetDocument
|
|||
if (ex is CommandException
|
||||
|| ex is CommandParsingException
|
||||
|| (ex is WrappedException wrappedException
|
||||
&& wrappedException.Type == "GetDocument.Design.OperationException"))
|
||||
&& wrappedException.Type == "Microsoft.Extensions.ApiDescription.Client.Design.OperationException"))
|
||||
{
|
||||
Reporter.WriteVerbose(ex.ToString());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ using System.Reflection;
|
|||
using System.Resources;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace GetDocument.Properties
|
||||
namespace Microsoft.Extensions.ApiDescription.Client.Properties
|
||||
{
|
||||
/// <summary>
|
||||
/// This API supports the GetDocument infrastructure and is not intended to be used
|
||||
|
|
@ -14,7 +14,7 @@ namespace GetDocument.Properties
|
|||
internal static class Resources
|
||||
{
|
||||
private static readonly ResourceManager _resourceManager
|
||||
= new ResourceManager("GetDocument.Properties.Resources", typeof(Resources).GetTypeInfo().Assembly);
|
||||
= new ResourceManager("Microsoft.Extensions.ApiDescription.Client.Properties.Resources", typeof(Resources).GetTypeInfo().Assembly);
|
||||
|
||||
/// <summary>
|
||||
/// The assembly to use.
|
||||
|
|
|
|||
|
|
@ -3,4 +3,4 @@
|
|||
Session["AccessModifier"] = "internal";
|
||||
Session["NoDiagnostics"] = true;
|
||||
#>
|
||||
<#@ include file="..\..\tools\Resources.tt" #>
|
||||
<#@ include file="..\..\..\tools\Resources.tt" #>
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@
|
|||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using static GetDocument.AnsiConstants;
|
||||
using static Microsoft.Extensions.ApiDescription.Client.AnsiConstants;
|
||||
|
||||
namespace GetDocument
|
||||
namespace Microsoft.Extensions.ApiDescription.Client
|
||||
{
|
||||
internal static class Reporter
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
using System;
|
||||
|
||||
namespace GetDocument
|
||||
namespace Microsoft.Extensions.ApiDescription.Client
|
||||
{
|
||||
internal class WrappedException : Exception
|
||||
{
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ using Microsoft.Build.Utilities;
|
|||
using Task = System.Threading.Tasks.Task;
|
||||
using Utilities = Microsoft.Build.Utilities;
|
||||
|
||||
namespace GenerationTasks
|
||||
namespace Microsoft.Extensions.ApiDescription.Client
|
||||
{
|
||||
/// <summary>
|
||||
/// Downloads a file.
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ using System.Security.Cryptography;
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GenerationTasks
|
||||
namespace Microsoft.Extensions.ApiDescription.Client
|
||||
{
|
||||
internal static class DownloadFileCore
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ using System.IO;
|
|||
using Microsoft.Build.Framework;
|
||||
using Microsoft.Build.Utilities;
|
||||
|
||||
namespace GenerationTasks
|
||||
namespace Microsoft.Extensions.ApiDescription.Client
|
||||
{
|
||||
/// <summary>
|
||||
/// Adds or corrects Namespace and OutputPath metadata in ServiceFileReference items.
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ using System.IO;
|
|||
using Microsoft.Build.Framework;
|
||||
using Microsoft.Build.Utilities;
|
||||
|
||||
namespace GenerationTasks
|
||||
namespace Microsoft.Extensions.ApiDescription.Client
|
||||
{
|
||||
/// <summary>
|
||||
/// Adds or corrects DocumentPath and project-related metadata in ServiceProjectReference items.
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ using System.IO;
|
|||
using Microsoft.Build.Framework;
|
||||
using Microsoft.Build.Utilities;
|
||||
|
||||
namespace GenerationTasks
|
||||
namespace Microsoft.Extensions.ApiDescription.Client
|
||||
{
|
||||
/// <summary>
|
||||
/// Adds or corrects DocumentPath metadata in ServiceUriReference items.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
|
||||
namespace GenerationTasks
|
||||
namespace Microsoft.Extensions.ApiDescription.Client
|
||||
{
|
||||
internal interface ILogWrapper
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using Microsoft.Build.Utilities;
|
||||
|
||||
namespace GenerationTasks
|
||||
namespace Microsoft.Extensions.ApiDescription.Client
|
||||
{
|
||||
internal class LogWrapper : ILogWrapper
|
||||
{
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@
|
|||
<IsPackable>false</IsPackable>
|
||||
<NuspecFile>$(MSBuildProjectName).nuspec</NuspecFile>
|
||||
<PackageTags>Build Tasks;msbuild;DownloadFile;GetFilenameFromUri;code generation</PackageTags>
|
||||
<RootNamespace>GenerationTasks</RootNamespace>
|
||||
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
|
|
|
|||
|
|
@ -2,15 +2,15 @@
|
|||
<Project>
|
||||
<Import Project="NSwagServiceReference.props" />
|
||||
<PropertyGroup>
|
||||
<_GenerationTasksAssemblyTarget Condition="'$(MSBuildRuntimeType)' == 'Core'">netstandard2.0</_GenerationTasksAssemblyTarget>
|
||||
<_GenerationTasksAssemblyTarget Condition="'$(MSBuildRuntimeType)' != 'Core'">net461</_GenerationTasksAssemblyTarget>
|
||||
<_GenerationTasksAssemblyPath>$(MSBuildThisFileDirectory)/../tasks/$(_GenerationTasksAssemblyTarget)/GenerationTasks.dll</_GenerationTasksAssemblyPath>
|
||||
<_GenerationTasksAssemblyTarget />
|
||||
<_ApiDescriptionTasksAssemblyTarget Condition="'$(MSBuildRuntimeType)' == 'Core'">netstandard2.0</_ApiDescriptionTasksAssemblyTarget>
|
||||
<_ApiDescriptionTasksAssemblyTarget Condition="'$(MSBuildRuntimeType)' != 'Core'">net461</_ApiDescriptionTasksAssemblyTarget>
|
||||
<_ApiDescriptionTasksAssemblyPath>$(MSBuildThisFileDirectory)/../tasks/$(_ApiDescriptionTasksAssemblyTarget)/Microsoft.Extensions.ApiDescription.Client.dll</_ApiDescriptionTasksAssemblyPath>
|
||||
<_ApiDescriptionTasksAssemblyTarget />
|
||||
</PropertyGroup>
|
||||
<UsingTask TaskName="GenerationTasks.GetFileReferenceMetadata" AssemblyFile="$(_GenerationTasksAssemblyPath)" />
|
||||
<UsingTask TaskName="GenerationTasks.GetProjectReferenceMetadata" AssemblyFile="$(_GenerationTasksAssemblyPath)" />
|
||||
<UsingTask TaskName="GenerationTasks.GetUriReferenceMetadata" AssemblyFile="$(_GenerationTasksAssemblyPath)" />
|
||||
<UsingTask TaskName="GenerationTasks.DownloadFile" AssemblyFile="$(_GenerationTasksAssemblyPath)" />
|
||||
<UsingTask TaskName="GetFileReferenceMetadata" AssemblyFile="$(_ApiDescriptionTasksAssemblyPath)" />
|
||||
<UsingTask TaskName="GetProjectReferenceMetadata" AssemblyFile="$(_ApiDescriptionTasksAssemblyPath)" />
|
||||
<UsingTask TaskName="GetUriReferenceMetadata" AssemblyFile="$(_ApiDescriptionTasksAssemblyPath)" />
|
||||
<UsingTask TaskName="Microsoft.Extensions.ApiDescription.Client.DownloadFile" AssemblyFile="$(_ApiDescriptionTasksAssemblyPath)" />
|
||||
|
||||
<PropertyGroup>
|
||||
<ServiceProjectReferenceCheckIfNewer Condition="'$(ServiceProjectReferenceCheckIfNewer)' == ''">true</ServiceProjectReferenceCheckIfNewer>
|
||||
|
|
|
|||
|
|
@ -184,9 +184,9 @@
|
|||
<_Temporary Remove="@(_Temporary)" />
|
||||
</ItemGroup>
|
||||
|
||||
<GenerationTasks.GetUriReferenceMetadata DocumentDirectory="$(ServiceUriReferenceDirectory)" Inputs="@(ServiceUriReference)">
|
||||
<GetUriReferenceMetadata DocumentDirectory="$(ServiceUriReferenceDirectory)" Inputs="@(ServiceUriReference)">
|
||||
<Output TaskParameter="Outputs" ItemName="_Temporary" />
|
||||
</GenerationTasks.GetUriReferenceMetadata>
|
||||
</GetUriReferenceMetadata>
|
||||
|
||||
<ItemGroup>
|
||||
<ServiceUriReference Remove="@(ServiceUriReference)" />
|
||||
|
|
@ -196,7 +196,7 @@
|
|||
</Target>
|
||||
|
||||
<Target Name="_ServiceUriReferenceGenerator_Core" Condition="'@(ServiceUriReference)' != ''">
|
||||
<GenerationTasks.DownloadFile Uri="%(ServiceUriReference.Identity)"
|
||||
<Microsoft.Extensions.ApiDescription.Client.DownloadFile Uri="%(ServiceUriReference.Identity)"
|
||||
DestinationPath="%(DocumentPath)"
|
||||
Overwrite="$(ServiceUriReferenceCheckIfNewer)" />
|
||||
|
||||
|
|
@ -215,9 +215,9 @@
|
|||
<_Temporary Remove="@(_Temporary)" />
|
||||
</ItemGroup>
|
||||
|
||||
<GenerationTasks.GetFileReferenceMetadata DocumentDirectory="$(ServiceFileReferenceDirectory)" Inputs="@(ServiceFileReference)">
|
||||
<GetFileReferenceMetadata DocumentDirectory="$(ServiceFileReferenceDirectory)" Inputs="@(ServiceFileReference)">
|
||||
<Output TaskParameter="Outputs" ItemName="_Temporary" />
|
||||
</GenerationTasks.GetFileReferenceMetadata>
|
||||
</GetFileReferenceMetadata>
|
||||
|
||||
<ItemGroup>
|
||||
<ServiceFileReference Remove="@(ServiceFileReference)" />
|
||||
|
|
|
|||
|
|
@ -6,12 +6,12 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.Versioning;
|
||||
using GetDocument.Properties;
|
||||
using Microsoft.DotNet.Cli.CommandLine;
|
||||
using Microsoft.Extensions.ApiDescription.Client.Properties;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace GetDocument.Commands
|
||||
namespace Microsoft.Extensions.ApiDescription.Client.Commands
|
||||
{
|
||||
internal class InvokeCommand : HelpCommandBase
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ using System.Collections.Generic;
|
|||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
|
||||
namespace GetDocument
|
||||
namespace Microsoft.Extensions.ApiDescription.Client
|
||||
{
|
||||
internal static class Exe
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using GetDocument.Commands;
|
||||
using GetDocument.Properties;
|
||||
using Microsoft.DotNet.Cli.CommandLine;
|
||||
using Microsoft.Extensions.ApiDescription.Client.Commands;
|
||||
using Microsoft.Extensions.ApiDescription.Client.Properties;
|
||||
|
||||
namespace GetDocument
|
||||
namespace Microsoft.Extensions.ApiDescription.Client
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,14 +5,14 @@ using System.Collections.Generic;
|
|||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using GetDocument.Properties;
|
||||
using Microsoft.Extensions.ApiDescription.Client.Properties;
|
||||
using IODirectory = System.IO.Directory;
|
||||
|
||||
namespace GetDocument
|
||||
namespace Microsoft.Extensions.ApiDescription.Client
|
||||
{
|
||||
internal class Project
|
||||
{
|
||||
private const string MSBuildResourceName = "GetDocument.ServiceProjectReferenceMetadata";
|
||||
private const string MSBuildResourceName = "Microsoft.Extensions.ApiDescription.Client.ServiceProjectReferenceMetadata";
|
||||
|
||||
private Project()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using GetDocument.Properties;
|
||||
using Microsoft.DotNet.Cli.CommandLine;
|
||||
using Microsoft.Extensions.ApiDescription.Client.Properties;
|
||||
|
||||
namespace GetDocument
|
||||
namespace Microsoft.Extensions.ApiDescription.Client
|
||||
{
|
||||
internal class ProjectOptions
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ using System.Reflection;
|
|||
using System.Resources;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace GetDocument.Properties
|
||||
namespace Microsoft.Extensions.ApiDescription.Client.Properties
|
||||
{
|
||||
/// <summary>
|
||||
/// This API supports the GetDocument infrastructure and is not intended to be used
|
||||
|
|
@ -14,7 +14,7 @@ namespace GetDocument.Properties
|
|||
internal static class Resources
|
||||
{
|
||||
private static readonly ResourceManager _resourceManager
|
||||
= new ResourceManager("GetDocument.Properties.Resources", typeof(Resources).GetTypeInfo().Assembly);
|
||||
= new ResourceManager("Microsoft.Extensions.ApiDescription.Client.Properties.Resources", typeof(Resources).GetTypeInfo().Assembly);
|
||||
|
||||
/// <summary>
|
||||
/// The configuration to use.
|
||||
|
|
@ -23,7 +23,7 @@ namespace GetDocument.Properties
|
|||
=> GetString("ConfigurationDescription");
|
||||
|
||||
/// <summary>
|
||||
/// dotnet getdocument
|
||||
/// dotnet-getdocument
|
||||
/// </summary>
|
||||
public static string CommandFullName
|
||||
=> GetString("CommandFullName");
|
||||
|
|
@ -55,7 +55,7 @@ namespace GetDocument.Properties
|
|||
projectDirectory);
|
||||
|
||||
/// <summary>
|
||||
/// Project '{Project}' targets framework '.NETCoreApp' version '{targetFrameworkVersion}'. This version of the GetDocument Command-line Tool only supports version 2.0 or higher.
|
||||
/// Project '{Project}' targets framework '.NETCoreApp' version '{targetFrameworkVersion}'. This version of the dotnet-getdocument tool only supports version 2.0 or higher.
|
||||
/// </summary>
|
||||
public static string NETCoreApp1Project([CanBeNull] object Project, [CanBeNull] object targetFrameworkVersion)
|
||||
=> string.Format(
|
||||
|
|
@ -63,7 +63,7 @@ namespace GetDocument.Properties
|
|||
Project, targetFrameworkVersion);
|
||||
|
||||
/// <summary>
|
||||
/// Project '{Project}' targets framework '.NETStandard'. There is no runtime associated with this framework, and projects targeting it cannot be executed directly. To use the GetDocument Command-line Tool with this project, add an executable project targeting .NET Core or .NET Framework that references this project and specify it using the --project option; or, update this project to target .NET Core and / or .NET Framework.
|
||||
/// Project '{Project}' targets framework '.NETStandard'. There is no runtime associated with this framework, and projects targeting it cannot be executed directly. To use the dotnet-getdocument tool with this project, add an executable project targeting .NET Core or .NET Framework that references this project and specify it using the --project option; or, update this project to target .NET Core and / or .NET Framework.
|
||||
/// </summary>
|
||||
public static string NETStandardProject([CanBeNull] object Project)
|
||||
=> string.Format(
|
||||
|
|
@ -115,7 +115,7 @@ namespace GetDocument.Properties
|
|||
=> GetString("RuntimeDescription");
|
||||
|
||||
/// <summary>
|
||||
/// Project '{Project}' targets framework '{targetFramework}'. The GetDocument Command-line Tool does not support this framework.
|
||||
/// Project '{Project}' targets framework '{targetFramework}'. The dotnet-getdocument tool does not support this framework.
|
||||
/// </summary>
|
||||
public static string UnsupportedFramework([CanBeNull] object Project, [CanBeNull] object targetFramework)
|
||||
=> string.Format(
|
||||
|
|
|
|||
|
|
@ -3,4 +3,4 @@
|
|||
Session["AccessModifier"] = "internal";
|
||||
Session["NoDiagnostics"] = true;
|
||||
#>
|
||||
<#@ include file="..\..\tools\Resources.tt" #>
|
||||
<#@ include file="..\..\..\tools\Resources.tt" #>
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@
|
|||
<value>The configuration to use.</value>
|
||||
</data>
|
||||
<data name="CommandFullName" xml:space="preserve">
|
||||
<value>dotnet getdocument</value>
|
||||
<value>dotnet-getdocument</value>
|
||||
</data>
|
||||
<data name="FrameworkDescription" xml:space="preserve">
|
||||
<value>The target framework.</value>
|
||||
|
|
@ -136,10 +136,10 @@
|
|||
<value>More than one project was found in directory '{projectDirectory}'. Specify one using its file name.</value>
|
||||
</data>
|
||||
<data name="NETCoreApp1Project" xml:space="preserve">
|
||||
<value>Project '{Project}' targets framework '.NETCoreApp' version '{targetFrameworkVersion}'. This version of the GetDocument Command-line Tool only supports version 2.0 or higher.</value>
|
||||
<value>Project '{Project}' targets framework '.NETCoreApp' version '{targetFrameworkVersion}'. This version of the dotnet-getdocument tool only supports version 2.0 or higher.</value>
|
||||
</data>
|
||||
<data name="NETStandardProject" xml:space="preserve">
|
||||
<value>Project '{Project}' targets framework '.NETStandard'. There is no runtime associated with this framework, and projects targeting it cannot be executed directly. To use the GetDocument Command-line Tool with this project, add an executable project targeting .NET Core or .NET Framework that references this project and specify it using the --project option; or, update this project to target .NET Core and / or .NET Framework.</value>
|
||||
<value>Project '{Project}' targets framework '.NETStandard'. There is no runtime associated with this framework, and projects targeting it cannot be executed directly. To use the dotnet-getdocument tool with this project, add an executable project targeting .NET Core or .NET Framework that references this project and specify it using the --project option; or, update this project to target .NET Core and / or .NET Framework.</value>
|
||||
</data>
|
||||
<data name="NoColorDescription" xml:space="preserve">
|
||||
<value>Do not colorize output.</value>
|
||||
|
|
@ -163,7 +163,7 @@
|
|||
<value>The runtime identifier to use.</value>
|
||||
</data>
|
||||
<data name="UnsupportedFramework" xml:space="preserve">
|
||||
<value>Project '{Project}' targets framework '{targetFramework}'. The GetDocument Command-line Tool does not support this framework.</value>
|
||||
<value>Project '{Project}' targets framework '{targetFramework}'. The dotnet-getdocument tool does not support this framework.</value>
|
||||
</data>
|
||||
<data name="UsingProject" xml:space="preserve">
|
||||
<value>Using project '{project}'.</value>
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
<OutputType>Exe</OutputType>
|
||||
<PackAsTool>true</PackAsTool>
|
||||
<PackageTags>GetDocument;command line;command-line;tool</PackageTags>
|
||||
<RootNamespace>GetDocument</RootNamespace>
|
||||
<RootNamespace>Microsoft.Extensions.ApiDescription.Client</RootNamespace>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,226 @@
|
|||
<#@ template hostspecific="true" #>
|
||||
<#@ assembly name="EnvDTE" #>
|
||||
<#@ assembly name="System.Core" #>
|
||||
<#@ assembly name="System.Windows.Forms" #>
|
||||
<#@ import namespace="System.Collections" #>
|
||||
<#@ import namespace="System.Collections.Generic" #>
|
||||
<#@ import namespace="System.ComponentModel.Design" #>
|
||||
<#@ import namespace="System.IO" #>
|
||||
<#@ import namespace="System.Linq" #>
|
||||
<#@ import namespace="System.Resources" #>
|
||||
<#@ import namespace="System.Text.RegularExpressions" #>
|
||||
<#@ import namespace="EnvDTE" #>
|
||||
<#
|
||||
var model = LoadResources();
|
||||
#>
|
||||
// <auto-generated />
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Resources;
|
||||
using JetBrains.Annotations;
|
||||
<#
|
||||
if (!model.NoDiagnostics)
|
||||
{
|
||||
#>
|
||||
using Microsoft.EntityFrameworkCore.Diagnostics;
|
||||
using Microsoft.Extensions.Logging;
|
||||
<#
|
||||
}
|
||||
#>
|
||||
|
||||
namespace <#= model.Namespace #>
|
||||
{
|
||||
/// <summary>
|
||||
/// This API supports the GetDocument infrastructure and is not intended to be used
|
||||
/// directly from your code. This API may change or be removed in future releases.
|
||||
/// </summary>
|
||||
<#= model.AccessModifier #> static class <#= model.Class #>
|
||||
{
|
||||
private static readonly ResourceManager _resourceManager
|
||||
= new ResourceManager("<#= model.ResourceName #>", typeof(<#= model.Class #>).GetTypeInfo().Assembly);
|
||||
<#
|
||||
foreach (var resource in model.Resources)
|
||||
{
|
||||
#>
|
||||
|
||||
/// <summary>
|
||||
<#
|
||||
foreach (var line in Lines(resource.Value))
|
||||
{
|
||||
#>
|
||||
/// <#= Xml(line) #>
|
||||
<#
|
||||
}
|
||||
#>
|
||||
/// </summary>
|
||||
<#
|
||||
if (resource.ForLogging)
|
||||
{
|
||||
if (resource.Types.Count() > 6)
|
||||
{
|
||||
#>
|
||||
public static readonly FallbackEventDefinition <#= resource.Name #>
|
||||
= new FallbackEventDefinition(
|
||||
<#= resource.EventId #>,
|
||||
LogLevel.<#= resource.Level #>,
|
||||
"<#= resource.EventId #>",
|
||||
_resourceManager.GetString("<#= resource.Name #>"));
|
||||
<#
|
||||
}
|
||||
else
|
||||
{
|
||||
var genericTypes = resource.Types.Any() ? ("<" + List(resource.Types) + ">") : "";
|
||||
#>
|
||||
public static readonly EventDefinition<#= genericTypes #> <#= resource.Name #>
|
||||
= new EventDefinition<#= genericTypes #>(
|
||||
<#= resource.EventId #>,
|
||||
LogLevel.<#= resource.Level #>,
|
||||
"<#= resource.EventId #>",
|
||||
LoggerMessage.Define<#= genericTypes #>(
|
||||
LogLevel.<#= resource.Level #>,
|
||||
<#= resource.EventId #>,
|
||||
_resourceManager.GetString("<#= resource.Name #>")));
|
||||
<#
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (resource.Parameters.Any())
|
||||
{
|
||||
#>
|
||||
public static string <#= resource.Name #>(<#= List("[CanBeNull] object ", resource.Parameters) #>)
|
||||
=> string.Format(
|
||||
GetString("<#= resource.Name #>", <#= List("nameof(", resource.Parameters, ")") #>),
|
||||
<#= List(resource.Parameters) #>);
|
||||
<#
|
||||
}
|
||||
else
|
||||
{
|
||||
#>
|
||||
public static string <#= resource.Name #>
|
||||
=> GetString("<#= resource.Name #>");
|
||||
<#
|
||||
}
|
||||
}
|
||||
}
|
||||
#>
|
||||
|
||||
private static string GetString(string name, params string[] formatterNames)
|
||||
{
|
||||
var value = _resourceManager.GetString(name);
|
||||
for (var i = 0; i < formatterNames.Length; i++)
|
||||
{
|
||||
value = value.Replace("{" + formatterNames[i] + "}", "{" + i + "}");
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
<#+
|
||||
ResourceFile LoadResources()
|
||||
{
|
||||
var result = new ResourceFile();
|
||||
|
||||
if (Session.ContainsKey("AccessModifier"))
|
||||
{
|
||||
result.AccessModifier = (string)Session["AccessModifier"];
|
||||
};
|
||||
|
||||
var services = (IServiceProvider)Host;
|
||||
var dte = (DTE)services.GetService(typeof(DTE));
|
||||
|
||||
if (!Session.TryGetValue("NoDiagnostics", out var noDiagnostics))
|
||||
{
|
||||
noDiagnostics = false;
|
||||
}
|
||||
|
||||
result.NoDiagnostics = (bool)noDiagnostics;
|
||||
|
||||
var resourceFile = (string)Session["ResourceFile"];
|
||||
if (!Path.IsPathRooted(resourceFile))
|
||||
{
|
||||
resourceFile = Host.ResolvePath(resourceFile);
|
||||
}
|
||||
|
||||
var resourceProjectItem = dte.Solution.FindProjectItem(resourceFile);
|
||||
var templateProjectItem = dte.Solution.FindProjectItem(Host.TemplateFile);
|
||||
var project = templateProjectItem.ContainingProject;
|
||||
var rootNamespace = (string)project.Properties.Item("RootNamespace").Value;
|
||||
var resourceDir = Path.GetDirectoryName(resourceFile);
|
||||
var projectDir = (string)project.Properties.Item("FullPath").Value;
|
||||
var resourceNamespace = rootNamespace + "." + resourceDir.Substring(projectDir.Length)
|
||||
.Replace(Path.DirectorySeparatorChar, '.');
|
||||
|
||||
result.Namespace = (string)resourceProjectItem.Properties.Item("CustomToolNamespace")?.Value;
|
||||
if (string.IsNullOrEmpty(result.Namespace))
|
||||
{
|
||||
result.Namespace = resourceNamespace;
|
||||
}
|
||||
|
||||
result.Class = Path.GetFileNameWithoutExtension(resourceFile);
|
||||
|
||||
result.ResourceName = resourceNamespace + "." + result.Class;
|
||||
|
||||
using (var reader = new ResXResourceReader(resourceFile))
|
||||
{
|
||||
reader.UseResXDataNodes = true;
|
||||
|
||||
result.Resources = Enumerable.ToList(
|
||||
from DictionaryEntry r in reader
|
||||
select new Resource((ResXDataNode)r.Value));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
IEnumerable<string> Lines(string value)
|
||||
=> value.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
|
||||
|
||||
string Xml(string value)
|
||||
=> value.Replace("<", "<").Replace(">", ">");
|
||||
|
||||
string List(IEnumerable<string> items)
|
||||
=> List(null, items);
|
||||
|
||||
string List(string prefix, IEnumerable<string> items, string suffix = null)
|
||||
=> string.Join(", ", items.Select(i => prefix + i + suffix));
|
||||
|
||||
class ResourceFile
|
||||
{
|
||||
public string Namespace { get; set; }
|
||||
public string AccessModifier { get; set; } = "public";
|
||||
public string Class { get; set; }
|
||||
public string ResourceName { get; set; }
|
||||
public IEnumerable<Resource> Resources { get; set; }
|
||||
public bool NoDiagnostics { get; set; }
|
||||
}
|
||||
|
||||
class Resource
|
||||
{
|
||||
public Resource(ResXDataNode node)
|
||||
{
|
||||
Name = node.Name;
|
||||
Value = (string)node.GetValue((ITypeResolutionService)null);
|
||||
Parameters = Regex.Matches(Value, @"\{(\w+)\}")
|
||||
.Cast<Match>()
|
||||
.Select(m => m.Groups[1].Value)
|
||||
.Distinct()
|
||||
.ToList();
|
||||
|
||||
var eventInfo = node.Comment.Split(' ');
|
||||
Level = eventInfo.FirstOrDefault() ?? "BadLevel";
|
||||
EventId = eventInfo.Skip(1).FirstOrDefault() ?? "BadEventId";
|
||||
Types = eventInfo.Skip(2).ToList();
|
||||
}
|
||||
|
||||
public string Name { get; }
|
||||
public string Value { get; }
|
||||
public string EventId { get; }
|
||||
public string Level { get; }
|
||||
public bool ForLogging => Name.StartsWith("Log");
|
||||
public IEnumerable<string> Parameters { get; }
|
||||
public IEnumerable<string> Types { get; }
|
||||
}
|
||||
#>
|
||||
Loading…
Reference in New Issue