Exemplo n.º 1
0
        void AddTask(SDTask task)
        {
            switch (task.TaskType)
            {
            case TaskType.Warning:
                if (!ShowWarnings)
                {
                    return;
                }
                break;

            case TaskType.Error:
                if (!ShowErrors)
                {
                    return;
                }
                break;

            case TaskType.Message:
                if (!ShowMessages)
                {
                    return;
                }
                break;

            default:
                return;
            }

            errors.Add(task);
        }
        public override void ProcessItem(SDTask item)
        {
            var documentPath = Path.Combine(this.GlobalStorage.Connection.BasePath, item.Document.ID);
            var pdfFileName  = Path.GetFileNameWithoutExtension(item.ID) + ".pdf";

            var docData = new StringBuilder();

            docData.AppendLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
            docData.AppendLine("<Document>");
            docData.AppendLine($"   <Filename>{pdfFileName}</Filename>");

            foreach (var field in this.Fields)
            {
                docData.AppendLine($"   <{GetValidName(field.Name)}>{item.GetPropertyValue(field.Name)}</{GetValidName(field.Name)}>");
            }

            docData.AppendLine("</Document>");

            var outputFile = Path.Combine(this.OutputFolder, item.ID);

            File.WriteAllText(outputFile, docData.ToString(), Encoding.UTF8);

            var pdfOutputFile = Path.Combine(this.OutputFolder, pdfFileName);

            GenericPlugin.Utils.Helper.GeneratePDFToFile(documentPath, pdfOutputFile);
        }
        /// <summary>
        /// Looks for errors of the form
        /// "C:/MyProject/MyProject.build(40,3): error CS1000: 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 ParseCSharpError(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);
                    string description = String.Concat(match.Groups[6].Value, " (", match.Groups[5], ")");

                    TaskType taskType = TaskType.Error;
                    if (String.Compare(match.Groups[4].Value, "warning", true) == 0)
                    {
                        taskType = TaskType.Warning;
                    }
                    task = new SDTask(FileName.Create(match.Groups[1].Value), description, col, line, taskType);
                } catch (Exception) {
                    // Ignore.
                }
            }

            return(task);
        }
        public void Parse085()
        {
            TaskCollection tasks = NAntOutputParser.Parse(GetNAntOutput());

            Assert.AreEqual(3, tasks.Count, "Should be three tasks.");

            SDTask task = tasks[0];

            Assert.AreEqual("C:\\Projects\\dotnet\\test\\corsavyvbtest\\corsavyvbtest.build", task.FileName.ToString(), "Task filename is incorrect.");
            Assert.AreEqual(TaskType.Warning, task.TaskType, "Should be a warning task.");
            Assert.AreEqual(48, task.Line, "Incorrect line number.");
            Assert.AreEqual(6, task.Column, "Incorrect col number.");
            Assert.AreEqual("Attribute 'imports' for <vbc ... /> is deprecated.  Use the <imports> element instead.",
                            task.Description,
                            "Task description is wrong.");

            task = tasks[1];
            Assert.AreEqual("C:\\Projects\\dotnet\\test\\corsavyvbtest\\MainForm.vb", task.FileName.ToString(), "Task filename is incorrect.");
            Assert.AreEqual(TaskType.Error, task.TaskType, "Should be an error task.");
            Assert.AreEqual(14, task.Line, "Incorrect line number.");
            Assert.AreEqual(1, task.Column, "Should be col number 1");
            Assert.AreEqual("Syntax error. (BC30035)",
                            task.Description,
                            "Task description is wrong.");

            task = tasks[2];
            Assert.AreEqual("C:\\Projects\\dotnet\\test\\corsavyvbtest\\corsavyvbtest.build", task.FileName.ToString(), "Task filename is incorrect.");
            Assert.AreEqual(TaskType.Error, task.TaskType, "Should be an error task.");
            Assert.AreEqual(48, task.Line, "Incorrect line number.");
            Assert.AreEqual(6, task.Column, "Incorrect col number.");
            Assert.AreEqual("External Program Failed: C:\\WINDOWS\\Microsoft.NET\\Framework\\v1.1.4322\\vbc.exe (return code was 1)",
                            task.Description,
                            "Task description is wrong.");
        }
        /// <summary>
        /// Parses a single line of text looking for errors.
        /// </summary>
        /// <param name="textLine">A NAnt output line.</param>
        /// <returns>A <see cref="Task"/> if the line contains an error or
        /// a warning; otherwise <see langword="null"/>.</returns>
        static SDTask ParseLine(string textLine)
        {
            SDTask task = null;

            task = ParseCSharpError(textLine);

            if (task == null)
            {
                task = ParseVBError(textLine);
            }

            if (task == null)
            {
                task = ParseFatalError(textLine);
            }

            if (task == null)
            {
                task = ParseVBFatalError(textLine);
            }

            if (task == null)
            {
                task = ParseNAntWarning(textLine);
            }
            if (task == null)
            {
                task = ParseNAntError(textLine);
            }

            return(task);
        }
