OpenAPITools / OpenAPITools/openapi-generator

[BUG][csharp-netcore] Outputs unexpected warning "Invalid .NET framework version, defaulting to v4.6.1"

Open
#3,686 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
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:

  1. 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
  1. 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.

  2. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.