There isn’t a dedicated forum for VSCode editor support, so I am posting here hoping that any Unity staff could see and point it to the right people.
My feedback/feature request is to let the user choose what LangVersion is used in csproj file, so that VSCode C# extension could provide relevant information.
The official C# extension of VSCode is way ahead of Unity in language feature support – they already moved on to C# 9. Because of this, the latest version of C# LangVersion is now “9.0”. However, the generated C# project by Unity specifies LangVersion as “latest” and thus VSCode C# defaults the language to 9.0 and suggesting code fixes in C# 9 that Unity’s C# 8 compiler does not yet recognize. For example, pattern matching:
// Original code:
Notification notification = args.Context as Notification;
if (notification == null)
return;
// LangVersion: latest
// Code fix with C# 9 feature:
if(args.Context is not Notification notification)
return;
However, VSCode C# extension already supports different code fixes based on LangVersion. If I change manually LangVersion to “8.0” in csproj file:
<PropertyGroup>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
The code fix becomes:
// Older C# code fix:
if(!(args.Context is Notification notification))
return;
There could be other use cases for this new feature, say if someone wants to limit themselves to use a specific language version in order to maintain source compatibility with some other older Unity projects, like Asset Stores authors.