I have a Sitecore project in which I am using visualstudio code analysis. I am using Sitecore method "Assert.ArgumentNotNull" to check for null arguments, However visualstudio code analysis engine doesn't recognize it and show "CA1062 Validate arguments of public methods" message.
Instead of creating a custom rule, Is there a easier way to tell analysis engine that "Assert.ArgumentNotNull" performs null check and message is invalid.
I don't want to suppress the message or disable it.
You can't use Sitecore's
Assertclass that way and that's why:Sitecore
Assertclass as well asNotNullAttributeandCanBeNullAttributewere made the way ReSharper can understand when it performs its own analysis.Definition of
Assert.ArgumentNotNull(object, string)method is the following:All those attributes are defined in Sitecore and R# understands them because of naming conventions.
Unfortunately, VS code analysis has another naming conventions.
ArgumentNotNullshould look like this for you:Since you can't modify the
Assertclass, you can't markargumentparameter withValidatedNotNullAttribute.