本文整理汇总了C#中CSharpSyntaxNode.ErrorsAndWarnings方法的典型用法代码示例。如果您正苦于以下问题:C# CSharpSyntaxNode.ErrorsAndWarnings方法的具体用法?C# CSharpSyntaxNode.ErrorsAndWarnings怎么用?C# CSharpSyntaxNode.ErrorsAndWarnings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSharpSyntaxNode
的用法示例。
在下文中一共展示了CSharpSyntaxNode.ErrorsAndWarnings方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VerifyErrorSpecial
private void VerifyErrorSpecial(CSharpSyntaxNode node, DirectiveInfo expected)
{
var diags = node.ErrorsAndWarnings();
Assert.Equal(1, diags.Length);
var actual = diags[0];
Assert.Equal(expected.Number, actual.Code);
// warning or not
if (NodeStatus.IsWarning == (expected.Status & NodeStatus.IsWarning))
{
Assert.Equal(DiagnosticSeverity.Warning, actual.Severity);
}
// error message
if (expected.Text != null)
{
Assert.Equal(expected.Text, actual.GetMessage(CultureInfo.InvariantCulture));
}
}
示例2: VerifyDiagnostics
/// <summary>
/// Verifies that the errors on the given CSharpSyntaxNode match the expected error codes and types
/// </summary>
/// <param name="node">The node that has errors</param>
/// <param name="errors">The list of expected errors</param>
private void VerifyDiagnostics(CSharpSyntaxNode node, List<TestError> errors)
{
VerifyDiagnostics(node.ErrorsAndWarnings(), errors);
}
示例3: VerifyErrorCode
private void VerifyErrorCode(CSharpSyntaxNode node, params int[] expected)
{
var actual = node.ErrorsAndWarnings().Select(e => e.Code).ToList();
// no error
if ((expected.Length == 0) && (actual.Count == 0))
{
return;
}
// Parser might give more errors than expected & that's fine
Assert.InRange(actual.Count, expected.Length, int.MaxValue);
// necessary?
if (actual.Count < expected.Length)
{
return;
}
foreach (int i in expected)
{
Assert.Contains(i, actual); // no order
}
}