public void IsMatchReturnsFalseWhenTaskTypesAreDifferent()
		{
			FileName fileName = new FileName(myTestFileName);
			lhs = new SDTask(fileName, description, column, line, TaskType.Warning);
			CreateTaskComparison();
			Assert.IsFalse(taskComparison.IsMatch);
		}
Ejemplo n.º 2
0
		public void Add(SDTask task)
		{
			if ((task.TaskType == TaskType.Error) || (task.TaskType == TaskType.Warning))  {
				SomethingWentWrong = true; 
			}
			Tasks.Add(task);
		}
		public void IsMatchReturnsFalseWhenFileNamesAreDifferent()
		{
			FileName fileName = new FileName(@"temp.cs");
			lhs = new SDTask(fileName, rhs.Description, rhs.Column, rhs.Line, rhs.TaskType);
			CreateTaskComparison();
			Assert.IsFalse(taskComparison.IsMatch);
		}
Ejemplo n.º 4
0
 public static void Remove(SDTask task)
 {
     if (tasks.Contains(task))
     {
         tasks.Remove(task);
         taskCount[task.TaskType]--;
         OnRemoved(new TaskEventArgs(task));
     }
 }
Ejemplo n.º 5
0
        void AddTask(SDTask task)
        {
            if (!isEnabled)
            {
                return;
            }
            if (!CheckTask(task))
            {
                return;
            }

            if (task.Line >= 1 && task.Line <= textEditor.Document.LineCount)
            {
                LoggingService.Debug(task.ToString());
                int offset    = textEditor.Document.GetOffset(task.Line, task.Column);
                int endOffset = TextUtilities.GetNextCaretPosition(textEditor.Document, offset, System.Windows.Documents.LogicalDirection.Forward, CaretPositioningMode.WordBorderOrSymbol);
                if (endOffset < 0)
                {
                    endOffset = textEditor.Document.TextLength;
                }
                int length = endOffset - offset;

                if (length < 1)
                {
                    // marker should be at least 1 characters long,
                    // but take care that we don't make it longer than the document
                    length = Math.Min(1, textEditor.Document.TextLength - offset);
                }

                ITextMarker marker = this.markerService.Create(offset, length);

                Color markerColor = Colors.Transparent;

                switch (task.TaskType)
                {
                case TaskType.Error:
                    markerColor = ErrorColor;
                    break;

                case TaskType.Message:
                    markerColor = MessageColor;
                    break;

                case TaskType.Warning:
                    markerColor = WarningColor;
                    break;
                }

                marker.MarkerColor = markerColor;
                marker.MarkerTypes = TextMarkerTypes.SquigglyUnderline | TextMarkerTypes.LineInScrollBar;

                marker.ToolTip = task.Description;

                marker.Tag = task;
            }
        }
		public void Init()
		{
			string className = "MyNamespace.MyTests";
			TestProject testProject = 
				TestProjectHelper.CreateTestProjectWithTestClassAndSingleTestMethod(className, "MyTestMethod");
			
			TestResult testResult = new TestResult("MyNamespace.MyTests.MyTestMethod");
			testResult.ResultType = TestResultType.Ignored;
			testResult.Message = "Test ignored";
			
			task = TestResultTask.Create(testResult, testProject);
		}
Ejemplo n.º 7
0
 public static void Add(SDTask task)
 {
     tasks.Add(task);
     if (!taskCount.ContainsKey(task.TaskType))
     {
         taskCount[task.TaskType] = 1;
     }
     else
     {
         taskCount[task.TaskType]++;
     }
     OnAdded(new TaskEventArgs(task));
 }
		public void Init()
		{
			TestResult testResult = new TestResult("MyNamespace.MyTests");
			testResult.ResultType = TestResultType.Failure;
			testResult.Message = "Test failed";
			testResult.StackTrace = 
				"Test Error : MyTest.Test\r\n" +
				"at TestResultTask.Create() in c:\\projects\\SharpDevelop\\TestResultTask.cs:line 45\r\n" +
				"at MyTest.Test() in c:\\myprojects\\test\\..\\test\\mytest.cs:line 28\r\n" +
				"";
			testResult.StackTraceFilePosition = 
				new FilePosition("c:\\myprojects\\test\\..\\test\\mytest.cs", 28, 1);
			task = TestResultTask.Create(testResult, null);
		}
		public void Init()
		{
			MockRegisteredTestFrameworks testFrameworks = new MockRegisteredTestFrameworks();
			MockClass c = MockClass.CreateMockClassWithoutAnyAttributes();
			TestClass testClass = new TestClass(c, testFrameworks);
			
			TestProject testProject = new TestProject(c.Project, c.ProjectContent, testFrameworks);
			testProject.TestClasses.Add(testClass);
			
			TestResult testResult = new TestResult("MyNamespace.MyTests.MyTestMethod");
			testResult.ResultType = TestResultType.Ignored;
			testResult.Message = "Test ignored";
			
			task = TestResultTask.Create(testResult, testProject);
		}
