Skip to content

[csharp] Differentiate between target framework and target framework version #7029

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

Open
jimschubert opened this issue Nov 22, 2017 · 0 comments

Comments

@jimschubert
Copy link
Contributor

Description

C# client supports .NET Standard 1.3 under the misnomer of v5.0. We don't yet support .NET Standard 2.0, although it should be a minor upgrade by the IDE to import our generated projects.

v5.0 refers to the PCL version, which is a different project file structure (I hope to fix this issue in the next week or two by separating PCL, netstandard, and .net framework into separate options). This should allow us to clearly differentiate between the TargetFramework and TargetFrameworkVersion mixture we currently have.

For reference, you can create two library projects in Visual Studio, one .NET Standard 1.3 and one "Portable Library" modified from the default 4.0 to 5.0. Project structures differ like this:

$ diff netstandard_1.3/netstandard_1.3/netstandard_1.3.csproj pcl_5.0/pcl_5.0/pcl_5.0.csproj
1,2c1,2
< <Project Sdk="Microsoft.NET.Sdk">
<
---
> <?xml version="1.0" encoding="utf-8"?>
> <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
4c4,11
<     <TargetFramework>netstandard1.3</TargetFramework>
---
>     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
>     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
>     <ProjectGuid>{435A49DB-F692-4835-BEEF-6473AF3075DB}</ProjectGuid>
>     <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
>     <OutputType>Library</OutputType>
>     <RootNamespace>pcl_5</RootNamespace>
>     <AssemblyName>pcl_5.0</AssemblyName>
>     <TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
6,7c13,33
<
< </Project>
---
>   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
>     <DebugSymbols>true</DebugSymbols>
>     <DebugType>full</DebugType>
>     <Optimize>false</Optimize>
>     <OutputPath>bin\Debug</OutputPath>
>     <DefineConstants>DEBUG;</DefineConstants>
>     <ErrorReport>prompt</ErrorReport>
>     <WarningLevel>4</WarningLevel>
>   </PropertyGroup>
>   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
>     <Optimize>true</Optimize>
>     <OutputPath>bin\Release</OutputPath>
>     <ErrorReport>prompt</ErrorReport>
>     <WarningLevel>4</WarningLevel>
>   </PropertyGroup>
>   <ItemGroup>
>     <Compile Include="MyClass.cs" />
>     <Compile Include="Properties\AssemblyInfo.cs" />
>   </ItemGroup>
>   <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
> </Project>
\ No newline at end of file

Project files also have different structures, so even our PCL 5.0 generated code currently would require users to manually adjust the project to be truly PCL 5.0 (right now, it's just a .NET Framework library). I think at a minimum, we need to conditionally include the portable msbuild targets and the ProjectTypeGuids option.

.NET Standard 2.0 was just announced back in August. I'd need to evaluate changes for this addition.

Swagger-codegen version

all

Swagger declaration file content or url
Command line used for generation

config-help -l csharp

Steps to reproduce

n\a (enhancement)

Related issues/PRs
Suggest a fix/enhancement

Related to #5527

My suggestion for this work is to differentiate clearly between .NET Framework, netstandard, and PCL versioning.

This may be easiest if we move to support something similar to a library option (e.g. framework). This would allow us to specify framework=dotnet and frameworkVersion=3.5 or framework=netstandard and frameworkVersion=1.3 rather than targetFramework=v3.5 or targetFramework=v5.0.

I don't know that there's that much difference between any of these, so I'm open to suggestions.

It may also be beneficial to sunset support for .net 3.5 and possibly .net 4.0 into separate projects to improve maintainability of the C# client generator.

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

No branches or pull requests

2 participants