Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding stylecop for SS3D folder #1253

Merged
merged 9 commits into from
Sep 21, 2023
Merged

Conversation

stilnat
Copy link
Contributor

@stilnat stilnat commented Sep 11, 2023

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.

image

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

@stilnat stilnat changed the title [WIP] Adding stylecop for SS3D folder Adding stylecop for SS3D folder Sep 11, 2023
@joaoburatto joaoburatto merged commit f5bd494 into RE-SS3D:develop Sep 21, 2023
2 checks passed
@stilnat stilnat deleted the analysers branch November 10, 2023 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a linter following our c# style guide and apply it to the whole code base
2 participants