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

[Mono] Mono MSBuild assumes C#7.3 feature level in new version #36058

Closed
WizzardMaker opened this issue Feb 9, 2020 · 8 comments
Closed

[Mono] Mono MSBuild assumes C#7.3 feature level in new version #36058

WizzardMaker opened this issue Feb 9, 2020 · 8 comments

Comments

@WizzardMaker
Copy link

Godot version: 3.1.2 Mono -> 3.2 Mono

OS/device including version: Windows 10

Issue description:
I can't use the new C#8 features with the new Mono version with the default .csproj file, as it tries to use C#7.3

src\InteractionLayerSystem\IInteractionLayer.cs(4,14): error CS8370: Feature 'default interface implementation' is not available in C# 7.3. Please use language version 8.0 or greater. [P:\Projekte\Major Games\OpenATD\OpenATD.csproj]
src\InteractionLayerSystem\IInteractionLayer.cs(4,14): error CS8701: Target runtime doesn't support default interface implementation. [P:\Projekte\Major Games\OpenATD\OpenATD.csproj]
Csc: C:\Program Files\Mono\bin\csc.bat /noconfig /nowarn:1701,1702 /nostdlib+ /errorreport:prompt /warn:4 /define:GODOT_WINDOWS;GODOT_64;GODOT;DEBUG;TOOLS /highentropyva+ /reference:"P:\Projekte\Major Games\OpenATD\.mono\assemblies\Debug\GodotSharp.dll" /reference:"P:\Projekte\Major Games\OpenATD\.mono\assemblies\Debug\GodotSharpEditor.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7\mscorlib.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7\System.Core.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7\System.dll" /debug+ /debug:portable /optimize- /out:.mono\temp\obj\Tools\OpenATD.dll /subsystemversion:6.00 /target:library /utf8output /langversion:7.3 ...

And forcing it with <LangVersion>8.0</LangVersion> gives this error

src\InteractionLayerSystem\IInteractionLayer.cs(4,14): error CS8701: Target runtime doesn't support default interface implementation. [P:\Projekte\Major Games\OpenATD\OpenATD.csproj]

Minimal reproduction project:
My .csproj file to maybe check for some errors
https://pastebin.com/ukUzAtKT

@neikeq
Copy link
Contributor

neikeq commented Feb 10, 2020

What build tool is selected in the editor settings? Is it mono's or vs build tools and what is the version?

@WizzardMaker
Copy link
Author

Both build tools fail to build the project

mono --version returns this:

Mono JIT compiler version 6.8.0 (Visual Studio built mono)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
        TLS:           __thread
        SIGSEGV:       normal
        Notification:  Thread + polling
        Architecture:  amd64
        Disabled:      none
        Misc:          softdebug
        Interpreter:   yes
        LLVM:          supported, not enabled.
        Suspend:       preemptive
        GC:            sgen (concurrent by default)

Visual Studio MSBuild reports this version:

C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\Roslyn>csc.exe -?
Microsoft (R) Visual C# Compiler Version 3.4.1-beta4-19614-01 (16504609)

@DanielFlaum
Copy link

DanielFlaum commented Jun 24, 2020

I also have this problem:

CommandConsole/Executor.cs(43,23): Feature 'recursive patterns' is not available in C# 7.3. Please use language version 8.0 or greater. [Frankweiler]

That error message appears both in Godot's editor, and in my IDE.

I'm running Fedora 32, and Godot Mono 3.2.1 stable. For my IDE I'm using VS Code 1.46.1. Mono is at version 6.8.0.123. MSBuild is at 16.5.0.

In my editor settings, the only Build Tool available for Mono is MSBuild (Mono).

@DanielFlaum
Copy link

DanielFlaum commented Jun 24, 2020

Oh hey, I just tried @WizzardMaker's attempt at forcing version 8 with <LangVersion>8.0</LangVersion>, and that worked for me. Here is my .csproj: https://pastebin.com/RwgByL3j

@GiantBlargg
Copy link
Contributor

GiantBlargg commented Jul 23, 2020

Adding <LangVersion>8.0</LangVersion> allows the use of some but not all of C# 8.0 features.

The missing features (including default interface implementation) require NetStandard 2.1 or NetCore 3.0, however supporting this in Godot does not seem to be a trivial task

@WizzardMaker Unfortunately it is likely you'll have to wait until Godot 4.0 to make full use of c# 8.0

As suggested in #39410 updating the docs to reflect that not all features are available would be best in the short term to avoid misleading people.

@Calinou
Copy link
Member

Calinou commented Jul 23, 2020

There's now a pull request that implements .NET Standard 2.1 support: #40595

It probably won't be cherry-picked to the 3.2 branch though.

@Calinou
Copy link
Member

Calinou commented Aug 18, 2022

This should be addressed by #64089 in 4.0, but 3.x will keep using Mono.

@raulsntos
Copy link
Member

I'll close this since #64089 has already been merged.

About 3.x, the .NET Sdk changes of #40595 were actually backported in #41408 and while you can change the <TargetFramework> manually to netstandard2.0 or netstandard2.1 I still recommend you to stay in net472 which in my experience has fewer bugs.

Keep in mind that you can use a newer C# version with <LangVersion> independently of the target framework (as you already know). Some features such as Span<T> are not available in older frameworks but can be polyfilled with NuGet packages. Otherwise, the feature is not supported and this is unlikely to change in 3.x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants