Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consume generator as a package #15133

Merged
7 commits merged into from
Sep 14, 2020
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
17 changes: 2 additions & 15 deletions eng/CodeGeneration.targets
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This target file goes away when the last user of TemporaryUsePreviousGeneratorVersion is gone.

<_AutoRestVersion>https://github.com/Azure/autorest/releases/download/autorest-3.0.6236/autorest-3.0.6236.tgz</_AutoRestVersion>
<_AutoRestCoreVersion>3.0.6306</_AutoRestCoreVersion>
<_AutoRestCSharpVersion>https://github.com/Azure/autorest.csharp/releases/download/3.0.0-dev.20200911.1/autorest-csharp-v3-3.0.0-dev.20200911.1.tgz</_AutoRestCSharpVersion>
<_AutoRestCSharpVersion>https://github.com/Azure/autorest.csharp/releases/download/3.0.0-dev.20200811.1/autorest-csharp-v3-3.0.0-dev.20200811.1.tgz</_AutoRestCSharpVersion>
<_SupportsCodeGeneration Condition="'$(IsClientLibrary)' == 'true'">true</_SupportsCodeGeneration>
<_DefaultInputName Condition="Exists('$(MSBuildProjectDirectory)/autorest.md')">$(MSBuildProjectDirectory)/autorest.md</_DefaultInputName>
<AutoRestInput Condition="'$(AutoRestInput)' == ''">$(_DefaultInputName)</AutoRestInput>
Expand All @@ -12,16 +12,11 @@
use the following command line (remove the space between minus minus): dotnet msbuild /t:GenerateCode /p:AutoRestAdditionalParameters="- -interactive"
-->
<AutoRestAdditionalParameters></AutoRestAdditionalParameters>
<_SharedCodeDirectory>$(MSBuildThisFileDirectory)../sdk/core/Azure.Core/src/Shared/</_SharedCodeDirectory>
<_AutoRestSharedCodeDirectory>$(_SharedCodeDirectory)AutoRest/</_AutoRestSharedCodeDirectory>

<_GenerateCode Condition="'$(_SupportsCodeGeneration)' == 'true' AND '$(AutoRestInput)' != ''">true</_GenerateCode>
</PropertyGroup>

<PropertyGroup>
<_AutoRestVersion Condition="'$(TemporaryUsePreviousGeneratorVersion)' == 'true'">https://github.com/Azure/autorest/releases/download/autorest-3.0.6236/autorest-3.0.6236.tgz</_AutoRestVersion>
<_AutoRestCoreVersion Condition="'$(TemporaryUsePreviousGeneratorVersion)' == 'true'">3.0.6306</_AutoRestCoreVersion>
<_AutoRestCSharpVersion Condition="'$(TemporaryUsePreviousGeneratorVersion)' == 'true'">https://github.com/Azure/autorest.csharp/releases/download/3.0.0-dev.20200811.1/autorest-csharp-v3-3.0.0-dev.20200811.1.tgz</_AutoRestCSharpVersion>
</PropertyGroup>

<Target Name="GenerateCode" Condition="'$(_GenerateCode)' == 'true'" >
Expand All @@ -38,17 +33,9 @@
<Error Text="Following GitHub URLs do not contain commit hash: @(GithubUrlsWithoutHash) please use permalinks for code generation inputs (see https://help.github.com/en/github/managing-files-in-a-repository/getting-permanent-links-to-files) " Condition="'@(GithubUrlsWithoutHash)' != ''" />

<RemoveDir Directories="$(MSBuildProjectDirectory)/Generated"/>
<Exec Command="npx autorest@$(_AutoRestVersion) --version=$(_AutoRestCoreVersion) $(AutoRestInput) $(AutoRestAdditionalParameters) --use=$(_AutoRestCSharpVersion) --output-folder=$(MSBuildProjectDirectory) --title=$(RootNamespace) --namespace=$(RootNamespace) --shared-source-folder=$(_SharedCodeDirectory)" />
<Exec Command="npx autorest@$(_AutoRestVersion) --version=$(_AutoRestCoreVersion) $(AutoRestInput) $(AutoRestAdditionalParameters) --use=$(_AutoRestCSharpVersion) --output-folder=$(MSBuildProjectDirectory) --title=$(RootNamespace) --namespace=$(RootNamespace) --shared-source-folder=$(AutoRestSharedCodeDirectory).." />
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reuse shared sources from the package.

