Коммит
2206ac28aa
|
@ -1,6 +1,6 @@
|
|||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.113">
|
||||
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.113" Condition="'$(IncludeStyleCopAnalyzers)' != 'false'">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
</PackageReference>
|
||||
|
|
|
@ -17,13 +17,9 @@ function Invoke-Block([scriptblock]$cmd) {
|
|||
}
|
||||
}
|
||||
|
||||
function Invoke-AutoRest($debugFlags, $testConfiguration, $outputFolder, $inputFile, $name, $namespace, $repoRoot) {
|
||||
function Invoke-AutoRest($autoRestArguments, $repoRoot) {
|
||||
Invoke-Block {
|
||||
$outputFlag = if($outputFolder) { "--output-folder=$outputFolder" } else { '' }
|
||||
$inputFlag = if($inputFile) { "--input-file=$inputFile" } else { '' }
|
||||
$titleFlag = if($name) { "--title=$name" } else { '' }
|
||||
$namespaceFlag = if($namespace) { "--namespace=$namespace" } else { '' }
|
||||
$command = "npx autorest-beta $debugFlags $testConfiguration $outputFlag $inputFlag $titleFlag $namespaceFlag"
|
||||
$command = "npx autorest-beta $autoRestArguments"
|
||||
$commandText = $command.Replace($repoRoot, "`$(SolutionDir)")
|
||||
|
||||
Write-Host ">" $commandText
|
||||
|
@ -37,17 +33,17 @@ $repoRoot = Resolve-Path (Join-Path $PSScriptRoot '..')
|
|||
$debugFlags = if (-not $noDebug) { '--debug', '--verbose' }
|
||||
|
||||
# Test server test configuration
|
||||
$testServerTestProject = Join-Path $repoRoot 'test' 'AutoRest.TestServer.Tests'
|
||||
$testConfiguration = Join-Path $testServerTestProject 'readme.md'
|
||||
$testServerDirectory = Join-Path $repoRoot 'test' 'TestServerProjects'
|
||||
$configurationPath = Join-Path $testServerDirectory 'readme.tests.md'
|
||||
$testServerSwaggerPath = Join-Path $repoRoot 'node_modules' '@microsoft.azure' 'autorest.testserver' 'swagger'
|
||||
$testNames = if ($name) { $name } else { 'url', 'body-string', 'body-complex', 'custom-baseUrl', 'custom-baseUrl-more-options' }
|
||||
$testNames = if ($name) { $name } else { 'url', 'body-string', 'body-complex', 'custom-baseUrl', 'custom-baseUrl-more-options', 'header' }
|
||||
|
||||
foreach ($testName in $testNames)
|
||||
{
|
||||
$outputFolder = Join-Path $testServerTestProject $testName
|
||||
$inputFile = Join-Path $testServerSwaggerPath "$testName.json"
|
||||
$namespace = $testName.Replace('-', '_')
|
||||
Invoke-AutoRest $debugFlags $testConfiguration $outputFolder $inputFile $testName $namespace $repoRoot
|
||||
$autoRestArguments = "$debugFlags --require=$configurationPath --input-file=$inputFile --title=$testName --namespace=$namespace"
|
||||
Invoke-AutoRest $autoRestArguments $repoRoot
|
||||
}
|
||||
|
||||
# Sample configuration
|
||||
|
@ -58,5 +54,6 @@ foreach ($projectName in $projectNames)
|
|||
{
|
||||
$projectDirectory = Join-Path $sampleDirectory $projectName
|
||||
$configurationPath = Join-Path $projectDirectory 'readme.md'
|
||||
Invoke-AutoRest $debugFlags $configurationPath -repoRoot $repoRoot
|
||||
$autoRestArguments = "$debugFlags --require=$configurationPath"
|
||||
Invoke-AutoRest $autoRestArguments $repoRoot
|
||||
}
|
|
@ -6,6 +6,6 @@
|
|||
title: AppConfiguration
|
||||
require: $(this-folder)/../readme.samples.md
|
||||
# https://github.com/Azure/azure-rest-api-specs-pr/pull/887/files
|
||||
input-file: appconfiguration.json
|
||||
input-file: $(this-folder)/appconfiguration.json
|
||||
namespace: Azure.AppConfiguration
|
||||
```
|
|
@ -6,6 +6,6 @@
|
|||
title: CognitiveServices.TextAnalytics
|
||||
require: $(this-folder)/../readme.samples.md
|
||||
# https://github.com/Azure/azure-rest-api-specs/pull/7133/files
|
||||
input-file: TextAnalytics.json
|
||||
input-file: $(this-folder)/TextAnalytics.json
|
||||
namespace: Azure.CognitiveServices.TextAnalytics
|
||||
```
|
|
@ -5,6 +5,6 @@
|
|||
``` yaml
|
||||
title: KeyVault
|
||||
require: $(this-folder)/../readme.samples.md
|
||||
input-file: keyvault.json
|
||||
input-file: $(this-folder)/keyvault.json
|
||||
namespace: Azure.KeyVault
|
||||
```
|
|
@ -5,6 +5,6 @@
|
|||
``` yaml
|
||||
title: Redis
|
||||
require: $(this-folder)/../readme.samples.md
|
||||
input-file: redis.json
|
||||
input-file: $(this-folder)/redis.json
|
||||
namespace: Azure.Redis
|
||||
```
|
|
@ -5,6 +5,6 @@
|
|||
``` yaml
|
||||
title: Xkcd
|
||||
require: $(this-folder)/../readme.samples.md
|
||||
input-file: xkcd.yaml
|
||||
input-file: $(this-folder)/xkcd.yaml
|
||||
namespace: Xkcd
|
||||
```
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
``` yaml
|
||||
use: $(this-folder)/../
|
||||
output-folder: $(title)
|
||||
output-folder: $(this-folder)/$(title)/$(title)
|
||||
clear-output-folder: true
|
||||
include-csproj: true
|
||||
```
|
|
@ -13,9 +13,12 @@ namespace Azure.Core.Pipeline
|
|||
{
|
||||
private readonly DiagnosticListener? _source;
|
||||
|
||||
public bool IsActivityEnabled { get; }
|
||||
|
||||
public ClientDiagnostics(string clientNamespace, bool isActivityEnabled)
|
||||
{
|
||||
if (isActivityEnabled)
|
||||
IsActivityEnabled = isActivityEnabled;
|
||||
if (IsActivityEnabled)
|
||||
{
|
||||
_source = new DiagnosticListener(clientNamespace);
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ namespace AutoRest.CSharp.V3.CodeGen
|
|||
//TODO: Need proper logic to convert the values to strings. Right now, everything is just using default ToString().
|
||||
//TODO: Need logic to trim duplicate slashes (/) so when combined, you don't end up with multiple // together
|
||||
var urlText = String.Join(String.Empty, operation.Request.HostSegments.Select(s=> s.IsConstant ? s.Constant.Value :"{" + s.Parameter.Name + "}"));
|
||||
Line($"request.Uri.Reset(new Uri($\"{urlText}\"));");
|
||||
Line($"request.Uri.Reset(new {Type(typeof(Uri))}($\"{urlText}\"));");
|
||||
|
||||
foreach (var segment in operation.Request.PathSegments)
|
||||
{
|
||||
|
|
|
@ -17,10 +17,10 @@ namespace AutoRest.CSharp.V3.CodeGen
|
|||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<OutputPath>bin</OutputPath>
|
||||
<PublishDir>$(OutputPath)</PublishDir>
|
||||
<NoWarn>SA1649</NoWarn>
|
||||
<NoWarn>SA1649,CS8618</NoWarn>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<WarningsAsErrors />
|
||||
<Nullable>enable</Nullable>
|
||||
<Nullable>annotations</Nullable>
|
||||
<RunAnalyzersDuringBuild>true</RunAnalyzersDuringBuild>
|
||||
<RunAnalyzersDuringLiveAnalysis>false</RunAnalyzersDuringLiveAnalysis>
|
||||
</PropertyGroup>
|
||||
|
|
|
@ -56,7 +56,6 @@ namespace AutoRest.CSharp.V3.CodeGen
|
|||
foreach (var property in schema.Properties)
|
||||
{
|
||||
var initializer = NeedsInitialization(property.Type) ? $" = new {Type(_typeFactory.CreateConcreteType(property.Type))}();" : null;
|
||||
|
||||
AutoProperty("public", _typeFactory.CreateType(property.Type), property.Name, property.IsReadOnly, initializer);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ namespace AutoRest.CodeModel
|
|||
.Replace("internal readonly struct DiagnosticScope", "public readonly struct DiagnosticScope");
|
||||
File.WriteAllText($"../../{Path}/DiagnosticScope.cs", cleanFile);
|
||||
File.WriteAllText($"../../AutoRest.CSharp.V3/Azure.Core.Shared/DiagnosticScope.cs", cleanFile);
|
||||
File.WriteAllText($"../../../test/AutoRest.TestServer.Tests/Azure.Core.Shared/DiagnosticScope.cs", cleanFile);
|
||||
|
||||
cachePath = "../cache/ArrayBufferWriter.cs";
|
||||
webClient.DownloadFile(@"https://raw.githubusercontent.com/Azure/azure-sdk-for-net/master/sdk/core/Azure.Core/src/Shared/ArrayBufferWriter.cs", cachePath);
|
||||
|
@ -35,7 +34,6 @@ namespace AutoRest.CodeModel
|
|||
.Replace("internal sealed class ArrayBufferWriter", "public sealed class ArrayBufferWriter");
|
||||
File.WriteAllText($"../../{Path}/ArrayBufferWriter.cs", cleanFile);
|
||||
File.WriteAllText($"../../AutoRest.CSharp.V3/Azure.Core.Shared/ArrayBufferWriter.cs", cleanFile);
|
||||
File.WriteAllText($"../../../test/AutoRest.TestServer.Tests/Azure.Core.Shared/ArrayBufferWriter.cs", cleanFile);
|
||||
|
||||
cachePath = "../cache/ClientDiagnostics.cs";
|
||||
webClient.DownloadFile(@"https://raw.githubusercontent.com/Azure/azure-sdk-for-net/master/sdk/core/Azure.Core/src/Shared/ClientDiagnostics.cs", cachePath);
|
||||
|
@ -46,7 +44,6 @@ namespace AutoRest.CodeModel
|
|||
.Replace("options.GetType().Namespace", "options.GetType().Namespace!");
|
||||
File.WriteAllText($"../../{Path}/ClientDiagnostics.cs", cleanFile);
|
||||
File.WriteAllText($"../../AutoRest.CSharp.V3/Azure.Core.Shared/ClientDiagnostics.cs", cleanFile);
|
||||
File.WriteAllText($"../../../test/AutoRest.TestServer.Tests/Azure.Core.Shared/ClientDiagnostics.cs", cleanFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,9 +13,12 @@ namespace Azure.Core.Pipeline
|
|||
{
|
||||
private readonly DiagnosticListener? _source;
|
||||
|
||||
public bool IsActivityEnabled { get; }
|
||||
|
||||
public ClientDiagnostics(string clientNamespace, bool isActivityEnabled)
|
||||
{
|
||||
if (isActivityEnabled)
|
||||
IsActivityEnabled = isActivityEnabled;
|
||||
if (IsActivityEnabled)
|
||||
{
|
||||
_source = new DiagnosticListener(clientNamespace);
|
||||
}
|
||||
|
|
|
@ -13,9 +13,12 @@ namespace Azure.Core.Pipeline
|
|||
{
|
||||
private readonly DiagnosticListener? _source;
|
||||
|
||||
public bool IsActivityEnabled { get; }
|
||||
|
||||
public ClientDiagnostics(string clientNamespace, bool isActivityEnabled)
|
||||
{
|
||||
if (isActivityEnabled)
|
||||
IsActivityEnabled = isActivityEnabled;
|
||||
if (IsActivityEnabled)
|
||||
{
|
||||
_source = new DiagnosticListener(clientNamespace);
|
||||
}
|
||||
|
|
|
@ -16,6 +16,12 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="../../src/assets/**/*.cs"/>
|
||||
<Folder Include="Infrastructure\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="../../src/assets/**/*.cs" />
|
||||
<Compile Include="../TestServerProjects/**/*.cs" Exclude="../TestServerProjects/**/obj/**/*.cs" LinkBase="TestServerProjects" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutoRest.TestServer.Tests
|
||||
namespace AutoRest.TestServer.Tests.Infrastructure
|
||||
{
|
||||
public interface ITestServer
|
||||
{
|
|
@ -6,7 +6,7 @@ using NUnit.Framework;
|
|||
using NUnit.Framework.Interfaces;
|
||||
using NUnit.Framework.Internal;
|
||||
|
||||
namespace AutoRest.TestServer.Tests
|
||||
namespace AutoRest.TestServer.Tests.Infrastructure
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = false, Inherited = false)]
|
||||
public class IgnoreOnTestServer : NUnitAttribute, IApplyToTest
|
|
@ -3,7 +3,7 @@ using System.ComponentModel;
|
|||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace AutoRest.TestServer.Tests
|
||||
namespace AutoRest.TestServer.Tests.Infrastructure
|
||||
{
|
||||
// Uses Windows Job Objects to ensure external processes are killed if the current process is terminated non-gracefully.
|
||||
internal static class ProcessTracker
|
|
@ -1,6 +1,6 @@
|
|||
using Azure.Core;
|
||||
|
||||
namespace AutoRest.TestServer.Tests
|
||||
namespace AutoRest.TestServer.Tests.Infrastructure
|
||||
{
|
||||
public class TestOptions: ClientOptions
|
||||
{
|
|
@ -5,7 +5,7 @@ using System;
|
|||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutoRest.TestServer.Tests
|
||||
namespace AutoRest.TestServer.Tests.Infrastructure
|
||||
{
|
||||
public class TestServerSession : IAsyncDisposable
|
||||
{
|
|
@ -4,14 +4,13 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using Azure;
|
||||
using Azure.Core.Pipeline;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace AutoRest.TestServer.Tests
|
||||
namespace AutoRest.TestServer.Tests.Infrastructure
|
||||
{
|
||||
[TestFixture(TestServerVersion.V1)]
|
||||
[TestFixture(TestServerVersion.V2)]
|
|
@ -11,7 +11,7 @@ using System.Text.Json;
|
|||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutoRest.TestServer.Tests
|
||||
namespace AutoRest.TestServer.Tests.Infrastructure
|
||||
{
|
||||
public class TestServerV1 : IDisposable, ITestServer
|
||||
{
|
|
@ -3,7 +3,7 @@ using System.Net.Http;
|
|||
using System.Threading.Tasks;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace AutoRest.TestServer.Tests
|
||||
namespace AutoRest.TestServer.Tests.Infrastructure
|
||||
{
|
||||
public class TestServerV1Test
|
||||
{
|
|
@ -10,7 +10,7 @@ using System.Net.Http;
|
|||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutoRest.TestServer.Tests
|
||||
namespace AutoRest.TestServer.Tests.Infrastructure
|
||||
{
|
||||
public class TestServerV2 : IDisposable, ITestServer
|
||||
{
|
|
@ -6,7 +6,7 @@ using System.Net.Http;
|
|||
using System.Threading.Tasks;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace AutoRest.TestServer.Tests
|
||||
namespace AutoRest.TestServer.Tests.Infrastructure
|
||||
{
|
||||
public class TestServerV2Test
|
||||
{
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
namespace AutoRest.TestServer.Tests
|
||||
namespace AutoRest.TestServer.Tests.Infrastructure
|
||||
{
|
||||
public enum TestServerVersion
|
||||
{
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
using System.Threading.Tasks;
|
||||
using AutoRest.TestServer.Tests.Infrastructure;
|
||||
using body_complex;
|
||||
using body_complex.Models.V20160229;
|
||||
using NUnit.Framework;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
using System.Threading.Tasks;
|
||||
using AutoRest.TestServer.Tests.Infrastructure;
|
||||
using body_string;
|
||||
using body_string.Models.V100;
|
||||
using NUnit.Framework;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
|
||||
using System.Threading.Tasks;
|
||||
using AutoRest.TestServer.Tests.Infrastructure;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace AutoRest.TestServer.Tests
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using AutoRest.TestServer.Tests.Infrastructure;
|
||||
using header;
|
||||
using header.Models.V100;
|
||||
using NUnit.Framework;
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
# Test coverage for test-server
|
||||
### AutoRest Configuration
|
||||
> see https://aka.ms/autorest
|
||||
|
||||
``` yaml
|
||||
use: $(this-folder)/../../
|
||||
clear-output-folder: true
|
||||
include-csproj: false
|
||||
include-assets: false
|
||||
```
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
using System.Threading.Tasks;
|
||||
using AutoRest.TestServer.Tests.Infrastructure;
|
||||
using NUnit.Framework;
|
||||
using url;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Azure;
|
||||
using AutoRest.TestServer.Tests.Infrastructure;
|
||||
using NUnit.Framework;
|
||||
using url;
|
||||
using url.Models.V100;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using AutoRest.TestServer.Tests.Infrastructure;
|
||||
using NUnit.Framework;
|
||||
using url;
|
||||
using url.Models.V100;
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Compile Include="../../../src/assets/**/*.cs" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<IncludeStyleCopAnalyzers>false</IncludeStyleCopAnalyzers>
|
||||
</PropertyGroup>
|
||||
</Project>
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче