-
Notifications
You must be signed in to change notification settings - Fork 407
Closed
Labels
LegacyIssues against the legacy project system.Issues against the legacy project system.
Description
Visual Studio Version: 16.3.1 and 16.4p1
<Nullable>enable</Nullable> is not getting picked up by old-style csprojs. Everything works if we have to put #nullable enable in every file, but that's distasteful. Is there another workaround
We can't move to SDK-style csproj until #4938 ships in 16.4 in November.
Command-line builds show that NRT is enabled and producing the expected warnings, but the IDE is adamant that nothing is in a nullable context.
Full repro for 16.3.1 and 16.4p1:
public class C
{
// CS8632 The annotation for nullable reference types should only be used in code within a
// '#nullable' annotations context.
// ↓
public void M(string? nullableParameter)
{
}
}Old-style csproj from new project template but with LangVersion 8.0 and Nullable enable:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>0098472d-d4d6-4ea1-9a6b-142942f81782</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OldStyleCsproj</RootNamespace>
<AssemblyName>OldStyleCsproj</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<LangVersion>8.0</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System"/>
<Reference Include="System.Core"/>
<Reference Include="System.Xml.Linq"/>
<Reference Include="System.Data.DataSetExtensions"/>
<Reference Include="Microsoft.CSharp"/>
<Reference Include="System.Data"/>
<Reference Include="System.Net.Http"/>
<Reference Include="System.Xml"/>
</ItemGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>User Impact:
Have to choose between not using NRTs in these projects or adding #nullable enable to every source file.
SemiNormal, HarinezumiSama and RudeySH
Metadata
Metadata
Assignees
Labels
LegacyIssues against the legacy project system.Issues against the legacy project system.