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

[CSharp] Problems with code creation #7218

Closed
karussell opened this issue Dec 19, 2017 · 10 comments
Closed

[CSharp] Problems with code creation #7218

karussell opened this issue Dec 19, 2017 · 10 comments

Comments

@karussell
Copy link
Contributor

karussell commented Dec 19, 2017

Description

I have no windows here and so I tried to build the c# version of our client library under Ubuntu 16.04, but this fails with:

[INFO] Target framework: net45
[INFO] Download nuget and packages
File ‘nuget.exe’ already there; not retrieving.

Mozilla Roots Importer - version 5.4.1.6
Download and import trusted root certificates from Mozilla's MXR.
Copyright 2002, 2003 Motus Technologies. Copyright 2004-2008 Novell. BSD licensed.

WARNING: mozroots is deprecated, please move to cert-sync instead.

Downloading from 'https://hg.mozilla.org/releases/mozilla-release/raw-file/default/security/nss/lib/ckfw/builtins/certdata.txt'...
Importing certificates into user store...
1 new root certificates were added to your trust store.
Import process completed.

[INFO] Copy DLLs to the 'bin' folder
[INFO] Run 'mcs' to build bin/IO.Swagger.dll
warning CS8001: SDK path could not be resolved
src/IO.Swagger/Model/ResponseCoordinatesArray.cs(30,58): error CS0305: Using the generic type `System.Collections.Generic.List<T>' requires `1' type argument(s)
/usr/lib/mono/4.5/mscorlib.dll (Location of the symbol related to previous error)
src/IO.Swagger/Api/GeocodingApi.cs(128,29): error CS0104: `Configuration' is an ambiguous reference between `IO.Swagger.Client.Configuration' and `IO.Swagger.Model.Configuration'
src/IO.Swagger/Client/Configuration.cs(23,18): (Location of the symbol related to previous error)
src/IO.Swagger/Model/Configuration.cs(30,26): (Location of the symbol related to previous error)
src/IO.Swagger/Api/GeocodingApi.cs(167,16): error CS0104: `Configuration' is an ambiguous reference between `IO.Swagger.Client.Configuration' and `IO.Swagger.Model.Configuration'
src/IO.Swagger/Client/Configuration.cs(23,18): (Location of the symbol related to previous error)
src/IO.Swagger/Model/Configuration.cs(30,26): (Location of the symbol related to previous error)
src/IO.Swagger/Api/GeocodingApi.cs(167,16): error CS0104: `Configuration' is an ambiguous reference between `IO.Swagger.Client.Configuration' and `IO.Swagger.Model.Configuration'
src/IO.Swagger/Client/Configuration.cs(23,18): (Location of the symbol related to previous error)
src/IO.Swagger/Model/Configuration.cs(30,26): (Location of the symbol related to previous error)
src/IO.Swagger/Api/GeocodingApi.cs(167,16): error CS0104: `Configuration' is an ambiguous reference between `IO.Swagger.Client.Configuration' and `IO.Swagger.Model.Configuration'
src/IO.Swagger/Client/Configuration.cs(23,18): (Location of the symbol related to previous error)
src/IO.Swagger/Model/Configuration.cs(30,26): (Location of the symbol related to previous error)
src/IO.Swagger/Api/IsochroneApi.cs(128,29): error CS0104: `Configuration' is an ambiguous reference between `IO.Swagger.Client.Configuration' and `IO.Swagger.Model.Configuration'
src/IO.Swagger/Client/Configuration.cs(23,18): (Location of the symbol related to previous error)
src/IO.Swagger/Model/Configuration.cs(30,26): (Location of the symbol related to previous error)
src/IO.Swagger/Api/IsochroneApi.cs(167,16): error CS0104: `Configuration' is an ambiguous reference between `IO.Swagger.Client.Configuration' and `IO.Swagger.Model.Configuration'
src/IO.Swagger/Client/Configuration.cs(23,18): (Location of the symbol related to previous error)
src/IO.Swagger/Model/Configuration.cs(30,26): (Location of the symbol related to previous error)
src/IO.Swagger/Api/IsochroneApi.cs(167,16): error CS0104: `Configuration' is an ambiguous reference between `IO.Swagger.Client.Configuration' and `IO.Swagger.Model.Configuration'
src/IO.Swagger/Client/Configuration.cs(23,18): (Location of the symbol related to previous error)
src/IO.Swagger/Model/Configuration.cs(30,26): (Location of the symbol related to previous error)
src/IO.Swagger/Api/IsochroneApi.cs(167,16): error CS0104: `Configuration' is an ambiguous reference between `IO.Swagger.Client.Configuration' and `IO.Swagger.Model.Configuration'
src/IO.Swagger/Client/Configuration.cs(23,18): (Location of the symbol related to previous error)
src/IO.Swagger/Model/Configuration.cs(30,26): (Location of the symbol related to previous error)
src/IO.Swagger/Api/MatrixApi.cs(170,26): error CS0104: `Configuration' is an ambiguous reference between `IO.Swagger.Client.Configuration' and `IO.Swagger.Model.Configuration'
src/IO.Swagger/Client/Configuration.cs(23,18): (Location of the symbol related to previous error)
src/IO.Swagger/Model/Configuration.cs(30,26): (Location of the symbol related to previous error)
src/IO.Swagger/Api/MatrixApi.cs(209,16): error CS0104: `Configuration' is an ambiguous reference between `IO.Swagger.Client.Configuration' and `IO.Swagger.Model.Configuration'
src/IO.Swagger/Client/Configuration.cs(23,18): (Location of the symbol related to previous error)
src/IO.Swagger/Model/Configuration.cs(30,26): (Location of the symbol related to previous error)
src/IO.Swagger/Api/MatrixApi.cs(209,16): error CS0104: `Configuration' is an ambiguous reference between `IO.Swagger.Client.Configuration' and `IO.Swagger.Model.Configuration'
src/IO.Swagger/Client/Configuration.cs(23,18): (Location of the symbol related to previous error)
src/IO.Swagger/Model/Configuration.cs(30,26): (Location of the symbol related to previous error)
src/IO.Swagger/Api/MatrixApi.cs(209,16): error CS0104: `Configuration' is an ambiguous reference between `IO.Swagger.Client.Configuration' and `IO.Swagger.Model.Configuration'
src/IO.Swagger/Client/Configuration.cs(23,18): (Location of the symbol related to previous error)
src/IO.Swagger/Model/Configuration.cs(30,26): (Location of the symbol related to previous error)
src/IO.Swagger/Api/RoutingApi.cs(184,27): error CS0104: `Configuration' is an ambiguous reference between `IO.Swagger.Client.Configuration' and `IO.Swagger.Model.Configuration'
src/IO.Swagger/Client/Configuration.cs(23,18): (Location of the symbol related to previous error)
src/IO.Swagger/Model/Configuration.cs(30,26): (Location of the symbol related to previous error)
src/IO.Swagger/Api/RoutingApi.cs(223,16): error CS0104: `Configuration' is an ambiguous reference between `IO.Swagger.Client.Configuration' and `IO.Swagger.Model.Configuration'
src/IO.Swagger/Client/Configuration.cs(23,18): (Location of the symbol related to previous error)
src/IO.Swagger/Model/Configuration.cs(30,26): (Location of the symbol related to previous error)
src/IO.Swagger/Api/RoutingApi.cs(223,16): error CS0104: `Configuration' is an ambiguous reference between `IO.Swagger.Client.Configuration' and `IO.Swagger.Model.Configuration'
src/IO.Swagger/Client/Configuration.cs(23,18): (Location of the symbol related to previous error)
src/IO.Swagger/Model/Configuration.cs(30,26): (Location of the symbol related to previous error)
src/IO.Swagger/Api/RoutingApi.cs(223,16): error CS0104: `Configuration' is an ambiguous reference between `IO.Swagger.Client.Configuration' and `IO.Swagger.Model.Configuration'
src/IO.Swagger/Client/Configuration.cs(23,18): (Location of the symbol related to previous error)
src/IO.Swagger/Model/Configuration.cs(30,26): (Location of the symbol related to previous error)
src/IO.Swagger/Api/SolutionApi.cs(108,28): error CS0104: `Configuration' is an ambiguous reference between `IO.Swagger.Client.Configuration' and `IO.Swagger.Model.Configuration'
src/IO.Swagger/Client/Configuration.cs(23,18): (Location of the symbol related to previous error)
src/IO.Swagger/Model/Configuration.cs(30,26): (Location of the symbol related to previous error)
src/IO.Swagger/Api/SolutionApi.cs(147,16): error CS0104: `Configuration' is an ambiguous reference between `IO.Swagger.Client.Configuration' and `IO.Swagger.Model.Configuration'
src/IO.Swagger/Client/Configuration.cs(23,18): (Location of the symbol related to previous error)
src/IO.Swagger/Model/Configuration.cs(30,26): (Location of the symbol related to previous error)
src/IO.Swagger/Api/SolutionApi.cs(147,16): error CS0104: `Configuration' is an ambiguous reference between `IO.Swagger.Client.Configuration' and `IO.Swagger.Model.Configuration'
src/IO.Swagger/Client/Configuration.cs(23,18): (Location of the symbol related to previous error)
src/IO.Swagger/Model/Configuration.cs(30,26): (Location of the symbol related to previous error)
src/IO.Swagger/Api/SolutionApi.cs(147,16): error CS0104: `Configuration' is an ambiguous reference between `IO.Swagger.Client.Configuration' and `IO.Swagger.Model.Configuration'
src/IO.Swagger/Client/Configuration.cs(23,18): (Location of the symbol related to previous error)
src/IO.Swagger/Model/Configuration.cs(30,26): (Location of the symbol related to previous error)
src/IO.Swagger/Api/VrpApi.cs(108,23): error CS0104: `Configuration' is an ambiguous reference between `IO.Swagger.Client.Configuration' and `IO.Swagger.Model.Configuration'
src/IO.Swagger/Client/Configuration.cs(23,18): (Location of the symbol related to previous error)
src/IO.Swagger/Model/Configuration.cs(30,26): (Location of the symbol related to previous error)
src/IO.Swagger/Api/VrpApi.cs(147,16): error CS0104: `Configuration' is an ambiguous reference between `IO.Swagger.Client.Configuration' and `IO.Swagger.Model.Configuration'
src/IO.Swagger/Client/Configuration.cs(23,18): (Location of the symbol related to previous error)
src/IO.Swagger/Model/Configuration.cs(30,26): (Location of the symbol related to previous error)
src/IO.Swagger/Api/VrpApi.cs(147,16): error CS0104: `Configuration' is an ambiguous reference between `IO.Swagger.Client.Configuration' and `IO.Swagger.Model.Configuration'
src/IO.Swagger/Client/Configuration.cs(23,18): (Location of the symbol related to previous error)
src/IO.Swagger/Model/Configuration.cs(30,26): (Location of the symbol related to previous error)
src/IO.Swagger/Api/VrpApi.cs(147,16): error CS0104: `Configuration' is an ambiguous reference between `IO.Swagger.Client.Configuration' and `IO.Swagger.Model.Configuration'
src/IO.Swagger/Client/Configuration.cs(23,18): (Location of the symbol related to previous error)
src/IO.Swagger/Model/Configuration.cs(30,26): (Location of the symbol related to previous error)
src/IO.Swagger/Model/ResponseCoordinatesArray.cs(56,28): warning CS0109: The member `IO.Swagger.Model.ResponseCoordinatesArray.ToJson()' does not hide an inherited member. The new keyword is not required
src/IO.Swagger/Model/ResponseInstructions.cs(56,28): warning CS0109: The member `IO.Swagger.Model.ResponseInstructions.ToJson()' does not hide an inherited member. The new keyword is not required
Compilation failed: 25 error(s), 3 warnings
[ERROR] Compilation failed with exit code 0

