I'm working on a codebase that is not yet <Nullable>enable</Nullable>
. There is a vague notion that we will activate nullablity sometime soonish.
While writing code I'm sometimes tempted to use nullability operators (e.g. void Foo(string? stringOrNull) {}
). Mostly to explicitly mark that this argument is intended to accept null and that the implementation does/should respect that. Obviously I won't get any potential wrong-usage compiler-warning befits until nullability is activated. But at least I have noted my intent at the implementation site and whenever nullability is activated it should be picked up.
But of cause, for now, I get the compiler warning CS8632: The annotation for nullable reference types should only be used in code within a '#nullable' annotations context
.
Can I just suppress that or are there any unintended consequences?
?
. Can't you just add#nullable enable
in the files where you use it? It should make the future migration to use it a lot smoother. – Kapellmeister