-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.NET 6 Preview 7 breaks builds that set $(LangVersion) 8.0 #19050
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
The bigger issue here is the global using:
Ignore the top-level statement error:
I think we shouldn't add to |
Context: dotnet/sdk#19050 xamarin-android is hitting this build error with .NET 6 Preview 7: C:\src\xamarin-android\external\Java.Interop\src\Java.Interop\obj\Debug\net6.0\Java.Interop.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\xamarin-android\external\Java.Interop\src\Java.Interop\Java.Interop.csproj] In fact, you can reproduce this by doing: dotnet new console dotnet build -p:LangVersion=8.0 It seems like `@(Import)` item group should not be present unless the project is C# 10 or higher? For now, we can set `$(DisableImplicitNamespaceImports)` to workaround the issue.
Context: dotnet/sdk#19050 xamarin-android is hitting this build error with .NET 6 Preview 7: C:\src\xamarin-android\external\Java.Interop\src\Java.Interop\obj\Debug\net6.0\Java.Interop.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\xamarin-android\external\Java.Interop\src\Java.Interop\Java.Interop.csproj] In fact, you can reproduce this by doing: dotnet new console dotnet build -p:LangVersion=8.0 It seems like `@(Import)` item group should not be present unless the project is C# 10 or higher? For now, we can set `$(DisableImplicitNamespaceImports)` to workaround the issue.
You mean if the language version is explicitly set? Yes that's a good point @JunTaoLuo |
Our example in dotnet/java-interop#859 was a |
I agree in principle. However, I want to highlight some nuances. LangVersion can be strings in additional to specific versions (e.g. preview, latest, latestMajor, etc) which can resolve to different C# version numbers. I don't think it's a good idea to duplicate the logic from Roslyn that deals with this resolution here in the SDK targets. Instead, it would be best if Roslyn can package that logic in a task that we can consume here. Tactically, I think the most we could do is check if the version is a number version and if it is, disable this feature if it's below 10.0. Thoughts? |
cc @jaredpar thoughts? |
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. |
I think it's quite reasonable to check When this change flowed to dotnet/maui we're seeing similar failures due to lots of https://github.com/dotnet/maui/search?q=LangVersion I don't actually know why they are there -- I just saw the break.
@JunTaoLuo if |
* Update dependencies from https://github.com/xamarin/xamarin-android build 6.0.1xx-preview7-8ca289588b6969a2cc878afa0813afec8cd63dd3-1 Microsoft.Android.Sdk.Windows From Version 30.0.100-preview.7.91 -> To Version 30.0.100-preview.7.93 Dependency coherency updates Microsoft.NETCore.App.Ref,Microsoft.Dotnet.Sdk.Internal,Microsoft.Extensions.Primitives,Microsoft.AspNetCore.App.Runtime.win-x64,Microsoft.Extensions.Hosting.Abstractions,Microsoft.Extensions.DependencyInjection.Abstractions,Microsoft.Extensions.DependencyInjection,Microsoft.Extensions.Configuration.Abstractions,Microsoft.Extensions.Configuration,Microsoft.Extensions.Logging.Abstractions,Microsoft.Extensions.Logging,Microsoft.Extensions.Logging.Console,Microsoft.Extensions.Logging.Debug,Microsoft.Extensions.FileProviders.Abstractions,Microsoft.Extensions.FileProviders.Embedded,Microsoft.AspNetCore.Authorization,Microsoft.AspNetCore.Components.WebView,Microsoft.AspNetCore.Components.Web,Microsoft.JSInterop,Microsoft.WindowsDesktop.App.Runtime.win-x64,System.CodeDom From Version 6.0.0-preview.7.21326.8 -> To Version 6.0.0-preview.7.21368.2 (parent: Microsoft.Dotnet.Sdk.Internal * [build] remove workaround for iOS AOT packages on Windows * Ignore NU1703 in DeviceTests NU1703 warns about using nuget packages which have xamarin.ios tfm references from a newer net6.0-maccatalyst project. * Workaround error for implicit imports Context: dotnet/sdk#19050 and dotnet/java-interop@4fb7c14 * Ignore NU1703 for Mac Catalyst projects * Revert "Ignore NU1703 in DeviceTests" This reverts commit 8fdf5e1. * Revert "Revert "Ignore NU1703 in DeviceTests"" This reverts commit 4d0456d. * Fix other C# 10-related errors * Use `LangVersion=latest` by default * Fixed new NRT-related errors that appeared from C# 10.0 * Disable StaticWebAssets in MauiRazorClassLibrarySample Workaround to get the build to work. Will revert later to investigate. Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Jonathan Peppers <jonathan.peppers@microsoft.com> Co-authored-by: Jonathan Dick <jondick@gmail.com> Co-authored-by: Eilon Lipton <Eilon@users.noreply.github.com>
* Update dependencies from https://github.com/xamarin/xamarin-android build 6.0.1xx-preview7-8ca289588b6969a2cc878afa0813afec8cd63dd3-1 Microsoft.Android.Sdk.Windows From Version 30.0.100-preview.7.91 -> To Version 30.0.100-preview.7.93 Dependency coherency updates Microsoft.NETCore.App.Ref,Microsoft.Dotnet.Sdk.Internal,Microsoft.Extensions.Primitives,Microsoft.AspNetCore.App.Runtime.win-x64,Microsoft.Extensions.Hosting.Abstractions,Microsoft.Extensions.DependencyInjection.Abstractions,Microsoft.Extensions.DependencyInjection,Microsoft.Extensions.Configuration.Abstractions,Microsoft.Extensions.Configuration,Microsoft.Extensions.Logging.Abstractions,Microsoft.Extensions.Logging,Microsoft.Extensions.Logging.Console,Microsoft.Extensions.Logging.Debug,Microsoft.Extensions.FileProviders.Abstractions,Microsoft.Extensions.FileProviders.Embedded,Microsoft.AspNetCore.Authorization,Microsoft.AspNetCore.Components.WebView,Microsoft.AspNetCore.Components.Web,Microsoft.JSInterop,Microsoft.WindowsDesktop.App.Runtime.win-x64,System.CodeDom From Version 6.0.0-preview.7.21326.8 -> To Version 6.0.0-preview.7.21368.2 (parent: Microsoft.Dotnet.Sdk.Internal * [build] remove workaround for iOS AOT packages on Windows * Ignore NU1703 in DeviceTests NU1703 warns about using nuget packages which have xamarin.ios tfm references from a newer net6.0-maccatalyst project. * Workaround error for implicit imports Context: dotnet/sdk#19050 and dotnet/java-interop@4fb7c14 * Ignore NU1703 for Mac Catalyst projects * Revert "Ignore NU1703 in DeviceTests" This reverts commit 8fdf5e1. * Revert "Revert "Ignore NU1703 in DeviceTests"" This reverts commit 4d0456d. * Fix other C# 10-related errors * Use `LangVersion=latest` by default * Fixed new NRT-related errors that appeared from C# 10.0 * Disable StaticWebAssets in MauiRazorClassLibrarySample Workaround to get the build to work. Will revert later to investigate. Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Jonathan Peppers <jonathan.peppers@microsoft.com> Co-authored-by: Jonathan Dick <jondick@gmail.com> Co-authored-by: Eilon Lipton <Eilon@users.noreply.github.com>
There is also a discussion here: #18825 |
I hit this today too. It's seems rather silly to turn on a feature that isn't supported. |
I think we can close this in favor of #19521, this feature is being redesigned. The idea is you will have to opt into it with |
Context: dotnet/sdk#19050 xamarin-android is hitting this build error with .NET 6 Preview 7: C:\src\xamarin-android\external\Java.Interop\src\Java.Interop\obj\Debug\net6.0\Java.Interop.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\xamarin-android\external\Java.Interop\src\Java.Interop\Java.Interop.csproj] In fact, you can reproduce this by doing: dotnet new console dotnet build -p:LangVersion=8.0 It seems like `@(Import)` item group should not be present unless the project is C# 10 or higher? For now, we can set `$(DisableImplicitNamespaceImports)` to workaround the issue.
Context: dotnet/sdk#19050 xamarin-android is hitting this build error with .NET 6 Preview 7: C:\src\xamarin-android\external\Java.Interop\src\Java.Interop\obj\Debug\net6.0\Java.Interop.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\xamarin-android\external\Java.Interop\src\Java.Interop\Java.Interop.csproj] In fact, you can reproduce this by doing: dotnet new console dotnet build -p:LangVersion=8.0 It seems like `@(Import)` item group should not be present unless the project is C# 10 or higher? For now, we can set `$(DisableImplicitNamespaceImports)` to workaround the issue.
Using
6.0.100-preview.7.21369.5
, you can do:This fails with:
Binlog: msbuild.zip
The text was updated successfully, but these errors were encountered: