Add public management ctor generation (#644)

This commit is contained in:
Pavel Krymets 2020-04-10 14:36:56 -07:00 коммит произвёл GitHub
Родитель 581ddb7ea0
Коммит 814a1f9e6a
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
135 изменённых файлов: 770 добавлений и 380 удалений

3
.gitattributes поставляемый
Просмотреть файл

@ -2,4 +2,5 @@
**/Generated/**/*.cs linguist-generated=true
**/Generated/**/*.csproj linguist-generated=true
**/*.yaml linguist-generated=true
**/*.yaml linguist-generated=true
**/Configuration.json linguist-generated=true

2
.gitignore поставляемый
Просмотреть файл

@ -352,4 +352,4 @@ MigrationBackup/
.ionide/
# Rider IDE
.idea/
.idea/

Просмотреть файл

@ -59,7 +59,7 @@ if (!($Exclude -contains "TestServer"))
{
$inputFile = Join-Path $testServerSwaggerPath "$testName.json"
$swaggerDefinitions[$testName] = @{
'title'=$testName;
'projectName'=$testName;
'output'=$testServerDirectory;
'arguments'="--require=$configurationPath --input-file=$inputFile"
}
@ -77,7 +77,7 @@ if (!($Exclude -contains "TestProjects"))
$testName = $directory.Name
$inputFile = Join-Path $directory "$testName.json"
$swaggerDefinitions[$testName] = @{
'title'=$testName;
'projectName'=$testName;
'output'=$testSwaggerPath;
'arguments'="--require=$configurationPath --input-file=$inputFile"
}
@ -100,9 +100,8 @@ if (!($Exclude -contains "Samples"))
{
$projectDirectory = Join-Path $repoRoot 'samples' $projectName
$sampleConfigurationPath = Join-Path $projectDirectory 'readme.md'
$swaggerDefinitions[$projectName] = @{
'title'=$projectName;
'projectName'=$projectName;
'output'=$projectDirectory;
'arguments'="--require=$sampleConfigurationPath"
}
@ -121,7 +120,7 @@ if (!($Exclude -contains "SmokeTests"))
$projectDirectory = Join-Path $repoRoot 'samples' 'smoketests' $projectName
$swaggerDefinitions[$projectName] = @{
'title'=$projectName;
'projectName'=$projectName;
'output'=$projectDirectory;
'arguments'="--require=$configurationPath $input"
}
@ -142,11 +141,11 @@ if ($updateLaunchSettings)
$definition = $swaggerDefinitions[$key];
$outputPath = (Join-Path $definition.output $key).Replace($repoRoot, '$(SolutionDir)')
$codeModel = Join-Path $outputPath 'CodeModel.yaml'
$namespace = $definition.title.Replace('-', '_')
$namespace = $definition.projectName.Replace('-', '_')
$settings.profiles[$key] = [ordered]@{
'commandName'='Project';
'commandLineArgs'="--standalone --input-codemodel=$codeModel --plugin=csharpgen --output-folder=$outputPath --namespace=$namespace --shared-source-folder=$sharedSourceNormalized --save-code-model=true"
'commandLineArgs'="--standalone $outputPath"
}
}
@ -179,6 +178,6 @@ if (![string]::IsNullOrWhiteSpace($name))
$keys | %{ $swaggerDefinitions[$_] } | ForEach-Object -Parallel {
Import-Module "$using:PSScriptRoot\Generation.psm1" -DisableNameChecking;
Invoke-Autorest $_.output $_.title $_.arguments $using:sharedSource $using:fast $using:clean;
Invoke-Autorest $_.output $_.projectName $_.arguments $using:sharedSource $using:fast $using:clean;
} -ThrottleLimit $parallel

Просмотреть файл

@ -22,16 +22,15 @@ function Invoke($command)
}
}
function Invoke-Autorest($baseOutput, $title, $autoRestArguments, $sharedSource, $fast, $clean)
function Invoke-Autorest($baseOutput, $projectName, $autoRestArguments, $sharedSource, $fast, $clean)
{
$outputPath = Join-Path $baseOutput $title
$namespace = $title.Replace('-', '_')
$command = "$script:autorestBinary $autoRestArguments --title=$title --namespace=$namespace --output-folder=$outputPath"
$outputPath = Join-Path $baseOutput $projectName
$namespace = $projectName.Replace('-', '_')
$command = "$script:autorestBinary $autoRestArguments --namespace=$namespace --output-folder=$outputPath"
if ($fast)
{
$codeModel = Join-Path $baseOutput $title "CodeModel.yaml"
$command = "dotnet run --project $script:AutorestPluginProject --no-build -- --plugin=csharpgen --title=$title --namespace=$namespace --standalone --input-file=$codeModel --output-folder=$outputPath --shared-source-folder=$sharedSource --save-code-model=true"
$command = "dotnet run --project $script:AutorestPluginProject --no-build -- --standalone $outputPath"
}
if ($clean)

Просмотреть файл

@ -17,7 +17,7 @@
# autorest-core version
version: 3.0.6268
shared-source-folder: $(this-folder)/src/assets
save-code-model: true
save-inputs: true
use: $(this-folder)/artifacts/bin/AutoRest.CSharp.V3/Debug/netcoreapp3.0/
clear-output-folder: false

1
samples/AppConfiguration/AppConfiguration/Configuration.json сгенерированный Normal file
Просмотреть файл

@ -0,0 +1 @@
{"OutputFolder":".","Namespace":"AppConfiguration","LibraryName":"AppConfiguration","SharedSourceFolder":"..\\..\\..\\src\\assets","AzureArm":false}

Просмотреть файл

@ -0,0 +1 @@
{"OutputFolder":".","Namespace":"Azure.AI.FormRecognizer","LibraryName":"FormRecognizer","SharedSourceFolder":"..\\..\\..\\src\\assets","AzureArm":false}

Просмотреть файл

@ -0,0 +1 @@
{"OutputFolder":".","Namespace":"Azure.Network.Management.Interface","LibraryName":"Interface","SharedSourceFolder":"..\\..\\..\\src\\assets","AzureArm":false}

Просмотреть файл

@ -1,7 +1,7 @@
!<!CodeModel>
info: !<!Info>
description: The Azure Storage Management API.
title: Azure.Storage.Management
title: StorageManagementClient
schemas: !<!Schemas>
booleans:
- !<!BooleanSchema> &ref_49
@ -20217,7 +20217,7 @@ security: !<!Security>
authenticationRequired: true
language: !<!Languages>
default:
name: AzureStorageManagement
name: StorageManagementClient
description: ''
protocol: !<!Protocols>
http: !<!HttpModel> {}

Просмотреть файл

@ -0,0 +1 @@
{"OutputFolder":".","Namespace":"Azure.Storage.Management","LibraryName":"Storage","SharedSourceFolder":"..\\..\\..\\src\\assets","AzureArm":true}

Просмотреть файл

@ -21,16 +21,13 @@ namespace Azure.Storage.Management
private readonly ClientDiagnostics _clientDiagnostics;
private readonly HttpPipeline _pipeline;
internal BlobContainersRestClient RestClient { get; }
/// <summary> Initializes a new instance of BlobContainersClient for mocking. </summary>
protected BlobContainersClient()
{
}
/// <summary> Initializes a new instance of BlobContainersClient. </summary>
internal BlobContainersClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, string host = "https://management.azure.com", string apiVersion = "2019-06-01")
public BlobContainersClient(string subscriptionId, TokenCredential tokenCredential, StorageManagementClientOptions options = null)
{
RestClient = new BlobContainersRestClient(clientDiagnostics, pipeline, subscriptionId, host, apiVersion);
_clientDiagnostics = clientDiagnostics;
_pipeline = pipeline;
options = new StorageManagementClientOptions();
_clientDiagnostics = new ClientDiagnostics(options);
_pipeline = ManagementPipelineBuilder.Build(tokenCredential, options);
RestClient = new BlobContainersRestClient(_clientDiagnostics, _pipeline, subscriptionId, options.Version);
}
/// <summary> Creates a new container under the specified account as described by request body. The container resource includes metadata and properties for that container. It does not include a list of the blobs contained by the container. </summary>

Просмотреть файл

@ -20,16 +20,13 @@ namespace Azure.Storage.Management
private readonly ClientDiagnostics _clientDiagnostics;
private readonly HttpPipeline _pipeline;
internal BlobServicesRestClient RestClient { get; }
/// <summary> Initializes a new instance of BlobServicesClient for mocking. </summary>
protected BlobServicesClient()
{
}
/// <summary> Initializes a new instance of BlobServicesClient. </summary>
internal BlobServicesClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, string host = "https://management.azure.com", string apiVersion = "2019-06-01")
public BlobServicesClient(string subscriptionId, TokenCredential tokenCredential, StorageManagementClientOptions options = null)
{
RestClient = new BlobServicesRestClient(clientDiagnostics, pipeline, subscriptionId, host, apiVersion);
_clientDiagnostics = clientDiagnostics;
_pipeline = pipeline;
options = new StorageManagementClientOptions();
_clientDiagnostics = new ClientDiagnostics(options);
_pipeline = ManagementPipelineBuilder.Build(tokenCredential, options);
RestClient = new BlobServicesRestClient(_clientDiagnostics, _pipeline, subscriptionId, options.Version);
}
/// <summary> Sets the properties of a storage accounts Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. </summary>

Просмотреть файл

@ -20,16 +20,13 @@ namespace Azure.Storage.Management
private readonly ClientDiagnostics _clientDiagnostics;
private readonly HttpPipeline _pipeline;
internal EncryptionScopesRestClient RestClient { get; }
/// <summary> Initializes a new instance of EncryptionScopesClient for mocking. </summary>
protected EncryptionScopesClient()
{
}
/// <summary> Initializes a new instance of EncryptionScopesClient. </summary>
internal EncryptionScopesClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, string host = "https://management.azure.com", string apiVersion = "2019-06-01")
public EncryptionScopesClient(string subscriptionId, TokenCredential tokenCredential, StorageManagementClientOptions options = null)
{
RestClient = new EncryptionScopesRestClient(clientDiagnostics, pipeline, subscriptionId, host, apiVersion);
_clientDiagnostics = clientDiagnostics;
_pipeline = pipeline;
options = new StorageManagementClientOptions();
_clientDiagnostics = new ClientDiagnostics(options);
_pipeline = ManagementPipelineBuilder.Build(tokenCredential, options);
RestClient = new EncryptionScopesRestClient(_clientDiagnostics, _pipeline, subscriptionId, options.Version);
}
/// <summary> Synchronously creates or updates an encryption scope under the specified storage account. If an encryption scope is already created and a subsequent request is issued with different properties, the encryption scope properties will be updated per the specified request. </summary>

Просмотреть файл

@ -8,6 +8,7 @@
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using Azure.Storage.Management.Models;
@ -18,16 +19,13 @@ namespace Azure.Storage.Management
private readonly ClientDiagnostics _clientDiagnostics;
private readonly HttpPipeline _pipeline;
internal FileServicesRestClient RestClient { get; }
/// <summary> Initializes a new instance of FileServicesClient for mocking. </summary>
protected FileServicesClient()
{
}
/// <summary> Initializes a new instance of FileServicesClient. </summary>
internal FileServicesClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, string host = "https://management.azure.com", string apiVersion = "2019-06-01")
public FileServicesClient(string subscriptionId, TokenCredential tokenCredential, StorageManagementClientOptions options = null)
{
RestClient = new FileServicesRestClient(clientDiagnostics, pipeline, subscriptionId, host, apiVersion);
_clientDiagnostics = clientDiagnostics;
_pipeline = pipeline;
options = new StorageManagementClientOptions();
_clientDiagnostics = new ClientDiagnostics(options);
_pipeline = ManagementPipelineBuilder.Build(tokenCredential, options);
RestClient = new FileServicesRestClient(_clientDiagnostics, _pipeline, subscriptionId, options.Version);
}
/// <summary> List all file services in storage accounts. </summary>