BTW: Changing the sdk option to just 4.5 removes also the warning "warning CS8001: SDK path could not be resolved". So I do not think that is the root cause.
BTW2: the same problems seems to persist with C# 5 under windows as someone else reported to me in a personal email.

Swagger-codegen version

2.2.3 or master from 14 Nov

Swagger declaration file content or url

https://github.com/graphhopper/directions-api-clients/blob/master/swagger.json

Command line used for generation

java -jar swagger.jar generate -i swagger.json -l csharp --artifact-version 0.10-SNAPSHOT --git-repo-id directions-api-client --git-user-id graphhopper --api-package directions-api-client -o csharp"

Steps to reproduce

install mono on Ubuntu 16.04 via

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb http://download.mono-project.com/repo/ubuntu xenial main" | sudo tee /etc/apt/sources.list.d/mono-official.list
sudo apt-get update
sudo apt install mono-complete

then do

git clone https://github.com/graphhopper/directions-api-clients
cd  directions-api-clients/csharp
bash build.sh
Related issues/PRs

Nothing found

Suggest a fix/enhancement

No idea

@jimschubert
Copy link
Contributor

@karussell Have you built your client against Swagger Codegen before?

I have a fix for the configuration issues, which should unblock most of the errors you're receiving.

It looks like your model:

    "ResponseCoordinatesArray": {
      "type": "array",
      "description": "An array containing coordinates",
      "items": {
        "type": "array",
        "items": {
          "type": "number",
          "format": "double"
        }
}

As an array of an array of doubles isn't currently supported, so I'd have to look into this since it appears that it may be supported elsewhere.

There's another issue #7358 for the last error in your trace regarding ToJson not being and override member because the base isn't marked virtual.

I don't have Mono installed locally because I've just gotten a new machine, and it's taking a while to download. I'll go ahead and open the PR with the fix for Configuration. The issue is that the property in the API template isn't prefix with this..

@jimschubert
Copy link
Contributor

I opened #7394 to address the issue with the Configuration ambiguity. Built locally and generated with:

java -jar ./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
  -i https://raw.githubusercontent.com/graphhopper/directions-api-clients/master/swagger.json \
  -l csharp \
  --artifact-version 0.10-SNAPSHOT \
  --api-package Directions.Api.Client \
  -o .bak/csharp

Should result in two remaining compilation issues of #7358 (toJson) and missing support for nested arrays.

@karussell
Copy link
Contributor Author

karussell commented Jan 13, 2018

Thanks, will try your suggestions!

@karussell Have you built your client against Swagger Codegen before?

Other clients, yes. But C# not.

@jimschubert
Copy link
Contributor

@karussell are there any other statically typed languages you're generating that support the array[array[double]]? I'd like to reuse existing code, if possible.

Also, I've opened #7399 to address the compilation issue of ToJson's virtual modifier.

@karussell
Copy link
Contributor Author

Thanks!

@karussell are there any other statically typed languages you're generating that support the array[array[double]]? I'd like to reuse existing code, if possible.

Yes, Java. And it compiles :)

@jimschubert
Copy link
Contributor

Ah. Looks like the Java client specifically relies on type erasure:

public class ResponseCoordinatesArray extends ArrayList<List> {

I'll look into applying the generics for nested schemas of array types for C#, although any fix may only be partially functional for API input types as it would most likely complicate initializations.

@jimschubert
Copy link
Contributor

@karussell I've opened #7400 to address the compilation issues you've experienced with the C# generator. That PR includes the fixes from the other two, to make it easier for you to evaluate.

@karussell
Copy link
Contributor Author

Cool, thanks!

@karussell
Copy link
Contributor Author

I can confirm that I can compile the project - thanks a bunch @jimschubert ! Also the test seem to run through:

$ bash ./mono_nunit_test.sh
...
Tests run: 237, Errors: 0, Failures: 0, Inconclusive: 0, Time: 0.2101916 seconds
Not run: 0, Invalid: 0, Ignored: 0, Skipped: 0

@karussell
Copy link
Contributor Author

PR was merged into master

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

No branches or pull requests

2 participants