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

PowerShell build error due to variable naming #767

Closed
wwendyc opened this issue Apr 16, 2021 · 5 comments
Closed

PowerShell build error due to variable naming #767

wwendyc opened this issue Apr 16, 2021 · 5 comments
Labels

Comments

@wwendyc
Copy link

wwendyc commented Apr 16, 2021

After AutoRest generation based on my team’s Swagger spec, the below build error occurs when running build-module.ps1

D:\a\1\s\src\ProviderHub\generated\api\Models\Api20201120\ProviderRegistrationPropertiesProviderHubMetadata.cs(6,9): error CS0535: 'ProviderRegistrationPropertiesProviderHubMetadata' does not implement interface member 'IProviderHubMetadata.ThirdPartyProviderAuthorizationAuthorizations' [D:\a\1\s\src\ProviderHub\Az.ProviderHub.csproj]
D:\a\1\s\src\ProviderHub\generated\api\Models\Api20201120\ProviderRegistrationPropertiesProviderHubMetadata.cs(7,9): error CS0738: 'ProviderRegistrationPropertiesProviderHubMetadata' does not implement interface member 'IProviderHubMetadataInternal.ThirdPartyProviderAuthorization'. 'ProviderRegistrationPropertiesProviderHubMetadata.ThirdPartyProviderAuthorization' cannot implement 'IProviderHubMetadataInternal.ThirdPartyProviderAuthorization' because it does not have the matching return type of 'IThirdPartyProviderAuthorization'. [D:\a\1\s\src\ProviderHub\Az.ProviderHub.csproj]
D:\a\1\s\src\ProviderHub\generated\api\Models\Api20201120\ProviderRegistrationPropertiesProviderHubMetadata.cs(7,9): error CS0535: 'ProviderRegistrationPropertiesProviderHubMetadata' does not implement interface member 'IProviderHubMetadataInternal.ThirdPartyProviderAuthorizationAuthorizations' [D:\a\1\s\src\ProviderHub\Az.ProviderHub.csproj]

Here is the link to the specific property in our Swagger:
https://github.com/Azure/azure-rest-api-specs/blob/master/specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/providerhub.json#L3629
We have another property called “providerAuthorizations” and I noticed that if I change this field from “authorizations” to something other than authorization/providerAuthorizations there is no error during the build.

@dolauli dolauli added the bug label May 14, 2021
@dolauli
Copy link
Contributor

dolauli commented May 25, 2023

The issue should have been fixed in autorest.powershell v4.

@soroshsabz
Copy link

@dolauli Where is v4?

I write a normal script like below

npm install -g "autorest"
autorest configuration.yaml

and autorest use version 3 like below

PS D:\Source\Repos\Resa\IpTables.Api\Source\BSN.IpTables.Cli> .\Generate-PowerShellClient.ps1

changed 1 package in 252ms
AutoRest code generation utility [cli version: 3.6.3; node: v18.15.0]
(C) 2018 Microsoft Corporation.
https://aka.ms/autorest
info    |    Loading AutoRest core      'C:\Users\sooro\.autorest\@[email protected]\nodemodules\@autorest\core\dist' (3.9.7)
info    | 
The default version of @autorest/powershell has been bumped from 2.1+ to 3.0+.
 > If you still want to use 2.1+ version, please specify it with --use:@autorest/[email protected].{x}, e.g 2.1.401.

info    |    Loading AutoRest extension '@autorest/powershell' (~3.0.0->3.0.505)
info    |    Loading AutoRest extension '@autorest/modelerfour' (4.15.414->4.15.414)
verbose | [1.53 s] Reading OpenAPI 3.0 file file:///D:/Source/Repos/Resa/IpTables.Api/Source/BSN.IpTables.Api/swagger.json
warning | PreCheck/CheckDuplicateSchemas | Checking for duplicate schemas, this could take a (long) while.  Run with --verbose for more detail.
verbose | [1.74 s]   ModelerFour/api-version-mode:client
verbose | [1.74 s]   ModelerFour/api-version-parameter:constant
verbose | [1.74 s]   ModelerFour/use-model-namespace:false
info    | Autorest completed in 2.46s. 206 files generated.

@soroshsabz
Copy link

related to BSVN/IpTables.Api#22

@soroshsabz
Copy link

I try to specify version be below code (as I learn from Azure/autorest#2976)

use:
  - '@autorest/[email protected]'

But I got below errors

The default version of @autorest/powershell has been bumped from 2.1+ to 3.0+.
 > If you still want to use 2.1+ version, please specify it with --use:@autorest/[email protected].{x}, e.g 2.1.401.

error   |   Error: Unable to resolve package '@autorest/[email protected]'.
error   | Autorest completed with an error. If you think the error message is unclear, or is a bug, please declare an issues at https://github.com/Azure/autorest/issues with the error message you are seeing.
fatal   | Failed to install extension '@autorest/powershell' (4.0.0)

@soroshsabz
Copy link

I found some workaround about that, with specific version in configuraiton.yaml as you can see in #1246 , But Did you know exist any better approach to using versoin 4.x?

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants