Creating a skeleton extension.
This commit is contained in:
Родитель
601df841b5
Коммит
c3ae27f4eb
|
@ -1,9 +1,9 @@
|
|||
{
|
||||
"verison": "0.0.0",
|
||||
"private": true,
|
||||
"name": "@autorest/csharp.v3",
|
||||
"description": "> See readme.md for instructions",
|
||||
"name": "@autorest/csharp-v3",
|
||||
"description": "See readme.md for instructions",
|
||||
"scripts": {
|
||||
"start": "dotnet ./path/to/binary/extension.exe"
|
||||
"start": "dotnet ./bin/AutoRest.CSharp.V3.dll --server"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
# AutoRest.CSharp.V3
|
||||
> see https://aka.ms/autorest
|
||||
|
||||
## Configuration
|
||||
```yaml
|
||||
clear-output-folder: false
|
||||
azure-track2-csharp: true
|
||||
|
||||
use-extension:
|
||||
"@autorest/remodeler" : "~2.0.4"
|
||||
|
||||
pipeline:
|
||||
csharp-v3:
|
||||
input: remodeler
|
||||
|
||||
output-artifact:
|
||||
- source-file-csharp
|
||||
```
|
|
@ -1,14 +1,37 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||
<AssemblyName>AutoRest.CSharp.V3</AssemblyName>
|
||||
<RootNamespace>AutoRest.CSharp.V3</RootNamespace>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<OutputPath>../bin</OutputPath>
|
||||
<PublishDir>$(OutputPath)</PublishDir>
|
||||
<!-- Some methods are marked async and don't have an await in them -->
|
||||
<NoWarn>1998</NoWarn>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<WarningsAsErrors />
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<DelaySign>false</DelaySign>
|
||||
<DefineConstants>TRACE;DEBUG;NETSTANDARD</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<DelaySign>true</DelaySign>
|
||||
<AssemblyOriginatorKeyFile>MSSharedLibKey.snk</AssemblyOriginatorKeyFile>
|
||||
<DefineConstants>TRACE;RELEASE;NETSTANDARD;SIGN</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AutoRest.Common" Version="2.4.48" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Plugins\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Perks.JsonRPC;
|
||||
|
||||
namespace AutoRest.CSharp.V3
|
||||
{
|
||||
internal class Dispatcher : NewPlugin
|
||||
{
|
||||
public Dispatcher(Connection connection, string plugin, string sessionId) : base(connection, plugin, sessionId) { }
|
||||
|
||||
protected override async Task<bool> ProcessInternal()
|
||||
{
|
||||
var files = await ListInputs();
|
||||
if (!files.Any())
|
||||
{
|
||||
throw new Exception("Generator did not receive the code model file.");
|
||||
}
|
||||
|
||||
var codeModel = await ReadFile(files.First());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,12 +1,30 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.Perks.JsonRPC;
|
||||
|
||||
namespace AutoRest.CSharp.V3
|
||||
{
|
||||
class Program
|
||||
internal static class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
public static int Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("Hello World!");
|
||||
if (!HasServerArgument(args))
|
||||
{
|
||||
Console.WriteLine("Not a valid invocation of this AutoRest extension. Invoke this extension through the AutoRest pipeline.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
using var connection = new Connection(Console.OpenStandardOutput(), Console.OpenStandardInput());
|
||||
connection.Dispatch<IEnumerable<string>>("GetPluginNames", async () => new[] { "csharp-v3" });
|
||||
connection.Dispatch<string, string, bool>("Process", (plugin, sessionId) => new Dispatcher(connection, plugin, sessionId).Process());
|
||||
connection.DispatchNotification("Shutdown", connection.Stop);
|
||||
connection.GetAwaiter().GetResult();
|
||||
|
||||
Console.Error.WriteLine("Shutting Down");
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static bool HasServerArgument(IEnumerable<string> args) => args?.Any(a => a.Equals("--server", StringComparison.InvariantCultureIgnoreCase)) ?? false;
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче