roslyn: Unexpected CS8614

Version Used: Microsoft ® Visual C# Compiler version 3.2.0-beta4-19359-03 (15b43b33) Microsoft.NetCore.App.Ref version 3.0.0-preview8-27912-07 Visual Studio Dev 16.2.0 Preview 4

Steps to Reproduce:

using System.Collections;
using System.Collections.ObjectModel;

namespace cs8614repro
{
    class ListClass1 : Collection<int>, IList
    {
    }
}

The problem only seems to reproduce when TargetFramework==netcoreapp3.0.

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <!-- netcoreapp2.2, netstandard2.1 build without any warnings; netcoreapp3.0 will generate CS8614 --> 
    <TargetFrameworks>netcoreapp3.0;netcoreapp2.2;netstandard2.1</TargetFrameworks>
  </PropertyGroup>
</Project>

Expected Behavior:

Builds without errors

Actual Behavior:

ListClass1.cs(6,41): warning CS8614: Nullability of reference types in type of parameter 'index' of 'void Collection<int>.RemoveAt(int index)' doesn't match implicitly implemented member 'void IList.RemoveAt(int index)'. [c:\src\projects\cs8614repro\cs8614repro\cs8614repro.csproj]

PS: As soon as this change hits our build servers, I believe this will likely break dotnet/wpf builds here: dotnet/wpf:SortDescriptionCollection.cs#L138

/cc @dotnet/wpf-developers

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 16 (15 by maintainers)

Most upvoted comments

@vatsan-madhavan Setting an explicit language version (<LangVersion>7.3</LangVersion>) should act as a workaround.