Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug Control of LangVersion in generated .Player.csproj files

Discussion in 'Editor & General Support' started by cellarmation, Mar 9, 2021.

  1. cellarmation


    Jan 17, 2015
    I am having some issues with Unity3D's support for generating multiple .csproj files for the same code. I am generating a .csproj file for editing my code as it runs in the editor (Assembly-CSharp.csproj) and for how it runs in the player of the exported UWP target platform (Assembly-CSharp.Player.csproj). This is using the options under "Preferences" > "External Tools" > "Generate .csproj files for:". This is a really useful feature!

    The generated csproj files include the supported C# language version via the tag <LangVersion>. This appears to be different in the main csproj file and the Player csproj file. The main csproj is set to "latest" and the Player is set to "6". I believe the version in the Player specific csproj file is wrong as I am able to successfully use C# 7 features both in the editor and in the external player.

    The version number being wrong does not seem to cause any obvious issues with Visual Studio or Unity3D directly, but it can confuse additional static analysis plugins in Visual Studio that check your code against the stated language version (such as Resharper). It would be nice if the player project could report the correct version, or if there is some workaround.

    I am using Unity 2019.4.13f1 with Visual Studio 2017 15.9.9
    ichiyaman, WarpedPixel and omg_peter like this.