swagger-api / swagger-api/swagger-codegen

[csharp] Rework version selection

Open
#5,527 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Client: C-Sharp Enhancement: General
Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

PR #4955 added support for .NET Standard 1.3 as targetFramework=v5.0. This version refers to the PCL Version. This is unintuitive for a number of reasons. First, dnx core 5.0 was a version of .NET Core which coincided with .NET Framework 4.5.1. Second, the targetFramework is meant to refer to .NET Standard 1.3, which supports more than just the latest and greatest. Lastly (for me, at least), there's no clear indication that .NET Framework won't have an actual future version of 5.0.

Swagger-codegen version

current master

Swagger declaration file content or url
Command line used for generation
Steps to reproduce
Related issues
Suggest a Fix

I like the suggestion @Gronsak made in his PR. Referring to the .NET Standard table:

Might I suggest reworking how the target framework is selected by adding a level of abstraction?

Instead of setting the target framework property directly a better option may be to have a property for choosing what kind of project you would like to output and a separete one for choosing the VS version targeted.
I would suggest going with the same alias as Microsoft defines here: .NET Standard Library

Platform Name Alias
.NET Standard netstandard 1.0 1.1 1.2 1.3 1.4 1.5 1.6 2.0
.NET Core netcoreapp 1.0 2.0
.NET Framework net 4.5 4.5.1 4.6 4.6.1 4.6.2 vNext 4.6.1
Mono/Xamarin Platforms vNext
Universal Windows Platform uap 10.0 vNext
Windows win 8.0 8.1
Windows Phone wpa 8.1
Windows Phone Silverlight wp 8.0

That would mean that to generate what is now defined as targetFramework: v3.5 you would instead input net3.5 and to make a net standard 1.3 project you would put in netstandard1.3.
You could then put in all the right values in targetFramework and targetFrameworkNuget for the targeted version of the project file.

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 reviewing PR #4955 and the current C# generator handling of targetFramework and targetFrameworkNuget. Compare the requested aliases, including netstandard1.3 and net3.5, with the generated project values. Done means project type and Visual Studio target selection are separate and the generated framework values match the requested platform.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.