Author: spouliot
Date: 2006-09-17 20:16:01 -0400 (Sun, 17 Sep 2006)
New Revision: 65557

Modified:
   trunk/cecil/gendarme/framework/ChangeLog
   trunk/cecil/gendarme/framework/Runner.cs
   trunk/cecil/gendarme/framework/Violation.cs
   trunk/cecil/gendarme/framework/Violations.cs
Log:
2006-09-17  Sebastien Pouliot  <[EMAIL PROTECTED]>

        * Violation.cs: Added a new Assembly property deduced from the 
        violator object.

2006-09-17  Christian Birkl <[EMAIL PROTECTED]>

        * Runner.cs: Reset the violation list when processing a new assembly.
        * Violations.cs: Implement IEnumerable.



Modified: trunk/cecil/gendarme/framework/ChangeLog
===================================================================
--- trunk/cecil/gendarme/framework/ChangeLog    2006-09-17 23:51:09 UTC (rev 
65556)
+++ trunk/cecil/gendarme/framework/ChangeLog    2006-09-18 00:16:01 UTC (rev 
65557)
@@ -1,3 +1,13 @@
+2006-09-17  Sebastien Pouliot  <[EMAIL PROTECTED]>
+
+       * Violation.cs: Added a new Assembly property deduced from the 
+       violator object.
+
+2006-09-17  Christian Birkl <[EMAIL PROTECTED]>
+
+       * Runner.cs: Reset the violation list when processing a new assembly.
+       * Violations.cs: Implement IEnumerable.
+
 2006-08-28  Sebastien Pouliot  <[EMAIL PROTECTED]>
 
        * framework.mdp: Rename the output assembly to Gendarme.Framework.dll

Modified: trunk/cecil/gendarme/framework/Runner.cs
===================================================================
--- trunk/cecil/gendarme/framework/Runner.cs    2006-09-17 23:51:09 UTC (rev 
65556)
+++ trunk/cecil/gendarme/framework/Runner.cs    2006-09-18 00:16:01 UTC (rev 
65557)
@@ -116,6 +116,8 @@
 
                public void Process (AssemblyDefinition assembly)
                {
+                       Violations.Reset();
+                       
                        IList messages;
                        foreach (IAssemblyRule rule in Rules.Assembly) {
                                messages = rule.CheckAssembly(assembly, this);

Modified: trunk/cecil/gendarme/framework/Violation.cs
===================================================================
--- trunk/cecil/gendarme/framework/Violation.cs 2006-09-17 23:51:09 UTC (rev 
65556)
+++ trunk/cecil/gendarme/framework/Violation.cs 2006-09-18 00:16:01 UTC (rev 
65557)
@@ -4,7 +4,7 @@
 // Authors:
 //     Sebastien Pouliot <[EMAIL PROTECTED]>
 //
-// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2005-2006 Novell, Inc (http://www.novell.com)
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -29,6 +29,8 @@
 using System;
 using System.Collections;
 
+using Mono.Cecil;
+
 namespace Gendarme.Framework {
 
        public struct Violation {
@@ -42,5 +44,27 @@
                        Violator = violator;
                        Messages = messages;
                }
+
+               public AssemblyDefinition Assembly {
+                       get {
+                               AssemblyDefinition ad = (Violator as 
AssemblyDefinition);
+                               if (ad != null)
+                                       return ad;
+                                       
+                               ModuleDefinition md = (Violator as 
ModuleDefinition);
+                               if (md != null)
+                                       return md.Assembly;
+
+                               TypeDefinition td = (Violator as 
TypeDefinition);
+                               if (td != null)
+                                       return td.Module.Assembly;
+                                       
+                               MethodDefinition nd = (Violator as 
MethodDefinition);
+                               if (nd != null)
+                                       return nd.DeclaringType.Module.Assembly;
+
+                               return null;
+                       }
+               }
        }
 }

Modified: trunk/cecil/gendarme/framework/Violations.cs
===================================================================
--- trunk/cecil/gendarme/framework/Violations.cs        2006-09-17 23:51:09 UTC 
(rev 65556)
+++ trunk/cecil/gendarme/framework/Violations.cs        2006-09-18 00:16:01 UTC 
(rev 65557)
@@ -3,6 +3,7 @@
 //
 // Authors:
 //     Sebastien Pouliot <[EMAIL PROTECTED]>
+//     Christian Birkl <[EMAIL PROTECTED]>
 //
 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
 //
@@ -28,11 +29,10 @@
 
 using System;
 using System.Collections;
-using System.Text;
 
 namespace Gendarme.Framework {
 
-       public class Violations {
+       public class Violations : IEnumerable {
 
                private ArrayList list;
 
@@ -40,7 +40,7 @@
                {
                }
 
-               public IList List {
+               private IList List {
                        get {
                                if (list == null)
                                        list = new ArrayList ();
@@ -48,6 +48,15 @@
                        }
                }
 
+               public int Count {
+                       get { return List.Count; }
+               }
+               
+               public void Reset ()
+               {
+                       list = null;
+               }
+               
                public void Add (IRule rule, object obj, IList messages)
                {
                        if (rule == null)
@@ -62,5 +71,10 @@
                {
                        List.Add (v);
                }
+               
+               public IEnumerator GetEnumerator ()
+               {
+                       return List.GetEnumerator();
+               }
        }
 }

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

Reply via email to