How to use Godot-dotnet with GDextension

Godot Version

Godot 4.5.1 stable mono

Question

Hi everyone

I am new to GDextension. I mainly use GDScript. I am interested in learning more about GDextension C# and C++ in Godot. I found GitHub - raulsntos/godot-dotnet. I am currently struggling to get it to work.

The reason why I want to use GitHub - raulsntos/godot-dotnet is because there is a scene manager addon (GitHub - esdg/GodotSceneManager: The Scene Manager plugin enhances your Godot development workflow by providing a visual graph editor for managing transitions between scenes.) written in C# that I want to use in my mobile project. My project is written in GDScript and I dont want to switch to Godot .net just to use the addon.

Steps I Took

  1. Create an empty Godot C# project
  2. Download the godot-dotnet project from github
  3. Unzip the project in the empty Godot C# project
  4. Go into the godot-dotnet folder
  5. Open the terminal in the folder
  6. run ./build.sh –build
  7. The build failed with a bunch of errors
Output:
  Tasks succeeded (0,3s) → artifacts/bin/Tasks/Debug/net9.0/Tasks.dll
Restore complete (1,1s)
  Godot.BindingsGenerator.Reflection succeeded (0,2s) → artifacts/bin/Godot.BindingsGenerator.Reflection/Debug/net9.0/Godot.BindingsGenerator.Reflection.dll
  Godot.BindingsGenerator.ApiDump succeeded (0,2s) → artifacts/bin/Godot.BindingsGenerator.ApiDump/Debug/net9.0/Godot.BindingsGenerator.ApiDump.dll
  Godot.EditorIntegration.OpenVisualStudio succeeded (0,2s) → artifacts/bin/Godot.EditorIntegration.OpenVisualStudio/Debug/net9.0-windows/Godot.EditorIntegration.OpenVisualStudio.dll
  Godot.EditorIntegration.MSBuildLogger succeeded (0,3s) → artifacts/bin/Godot.EditorIntegration.MSBuildLogger/Debug/net9.0/Godot.EditorIntegration.MSBuildLogger.dll
  Godot.PluginLoader succeeded (0,2s) → artifacts/bin/Godot.PluginLoader/Debug/net9.0/Godot.PluginLoader.dll
  Godot.Tasks succeeded (0,2s) → artifacts/bin/Godot.Tasks/Debug/net9.0/Godot.Tasks.dll
  Godot.UpgradeAssistant.Core succeeded (0,5s) → artifacts/bin/Godot.UpgradeAssistant.Core/Debug/net9.0/Godot.UpgradeAssistant.Core.dll
  Godot.Common succeeded (0,1s) → artifacts/bin/Godot.Common/Debug/net9.0/Godot.Common.dll
  Godot.Common.Tests succeeded (0,2s) → artifacts/bin/Godot.Common.Tests/Debug/net9.0/Godot.Common.Tests.dll
  Godot.SourceGenerators failed with 2 error(s) (3,8s)
    /home/user/GodotProjects/dotnet-test/GodotDotnet/src/Godot.SourceGenerators/BindMembersGenerator.cs(10,2): error RS1038: This compiler extension should not be implemented in an assembly containing a reference to Microsoft.CodeAnalysis.Workspaces. The Microsoft.CodeAnalysis.Workspaces assembly is not provided during command line compilation scenarios, so references to it could cause the compiler extension to behave unpredictably. (https://github.com/dotnet/roslyn-analyzers/blob/main/docs/rules/RS1038.md)
    /home/user/GodotProjects/dotnet-test/GodotDotnet/src/Godot.SourceGenerators/EntryPointGenerator.cs(13,2): error RS1038: This compiler extension should not be implemented in an assembly containing a reference to Microsoft.CodeAnalysis.Workspaces. The Microsoft.CodeAnalysis.Workspaces assembly is not provided during command line compilation scenarios, so references to it could cause the compiler extension to behave unpredictably. (https://github.com/dotnet/roslyn-analyzers/blob/main/docs/rules/RS1038.md)
  Godot.Analyzers failed with 12 error(s) (4,2s)
    /home/user/GodotProjects/dotnet-test/GodotDotnet/src/Godot.Analyzers/Analyzers/AttributeOutsideGodotClassAnalyzer.cs(11,2): error RS1038: This compiler extension should not be implemented in an assembly containing a reference to Microsoft.CodeAnalysis.Workspaces. The Microsoft.CodeAnalysis.Workspaces assembly is not provided during command line compilation scenarios, so references to it could cause the compiler extension to behave unpredictably. (https://github.com/dotnet/roslyn-analyzers/blob/main/docs/rules/RS1038.md)
    /home/user/GodotProjects/dotnet-test/GodotDotnet/src/Godot.Analyzers/Analyzers/BindMethodAnalyzer.cs(8,2): error RS1038: This compiler extension should not be implemented in an assembly containing a reference to Microsoft.CodeAnalysis.Workspaces. The Microsoft.CodeAnalysis.Workspaces assembly is not provided during command line compilation scenarios, so references to it could cause the compiler extension to behave unpredictably. (https://github.com/dotnet/roslyn-analyzers/blob/main/docs/rules/RS1038.md)
    /home/user/GodotProjects/dotnet-test/GodotDotnet/src/Godot.Analyzers/Analyzers/BindPropertyAnalyzer.cs(8,2): error RS1038: This compiler extension should not be implemented in an assembly containing a reference to Microsoft.CodeAnalysis.Workspaces. The Microsoft.CodeAnalysis.Workspaces assembly is not provided during command line compilation scenarios, so references to it could cause the compiler extension to behave unpredictably. (https://github.com/dotnet/roslyn-analyzers/blob/main/docs/rules/RS1038.md)
    /home/user/GodotProjects/dotnet-test/GodotDotnet/src/Godot.Analyzers/Analyzers/BindConstantAnalyzer.cs(8,2): error RS1038: This compiler extension should not be implemented in an assembly containing a reference to Microsoft.CodeAnalysis.Workspaces. The Microsoft.CodeAnalysis.Workspaces assembly is not provided during command line compilation scenarios, so references to it could cause the compiler extension to behave unpredictably. (https://github.com/dotnet/roslyn-analyzers/blob/main/docs/rules/RS1038.md)
    /home/user/GodotProjects/dotnet-test/GodotDotnet/src/Godot.Analyzers/Analyzers/BindConstructorAnalyzer.cs(10,2): error RS1038: This compiler extension should not be implemented in an assembly containing a reference to Microsoft.CodeAnalysis.Workspaces. The Microsoft.CodeAnalysis.Workspaces assembly is not provided during command line compilation scenarios, so references to it could cause the compiler extension to behave unpredictably. (https://github.com/dotnet/roslyn-analyzers/blob/main/docs/rules/RS1038.md)
    /home/user/GodotProjects/dotnet-test/GodotDotnet/src/Godot.Analyzers/Analyzers/BoundMembersMustHaveUniqueNamesAnalyzer.cs(10,2): error RS1038: This compiler extension should not be implemented in an assembly containing a reference to Microsoft.CodeAnalysis.Workspaces. The Microsoft.CodeAnalysis.Workspaces assembly is not provided during command line compilation scenarios, so references to it could cause the compiler extension to behave unpredictably. (https://github.com/dotnet/roslyn-analyzers/blob/main/docs/rules/RS1038.md)
    /home/user/GodotProjects/dotnet-test/GodotDotnet/src/Godot.Analyzers/Analyzers/GodotClassAnalyzer.cs(8,2): error RS1038: This compiler extension should not be implemented in an assembly containing a reference to Microsoft.CodeAnalysis.Workspaces. The Microsoft.CodeAnalysis.Workspaces assembly is not provided during command line compilation scenarios, so references to it could cause the compiler extension to behave unpredictably. (https://github.com/dotnet/roslyn-analyzers/blob/main/docs/rules/RS1038.md)
    /home/user/GodotProjects/dotnet-test/GodotDotnet/src/Godot.Analyzers/Analyzers/GodotClassWithEditorCallbacksMustBeToolAnalyzer.cs(9,2): error RS1038: This compiler extension should not be implemented in an assembly containing a reference to Microsoft.CodeAnalysis.Workspaces. The Microsoft.CodeAnalysis.Workspaces assembly is not provided during command line compilation scenarios, so references to it could cause the compiler extension to behave unpredictably. (https://github.com/dotnet/roslyn-analyzers/blob/main/docs/rules/RS1038.md)
    /home/user/GodotProjects/dotnet-test/GodotDotnet/src/Godot.Analyzers/Analyzers/MarshallingRequiresCopyingAnalyzer.cs(8,2): error RS1038: This compiler extension should not be implemented in an assembly containing a reference to Microsoft.CodeAnalysis.Workspaces. The Microsoft.CodeAnalysis.Workspaces assembly is not provided during command line compilation scenarios, so references to it could cause the compiler extension to behave unpredictably. (https://github.com/dotnet/roslyn-analyzers/blob/main/docs/rules/RS1038.md)
    /home/user/GodotProjects/dotnet-test/GodotDotnet/src/Godot.Analyzers/Analyzers/MustBeVariantAnalyzer.cs(12,2): error RS1038: This compiler extension should not be implemented in an assembly containing a reference to Microsoft.CodeAnalysis.Workspaces. The Microsoft.CodeAnalysis.Workspaces assembly is not provided during command line compilation scenarios, so references to it could cause the compiler extension to behave unpredictably. (https://github.com/dotnet/roslyn-analyzers/blob/main/docs/rules/RS1038.md)
    /home/user/GodotProjects/dotnet-test/GodotDotnet/src/Godot.Analyzers/Analyzers/SignalDelegateNameSuffixAnalyzer.cs(9,2): error RS1038: This compiler extension should not be implemented in an assembly containing a reference to Microsoft.CodeAnalysis.Workspaces. The Microsoft.CodeAnalysis.Workspaces assembly is not provided during command line compilation scenarios, so references to it could cause the compiler extension to behave unpredictably. (https://github.com/dotnet/roslyn-analyzers/blob/main/docs/rules/RS1038.md)
    /home/user/GodotProjects/dotnet-test/GodotDotnet/src/Godot.Analyzers/Analyzers/SignalDelegateParameterTypesAnalyzer.cs(9,2): error RS1038: This compiler extension should not be implemented in an assembly containing a reference to Microsoft.CodeAnalysis.Workspaces. The Microsoft.CodeAnalysis.Workspaces assembly is not provided during command line compilation scenarios, so references to it could cause the compiler extension to behave unpredictably. (https://github.com/dotnet/roslyn-analyzers/blob/main/docs/rules/RS1038.md)
  Godot.BindingsGenerator failed with 1 error(s) (3,9s)
    /home/user/GodotProjects/dotnet-test/GodotDotnet/src/Godot.BindingsGenerator/DefaultValueParsers/DefaultValueParser.cs(22,69): error CS1573: Parameter 'typeDB' has no matching param tag in the XML comment for 'DefaultValueParser.Parse(string, TypeDB)' (but other parameters do)
  Godot.UpgradeAssistant.Providers failed with 12 error(s) (1,8s)
    /home/user/GodotProjects/dotnet-test/GodotDotnet/src/Godot.Common.CodeAnalysis/Enums/PropertyUsageFlags.cs(97,17): error CS8762: Parameter 'name' must have a non-null value when exiting with 'true'.
    /home/user/GodotProjects/dotnet-test/GodotDotnet/src/Godot.Common.CodeAnalysis/Enums/PropertyUsageFlags.cs(109,25): error CS8762: Parameter 'name' must have a non-null value when exiting with 'true'.
    /home/user/GodotProjects/dotnet-test/GodotDotnet/src/Godot.Common.CodeAnalysis/Enums/PropertyHint.cs(53,14): error CA2263: Prefer the generic overload 'System.Enum.IsDefined<TEnum>(TEnum)' instead of 'System.Enum.IsDefined(System.Type, object)' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2263)
    /home/user/GodotProjects/dotnet-test/GodotDotnet/src/Godot.Common.CodeAnalysis/Enums/PropertyHint.cs(58,46): error CA2263: Prefer the generic overload 'System.Enum.GetName<TEnum>(TEnum)' instead of 'System.Enum.GetName(System.Type, object)' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2263)
    /home/user/GodotProjects/dotnet-test/GodotDotnet/src/Godot.Common.CodeAnalysis/Enums/VariantType.cs(54,14): error CA2263: Prefer the generic overload 'System.Enum.IsDefined<TEnum>(TEnum)' instead of 'System.Enum.IsDefined(System.Type, object)' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2263)
    /home/user/GodotProjects/dotnet-test/GodotDotnet/src/Godot.Common.CodeAnalysis/Enums/VariantType.cs(59,45): error CA2263: Prefer the generic overload 'System.Enum.GetName<TEnum>(TEnum)' instead of 'System.Enum.GetName(System.Type, object)' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2263)
    /home/user/GodotProjects/dotnet-test/GodotDotnet/src/Godot.Common.CodeAnalysis/Enums/VariantTypeMetadata.cs(28,14): error CA2263: Prefer the generic overload 'System.Enum.IsDefined<TEnum>(TEnum)' instead of 'System.Enum.IsDefined(System.Type, object)' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2263)
    /home/user/GodotProjects/dotnet-test/GodotDotnet/src/Godot.Common.CodeAnalysis/Enums/VariantTypeMetadata.cs(33,60): error CA2263: Prefer the generic overload 'System.Enum.GetName<TEnum>(TEnum)' instead of 'System.Enum.GetName(System.Type, object)' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2263)
    /home/user/GodotProjects/dotnet-test/GodotDotnet/src/Godot.Common.CodeAnalysis/Enums/PropertyUsageFlags.cs(51,61): error CA2263: Prefer the generic overload 'System.Enum.GetValues<TEnum>()' instead of 'System.Enum.GetValues(System.Type)' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2263)
    /home/user/GodotProjects/dotnet-test/GodotDotnet/src/Godot.Common.CodeAnalysis/Enums/PropertyUsageFlags.cs(58,26): error CA2263: Prefer the generic overload 'System.Enum.GetNames<TEnum>()' instead of 'System.Enum.GetNames(System.Type)' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2263)
    /home/user/GodotProjects/dotnet-test/GodotDotnet/src/Godot.Common.CodeAnalysis/Enums/PropertyUsageFlags.cs(96,24): error CA2263: Prefer the generic overload 'System.Enum.GetName<TEnum>(TEnum)' instead of 'System.Enum.GetName(System.Type, object)' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2263)
    /home/user/GodotProjects/dotnet-test/GodotDotnet/src/Godot.Common.CodeAnalysis/Enums/PropertyUsageFlags.cs(108,32): error CA2263: Prefer the generic overload 'System.Enum.GetName<TEnum>(TEnum)' instead of 'System.Enum.GetName(System.Type, object)' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2263)

Build failed with 27 error(s) in 8,9s
Build failed with exit code 1. Check errors above.

Operating System

DotNet SDK Version

I have tried it with version 9.0.2 and 9.0.11. Both gave the same results.

The scene manager addon you mentioned is made using the GodotSharp bindings, so it won’t work with the new godot-dotnet bindings out of the box. Also, godot-dotnet is still a work in progress and is not production ready, so it would be much easier and safer for you to use the .NET/Mono version of Godot rather than build godot-dotnet.

However, if you still want to build godot-dotnet, you have to disable warnings as errors and enable binding generation:

./build.sh --build -warnAsError false /p:GenerateGodotBindings=true

This is a workaround until we fix the warnings and enable generating the bindings by default, and it shows that it’s still very much a work in progress.

Thank you for the reply. My game is written in gdscript and I don’t want to use mono just to use the scene manager plugin. I think it is best to wait for the stable release instead.

If it may be of any help. I found RS1038 is being triggered for analyzer + codefixer project when only codefixers reference the workspace types · Issue #7438 · dotnet/roslyn-analyzers · GitHub when searching the error codes.