本文整理汇总了C#中SourceLocation.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# SourceLocation.ToString方法的具体用法?C# SourceLocation.ToString怎么用?C# SourceLocation.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SourceLocation
的用法示例。
在下文中一共展示了SourceLocation.ToString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddError
private void AddError(string type, SourceLocation startPosition, SourceLocation stopPosition, string errorMessage)
{
ListViewItem lvi = this.listErrors.Items.Add(type);
lvi.SubItems.Add(startPosition.ToString());
lvi.SubItems.Add(stopPosition.ToString());
lvi.SubItems.Add(errorMessage);
lvi.Tag = new SourceLocation[] {startPosition, stopPosition};
}
示例2: TestSourceLocationToString
public void TestSourceLocationToString()
{
string sampleProgram = @"using System;
class MainClass
{
static void Main()
{
#line 200
int i; // CS0168 on line 200
#line default
char c; // CS0168 on line 9
}
}
";
SyntaxTree syntaxTree = SyntaxFactory.ParseSyntaxTree(sampleProgram);
TextSpan span1 = new TextSpan(sampleProgram.IndexOf("i;"), 2);
TextSpan span2 = new TextSpan(sampleProgram.IndexOf("c;"), 2);
SourceLocation loc1 = new SourceLocation(syntaxTree, span1);
SourceLocation loc2 = new SourceLocation(syntaxTree, span2);
// GetDebuggerDisplay() is private
// Assert.Equal("SourceLocation(@8:13)\"i;\"", loc1.GetDebuggerDisplay());
Assert.Equal("SourceFile([91..93))", loc1.ToString());
// Assert.Equal("SourceLocation(@10:14)\"c;\"", loc2.GetDebuggerDisplay());
Assert.Equal("SourceFile([148..150))", loc2.ToString());
}
示例3: ToString
public new void ToString() {
SourceLocation loc = new SourceLocation("bar.cs", 47);
Assert.Equals("bar.cs, line 47", loc.ToString());
}
示例4: ReportError
private void ReportError(string message, SourceLocation start, SourceLocation end)
{
if (this.tabControl.SelectedTab == this.tabPageInstall)
{
ListViewItem lvi = this.listErrors.Items.Add(start.ToString());
lvi.SubItems.Add(end.ToString());
lvi.SubItems.Add(message);
lvi.Tag = new SourceLocation[] { start, end };
}
else
{
this.txtResult.Text = this.txtResult.Text +
String.Format("ERROR [{0} - {1}]: {2}\r\n", start, end, message);
}
}