Exemplo n.º 6
0
        public void ParseVBError085()
        {
            TaskCollection tasks = NAntOutputParser.Parse(GetNAntVBOutput());

            Assert.AreEqual(3, tasks.Count, "Should be three tasks.");

            SDTask task = tasks[0];

            Assert.IsNull(task.FileName, "Task filename should be blank.");
            Assert.AreEqual(TaskType.Error, task.TaskType, "Should be an error task.");
            Assert.AreEqual(0, task.Line, "Should be line number 0.");
            Assert.AreEqual(0, task.Column, "Should be col number 0");
            Assert.AreEqual("Unable to write to output file 'C:\\Projects\\dotnet\\test\\corsavyvbtest\\bin\\Debug\\corsavyvbtest.exe': The process cannot access the file because it is being used by another process.  (BC31019)",
                            task.Description,
                            "Task description is wrong.");

            task = tasks[1];
            Assert.IsNull(task.FileName, "Task filename should be blank.");
            Assert.AreEqual(TaskType.Error, task.TaskType, "Should be an error task.");
            Assert.AreEqual(0, task.Line, "Should be line number 0.");
            Assert.AreEqual(0, task.Column, "Should be col number 0");
            Assert.AreEqual("Unable to write to output file 'C:\\Projects\\dotnet\\test\\corsavyvbtest\\bin\\Debug\\corsavyvbtest.pdb': Access is denied.  (BC31019)",
                            task.Description,
                            "Task description is wrong.");

            task = tasks[2];
            Assert.AreEqual("C:\\Projects\\dotnet\\test\\corsavyvbtest\\corsavyvbtest.build", task.FileName.ToString(), "Task filename is incorrect.");
            Assert.AreEqual(TaskType.Error, task.TaskType, "Should be an error task.");
            Assert.AreEqual(48, task.Line, "Incorrect line number.");
            Assert.AreEqual(6, task.Column, "Incorrect col number.");
            Assert.AreEqual("External Program Failed: C:\\WINDOWS\\Microsoft.NET\\Framework\\v1.1.4322\\vbc.exe (return code was 1)",
                            task.Description,
                            "Task description is wrong.");
        }
        public void Init()
        {
            TestResult testResult = new TestResult("MyNamespace.MyTests");

            testResult.ResultType = TestResultType.Failure;
            task = TestResultTask.Create(testResult, null);
        }
Exemplo n.º 8
0
        public void Parse085()
        {
            TaskCollection tasks = NAntOutputParser.Parse(GetNAntOutput());

            Assert.AreEqual(2, tasks.Count, "Should be two tasks.");

            SDTask task = tasks[0];

            Assert.AreEqual("C:\\Projects\\dotnet\\Test\\corsavytest\\corsavytest.build", task.FileName.ToString(), "Task filename is incorrect.");
            Assert.AreEqual(TaskType.Warning, task.TaskType, "Should be a warning task.");
            Assert.AreEqual(5, task.Line, "Incorrect line number.");
            Assert.AreEqual(4, task.Column, "Incorrect col number.");
            Assert.AreEqual("Attribute 'propertyexists' for <ifnot ... /> is deprecated.  Use <if test=\"${property::exists('propertyname')}\"> instead.",
                            task.Description,
                            "Task description is wrong.");

            task = tasks[1];
            Assert.AreEqual("C:\\Projects\\dotnet\\Test\\corsavytest\\corsavytest.build", task.FileName.ToString(), "Task filename is incorrect.");
            Assert.AreEqual(TaskType.Error, task.TaskType, "Should be an error task.");
            Assert.AreEqual(48, task.Line, "Incorrect line number.");
            Assert.AreEqual(6, task.Column, "Incorrect col number.");
            Assert.AreEqual("An empty string is not a valid value for attribute 'win32icon' of <csc ... />.",
                            task.Description,
                            "Task description is wrong.");
        }
