Sharprompt icon indicating copy to clipboard operation
Sharprompt copied to clipboard

Add better Null Reference Type support

Open shibayan opened this issue 2 years ago • 1 comments

Adopt NRT as a required condition for the value. I need to use NullabilityInfoContext which will probably be added in NET 6. https://devblogs.microsoft.com/dotnet/announcing-net-6-preview-7/#getting-top-level-nullability-information

Proposal

// Value is required
var intValue = Prompt.Input<int>("Integer value");
var strValue = Prompt.Input<string>("String value");

// Value is optional
var optionalIntValue = Prompt.Input<int?>("Optional integer value");
var optionalStrValue = Prompt.Input<string?>("Optional string value");

shibayan avatar Aug 14 '21 18:08 shibayan

Currently in C#, nullability passed as a type parameter does not seem to be obtainable via reflection.

shibayan avatar Nov 13 '22 08:11 shibayan