question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

.NET 6 Preview 7 breaks builds that set $(LangVersion) 8.0

See original GitHub issue

Using 6.0.100-preview.7.21369.5, you can do:

dotnet new console
dotnet build -p:LangVersion=8.0 -bl

This fails with:

C:\src\globalusing\Program.cs(2,1): error CS8400: Feature 'top-level statements' is not available in C# 8.0. Please use language version 9.0 or greater. [C:\src\globalusing\globalusing.csproj]
C:\src\globalusing\obj\Debug\net6.0\globalusing.ImplicitNamespaceImports.cs(2,1): error CS8400: Feature 'global using directive' is not available in C# 8.0. Please use language version 10.0 or greater. [C:\src\globalusing\globalusing.csproj]
C:\src\globalusing\obj\Debug\net6.0\globalusing.ImplicitNamespaceImports.cs(3,1): error CS8400: Feature 'global using directive' is not available in C# 8.0. Please use language version 10.0 or greater. [C:\src\globalusing\globalusing.csproj]
C:\src\globalusing\obj\Debug\net6.0\globalusing.ImplicitNamespaceImports.cs(4,1): error CS8400: Feature 'global using directive' is not available in C# 8.0. Please use language version 10.0 or greater. [C:\src\globalusing\globalusing.csproj]
C:\src\globalusing\obj\Debug\net6.0\globalusing.ImplicitNamespaceImports.cs(5,1): error CS8400: Feature 'global using directive' is not available in C# 8.0. Please use language version 10.0 or greater. [C:\src\globalusing\globalusing.csproj]
C:\src\globalusing\obj\Debug\net6.0\globalusing.ImplicitNamespaceImports.cs(6,1): error CS8400: Feature 'global using directive' is not available in C# 8.0. Please use language version 10.0 or greater. [C:\src\globalusing\globalusing.csproj]
C:\src\globalusing\obj\Debug\net6.0\globalusing.ImplicitNamespaceImports.cs(7,1): error CS8400: Feature 'global using directive' is not available in C# 8.0. Please use language version 10.0 or greater. [C:\src\globalusing\globalusing.csproj]
C:\src\globalusing\obj\Debug\net6.0\globalusing.ImplicitNamespaceImports.cs(8,1): error CS8400: Feature 'global using directive' is not available in C# 8.0. Please use language version 10.0 or greater. [C:\src\globalusing\globalusing.csproj]

Binlog: msbuild.zip

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:11 (9 by maintainers)

github_iconTop GitHub Comments

3reactions
jaredparcommented, Jul 21, 2021

My thoughts here are that the customer has willingly downgraded one aspect of the project here (the language version). It is reasonable that they may need to downgrade other parts of the project here to compensate (implicit global usings)

Our general focus is that we default all of our experiences, including language version, based on the selected target framework. It’s a very simple model for us to all follow. Particularly because all of our experiences have on “off” switch. That means the default experience is as vibrant as we want and customers have the knobs to disable experiences they don’t want or aren’t compatible with other knobs.

1reaction
jonathanpepperscommented, Aug 11, 2021

I think we can close this in favor of https://github.com/dotnet/sdk/issues/19521, this feature is being redesigned.

The idea is you will have to opt into it with ImplicitUsings=true, so we wouldn’t have hit an issue if that was the case.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Announcing .NET 8 Preview 7
NET 8 Preview 7 is now available. We're already at the final preview release for .NET 8 and will now shift to release...
Read more >
C# language versioning - C# Guide
The value preview uses the latest available preview C# language version that your compiler supports. Configure multiple projects. To configure ...
Read more >
How to change C# Language Version for all of the projects ...
To set a version for all your project at once, you can create a file named Directory.Build.props (case-sensitive on Linux) at the root...
Read more >
VS 2019 for Mac Preview 2: Error CS1617: Invalid option ' ...
NET Core 3.0 ASP.NET project I'm getting the following build error. Error CS1617: Invalid option '8.0' for /langversion. Use '/langversion:?' to list supported ......
Read more >
What's New in .NET 7? Discover ALL .NET 7 Features
Explore the exciting new features of .NET 7, designed to deliver faster and more efficient performance with greater reliability.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found