fxCop
We use FxCop to check wether DelftShell sources follow correct coding standards such as
- correct CapITalizaTION
- exception throwing
- naming
The reports are currently generated for core functionality only.
An fxcop report can be generated manually by running the fxcop project on Teamcity. To inspect the results we can use FxCopGraph and FxCopReport.
Common mistakes
Often I find people use System.Exception instead of a more specific one like ArgumentException or ReadOnlyException etc.
Assemblies are often missing the ClsCompliant attribute and SecurityPermission Attribute.
Example
[assembly: CLSCompliant(true)] //fxcop prerequisite [assembly: SecurityPermission(SecurityAction.RequestMinimum, Execution = true)] //fxcop prerequisite
When using a format statement or a ToString() function, the CultureInfo is usually missing. At least specify CultureInfo.InvariantCulture so the conversion always yields the same result when intended:
examples:
myInt.ToString(CultureInfo.InvariantCulture) string.Format(CultureInfo.InvariantCulture, "Tomorrow I will be {0} years old", 37)
Links
I found the following links on internet about coding standards while fixing some issues:
document on coding standards
Exception handling
FxCop, locale installatie