Exemplo n.º 9
0
        public void ParseCscError085()
        {
            TaskCollection tasks = NAntOutputParser.Parse(GetNAntCscOutput());

            Assert.AreEqual(2, tasks.Count, "Should be two tasks.");

            SDTask task = tasks[0];

            Assert.IsNull(task.FileName, "Task filename should be blank.");
            Assert.AreEqual(TaskType.Error, task.TaskType, "Should be an error task.");
            Assert.AreEqual(0, task.Line, "Should be line number 0.");
            Assert.AreEqual(0, task.Column, "Should be col number 0");
            Assert.AreEqual("fatal error CS0042: Unexpected error creating debug information file 'c:\\Projects\\dotnet\\Test\\corsavytest\\bin\\Debug\\corsavytest.PDB' -- 'c:\\Projects\\dotnet\\Test\\corsavytest\\bin\\Debug\\corsavytest.pdb: The process cannot access the file because it is being used by another process.",
                            task.Description,
                            "Task description is wrong.");

            task = tasks[1];
            Assert.AreEqual("C:\\Projects\\dotnet\\Test\\corsavytest\\corsavytest.build", task.FileName.ToString(), "Task filename is incorrect.");
            Assert.AreEqual(TaskType.Error, task.TaskType, "Should be an error task.");
            Assert.AreEqual(48, task.Line, "Incorrect line number.");
            Assert.AreEqual(6, task.Column, "Incorrect col number.");
            Assert.AreEqual("External Program Failed: C:\\WINDOWS\\Microsoft.NET\\Framework\\v1.1.4322\\csc.exe (return code was 1)",
                            task.Description,
                            "Task description is wrong.");
        }
        /// <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);
        }
        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 IsMatchReturnsFalseWhenRhsTaskIsNull()
        {
            rhs = null;
            CreateTaskComparison();

            Assert.IsFalse(taskComparison.IsMatch);
        }
        public void IsMatchReturnsFalseWhenTaskTypesAreDifferent()
        {
            FileName fileName = new FileName(myTestFileName);

            lhs = new SDTask(fileName, description, column, line, TaskType.Warning);
            CreateTaskComparison();
            Assert.IsFalse(taskComparison.IsMatch);
        }
Exemplo n.º 14
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);
        }
        public void IsMatchReturnsFalseWhenColumnsAreDifferent()
        {
            FileName fileName = new FileName(myTestFileName);

            rhs = new SDTask(fileName, description, 500, line, TaskType.Error);
            CreateTaskComparison();
            Assert.IsFalse(taskComparison.IsMatch);
        }
        public void TaskComparisonIsMatchReturnsTrueWhenBothTasksAreNull()
        {
            lhs = null;
            rhs = null;
            CreateTaskComparison();

            Assert.IsTrue(taskComparison.IsMatch);
        }
Exemplo n.º 18
0
 void AddItem(SDTask item)
 {
     foreach (KeyValuePair <string, bool> pair in displayedTokens)
     {
         if (item.Description.StartsWith(pair.Key, StringComparison.Ordinal) && pair.Value && IsInScope(item))
         {
             tasks.Add(item);
         }
     }
 }
        public void ProcessTemplate_TemplateHostHasOneErrorAfterProcessing_ErrorTaskAddedToTaskList()
        {
            CreateGenerator(@"d:\a.tt");
            templatingHost.ErrorsCollection.Add(new CompilerError());
            generator.ProcessTemplate();

            SDTask task = customToolContext.FirstTaskAdded;

            Assert.AreEqual(TaskType.Error, task.TaskType);
        }
        public override void ProcessItem(SDTask item)
        {
            base.ProcessItem(item);

            this.ExtractCustomTableData(item);

            this.CheckConfidence(item);

            base.SetTaskData(item);
        }
Exemplo n.º 21
0
        void TaskViewMouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            SDTask    task    = taskView.SelectedItem as SDTask;
            var       item    = taskView.ItemContainerGenerator.ContainerFromItem(task) as ListViewItem;
            UIElement element = e.MouseDevice.DirectlyOver as UIElement;

            if (task != null && task.FileName != null && element != null && item != null &&
                element.IsDescendantOf(item))
            {
                SD.FileService.JumpToFilePosition(task.FileName, task.Line, task.Column);
            }
        }
        public void ProcessTemplate_ThrowsException_ErrorTaskAddedToTaskList()
        {
            CreateGenerator(@"d:\a.tt");
            var ex = new Exception("error");

            templatingHost.ExceptionToThrowWhenProcessTemplateCalled = ex;
            generator.ProcessTemplate();

            SDTask task = customToolContext.FirstTaskAdded;

            Assert.AreEqual("error", task.Description);
        }
        public void PreprocessTemplate_ProjectHasNoCodeDomProvider_WarningTaskAdded()
        {
            TestableFileProjectItem projectFile = CreatePreprocessor(@"d:\test.tt");

            projectFile.TestableProject.CodeDomProviderToReturn = null;

            preprocessor.PreprocessTemplate();

            SDTask task = customToolContext.FirstTaskAdded;

            Assert.AreEqual(TaskType.Warning, task.TaskType);
        }
        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);
        }
        public void ProcessTemplate_ThrowsInvalidOperationException_ErrorTaskAddedToTaskListWithTemplateFileName()
        {
            CreateGenerator(@"d:\a.tt");
            var ex = new InvalidOperationException("invalid operation error");

            templatingHost.ExceptionToThrowWhenProcessTemplateCalled = ex;
            generator.ProcessTemplate();

            SDTask task             = customToolContext.FirstTaskAdded;
            var    expectedFileName = new FileName(@"d:\a.tt");

            Assert.AreEqual(expectedFileName, task.FileName);
        }
        public void ProcessTemplate_TemplateHostHasOneErrorAfterProcessing_ErrorDescriptionIsAddedToTaskList()
        {
            CreateGenerator(@"d:\a.tt");
            var error = new CompilerError();

            error.ErrorText = "error text";
            templatingHost.ErrorsCollection.Add(error);
            generator.ProcessTemplate();

            SDTask task = customToolContext.FirstTaskAdded;

            Assert.AreEqual("error text", task.Description);
        }
        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);
        }