Просмотреть файл

@ -21,16 +21,13 @@ namespace Azure.Storage.Management
private readonly ClientDiagnostics _clientDiagnostics;
private readonly HttpPipeline _pipeline;
internal FileSharesRestClient RestClient { get; }
/// <summary> Initializes a new instance of FileSharesClient for mocking. </summary>
protected FileSharesClient()
{
}
/// <summary> Initializes a new instance of FileSharesClient. </summary>
internal FileSharesClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, string host = "https://management.azure.com", string apiVersion = "2019-06-01")
public FileSharesClient(string subscriptionId, TokenCredential tokenCredential, StorageManagementClientOptions options = null)
{
RestClient = new FileSharesRestClient(clientDiagnostics, pipeline, subscriptionId, host, apiVersion);
_clientDiagnostics = clientDiagnostics;
_pipeline = pipeline;
options = new StorageManagementClientOptions();
_clientDiagnostics = new ClientDiagnostics(options);
_pipeline = ManagementPipelineBuilder.Build(tokenCredential, options);
RestClient = new FileSharesRestClient(_clientDiagnostics, _pipeline, subscriptionId, options.Version);
}
/// <summary> Creates a new share under the specified account as described by request body. The share resource includes metadata and properties for that share. It does not include a list of the files contained by the share. </summary>

Просмотреть файл

@ -8,6 +8,7 @@
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using Azure.Storage.Management.Models;
@ -18,16 +19,13 @@ namespace Azure.Storage.Management
private readonly ClientDiagnostics _clientDiagnostics;
private readonly HttpPipeline _pipeline;
internal ManagementPoliciesRestClient RestClient { get; }
/// <summary> Initializes a new instance of ManagementPoliciesClient for mocking. </summary>
protected ManagementPoliciesClient()
{
}
/// <summary> Initializes a new instance of ManagementPoliciesClient. </summary>
internal ManagementPoliciesClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, string host = "https://management.azure.com", string apiVersion = "2019-06-01")
public ManagementPoliciesClient(string subscriptionId, TokenCredential tokenCredential, StorageManagementClientOptions options = null)
{
RestClient = new ManagementPoliciesRestClient(clientDiagnostics, pipeline, subscriptionId, host, apiVersion);
_clientDiagnostics = clientDiagnostics;
_pipeline = pipeline;
options = new StorageManagementClientOptions();
_clientDiagnostics = new ClientDiagnostics(options);
_pipeline = ManagementPipelineBuilder.Build(tokenCredential, options);
RestClient = new ManagementPoliciesRestClient(_clientDiagnostics, _pipeline, subscriptionId, options.Version);
}
/// <summary> Gets the managementpolicy associated with the specified storage account. </summary>

Просмотреть файл

@ -19,16 +19,13 @@ namespace Azure.Storage.Management
private readonly ClientDiagnostics _clientDiagnostics;
private readonly HttpPipeline _pipeline;
internal OperationsRestClient RestClient { get; }
/// <summary> Initializes a new instance of OperationsClient for mocking. </summary>
protected OperationsClient()
{
}
/// <summary> Initializes a new instance of OperationsClient. </summary>
internal OperationsClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string host = "https://management.azure.com", string apiVersion = "2019-06-01")
public OperationsClient(TokenCredential tokenCredential, StorageManagementClientOptions options = null)
{
RestClient = new OperationsRestClient(clientDiagnostics, pipeline, host, apiVersion);
_clientDiagnostics = clientDiagnostics;
_pipeline = pipeline;
options = new StorageManagementClientOptions();
_clientDiagnostics = new ClientDiagnostics(options);
_pipeline = ManagementPipelineBuilder.Build(tokenCredential, options);
RestClient = new OperationsRestClient(_clientDiagnostics, _pipeline, options.Version);
}
/// <summary> Lists all of the available Storage Rest API operations. </summary>

Просмотреть файл

@ -8,6 +8,7 @@
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using Azure.Storage.Management.Models;
@ -18,16 +19,13 @@ namespace Azure.Storage.Management
private readonly ClientDiagnostics _clientDiagnostics;
private readonly HttpPipeline _pipeline;
internal PrivateEndpointConnectionsRestClient RestClient { get; }
/// <summary> Initializes a new instance of PrivateEndpointConnectionsClient for mocking. </summary>
protected PrivateEndpointConnectionsClient()
{
}
/// <summary> Initializes a new instance of PrivateEndpointConnectionsClient. </summary>
internal PrivateEndpointConnectionsClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, string host = "https://management.azure.com", string apiVersion = "2019-06-01")
public PrivateEndpointConnectionsClient(string subscriptionId, TokenCredential tokenCredential, StorageManagementClientOptions options = null)
{
RestClient = new PrivateEndpointConnectionsRestClient(clientDiagnostics, pipeline, subscriptionId, host, apiVersion);
_clientDiagnostics = clientDiagnostics;
_pipeline = pipeline;
options = new StorageManagementClientOptions();
_clientDiagnostics = new ClientDiagnostics(options);
_pipeline = ManagementPipelineBuilder.Build(tokenCredential, options);
RestClient = new PrivateEndpointConnectionsRestClient(_clientDiagnostics, _pipeline, subscriptionId, options.Version);
}
/// <summary> Gets the specified private endpoint connection associated with the storage account. </summary>

Просмотреть файл

@ -8,6 +8,7 @@
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using Azure.Storage.Management.Models;
@ -18,16 +19,13 @@ namespace Azure.Storage.Management
private readonly ClientDiagnostics _clientDiagnostics;
private readonly HttpPipeline _pipeline;
internal PrivateLinkResourcesRestClient RestClient { get; }
/// <summary> Initializes a new instance of PrivateLinkResourcesClient for mocking. </summary>
protected PrivateLinkResourcesClient()
{
}
/// <summary> Initializes a new instance of PrivateLinkResourcesClient. </summary>
internal PrivateLinkResourcesClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, string host = "https://management.azure.com", string apiVersion = "2019-06-01")
public PrivateLinkResourcesClient(string subscriptionId, TokenCredential tokenCredential, StorageManagementClientOptions options = null)
{
RestClient = new PrivateLinkResourcesRestClient(clientDiagnostics, pipeline, subscriptionId, host, apiVersion);
_clientDiagnostics = clientDiagnostics;
_pipeline = pipeline;
options = new StorageManagementClientOptions();
_clientDiagnostics = new ClientDiagnostics(options);
_pipeline = ManagementPipelineBuilder.Build(tokenCredential, options);
RestClient = new PrivateLinkResourcesRestClient(_clientDiagnostics, _pipeline, subscriptionId, options.Version);
}
/// <summary> Gets the private link resources that need to be created for a storage account. </summary>

Просмотреть файл

@ -19,16 +19,13 @@ namespace Azure.Storage.Management
private readonly ClientDiagnostics _clientDiagnostics;
private readonly HttpPipeline _pipeline;
internal SkusRestClient RestClient { get; }
/// <summary> Initializes a new instance of SkusClient for mocking. </summary>
protected SkusClient()
{
}
/// <summary> Initializes a new instance of SkusClient. </summary>
internal SkusClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, string host = "https://management.azure.com", string apiVersion = "2019-06-01")
public SkusClient(string subscriptionId, TokenCredential tokenCredential, StorageManagementClientOptions options = null)
{
RestClient = new SkusRestClient(clientDiagnostics, pipeline, subscriptionId, host, apiVersion);
_clientDiagnostics = clientDiagnostics;
_pipeline = pipeline;
options = new StorageManagementClientOptions();
_clientDiagnostics = new ClientDiagnostics(options);
_pipeline = ManagementPipelineBuilder.Build(tokenCredential, options);
RestClient = new SkusRestClient(_clientDiagnostics, _pipeline, subscriptionId, options.Version);
}
/// <summary> Lists the available SKUs supported by Microsoft.Storage for given subscription. </summary>

Просмотреть файл

@ -22,16 +22,13 @@ namespace Azure.Storage.Management
private readonly ClientDiagnostics _clientDiagnostics;
private readonly HttpPipeline _pipeline;
internal StorageAccountsRestClient RestClient { get; }
/// <summary> Initializes a new instance of StorageAccountsClient for mocking. </summary>
protected StorageAccountsClient()
{
}
/// <summary> Initializes a new instance of StorageAccountsClient. </summary>
internal StorageAccountsClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, string host = "https://management.azure.com", string apiVersion = "2019-06-01")
public StorageAccountsClient(string subscriptionId, TokenCredential tokenCredential, StorageManagementClientOptions options = null)
{
RestClient = new StorageAccountsRestClient(clientDiagnostics, pipeline, subscriptionId, host, apiVersion);
_clientDiagnostics = clientDiagnostics;
_pipeline = pipeline;
options = new StorageManagementClientOptions();
_clientDiagnostics = new ClientDiagnostics(options);
_pipeline = ManagementPipelineBuilder.Build(tokenCredential, options);
RestClient = new StorageAccountsRestClient(_clientDiagnostics, _pipeline, subscriptionId, options.Version);
}
/// <summary> Checks that the storage account name is valid and is not already in use. </summary>

Просмотреть файл

@ -0,0 +1,99 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using Azure.Core;
using Azure.Storage.Management;
namespace Azure.Storage.Management
{
/// <summary> Storage service management client. </summary>
public class StorageManagementClient
{
private readonly StorageManagementClientOptions _options;
private readonly TokenCredential _tokenCredential;
private readonly string _subscriptionId;
/// <summary> Initializes a new instance of StorageManagementClient. </summary>
public StorageManagementClient(string subscriptionId, TokenCredential tokenCredential, StorageManagementClientOptions options = null)
{
_options = options ?? new StorageManagementClientOptions();
_tokenCredential = tokenCredential;
_subscriptionId = subscriptionId;
}
/// <summary> Creates a new instance of BlobServicesClient. </summary>
public BlobServicesClient GetBlobServicesClient()
{
return new BlobServicesClient(_subscriptionId, _tokenCredential, _options);
}
/// <summary> Creates a new instance of BlobContainersClient. </summary>
public BlobContainersClient GetBlobContainersClient()
{
return new BlobContainersClient(_subscriptionId, _tokenCredential, _options);
}
/// <summary> Creates a new instance of FileServicesClient. </summary>
public FileServicesClient GetFileServicesClient()
{
return new FileServicesClient(_subscriptionId, _tokenCredential, _options);
}
/// <summary> Creates a new instance of FileSharesClient. </summary>
public FileSharesClient GetFileSharesClient()
{
return new FileSharesClient(_subscriptionId, _tokenCredential, _options);
}
/// <summary> Creates a new instance of OperationsClient. </summary>
public OperationsClient GetOperationsClient()
{
return new OperationsClient(_tokenCredential, _options);
}
/// <summary> Creates a new instance of SkusClient. </summary>
public SkusClient GetSkusClient()
{
return new SkusClient(_subscriptionId, _tokenCredential, _options);
}
/// <summary> Creates a new instance of StorageAccountsClient. </summary>
public StorageAccountsClient GetStorageAccountsClient()
{
return new StorageAccountsClient(_subscriptionId, _tokenCredential, _options);
}
/// <summary> Creates a new instance of UsagesClient. </summary>
public UsagesClient GetUsagesClient()
{
return new UsagesClient(_subscriptionId, _tokenCredential, _options);
}
/// <summary> Creates a new instance of ManagementPoliciesClient. </summary>
public ManagementPoliciesClient GetManagementPoliciesClient()
{
return new ManagementPoliciesClient(_subscriptionId, _tokenCredential, _options);
}
/// <summary> Creates a new instance of PrivateEndpointConnectionsClient. </summary>
public PrivateEndpointConnectionsClient GetPrivateEndpointConnectionsClient()
{
return new PrivateEndpointConnectionsClient(_subscriptionId, _tokenCredential, _options);
}
/// <summary> Creates a new instance of PrivateLinkResourcesClient. </summary>
public PrivateLinkResourcesClient GetPrivateLinkResourcesClient()
{
return new PrivateLinkResourcesClient(_subscriptionId, _tokenCredential, _options);
}
/// <summary> Creates a new instance of EncryptionScopesClient. </summary>
public EncryptionScopesClient GetEncryptionScopesClient()
{
return new EncryptionScopesClient(_subscriptionId, _tokenCredential, _options);
}
}
}

