Background
I have created a Directory.Build.props
in my root repo folder with the following contents:
<Project>
<PropertyGroup>
<LangVersion>7.3</LangVersion>
</PropertyGroup>
</Project>
I need to prevent the usage of C# 8 syntax within our codebase, since it is targeting .Net 4.7.2
The above file sets the LangVersion
property for each project within the solution.
The problem
Our codebase is big. Many projects within one single solution with many programmers working in differents and / or adding new ones, this is not a problem itself but rather the fact that any programmer can override the LangVersion
within their own .csproj
file.
I know we can stop those changes in the code review phase or by sending reminders every hour to all the programmers telling them not to use C# 8 for this specific project. But I was wondering if I could just celebrate their boldness by giving them a nice and handsome compiler error.
Maybe with a custom code analizer with Roslyn? Is there any way?