why microsoft keeps documenting code with constant like WM_SOMECONSTANT but the code analysis in Visual Studio reports the CA1707 warning?
Should we suppress all these warning for the solution? should we rename all the constants?
why microsoft keeps documenting code with constant like WM_SOMECONSTANT but the code analysis in Visual Studio reports the CA1707 warning?
Should we suppress all these warning for the solution? should we rename all the constants?
Copyright © 2021 Jogjafile Inc.
It looks like you're referencing a Native function in Windows. The recommendation here is to put the call to that function (and any enums and constants it needs) in a separate
NativeMethodsclass with its own.csfile. That way it's easy to suppress theCA1707in code for the whole file.And it's recommended to not sprinkle your non-native code with all of these constants either, can you create a simple wrapper that acts as the bridge between the ugly native win32 API and how you intend people to use it in your C# app? That way the rest of the code can remain blissfully unaware of it.
A few tricks that may help here:
When using the new
.editorconfigstyle ruleset files, you can specify a naming convention for the files to which rules apply:You can suppress inline with a compiler directive for a whole file:
You could move the native methods to a separate class library and disable the rule there altogether.