Unable to build Godot with C# support and Godex
Yam-s opened this issue · 19 comments
From looking at the Setup and the Compiling with Mono Godot docs page, I ran the following commands to hopefully enable C# support along with Godex:
scons -j8 p=windows target=release_debug tools=yes module_mono_enabled=yes mono_glue=no custom_modules="../godex" mono_prefix="C:\Program Files\Mono"
Glue generation:
.\bin\godot.windows.opt.tools.64.mono.exe --generate-mono-glue .\modules\mono\glue
WARNING: The component BtStreamedShape is not trivial copyable
at: ECS::register_component (C:\Godot\godex\modules\bullet_physics\../../ecs.h:425)
WARNING: The component BtStreamedShape is not trivial destructible
at: ECS::register_component (C:\Godot\godex\modules\bullet_physics\../../ecs.h:427)
WARNING: The component BtStreamedShape is not trivial copy assignable
at: ECS::register_component (C:\Godot\godex\modules\bullet_physics\../../ecs.h:429)
WARNING: The component BtStreamedShape is not trivial move assignable
at: ECS::register_component (C:\Godot\godex\modules\bullet_physics\../../ecs.h:431)
WARNING: The component BtStreamedShape is not trivial move constructible
at: ECS::register_component (C:\Godot\godex\modules\bullet_physics\../../ecs.h:433)
Component: BtStreamedShape registered with ID: 11
Component: Force registered with ID: 12
Component: Torque registered with ID: 13
Component: Impulse registered with ID: 14
Component: TorqueImpulse registered with ID: 15
SystemBundle: Bullet Physics Base Only registered with ID: 0
System: BtBodyConfig registered with ID: 0
System: BtAreaConfig registered with ID: 1
System: BtApplyForces registered with ID: 2
System: BtSpacesStep registered with ID: 3
System: BtOverlapCheck registered with ID: 4
System: BtBodySync registered with ID: 5
System: BtPawnWalk registered with ID: 6
SystemBundle: Bullet Physics All Features registered with ID: 1
Component: Child registered with ID: 16
Component: Disabled registered with ID: 17
WARNING: The component MeshComponent is not trivial copyable
at: ECS::register_component (C:\Godot\godex\components\../ecs.h:425)
WARNING: The component MeshComponent is not trivial destructible
at: ECS::register_component (C:\Godot\godex\components\../ecs.h:427)
WARNING: The component MeshComponent is not trivial copy assignable
at: ECS::register_component (C:\Godot\godex\components\../ecs.h:429)
WARNING: The component MeshComponent is not trivial move assignable
at: ECS::register_component (C:\Godot\godex\components\../ecs.h:431)
WARNING: The component MeshComponent is not trivial move constructible
at: ECS::register_component (C:\Godot\godex\components\../ecs.h:433)
Component: MeshComponent registered with ID: 18
Component: TransformComponent registered with ID: 19
WARNING: The component Shape3DComponent is not trivial copyable
at: ECS::register_component (C:\Godot\godex\components\../ecs.h:425)
WARNING: The component Shape3DComponent is not trivial destructible
at: ECS::register_component (C:\Godot\godex\components\../ecs.h:427)
WARNING: The component Shape3DComponent is not trivial copy assignable
at: ECS::register_component (C:\Godot\godex\components\../ecs.h:429)
WARNING: The component Shape3DComponent is not trivial move assignable
at: ECS::register_component (C:\Godot\godex\components\../ecs.h:431)
WARNING: The component Shape3DComponent is not trivial move constructible
at: ECS::register_component (C:\Godot\godex\components\../ecs.h:433)
Component: Shape3DComponent registered with ID: 20
SystemBundle: Rendering 3D registered with ID: 2
System: ScenarioManagerSystem registered with ID: 7
System: MeshUpdaterSystem registered with ID: 8
System: MeshTransformUpdaterSystem registered with ID: 9
Dynamic system: PhysicsSystemDispatcher registered with ID: 10
SystemBundle: Godot Physics registered with ID: 3
System: CallPhysicsProcess registered with ID: 11
System: StepPhysicsServer3D registered with ID: 12
Mono: Log file is: 'C:\Users\yam\AppData\Roaming/Godot/mono/mono_logs/2021-06-10_13.53.17_14676.log'
ERROR: This function should never be used outside the editor, it can severely damage performance.
at: (servers\rendering\renderer_rd\renderer_storage_rd.cpp:7875)
ERROR: This shared component is not init. So you can't use it.
at: (C:\Godot\godex\modules\godot\nodes\shared_component_resource.cpp:30)
ERROR: Attempting to use an uninitialized RID
at: (C:\Godot\godot\core/templates/rid_owner.h:197)
Ignoring type 'Components3DGizmoPlugin' because it's not exposed
I receive the following errors when attempting to build with the glue:
scons -j8 p=windows target=release_debug tools=yes module_mono_enabled=yes mono_glue=yes custom_modules="../godex" mono_prefix="C:\Program Files\Mono"
[ 97%] Linking Static Library ==> modules\module_mono.windows.opt.tools.64.lib
[ 97%] build_api_solution(["bin\GodotSharp\Api\Debug\GodotSharp.dll", "bin\GodotSharp\Api\Debug\GodotSharp.pdb", "bin\GodotSharp\Api\Debug\GodotSharp.xml", "bin\GodotSharp\Api\Debug\GodotSharpEditor.dll", "bin\GodotSharp\Api\Debug\GodotSharpEditor.pdb", "bin\GodotSharp\Api\Debug\GodotSharpEditor.xml"], [])
[ 97%] build_godot_net_sdk(["bin\GodotSharp\Tools\nupkgs\Godot.NET.Sdk.4.0.0-dev5.nupkg", "bin\GodotSharp\Tools\nupkgs\Godot.SourceGenerators.4.0.0-dev2.nupkg"], [])
[ 97%] MSBuild path: C:\Program Files\dotnet\dotnet.exe
[ 97%] MSBuild path: C:\Program Files\dotnet\dotnet.exe
[100%] progress_finish(["progress_finish"], [])
[100%] Microsoft (R) Build Engine version 16.10.0+4242f381a for .NET
Copyright (C) Microsoft Corporation. All rights reserved.
Microsoft (R) Build Engine version 16.10.0+4242f381a for .NET
Copyright (C) Microsoft Corporation. All rights reserved.
[100%] Determining projects to restore...
Restored C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharpEditor\GodotSharpEditor.csproj (in 53 ms).
Restored C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\GodotSharp.csproj (in 53 ms).
Determining projects to restore...
Restored C:\Godot\godot\modules\mono\editor\Godot.NET.Sdk\Godot.SourceGenerators.Sample\Godot.SourceGenerators.Sample.csproj (in 78 ms).
Restored C:\Godot\godot\modules\mono\editor\Godot.NET.Sdk\Godot.NET.Sdk\Godot.NET.Sdk.csproj (in 118 ms).
Restored C:\Godot\godot\modules\mono\editor\Godot.NET.Sdk\Godot.SourceGenerators\Godot.SourceGenerators.csproj (in 125 ms).
1 of 4 projects are up-to-date for restore.
Godot.NET.Sdk ->
Successfully created package 'C:\Godot\godot\modules\mono\editor\Godot.NET.Sdk\Godot.NET.Sdk\bin\Release\Godot.NET.Sdk.4.0.0-dev5.nupkg'.
Godot.SourceGenerators -> C:\Godot\godot\modules\mono\editor\Godot.NET.Sdk\Godot.SourceGenerators\bin\Release\netstandard2.0\Godot.SourceGenerators.dll
C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\Core\Array.cs(144,35): error CS0426: The type name 'Array' does not exist in the type 'System' [C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\GodotSharp.csproj]
C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\Core\Array.cs(177,79): error CS0426: The type name 'Array' does not exist in the type 'System' [C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\GodotSharp.csproj]
C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\Core\Array.cs(207,81): error CS0426: The type name 'Array' does not exist in the type 'System' [C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\GodotSharp.csproj]
C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\Core\Array.cs(28,26): error CS0535: 'Array' does not implement interface member 'ICollection.CopyTo(Array, int)' [C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\GodotSharp.csproj]
C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\Generated\GodotObjects\Label.cs(77,38): warning CS0108: 'Label.TextDirection' hides inherited member 'Control.TextDirection'. Use the new keyword if hiding was intended. [C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\GodotSharp.csproj]
C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\Core\Dictionary.cs(134,35): error CS0426: The type name 'Array' does not exist in the type 'System' [C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\GodotSharp.csproj]
C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\Core\Dictionary.cs(29,9): error CS0535: 'Dictionary' does not implement interface member 'ICollection.CopyTo(Array, int)' [C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\GodotSharp.csproj]
C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\Core\Attributes\AssemblyHasScriptsAttribute.cs(9,33): error CS0426: The type name 'Type' does not exist in the type 'System' [C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\GodotSharp.csproj]
C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\Core\Attributes\AssemblyHasScriptsAttribute.cs(16,51): error CS0426: The type name 'Type' does not exist in the type 'System' [C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\GodotSharp.csproj]
C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\Generated\GodotObjects\LineEdit.cs(428,38): warning CS0108: 'LineEdit.TextDirection' hides inherited member 'Control.TextDirection'. Use the new keyword if hiding was intended. [C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\GodotSharp.csproj]
C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\Generated\GodotObjects\ArrayMesh.cs(89,36): warning CS0108: 'ArrayMesh.BlendShapeMode' hides inherited member 'Mesh.BlendShapeMode'. Use the new keyword if hiding was intended. [C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\GodotSharp.csproj]
C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\Generated\GodotObjects\LinkButton.cs(53,38): warning CS0108: 'LinkButton.TextDirection' hides inherited member 'Control.TextDirection'. Use the new keyword if hiding was intended. [C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\GodotSharp.csproj]
C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\Generated\GodotObjects\Button.cs(82,38): warning CS0108: 'Button.TextDirection' hides inherited member 'Control.TextDirection'. Use the new keyword if hiding was intended. [C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\GodotSharp.csproj]
C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\Generated\GodotObjects\GLTFAccessor.cs(351,20): warning CS0108: 'GLTFAccessor.GetType()' hides inherited member 'object.GetType()'. Use the new keyword if hiding was intended. [C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\GodotSharp.csproj]
C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\Generated\GodotObjects\GLTFLight.cs(163,23): warning CS0108: 'GLTFLight.GetType()' hides inherited member 'object.GetType()'. Use the new keyword if hiding was intended. [C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\GodotSharp.csproj]
C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\Generated\GodotObjects\RichTextLabel.cs(341,38): warning CS0108: 'RichTextLabel.TextDirection' hides inherited member 'Control.TextDirection'. Use the new keyword if hiding was intended. [C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\GodotSharp.csproj]
C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\Generated\GodotObjects\TextEdit.cs(188,38): warning CS0108: 'TextEdit.TextDirection' hides inherited member 'Control.TextDirection'. Use the new keyword if hiding was intended. [C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\GodotSharp.csproj]
C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\Generated\GodotObjects\GraphNode.cs(54,38): warning CS0108: 'GraphNode.TextDirection' hides inherited member 'Control.TextDirection'. Use the new keyword if hiding was intended. [C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\GodotSharp.csproj]
C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\Core\Array.cs(144,35): error CS0426: The type name 'Array' does not exist in the type 'System' [C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\GodotSharp.csproj]
C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\Core\Array.cs(177,79): error CS0426: The type name 'Array' does not exist in the type 'System' [C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\GodotSharp.csproj]
C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\Core\Array.cs(207,81): error CS0426: The type name 'Array' does not exist in the type 'System' [C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\GodotSharp.csproj]
C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\Core\Array.cs(28,26): error CS0535: 'Array' does not implement interface member 'ICollection.CopyTo(Array, int)' [C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\GodotSharp.csproj]
C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\Core\Dictionary.cs(134,35): error CS0426: The type name 'Array' does not exist in the type 'System' [C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\GodotSharp.csproj]
C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\Core\Dictionary.cs(29,9): error CS0535: 'Dictionary' does not implement interface member 'ICollection.CopyTo(Array, int)' [C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\GodotSharp.csproj]
C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\Core\Attributes\AssemblyHasScriptsAttribute.cs(9,33): error CS0426: The type name 'Type' does not exist in the type 'System' [C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\GodotSharp.csproj]
C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\Core\Attributes\AssemblyHasScriptsAttribute.cs(16,51): error CS0426: The type name 'Type' does not exist in the type 'System' [C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\GodotSharp.csproj]
C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\Generated\GodotObjects\ArrayMesh.cs(89,36): warning CS0108: 'ArrayMesh.BlendShapeMode' hides inherited member 'Mesh.BlendShapeMode'. Use the new keyword if hiding was intended. [C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\GodotSharp.csproj]
C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\Generated\GodotObjects\Button.cs(82,38): warning CS0108: 'Button.TextDirection' hides inherited member 'Control.TextDirection'. Use the new keyword if hiding was intended. [C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\GodotSharp.csproj]
C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\Generated\GodotObjects\GLTFAccessor.cs(351,20): warning CS0108: 'GLTFAccessor.GetType()' hides inherited member 'object.GetType()'. Use the new keyword if hiding was intended. [C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\GodotSharp.csproj]
C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\Generated\GodotObjects\GLTFLight.cs(163,23): warning CS0108: 'GLTFLight.GetType()' hides inherited member 'object.GetType()'. Use the new keyword if hiding was intended. [C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\GodotSharp.csproj]
C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\Generated\GodotObjects\Label.cs(77,38): warning CS0108: 'Label.TextDirection' hides inherited member 'Control.TextDirection'. Use the new keyword if hiding was intended. [C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\GodotSharp.csproj]
C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\Generated\GodotObjects\GraphNode.cs(54,38): warning CS0108: 'GraphNode.TextDirection' hides inherited member 'Control.TextDirection'. Use the new keyword if hiding was intended. [C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\GodotSharp.csproj]
C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\Generated\GodotObjects\LineEdit.cs(428,38): warning CS0108: 'LineEdit.TextDirection' hides inherited member 'Control.TextDirection'. Use the new keyword if hiding was intended. [C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\GodotSharp.csproj]
C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\Generated\GodotObjects\LinkButton.cs(53,38): warning CS0108: 'LinkButton.TextDirection' hides inherited member 'Control.TextDirection'. Use the new keyword if hiding was intended. [C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\GodotSharp.csproj]
C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\Generated\GodotObjects\RichTextLabel.cs(341,38): warning CS0108: 'RichTextLabel.TextDirection' hides inherited member 'Control.TextDirection'. Use the new keyword if hiding was intended. [C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\GodotSharp.csproj]
C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\Generated\GodotObjects\TextEdit.cs(188,38): warning CS0108: 'TextEdit.TextDirection' hides inherited member 'Control.TextDirection'. Use the new keyword if hiding was intended. [C:\Godot\godot\modules\mono\glue\GodotSharp\GodotSharp\GodotSharp.csproj]
C:\Program Files\dotnet\sdk\5.0.300\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(221,5): warning NU5128: Some target frameworks declared in the dependencies group of the nuspec and the lib/ref folder do not have exact matches in the other location. Consult the list of actions below: [C:\Godot\godot\modules\mono\editor\Godot.NET.Sdk\Godot.SourceGenerators\Godot.SourceGenerators.csproj]
C:\Program Files\dotnet\sdk\5.0.300\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(221,5): warning NU5128: - Add lib or ref assemblies for the netstandard2.0 target framework [C:\Godot\godot\modules\mono\editor\Godot.NET.Sdk\Godot.SourceGenerators\Godot.SourceGenerators.csproj]
Successfully created package 'C:\Godot\godot\modules\mono\editor\Godot.NET.Sdk\Godot.SourceGenerators\bin\Release\Godot.SourceGenerators.4.0.0-dev2.nupkg'.
[100%] scons: *** [bin\GodotSharp\Tools\nupkgs\Godot.NET.Sdk.4.0.0-dev5.nupkg] RuntimeError : 'msbuild' exited with error code: 1
Linking Program ==> bin\godot.windows.opt.tools.64.mono.exe
Traceback (most recent call last):
File "C:\Godot\godot\modules\mono\build_scripts\solution_builder.py", line 103, in run_command
subprocess.check_call(args, env=env_override)
File "c:\program files (x86)\python37-32\lib\subprocess.py", line 347, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['C:\\Program Files\\dotnet\\dotnet.exe', 'msbuild', 'C:\\Godot\\godot\\modules\\mono\\editor/Godot.NET.Sdk/Godot.NET.Sdk.sln', '/restore', '/t:Build', '/p:Configuration=Release', '/p:GodotPlatform=windows']' returned non-zero exit status 1.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\program files (x86)\python37-32\lib\site-packages\SCons\Action.py", line 1280, in execute
result = self.execfunction(target=target, source=rsources, env=env)
File "C:\Godot\godot\modules\mono\build_scripts\godot_net_sdk_build.py", line 20, in build_godot_net_sdk
build_solution(env, solution_path, build_config, extra_msbuild_args)
File "C:\Godot\godot\modules\mono\build_scripts\solution_builder.py", line 145, in build_solution
run_command(msbuild_path, msbuild_args, env_override=msbuild_env, name="msbuild")
File "C:\Godot\godot\modules\mono\build_scripts\solution_builder.py", line 105, in run_command
raise RuntimeError("'%s' exited with error code: %s" % (name, e.returncode))
RuntimeError: 'msbuild' exited with error code: 1
scons: *** [bin\GodotSharp\Api\Debug\GodotSharp.dll] RuntimeError : 'msbuild' exited with error code: 1
Traceback (most recent call last):
File "C:\Godot\godot\modules\mono\build_scripts\solution_builder.py", line 103, in run_command
erride)
File "c:\program files (x86)\python37-32\lib\subprocess.py", line 347, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['C:\\Program Files\\dotnet\\dotnet.exe', 'msbuild', 'C:\\Godot\\godot\\modules\\mono\\glue/GodotSharp/GodotSharp.sln', '/restore', '/t:Build', '/p:Configuration=Debug', '/p:NoWarn=1591']' returned non-zero exit status 1.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\program files (x86)\python37-32\lib\site-packages\SCons\Action.py", line 1280, in execute
result = self.execfunction(target=target, source=rsources, env=env)
File "C:\Godot\godot\modules\mono\build_scripts\api_solution_build.py", line 21, in build_api_solution
build_solution(env, solution_path, build_config, extra_msbuild_args=extra_msbuild_args)
File "C:\Godot\godot\modules\mono\build_scripts\solution_builder.py", line 145, in build_solution
run_command(msbuild_path, msbuild_args, env_override=msbuild_env, name="msbuild")
File "C:\Godot\godot\modules\mono\build_scripts\solution_builder.py", line 105, in run_command
raise RuntimeError("'%s' exited with error code: %s" % (name, e.returncode))
RuntimeError: 'msbuild' exited with error code: 1
Creating library bin\godot.windows.opt.tools.64.mono.lib and object bin\godot.windows.opt.tools.64.mono.exp
scons: building terminated because of errors.
I'm looking into this now out of interest, and I'm pretty sure it's because the mono glue generates a file called System.cs
which maps Godex's System class. This then overrides the native C# System
type, which means when other classes in the generated glue reference e.g. System.Array
, i.e. the built-in C# array type, it's instead looking for it in the System.cs
file.
I haven't yet got the whole thing compiled and working, but you can fix the syntax errors in the glue manually (there are only a few) by using aliased imports for the relevant types, e.g. in modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs
you can add:
using SystemArray = System.Array;
To the using directives, and then replace instances of System.Array
with SystemArray
.
However, I'm expecting this might cause further effects when trying to write C# scripts in Godot, so it may be better to somehow change how the glue is generated for the Godex classes so that the types don't clash.
Alternatively I suspect if you build the initial binary without the Godex module, then generate the glue, then compile the final binary with Godex, it should build successfully (haven't tried it, but I'm 99% sure). Of course, you wouldn't then have a native mapping for Godex in C# which I guess is kinda the point of building it with Mono, though you could build a facade or adaptor or something manually.
Going to continue playing with it and see what comes up.
Btw, here is a git patch that you can apply to the generated glue to fix the syntax, so it should at least build.
Index: modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs (revision a3850ba05094ce6026c6a60241e1bd82f1d3b826)
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs (date 1637237399009)
@@ -6,6 +6,7 @@
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
+using SystemEnvironment = System.Environment;
namespace Godot
{
@@ -243,7 +244,7 @@
/// </summary>
public static void PrintStack()
{
- Print(System.Environment.StackTrace);
+ Print(SystemEnvironment.StackTrace);
}
/// <summary>
Index: modules/mono/glue/GodotSharp/GodotSharp/Core/Dictionary.cs
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Dictionary.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Dictionary.cs
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Dictionary.cs (revision a3850ba05094ce6026c6a60241e1bd82f1d3b826)
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Dictionary.cs (date 1637237368889)
@@ -4,6 +4,7 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Diagnostics.CodeAnalysis;
+using SystemArray = System.Array;
namespace Godot.Collections
{
@@ -202,7 +203,7 @@
/// </summary>
/// <param name="array">The array to copy to.</param>
/// <param name="index">The index to start at.</param>
- public void CopyTo(System.Array array, int index)
+ public void CopyTo(SystemArray array, int index)
{
if (array == null)
throw new ArgumentNullException(nameof(array), "Value cannot be null.");
Index: modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs (revision a3850ba05094ce6026c6a60241e1bd82f1d3b826)
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs (date 1637237345131)
@@ -3,6 +3,7 @@
using System.Collections;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+using SystemArray = System.Array;
namespace Godot.Collections
{
@@ -29,7 +30,7 @@
/// Wrapper around Godot's Array class, an array of Variant
/// typed elements allocated in the engine in C++. Useful when
/// interfacing with the engine. Otherwise prefer .NET collections
- /// such as <see cref="System.Array"/> or <see cref="List{T}"/>.
+ /// such as <see cref="SystemArray"/> or <see cref="List{T}"/>.
/// </summary>
public class Array : IList, IDisposable
{
@@ -234,7 +235,7 @@
/// </summary>
/// <param name="array">The array to copy to.</param>
/// <param name="index">The index to start at.</param>
- public void CopyTo(System.Array array, int index)
+ public void CopyTo(SystemArray array, int index)
{
if (array == null)
throw new ArgumentNullException(nameof(array), "Value cannot be null.");
@@ -275,7 +276,7 @@
internal static extern IntPtr godot_icall_Array_Ctor();
[MethodImpl(MethodImplOptions.InternalCall)]
- internal static extern IntPtr godot_icall_Array_Ctor_MonoArray(System.Array array);
+ internal static extern IntPtr godot_icall_Array_Ctor_MonoArray(SystemArray array);
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern void godot_icall_Array_Dtor(IntPtr ptr);
@@ -305,7 +306,7 @@
internal static extern bool godot_icall_Array_Contains(IntPtr ptr, object item);
[MethodImpl(MethodImplOptions.InternalCall)]
- internal static extern void godot_icall_Array_CopyTo(IntPtr ptr, System.Array array, int arrayIndex);
+ internal static extern void godot_icall_Array_CopyTo(IntPtr ptr, SystemArray array, int arrayIndex);
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern IntPtr godot_icall_Array_Duplicate(IntPtr ptr, bool deep);
Index: modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/AssemblyHasScriptsAttribute.cs
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/AssemblyHasScriptsAttribute.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/AssemblyHasScriptsAttribute.cs
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/AssemblyHasScriptsAttribute.cs (revision a3850ba05094ce6026c6a60241e1bd82f1d3b826)
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/AssemblyHasScriptsAttribute.cs (date 1637237626064)
@@ -1,4 +1,5 @@
using System;
+using SystemType = System.Type;
namespace Godot
{
@@ -6,14 +7,14 @@
public class AssemblyHasScriptsAttribute : Attribute
{
private readonly bool requiresLookup;
- private readonly System.Type[] scriptTypes;
+ private readonly SystemType[] scriptTypes;
public AssemblyHasScriptsAttribute()
{
requiresLookup = true;
}
- public AssemblyHasScriptsAttribute(System.Type[] scriptTypes)
+ public AssemblyHasScriptsAttribute(SystemType[] scriptTypes)
{
requiresLookup = false;
this.scriptTypes = scriptTypes;
Note: We chatted about this in discord and we contacted the Godot team to have support for that, here the discord chat link: https://discord.com/channels/797456114404163625/797456114404163630/852560754611322930
Note: We chatted about this in discord and we contacted the Godot team to have support for that, here the discord chat link: https://discord.com/channels/797456114404163625/797456114404163630/852560754611322930
Great!
FWIW, Godot 4 is in the process of moving off of mono, onto dotnet6. It still uses a similar "generated glue" approach, but it could be different enough/more modern such that it avoids this issue. I've been testing out the dotnet6 branch recently but haven't tried to build godex on it. I've no idea if it'll make a difference, but I'll give it a go when I can.
Since System
is such a common namespace in C#, I would prefer to generate the class with a different name (e.g.: GodexSystem
) to avoid ambiguity errors. But that will require some other changes, as there is code that assumes C# classes don't have a different name.
I've 0 experience with C# but it seems that it's possible to use the C# namespace to fix it. In case case: GdSystem
or godex::System
or GodexSystem
seems good enough, especially if it's not required to rename the C++ class, that would affect other scripted languages.
What's the correct steps to fix this issue @neikeq?
We definitely don't want to generate a class named System
, because it will result in many ambiguity errors. It would be like calling your C++ class std
, except C# doesn't use ::
for resolving namespaces, so the compiler can't know if you want the class or the namespace. Placing that class in a different namespace, may not result in ambiguity errors when compiling the bindings, but it will result in that for whoever is using/importing that namespace.
One option is for the bindings' generator to just rename System
to System_
, or SystemClass
, or something like that, to remove ambiguity. This is the easiest solution, and it could be implemented right away today.
The other option is to generate a class named GodexSystem
. I don't suppose you want to change the name of the C++ class, so it will require some special handling by the bindings' generator. Either we add some kind of metadata information in ClassDB that informs that a class can go into the specified namespace, our we hard-code the C# bindings' generator to rename System
to GodexSystem
. The latter assumes the class comes from Godex, which may not be the case if there's another ECS module in the future.
@AndreaCatania I think that's fine, since C# users will be using an ide that'll autocomplete anyway, so it's unlikely to cause confusion.
Though the cleanest solution imo would be to prefix any Godex generated classes with Godex, to prevent any other clashes/potential future clashes of namespace. Some C++ libraries use this kind of system already in godot, for example the libicu library allows a flag to add a custom prefix to statically linked functions to prevent clashes, which was recently used to prevent a clash with the dotnet bundled icu. But I'm uncertain how simple it'd be for a module to implement it on their "side" of the build, rather than having to patch the C# bindings generator itself. Classdb metadata would be best in that case as @neikeq said, but I guess would take some work to get setup to have the bindings gen detect it and output the prefixed names.
But overall I agree that simply having the generator rename with some kind of generic suffix/prefix is the simplest way and prevents any need for specific custom handling.
I'll look into this next Saturday after I'm done with other tasks, and I need to make sure not to break code that assumes class names.
This diff is a working update where I changed System
to BaseSystem
https://discordapp.com/channels/797456114404163625/865464299681349662/969402587340226570
@neikeq Nice, thx a lot!
@FieldStudios If you managed to get it working already, you may submit a PR directly if you have some free time 🙌
I tried to write the "System_" solution by changing https://github.com/godotengine/godot/blob/master/modules/mono/editor/bindings_generator.h#L507 to
if (itype.name == "System") {
itype.proxy_name = "System_";
} else {
itype.proxy_name = itype.name.begins_with("_") ? itype.name.substr(1, itype.name.length()) : itype.name;
}
This does generally work, but there are 2 problems:
- The generator adds a "GodotClassName" attribute, if name and proxy_name don't match, that is not defined anywhere, which means "build_assemblies.py" will fail
- When creating a script from the editor with "System" as the base type, it will still generate it inheriting from "System"
This should be fixed in Godot 4.0+. Classes named System
are renamed to System_
.
You are right, it is.
Does Godex work with 4.x ?