本文整理汇总了C#中System.CodeDom.Compiler.CompilerError.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# CompilerError.ToString方法的具体用法?C# CompilerError.ToString怎么用?C# CompilerError.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.CodeDom.Compiler.CompilerError
的用法示例。
在下文中一共展示了CompilerError.ToString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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();
}
示例2: Constructor5_Deny_Unrestricted
public void Constructor5_Deny_Unrestricted ()
{
CompilerError ce = new CompilerError (fname, 1, 1, "cs0000", "error text");
Assert.IsTrue ((ce.ToString ().IndexOf (fname) >= 0), "ToString");
Assert.AreEqual (1, ce.Column, "Column");
ce.Column = Int32.MinValue;
Assert.AreEqual ("cs0000", ce.ErrorNumber, "ErrorNumber");
ce.ErrorNumber = String.Empty;
Assert.AreEqual ("error text", ce.ErrorText, "ErrorText");
ce.ErrorText = String.Empty;
Assert.AreEqual (fname, ce.FileName, "FileName");
ce.FileName = String.Empty;
Assert.IsFalse (ce.IsWarning, "IsWarning");
ce.IsWarning = true;
Assert.AreEqual (1, ce.Line, "Line");
ce.Line = Int32.MinValue;
}
示例3: Constructor0_Deny_Unrestricted
public void Constructor0_Deny_Unrestricted ()
{
CompilerError ce = new CompilerError ();
Assert.AreEqual (0, ce.Column, "Column");
ce.Column = 1;
Assert.AreEqual (String.Empty, ce.ErrorNumber, "ErrorNumber");
ce.ErrorNumber = "cs0000";
Assert.AreEqual (String.Empty, ce.ErrorText, "ErrorText");
ce.ErrorText = "error text";
Assert.AreEqual (String.Empty, ce.FileName, "FileName");
ce.FileName = fname;
Assert.IsFalse (ce.IsWarning, "IsWarning");
ce.IsWarning = true;
Assert.AreEqual (0, ce.Line, "Line");
ce.Line = 1;
Assert.IsNotNull (ce.ToString (), "ToString");
}
示例4: CompilerException
public CompilerException(CompilerError error)
: base(error.ToString())
{
}
示例5: HandleImportWarnings
private void HandleImportWarnings(ServiceDescriptionImportWarnings warnings)
{
// TODO: explicitly handle all of the warnings generated by the ServiceImporter
if (warnings != 0)
{
Trace.TraceError("Warnings: {0}", warnings);
StringBuilder exceptionMessage = new StringBuilder();
if ((warnings | ServiceDescriptionImportWarnings.NoCodeGenerated) == warnings)
{
CompilerError error = new CompilerError();
error.ErrorText = ErrorMessages.NoCodeGenerated;
error.IsWarning = false;
error.FileName = m_url;
error.ErrorNumber = "CG110";
Errors.Add(error);
exceptionMessage.AppendLine(error.ToString());
}
if ((warnings | ServiceDescriptionImportWarnings.NoMethodsGenerated) == warnings)
{
CompilerError error = new CompilerError();
error.ErrorText = ErrorMessages.NoMethodsGenerated;
error.IsWarning = false;
error.FileName = m_url;
error.ErrorNumber = "CG111";
Errors.Add(error);
exceptionMessage.AppendLine(error.ToString());
}
if ((warnings | ServiceDescriptionImportWarnings.OptionalExtensionsIgnored) == warnings)
{
CompilerError error = new CompilerError();
error.ErrorText = ErrorMessages.OptionalExtensionsIgnored;
error.IsWarning = true;
error.FileName = m_url;
error.ErrorNumber = "CG112";
Errors.Add(error);
}
if ((warnings | ServiceDescriptionImportWarnings.RequiredExtensionsIgnored) == warnings)
{
CompilerError error = new CompilerError();
error.ErrorText = ErrorMessages.RequiredExtensionsIgnored;
error.IsWarning = false;
error.FileName = m_url;
error.ErrorNumber = "CG113";
Errors.Add(error);
exceptionMessage.AppendLine(error.ToString());
}
if ((warnings | ServiceDescriptionImportWarnings.SchemaValidation) == warnings)
{
CompilerError error = new CompilerError();
error.ErrorText = ErrorMessages.SchemaValidation;
error.IsWarning = false;
error.FileName = m_url;
error.ErrorNumber = "CG114";
Errors.Add(error);
exceptionMessage.AppendLine(error.ToString());
}
if ((warnings | ServiceDescriptionImportWarnings.UnsupportedBindingsIgnored) == warnings)
{
CompilerError error = new CompilerError();
error.ErrorText = ErrorMessages.UnsupportedBindingsIgnored;
error.IsWarning = true;
error.FileName = m_url;
error.ErrorNumber = "CG115";
Errors.Add(error);
}
if ((warnings | ServiceDescriptionImportWarnings.UnsupportedOperationsIgnored) == warnings)
{
CompilerError error = new CompilerError();
error.ErrorText = ErrorMessages.UnsupportedOperationsIgnored;
error.IsWarning = true;
error.FileName = m_url;
error.ErrorNumber = "CG116";
Errors.Add(error);
}
if ((warnings | ServiceDescriptionImportWarnings.WsiConformance) == warnings)
{
CompilerError error = new CompilerError();
error.ErrorText = ErrorMessages.WsiConformance;
error.IsWarning = true;
error.FileName = m_url;
error.ErrorNumber = "CG117";
Errors.Add(error);
}
if (exceptionMessage.Length!=0)
{
throw new ApplicationException(string.Format("{0}; Warnings : {1}", exceptionMessage.ToString(), warnings));
}
else
{
//.........这里部分代码省略.........
示例6: GetCompileErrorLines
private static IEnumerable<string> GetCompileErrorLines( CompilerError error )
{
yield return error.ToString();
yield return File.ReadAllLines( error.FileName ).Skip( error.Line - 1 ).First();
}