forked from Particular/docs.particular.net
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ProjectLangVersion.cs
35 lines (30 loc) · 1.27 KB
/
ProjectLangVersion.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System.Xml.Linq;
using System.Xml.XPath;
using NUnit.Framework;
namespace IntegrityTests
{
public class ProjectLangVersion
{
[Test]
public void ShouldUseLangVersionLatest()
{
// Also reflected in https://docs.particular.net/samples/#technology-choices-c-language-level
// And in /tools/projectStandards.linq
new TestRunner("*.csproj", "SDK-style project files (VS2017+) must specify LangVersion=7.3 - Provides the best balance between users between samples for netcoreapp3.1 and samples built by the user likely without LangVersion element.")
.IgnoreSnippets()
.Run(projectFilePath =>
{
var xdoc = XDocument.Load(projectFilePath);
// Ignore non-Sdk (VS2015 and previous) style projects
var sdk = xdoc.Root.Attribute("Sdk");
if (sdk == null)
{
return true;
}
var firstTargetFrameworksElement = xdoc.XPathSelectElement("/Project/PropertyGroup/LangVersion");
var value = firstTargetFrameworksElement?.Value;
return value == "7.3";
});
}
}
}