Просмотреть файл

@ -0,0 +1,34 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using Azure.Core;
namespace Azure.Storage.Management
{
/// <summary> Client options for Storage. </summary>
public class StorageManagementClientOptions : ClientOptions
{
private const ServiceVersion LatestVersion = ServiceVersion.V2019_06_01;
/// <summary> The version of the service to use. </summary>
public enum ServiceVersion
{
/// <summary> Service version "2019-06-01". </summary>
V2019_06_01 = 1,
}
internal string Version { get; }
/// <summary> Initializes new instance of StorageManagementClientOptions. </summary>
public StorageManagementClientOptions(ServiceVersion version = LatestVersion)
{
Version = version switch
{
ServiceVersion.V2019_06_01 => "2019-06-01",
_ => throw new NotSupportedException()
};
}
}
}

Просмотреть файл

@ -20,16 +20,13 @@ namespace Azure.Storage.Management
private readonly ClientDiagnostics _clientDiagnostics;
private readonly HttpPipeline _pipeline;
internal UsagesRestClient RestClient { get; }
/// <summary> Initializes a new instance of UsagesClient for mocking. </summary>
protected UsagesClient()
{
}
/// <summary> Initializes a new instance of UsagesClient. </summary>
internal UsagesClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, string host = "https://management.azure.com", string apiVersion = "2019-06-01")
public UsagesClient(string subscriptionId, TokenCredential tokenCredential, StorageManagementClientOptions options = null)
{
RestClient = new UsagesRestClient(clientDiagnostics, pipeline, subscriptionId, host, apiVersion);
_clientDiagnostics = clientDiagnostics;
_pipeline = pipeline;
options = new StorageManagementClientOptions();
_clientDiagnostics = new ClientDiagnostics(options);
_pipeline = ManagementPipelineBuilder.Build(tokenCredential, options);
RestClient = new UsagesRestClient(_clientDiagnostics, _pipeline, subscriptionId, options.Version);
}
/// <summary> Gets the current usage count and the limit for the resources of the location under the subscription. </summary>

Просмотреть файл

