Obsidian icon indicating copy to clipboard operation
Obsidian copied to clipboard

Enable nullable reference types

Open Seb-stian opened this issue 3 years ago • 7 comments

Adding this feature was decided by a discord poll. Nullable annotation should be enabled in the whole solution.

Seb-stian avatar Apr 22 '21 15:04 Seb-stian

Can I have this issue assigned to me?


I'm presently requesting further information on Discord. Once I have a better understanding of the full requirements through Discord conversations, I'll come back here to summarize them for documentation purposes.

tacosontitan avatar Aug 15 '21 15:08 tacosontitan

After discussing the issue in more detail on Discord, the objectives are:

  • Add the nullable annotation ? to all reference types.
    • This is regardless of the use-type (fields, properties, method arguments, local variables, etc.).

The use-case of the reference type should be taken into account when adding the annotation, to ensure it is only added where the intent is to allow null values. For example, the following snippet should mark the argument string text as nullable (string? text) since null is explicitly handled.

public ChatMessage AppendText(string text) {
    if (Text is null)
        Text = text;
    else
        Text += text;

    return this;
}

In cases where the intent cannot be easily inferred as allowing the use of null values, then it should be explicitly defined that null is not supported, along with a TODO comment:

#nullable disable // TODO: resolve nullability
private string superWeirdBehavingString;
#nullable restore

Note: Formatting simplified for the sake of comment brevity.

tacosontitan avatar Aug 15 '21 16:08 tacosontitan

Unfortunately, I keep running out of time to work on this; I apologize, I'm relinquishing the assignment.

tacosontitan avatar Oct 28 '21 21:10 tacosontitan

that's fine, no apologies needed. you were willing to put your free time into this project, yet did not have enough to actually do so. I understand :)

Naamloos avatar Oct 28 '21 21:10 Naamloos

That's fine, thanks for letting us know!

Seb-stian avatar Oct 28 '21 21:10 Seb-stian

[...] you were willing to put your free time into this project, yet did not have enough to actually do so. [...]

That's why open source is open source - everyone that wants to do this can do it.

ndelta0 avatar Oct 28 '21 21:10 ndelta0

Has this been enabled yet? I'm not sure... Please close this issue if it has been enabled.

Naamloos avatar Jan 09 '22 19:01 Naamloos

Closing as its enabled~

Tides avatar Feb 10 '24 23:02 Tides