Ejemplo n.º 10
0
 bool CheckTask(SDTask task)
 {
     if (textEditor.FileName == null)
     {
         return(false);
     }
     if (task.FileName == null || task.Column <= 0)
     {
         return(false);
     }
     if (task.TaskType != TaskType.Warning && task.TaskType != TaskType.Error)
     {
         return(false);
     }
     return(FileUtility.IsEqualFileName(task.FileName, textEditor.FileName));
 }
Ejemplo n.º 11
0
		/// <summary>
		/// Parses errors of the form.
		/// "[delete] C:\foo\foo.build(94,5):"
        /// "[delete] Cannot delete directory 'C:\foo\bin'. The directory does not exist."
 		/// </summary>
		/// <param name="textLine">The line of text to parse.</param>
		/// <returns>A <see cref="Task"/> if an error was found; otherwise
		/// <see langword="null"/>.</returns> 
		static SDTask ParseMultilineBuildError(string output)
		{
			SDTask task = null;
			
			Match match = Regex.Match(output, @"^.*?\[delete\] (\w+:[/\\].*?)\(([\d]*),([\d]*)\):$\n^.*?\[delete\] (.*?)$", RegexOptions.Multiline);
			
			if (match.Success) {
				
				try	{
					int line = Convert.ToInt32(match.Groups[2].Value);
					int col = Convert.ToInt32(match.Groups[3].Value);
					string description = String.Concat(match.Groups[4]);
					task = new SDTask(FileName.Create(match.Groups[1].Value), description, col, line, TaskType.Error);
				} catch(Exception) { };
			}
			
			return task;
		}
Ejemplo n.º 12
0
		/// <summary>
		/// Looks for errors of the form 
		/// "BUILD FAILED"
		/// "[csc] C:/foo/foo.cs(5,5):"
		/// "Something bad happened."
		/// </summary>
		/// <param name="textLine">The line of text to parse.</param>
		/// <returns>A <see cref="Task"/> if an error was found; otherwise
		/// <see langword="null"/>.</returns>
		static SDTask ParseNAntBuildFailedError(string output)
		{
			SDTask task = null;
			
			Match match = Regex.Match(output, @"^BUILD FAILED.*?$\n^$\n^(\w+:[/\\].*?)\(([\d]*),([\d]*)\):$\n^(.*?)$\n^(.*?)$", RegexOptions.Multiline);
			
			if (match.Success) {
				
				try	{
					int line = Convert.ToInt32(match.Groups[2].Value);
					int col = Convert.ToInt32(match.Groups[3].Value);
					string description = String.Concat(match.Groups[4], Environment.NewLine, match.Groups[5]);
					task = new SDTask(FileName.Create(match.Groups[1].Value), description, col, line, TaskType.Error);
				} catch(Exception) { };
			} else {
				
				match = Regex.Match(output, @"^BUILD FAILED$\n^$\n^(.*?)$", RegexOptions.Multiline);
				
				if (match.Success) {
					task = new SDTask(null, match.Groups[1].Value, 0, 0, TaskType.Error);
				}
			}	
			
			return task;
		}
Ejemplo n.º 13
0
		/// <summary>
		/// Looks for errors of the form 
		/// "fatal error CS00042: An error occurred."
		/// </summary>
		/// <param name="textLine">The line of text to parse.</param>
		/// <returns>A <see cref="Task"/> if a warning was found; otherwise
		/// <see langword="null"/>.</returns>
		static SDTask ParseNAntWarning(string textLine)
		{
			SDTask task = null;
			Match match = Regex.Match(textLine, @"^.*?(Read-only property .*? cannot be overwritten.)$");
			if (match.Success) {
				try	{
					task = new SDTask(null, match.Groups[1].Value, 0, 0, TaskType.Warning);
				} catch (Exception) {
					// Ignore.
				}
			}
			
			return task;
		}
Ejemplo n.º 14
0
		/// <summary>
		/// Looks for errors of the form 
		/// "vbc : error BC31019: Unable to write to output file."
		/// </summary>
		/// <param name="textLine">The line of text to parse.</param>
		/// <returns>A <see cref="Task"/> if an error was found; otherwise
		/// <see langword="null"/>.</returns>
		static SDTask ParseVBFatalError(string textLine)
		{
			SDTask task = null;
			Match match = Regex.Match(textLine, @"^.*?vbc : error (.*?): (.*?)$");
			if (match.Success) {
				try	{
					string description = String.Concat(match.Groups[2].Value, " (", match.Groups[1].Value, ")");
					task = new SDTask(null, description, 0, 0, TaskType.Error);
				} catch (Exception) {
					// Ignore.
				}
			}
			
			return task;
		}
		public void TaskComparisonIsMatchReturnsTrueWhenBothTasksAreNull()
		{
			lhs = null;
			rhs = null;
			CreateTaskComparison();
			
			Assert.IsTrue(taskComparison.IsMatch);
		}
		public void IsMatchReturnsFalseWhenRhsTaskIsNull()
		{
			rhs = null;
			CreateTaskComparison();
			
			Assert.IsFalse(taskComparison.IsMatch);
		}
