A few options:
- no warning (as today)
- warn for passing a possibly null value to
[DisallowNull]int? parameter
- disallow
[DisallowNull] on that parameter. If we do that, then we should probably also disallow on string?.
[Fact]
public void DisallowNull_04()
{
var source =
@"using System.Runtime.CompilerServices;
class Program
{
static void F1([DisallowNull]int i) { }
static void F2([DisallowNull]int? i) { }
static void M1(int i1)
{
F1(i1);
F2(i1);
}
static void M2(int? i2)
{
F2(i2); // I expected a warning here (jcouv)
if (i2 == null) return;
F2(i2);
}
}";
var comp = CreateCompilation(new[] { DisallowNullAttributeDefinition, source }, options: WithNonNullTypesTrue());
comp.VerifyDiagnostics();
}
Branch disallow-nullable
A few options:
[DisallowNull]int?parameter[DisallowNull]on that parameter. If we do that, then we should probably also disallow onstring?.Branch
disallow-nullable