What is the policy for argument validation in Roslyn code? I can see places where I can pass null
and get NullReferenceException
instead of ArgumentNullException
.
Are pull requests adding argument validation a good idea?
Public APIs should throw ArgumentnNullException. If not that'd be a bug. Internal APIs don't need to check anything. It's good to add Debug.Assert(x != null)
to capture the intent or whenever the null ref would occur later on and might be hard to find where the original problem was.
Most helpful comment
Public APIs should throw ArgumentnNullException. If not that'd be a bug. Internal APIs don't need to check anything. It's good to add
Debug.Assert(x != null)
to capture the intent or whenever the null ref would occur later on and might be hard to find where the original problem was.