CA1806: When a method returns a new instance and the instance is ignored

The official title of the CA1806 analyzer warning is “Do not ignore method results,” but this doesn’t really show up in the list of warnings. Instead of showing this generic message, when CA1806 is triggered, it shows very specific text about what triggered the warning. In this article, I’ll show a few examples of code … Read more

CA1062: Validate parameter is non-null before using it

When you have a public method that isn’t null checking its parameters, then you’ll get the CA1062 code analysis warning. For example, the following code isn’t null checking the movieRepository parameter: This results in the CA1062 code analysis warning: CA1062 In externally visible method ‘void StreamingService.LogMovies(MovieRepository movieRepository)’, validate parameter ‘movieRepository’ is non-null before using it. … Read more