diff --git a/gendarme/console/IgnoreFileList.cs b/gendarme/console/IgnoreFileList.cs index b714ded6e..c4a4fa3b4 100644 --- a/gendarme/console/IgnoreFileList.cs +++ b/gendarme/console/IgnoreFileList.cs @@ -40,6 +40,7 @@ namespace Gendarme { public class IgnoreFileList : BasicIgnoreList { private string current_rule; + private string currentFileName; private Dictionary> assemblies = new Dictionary> (); private Dictionary> types = new Dictionary> (); private Dictionary> methods = new Dictionary> (); @@ -54,24 +55,34 @@ public IgnoreFileList (IRunner runner, string fileName) private void Push (string fileName) { - if (!String.IsNullOrEmpty (fileName) && File.Exists (fileName) && !files.Contains (fileName)) { + if (String.IsNullOrEmpty (fileName)) + return; + + if (File.Exists (fileName) && !files.Contains (fileName)) { files.Push (fileName); } + else { + var directory = Path.GetDirectoryName (currentFileName); + if (!string.IsNullOrEmpty (directory) && !fileName.StartsWith (directory)){ + Push (Path.Combine (directory, fileName)); + } + } } private void Parse () { char [] buffer = new char [4096]; while (files.Count > 0) { - string fileName = files.Pop (); - using (StreamLineReader sr = new StreamLineReader (fileName)) { + currentFileName = files.Pop (); + using (StreamLineReader sr = new StreamLineReader (currentFileName)) { while (!sr.EndOfStream) { int length = sr.ReadLine (buffer, 0, buffer.Length); ProcessLine (buffer, length); } } } - Resolve (); + currentFileName = null; + Resolve(); TearDown (); } @@ -132,7 +143,7 @@ private void ProcessLine (char [] buffer, int length) base.Add (current_rule, NamespaceDefinition.GetDefinition (GetString (buffer, length))); break; case '@': // include file - files.Push (GetString (buffer, length)); + Push (GetString (buffer, length)); break; default: Console.Error.WriteLine ("Bad ignore entry : '{0}'", new string (buffer));