Skip to content
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

Global usings are used even if not supported #14434

Closed
dotMorten opened this issue Mar 16, 2022 · 3 comments · Fixed by #14475
Closed

Global usings are used even if not supported #14434

dotMorten opened this issue Mar 16, 2022 · 3 comments · Fixed by #14475
Assignees
Labels
bug If an issue is a bug or a pull request a bug fix dotnet An issue or pull request related to .NET (6) dotnet-pri0 .NET 6: required for stable release
Milestone

Comments

@dotMorten
Copy link
Contributor

dotMorten commented Mar 16, 2022

Steps to Reproduce

Install latest .NET SDK 6.0.3 + .NET MAUI 14 Preview workloads

  1. Create a net6.0-ios class library
  2. Set language version to 9.0 (or lower)
  3. Compile

Expected Behavior

Build success

Actual Behavior

Fails with:

obj\Release\net6.0-ios13.0\Esri.ArcGISRuntime.GlobalUsings.g.cs(2,1): error CS8773: Feature 'global using directive' is not available in C# 9.0. Please use language version 10.0 or greater. 

The generated code contains this, which looks like a hack around supporting nfloat

global using nfloat = global::System.Runtime.InteropServices.NFloat;

Environment

Click to expand
Microsoft Visual Studio Enterprise 2022
Version 17.1.0
VisualStudio.17.Release/17.1.0+32210.238
Microsoft .NET Framework
Version 4.8.04161

Installed Version: Enterprise

Visual C++ 2022   00476-80000-00000-AA891
Microsoft Visual C++ 2022

ASP.NET and Web Tools 2019   17.1.358.51495
ASP.NET and Web Tools 2019

ASP.NET Web Frameworks and Tools 2019   17.1.358.51495
For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0   17.1.358.51495
Azure App Service Tools v3.0.0

C# Tools   4.1.0-5.22109.6+0c82c4114a4e4b8b723b915eee3b13261db6717f
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools   1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Extensibility Message Bus   1.2.6 (master@34d6af2)
Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.

Microsoft JVM Debugger   1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft Library Manager   2.1.161+abc97ecc7d.RR
Install client-side libraries easily to any web project

Microsoft MI-Based Debugger   1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual C++ Wizards   1.0
Microsoft Visual C++ Wizards

Microsoft Visual Studio Tools for Containers   1.2
Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.

Microsoft Visual Studio VC Package   1.0
Microsoft Visual Studio VC Package

Mono Debugging for Visual Studio   17.1.10 (65f98f5)
Support for debugging Mono processes with Visual Studio.

NuGet Package Manager   6.1.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

Project System Tools   1.0
Tools for working with C#, VisualBasic, and F# projects.

Razor (ASP.NET Core)   17.0.0.2206201+62a2c1d6162f828801565a7ca26d9d48b810a05b
Provides languages services for ASP.NET Core Razor.

SQL Server Data Tools   17.0.62201.12090
Microsoft SQL Server Data Tools

Syntax Visualizer   1.0
An extension for visualizing Roslyn SyntaxTrees.

Test Adapter for Boost.Test   1.0
Enables Visual Studio's testing tools with unit tests written for Boost.Test.  The use terms and Third Party Notices are available in the extension installation directory.

Test Adapter for Google Test   1.0
Enables Visual Studio's testing tools with unit tests written for Google Test.  The use terms and Third Party Notices are available in the extension installation directory.

Tweaks 2022   1.1.125
A collection of minor fixes and tweaks for Visual Studio to reduce the paper cuts and make you a happier developer

TypeScript Tools   17.0.1229.2001
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools   4.1.0-5.22109.6+0c82c4114a4e4b8b723b915eee3b13261db6717f
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools   17.1.0-beta.21610.4+07b5673e4f2fa7630e78abe37f16b372353a7242
Microsoft Visual F# Tools

Visual Studio Code Debug Adapter Host Package   1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Container Tools Extensions   1.0
View, manage, and diagnose containers within Visual Studio.

