本文整理匯總了C#中TestHelper.DiagnosticResult.Any方法的典型用法代碼示例。如果您正苦於以下問題:C# DiagnosticResult.Any方法的具體用法?C# DiagnosticResult.Any怎麽用?C# DiagnosticResult.Any使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類TestHelper.DiagnosticResult
的用法示例。
在下文中一共展示了DiagnosticResult.Any方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: VerifyDiagnosticsAsync
/// <summary>
/// General method that gets a collection of actual <see cref="Diagnostic"/>s found in the source after the
/// analyzer is run, then verifies each of them.
/// </summary>
/// <param name="sources">An array of strings to create source documents from to run the analyzers on.</param>
/// <param name="language">The language of the classes represented by the source strings.</param>
/// <param name="analyzers">The analyzers to be run on the source code.</param>
/// <param name="expected">A collection of <see cref="DiagnosticResult"/>s that should appear after the analyzer
/// is run on the sources.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that the task will observe.</param>
/// <param name="filenames">The filenames or null if the default filename should be used</param>
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
private async Task VerifyDiagnosticsAsync(string[] sources, string language, ImmutableArray<DiagnosticAnalyzer> analyzers, DiagnosticResult[] expected, CancellationToken cancellationToken, string[] filenames)
{
VerifyDiagnosticResults(await this.GetSortedDiagnosticsAsync(sources, language, analyzers, cancellationToken, filenames).ConfigureAwait(false), analyzers, expected);
// If filenames is null we want to test for exclusions too
if (filenames == null)
{
// Also check if the analyzer honors exclusions
if (expected.Any(x => x.Id.StartsWith("SA", StringComparison.Ordinal) || x.Id.StartsWith("SX", StringComparison.Ordinal)))
{
// We want to look at non-stylecop diagnostics only. We also insert a new line at the beginning
// so we have to move all diagnostic location down by one line
var expectedResults = expected
.Where(x => !x.Id.StartsWith("SA", StringComparison.Ordinal) && !x.Id.StartsWith("SX", StringComparison.Ordinal))
.Select(x => x.WithLineOffset(1))
.ToArray();
VerifyDiagnosticResults(await this.GetSortedDiagnosticsAsync(sources.Select(x => " // <auto-generated>\r\n" + x).ToArray(), language, analyzers, cancellationToken, null).ConfigureAwait(false), analyzers, expectedResults);
}
}
}
示例2: VerifyDiagnosticsAsync
/// <summary>
/// General method that gets a collection of actual <see cref="Diagnostic"/>s found in the source after the
/// analyzer is run, then verifies each of them.
/// </summary>
/// <param name="sources">An array of strings to create source documents from to run the analyzers on.</param>
/// <param name="language">The language of the classes represented by the source strings.</param>
/// <param name="analyzers">The analyzers to be run on the source code.</param>
/// <param name="expected">A collection of <see cref="DiagnosticResult"/>s that should appear after the analyzer
/// is run on the sources.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that the task will observe.</param>
/// <param name="filenames">The filenames or null if the default filename should be used</param>
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
private async Task VerifyDiagnosticsAsync(string[] sources, string language, ImmutableArray<DiagnosticAnalyzer> analyzers, DiagnosticResult[] expected, CancellationToken cancellationToken, string[] filenames)
{
VerifyDiagnosticResults(await this.GetSortedDiagnosticsAsync(sources, language, analyzers, cancellationToken, filenames).ConfigureAwait(false), analyzers, expected);
// If filenames is null we want to test for exclusions too
if (filenames == null)
{
// Also check if the analyzer honors exclusions
if (expected.Any(IsSubjectToExclusion))
{
// Diagnostics reported by the compiler and analyzer diagnostics which don't have a location will
// still be reported. We also insert a new line at the beginning so we have to move all diagnostic
// locations which have a specific position down by one line.
var expectedResults = expected
.Where(x => !IsSubjectToExclusion(x))
.Select(x => x.WithLineOffset(1))
.ToArray();
VerifyDiagnosticResults(await this.GetSortedDiagnosticsAsync(sources.Select(x => " // <auto-generated>\r\n" + x).ToArray(), language, analyzers, cancellationToken, null).ConfigureAwait(false), analyzers, expectedResults);
}
}
}