Author: nestor
Date: 2007-09-25 17:38:03 -0400 (Tue, 25 Sep 2007)
New Revision: 86357

Modified:
   trunk/cecil/gendarme/framework/ChangeLog
   trunk/cecil/gendarme/framework/Runner.cs
Log:
2007-09-25  Nestor Salceda  <[EMAIL PROTECTED]>

        * Runner.cs: Implemented the inclusion and exclusion of rules.



Modified: trunk/cecil/gendarme/framework/ChangeLog
===================================================================
--- trunk/cecil/gendarme/framework/ChangeLog    2007-09-25 21:02:30 UTC (rev 
86356)
+++ trunk/cecil/gendarme/framework/ChangeLog    2007-09-25 21:38:03 UTC (rev 
86357)
@@ -1,14 +1,18 @@
-2007-09-14  Nestor Salceda <[EMAIL PROTECTED]>
+2007-09-25  Nestor Salceda  <[EMAIL PROTECTED]>
 
+       * Runner.cs: Implemented the inclusion and exclusion of rules.
+
+2007-09-14  Nestor Salceda  <[EMAIL PROTECTED]>
+
        * gendarme-framework.pc.in:  The framework will be installed in
        ${prefix}/lib/gendarme not in ${prefix}/lib/Gendarme.Framework.  It
        works correctly now.
 
-2007-09-03  Nestor Salceda <[EMAIL PROTECTED]>
+2007-09-03  Nestor Salceda  <[EMAIL PROTECTED]>
 
        * RuleCollection.cs: Removed the indexer with name as parameter.
 
-2007-08-31  Nestor Salceda <[EMAIL PROTECTED]>
+2007-08-31  Nestor Salceda  <[EMAIL PROTECTED]>
        
        * gendarme-framework.pc.in, Makefile.am: Install Gendarme.Framework to
        be reusable (pkg-config) with other runners.

Modified: trunk/cecil/gendarme/framework/Runner.cs
===================================================================
--- trunk/cecil/gendarme/framework/Runner.cs    2007-09-25 21:02:30 UTC (rev 
86356)
+++ trunk/cecil/gendarme/framework/Runner.cs    2007-09-25 21:38:03 UTC (rev 
86357)
@@ -81,18 +81,31 @@
                        return (IRule) Activator.CreateInstance (type);
                }
 
+               private bool IsContainedInRuleSet (string rule, string mask)
+               {
+                       string[] ruleSet = mask.Split ('|');
+                       foreach (string entry in ruleSet) {
+                               if (String.Compare (rule, entry.Trim ()) == 0)
+                                       return true;
+                       }
+                       return false;
+               }
+
                public int LoadRulesFromAssembly (string assembly, string 
includeMask, string excludeMask)
                {
-                       if (includeMask != "*")
-                               throw new NotImplementedException 
("includeMask");
-                       if ((excludeMask != null) && (excludeMask.Length > 0))
-                               throw new NotImplementedException 
("excludeMask");
-
                        int total = 0;
                        Assembly a = Assembly.LoadFile (Path.GetFullPath 
(assembly));
                        foreach (Type t in a.GetTypes ()) {
                                if (t.IsAbstract || t.IsInterface)
                                        continue;
+                               
+                               if (includeMask != "*")
+                                       if (!IsContainedInRuleSet (t.Name, 
includeMask))
+                                               continue;
+                               
+                               if ((excludeMask != null) && 
(excludeMask.Length > 0)) 
+                                       if (IsContainedInRuleSet (t.Name, 
excludeMask))
+                                               continue;
 
                                LoadRules (typeof (IAssemblyRule), t, 
Rules.Assembly, ref total);
                                LoadRules (typeof (IModuleRule), t, 
Rules.Module, ref total);

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to