Exemplo n.º 28
0
        public override void SetActiveContext(SDTask task)
        {
            base.SetActiveContext(task);

            task.SetPropertyValue("ReviewAction", "");

            if (this.FieldsMapByFieldName.ContainsKey(Constants.Campos.VendorVAT))
            {
                // Forçar o focus inicial no primeiro campo
                var field = this.FieldsMapByFieldName[Constants.Campos.VendorVAT] as SDTextBox;
                field.Focus();
                field.TextBox.Focus();
                SmartFieldUserControl_OnHighlightEntity(field, field.Entity);
            }
        }
        /// <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);
        }
        public void Parse085()
        {
            TaskCollection tasks = NAntOutputParser.Parse(GetNAntOutput());

            Assert.AreEqual(1, tasks.Count, "Should be one task.");

            SDTask task = tasks[0];

            Assert.IsNull(task.FileName, "Should not have any filename information.");
            Assert.AreEqual(TaskType.Error, task.TaskType, "Should be an error task.");
            Assert.AreEqual(0, task.Line, "Should be line number 0");
            Assert.AreEqual(0, task.Column, "Should be col number 0");
            Assert.AreEqual("Target 'abuild' does not exist in this project.",
                            task.Description,
                            "Task description is wrong.");
        }
Exemplo n.º 31
0
        void AddTask(SDTask task)
        {
            switch (task.TaskType) {
                case TaskType.Warning:
                    if (!ShowWarnings) {
                        return;
                    }
                    break;
                case TaskType.Error:
                    if (!ShowErrors) {
                        return;
                    }
                    break;
                case TaskType.Message:
                    if (!ShowMessages) {
                        return;
                    }
                    break;
                default:
                    return;
            }

            errors.Add(task);
        }
Exemplo n.º 32
0
		IUnresolvedTypeDefinition GetCurrentClass(SDTask item)
		{
			// Tasks are created by parsing, so the parse information for item.FileName should already be present.
			// If they aren't, that's because the file might have been deleted/renamed in the meantime.
			// We use GetExistingParseInformation to avoid trying to parse a file that might have been deleted/renamed.
			IUnresolvedFile parseInfo = SD.ParserService.GetExistingUnresolvedFile(item.FileName);
			if (parseInfo != null) {
				var c = parseInfo.GetInnermostTypeDefinition(item.Line, item.Column);
				if (c != null) return c;
			}
			
			return null;
		}
Exemplo n.º 33
0
		bool IsInScope(SDTask item)
		{
			var current = GetCurrentClass();
			var itemClass = GetCurrentClass(item);
			
			switch (this.selectedScopeIndex) {
				case 0:
					// Solution
					if (ProjectService.OpenSolution != null) {
						foreach (IProject proj in ProjectService.OpenSolution.Projects) {
							if (proj.FindFile(item.FileName) != null)
								return true;
						}
					}
					return false;
				case 1:
					// Project
					return ProjectService.CurrentProject != null && ProjectService.CurrentProject.FindFile(item.FileName) != null;
				case 2:
					// All open files
					return SD.Workbench.ViewContentCollection.Select(vc => vc.GetService<ITextEditor>()).Any(editor => editor != null && item.FileName == editor.FileName);
				case 3:
					// File
					return SD.Workbench.ActiveViewContent != null && SD.Workbench.ActiveViewContent.PrimaryFileName == item.FileName;
				case 4:
					// Namespace
					return current != null && itemClass != null && current.Namespace == itemClass.Namespace;
				case 5:
					// Class/Module
					return current != null && itemClass != null && current == itemClass;
			}
			
			return true;
		}
Exemplo n.º 34
0
		void AddItem(SDTask item)
		{
			foreach (KeyValuePair<string, bool> pair in displayedTokens) {
				if (item.Description.StartsWith(pair.Key, StringComparison.Ordinal) && pair.Value && IsInScope(item))
					tasks.Add(item);
			}
		}