Skip to content

Commit 23cd85a

Browse files
committed
Fix lang service reporting C# 7.3 errors in Error List
By setting LangVersion so late in msbuild evaluation, the `CommandLineArgsForDesignTimeEvaluation` property is set based on the default value (of 7.3, for .NET Framework projects). This causes the VS language service to initialize with the wrong language version. I originally moved this property definition to the .targets because `$(Language)` isn't set in time for the .props files to use them. But we can move it back to .props by using the project file extension instead.
1 parent 2fb29d7 commit 23cd85a

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

Directory.Build.props

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@
4040
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
4141
</PropertyGroup>
4242

43+
<PropertyGroup>
44+
<LangVersion Condition="'$(MSBuildProjectExtension)'=='.csproj'">13</LangVersion>
45+
<LangVersion Condition="'$(MSBuildProjectExtension)'=='.vbproj'">16.9</LangVersion>
46+
</PropertyGroup>
47+
4348
<ItemGroup>
4449
<AdditionalFiles Include="$(MSBuildThisFileDirectory)stylecop.json" Link="stylecop.json" />
4550
</ItemGroup>

Directory.Build.targets

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project>
3-
<PropertyGroup>
4-
<LangVersion Condition="'$(Language)'=='C#'">13</LangVersion>
5-
<LangVersion Condition="'$(Language)'=='VB'">16.9</LangVersion>
6-
</PropertyGroup>
73
<ItemGroup>
84
<!-- Avoid compile error about missing namespace when combining ImplicitUsings with .NET Framework target frameworks. -->
95
<Using Remove="System.Net.Http" Condition="'$(TargetFrameworkIdentifier)'=='.NETFramework'" />

0 commit comments

Comments
 (0)