Visual Studio IntelliCode   2.2
AI-assisted development for Visual Studio.

Visual Studio Tools for CMake   1.0
Visual Studio Tools for CMake

Visual Studio Tools for Containers   1.0
Visual Studio Tools for Containers

VisualStudio.DeviceLog   1.0
Information about my package

VisualStudio.Foo   1.0
Information about my package

VisualStudio.Mac   1.0
Mac Extension for Visual Studio

Xamarin   17.1.0.309 (d17-1@3f96c58)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer   17.1.0.87 (remotes/origin/main@d50fb5635)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin Templates   17.1.8 (590388a)
Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.

Xamarin.Android SDK   12.2.0.4 (d17-1/19b97b7)
Xamarin.Android Reference Assemblies and MSBuild support.
    Mono: a5d1934
    Java.Interop: xamarin/java.interop/d17-1@7ac33610
    ProGuard: Guardsquare/proguard/v7.0.1@912d149
    SQLite: xamarin/sqlite/3.37.1@0893b3b
    Xamarin.Android Tools: xamarin/xamarin-android-tools/d17-1@db125a7


Xamarin.iOS and Xamarin.Mac SDK   15.6.0.3 (caa899d24)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

Build Logs

Example Project (If Possible)

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net6.0-ios</TargetFramework>
    <ImplicitUsings>disable</ImplicitUsings> <!-- shouldn't be necessary but just to make sure -->
    <LangVersion>9</LangVersion>
  </PropertyGroup>
</Project>

Notes

You might want to ask why not just target v10? When building cross platform libraries and many of v10 features not being supported by older targets, we prefer lowering the language version enabled in the cross-platform class libraries, to reduce risk of code not compiling on certain targets.

Likely introduced by #14197

Workaround

Specify <NoNFloatUsing>true</NoNFloatUsing> in project file.

@dotMorten
Copy link
Contributor Author

NoNFloatUsing should probably be forced to true if language version is less than 10 @rolfbjarne ?

@rolfbjarne
Copy link
Member

NoNFloatUsing should probably be forced to true if language version is less than 10 @rolfbjarne ?

That sounds like a good option.

@rolfbjarne rolfbjarne added dotnet An issue or pull request related to .NET (6) dotnet-pri0 .NET 6: required for stable release labels Mar 17, 2022
@rolfbjarne rolfbjarne added this to the .NET 6 milestone Mar 17, 2022
@rolfbjarne rolfbjarne added the bug If an issue is a bug or a pull request a bug fix label Mar 17, 2022
@mfkl
Copy link

mfkl commented Mar 21, 2022

Same issue here, builds fine with Installing workload manifest microsoft.net.sdk.ios version 15.2.301-preview.13.7…,
but KO with Installing workload manifest microsoft.net.sdk.ios version 15.2.302-preview.14.117…, which our CI picks up automatically.

We get

D:\a\1\s\src\LibVLCSharp\obj\Release\net6.0-macos\LibVLCSharp.GlobalUsings.g.cs(2,1): error CS8773: Feature 'global using directive' is not available in C# 9.0. Please use language version 10.0 or greater. [D:\a\1\s\src\LibVLCSharp\LibVLCSharp.csproj]

Even though we are not using global using or enabling the implicit use of them. On Windows only, mac builds fine.

Trying to bump the lang version to 10.0 fixes the Windows builds, but fails the macOS one, with

 CSC : error CS1617: Invalid option '10.0' for /langversion. Use '/langversion:?' to list supported values. [/Users/runner/work/1/s/src/LibVLCSharp/LibVLCSharp.csproj]

rolfbjarne added a commit to rolfbjarne/xamarin-macios that referenced this issue Mar 22, 2022
@rolfbjarne rolfbjarne self-assigned this Mar 24, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Apr 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug If an issue is a bug or a pull request a bug fix dotnet An issue or pull request related to .NET (6) dotnet-pri0 .NET 6: required for stable release
Projects
None yet
3 participants