‘SuppressMessage’ for a whole namespace

Suppression of a code analysis warning for a namespace and all its descendant symbols is possible since Visual Studio 2019: [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage( “Microsoft.Naming”, “CA1707:IdentifiersShouldNotContainUnderscores”, Justification = “Test methods require underscores for readability.” Scope = “namespaceanddescendants”, Target = “Company.Product.Tests”)] Scope – The target on which the warning is being suppressed. If the target is not specified, … Read more

Stylecop vs FXcop

Stylecop is a style analysis tool that works at the source code level. It exists primarily to provide a single common style that managed projects can use to remain consistent within the larger world of managed software. It makes decisions regarding style primarily to avoid holy wars (after all, style is almost always an inherently … Read more

CA2202, how to solve this case

You should suppress the warnings in this case. Code that deals with disposables should be consistent, and you shouldn’t have to care that other classes take ownership of the disposables you created and also call Dispose on them. [SuppressMessage(“Microsoft.Usage”, “CA2202:Do not dispose objects multiple times”)] public static byte[] Encrypt(string data, byte[] key, byte[] iv) { … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)