Ejemplo n.º 17
0
 public static void Remove(SDTask task)
 {
     if (tasks.Contains(task)) {
         tasks.Remove(task);
         taskCount[task.TaskType]--;
         OnRemoved(new TaskEventArgs(task));
     }
 }
		public void AddTask(SDTask task)
		{
			TaskService.Add(task);
		}
Ejemplo n.º 19
0
		void UpdateTasks(XamlErrorService xamlErrorService)
		{
			Debug.Assert(xamlErrorService != null);
			foreach (SDTask task in tasks) {
				TaskService.Remove(task);
			}
			
			tasks.Clear();
			
			foreach (XamlError error in xamlErrorService.Errors) {
				var task = new SDTask(PrimaryFile.FileName, error.Message, error.Column - 1, error.Line, TaskType.Error);
				tasks.Add(task);
				TaskService.Add(task);
			}
			
			TaskService.AddRange(DllLoadErrors);
			
			if (xamlErrorService.Errors.Count != 0) {
				SD.Workbench.GetPad(typeof(ErrorListPad)).BringPadToFront();
			}
		}
Ejemplo n.º 20
0
		/// <summary>
		///     <para>
		///       Initializes a new instance of <see cref='TaskCollection'/> containing any array of <see cref='Task'/> objects.
		///    </para>
		/// </summary>
		/// <param name='val'>
		///       A array of <see cref='Task'/> objects with which to intialize the collection
		/// </param>
		public TaskCollection(SDTask[] val)
		{
			this.AddRange(val);
		}
 public TaskEventArgs(SDTask task)
 {
     this.task = task;
 }
		public void Init()
		{
			FileName fileName = new FileName(myTestFileName);
			lhs = new SDTask(fileName, description, column, line, TaskType.Error);
			rhs = new SDTask(fileName, description, column, line, TaskType.Error);
		}
		public void IsMatchReturnsFalseWhenColumnsAreDifferent()
		{
			FileName fileName = new FileName(myTestFileName);
			rhs = new SDTask(fileName, description, 500, line, TaskType.Error);
			CreateTaskComparison();
			Assert.IsFalse(taskComparison.IsMatch);
		}
Ejemplo n.º 24
0
 public static void Add(SDTask task)
 {
     tasks.Add(task);
     if (!taskCount.ContainsKey(task.TaskType)) {
         taskCount[task.TaskType] = 1;
     } else {
         taskCount[task.TaskType]++;
     }
     OnAdded(new TaskEventArgs(task));
 }
 public void AddTask(SDTask task)
 {
     TasksAdded.Add(task);
 }
		public void Init()
		{
			TestResult testResult = new TestResult("MyNamespace.MyTests");
			testResult.ResultType = TestResultType.Ignored;
			task = TestResultTask.Create(testResult, null);
		}
Ejemplo n.º 27
0
		bool CheckTask(SDTask task)
		{
			if (textEditor.FileName == null)
				return false;
			if (task.FileName == null || task.Column <= 0)
				return false;
			if (task.TaskType != TaskType.Warning && task.TaskType != TaskType.Error)
				return false;
			return FileUtility.IsEqualFileName(task.FileName, textEditor.FileName);
		}
Ejemplo n.º 28
0
		/// <summary>
		/// Looks for errors of the form 
		/// "C:/MyProject/MyProject.build(40,3): ifnot is deprecated."
		/// </summary>
		/// <param name="textLine">The line of text to parse.</param>
		/// <returns>A <see cref="Task"/> if an error was found; otherwise
		/// <see langword="null"/>.</returns>
		static SDTask ParseNAntError(string textLine)
		{
			SDTask task = null;
			
			Match match = Regex.Match(textLine, @"^.*?(\w+:[/\\].*?)\(([\d]*),([\d]*)\): (.*?)$");
			if (match.Success) {
				try	{
					int line = Convert.ToInt32(match.Groups[2].Value);
					int col = Convert.ToInt32(match.Groups[3].Value);                     
					
					task = new SDTask(FileName.Create(match.Groups[1].Value), match.Groups[4].Value, col, line, TaskType.Warning);
				} catch (Exception) {
					// Ignore.
				}
			}

			return task;
		}
