OpenAPITools / OpenAPITools/openapi-generator
[BUG][csharp-netcore] Outputs unexpected warning "Invalid .NET framework version, defaulting to v4.6.1"
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- What's the version of OpenAPI Generator used?
- Have you search for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Bounty to sponsor the fix (example)
Description
When generating a client using the csharp-netcore generator with a targetFramework of netcoreapp2.0, there is the following warning output to the console:
[main] WARN o.o.c.languages.CSharpClientCodegen - Invalid .NET framework version, defaulting to v4.6.1
[main] INFO o.o.c.languages.CSharpClientCodegen - Generating code for .NET Framework v4.6.1
This seems unexpected for a few reasons:
- v4.6.1 is not one of the valid target frameworks listed in the documentation when running the command openapi-generator config-help -g csharp-netcore (although it is listed as the default, which is confusing):
targetFramework
The target .NET framework version. (Default: v4.6.1)
netstandard1.3 - .NET Standard 1.3 compatible
netstandard1.4 - .NET Standard 1.4 compatible
netstandard1.5 - .NET Standard 1.5 compatible
netstandard1.6 - .NET Standard 1.6 compatible
netstandard2.0 - .NET Standard 2.0 compatible
netcoreapp2.0 - .NET Core 2.0 compatible
-
The generate command sets targetFramework=netcoreapp2.0, which is listed as a valid value in the documentation, so it isn't clear why this warning is saying the framework version is invalid.
-
The warning indicates the logger was for the class "o.o.c.languages.CSharpClientCodegen", but the csharp-netcore generator is defined in the CSharpNetCoreClientCodegen class. I think this class is not setting up its logger correctly.
openapi-generator version
4.1.0
OpenAPI declaration file content or url
I used the test yaml here: https://github.com/OpenAPITools/openapi-generator/blob/v4.1.0/modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
Command line used for generation
openapi-generator generate -g csharp-netcore -i ./petstore-with-fake-endpoints-models-for-testing.yaml --additional-properties targetFramework=netcoreapp2.0 -o ./netcoreapp2.0
Steps to reproduce
Run the command line above and look at the console output.
Related issues/PRs
https://github.com/OpenAPITools/openapi-generator/issues/3682
Suggest a fix
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by inspecting CSharpClientCodegen and CSharpNetCoreClientCodegen, then reproduce the issue with the documented config-help command and the provided csharp-netcore generation command. Trace targetFramework validation, the default value, and logger setup; done means netcoreapp2.0 is accepted without the unexpected warning and the logger identifies the appropriate generator.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100