@ -4,9 +4,10 @@
> see https://aka.ms/autorest
``` yaml
title: Azure.Storage.Management
azure-arm: true
require: $(this-folder)/../../readme.md
input-file:
library-name: Storage
input-file:
- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/7586a4893bbafd6d1f90b983bc091c7abf3eed59/specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/blob.json
- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/7586a4893bbafd6d1f90b983bc091c7abf3eed59/specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/file.json
- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/7586a4893bbafd6d1f90b983bc091c7abf3eed59/specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/storage.json

1
samples/Azure.Storage.Tables/Azure.Storage.Tables/Configuration.json сгенерированный Normal file
Просмотреть файл

@ -0,0 +1 @@
{"OutputFolder":".","Namespace":"Azure.Storage.Tables","LibraryName":"Tables","SharedSourceFolder":"..\\..\\..\\src\\assets","AzureArm":false}

Просмотреть файл

@ -1,7 +1,7 @@
!<!CodeModel>
info: !<!Info>
description: 'Client that can be used to query an index and upload, merge, or delete documents.'
title: CognitiveSearch
title: CognitiveServices
schemas: !<!Schemas>
booleans:
- !<!BooleanSchema> &ref_9
@ -22216,7 +22216,7 @@ security: !<!Security>
authenticationRequired: false
language: !<!Languages>
default:
name: CognitiveSearch
name: CognitiveServices
description: ''
protocol: !<!Protocols>
http: !<!HttpModel> {}

1
samples/CognitiveSearch/CognitiveSearch/Configuration.json сгенерированный Normal file
Просмотреть файл

@ -0,0 +1 @@
{"OutputFolder":".","Namespace":"CognitiveSearch","LibraryName":"CognitiveSearch","SharedSourceFolder":"..\\..\\..\\src\\assets","AzureArm":false}

Просмотреть файл

@ -0,0 +1 @@
{"OutputFolder":".","Namespace":"CognitiveServices.TextAnalytics","LibraryName":"TextAnalytics","SharedSourceFolder":"..\\..\\..\\src\\assets","AzureArm":false}

4
samples/SignalR/SignalR/CodeModel.yaml сгенерированный
Просмотреть файл

@ -1,6 +1,6 @@
!<!CodeModel>
info: !<!Info>
title: SignalR
title: Azure SignalR Serverless WebSocket
schemas: !<!Schemas>
numbers:
- !<!NumberSchema> &ref_31
@ -1205,7 +1205,7 @@ security: !<!Security>
authenticationRequired: false
language: !<!Languages>
default:
name: SignalR
name: AzureSignalRServerlessWebSocket
description: ''
protocol: !<!Protocols>
http: !<!HttpModel> {}

1
samples/SignalR/SignalR/Configuration.json сгенерированный Normal file
Просмотреть файл

@ -0,0 +1 @@
{"OutputFolder":".","Namespace":"SignalR","LibraryName":"SignalR","SharedSourceFolder":"..\\..\\..\\src\\assets","AzureArm":false}

Просмотреть файл

@ -1,94 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using AutoRest.CSharp.V3.AutoRest.Communication.Serialization.Models;
namespace AutoRest.CSharp.V3.AutoRest.Communication
{
internal class HostCommunication : IPluginCommunication
{
private readonly Dictionary<string, string> _arguments;
private readonly string _basePath;
public HostCommunication(string[] args)
{
_arguments = new Dictionary<string, string>();
foreach (string s in args)
{
var parts = s.Split("=");
string name = parts[0];
if (name.StartsWith("--"))
{
name = name.Substring(2);
}
_arguments[name] = parts.Length == 1 ? "true" : parts[1];
}
_basePath = _arguments["output-folder"];
PluginName = _arguments["plugin"];
}
public string PluginName { get; }
public Task<string> ReadFile(string filename)
{
filename = Path.Combine(_basePath, filename);
return File.ReadAllTextAsync(filename);
}
public Task<T> GetValue<T>(string key)
{
if (_arguments.TryGetValue(key, out var stringValue))
{
var conversionType = typeof(T);
// Handle nullable
if (conversionType.IsGenericType && conversionType.GetGenericTypeDefinition() == typeof(Nullable<>))
{
conversionType = conversionType.GetGenericArguments()[0];
}
var value = (T) Convert.ChangeType(stringValue, conversionType);
return Task.FromResult(value);
}
return Task.FromResult(default(T)!);
}
public Task<string[]> ListInputs(string? artifactType = null)
{
List<string> inputs = new List<string>();
foreach (string argumentsKey in _arguments.Keys)
{
string inputPrefix = "input-";
if (argumentsKey.StartsWith(inputPrefix))
{
inputs.Add(_arguments[argumentsKey]);
}
}
return Task.FromResult(inputs.ToArray());
}
public async Task WriteFile(string filename, string content, string artifactType, RawSourceMap? sourceMap = null)
{
if (string.IsNullOrEmpty(content))
{
return;
}
filename = Path.Combine(_basePath, filename);
Console.WriteLine($"Writing {filename} {artifactType}");
Directory.CreateDirectory(Path.GetDirectoryName(filename));
await File.WriteAllTextAsync(filename, content);
}
public async Task Fatal(string text)
{
await Console.Error.WriteLineAsync("FATAL: " + text);
}
}
}

Просмотреть файл

@ -0,0 +1,72 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using AutoRest.CSharp.V3.AutoRest.Plugins;
using AutoRest.CSharp.V3.Input;
namespace AutoRest.CSharp.V3.AutoRest.Communication
{
internal class StandaloneGeneratorRunner
{
public static async Task RunAsync(string[] args)
{
var basePath = args.Single(a=> !a.StartsWith("--"));
var configuration = LoadConfiguration(basePath, File.ReadAllText(Path.Combine(basePath, "Configuration.json")));
var codeModel = CodeModelSerialization.DeserializeCodeModel(File.ReadAllText(Path.Combine(basePath, "CodeModel.yaml")));
var workspace = await new CSharpGen().ExecuteAsync(codeModel, configuration);
await foreach (var file in workspace.GetGeneratedFilesAsync())
{
if (string.IsNullOrEmpty(file.Text))
{
continue;
}
var filename = Path.Combine(basePath, file.Name);
Console.WriteLine($"Writing {filename}");
Directory.CreateDirectory(Path.GetDirectoryName(filename));
await File.WriteAllTextAsync(filename, file.Text);
}
}
internal static string SaveConfiguration(Configuration configuration)
{
using (var memoryStream = new MemoryStream())
{
using (Utf8JsonWriter writer = new Utf8JsonWriter(memoryStream))
{
writer.WriteStartObject();
writer.WriteString(nameof(Configuration.OutputFolder), Path.GetRelativePath(configuration.OutputFolder, configuration.OutputFolder));
writer.WriteString(nameof(Configuration.Namespace), configuration.Namespace);
writer.WriteString(nameof(Configuration.LibraryName), configuration.LibraryName);
writer.WriteString(nameof(Configuration.SharedSourceFolder), Path.GetRelativePath(configuration.OutputFolder,configuration.SharedSourceFolder));
writer.WriteBoolean(nameof(Configuration.AzureArm), configuration.AzureArm);
writer.WriteEndObject();
}
return Encoding.UTF8.GetString(memoryStream.ToArray());
}
}
private static Configuration LoadConfiguration(string basePath, string json)
{
JsonDocument document = JsonDocument.Parse(json);
var root = document.RootElement;
return new Configuration(
Path.Combine(basePath, root.GetProperty(nameof(Configuration.OutputFolder)).GetString()),
root.GetProperty(nameof(Configuration.Namespace)).GetString(),
root.GetProperty(nameof(Configuration.LibraryName)).GetString(),
Path.Combine(basePath, root.GetProperty(nameof(Configuration.SharedSourceFolder)).GetString()),
saveInputs: false,
root.GetProperty(nameof(Configuration.AzureArm)).GetBoolean()
);
}
}
}

Просмотреть файл

@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text.Json;
using System.Threading.Tasks;
using AutoRest.CSharp.V3.AutoRest.Communication;
using AutoRest.CSharp.V3.Generation.Types;
@ -15,6 +16,7 @@ using AutoRest.CSharp.V3.Input.Source;
using AutoRest.CSharp.V3.Output.Builders;
using AutoRest.CSharp.V3.Output.Models.Responses;
using AutoRest.CSharp.V3.Output.Models.Types;
using AutoRest.CSharp.V3.Utilities;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Formatting;
using Microsoft.CodeAnalysis.Simplification;
@ -26,7 +28,7 @@ namespace AutoRest.CSharp.V3.AutoRest.Plugins
[PluginName("csharpgen")]
internal class CSharpGen : IPlugin
{
public async Task<bool> Execute(IPluginCommunication autoRest, CodeModel codeModel, Configuration configuration)
public async Task<GeneratedCodeWorkspace> ExecuteAsync(CodeModel codeModel, Configuration configuration)
{
Directory.CreateDirectory(configuration.OutputFolder);
var project = GeneratedCodeWorkspace.Create(configuration.OutputFolder, configuration.SharedSourceFolder);
@ -73,11 +75,51 @@ namespace AutoRest.CSharp.V3.AutoRest.Plugins
foreach (var client in context.Library.Clients)
{
var codeWriter = new CodeWriter();
clientWriter.WriteClient(codeWriter, client);
clientWriter.WriteClient(codeWriter, client, context.Configuration);
project.AddGeneratedFile($"Operations/{client.Type.Name}.cs", codeWriter.ToString());
}
if (context.Configuration.AzureArm)
{
var codeWriter = new CodeWriter();
ManagementClientWriter.WriteClientOptions(codeWriter, context);
project.AddGeneratedFile($"Operations/{context.Configuration.LibraryName}ManagementClientOptions.cs", codeWriter.ToString());
var clientCodeWriter = new CodeWriter();
ManagementClientWriter.WriteAggregateClient(clientCodeWriter, context);
project.AddGeneratedFile($"Operations/{context.Configuration.LibraryName}ManagementClient.cs", clientCodeWriter.ToString());
}
return project;
}
public async Task<bool> Execute(IPluginCommunication autoRest)
{
string codeModelFileName = (await autoRest.ListInputs()).FirstOrDefault();
if (string.IsNullOrEmpty(codeModelFileName)) throw new Exception("Generator did not receive the code model file.");
var codeModelYaml = await autoRest.ReadFile(codeModelFileName);
CodeModel codeModel = CodeModelSerialization.DeserializeCodeModel(codeModelYaml);
var configuration = new Configuration(
new Uri(GetRequiredOption(autoRest, "output-folder")).LocalPath,
GetRequiredOption(autoRest, "namespace"),
autoRest.GetValue<string?>("library-name").GetAwaiter().GetResult(),
new Uri(GetRequiredOption(autoRest, "shared-source-folder")).LocalPath,
autoRest.GetValue<bool?>("save-inputs").GetAwaiter().GetResult() ?? false,
autoRest.GetValue<bool?>("azure-arm").GetAwaiter().GetResult() ?? false
);
if (configuration.SaveInputs)
{
await autoRest.WriteFile("Configuration.json", StandaloneGeneratorRunner.SaveConfiguration(configuration), "source-file-csharp");
await autoRest.WriteFile("CodeModel.yaml", codeModelYaml, "source-file-csharp");
}
var project = await ExecuteAsync(codeModel, configuration);
await foreach (var file in project.GetGeneratedFilesAsync())
{
await autoRest.WriteFile(file.Name, file.Text, "source-file-csharp");
@ -85,5 +127,10 @@ namespace AutoRest.CSharp.V3.AutoRest.Plugins
return true;
}
private string GetRequiredOption(IPluginCommunication autoRest, string name)
{
return autoRest.GetValue<string?>(name).GetAwaiter().GetResult() ?? throw new InvalidOperationException($"{name} configuration parameter is required");
}
}
}

Просмотреть файл

@ -28,9 +28,10 @@ namespace AutoRest.CSharp.V3.AutoRest.Plugins
</Project>
";
public async Task<bool> Execute(IPluginCommunication autoRest, CodeModel codeModel, Configuration configuration)
public async Task<bool> Execute(IPluginCommunication autoRest)
{
await autoRest.WriteFile($"{configuration.Title}.csproj", _csProjContent, "source-file-csharp");
var ns = await autoRest.GetValue<string>("namespace");
await autoRest.WriteFile($"{ns}.csproj", _csProjContent, "source-file-csharp");
return true;
}

Просмотреть файл

@ -2,30 +2,32 @@
// Licensed under the MIT License. See License.txt in the project root for license information.
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.Json;
using AutoRest.CSharp.V3.AutoRest.Communication;
namespace AutoRest.CSharp.V3.AutoRest.Plugins
{
internal class Configuration
{
public Configuration(string outputFolder, string ns, string? name, string sharedSourceFolder, bool saveInputs, bool azureArm)
{
OutputFolder = outputFolder;
Namespace = ns;
var namespaceParts = ns.Split('.');
LibraryName = name ?? namespaceParts.Last();
SharedSourceFolder = sharedSourceFolder;
SaveInputs = saveInputs;
AzureArm = azureArm;
}
public string OutputFolder { get; }
public string Namespace { get; }
public string Title { get; }
public string LibraryName { get; }
public string SharedSourceFolder { get; }
public bool SaveCodeModel { get; }
public Configuration(IPluginCommunication autoRest)
{
OutputFolder = new Uri(GetRequiredOption(autoRest, "output-folder")).LocalPath;
SharedSourceFolder = new Uri(GetRequiredOption(autoRest, "shared-source-folder")).LocalPath;
Namespace = autoRest.GetValue<string?>("namespace").GetAwaiter().GetResult() ?? "Sample";
Title = autoRest.GetValue<string?>("title").GetAwaiter().GetResult() ?? "Sample";
SaveCodeModel = autoRest.GetValue<bool?>("save-code-model").GetAwaiter().GetResult() ?? false;
}
private static string GetRequiredOption(IPluginCommunication autoRest, string name)
{
return autoRest.GetValue<string?>(name).GetAwaiter().GetResult() ?? throw new InvalidOperationException($"{name} configuration parameter is required");
}
public bool SaveInputs { get; }
public bool AzureArm { get; }
}
}

Просмотреть файл

@ -10,8 +10,7 @@ namespace AutoRest.CSharp.V3.AutoRest.Plugins
{
internal interface IPlugin
{
Task<bool> Execute(IPluginCommunication autoRest, CodeModel codeModel, Configuration configuration);
bool DeserializeCodeModel => true;
Task<bool> Execute(IPluginCommunication autoRest);
}
[AttributeUsage(AttributeTargets.Class)]

Просмотреть файл

@ -0,0 +1,147 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System;
using System.Collections.Generic;
using System.Linq;
using AutoRest.CSharp.V3.Generation.Writers;
using AutoRest.CSharp.V3.Output.Models.Shared;
using AutoRest.CSharp.V3.Output.Models.Types;
using Azure.Core;
namespace AutoRest.CSharp.V3.AutoRest.Plugins
{
internal class ManagementClientWriter
{
public static void WriteAggregateClient(CodeWriter writer, BuildContext context)
{
var title = context.Configuration.LibraryName;
using (writer.Scope($"namespace {context.Configuration.Namespace}"))
{
Dictionary<string, Parameter> allParameters = new Dictionary<string, Parameter>();
foreach (var parameter in context.Library.Clients.SelectMany(p => p.RestClient.Parameters))
{
if (ManagementClientWriterHelpers.IsHostParameter(parameter) ||
ManagementClientWriterHelpers.IsApiVersionParameter(parameter))
{
continue;
}
allParameters[parameter.Name] = parameter;
}
writer.WriteXmlDocumentationSummary($"{title} service management client.");
using (writer.Scope($"public class {title}ManagementClient"))
{
writer.Line($"private readonly {title}ManagementClientOptions _options;");
writer.Line($"private readonly {typeof(TokenCredential)} _tokenCredential;");
foreach (var parameter in allParameters.Values)
{
writer.Line($"private readonly {parameter.Type} _{parameter.Name};");
}
writer.WriteXmlDocumentationSummary($"Initializes a new instance of {title}ManagementClient");
writer.Append($"public {title}ManagementClient(");
foreach (Parameter parameter in allParameters.Values)
{
writer.WriteParameter(parameter);
}
writer.Append($"{typeof(TokenCredential)} tokenCredential, {title}ManagementClientOptions options = null)");
using (writer.Scope())
{
writer.Line($"_options = options ?? new {title}ManagementClientOptions();");
writer.Line($"_tokenCredential = tokenCredential;");
foreach (Parameter parameter in allParameters.Values)
{
writer.Line($"_{parameter.Name} = {parameter.Name};");
}
}
writer.Line();
foreach (var client in context.Library.Clients)
{
writer.WriteXmlDocumentationSummary($"Creates a new instance of {client.Type.Name}");
using (writer.Scope($"public {client.Type} Get{client.Type.Name}()"))
{
writer.Append($"return new {client.Type}(");
foreach (var parameter in client.RestClient.Parameters)
{
if (ManagementClientWriterHelpers.IsHostParameter(parameter) ||
ManagementClientWriterHelpers.IsApiVersionParameter(parameter))
{
continue;
}
writer.Append($"_{parameter.Name}, ");
}
writer.Line($"_tokenCredential, _options);");
}
writer.Line();
}
}
}
}
public static void WriteClientOptions(CodeWriter writer, BuildContext context)
{
var title = context.Configuration.LibraryName;
var apiVersions = context.CodeModel.OperationGroups
.SelectMany(g => g.Operations.SelectMany(o => o.ApiVersions))
.Select(v => v.Version)
.Distinct()
.OrderBy(v => v)
.Select(v=> (Version: v, Name: ToVersionProperty(v)))
.ToArray();
using (writer.Scope($"namespace {context.Configuration.Namespace}"))
{
writer.WriteXmlDocumentationSummary($"Client options for {title}.");
using (writer.Scope($"public class {title}ManagementClientOptions: {typeof(ClientOptions)}"))
{
writer.Line($"private const ServiceVersion LatestVersion = ServiceVersion.{apiVersions.Last().Name};");
writer.WriteXmlDocumentationSummary("The version of the service to use.");
using (writer.Scope($"public enum ServiceVersion"))
{
int i = 1;
foreach (var apiVersion in apiVersions)
{
writer.WriteXmlDocumentationSummary($"Service version \"{apiVersion.Version}\"");
writer.Line($"{apiVersion.Name} = {i:L},");
i++;
}
}
writer.Line($"internal string Version {{ get; }}");
writer.WriteXmlDocumentationSummary($"Initializes new instance of {title}ManagementClientOptions.");
using (writer.Scope($"public {title}ManagementClientOptions(ServiceVersion version = LatestVersion)"))
{
writer.Append($"Version = version ");
using (writer.Scope($"switch", end: "};"))
{
foreach (var apiVersion in apiVersions)
{
writer.Line($"ServiceVersion.{apiVersion.Name} => {apiVersion.Version:L},");
}
writer.Line($"_ => throw new {typeof(NotSupportedException)}()");
}
}
}
}
}
private static string ToVersionProperty(string s)
{
return "V" + s.Replace(".", "_").Replace('-', '_');
}
}
}

Просмотреть файл

@ -25,33 +25,15 @@ namespace AutoRest.CSharp.V3.AutoRest.Plugins
public static async Task<bool> Start(IPluginCommunication autoRest)
{
// AutoRest sends an empty Object as a 'true' value. When the configuration item is not present, it sends a Null value.
if ((await autoRest.GetValue<JsonElement?>($"{autoRest.PluginName}.attach")).IsObject())
{
DebuggerAwaiter.AwaitAttach();
}
try
{
Configuration configuration = new Configuration(autoRest);
IPlugin plugin = Plugins[autoRest.PluginName]();
CodeModel codeModel = new CodeModel();
if (plugin.DeserializeCodeModel)
// AutoRest sends an empty Object as a 'true' value. When the configuration item is not present, it sends a Null value.
if (autoRest.GetValue<JsonElement?>($"{autoRest.PluginName}.attach").GetAwaiter().GetResult().IsObject())
{
string codeModelFileName = (await autoRest.ListInputs()).FirstOrDefault();
if (codeModelFileName.IsNullOrEmpty()) throw new Exception("Generator did not receive the code model file.");
string codeModelYaml = await autoRest.ReadFile(codeModelFileName);
if (configuration.SaveCodeModel)
{
await autoRest.WriteFile("CodeModel.yaml", codeModelYaml, "source-file-csharp");
}
codeModel = CodeModelSerialization.DeserializeCodeModel(codeModelYaml);
DebuggerAwaiter.AwaitAttach();
}
await plugin.Execute(autoRest, codeModel, configuration);
await plugin.Execute(autoRest);
return true;
}
catch (Exception e)

Просмотреть файл

@ -6,6 +6,7 @@ using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Linq;
using AutoRest.CSharp.V3.AutoRest.Plugins;
using AutoRest.CSharp.V3.Generation.Types;
using AutoRest.CSharp.V3.Output.Models;
using AutoRest.CSharp.V3.Output.Models.Requests;
@ -24,7 +25,7 @@ namespace AutoRest.CSharp.V3.Generation.Writers
{
internal class ClientWriter
{
public void WriteClient(CodeWriter writer, Client client)
public void WriteClient(CodeWriter writer, Client client, Configuration configuration)
{
var cs = client.Type;
var @namespace = cs.Namespace;
@ -34,7 +35,15 @@ namespace AutoRest.CSharp.V3.Generation.Writers
using (writer.Scope($"{client.DeclaredType.Accessibility} partial class {cs.Name}"))
{
WriteClientFields(writer, client);
WriteClientCtors(writer, client);
if (configuration.AzureArm)
{
WriteManagementClientCtors(writer, client, configuration);
}
else
{
WriteClientCtors(writer, client);
}
foreach (var clientMethod in client.Methods)
{
@ -58,6 +67,54 @@ namespace AutoRest.CSharp.V3.Generation.Writers
}
}
private void WriteManagementClientCtors(CodeWriter writer, Client client, Configuration configuration)
{
writer.WriteXmlDocumentationSummary($"Initializes a new instance of {client.Type.Name}");
writer.Append($"public {client.Type.Name:D}(");
foreach (Parameter parameter in client.RestClient.Parameters)
{
// Skip host and API Version parameters that would be set later
if (ManagementClientWriterHelpers.IsHostParameter(parameter) ||
ManagementClientWriterHelpers.IsApiVersionParameter(parameter))
{
continue;
}
writer.WriteParameter(parameter);
}
writer.Append($"{typeof(TokenCredential)} tokenCredential, {configuration.LibraryName}ManagementClientOptions options = null)");
using (writer.Scope())
{
writer.Line($"options = new {configuration.LibraryName}ManagementClientOptions();");
writer.Line($"_clientDiagnostics = new {typeof(ClientDiagnostics)}(options);");
writer.Line($"_pipeline = {typeof(ManagementPipelineBuilder)}.Build(tokenCredential, options);");
writer.Append($"this.RestClient = new {client.RestClient.Type}(_clientDiagnostics, _pipeline, ");
foreach (Parameter parameter in client.RestClient.Parameters)
{
if (ManagementClientWriterHelpers.IsHostParameter(parameter))
{
continue;
}
if (ManagementClientWriterHelpers.IsApiVersionParameter(parameter))
{
writer.Append($"options.Version, ");
continue;
}
writer.Append($"{parameter.Name:I}, ");
}
writer.RemoveTrailingComma();
writer.Line($");");
}
writer.Line();
}
private void WriteClientMethod(CodeWriter writer, ClientMethod clientMethod, bool async)
{
CSharpType? bodyType = clientMethod.RestClientMethod.ReturnType;

Просмотреть файл

@ -0,0 +1,14 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System;
using AutoRest.CSharp.V3.Output.Models.Shared;
namespace AutoRest.CSharp.V3.Generation.Writers
{
internal static class ManagementClientWriterHelpers
{
public static bool IsHostParameter(Parameter parameter) => string.Equals(parameter.Name, "host", StringComparison.InvariantCultureIgnoreCase);
public static bool IsApiVersionParameter(Parameter parameter) => string.Equals(parameter.Name, "apiVersion", StringComparison.InvariantCultureIgnoreCase);
}
}

Просмотреть файл

@ -10,18 +10,18 @@ namespace AutoRest.CSharp.V3.Output.Models.Types
{
internal class BuildContext
{
private readonly CodeModel _codeModel;
private OutputLibrary? _library;
private TypeFactory? _typeFactory;
public BuildContext(CodeModel codeModel, Configuration configuration, SourceInputModel sourceInputModel)
{
_codeModel = codeModel;
CodeModel = codeModel;
Configuration = configuration;
SourceInputModel = sourceInputModel;
}
public OutputLibrary Library => _library ??= new OutputLibrary(_codeModel, this);
public CodeModel CodeModel { get; }
public OutputLibrary Library => _library ??= new OutputLibrary(CodeModel, this);
public string DefaultNamespace => Configuration.Namespace;
public TypeFactory TypeFactory => _typeFactory ??= new TypeFactory(Library);
public Configuration Configuration { get; }

Просмотреть файл

@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using AutoRest.CSharp.V3.AutoRest.Communication;
using AutoRest.CSharp.V3.AutoRest.Communication.MessageHandling;
using AutoRest.CSharp.V3.AutoRest.Communication.Serialization;
@ -17,11 +18,12 @@ namespace AutoRest.CSharp.V3
private static bool HasServerArgument(IEnumerable<string> args) => args?.Any(a => a.Equals("--server", StringComparison.InvariantCultureIgnoreCase)) ?? false;
private static bool PluginStart(JsonRpcConnection connection, string pluginName, string sessionId) => PluginProcessor.Start(new JsonRpcCommunication(connection, pluginName, sessionId)).GetAwaiter().GetResult();
public static int Main(string[] args)
public static async Task<int> Main(string[] args)
{
if (args.Contains("--standalone"))
{
return RunStandalone(args);
await StandaloneGeneratorRunner.RunAsync(args);
return 0;
}
if (args.Contains("--launch-debugger") && !Debugger.IsAttached)
@ -48,9 +50,5 @@ namespace AutoRest.CSharp.V3
return 0;
}
private static int RunStandalone(string[] args)
{
return PluginProcessor.Start(new HostCommunication(args)).GetAwaiter().GetResult() ? 0 : 1;
}
}
}

Просмотреть файл

@ -2,87 +2,87 @@
"profiles": {
"additionalProperties": {
"commandName": "Project",
"commandLineArgs": "--standalone --input-codemodel=$(SolutionDir)\\test\\TestServerProjects\\additionalProperties\\CodeModel.yaml --plugin=csharpgen --output-folder=$(SolutionDir)\\test\\TestServerProjects\\additionalProperties --namespace=additionalProperties --shared-source-folder=$(SolutionDir)\\src\\assets --save-code-model=true"
"commandLineArgs": "--standalone $(SolutionDir)\\test\\TestServerProjects\\additionalProperties"
},
"AdditionalPropertiesEx": {
"commandName": "Project",
"commandLineArgs": "--standalone --input-codemodel=$(SolutionDir)\\test\\TestProjects\\AdditionalPropertiesEx\\CodeModel.yaml --plugin=csharpgen --output-folder=$(SolutionDir)\\test\\TestProjects\\AdditionalPropertiesEx --namespace=AdditionalPropertiesEx --shared-source-folder=$(SolutionDir)\\src\\assets --save-code-model=true"
"commandLineArgs": "--standalone $(SolutionDir)\\test\\TestProjects\\AdditionalPropertiesEx"
},
"AppConfiguration": {
"commandName": "Project",
"commandLineArgs": "--standalone --input-codemodel=$(SolutionDir)\\samples\\AppConfiguration\\AppConfiguration\\CodeModel.yaml --plugin=csharpgen --output-folder=$(SolutionDir)\\samples\\AppConfiguration\\AppConfiguration --namespace=AppConfiguration --shared-source-folder=$(SolutionDir)\\src\\assets --save-code-model=true"
"commandLineArgs": "--standalone $(SolutionDir)\\samples\\AppConfiguration\\AppConfiguration"
},
"Azure.AI.FormRecognizer": {
"commandName": "Project",
"commandLineArgs": "--standalone --input-codemodel=$(SolutionDir)\\samples\\Azure.AI.FormRecognizer\\Azure.AI.FormRecognizer\\CodeModel.yaml --plugin=csharpgen --output-folder=$(SolutionDir)\\samples\\Azure.AI.FormRecognizer\\Azure.AI.FormRecognizer --namespace=Azure.AI.FormRecognizer --shared-source-folder=$(SolutionDir)\\src\\assets --save-code-model=true"
"commandLineArgs": "--standalone $(SolutionDir)\\samples\\Azure.AI.FormRecognizer\\Azure.AI.FormRecognizer"
},
"Azure.Network.Management.Interface": {
"commandName": "Project",
"commandLineArgs": "--standalone --input-codemodel=$(SolutionDir)\\samples\\Azure.Network.Management.Interface\\Azure.Network.Management.Interface\\CodeModel.yaml --plugin=csharpgen --output-folder=$(SolutionDir)\\samples\\Azure.Network.Management.Interface\\Azure.Network.Management.Interface --namespace=Azure.Network.Management.Interface --shared-source-folder=$(SolutionDir)\\src\\assets --save-code-model=true"
"commandLineArgs": "--standalone $(SolutionDir)\\samples\\Azure.Network.Management.Interface\\Azure.Network.Management.Interface"
},
"Azure.Storage.Management": {
"commandName": "Project",
"commandLineArgs": "--standalone --input-codemodel=$(SolutionDir)\\samples\\Azure.Storage.Management\\Azure.Storage.Management\\CodeModel.yaml --plugin=csharpgen --output-folder=$(SolutionDir)\\samples\\Azure.Storage.Management\\Azure.Storage.Management --namespace=Azure.Storage.Management --shared-source-folder=$(SolutionDir)\\src\\assets --save-code-model=true"
"commandLineArgs": "--standalone $(SolutionDir)\\samples\\Azure.Storage.Management\\Azure.Storage.Management"
},
"Azure.Storage.Tables": {
"commandName": "Project",
"commandLineArgs": "--standalone --input-codemodel=$(SolutionDir)\\samples\\Azure.Storage.Tables\\Azure.Storage.Tables\\CodeModel.yaml --plugin=csharpgen --output-folder=$(SolutionDir)\\samples\\Azure.Storage.Tables\\Azure.Storage.Tables --namespace=Azure.Storage.Tables --shared-source-folder=$(SolutionDir)\\src\\assets --save-code-model=true"
"commandLineArgs": "--standalone $(SolutionDir)\\samples\\Azure.Storage.Tables\\Azure.Storage.Tables"
},
"azure-parameter-grouping": {
"commandName": "Project",
"commandLineArgs": "--standalone --input-codemodel=$(SolutionDir)\\test\\TestServerProjects\\azure-parameter-grouping\\CodeModel.yaml --plugin=csharpgen --output-folder=$(SolutionDir)\\test\\TestServerProjects\\azure-parameter-grouping --namespace=azure_parameter_grouping --shared-source-folder=$(SolutionDir)\\src\\assets --save-code-model=true"
"commandLineArgs": "--standalone $(SolutionDir)\\test\\TestServerProjects\\azure-parameter-grouping"
},
"body-array": {
"commandName": "Project",
"commandLineArgs": "--standalone --input-codemodel=$(SolutionDir)\\test\\TestServerProjects\\body-array\\CodeModel.yaml --plugin=csharpgen --output-folder=$(SolutionDir)\\test\\TestServerProjects\\body-array --namespace=body_array --shared-source-folder=$(SolutionDir)\\src\\assets --save-code-model=true"
"commandLineArgs": "--standalone $(SolutionDir)\\test\\TestServerProjects\\body-array"
},
"body-boolean": {
"commandName": "Project",
"commandLineArgs": "--standalone --input-codemodel=$(SolutionDir)\\test\\TestServerProjects\\body-boolean\\CodeModel.yaml --plugin=csharpgen --output-folder=$(SolutionDir)\\test\\TestServerProjects\\body-boolean --namespace=body_boolean --shared-source-folder=$(SolutionDir)\\src\\assets --save-code-model=true"
"commandLineArgs": "--standalone $(SolutionDir)\\test\\TestServerProjects\\body-boolean"
},
"body-byte": {
"commandName": "Project",
"commandLineArgs": "--standalone --input-codemodel=$(SolutionDir)\\test\\TestServerProjects\\body-byte\\CodeModel.yaml --plugin=csharpgen --output-folder=$(SolutionDir)\\test\\TestServerProjects\\body-byte --namespace=body_byte --shared-source-folder=$(SolutionDir)\\src\\assets --save-code-model=true"
"commandLineArgs": "--standalone $(SolutionDir)\\test\\TestServerProjects\\body-byte"
},
"body-complex": {
"commandName": "Project",
"commandLineArgs": "--standalone --input-codemodel=$(SolutionDir)\\test\\TestServerProjects\\body-complex\\CodeModel.yaml --plugin=csharpgen --output-folder=$(SolutionDir)\\test\\TestServerProjects\\body-complex --namespace=body_complex --shared-source-folder=$(SolutionDir)\\src\\assets --save-code-model=true"
"commandLineArgs": "--standalone $(SolutionDir)\\test\\TestServerProjects\\body-complex"
},
"body-date": {
"commandName": "Project",
"commandLineArgs": "--standalone --input-codemodel=$(SolutionDir)\\test\\TestServerProjects\\body-date\\CodeModel.yaml --plugin=csharpgen --output-folder=$(SolutionDir)\\test\\TestServerProjects\\body-date --namespace=body_date --shared-source-folder=$(SolutionDir)\\src\\assets --save-code-model=true"
"commandLineArgs": "--standalone $(SolutionDir)\\test\\TestServerProjects\\body-date"
},
"body-datetime": {
"commandName": "Project",
"commandLineArgs": "--standalone --input-codemodel=$(SolutionDir)\\test\\TestServerProjects\\body-datetime\\CodeModel.yaml --plugin=csharpgen --output-folder=$(SolutionDir)\\test\\TestServerProjects\\body-datetime --namespace=body_datetime --shared-source-folder=$(SolutionDir)\\src\\assets --save-code-model=true"
"commandLineArgs": "--standalone $(SolutionDir)\\test\\TestServerProjects\\body-datetime"
},
"body-datetime-rfc1123": {
"commandName": "Project",
"commandLineArgs": "--standalone --input-codemodel=$(SolutionDir)\\test\\TestServerProjects\\body-datetime-rfc1123\\CodeModel.yaml --plugin=csharpgen --output-folder=$(SolutionDir)\\test\\TestServerProjects\\body-datetime-rfc1123 --namespace=body_datetime_rfc1123 --shared-source-folder=$(SolutionDir)\\src\\assets --save-code-model=true"
"commandLineArgs": "--standalone $(SolutionDir)\\test\\TestServerProjects\\body-datetime-rfc1123"
},
"body-dictionary": {
"commandName": "Project",
"commandLineArgs": "--standalone --input-codemodel=$(SolutionDir)\\test\\TestServerProjects\\body-dictionary\\CodeModel.yaml --plugin=csharpgen --output-folder=$(SolutionDir)\\test\\TestServerProjects\\body-dictionary --namespace=body_dictionary --shared-source-folder=$(SolutionDir)\\src\\assets --save-code-model=true"
"commandLineArgs": "--standalone $(SolutionDir)\\test\\TestServerProjects\\body-dictionary"
},
"body-duration": {
"commandName": "Project",
"commandLineArgs": "--standalone --input-codemodel=$(SolutionDir)\\test\\TestServerProjects\\body-duration\\CodeModel.yaml --plugin=csharpgen --output-folder=$(SolutionDir)\\test\\TestServerProjects\\body-duration --namespace=body_duration --shared-source-folder=$(SolutionDir)\\src\\assets --save-code-model=true"
"commandLineArgs": "--standalone $(SolutionDir)\\test\\TestServerProjects\\body-duration"
},
"body-file": {
"commandName": "Project",
"commandLineArgs": "--standalone --input-codemodel=$(SolutionDir)\\test\\TestServerProjects\\body-file\\CodeModel.yaml --plugin=csharpgen --output-folder=$(SolutionDir)\\test\\TestServerProjects\\body-file --namespace=body_file --shared-source-folder=$(SolutionDir)\\src\\assets --save-code-model=true"
"commandLineArgs": "--standalone $(SolutionDir)\\test\\TestServerProjects\\body-file"
},
"body-integer": {
"commandName": "Project",
"commandLineArgs": "--standalone --input-codemodel=$(SolutionDir)\\test\\TestServerProjects\\body-integer\\CodeModel.yaml --plugin=csharpgen --output-folder=$(SolutionDir)\\test\\TestServerProjects\\body-integer --namespace=body_integer --shared-source-folder=$(SolutionDir)\\src\\assets --save-code-model=true"
"commandLineArgs": "--standalone $(SolutionDir)\\test\\TestServerProjects\\body-integer"
},
"body-number": {
"commandName": "Project",
"commandLineArgs": "--standalone --input-codemodel=$(SolutionDir)\\test\\TestServerProjects\\body-number\\CodeModel.yaml --plugin=csharpgen --output-folder=$(SolutionDir)\\test\\TestServerProjects\\body-number --namespace=body_number --shared-source-folder=$(SolutionDir)\\src\\assets --save-code-model=true"
"commandLineArgs": "--standalone $(SolutionDir)\\test\\TestServerProjects\\body-number"
},
"body-string": {
"commandName": "Project",
"commandLineArgs": "--standalone --input-codemodel=$(SolutionDir)\\test\\TestServerProjects\\body-string\\CodeModel.yaml --plugin=csharpgen --output-folder=$(SolutionDir)\\test\\TestServerProjects\\body-string --namespace=body_string --shared-source-folder=$(SolutionDir)\\src\\assets --save-code-model=true"
"commandLineArgs": "--standalone $(SolutionDir)\\test\\TestServerProjects\\body-string"
},
"body-time": {
"commandName": "Project",
@ -90,87 +90,87 @@
},
"CognitiveSearch": {
"commandName": "Project",
"commandLineArgs": "--standalone --input-codemodel=$(SolutionDir)\\samples\\CognitiveSearch\\CognitiveSearch\\CodeModel.yaml --plugin=csharpgen --output-folder=$(SolutionDir)\\samples\\CognitiveSearch\\CognitiveSearch --namespace=CognitiveSearch --shared-source-folder=$(SolutionDir)\\src\\assets --save-code-model=true"
"commandLineArgs": "--standalone $(SolutionDir)\\samples\\CognitiveSearch\\CognitiveSearch"
},
"CognitiveServices.TextAnalytics": {
"commandName": "Project",
"commandLineArgs": "--standalone --input-codemodel=$(SolutionDir)\\samples\\CognitiveServices.TextAnalytics\\CognitiveServices.TextAnalytics\\CodeModel.yaml --plugin=csharpgen --output-folder=$(SolutionDir)\\samples\\CognitiveServices.TextAnalytics\\CognitiveServices.TextAnalytics --namespace=CognitiveServices.TextAnalytics --shared-source-folder=$(SolutionDir)\\src\\assets --save-code-model=true"
"commandLineArgs": "--standalone $(SolutionDir)\\samples\\CognitiveServices.TextAnalytics\\CognitiveServices.TextAnalytics"
},
"custom-baseUrl": {
"commandName": "Project",
"commandLineArgs": "--standalone --input-codemodel=$(SolutionDir)\\test\\TestServerProjects\\custom-baseUrl\\CodeModel.yaml --plugin=csharpgen --output-folder=$(SolutionDir)\\test\\TestServerProjects\\custom-baseUrl --namespace=custom_baseUrl --shared-source-folder=$(SolutionDir)\\src\\assets --save-code-model=true"
"commandLineArgs": "--standalone $(SolutionDir)\\test\\TestServerProjects\\custom-baseUrl"
},
"custom-baseUrl-more-options": {
"commandName": "Project",
"commandLineArgs": "--standalone --input-codemodel=$(SolutionDir)\\test\\TestServerProjects\\custom-baseUrl-more-options\\CodeModel.yaml --plugin=csharpgen --output-folder=$(SolutionDir)\\test\\TestServerProjects\\custom-baseUrl-more-options --namespace=custom_baseUrl_more_options --shared-source-folder=$(SolutionDir)\\src\\assets --save-code-model=true"
"commandLineArgs": "--standalone $(SolutionDir)\\test\\TestServerProjects\\custom-baseUrl-more-options"
},
"custom-baseUrl-paging": {
"commandName": "Project",
"commandLineArgs": "--standalone --input-codemodel=$(SolutionDir)\\test\\TestServerProjects\\custom-baseUrl-paging\\CodeModel.yaml --plugin=csharpgen --output-folder=$(SolutionDir)\\test\\TestServerProjects\\custom-baseUrl-paging --namespace=custom_baseUrl_paging --shared-source-folder=$(SolutionDir)\\src\\assets --save-code-model=true"
"commandLineArgs": "--standalone $(SolutionDir)\\test\\TestServerProjects\\custom-baseUrl-paging"
},
"extensible-enums-swagger": {
"commandName": "Project",
"commandLineArgs": "--standalone --input-codemodel=$(SolutionDir)\\test\\TestServerProjects\\extensible-enums-swagger\\CodeModel.yaml --plugin=csharpgen --output-folder=$(SolutionDir)\\test\\TestServerProjects\\extensible-enums-swagger --namespace=extensible_enums_swagger --shared-source-folder=$(SolutionDir)\\src\\assets --save-code-model=true"
"commandLineArgs": "--standalone $(SolutionDir)\\test\\TestServerProjects\\extensible-enums-swagger"
},
"ExtensionClientName": {
"commandName": "Project",
"commandLineArgs": "--standalone --input-codemodel=$(SolutionDir)\\test\\TestProjects\\ExtensionClientName\\CodeModel.yaml --plugin=csharpgen --output-folder=$(SolutionDir)\\test\\TestProjects\\ExtensionClientName --namespace=ExtensionClientName --shared-source-folder=$(SolutionDir)\\src\\assets --save-code-model=true"
"commandLineArgs": "--standalone $(SolutionDir)\\test\\TestProjects\\ExtensionClientName"
},
"header": {
"commandName": "Project",
"commandLineArgs": "--standalone --input-codemodel=$(SolutionDir)\\test\\TestServerProjects\\header\\CodeModel.yaml --plugin=csharpgen --output-folder=$(SolutionDir)\\test\\TestServerProjects\\header --namespace=header --shared-source-folder=$(SolutionDir)\\src\\assets --save-code-model=true"
"commandLineArgs": "--standalone $(SolutionDir)\\test\\TestServerProjects\\header"
},
"httpInfrastructure": {
"commandName": "Project",
"commandLineArgs": "--standalone --input-codemodel=$(SolutionDir)\\test\\TestServerProjects\\httpInfrastructure\\CodeModel.yaml --plugin=csharpgen --output-folder=$(SolutionDir)\\test\\TestServerProjects\\httpInfrastructure --namespace=httpInfrastructure --shared-source-folder=$(SolutionDir)\\src\\assets --save-code-model=true"
"commandLineArgs": "--standalone $(SolutionDir)\\test\\TestServerProjects\\httpInfrastructure"
},
"lro": {
"commandName": "Project",
"commandLineArgs": "--standalone --input-codemodel=$(SolutionDir)\\test\\TestServerProjects\\lro\\CodeModel.yaml --plugin=csharpgen --output-folder=$(SolutionDir)\\test\\TestServerProjects\\lro --namespace=lro --shared-source-folder=$(SolutionDir)\\src\\assets --save-code-model=true"
"commandLineArgs": "--standalone $(SolutionDir)\\test\\TestServerProjects\\lro"
},
"media_types": {
"commandName": "Project",
"commandLineArgs": "--standalone --input-codemodel=$(SolutionDir)\\test\\TestServerProjects\\media_types\\CodeModel.yaml --plugin=csharpgen --output-folder=$(SolutionDir)\\test\\TestServerProjects\\media_types --namespace=media_types --shared-source-folder=$(SolutionDir)\\src\\assets --save-code-model=true"
"commandLineArgs": "--standalone $(SolutionDir)\\test\\TestServerProjects\\media_types"
},
"model-flattening": {
"commandName": "Project",
"commandLineArgs": "--standalone --input-codemodel=$(SolutionDir)\\test\\TestServerProjects\\model-flattening\\CodeModel.yaml --plugin=csharpgen --output-folder=$(SolutionDir)\\test\\TestServerProjects\\model-flattening --namespace=model_flattening --shared-source-folder=$(SolutionDir)\\src\\assets --save-code-model=true"
"commandLineArgs": "--standalone $(SolutionDir)\\test\\TestServerProjects\\model-flattening"
},
"NameConflicts": {
"commandName": "Project",
"commandLineArgs": "--standalone --input-codemodel=$(SolutionDir)\\test\\TestProjects\\NameConflicts\\CodeModel.yaml --plugin=csharpgen --output-folder=$(SolutionDir)\\test\\TestProjects\\NameConflicts --namespace=NameConflicts --shared-source-folder=$(SolutionDir)\\src\\assets --save-code-model=true"
"commandLineArgs": "--standalone $(SolutionDir)\\test\\TestProjects\\NameConflicts"
},
"non-string-enum": {
"commandName": "Project",
"commandLineArgs": "--standalone --input-codemodel=$(SolutionDir)\\test\\TestServerProjects\\non-string-enum\\CodeModel.yaml --plugin=csharpgen --output-folder=$(SolutionDir)\\test\\TestServerProjects\\non-string-enum --namespace=non_string_enum --shared-source-folder=$(SolutionDir)\\src\\assets --save-code-model=true"
"commandLineArgs": "--standalone $(SolutionDir)\\test\\TestServerProjects\\non-string-enum"
},
"paging": {
"commandName": "Project",
"commandLineArgs": "--standalone --input-codemodel=$(SolutionDir)\\test\\TestServerProjects\\paging\\CodeModel.yaml --plugin=csharpgen --output-folder=$(SolutionDir)\\test\\TestServerProjects\\paging --namespace=paging --shared-source-folder=$(SolutionDir)\\src\\assets --save-code-model=true"
"commandLineArgs": "--standalone $(SolutionDir)\\test\\TestServerProjects\\paging"
},
"SignalR": {
"commandName": "Project",
"commandLineArgs": "--standalone --input-codemodel=$(SolutionDir)\\samples\\SignalR\\SignalR\\CodeModel.yaml --plugin=csharpgen --output-folder=$(SolutionDir)\\samples\\SignalR\\SignalR --namespace=SignalR --shared-source-folder=$(SolutionDir)\\src\\assets --save-code-model=true"
"commandLineArgs": "--standalone $(SolutionDir)\\samples\\SignalR\\SignalR"
},
"TypeSchemaMapping": {
"commandName": "Project",
"commandLineArgs": "--standalone --input-codemodel=$(SolutionDir)\\test\\TestProjects\\TypeSchemaMapping\\CodeModel.yaml --plugin=csharpgen --output-folder=$(SolutionDir)\\test\\TestProjects\\TypeSchemaMapping --namespace=TypeSchemaMapping --shared-source-folder=$(SolutionDir)\\src\\assets --save-code-model=true"
"commandLineArgs": "--standalone $(SolutionDir)\\test\\TestProjects\\TypeSchemaMapping"
},
"url": {
"commandName": "Project",
"commandLineArgs": "--standalone --input-codemodel=$(SolutionDir)\\test\\TestServerProjects\\url\\CodeModel.yaml --plugin=csharpgen --output-folder=$(SolutionDir)\\test\\TestServerProjects\\url --namespace=url --shared-source-folder=$(SolutionDir)\\src\\assets --save-code-model=true"
"commandLineArgs": "--standalone $(SolutionDir)\\test\\TestServerProjects\\url"
},
"url-multi-collectionFormat": {
"commandName": "Project",
"commandLineArgs": "--standalone --input-codemodel=$(SolutionDir)\\test\\TestServerProjects\\url-multi-collectionFormat\\CodeModel.yaml --plugin=csharpgen --output-folder=$(SolutionDir)\\test\\TestServerProjects\\url-multi-collectionFormat --namespace=url_multi_collectionFormat --shared-source-folder=$(SolutionDir)\\src\\assets --save-code-model=true"
"commandLineArgs": "--standalone $(SolutionDir)\\test\\TestServerProjects\\url-multi-collectionFormat"
},
"validation": {
"commandName": "Project",
"commandLineArgs": "--standalone --input-codemodel=$(SolutionDir)\\test\\TestServerProjects\\validation\\CodeModel.yaml --plugin=csharpgen --output-folder=$(SolutionDir)\\test\\TestServerProjects\\validation --namespace=validation --shared-source-folder=$(SolutionDir)\\src\\assets --save-code-model=true"
"commandLineArgs": "--standalone $(SolutionDir)\\test\\TestServerProjects\\validation"
},
"xml-service": {
"commandName": "Project",
"commandLineArgs": "--standalone --input-codemodel=$(SolutionDir)\\test\\TestServerProjects\\xml-service\\CodeModel.yaml --plugin=csharpgen --output-folder=$(SolutionDir)\\test\\TestServerProjects\\xml-service --namespace=xml_service --shared-source-folder=$(SolutionDir)\\src\\assets --save-code-model=true"
"commandLineArgs": "--standalone $(SolutionDir)\\test\\TestServerProjects\\xml-service"
}
}
}

Просмотреть файл

@ -0,0 +1,22 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#nullable enable
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text.Json;
using System.Xml;
using Azure.Core.Pipeline;
namespace Azure.Core
{
internal static class ManagementPipelineBuilder
{
public static HttpPipeline Build(TokenCredential credential, ClientOptions options)
{
return HttpPipelineBuilder.Build(options, new BearerTokenAuthenticationPolicy(credential, "https://management.azure.com//.default"));
}
}
}

Просмотреть файл

@ -1,7 +1,7 @@
!<!CodeModel>
info: !<!Info>
description: Test Infrastructure for AutoRest
title: AdditionalPropertiesEx
title: AdditionalPropertiesClient
schemas: !<!Schemas>
numbers:
- !<!NumberSchema> &ref_4
@ -533,7 +533,7 @@ security: !<!Security>
authenticationRequired: false
language: !<!Languages>
default:
name: AdditionalPropertiesEx
name: AdditionalPropertiesClient
description: ''
protocol: !<!Protocols>
http: !<!HttpModel> {}

1
test/TestProjects/AdditionalPropertiesEx/Configuration.json сгенерированный Normal file
Просмотреть файл

@ -0,0 +1 @@
{"OutputFolder":".","Namespace":"AdditionalPropertiesEx","LibraryName":"AdditionalPropertiesEx","SharedSourceFolder":"..\\..\\..\\src\\assets","AzureArm":false}

4
test/TestProjects/ExtensionClientName/CodeModel.yaml сгенерированный
Просмотреть файл

@ -1,7 +1,7 @@
!<!CodeModel>
info: !<!Info>
description: Resource Flattening for AutoRest
title: ExtensionClientName
title: AutoRest Parameter Flattening
schemas: !<!Schemas>
strings:
- !<!StringSchema> &ref_0
@ -217,7 +217,7 @@ security: !<!Security>
authenticationRequired: false
language: !<!Languages>
default:
name: ExtensionClientName
name: AutoRestParameterFlattening
description: ''
protocol: !<!Protocols>
http: !<!HttpModel> {}

1
test/TestProjects/ExtensionClientName/Configuration.json сгенерированный Normal file
Просмотреть файл

@ -0,0 +1 @@
{"OutputFolder":".","Namespace":"ExtensionClientName","LibraryName":"ExtensionClientName","SharedSourceFolder":"..\\..\\..\\src\\assets","AzureArm":false}

4
test/TestProjects/NameConflicts/CodeModel.yaml сгенерированный
Просмотреть файл

@ -1,7 +1,7 @@
!<!CodeModel>
info: !<!Info>
description: Resource Flattening for AutoRest
title: NameConflicts
title: AutoRest Parameter Flattening
schemas: !<!Schemas>
strings:
- !<!StringSchema> &ref_0
@ -2230,7 +2230,7 @@ security: !<!Security>
authenticationRequired: false
language: !<!Languages>
default:
name: NameConflicts
name: AutoRestParameterFlattening
description: ''
protocol: !<!Protocols>
http: !<!HttpModel> {}

1
test/TestProjects/NameConflicts/Configuration.json сгенерированный Normal file
Просмотреть файл

@ -0,0 +1 @@
{"OutputFolder":".","Namespace":"NameConflicts","LibraryName":"NameConflicts","SharedSourceFolder":"..\\..\\..\\src\\assets","AzureArm":false}

4
test/TestProjects/TypeSchemaMapping/CodeModel.yaml сгенерированный
Просмотреть файл

@ -1,7 +1,7 @@
!<!CodeModel>
info: !<!Info>
description: Schema mapping
title: TypeSchemaMapping
title: Schema mapping
schemas: !<!Schemas>
numbers:
- !<!NumberSchema> &ref_1
@ -514,7 +514,7 @@ security: !<!Security>
authenticationRequired: false
language: !<!Languages>
default:
name: TypeSchemaMapping
name: SchemaMapping
description: ''
protocol: !<!Protocols>
http: !<!HttpModel> {}

1
test/TestProjects/TypeSchemaMapping/Configuration.json сгенерированный Normal file
Просмотреть файл

@ -0,0 +1 @@
{"OutputFolder":".","Namespace":"TypeSchemaMapping","LibraryName":"TypeSchemaMapping","SharedSourceFolder":"..\\..\\..\\src\\assets","AzureArm":false}

Просмотреть файл

@ -1,7 +1,7 @@
!<!CodeModel>
info: !<!Info>
description: Test Infrastructure for AutoRest
title: additionalProperties
title: AdditionalPropertiesClient
schemas: !<!Schemas>
booleans:
- !<!BooleanSchema> &ref_6
@ -1050,7 +1050,7 @@ security: !<!Security>
authenticationRequired: false
language: !<!Languages>
default:
name: AdditionalProperties
name: AdditionalPropertiesClient
description: ''
protocol: !<!Protocols>
http: !<!HttpModel> {}

1
test/TestServerProjects/additionalProperties/Configuration.json сгенерированный Normal file
Просмотреть файл

@ -0,0 +1 @@
{"OutputFolder":".","Namespace":"additionalProperties","LibraryName":"additionalProperties","SharedSourceFolder":"..\\..\\..\\src\\assets","AzureArm":false}

Просмотреть файл

@ -1,7 +1,7 @@
!<!CodeModel>
info: !<!Info>
description: Test Infrastructure for AutoRest
title: azure-parameter-grouping
title: AutoRest Parameter Grouping Test Service
schemas: !<!Schemas>
numbers:
- !<!NumberSchema> &ref_3
@ -686,7 +686,7 @@ security: !<!Security>
authenticationRequired: false
language: !<!Languages>
default:
name: AzureParameterGrouping
name: AutoRestParameterGroupingTestService
description: ''
protocol: !<!Protocols>
http: !<!HttpModel> {}

1
test/TestServerProjects/azure-parameter-grouping/Configuration.json сгенерированный Normal file
Просмотреть файл

@ -0,0 +1 @@
{"OutputFolder":".","Namespace":"azure_parameter_grouping","LibraryName":"azure_parameter_grouping","SharedSourceFolder":"..\\..\\..\\src\\assets","AzureArm":false}

4
test/TestServerProjects/body-array/CodeModel.yaml сгенерированный
Просмотреть файл

@ -1,7 +1,7 @@
!<!CodeModel>
info: !<!Info>
description: Test Infrastructure for AutoRest Swagger BAT
title: body-array
title: AutoRest Swagger BAT Array Service
schemas: !<!Schemas>
booleans:
- !<!BooleanSchema> &ref_8
@ -5316,7 +5316,7 @@ security: !<!Security>
authenticationRequired: false
language: !<!Languages>
default:
name: BodyArray
name: AutoRestSwaggerBATArrayService
description: ''
protocol: !<!Protocols>
http: !<!HttpModel> {}

1
test/TestServerProjects/body-array/Configuration.json сгенерированный Normal file
Просмотреть файл

@ -0,0 +1 @@
{"OutputFolder":".","Namespace":"body_array","LibraryName":"body_array","SharedSourceFolder":"..\\..\\..\\src\\assets","AzureArm":false}

4
test/TestServerProjects/body-boolean/CodeModel.yaml сгенерированный
Просмотреть файл

@ -1,7 +1,7 @@
!<!CodeModel>
info: !<!Info>
description: Test Infrastructure for AutoRest
title: body-boolean
title: AutoRest Bool Test Service
schemas: !<!Schemas>
booleans:
- !<!BooleanSchema> &ref_0
@ -532,7 +532,7 @@ security: !<!Security>
authenticationRequired: false
language: !<!Languages>
default:
name: BodyBoolean
name: AutoRestBoolTestService
description: ''
protocol: !<!Protocols>
http: !<!HttpModel> {}

1
test/TestServerProjects/body-boolean/Configuration.json сгенерированный Normal file
Просмотреть файл

@ -0,0 +1 @@
{"OutputFolder":".","Namespace":"body_boolean","LibraryName":"body_boolean","SharedSourceFolder":"..\\..\\..\\src\\assets","AzureArm":false}

4
test/TestServerProjects/body-byte/CodeModel.yaml сгенерированный
Просмотреть файл

@ -1,7 +1,7 @@
!<!CodeModel>
info: !<!Info>
description: Test Infrastructure for AutoRest Swagger BAT
title: body-byte
title: AutoRest Swagger BAT Byte Service
schemas: !<!Schemas>
numbers:
- !<!NumberSchema> &ref_1
@ -442,7 +442,7 @@ security: !<!Security>
authenticationRequired: false
language: !<!Languages>
default:
name: BodyByte
name: AutoRestSwaggerBATByteService
description: ''
protocol: !<!Protocols>
http: !<!HttpModel> {}

1
test/TestServerProjects/body-byte/Configuration.json сгенерированный Normal file
Просмотреть файл

@ -0,0 +1 @@
{"OutputFolder":".","Namespace":"body_byte","LibraryName":"body_byte","SharedSourceFolder":"..\\..\\..\\src\\assets","AzureArm":false}

4
test/TestServerProjects/body-complex/CodeModel.yaml сгенерированный
Просмотреть файл

@ -1,7 +1,7 @@
!<!CodeModel>
info: !<!Info>
description: Test Infrastructure for AutoRest
title: body-complex
title: AutoRest Complex Test Service
schemas: !<!Schemas>
booleans:
- !<!BooleanSchema> &ref_11
@ -5421,7 +5421,7 @@ security: !<!Security>
authenticationRequired: false
language: !<!Languages>
default:
name: BodyComplex
name: AutoRestComplexTestService
description: ''
protocol: !<!Protocols>
http: !<!HttpModel> {}

1
test/TestServerProjects/body-complex/Configuration.json сгенерированный Normal file
Просмотреть файл

@ -0,0 +1 @@
{"OutputFolder":".","Namespace":"body_complex","LibraryName":"body_complex","SharedSourceFolder":"..\\..\\..\\src\\assets","AzureArm":false}

4
test/TestServerProjects/body-date/CodeModel.yaml сгенерированный
Просмотреть файл

@ -1,7 +1,7 @@
!<!CodeModel>
info: !<!Info>
description: Test Infrastructure for AutoRest
title: body-date
title: AutoRest Date Test Service
schemas: !<!Schemas>
numbers:
- !<!NumberSchema> &ref_2
@ -590,7 +590,7 @@ security: !<!Security>
authenticationRequired: false
language: !<!Languages>
default:
name: BodyDate
name: AutoRestDateTestService
description: ''
protocol: !<!Protocols>
http: !<!HttpModel> {}

1
test/TestServerProjects/body-date/Configuration.json сгенерированный Normal file
Просмотреть файл

@ -0,0 +1 @@
{"OutputFolder":".","Namespace":"body_date","LibraryName":"body_date","SharedSourceFolder":"..\\..\\..\\src\\assets","AzureArm":false}

Просмотреть файл

@ -1,7 +1,7 @@
!<!CodeModel>
info: !<!Info>
description: Test Infrastructure for AutoRest
title: body-datetime-rfc1123
title: AutoRest RFC1123 DateTime Test Service
schemas: !<!Schemas>
numbers:
- !<!NumberSchema> &ref_2
@ -642,7 +642,7 @@ security: !<!Security>
authenticationRequired: false
language: !<!Languages>
default:
name: BodyDatetimeRfc1123
name: AutoRestRFC1123DateTimeTestService
description: ''
protocol: !<!Protocols>
http: !<!HttpModel> {}

1
test/TestServerProjects/body-datetime-rfc1123/Configuration.json сгенерированный Normal file
Просмотреть файл

@ -0,0 +1 @@
{"OutputFolder":".","Namespace":"body_datetime_rfc1123","LibraryName":"body_datetime_rfc1123","SharedSourceFolder":"..\\..\\..\\src\\assets","AzureArm":false}

4
test/TestServerProjects/body-datetime/CodeModel.yaml сгенерированный
Просмотреть файл

@ -1,7 +1,7 @@
!<!CodeModel>
info: !<!Info>
description: Test Infrastructure for AutoRest
title: body-datetime
title: AutoRest DateTime Test Service
schemas: !<!Schemas>
numbers:
- !<!NumberSchema> &ref_2
@ -1417,7 +1417,7 @@ security: !<!Security>
authenticationRequired: false
language: !<!Languages>
default:
name: BodyDatetime
name: AutoRestDateTimeTestService
description: ''
protocol: !<!Protocols>
http: !<!HttpModel> {}

1
test/TestServerProjects/body-datetime/Configuration.json сгенерированный Normal file
Просмотреть файл

@ -0,0 +1 @@
{"OutputFolder":".","Namespace":"body_datetime","LibraryName":"body_datetime","SharedSourceFolder":"..\\..\\..\\src\\assets","AzureArm":false}

Просмотреть файл

@ -1,7 +1,7 @@
!<!CodeModel>
info: !<!Info>
description: Test Infrastructure for AutoRest Swagger BAT
title: body-dictionary
title: AutoRest Swagger BAT dictionary Service
schemas: !<!Schemas>
booleans:
- !<!BooleanSchema> &ref_3
@ -4638,7 +4638,7 @@ security: !<!Security>
authenticationRequired: false
language: !<!Languages>
default:
name: BodyDictionary
name: AutoRestSwaggerBATDictionaryService
description: ''
protocol: !<!Protocols>
http: !<!HttpModel> {}

1
test/TestServerProjects/body-dictionary/Configuration.json сгенерированный Normal file
Просмотреть файл

@ -0,0 +1 @@
{"OutputFolder":".","Namespace":"body_dictionary","LibraryName":"body_dictionary","SharedSourceFolder":"..\\..\\..\\src\\assets","AzureArm":false}

4
test/TestServerProjects/body-duration/CodeModel.yaml сгенерированный
Просмотреть файл

@ -1,7 +1,7 @@
!<!CodeModel>
info: !<!Info>
description: Test Infrastructure for AutoRest
title: body-duration
title: AutoRest Duration Test Service
schemas: !<!Schemas>
numbers:
- !<!NumberSchema> &ref_1
@ -346,7 +346,7 @@ security: !<!Security>
authenticationRequired: false
language: !<!Languages>
default:
name: BodyDuration
name: AutoRestDurationTestService
description: ''
protocol: !<!Protocols>
http: !<!HttpModel> {}

1
test/TestServerProjects/body-duration/Configuration.json сгенерированный Normal file
Просмотреть файл

@ -0,0 +1 @@
{"OutputFolder":".","Namespace":"body_duration","LibraryName":"body_duration","SharedSourceFolder":"..\\..\\..\\src\\assets","AzureArm":false}

4
test/TestServerProjects/body-file/CodeModel.yaml сгенерированный
Просмотреть файл

@ -1,7 +1,7 @@
!<!CodeModel>
info: !<!Info>
description: Test Infrastructure for AutoRest Swagger BAT
title: body-file
title: AutoRest Swagger BAT File Service
schemas: !<!Schemas>
numbers:
- !<!NumberSchema> &ref_0
@ -249,7 +249,7 @@ security: !<!Security>
authenticationRequired: false
language: !<!Languages>
default:
name: BodyFile
name: AutoRestSwaggerBATFileService
description: ''
protocol: !<!Protocols>
http: !<!HttpModel> {}

1
test/TestServerProjects/body-file/Configuration.json сгенерированный Normal file
Просмотреть файл

@ -0,0 +1 @@
{"OutputFolder":".","Namespace":"body_file","LibraryName":"body_file","SharedSourceFolder":"..\\..\\..\\src\\assets","AzureArm":false}

4
test/TestServerProjects/body-integer/CodeModel.yaml сгенерированный
Просмотреть файл

@ -1,7 +1,7 @@
!<!CodeModel>
info: !<!Info>
description: Test Infrastructure for AutoRest
title: body-integer
title: AutoRest Integer Test Service
schemas: !<!Schemas>
numbers:
- !<!NumberSchema> &ref_4
@ -986,7 +986,7 @@ security: !<!Security>
authenticationRequired: false
language: !<!Languages>
default:
name: BodyInteger
name: AutoRestIntegerTestService
description: ''
protocol: !<!Protocols>
http: !<!HttpModel> {}

1
test/TestServerProjects/body-integer/Configuration.json сгенерированный Normal file
Просмотреть файл

@ -0,0 +1 @@
{"OutputFolder":".","Namespace":"body_integer","LibraryName":"body_integer","SharedSourceFolder":"..\\..\\..\\src\\assets","AzureArm":false}

4
test/TestServerProjects/body-number/CodeModel.yaml сгенерированный
Просмотреть файл

@ -1,7 +1,7 @@
!<!CodeModel>
info: !<!Info>
description: Test Infrastructure for AutoRest
title: body-number
title: AutoRest Number Test Service
schemas: !<!Schemas>
numbers:
- !<!NumberSchema> &ref_1
@ -1809,7 +1809,7 @@ security: !<!Security>
authenticationRequired: false
language: !<!Languages>
default:
name: BodyNumber
name: AutoRestNumberTestService
description: ''
protocol: !<!Protocols>
http: !<!HttpModel> {}

1
test/TestServerProjects/body-number/Configuration.json сгенерированный Normal file
Просмотреть файл

@ -0,0 +1 @@
{"OutputFolder":".","Namespace":"body_number","LibraryName":"body_number","SharedSourceFolder":"..\\..\\..\\src\\assets","AzureArm":false}

4
test/TestServerProjects/body-string/CodeModel.yaml сгенерированный
Просмотреть файл

@ -1,7 +1,7 @@
!<!CodeModel>
info: !<!Info>
description: Test Infrastructure for AutoRest Swagger BAT
title: body-string
title: AutoRest Swagger BAT Service
schemas: !<!Schemas>
numbers:
- !<!NumberSchema> &ref_1
@ -1516,7 +1516,7 @@ security: !<!Security>
authenticationRequired: false
language: !<!Languages>
default:
name: BodyString
name: AutoRestSwaggerBATService
description: ''
protocol: !<!Protocols>
http: !<!HttpModel> {}

1
test/TestServerProjects/body-string/Configuration.json сгенерированный Normal file
Просмотреть файл

@ -0,0 +1 @@
{"OutputFolder":".","Namespace":"body_string","LibraryName":"body_string","SharedSourceFolder":"..\\..\\..\\src\\assets","AzureArm":false}

Просмотреть файл

@ -1,7 +1,7 @@
!<!CodeModel>
info: !<!Info>
description: Test Infrastructure for AutoRest
title: custom-baseUrl-more-options
title: AutoRest Parameterized Custom Host Test Client
schemas: !<!Schemas>
numbers:
- !<!NumberSchema> &ref_0
@ -254,7 +254,7 @@ security: !<!Security>
authenticationRequired: false
language: !<!Languages>
default:
name: CustomBaseUrlMoreOptions
name: AutoRestParameterizedCustomHostTestClient
description: ''
protocol: !<!Protocols>
http: !<!HttpModel> {}

1
test/TestServerProjects/custom-baseUrl-more-options/Configuration.json сгенерированный Normal file
Просмотреть файл

@ -0,0 +1 @@
{"OutputFolder":".","Namespace":"custom_baseUrl_more_options","LibraryName":"custom_baseUrl_more_options","SharedSourceFolder":"..\\..\\..\\src\\assets","AzureArm":false}

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше