Esempio n. 1
0
        protected override void ExecuteTask()
        {
            //TODO: First Test to do Item
            //FIXME: First Fix me Item
            //HACK: First Hack Item

            Project.Log(Level.Info, "Using Source Folder " + _SourceFolder);
            ToDo todo = new ToDo();

            foreach (Token token in Tokens)
            {
                try
                {
                    string[] patterns = _SearchPattern.Split(';');
                    foreach (string pattern in patterns)
                    {
                        String[] files = Directory.GetFiles(_SourceFolder, pattern, SearchOption.AllDirectories);
                        foreach (string file in files)
                        {
                            Project.Log(Level.Debug, file);
                            string[] lines = File.ReadAllLines(file);
                            for (int i = 0; i < lines.Length; i++)
                            {
                                string szRegex = string.Format(@"\/\/\s{{0,1}}{0}:(?<comment>.*)", token.Value);

                                Regex           re       = new Regex(szRegex, RegexOptions.IgnoreCase);
                                MatchCollection matchCol = re.Matches(lines[i]);
                                if (matchCol.Count > 0)
                                {
                                    foreach (Match match in matchCol)
                                    {
                                        string todoMessage = match.Groups["comment"].Value.Trim();
                                        todo.Items.Add(new ToDoItem()
                                        {
                                            Message = todoMessage, File = file, Type = token.Value, Line = i + 1
                                        });
                                    }
                                }
                            }
                        }
                    }
                    try
                    {
                        if (File.Exists(_OutputFile))
                        {
                            File.Delete(_OutputFile);
                        }
                        using (StreamWriter writer = File.CreateText(_OutputFile))
                        {
                            writer.Write(SerializeObject(todo, typeof(ToDo)));
                        }
                    }
                    catch (Exception ex)
                    {
                        Project.Log(Level.Error, "Failed to write to output file");
                        Project.Log(Level.Error, ex.Message);
                        Project.Log(Level.Error, ex.StackTrace);
                    }
                }
                catch (Exception ex)
                {
                    Project.Log(Level.Error, ex.Message);
                    Project.Log(Level.Error, ex.StackTrace);
                    if (ex.InnerException != null)
                    {
                        Project.Log(Level.Error, ex.InnerException.Message);
                        Project.Log(Level.Error, ex.InnerException.StackTrace);
                    }
                }
            }
        }
Esempio n. 2
0
		protected override void ExecuteTask()
		{
			//TODO: First Test to do Item
			//FIXME: First Fix me Item
			//HACK: First Hack Item

			Project.Log(Level.Info, "Using Source Folder " + _SourceFolder);
			ToDo todo = new ToDo();
			foreach(Token token in Tokens)
			{			
				try
				{
					string[] patterns =  _SearchPattern.Split(';');
					foreach(string pattern in patterns)
					{
						String[] files = Directory.GetFiles(_SourceFolder,pattern,SearchOption.AllDirectories);
						foreach(string file in files)
						{
                            Project.Log(Level.Debug, file);
                            string[] lines = File.ReadAllLines(file);
                            for (int i = 0; i < lines.Length; i++)
                            {
                                string szRegex = string.Format(@"\/\/\s{{0,1}}{0}:(?<comment>.*)", token.Value);

                                Regex re = new Regex(szRegex, RegexOptions.IgnoreCase);
                                MatchCollection matchCol = re.Matches(lines[i]);
                                if (matchCol.Count > 0)
                                {
                                    foreach (Match match in matchCol)
                                    {
                                        string todoMessage = match.Groups["comment"].Value.Trim();
                                        todo.Items.Add(new ToDoItem() { Message = todoMessage, File = file, Type = token.Value, Line = i + 1 });
                                    }
                                }
                            }
						}
					}		
					try
					{
						if(File.Exists(_OutputFile))
						   File.Delete(_OutputFile);
						using(StreamWriter writer = File.CreateText(_OutputFile))
						{
							writer.Write(SerializeObject(todo,typeof(ToDo)));
						}
					}
					catch(Exception ex)
					{
						Project.Log(Level.Error,"Failed to write to output file");
						Project.Log(Level.Error,ex.Message);	
						Project.Log(Level.Error,ex.StackTrace);
					}
				}
				catch(Exception ex)
				{
					Project.Log(Level.Error,ex.Message);
					Project.Log(Level.Error,ex.StackTrace);
					if(ex.InnerException != null)
					{
						Project.Log(Level.Error,ex.InnerException.Message);
						Project.Log(Level.Error,ex.InnerException.StackTrace);
					}
				}
			}		
		}