Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
The goal of this PR is to add an analyser properly to our scripts only. It should also consider some of those issues as errors in CI.
To make the build fail in CI, simply configure some warnings to be errors instead.
Add a ruleset editor, to generate and/or remove rulesets from SS3D subfolders.
The source ruleset file is at :
Assets/Scripts/SS3D/Analysers/CustomRuleSetInitializer/SS3DRules.ruleset
We still have to decide which rules should we keep, which should throw a warning and which should throw an error.
Throwing warnings only for now, to avoid making the build fail and having to deal with hundreds of problematic files.
For the analyser to work, an assembly has to reference the analyser assembly. Know that this will propagate the analyser to all assemblies your assembly references.
Changes to Files
Technical Notes (optional)
Most was done following this tutorial : https://docs.unity3d.com/2021.3/Documentation/Manual/roslyn-analyzers.html#analyser-scope-anchor-link
One difficulty was the ability to limit the scope to only our folder. Normally, scope is defined by assemblies AND other assembly they references, which is a big mess and 90% references external libraries. The solution I suggest is to use ruleset files, to define custom behavior of analysers per assembly. I wrote a default ruleset file that ignore every warning from stylecop, and for each assembly in our SS3D Folder, a ruleset file applying our own ruleset, overriding the default one. I wrote an editor script that, on load, copy the content of a ruleset files to each assembly, so we have a single file to maintain. It's a bit hacky but I searched a lot and did not find any good alternatives.
Fixes (optional)
closes #1027