I do not often see people talk about Gendarme around here, so i will assume people dont know what is Gendarme, and how it can help them.
TL;DR VERSION : Now you can analyze your Unity assemblies with Unity specific rules, and see where you can improve your scripts.
On Mac, you need to download Mono to execute it
On Windows, you need .Net 3.5 at least
Get Gendarme + Unity rules here : https://github.com/downloads/fderudder/unity-gendarme/Unity-Gendarme-2.10.zip
Repository’s here GitHub - fderudder/unity-gendarme: A tool based on mono-tools' Gendarme, to provide analysis rules dedicated to Unity's assemblies
Dont forget to check “All code, visible or not, outside the assemblies”. See last image at the end of this post.
KNOWN BUGS : n/a
Gendarme is part of the Mono Tools. For those unaware of that, Mono is what your scripts run on (hence MonoBehaviour). Gendarme is an assembly analyzer. It loads your .Net/Mono code, tests it against a set of rules, and generates a report, telling you with more or less accuracy where you could optimize, get rid of smelly code, refactor your copy/pasted files, etc etc. Gendarme is really usefull on every project, no matter what scale it is.
Now that everybody is more familiar with Gendarme, i would like to introduce you to the Unity Rules for Gendarme. Since i’m not a big fan of ads, i’ll describe it through a Q/A.
Q : What is that thing ?
A : As you’re reading that, It’s only a small set of basic performance tips and tricks, implemented as rules within Gendarme. It analyze your project’s assembly and generates a report, pointing you where you could optimize stuff.
Q : What’s the point ?
A : Automation, optimization, and stuff like that. You can easily use it in a build chain for example (since Gendarme already works with lots of continuous integration system, it will be pretty easy to add this in your jobs). And it can show you errors you may have forgotten, or you werent aware of while writing your code some weeks ago.
Q : What rules are available ?
A : I’ve implemented 4 basic performance oriented rules, just as a proof of concept. Those are :
- AvoidEmptyComponentsMethods : checks if your scripts have empty Updates. It’s tested against all MonoBehaviours basic methods
- AvoidUsingFindObjectInUpdate : Checks if you are using Object.FindObjectOfType, FindObjectsOfType, or GameObject.Find(“name”) in your Update/LateUpdate/FixedUpdate.
- CacheComponentLookup : checks if you call transforms, or stuffs like that in updates, and suggests to cache those in local member instead.
- UseBuiltInArray : checks the use of Array and ArrayList and suggest to change them for type[ ] or generic collection instead.
Q : That’s a very little number of rules dude.
A : I know. The project is just starting. Now i hope people will suggest new rules, new tips and tricks we could add to the set of rules dedicated to Unity.
Q : This sounds cool, but i tested my game, and i’m pretty sure it has detected false positives.
A : Oh. Well, it’s totally and definitely possible. I didnt have a lot of time and codebase to test this, so it may generates false positives. I have to set up a structure to track down those kind of bug reports by the way.
Q : How organized are you ?
A : Badly. I just gave a shot to that idea, wrote the code, tested against some codebase of mine, and that’s all. I dont know what i have to do now to get more organized. So feel free to point out where i should start. For example, i know i should setup a repository of some sort somewhere, probably on GitHub, to keep the code open source. And maybe a bugtracker. I dont know, i lack experience in open source projects, and especially public projects. So i’m kinda lost here.
Q : Well i found that a great tool, though there’s a little set of rules. How can i help ?
A : Report when you think you find false positives. I really want to have the rules as accurate as possibles. If you want to suggests new rules too. I’m open minded, so feel free to rant, to suggest, to report, to send me 24 inches screens.
Q : Well, i found that’s a shitty tool, and you just ripped off Gendarme and added some rules.
A : True. That’s just the beginning though. I hope you’ll find an interest in analyzing your codebase, and maybe it’ll help you. And maybe there will be more and more rules coming soon (i hope).
Q : How do i get it ?
A : Here : https://github.com/downloads/fderudder/unity-gendarme/Unity-Gendarme-2.10.zipBe warned that it’s a .Net/Mono software, so you need at least the Mono runtime on *nix/MacOs, or .Net on Windows. Otherwise, it may have some problem to work properly
.
Q : Where do i report stuff ?
A : i’d prefer that you report in that thread, or you can do it at: unity.gendarme@gmail.com
Q : Where do i send the 24" screen mentionned earlier ?
A : Dont do that, that was a joke. (But if you insist, i could use a third screen).
Q : I DONT SEE ANYTHING ! YOU LIED !
A : Nope, it’s just that you have to run Gendarme with the “All code, visible or not, outside the assemblies” option.
Q : How do i use it by the way ?
A :
This way :