c# warning – Mark assemblies with NeutralResourcesLanguageAttribute

The NeutralResourcesLanguageAttribute informs the resource manager of the language that was used to display resources which are contained in the main assembly. E.g. if you coded your assembly so that it contains resources which are in English, then include the following line in your AssemblyInfo.cs [assembly: NeutralResourcesLanguage(“en”)] This way, when looking up resources in English, … Read more

How to get the FxCop custom dictionary to work?

If you use it inside Visual Studio… From Visual Studio Code Analysis Team Blog To add a custom dictionary to a C# and Visual Basic project is simple: In Solution Explorer, right-click on the project and choose Add -> New Item… Under Templates, select XML File, enter a name for the dictionary, such as CodeAnalysisDictionary.xml … Read more

What’s with the “Afx” in StdAfx.h?

From Wikipedia: One interesting quirk of MFC is the use of “Afx” as the prefix for many functions, macros and the standard precompiled header name “stdafx.h”. During early development what became MFC was called “Application Framework Extensions” and abbreviated “Afx”. The name Microsoft Foundation Classes (MFC) was adopted too late in the release cycle to … Read more

Why is it considered bad to expose List? [duplicate]

I agree with moose-in-the-jungle here: List<T> is an unconstrained, bloated object that has a lot of “baggage” in it. Fortunately the solution is simple: expose IList<T> instead. It exposes a barebones interface that has most all of List<T>‘s methods (with the exception of things like AddRange()) and it doesn’t constrain you to the specific List<T> … Read more

Parameter naming: filename or fileName?

Lower camel case is recommended for fields and parameters. Example 1: fileName // for fields, parameters, etc. FileName // for properties, class names, etc. Generally, fileName is used and NOT filename; you can verify that by reading source code of open source stuff created by Microsoft, such as Enterprise Library. Reasons: The main point behind … Read more

‘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