Enabling Nullable Annotations in X# Projects

This forum is meant for questions and discussions about the X# language and tools
Post Reply
User avatar
Irwin
Posts: 255
Joined: Wed Mar 23, 2022 10:24 am
Location: Spain

Enabling Nullable Annotations in X# Projects

Post by Irwin »

Hi Chris and Robert,

I've encountered an issue with nullable annotations. Here's what's happening:

Nullable Type Warning: I'm using a nullable type in my code, and I'm getting a warning about it (warning XS8632: The annotation for nullable reference types should only be used in code within a '#nullable' annotations context). I tried to enable nullable annotations but I noticed that XIDE does not have the option to enable this feature in the <PropertyGroup> section of the .xiproj file.

Using #nullable Enable/Restore: I attempted to wrap my methods with #nullable enable and #nullable restore to enable nullable annotations, but this approach resulted in a compilation error, suggesting that this case is not supported or recognized by the compiler.

I've solved my "issue" by adding the -nullable+ flag in the Additional compiler arguments, however, this feels like a temporary workaround rather than a proper solution.

regards,

Irwin.
XSharp Development Team (VFP)
Spain | irwin@xsharp.eu
User avatar
robert
Posts: 5084
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Re: Enabling Nullable Annotations in X# Projects

Post by robert »

Irwin,

We are not really supporting the nullable compiler flag.
Since our compiler source inherits from Roslyn, you can indeed add the command line option -nullable+, and it may work, but we did not properly test this yet.
We also do not yet support the #nullable preprocessor command

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
Irwin
Posts: 255
Joined: Wed Mar 23, 2022 10:24 am
Location: Spain

Re: Enabling Nullable Annotations in X# Projects

Post by Irwin »

robert wrote: Thu Feb 13, 2025 11:17 am Irwin,

We are not really supporting the nullable compiler flag.
Since our compiler source inherits from Roslyn, you can indeed add the command line option -nullable+, and it may work, but we did not properly test this yet.
We also do not yet support the #nullable preprocessor command

Robert
Hi Robert,
Thanks for the clarification. I will keep the -nullable+ flag in place to suppress the warning for now.

Irwin
XSharp Development Team (VFP)
Spain | irwin@xsharp.eu
User avatar
robert
Posts: 5084
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Re: Enabling Nullable Annotations in X# Projects

Post by robert »

Irwin,
You can also disable the warning. Adding the command line option may have unwanted (read untested) side effects.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
Post Reply