Skip to content

Updating program to .NET 6 Preview 7 SDK causes warnings about interpolated string handlers in previously working code #55345

@jkoritzinsky

Description

@jkoritzinsky

Version Used: 4.0.0-3.21376.22 (SDK version 6.0.100-preview.7.21377.7)

Steps to Reproduce:

Write the following program with any SDK prior to the .NET 6 Preview 7 SDK (using any 3.x.x Roslyn version):

<Project>
	<PropertyGroup>
		<OutputType>Exe</OutputType>
		<LangVersion>8.0</LangVersion> <!-- Can be anything less than 10.0 and not Preview -->
	</PropertyGroup>
</Project>
using System;
using System.Text;

StringBuilder builder = new();
builder.Append($"Hello World, {args.Length}");
Console.WriteLine(builder);

Rationale for having the LangVersion element: It was initially for ensuring that new language features could be used in dotnet/runtime and dotnet/runtimelab early, but the line was never removed after C# 8.0 was released.

This builds correctly in Preview 6.

Expected Behavior:

This builds in Preview 7 using the same method overloads as Preview 6, or a diagnostic with more information to know exactly what changed with the upgrade.

Alternatively, a breaking change notice could be posted in partnership with the .NET Libraries team.

Actual Behavior:

This fails to build in Preview 7, with the following diagnostic since Roslyn picks the new overload that uses the new 'interpolated string handlers' feature:

error CS8400: Feature 'interpolated string handlers' is not available in C# 8.0. Please use language version 10.0 or greater.

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions