本文整理汇总了C#中System.CodeDom.Compiler.CompilerError类的典型用法代码示例。如果您正苦于以下问题:C# CompilerError类的具体用法?C# CompilerError怎么用?C# CompilerError使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CompilerError类属于System.CodeDom.Compiler命名空间,在下文中一共展示了CompilerError类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LogError
void LogError(CompilerError error)
{
if (error.IsWarning)
Log.LogWarning(null, error.ErrorNumber, null, error.FileName, error.Line, error.Column, 0, 0, error.ErrorText);
else
Log.LogError(null, error.ErrorNumber, null, error.FileName, error.Line, error.Column, 0, 0, error.ErrorText);
}
示例2: ParseLine
public CompilerError ParseLine(string line)
{
// try to match standard mono errors
Match match = normalError.Match(line);
if (match.Success) {
CompilerError error = new CompilerError();
error.Column = Int32.Parse(match.Result("${column}"));
error.Line = Int32.Parse(match.Result("${line}"));
error.FileName = Path.GetFullPath(match.Result("${file}"));
error.IsWarning = match.Result("${error}") == "warning";
error.ErrorNumber = match.Result("${number}");
error.ErrorText = match.Result("${message}");
return error;
} else {
match = generalError.Match(line);
if (match.Success) {
CompilerError error = new CompilerError();
error.IsWarning = match.Result("${error}") == "warning";
error.ErrorNumber = match.Result("${number}");
error.ErrorText = match.Result("${message}");
return error;
}
}
return null;
}
示例3: AppendError
private static void AppendError(StringBuilder message, CompilerError error, string[] lines)
{
message.AppendLine( error.ToString() );
if (error.Line <= 0)
{
return;
}
var line = error.Line - 1;
if( line - 1 > 0 )
{
message.AppendLine( string.Format("{0}: {1}", (line - 1).ToString( "0000", CultureInfo.CurrentUICulture ), lines[line - 1]) );
}
message.AppendLine( string.Format("{0}: {1}", (line - 1).ToString( "0000", CultureInfo.CurrentUICulture ), lines[line]) );
if( line + 1 < lines.Length )
{
message.AppendLine( string.Format("{0}: {1}", (line + 1).ToString( "0000", CultureInfo.CurrentUICulture ), lines[line + 1]) );
}
message.AppendLine();
}
示例4: TaskType_CompilerErrorIsNotWarning_ReturnsError
public void TaskType_CompilerErrorIsNotWarning_ReturnsError()
{
var error = new CompilerError();
var task = new CompilerErrorTask(error);
Assert.AreEqual(TaskType.Error, task.TaskType);
}
示例5: LogError
private void LogError(string fileName, string format, params object[] args)
{
var engineHost = (ITextTemplatingEngineHost)this.TextTemplating;
string errorText = string.Format(CultureInfo.CurrentCulture, format, args);
var error = new CompilerError { FileName = fileName, ErrorText = errorText };
engineHost.LogErrors(new CompilerErrorCollection(new[] { error }));
}
示例6: Warning
public void Warning (string message)
{
var err = new CompilerError (null, -1, -1, null, message) {
IsWarning = true,
};
Errors.Add (err);
}
示例7: CompilerConversionTestCase
public CompilerConversionTestCase(Type sourceType, Type targetType, CastFlag castFlag, string codeline = null, CompilerError compilerError = null)
{
this.SourceType = sourceType;
this.TargetType = targetType;
this.Codeline = codeline;
this.CompilerError = compilerError;
this.CastFlag = castFlag;
}
示例8: CompilerErrorTask
public CompilerErrorTask(CompilerError error)
: base(GetFileName(error.FileName),
error.ErrorText,
error.Column,
error.Line,
GetTaskType(error.IsWarning))
{
}
示例9: AddError
CompilerError AddError (string message)
{
CompilerError err = new CompilerError ();
err.Column = err.Line = -1;
err.ErrorText = message;
errors.Add (err);
return err;
}
示例10: TaskType_CompilerErrorIsWarning_ReturnsWarning
public void TaskType_CompilerErrorIsWarning_ReturnsWarning()
{
var error = new CompilerError();
error.IsWarning = true;
var task = new CompilerErrorTask(error);
Assert.AreEqual(TaskType.Warning, task.TaskType);
}
示例11: AddRange
/// <devdoc>
/// <para>Copies the elements of an array to the end of the <see cref='System.CodeDom.Compiler.CompilerErrorCollection'/>.</para>
/// </devdoc>
public void AddRange(CompilerError[] value) {
if (value == null) {
throw new ArgumentNullException("value");
}
for (int i = 0; ((i) < (value.Length)); i = ((i) + (1))) {
this.Add(value[i]);
}
}
示例12: Line_CompilerErrorLineIsThree_ReturnsThree
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);
}
示例13: FileName_CompilerErrorFileNameIsTestTxt_ReturnsTestTxt
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);
}
示例14: FormatCompilerError
private static string FormatCompilerError(CompilerError compilerError)
{
return string.Format(
"{0}, Line {1}: {2}",
compilerError.FileName,
compilerError.Line,
compilerError.ErrorText
);
}
示例15: BuildError
public BuildError (CompilerError error)
{
FileName = error.FileName;
Line = error.Line;
Column = error.Column;
ErrorNumber = error.ErrorNumber;
ErrorText = error.ErrorText;
IsWarning = error.IsWarning;
}