Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Bug Don't report <LangVersion>latest</LangVersion> because it triggers some analyzers

Discussion in '2021.1 Beta' started by aybe, Nov 11, 2020.

  1. aybe

    aybe

    Joined:
    Feb 20, 2019
    Posts:
    55
    Issues such as IDE0090: 'new' expression can be simplified are inappropriately raised because C# 9 isn't yet supported by Unity.

    Thanks :)
     
    morhun_EP and escape_artist like this.
  2. Stakk3r

    Stakk3r

    Joined:
    Mar 10, 2020
    Posts:
    1
    Still having this problem with 2021... very annoying to see those problem markers all around my code! Is there a way to manually fix the LangVersion?
     
  3. WarpedPixel

    WarpedPixel

    Joined:
    Jun 21, 2020
    Posts:
    3
    Yes. In your .csproj files (which Unity regenerates every now and then), look for
    <LangVersion>latest</LangVersion> and replace latest by 8.0. Arguably a Unity bug since it doesn't actually support the latest C# available. This is annoying because it will be stomped on anytime the csproj is regenerated. You could write an Editor script that fixes this automatically.
     
    mbchapman likes this.
  4. chemicalcrux

    chemicalcrux

    Joined:
    Mar 16, 2017
    Posts:
    720
    I have run into this problem in 2020.3.13f1 as well. Strangely, if I manually regenerate the csproj files from the Preferences -> External Tools menu, it writes 8.0 into <LangVersion>.
     
    Oneiros90 and mbchapman like this.
  5. mbchapman

    mbchapman

    Joined:
    May 31, 2021
    Posts:
    6
    Preferences -> External Tools -> "Regenerate project files"


    This also works for me in 2020.3.14f1.