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

C#: Enable nullable environment for GodotTools #87137

Merged
merged 1 commit into from
Feb 17, 2024

Conversation

Repiteo
Copy link
Contributor

@Repiteo Repiteo commented Jan 13, 2024

Enables nullability in majority of GodotTools projects. At first I didn't think this would be possible without GodotSharp getting nullable first (see #83117), but it turns out there was quite a lot that could be setup as-is! The only real area that didn't get expanded upon were certain GodotObject fields (mirroring the selectively disabled nullability seen on a handful of files beforehand), which is likely to be more feasible when GodotSharp gets full-project nullability.

@Repiteo
Copy link
Contributor Author

Repiteo commented Jan 17, 2024

Updated to include GodotTools.IdeMessaging as well; while it's still a touchy file, I realized that it was perfectly safe to upgrade to C# 9 without issue, which does include nullability!

@YuriSizov
Copy link
Contributor

Could you please rebase on the current master? We had an issue with macOS builds which failed your CI.

@Repiteo
Copy link
Contributor Author

Repiteo commented Jan 17, 2024

Done and done!

Copy link
Member

@raulsntos raulsntos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking the time to work on this. I think it might've been easier to split the PR by csproj but what's done is done.

@Repiteo Repiteo force-pushed the dotnet/nullable-godot-tools branch 4 times, most recently from 968988c to 0edadd7 Compare January 31, 2024 14:26
@@ -20,36 +20,36 @@ public JetBrains.Rider.PathLocator.OS CurrentOS
}
}

public T FromJson<T>(string json)
public T? FromJson<T>(string json)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These methods implement the IRiderLocatorEnvironment interface that comes from https://github.com/JetBrains/resharper-unity/blob/net241/unity/PathLocator/PathLocator.csproj. This project doesn't enable nullability so the interface is not annotated.

Usually the implementation should match the interface, but in this case I'm not aware of any Microsoft guidelines that cover the case of a null-oblivious interface implemented by a null-aware class.

@@ -7,11 +7,11 @@ namespace GodotTools.BuildLogger
{
public class GodotBuildLogger : ILogger
{
public string Parameters { get; set; }
public string? Parameters { get; set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This property implements the ILogger interface which is not annotated for nullability: https://source.dot.net/#Microsoft.Build.Framework/ILogger.cs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nullability is disabled for that linked file overall, but the description of the property is: "The parameter string (can be null)". This certainly makes it seem like making it nullable is the correct call in a null-aware context

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. Like I said in #87137 (comment) I'm not aware of any guidelines to follow in this case so I was only bringing attention to it, but it's probably fine to leave it as-is.

@Repiteo Repiteo force-pushed the dotnet/nullable-godot-tools branch 2 times, most recently from 2c2b612 to 2964218 Compare February 13, 2024 15:33
Copy link
Member

@raulsntos raulsntos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@raulsntos raulsntos modified the milestones: 4.x, 4.3 Feb 17, 2024
@akien-mga akien-mga merged commit ccd9cef into godotengine:master Feb 17, 2024
16 checks passed
@akien-mga
Copy link
Member

Thanks!

@Repiteo Repiteo deleted the dotnet/nullable-godot-tools branch February 17, 2024 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants