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

Issues such as IDE0090: ‘new’ expression can be simplified are inappropriately raised because C# 9 isn’t yet supported by Unity.

Thanks :slight_smile:

2 Likes

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?

Yes. In your .csproj files (which Unity regenerates every now and then), look for
latest 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.

1 Like

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 .

2 Likes

Preferences -> External Tools -> "Regenerate project files"

This also works for me in 2020.3.14f1.