Skip to content

Commit 9671ea4

Browse files
authored
AutoRest version update (Azure#11621)
* Updated version. Removing shared files and then copying them again to fix folder name casing. * Re-added shared files with fixed folder name. * Regeneration after version update. * Copied wrong version of the file. * Update generator version and add string request fix. * Fix path folder casing. * Fix casing. * More casing. * Last of casing. Now, it is fixed for the repo.
1 parent 7cbe9dc commit 9671ea4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+190
-104
lines changed

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ input-file:
260260
require: https://github.com/Azure/azure-rest-api-specs/blob/49fc16354df7211f8392c56884a3437138317d1f/specification/azsadmin/resource-manager/storage/readme.md
261261
```
262262
263-
3. Run `dotnet msbuild /t:GenerateCode` in src directory of the project (e.g. `net\sdk\storage\Azure.Management.Storage\src`). This would run Autorest and generate the code. (NOTE: this step requires Node 13).
263+
3. Run `dotnet msbuild /t:GenerateCode` in src directory of the project (e.g. `net\sdk\storage\Azure.Management.Storage\src`). This would run AutoRest and generate the code. (NOTE: this step requires Node 13).
264264
4. For management plan libraries add `azure-arm: true` setting to `autorest.md` client constructors and options would be auto-generated. For data-plane libraries follow the next two steps.
265265
4. Add a `*ClientOptions` type that inherits from `ClientOptions` and has a service version enum:
266266

eng/CodeGeneration.targets

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
<Project>
22

33
<PropertyGroup>
4-
<_AutoRestVersion>https://github.com/Azure/autorest/releases/download/autorest-3.0.6221/autorest-3.0.6221.tgz</_AutoRestVersion>
5-
<_AutoRestCoreVersion>3.0.6280</_AutoRestCoreVersion>
6-
<_AutoRestCSharpVersion>https://github.com/Azure/autorest.csharp/releases/download/3.0.0-dev.20200415.7/autorest-csharp-v3-3.0.0-dev.20200415.7.tgz</_AutoRestCSharpVersion>
4+
<_AutoRestVersion>https://github.com/Azure/autorest/releases/download/autorest-3.0.6222/autorest-3.0.6222.tgz</_AutoRestVersion>
5+
<_AutoRestCoreVersion>3.0.6282</_AutoRestCoreVersion>
6+
<_AutoRestCSharpVersion>https://github.com/Azure/autorest.csharp/releases/download/3.0.0-dev.20200427.3/autorest-csharp-v3-3.0.0-dev.20200427.3.tgz</_AutoRestCSharpVersion>
77
<_SupportsCodeGeneration Condition="'$(IsClientLibrary)' == 'true'">true</_SupportsCodeGeneration>
88
<_DefaultInputName Condition="Exists('$(MSBuildProjectDirectory)/autorest.md')">$(MSBuildProjectDirectory)/autorest.md</_DefaultInputName>
9-
<AutorestInput Condition="'$(AutorestInput)' == ''">$(_DefaultInputName)</AutorestInput>
9+
<AutoRestInput Condition="'$(AutoRestInput)' == ''">$(_DefaultInputName)</AutoRestInput>
1010
<!--
1111
Allows passing additional AutoRest command line arguments, for example to run in interactive mode
12-
use the following command line (remove the space between minus minus): dotnet msbuild /t:GenerateCode /p:AutorestAdditionalParameters="- -interactive"
12+
use the following command line (remove the space between minus minus): dotnet msbuild /t:GenerateCode /p:AutoRestAdditionalParameters="- -interactive"
1313
-->
14-
<AutorestAdditionalParameters></AutorestAdditionalParameters>
14+
<AutoRestAdditionalParameters></AutoRestAdditionalParameters>
1515
<_SharedCodeDirectory>$(MSBuildThisFileDirectory)../sdk/core/Azure.Core/src/Shared/</_SharedCodeDirectory>
16-
<_AutoRestSharedCodeDirectory>$(_SharedCodeDirectory)Autorest/</_AutoRestSharedCodeDirectory>
16+
<_AutoRestSharedCodeDirectory>$(_SharedCodeDirectory)AutoRest/</_AutoRestSharedCodeDirectory>
1717

18-
<_GenerateCode Condition="'$(_SupportsCodeGeneration)' == 'true' AND '$(AutorestInput)' != ''">true</_GenerateCode>
18+
<_GenerateCode Condition="'$(_SupportsCodeGeneration)' == 'true' AND '$(AutoRestInput)' != ''">true</_GenerateCode>
1919
<UsesJsonSerialization Condition="'$(UsesJsonSerialization)' == ''">true</UsesJsonSerialization>
2020
</PropertyGroup>
2121

2222
<Target Name="GenerateCode" Condition="'$(_GenerateCode)' == 'true'" >
2323
<RemoveDir Directories="$(MSBuildProjectDirectory)/Generated"/>
24-
<Exec Command="npx autorest@$(_AutoRestVersion) --version=$(_AutoRestCoreVersion) $(AutorestInput) $(AutorestAdditionalParameters) --use=$(_AutoRestCSharpVersion) --output-folder=$(MSBuildProjectDirectory) --title=$(RootNamespace) --namespace=$(RootNamespace) --shared-source-folder=$(_SharedCodeDirectory) --verbose" />
24+
<Exec Command="npx autorest@$(_AutoRestVersion) --version=$(_AutoRestCoreVersion) $(AutoRestInput) $(AutoRestAdditionalParameters) --use=$(_AutoRestCSharpVersion) --output-folder=$(MSBuildProjectDirectory) --title=$(RootNamespace) --namespace=$(RootNamespace) --shared-source-folder=$(_SharedCodeDirectory) --verbose" />
2525
</Target>
2626

2727
<ItemGroup Condition="'$(_GenerateCode)' == 'true'">
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
#nullable enable
5+
6+
using System;
7+
using System.Globalization;
8+
9+
namespace Azure.Core
10+
{
11+
internal class RawRequestUriBuilder: RequestUriBuilder
12+
{
13+
private const string SchemeSeparator = "://";
14+
private const char HostSeparator = '/';
15+
private const char PortSeparator = ':';
16+
private static readonly char[] HostOrPort = { HostSeparator, PortSeparator };
17+
private const char QueryBeginSeparator = '?';
18+
private const char QueryContinueSeparator = '&';
19+
private const char QueryValueSeparator = '=';
20+
21+
private RawWritingPosition _position = RawWritingPosition.Scheme;
22+
23+
private static (string Name, string Value) GetQueryParts(string queryUnparsed)
24+
{
25+
int separatorIndex = queryUnparsed.IndexOf(QueryValueSeparator);
26+
if (separatorIndex == -1)
27+
{
28+
return (queryUnparsed, string.Empty);
29+
}
30+
return (queryUnparsed.Substring(0, separatorIndex), queryUnparsed.Substring(separatorIndex + 1));
31+
}
32+
33+
public void AppendRaw(string value, bool escape)
34+
{
35+
while (!string.IsNullOrWhiteSpace(value))
36+
{
37+
if (_position == RawWritingPosition.Scheme)
38+
{
39+
int separator = value.IndexOf(SchemeSeparator, StringComparison.InvariantCultureIgnoreCase);
40+
if (separator == -1)
41+
{
42+
Scheme += value;
43+
value = string.Empty;
44+
}
45+
else
46+
{
47+
Scheme += value.Substring(0, separator);
48+
// TODO: Find a better way to map schemes to default ports
49+
Port = string.Equals(Scheme, "https", StringComparison.OrdinalIgnoreCase) ? 443 : 80;
50+
value = value.Substring(separator + SchemeSeparator.Length);
51+
_position = RawWritingPosition.Host;
52+
}
53+
}
54+
else if (_position == RawWritingPosition.Host)
55+
{
56+
int separator = value.IndexOfAny(HostOrPort);
57+
if (separator == -1)
58+
{
59+
if (string.IsNullOrEmpty(Path))
60+
{
61+
Host += value;
62+
value = string.Empty;
63+
}
64+
else
65+
{
66+
// All Host information must be written before Path information
67+
// If Path already has information, we transition to writing Path
68+
_position = RawWritingPosition.Path;
69+
}
70+
}
71+
else
72+
{
73+
Host += value.Substring(0, separator);
74+
_position = value[separator] == HostSeparator ? RawWritingPosition.Path : RawWritingPosition.Port;
75+
value = value.Substring(separator + 1);
76+
}
77+
}
78+
else if (_position == RawWritingPosition.Port)
79+
{
80+
int separator = value.IndexOf(HostSeparator);
81+
if (separator == -1)
82+
{
83+
Port = int.Parse(value, CultureInfo.InvariantCulture);
84+
value = string.Empty;
85+
}
86+
else
87+
{
88+
Port = int.Parse(value.Substring(0, separator), CultureInfo.InvariantCulture);
89+
value = value.Substring(separator + 1);
90+
}
91+
// Port cannot be split (like Host), so always transition to Path when Port is parsed
92+
_position = RawWritingPosition.Path;
93+
}
94+
else if (_position == RawWritingPosition.Path)
95+
{
96+
int separator = value.IndexOf(QueryBeginSeparator);
97+
if (separator == -1)
98+
{
99+
AppendPath(value, escape);
100+
value = string.Empty;
101+
}
102+
else
103+
{
104+
AppendPath(value.Substring(0, separator), escape);
105+
value = value.Substring(separator + 1);
106+
_position = RawWritingPosition.Query;
107+
}
108+
}
109+
else if (_position == RawWritingPosition.Query)
110+
{
111+
int separator = value.IndexOf(QueryContinueSeparator);
112+
if (separator == 0)
113+
{
114+
value = value.Substring(1);
115+
}
116+
else if (separator == -1)
117+
{
118+
(string queryName, string queryValue) = GetQueryParts(value);
119+
AppendQuery(queryName, queryValue, escape);
120+
value = string.Empty;
121+
}
122+
else
123+
{
124+
(string queryName, string queryValue) = GetQueryParts(value.Substring(0, separator));
125+
AppendQuery(queryName, queryValue, escape);
126+
value = value.Substring(separator + 1);
127+
}
128+
}
129+
}
130+
}
131+
132+
private enum RawWritingPosition
133+
{
134+
Scheme,
135+
Host,
136+
Port,
137+
Path,
138+
Query
139+
}
140+
141+
public void AppendRawNextLink(string nextLink, bool escape)
142+
{
143+
// If it is an absolute link, we use the nextLink as the entire url
144+
if (nextLink.StartsWith(Uri.UriSchemeHttp, StringComparison.InvariantCultureIgnoreCase))
145+
{
146+
Reset(new Uri(nextLink));
147+
return;
148+
}
149+
150+
AppendPath(nextLink, escape);
151+
}
152+
}
153+
}

sdk/core/Azure.Core/src/Shared/Autorest/RequestHeaderExtensions.cs sdk/core/Azure.Core/src/Shared/AutoRest/RequestHeaderExtensions.cs

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#nullable enable
55

66
using System;
7+
using System.Collections.Generic;
78
using System.Globalization;
89

910
namespace Azure.Core
@@ -49,5 +50,10 @@ public static void Add(this RequestHeaders headers, string name, byte[] value)
4950
{
5051
headers.Add(name, Convert.ToBase64String(value));
5152
}
53+
54+
public static void AddDelimited<T>(this RequestHeaders headers, string name, IEnumerable<T> value, string delimiter)
55+
{
56+
headers.Add(name, string.Join(delimiter, value));
57+
}
5258
}
5359
}

sdk/core/Azure.Core/src/Shared/Autorest/RequestUriBuilderExtensions.cs sdk/core/Azure.Core/src/Shared/AutoRest/RequestUriBuilderExtensions.cs

+5
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ public static void AppendQuery(this RequestUriBuilder builder, string name, byte
9797
builder.AppendQuery(name, Convert.ToBase64String(value), escape);
9898
}
9999

100+
public static void AppendQuery(this RequestUriBuilder builder, string name, Guid value, bool escape = true)
101+
{
102+
builder.AppendQuery(name, value.ToString(), escape);
103+
}
104+
100105
public static void AppendQueryDelimited<T>(this RequestUriBuilder builder, string name, IEnumerable<T> value, string delimiter, bool escape = true)
101106
{
102107
builder.AppendQuery(name, string.Join(delimiter, value), escape);

sdk/core/Azure.Core/src/Shared/Autorest/RawRequestUriBuilder.cs

-91
This file was deleted.

sdk/formrecognizer/Azure.AI.FormRecognizer/src/Generated/Operations/ServiceClient.cs

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/formrecognizer/Azure.AI.FormRecognizer/src/Generated/Operations/ServiceRestClient.cs

+3-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/search/Azure.Search.Documents/src/Generated/Operations/DataSourcesClient.cs

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/search/Azure.Search.Documents/src/Generated/Operations/DocumentsClient.cs

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/search/Azure.Search.Documents/src/Generated/Operations/IndexersClient.cs

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/search/Azure.Search.Documents/src/Generated/Operations/IndexesClient.cs

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/search/Azure.Search.Documents/src/Generated/Operations/ServiceClient.cs

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/search/Azure.Search.Documents/src/Generated/Operations/SkillsetsClient.cs

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/search/Azure.Search.Documents/src/Generated/Operations/SynonymMapsClient.cs

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)