You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In void M([DisallowNull]string x) the attribute is redundant.
Same in void M<T>([DisallowNull]T t) where T : class or void M<T>([DisallowNull]T t) where T : struct.
[MaybeNull]int or [MaybeNull]int?.
void M([MaybeNull] string s) (the attribute will affect the state of the argument, but why would anyone want that?)
using [NotNullIfNotNull(parameter)] for a parameter that doesn't exist
Note that some of those may be useful on ref parameters: void M([DisallowNull]ref string? s) or void M([MaybeNull]ref string s).
Also, the conditional attributes seem useful on non-generic types: [MaybeNullWhen(true)]string s or [NotNullWhen(true)]string? s.
Relates to #36009 (Should [DisallowNull] apply to value types or nullable value types?)
In
void M([DisallowNull]string x)the attribute is redundant.Same in
void M<T>([DisallowNull]T t) where T : classorvoid M<T>([DisallowNull]T t) where T : struct.[MaybeNull]intor[MaybeNull]int?.void M([MaybeNull] string s)(the attribute will affect the state of the argument, but why would anyone want that?)void M([DoesNotReturnIf(true)] out bool)[MaybeNull, NotNullWhen(false)](should work per Tweak interaction of outbound annotations ([MaybeNull, NotNullWhen(false)]) #36410)MaybeNull and NotNull conflict
MaybeNullWhen(b) and NotNullWhen(b) (same b) conflict
int M([MaybeNullWhen(true) string x)should warn because return type is notbool[DisallowNull] string? Property { get { ... } }or[MaybeNull] string Property { set { ... } }or[DisallowNull] readonly string? field = ...;using
[DisallowNull]or other attributes outside of a nullable annotations context (Usage of flow analysis attributes should warn outside of annotation context #36588)using
[NotNullIfNotNull(parameter)]for a parameter that doesn't existNote that some of those may be useful on
refparameters:void M([DisallowNull]ref string? s)orvoid M([MaybeNull]ref string s).Also, the conditional attributes seem useful on non-generic types:
[MaybeNullWhen(true)]string sor[NotNullWhen(true)]string? s.Relates to #36009 (Should [DisallowNull] apply to value types or nullable value types?)
Relates to PR #35955