本文整理汇总了C#中IExtensionManager.PerformFunctionAsync方法的典型用法代码示例。如果您正苦于以下问题:C# IExtensionManager.PerformFunctionAsync方法的具体用法?C# IExtensionManager.PerformFunctionAsync怎么用?C# IExtensionManager.PerformFunctionAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IExtensionManager
的用法示例。
在下文中一共展示了IExtensionManager.PerformFunctionAsync方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AppendFixesOrSuppressionsAsync
private async Task<List<CodeFixCollection>> AppendFixesOrSuppressionsAsync(
Document document,
TextSpan span,
IEnumerable<Diagnostic> diagnosticsWithSameSpan,
List<CodeFixCollection> result,
object fixer,
IExtensionManager extensionManager,
Func<Diagnostic, bool> hasFix,
Func<ImmutableArray<Diagnostic>, Task<IEnumerable<CodeFix>>> getFixes,
CancellationToken cancellationToken)
{
var diagnostics = diagnosticsWithSameSpan.Where(d => hasFix(d)).OrderByDescending(d => d.Severity).ToImmutableArray();
if (diagnostics.Length <= 0)
{
// this can happen for suppression case where all diagnostics can't be suppressed
return result;
}
var fixes = await extensionManager.PerformFunctionAsync(fixer, () => getFixes(diagnostics)).ConfigureAwait(false);
if (fixes != null && fixes.Any())
{
FixAllCodeActionContext fixAllContext = null;
var codeFixProvider = fixer as CodeFixProvider;
if (codeFixProvider != null)
{
// If the codeFixProvider supports fix all occurrences, then get the corresponding FixAllProviderInfo and fix all context.
var fixAllProviderInfo = ImmutableInterlocked.GetOrAdd(ref _fixAllProviderMap, codeFixProvider, FixAllProviderInfo.Create);
if (fixAllProviderInfo != null)
{
fixAllContext = new FixAllCodeActionContext(document, fixAllProviderInfo, codeFixProvider, diagnostics, this.GetDocumentDiagnosticsAsync, this.GetProjectDiagnosticsAsync, cancellationToken);
}
}
result = result ?? new List<CodeFixCollection>();
var codeFix = new CodeFixCollection(fixer, span, fixes, fixAllContext);
result.Add(codeFix);
}
return result;
}