Ejemplo n.º 29
0
		/// <summary>
		///    <para> Removes a specific <see cref='Task'/> from the 
		///    <see cref='TaskCollection'/> .</para>
		/// </summary>
		/// <param name='val'>The <see cref='Task'/> to remove from the <see cref='TaskCollection'/> .</param>
		/// <returns><para>None.</para></returns>
		/// <exception cref='System.ArgumentException'><paramref name='val'/> is not found in the Collection. </exception>
		public void Remove(SDTask val)
		{
			List.Remove(val);
		}
Ejemplo n.º 30
0
		public TaskEventArgs(SDTask task)
		{
			this.task = task;
		}
Ejemplo n.º 31
0
		/// <summary>
		/// Looks for errors of the form 
		/// "C:/MyProject/MyProject.build(40): error CS1000: An error occurred."
		/// </summary>
		/// <remarks>
		/// This should handle C++ errors too.</remarks>
		/// <param name="textLine">The line of text to parse.</param>
		/// <returns>A <see cref="Task"/> if an error was found; otherwise
		/// <see langword="null"/>.</returns>
		static SDTask ParseVBError(string textLine)
		{
			SDTask task = null;
			Match match = Regex.Match(textLine, @"^.*?(\w+:[/\\].*?)\(([\d]*)\) : (.*?) (.*?): (.*?)$");
			if (match.Success) {
				try	{
					int line = Convert.ToInt32(match.Groups[2].Value);
					string description = String.Concat(match.Groups[5].Value, " (", match.Groups[4], ")");
					
					TaskType taskType = TaskType.Error;
					if (String.Compare(match.Groups[3].Value, "warning", true) == 0) {
						taskType = TaskType.Warning;
					}
					task = new SDTask(FileName.Create(match.Groups[1].Value), description, 0, line, taskType);
				} catch (Exception) {
					// Ignore.
				}
			}
			
			return task;
		}
Ejemplo n.º 32
0
		public TaskComparison(SDTask lhs, SDTask rhs)
		{
			this.lhs = lhs;
			this.rhs = rhs;
			Compare();
		}
Ejemplo n.º 33
0
		/// <summary>
		/// Looks for errors of the form 
		/// "fatal error CS00042: An error occurred."
		/// </summary>
		/// <param name="textLine">The line of text to parse.</param>
		/// <returns>A <see cref="Task"/> if an error was found; otherwise
		/// <see langword="null"/>.</returns>
		static SDTask ParseFatalError(string textLine)
		{
			SDTask task = null;
			Match match = Regex.Match(textLine, @"^.*?(fatal error .*?: .*?)$");
			if (match.Success) {
				try	{
					task = new SDTask(null, match.Groups[1].Value, 0, 0, TaskType.Error);
				} catch (Exception) {
					// Ignore.
				}
			}
			
			return task;
		}
Ejemplo n.º 34
0
		void AddTask(SDTask task)
		{
			if (!isEnabled)
				return;
			if (!CheckTask(task))
				return;
			
			if (task.Line >= 1 && task.Line <= textEditor.Document.LineCount) {
				LoggingService.Debug(task.ToString());
				int offset = textEditor.Document.GetOffset(task.Line, task.Column);
				int endOffset = TextUtilities.GetNextCaretPosition(textEditor.Document, offset, System.Windows.Documents.LogicalDirection.Forward, CaretPositioningMode.WordBorderOrSymbol);
				if (endOffset < 0) endOffset = textEditor.Document.TextLength;
				int length = endOffset - offset;
				
				if (length < 2) {
					// marker should be at least 2 characters long, but take care that we don't make
					// it longer than the document
					length = Math.Min(2, textEditor.Document.TextLength - offset);
				}
				
				ITextMarker marker = this.markerService.Create(offset, length);
				
				Color markerColor = Colors.Transparent;
				
				switch (task.TaskType) {
					case TaskType.Error:
						markerColor = ErrorColor;
						break;
					case TaskType.Message:
						markerColor = MessageColor;
						break;
					case TaskType.Warning:
						markerColor = WarningColor;
						break;
				}
				
				marker.MarkerColor = markerColor;
				marker.MarkerTypes = TextMarkerTypes.SquigglyUnderline | TextMarkerTypes.LineInScrollBar;
				
				marker.ToolTip = task.Description;
				
				marker.Tag = task;
			}
		}
Ejemplo n.º 35
0
		/// <summary>
		/// <para>Inserts a <see cref='Task'/> into the <see cref='TaskCollection'/> at the specified index.</para>
		/// </summary>
		/// <param name='index'>The zero-based index where <paramref name='val'/> should be inserted.</param>
		/// <param name='val'>The <see cref='Task'/> to insert.</param>
		/// <returns><para>None.</para></returns>
		/// <seealso cref='TaskCollection.Add'/>
		public void Insert(int index, SDTask val)
		{
			List.Insert(index, val);
		}