stub
This is in reference to #211
I have some stuff in mind, will add it later.
These three:
using declarations, etc)From vague memory dymanoid used StyleCop in the Real Time mod to ensure consistent code comments, etc. This would be particularly useful for the planned TM:PE API (couldn't find issue tracking that) as we could use the proper code comments to auto-generate API docs to github.io, not to mention just making the source far more maintainable to anyone who hasn't been working on it the past 3+ years ;)
There is also a non-open source, but free, U2U Consult Performance Code Analyzers which might be worth investigating. I don't know if it's usable with the version of .Net Framework that C:SL limits us to?
All of the above work on VS2017 and would thus be suitable for open source contributions.
I don't use the JetBrains IDE (Riser?) so can't comment on that. @krzychu124 might have some ideas in that respect.
@VictorPhilipp We should ideally make a decision (well, really a decision between you and krzychu) on these things prior to any major code refactorings (such as move to harmony)?
There is also SonarLint which, according to https://stackoverflow.com/questions/748631/lint-for-c-sharp also uses Roslyn under the hood. It can installed directly from VS marketplace: https://marketplace.visualstudio.com/items?itemName=SonarSource.SonarLintforVisualStudio2017
We should also consider to implement a build pipeline (e.g. Travis CI) that runs for each pull request and merge. The linter and (later) tests will have to run successfully before a PR can be accepted.
An important aspect is integratability (into build pipeline) and ease of use. I have just downloaded all four tools and try them for a while.
Links to marketplace:
@krzychu124 Maybe you could set up Travis CI for this repo? https://travis-ci.org/krzychu124/Cities-Skylines-Traffic-Manager-President-Edition
I checked StyleCop:

馃憤 It is quite easy to configure (see screenshot above: "StyleCop Settings")
馃憥 You cannot set severity by issue type, only for all issues in general
馃憥 Build integration does not work. The project is broken after enabling and I had to manually repair the .csproj file. It is missing some StyleCop project


馃憥 You cannot group findings because StyleCop does not fill the respective fields in the error log (e.g. "Code" and "Tool")

Conclusion: 馃憥
I checked SonarLint:
I checked Roslynator:


Maybe the problem is caused by the old csproj format we use (it's from VS 2015)? I tried to update it to the new format (https://natemcmaster.com/blog/2017/03/09/vs2015-to-vs2017-upgrade/) but that did not make any difference.
I found a GitHub issue (https://github.com/JosefPihrt/Roslynator/issues/198) but setting the dropdown inside the error list to "Build + IntelliSense" did nothing.
It's sad. Roslynator looks promising but I am unable to get it running.
Regarding CodeMaid: This tool does not provide any static code analysis rules
@krzychu124 was magically able to create a build pipeline which facilitates StyleCop. The VS project file was also fixed.
Next steps:
Do not use that StyleCop version, it's obsolete.
Use:
StyleCop.Analyzers
FxCop Analyzers
Roslynator Analyzers
They are implemented as Roslyn analyzers and can be easily integrated into any build environment, the severity of each particular issue can be configured (info/warning/error/ignore), etc etc
See the Real Time repo for examples.
Yeah, I know, that's why we are using StyleCop.Analyzers. Great extension.
Thanks for links to other code analyzers :wink:
Will we add any more of the analysers listed above or can this issue be closed?
Some analysers were added to solution around v10.21 so closing this.
Also, @kvakvs added brief style guide to wiki (also linked from contributing guide) here: https://github.com/CitiesSkylinesMods/TMPE/wiki/Code-style-and-naming
Most helpful comment
@krzychu124 was magically able to create a build pipeline which facilitates StyleCop. The VS project file was also fixed.
Next steps: