12 changed files with 338 additions and 21 deletions
@ -0,0 +1,39 @@
@@ -0,0 +1,39 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.CodeDom.Compiler; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop; |
||||
|
||||
namespace ICSharpCode.TextTemplating |
||||
{ |
||||
public class CompilerErrorTask : Task |
||||
{ |
||||
public CompilerErrorTask(CompilerError error) |
||||
: base( |
||||
GetFileName(error.FileName), |
||||
error.ErrorText, |
||||
error.Column, |
||||
error.Line, |
||||
GetTaskType(error.IsWarning)) |
||||
{ |
||||
} |
||||
|
||||
static TaskType GetTaskType(bool warning) |
||||
{ |
||||
if (warning) { |
||||
return TaskType.Warning; |
||||
} |
||||
return TaskType.Error; |
||||
} |
||||
|
||||
static FileName GetFileName(string fileName) |
||||
{ |
||||
if (!String.IsNullOrEmpty(fileName)) { |
||||
return new FileName(fileName); |
||||
} |
||||
return null; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,17 @@
@@ -0,0 +1,17 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.CodeDom.Compiler; |
||||
|
||||
namespace ICSharpCode.TextTemplating |
||||
{ |
||||
public class TemplatingHostProcessTemplateError : CompilerError |
||||
{ |
||||
public TemplatingHostProcessTemplateError(Exception ex, string fileName) |
||||
{ |
||||
this.ErrorText = ex.Message; |
||||
this.FileName = fileName; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,69 @@
@@ -0,0 +1,69 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.CodeDom.Compiler; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.TextTemplating; |
||||
using NUnit.Framework; |
||||
|
||||
namespace TextTemplating.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class CompilerErrorTaskTests |
||||
{ |
||||
[Test] |
||||
public void FileName_CompilerErrorFileNameIsTestTxt_ReturnsTestTxt() |
||||
{ |
||||
var error = new CompilerError(); |
||||
error.FileName = "test.txt"; |
||||
var task = new CompilerErrorTask(error); |
||||
|
||||
FileName expectedFileName = new FileName("test.txt"); |
||||
Assert.AreEqual(expectedFileName, task.FileName); |
||||
} |
||||
|
||||
[Test] |
||||
public void Column_CompilerErrorColumnIsTwo_ReturnsTwo() |
||||
{ |
||||
var error = new CompilerError(); |
||||
error.FileName = "test.txt"; |
||||
error.Line = 1; |
||||
error.Column = 2; |
||||
var task = new CompilerErrorTask(error); |
||||
|
||||
Assert.AreEqual(2, task.Column); |
||||
} |
||||
|
||||
[Test] |
||||
public void Line_CompilerErrorLineIsThree_ReturnsThree() |
||||
{ |
||||
var error = new CompilerError(); |
||||
error.FileName = "test.txt"; |
||||
error.Line = 3; |
||||
var task = new CompilerErrorTask(error); |
||||
|
||||
Assert.AreEqual(3, task.Line); |
||||
} |
||||
|
||||
[Test] |
||||
public void TaskType_CompilerErrorIsWarning_ReturnsWarning() |
||||
{ |
||||
var error = new CompilerError(); |
||||
error.IsWarning = true; |
||||
var task = new CompilerErrorTask(error); |
||||
|
||||
Assert.AreEqual(TaskType.Warning, task.TaskType); |
||||
} |
||||
|
||||
[Test] |
||||
public void TaskType_CompilerErrorIsNotWarning_ReturnsError() |
||||
{ |
||||
var error = new CompilerError(); |
||||
var task = new CompilerErrorTask(error); |
||||
|
||||
Assert.AreEqual(TaskType.Error, task.TaskType); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue