pkdawson / imgui-godot

Dear ImGui plugin for Godot 4
MIT License
322 stars 19 forks source link

Fix warning CS0649 #4

Closed XPhyro closed 1 year ago

XPhyro commented 2 years ago

When building the game, the C# compiler complains about CS0649. As I see it, the font is expected to be assigned in the Godot editor, not via code, so this should be made clear to the compiler.

pkdawson commented 1 year ago

Hi, thanks for the PR. Sorry for the extremely late response, somehow I never got a notification about this.

I'm not able to reproduce a warning with the official Godot 3.5 binaries. I tried on Windows, macOS, and a fresh install of Fedora Linux 36 - all using the .NET 6 SDK.

I'm no C# expert, but in general there shouldn't be warnings about normal, documented, non-deprecated code, so I don't like to suppress warnings except as a last resort.

XPhyro commented 1 year ago

Hi, thanks for the PR. Sorry for the extremely late response, somehow I never got a notification about this.

No worries.

I'm not able to reproduce a warning with the official Godot 3.5 binaries. I tried on Windows, macOS, and a fresh install of Fedora Linux 36 - all using the .NET 6 SDK.

Might be fixed in 3.5, not sure. For context, at the time, I used Godot 3.4 & Godot 4 (compiled from git master) on Arch Linux.

I'm no C# expert, but in general there shouldn't be warnings about normal, documented, non-deprecated code, so I don't like to suppress warnings except as a last resort.

At the time, on my system, the compiler produced CS0649 for any variable marked with [Export] and not set. I didn't think it was a great idea to have a dummy assignment, so opted for suppression.

Godot 3.5 might be doing something for this similar to Unity's special treatment for [SerializeField] variables.

pkdawson commented 1 year ago

I tested a little more and found that removing the "= null" causes that warning. But explicitly assigning null is enough to remove the warning, so I think the current code is correct. The compiler doesn't report any issues even with all warnings turned on (level 9999).

XPhyro commented 1 year ago

I tested a little more and found that removing the "= null" causes that warning.

Oh yeah, it already has an assignment. I must have accidentally removed it.

At the time, on my system, the compiler produced CS0649 for any variable marked with [Export] and not set.

Also I didn't know in-place assignments suppressed this warning.

Sorry about the hassle overall.