</Target>

<PropertyGroup Condition="'$(_GenerateCode)' == 'true'">
<NoWarn>$(NoWarn);CA1812</NoWarn>
</PropertyGroup>

<ItemGroup Condition="'$(_GenerateCode)' == 'true'">
<Compile Include="$(_AutoRestSharedCodeDirectory)/**/*.cs" Link="Shared/AutoRest/%(RecursiveDir)/%(Filename)%(Extension)" />
</ItemGroup>

</Project>


Expand Down
8 changes: 8 additions & 0 deletions eng/Directory.Build.Data.props
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,12 @@
<!-- Disable doc comments for test projects -->
<DocumentationFile></DocumentationFile>
</PropertyGroup>

<!-- Code generation settings -->
<PropertyGroup>
<!-- Don't use code generator bundled Azure.Core shared source for code generation -->
<AzureCoreSharedCodeDirectory>$(AzureCoreSharedSources)</AzureCoreSharedCodeDirectory>
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure I understand this? If the shared sources in the nuget package match the generator why wouldn't we always use those?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Generator nuget package carries 2 kinds of shared sources:

  1. Generator specific sources
  2. Parts of Azure.Core shared that we sync from azure-sdk-for-net to autorest.csharp and are required for generated libraries.

We always use the former from the package but considering this repo has the original versions of Azure.Core shared files we doing used them from the package.

<!-- Don't use code generator bundled Azure.Core shared source when building, projects in this repo include individual sources when needed -->
<IncludeAzureCoreSharedCode>false</IncludeAzureCoreSharedCode>
</PropertyGroup>
</Project>
6 changes: 4 additions & 2 deletions eng/Directory.Build.Data.targets
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" PrivateAssets="all" IsImplicitlyDefined="true" />
</ItemGroup>

<!-- Add Client SDK Analyzers -->
<!-- Add Client SDK Tools -->
<ItemGroup>
<PackageReference Condition="'$(IsClientLibrary)' == 'true'" Include="AutoRest.CSharp.V3" PrivateAssets="All" />

<PackageReference Condition="'$(GenerateAPIListing)' == 'true'" Include="Microsoft.DotNet.GenAPI" PrivateAssets="All" />

<PackageReference Condition="'$(EnableClientSdkAnalyzers)' == 'true'" Include="Azure.ClientSdk.Analyzers" PrivateAssets="All" />
Expand Down Expand Up @@ -103,7 +105,7 @@

<Import Project="ApiListing.targets" />

<Import Project="CodeGeneration.targets" />
<Import Project="CodeGeneration.targets" Condition="'$(TemporaryUsePreviousGeneratorVersion)' == 'true'" />

<Import Project="TestFramework.targets" Condition="'$(IsTestProject)' == 'true'"/>

Expand Down
1 change: 1 addition & 0 deletions eng/Packages.Data.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<ItemGroup>
<PackageReference Update="ApprovalTests" Version="3.0.22" />
<PackageReference Update="ApprovalUtilities" Version="3.0.22" />
<PackageReference Update="AutoRest.CSharp.V3" Version="1.0.0-alpha.20200914.3" />
<PackageReference Update="Azure.AI.FormRecognizer" Version="3.0.0" />
<PackageReference Update="Azure.AI.TextAnalytics" Version="5.0.0" />
<PackageReference Update="Azure.Data.AppConfiguration" Version="1.0.0" />
Expand Down
2 changes: 1 addition & 1 deletion eng/scripts/CodeChecks.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ try {

Write-Host "Re-generating clients"
Invoke-Block {
& dotnet msbuild $PSScriptRoot\..\service.proj /t:GenerateCode /p:ServiceDirectory=$ServiceDirectory
& dotnet msbuild $PSScriptRoot\..\service.proj /restore /t:GenerateCode /p:ServiceDirectory=$ServiceDirectory

# https://github.com/Azure/azure-sdk-for-net/issues/8584
# & $repoRoot\storage\generate.ps1
Expand Down
Loading