Alexey Andrushkevich Alexey Andrushkevich - 6 months ago 62
C# Question

NotNull attribute

I'm looking at vnext engineering guideline and have noticed that they recommend to use

attribute instead of explicit checking of input argument for null and throwing
. The thing that confused me is that base on this guideline it is just enough to declare this attribute and the checking code will be generated at compile time into the method body. I've tried to do this in my test project however the magic didn't happen i.e. it threw the exception
instead of
. How this is supposed to work? Are they going to use some AOP library to inject the checking code at compile time?

Answer Source

Updated: Jan 12, 2016

The NotNullAttribute is gone. The ASP.NET team removed it and currently there's no plan to bring it back.

The attribute will be replaced through a precompilation step, using Roslyn, by code that does the actual check.

However, the feature is not yet ready. It will come in a later version.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download