As far as I can see, there is no way to enable [SuppressMessage] in the gendarme (in 2.8). I grabbed the last source from GitHub because it did not work as described.
SupressMessageEngine is present in the code, and there are tests that run it by manually overriding Runner.Engines.Subscribe. But [EngineDependency (typeof (SuppressMessageEngine)]] does not apply to all compiled rules that he subscribed to when the gendarme actually works.
I also looked at the source to find a way to always subscribe to a specific engine through config - but it is not.
I could be wrong, but it looks like he forgot to go back and apply the appropriate EngineDependency attributes.
The only "workaround" I can come up with is to write a custom rule that, when called, adds a SuppressMessageEngine subscription and does nothing. Hacky yes, but this should work based on what I saw in their code.
FYI - just implemented this. You need to create your own custom rule, import Mono.Cecil and Gendarme.Framework and the target platform .NET 3.5
using Gendarme.Framework; using Gendarme.Framework.Engines; namespace MyRules { [Problem("Gendarme devs forgot to attribute rules with SuppressMessageEngine")] [Solution("Include this rule")] [EngineDependency(typeof(SuppressMessageEngine))] public class AddSuppressMessageSupportRule : Rule {} }
Unfortunately, this will not entail FxCopCompatibility attributes (i.e. SupressMessage for the FxCop rule that matches the gendarme rule will also suppress the gendarme rule), but at least it allows the use of gendarme names for suppression.
Ethan J. Brown
source share