Jun 30, 2016 12:47 AM
(This post was last modified: Jun 30, 2016 12:48 AM by caesay.)
The attributes are merely hints to the caller that the method has a certain requirement (NotNull or CanBeNull). Presumably, these attributes assist Microsoft and the CLR team in enforcing code contracts and doing unit tests.
In C#6 and roslyn i believe these attributes are internal-only, so they've been deprecated.
Some extensions / libraries have their own NotNull attributes - such as Resharper. If you include the JetBrains.Annotations library, you get [notnull] and [canbenull] and many other attributes, and if the consumer of the library has Resharper installed, they will get visual cues if they try to pass in a potential null value as a [NotNull] method parameter.
In summary, these attributes are for code contracts, and are not an excuse to skip doing null checks in your methods.