Roslyn: Policy for argument validation in Roslyn code

Created on 2 Sep 2016  路  1Comment  路  Source: dotnet/roslyn

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?

Question Resolution-Answered

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.

>All comments

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.

Was this page helpful?
0 / 5 - 0 ratings