Comment on The error model of Microsoft's new languageparentComments−taspeotis12yI imagine you could do even better with something like PostSharp or Fody. public void MyFunction([InRange(0, 5)] int x, [NotNull] object y) { // ... } I just checked, and in fact Fody can do something just like this [1].The only downside I see is contracts like this would be hard to write concisely: if (useFirstObject == true) Contract.AssertNotNull(firstObject); else Contract.AssertNotNull(secondObject); [1] https://github.com/Fody/NullGuard
Comments
I imagine you could do even better with something like PostSharp or Fody.
I just checked, and in fact Fody can do something just like this [1].The only downside I see is contracts like this would be hard to write concisely:
[1] https://github.com/Fody/NullGuard