Skip to content

DotMake.CommandLine v1.6.8

Compare
Choose a tag to compare
@calacayir calacayir released this 16 Jan 01:28
· 33 commits to main since this release
  • Added support for SuppressNullableWarningExpression and C# 11 required modifier:

    An option/argument will be considered required when

    • There is no property initializer and the property type is a reference type (e.g. public string Arg { get; set; }).
      string is a reference type which has a null as the default value but bool and enum are value
      types which already have non-null default values. Nullable<T> is a reference type, e.g. bool?.
    • There is a property initializer, but it's initialized with null or null! (SuppressNullableWarningExpression)
      (e.g. public string Arg { get; set; } = null!;).
    • If it's forced via attribute property Required (e.g. [CliArgument(Required = true)]).
    • If it's forced via required modifier (e.g. public required string Opt { get; set; }).
      Note that for being able to use required modifier, if your target framework is below net7.0,
      you also need <LangVersion>11.0</LangVersion> tag (minimum) in your .csproj file
      (our source generator supplies the polyfills automatically as long as you set C# language version to 11).

    An option/argument will be considered optional when

    • There is no property initializer (e.g. public bool Opt { get; set; }) but the property type is a value type
      which already have non-null default value.
    • There is a property initializer but it's not initialized with null or null! (SuppressNullableWarningExpression)
      (e.g. public string Arg { get; set; } = "Default";).
    • If it's forced via attribute property Required (e.g. [CliArgument(Required = false)]).
  • Added AllowExisting property to [CliOption] and [CliArgument] which gets or sets a value indicating whether
    an argument should accept only values corresponding to an existing file or directory.