Hello Brian,

On Mar 5, 5:33 pm, Brian <[email protected]> wrote:
> Hi folks,
>
> I'm brand new to Gendarme -- basically looking at creating some quick
> rules to catch a few in house rules on .NET assemblies --
> specifically, was looking how to block entire namespaces like
> System.Reflection (I think this one is easy but was having issues
> doing this -- I figured out how to catch specific classes, but I'm
> doing something wrong on the entire namespace).  Also, was trying to
> detect unsafe and/or P/Invoke callsbut not quite getting it.
>
> Any tips?

Since source code for all Gendarme (>250) rules is available your best
bet is to find something similar and adapt it to your specific needs.
Most of them are really small and easy to read/understand.

E.g. "was looking how to block entire namespaces like
System.Reflection"

that sounds a bit like
Gendarme.Rules.BadPractice.AvoidCallingProblematicMethodsRule
doc @ 
https://github.com/spouliot/gendarme/wiki/Gendarme.Rules.BadPractice.AvoidCallingProblematicMethodsRule%28git%29
sources @
https://github.com/mono/mono-tools/blob/master/gendarme/rules/Gendarme.Rules.BadPractice/AvoidCallingProblematicMethodsRule.cs


E.g. "detect unsafe and/or P/Invoke calls"

Pinvoke are easy to find, see
Gendarme.Rules.Interoperability.PInvokeShouldNotBeVisibleRule
doc @ 
https://github.com/spouliot/gendarme/wiki/Gendarme.Rules.Interoperability.PInvokeShouldNotBeVisibleRule%28git%29
sources @
https://github.com/mono/mono-tools/blob/master/gendarme/rules/Gendarme.Rules.Interoperability/PInvokeShouldNotBeVisibleRule.cs

However there is no metadata properties that will tell you if you're
dealing with unsafe code or not. You'll need to provide your own code
to detect this (e.g. some instructions are unverifiable, uses of
pointers...). You can look at Cecil's archive mails (or ask on it's
mailing-list), I'm pretty sure there's someone who already has some
code for doing so.

Sebastien

p.s. link to sources are against Gendarme 'master' which has new API
splitting the Name and Namespace parameters (instead of using
FullName). Either use/build Gendarme from GIT (futureproof) or look at
the source code from mono-2-10 branch (for Gendarme 2.10).

-- 
You received this message because you are subscribed to the Google Groups 
"Gendarme" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/gendarme?hl=en.

Reply via email to