Azure / autorest.csharp

Extension for AutoRest (https://github.com/Azure/autorest) that generates C# code
MIT License
142 stars 166 forks source link

output-folder in YAML file does not respected for CSharp #1146

Open kant2002 opened 3 years ago

kant2002 commented 3 years ago

Describe the bug

Given YAML file there

```yaml
input-file: Project.Api/obj/Project.Api.json
csharp:
  output-folder: Project.Api.Client/Generated
  namespace: Project.Api.Client
  use-datetimeoffset: true

typescript:
  output-folder : public/app/services/api
  enum-types: true

when run generation either autorest or autorest --csharp with autorest 3.1.4 CSharp files created in the generated folder. What is more strange, if I run autorest --typescript it produce output for TypeScript (in configure location) and CSharp (in generated folder).

 autorest --typescript

WARNING: AutoRest has not been tested with Node versions greater than v14.

AutoRest code generation utility [cli version: 3.1.4; node: v15.7.0, max-memory: 4096 MB]
(C) 2018 Microsoft Corporation.
https://aka.ms/autorest
NOTE: AutoRest core version selected from configuration: ~3.1.0.
   Loading AutoRest core      'C:\Users\user\.autorest\@autorest_core@3.1.3\node_modules\@autorest\core\dist' (3.1.3)
INFORMATION: > Loading AutoRest extension '@autorest/csharp' (latest->3.0.0-beta.20210409.1)
INFORMATION: > Loading AutoRest extension '@autorest/typescript' (latest->6.0.0-alpha.20210309.1)
INFORMATION: > Loading AutoRest extension '@autorest/modelerfour' (4.17.2->4.17.2)

WARNING (PreCheck/SchemaMissingType): The schema 'FacilityAreaRequest-area' with an undefined type and 'allOf'/'anyOf'/'oneOf' is a bit ambigious. This has been auto-corrected to 'type:object'       

WARNING (PreCheck/SchemaMissingType): The schema 'FacilityInformation-area' with an undefined type and 'allOf'/'anyOf'/'oneOf' is a bit ambigious. This has been auto-corrected to 'type:object'       

WARNING (PreCheck/SchemaMissingType): The schema 'LocationInformation-area' with an undefined type and 'allOf'/'anyOf'/'oneOf' is a bit ambigious. This has been auto-corrected to 'type:object'       

WARNING (PreCheck/CheckDuplicateSchemas): Checking for duplicate schemas, this could take a (long) while.  Run with --verbose for more detail.

WARNING (Modeler/MissingType): The schema 'components·1pahbfj·schemas·problemdetails·additionalproperties' has no type or format information whatsoever. Location:
   Project.Api/obj/Project.Api.json#/components/schemas/components·1pahbfj·schemas·problemdetails·additionalproperties
WARNING: output-folder path should be an absolute path
INFORMATION: Autorest.Typescript took 25920ms
[39.73 s] Generation Complete

Expected behavior I would like to output-folder setting to be respected.

timotheeguerin commented 3 years ago

Can you confirm here that if you replace the key with csharpgen then it generate in the correct place? WIll have to use --csharp or csharp:true

kant2002 commented 3 years ago

Confirm that autorest --csharp and using csharpgen instead of csharp place files in proper location.

timotheeguerin commented 3 years ago

Sweet okay, so then this is a probllem with the @autorest/csharp extension configuration. Will transfer there.

The issue is the plugin name is csharpgen instead of csharp so it doesn't load the nested config.

Solution:

kant2002 commented 3 years ago

When you say workaroud for Python, do you mean change in that place and around? https://github.com/Azure/autorest.python/pull/897/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5R63

Just curious.

timotheeguerin commented 3 years ago

Yes exactly

kant2002 commented 3 years ago

Whole Autorest looks a lot like large ETL for source code AST. Hard to understand what exactly going on, until you see whole picture.

Can I try make PR for this fix? I may abandon that, but I really want to understand what's going on. That improve my survivability level near AutoRest.

chamons commented 3 years ago

@kant2002 - PRs are always welcome, autorest and autorest.csharp are open source project.

chamons commented 3 years ago

Not sure this is fixable without renaming the plugin @timotheeguerin ?

timotheeguerin commented 3 years ago

@chamons, it should be, you can do the same "workaround" as I made for the python plugin https://github.com/Azure/autorest.python/pull/897

Just basically need to add a no op plugin called csharp before your other plugins