Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions eng/CodeGeneration.targets
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<Project>

<PropertyGroup>
<_AutoRestVersion>https://github.com/Azure/autorest/releases/download/autorest-3.0.6207/autorest-3.0.6207.tgz</_AutoRestVersion>
<_AutoRestCoreVersion>3.0.6257</_AutoRestCoreVersion>
<_AutoRestCSharpVersion>https://github.com/Azure/autorest.csharp/releases/download/3.0.0-dev.20200402.6/autorest-csharp-v3-3.0.0-dev.20200402.6.tgz</_AutoRestCSharpVersion>
<_AutoRestVersion>https://github.com/Azure/autorest/releases/download/autorest-3.0.6221/autorest-3.0.6221.tgz</_AutoRestVersion>
<_AutoRestCoreVersion>3.0.6280</_AutoRestCoreVersion>
<_AutoRestCSharpVersion>https://github.com/Azure/autorest.csharp/releases/download/3.0.0-dev.20200414.2/autorest-csharp-v3-3.0.0-dev.20200414.2.tgz</_AutoRestCSharpVersion>
<_SupportsCodeGeneration Condition="'$(IsClientLibrary)' == 'true'">true</_SupportsCodeGeneration>
<_DefaultInputName Condition="Exists('$(MSBuildProjectDirectory)/autorest.md')">$(MSBuildProjectDirectory)/autorest.md</_DefaultInputName>
<AutorestInput Condition="'$(AutorestInput)' == ''">$(_DefaultInputName)</AutorestInput>
<AutorestConfiguration Condition="'$(AutorestConfiguration)' == '' AND '$(AutorestInput)' != '$(_DefaultInputName)'">$(_DefaultInputName)</AutorestConfiguration>
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need this feature. Autorest now supports including remote config into a local one.

<!--
Allows passing additional AutoRest command line arguments, for example to run in interactive mode
use the following command line (remove the space between minus minus): dotnet msbuild /t:GenerateCode /p:AutorestAdditionalParameters="- -interactive"
Expand All @@ -21,11 +20,8 @@
</PropertyGroup>

<Target Name="GenerateCode" Condition="'$(_GenerateCode)' == 'true'" >
<PropertyGroup>
<_RequireConfigurationArgument Condition="'$(AutorestConfiguration)' != ''">--require=$(AutorestConfiguration)</_RequireConfigurationArgument>
</PropertyGroup>
<RemoveDir Directories="$(MSBuildProjectDirectory)/Generated"/>
<Exec Command="npx autorest@$(_AutoRestVersion) --version=$(_AutoRestCoreVersion) $(AutorestInput) $(_RequireConfigurationArgument) $(AutorestAdditionalParameters) --use=$(_AutoRestCSharpVersion) --output-folder=$(MSBuildProjectDirectory) --title=$(RootNamespace) --namespace=$(RootNamespace) --shared-source-folder=$(_SharedCodeDirectory) --verbose" />
<Exec Command="npx autorest@$(_AutoRestVersion) --version=$(_AutoRestCoreVersion) $(AutorestInput) $(AutorestAdditionalParameters) --use=$(_AutoRestCSharpVersion) --output-folder=$(MSBuildProjectDirectory) --title=$(RootNamespace) --namespace=$(RootNamespace) --shared-source-folder=$(_SharedCodeDirectory) --verbose" />
</Target>

<ItemGroup Condition="'$(_GenerateCode)' == 'true'">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

#nullable enable

using System;

namespace Azure.Core
{
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
internal class CodeGenMemberAttribute : Attribute
{
public string OriginalName { get; }
public string? OriginalName { get; }

/// <summary>
/// For collection properties. When set to true empty collection would be treated as undefined and not serialized.
/// </summary>
public bool EmptyAsUndefined { get; set; }

/// <summary>
/// For collection and model properties. Whether the property would always be initialized on creation/deserialization.
/// Requires a parameterless constructor for implementation type.
/// </summary>
public bool Initialize { get; set; }

public CodeGenMemberAttribute()
{
}

public CodeGenMemberAttribute(string originalName)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Azure.Core
{
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct)]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct, AllowMultiple = true)]
internal class CodeGenSuppressAttribute : Attribute
{
public string Member { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ internal static class JsonElementExtensions
public static TimeSpan GetTimeSpan(in this JsonElement element, string format) => format switch
{
"P" => XmlConvert.ToTimeSpan(element.GetString()),
"T" => TimeSpan.ParseExact(element.GetString(), "T", CultureInfo.InvariantCulture),
_ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format))
};

Expand Down
Original file line number Diff line number Diff line change
@@ -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"));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not a big deal since they usually get canonicalized, but did you mean for two "//" here toward the end of the URI?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, actually @schaabs told me to do it :)

Copy link
Copy Markdown

@schaabs schaabs Apr 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not technically a URI it's a scope string, which has to be exact. Since the resource string registered with AAD, "https://management.azure.com/", ends in a "/" the default scope has the two "//", "https://management.azure.com//.default". It's unfortunate because it's inconsistent between services, and is dependent on how the resource was registered with AAD. For instance the resource for key vault is "https://vaults.azure.net" doesn't end in a "/" so its default scope, "https://vaults.azure.net/.default" does not have the double slashes.

}
}
}
1 change: 1 addition & 0 deletions sdk/core/Azure.Core/src/Shared/Autorest/TypeFormatters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ internal class TypeFormatters
public static string ToString(TimeSpan value, string format) => format switch
{
"P" => XmlConvert.ToString(value),
"T" => value.ToString("T", CultureInfo.InvariantCulture),
_ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format))
};

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading