提交 8134e597 编写于 作者: S Sam Harwell

Add rationale for remaining suppressions

上级 b7025ccf
......@@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Syntax;
......@@ -134,9 +135,8 @@ private bool ContextForbidsAwait
/// Reports an error if the await expression did not occur in an async context.
/// </summary>
/// <returns>True if the expression contains errors.</returns>
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "'await without async' refers to the error scenario.")]
private bool ReportBadAwaitWithoutAsync(Location location, DiagnosticBag diagnostics)
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods
{
DiagnosticInfo info = null;
var containingMemberOrLambda = this.ContainingMemberOrLambda;
......
......@@ -4,6 +4,7 @@
using System.Collections.Immutable;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Microsoft.CodeAnalysis.CodeGen;
using Microsoft.CodeAnalysis.CSharp.Symbols;
......@@ -256,9 +257,8 @@ protected override BoundStatement GenerateStateMachineCreation(LocalSymbol state
/// <summary>
/// Generates the `ValueTask&lt;bool> MoveNextAsync()` method.
/// </summary>
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "Standard naming convention for generating 'IAsyncEnumerator.MoveNextAsync'")]
private void GenerateIAsyncEnumeratorImplementation_MoveNextAsync()
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods
{
// Produce:
// if (state == StateMachineStates.FinishedStateMachine)
......@@ -386,9 +386,8 @@ private void GenerateIAsyncEnumeratorImplementation_MoveNextAsync()
/// Generates the `ValueTask IAsyncDisposable.DisposeAsync()` method.
/// The DisposeAsync method should not be called from states -1 (running) or 0-and-up (awaits).
/// </summary>
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "Standard naming convention for generating 'IAsyncDisposable.DisposeAsync'")]
private void GenerateIAsyncDisposable_DisposeAsync()
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods
{
// Produce:
// if (state >= StateMachineStates.NotStartedStateMachine /* -3 */)
......
......@@ -6,6 +6,7 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Text;
using System.Threading;
......@@ -152,9 +153,8 @@ public Task<SyntaxNode> GetRootAsync(CancellationToken cancellationToken = defau
/// <summary>
/// Gets the root node of the syntax tree asynchronously.
/// </summary>
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "Public API.")]
protected abstract Task<SyntaxNode> GetRootAsyncCore(CancellationToken cancellationToken);
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods
/// <summary>
/// Create a new syntax tree based off this tree using a new source text.
......
......@@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.
using System;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Host;
......@@ -49,9 +50,8 @@ public IndentationResult(int basePosition, int offset) : this()
[Obsolete("Use Microsoft.CodeAnalysis.Indentation.IIndentationService instead.")]
internal interface IIndentationService : ILanguageService
{
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "This service is obsolete.")]
Task<IndentationResult?> GetDesiredIndentation(Document document, int lineNumber, CancellationToken cancellationToken);
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods
}
// Removal of this interface tracked with https://github.com/dotnet/roslyn/issues/35872
......
......@@ -594,9 +594,8 @@ protected virtual string GetSuspensionPointDisplayName(SyntaxNode node, EditKind
// so we stash them here in plain array (can't use immutable, see the bug) just before we report NFW.
private static ActiveStatement[]? s_fatalErrorBaseActiveStatements;
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "'AnalyzeDocumentAsync' is the name of the method where an error occurred.")]
private static bool ReportFatalErrorAnalyzeDocumentAsync(ImmutableArray<ActiveStatement> baseActiveStatements, Exception e)
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods
{
if (!(e is OperationCanceledException))
{
......
......@@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.
using System;
using System.Diagnostics.CodeAnalysis;
namespace Microsoft.CodeAnalysis.Editing
{
......@@ -147,9 +148,8 @@ public DeclarationModifiers WithPartial(bool isPartial)
return new DeclarationModifiers(SetFlag(_modifiers, Modifiers.Partial, isPartial));
}
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "Public API.")]
public DeclarationModifiers WithAsync(bool isAsync)
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods
{
return new DeclarationModifiers(SetFlag(_modifiers, Modifiers.Async, isAsync));
}
......
......@@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.
using System;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.Threading.Tasks;
......@@ -23,8 +24,7 @@ internal interface IExpeditableDelaySource
/// <para>The <paramref name="delay"/> argument's <see cref="TimeSpan.TotalMilliseconds"/> property is greater than <see cref="int.MaxValue"/>.</para>
/// </exception>
/// <exception cref="OperationCanceledException">The delay has been canceled.</exception>
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "Named after 'Task.Delay'")]
Task<bool> Delay(TimeSpan delay, CancellationToken cancellationToken);
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods
}
}
......@@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.
using System;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.Threading.Tasks;
using Roslyn.Utilities;
......@@ -11,9 +12,8 @@ namespace Microsoft.CodeAnalysis.Shared.TestHooks
{
internal static class TaskExtensions
{
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "This is a Task wrapper, not an asynchronous method.")]
public static Task CompletesAsyncOperation(this Task task, IAsyncToken asyncToken)
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods
{
if (asyncToken is AsynchronousOperationListener.DiagnosticAsyncToken diagnosticToken)
{
......@@ -26,9 +26,8 @@ public static Task CompletesAsyncOperation(this Task task, IAsyncToken asyncToke
[PerformanceSensitive(
"https://developercommunity.visualstudio.com/content/problem/854696/changing-target-framework-takes-10-minutes-with-10.html",
AllowCaptures = false)]
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "This is a Task wrapper, not an asynchronous method.")]
public static Task CompletesTrackingOperation(this Task task, IDisposable token)
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods
{
if (token == null || token == EmptyAsyncToken.Instance)
{
......
......@@ -480,9 +480,8 @@ private void CompleteWithTask(Task<T> task, CancellationToken cancellationToken)
}
}
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "This is a Task wrapper, not an asynchronous method.")]
private Task<T> GetCachedValueAndCacheThisValueIfNoneCached_NoLock(Task<T> task)
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods
{
if (_cachedResult != null)
{
......
......@@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.
using System;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.Threading.Tasks;
......@@ -50,9 +51,8 @@ public SimpleTaskQueue(TaskScheduler taskScheduler)
[PerformanceSensitive(
"https://developercommunity.visualstudio.com/content/problem/854696/changing-target-framework-takes-10-minutes-with-10.html",
AllowCaptures = false)]
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "This is a Task wrapper, not an asynchronous method.")]
public Task ScheduleTask(Action taskAction, CancellationToken cancellationToken = default)
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods
{
return ScheduleTaskWorker(
(delay, arg) => arg.Item1._latestTask.ContinueWithAfterDelay(arg.taskAction, arg.cancellationToken, delay, TaskContinuationOptions.None, arg.Item1._taskScheduler),
......@@ -62,9 +62,8 @@ public Task ScheduleTask(Action taskAction, CancellationToken cancellationToken
[PerformanceSensitive(
"https://developercommunity.visualstudio.com/content/problem/854696/changing-target-framework-takes-10-minutes-with-10.html",
AllowCaptures = false)]
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "This is a Task wrapper, not an asynchronous method.")]
public Task<T> ScheduleTask<T>(Func<T> taskFunc, CancellationToken cancellationToken = default)
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods
{
return ScheduleTaskWorker(
(delay, arg) => arg.Item1._latestTask.ContinueWithAfterDelay(arg.taskFunc, arg.cancellationToken, delay, TaskContinuationOptions.None, arg.Item1._taskScheduler),
......@@ -74,9 +73,8 @@ public Task<T> ScheduleTask<T>(Func<T> taskFunc, CancellationToken cancellationT
[PerformanceSensitive(
"https://developercommunity.visualstudio.com/content/problem/854696/changing-target-framework-takes-10-minutes-with-10.html",
AllowCaptures = false)]
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "This is a Task wrapper, not an asynchronous method.")]
public Task ScheduleTask(Func<Task> taskFuncAsync, CancellationToken cancellationToken = default)
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods
{
return ScheduleTaskWorker(
(delay, arg) => arg.Item1._latestTask.ContinueWithAfterDelayFromAsync(arg.taskFuncAsync, arg.cancellationToken, delay, TaskContinuationOptions.None, arg.Item1._taskScheduler),
......@@ -86,9 +84,8 @@ public Task ScheduleTask(Func<Task> taskFuncAsync, CancellationToken cancellatio
[PerformanceSensitive(
"https://developercommunity.visualstudio.com/content/problem/854696/changing-target-framework-takes-10-minutes-with-10.html",
AllowCaptures = false)]
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "This is a Task wrapper, not an asynchronous method.")]
public Task<T> ScheduleTask<T>(Func<Task<T>> taskFuncAsync, CancellationToken cancellationToken = default)
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods
{
return ScheduleTaskWorker(
(delay, arg) => arg.Item1._latestTask.ContinueWithAfterDelayFromAsync(arg.taskFuncAsync, arg.cancellationToken, delay, TaskContinuationOptions.None, arg.Item1._taskScheduler),
......
......@@ -7,6 +7,7 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
......@@ -21,44 +22,36 @@ internal static class SpecializedTasks
[Obsolete("Use Task.CompletedTask instead which is available in the framework.")]
public static readonly Task EmptyTask = Task.CompletedTask;
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "This is a Task wrapper, not an asynchronous method.")]
public static Task<T?> AsNullable<T>(this Task<T> task) where T : class
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods
=> task!;
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "This is a Task wrapper, not an asynchronous method.")]
public static Task<T> Default<T>() where T : struct
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods
=> TasksOfStruct<T>.Default;
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "This is a Task wrapper, not an asynchronous method.")]
public static Task<T?> Null<T>() where T : class
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods
=> TasksOfClass<T>.Null;
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "This is a Task wrapper, not an asynchronous method.")]
public static Task<IReadOnlyList<T>> EmptyReadOnlyList<T>()
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods
=> EmptyTasks<T>.EmptyReadOnlyList;
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "This is a Task wrapper, not an asynchronous method.")]
public static Task<IList<T>> EmptyList<T>()
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods
=> EmptyTasks<T>.EmptyList;
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "This is a Task wrapper, not an asynchronous method.")]
public static Task<ImmutableArray<T>> EmptyImmutableArray<T>()
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods
=> EmptyTasks<T>.EmptyImmutableArray;
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "This is a Task wrapper, not an asynchronous method.")]
public static Task<IEnumerable<T>> EmptyEnumerable<T>()
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods
=> EmptyTasks<T>.EmptyEnumerable;
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "This is a Task wrapper, not an asynchronous method.")]
public static Task<T> FromResult<T>(T t) where T : class
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods
=> FromResultCache<T>.FromResult(t);
private static class TasksOfStruct<T> where T : struct
......@@ -84,9 +77,8 @@ private static class FromResultCache<T> where T : class
private static readonly ConditionalWeakTable<T, Task<T>> s_fromResultCache = new ConditionalWeakTable<T, Task<T>>();
private static readonly ConditionalWeakTable<T, Task<T>>.CreateValueCallback s_taskCreationCallback = Task.FromResult<T>;
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "This is a Task wrapper, not an asynchronous method.")]
public static Task<T> FromResult(T t)
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods
{
return s_fromResultCache.GetValue(t, s_taskCreationCallback);
}
......
......@@ -110,9 +110,8 @@ public static T WaitAndGetResult_CanCallOnBackground<T>(this Task<T> task, Cance
// simply changing the default underlying behavior, but rejected that idea because there was
// a good chance that existing users had already drawn a dependency on the current behavior.
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "This is a Task wrapper, not an asynchronous method.")]
public static Task SafeContinueWith(
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods
this Task task,
Action<Task> continuationAction,
CancellationToken cancellationToken,
......@@ -130,9 +129,8 @@ bool continuationFunction(Task antecedent)
return task.SafeContinueWith(continuationFunction, cancellationToken, continuationOptions, scheduler);
}
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "This is a Task wrapper, not an asynchronous method.")]
public static Task<TResult> SafeContinueWith<TInput, TResult>(
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods
this Task<TInput> task,
Func<Task<TInput>, TResult> continuationFunction,
CancellationToken cancellationToken,
......@@ -142,9 +140,8 @@ bool continuationFunction(Task antecedent)
task, continuationFunction, cancellationToken, TaskContinuationOptions.None, scheduler);
}
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "This is a Task wrapper, not an asynchronous method.")]
public static Task<TResult> SafeContinueWith<TInput, TResult>(
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods
this Task<TInput> task,
Func<Task<TInput>, TResult> continuationFunction,
CancellationToken cancellationToken,
......@@ -157,9 +154,8 @@ bool continuationFunction(Task antecedent)
(Task antecedent) => continuationFunction((Task<TInput>)antecedent), cancellationToken, continuationOptions, scheduler);
}
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "This is a Task wrapper, not an asynchronous method.")]
public static Task SafeContinueWith<TInput>(
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods
this Task<TInput> task,
Action<Task<TInput>> continuationAction,
CancellationToken cancellationToken,
......@@ -172,9 +168,8 @@ bool continuationFunction(Task antecedent)
(Task antecedent) => continuationAction((Task<TInput>)antecedent), cancellationToken, continuationOptions, scheduler);
}
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "This is a Task wrapper, not an asynchronous method.")]
public static Task<TResult> SafeContinueWith<TResult>(
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods
this Task task,
Func<Task, TResult> continuationFunction,
CancellationToken cancellationToken,
......@@ -217,9 +212,8 @@ TResult outerFunction(Task t)
return task.ContinueWith(outerFunction, cancellationToken, continuationOptions | TaskContinuationOptions.LazyCancellation, scheduler);
}
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "This is a Task wrapper, not an asynchronous method.")]
public static Task<TResult> SafeContinueWith<TResult>(
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods
this Task task,
Func<Task, TResult> continuationFunction,
CancellationToken cancellationToken,
......@@ -228,9 +222,8 @@ TResult outerFunction(Task t)
return task.SafeContinueWith(continuationFunction, cancellationToken, TaskContinuationOptions.None, scheduler);
}
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "This is a Task wrapper, not an asynchronous method.")]
public static Task SafeContinueWith(
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods
this Task task,
Action<Task> continuationAction,
TaskScheduler scheduler)
......@@ -238,9 +231,8 @@ TResult outerFunction(Task t)
return task.SafeContinueWith(continuationAction, CancellationToken.None, TaskContinuationOptions.None, scheduler);
}
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "This is a Task wrapper, not an asynchronous method.")]
public static Task SafeContinueWith<TInput>(
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods
this Task<TInput> task,
Action<Task<TInput>> continuationFunction,
TaskScheduler scheduler)
......@@ -248,9 +240,8 @@ TResult outerFunction(Task t)
return task.SafeContinueWith(continuationFunction, CancellationToken.None, TaskContinuationOptions.None, scheduler);
}
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "This is a Task wrapper, not an asynchronous method.")]
public static Task<TResult> SafeContinueWith<TInput, TResult>(
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods
this Task<TInput> task,
Func<Task<TInput>, TResult> continuationFunction,
TaskScheduler scheduler)
......@@ -258,9 +249,8 @@ TResult outerFunction(Task t)
return task.SafeContinueWith(continuationFunction, CancellationToken.None, TaskContinuationOptions.None, scheduler);
}
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "This is a Task wrapper, not an asynchronous method.")]
public static Task SafeContinueWith(
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods
this Task task,
Action<Task> continuationAction,
CancellationToken cancellationToken,
......@@ -270,9 +260,8 @@ TResult outerFunction(Task t)
}
// Code provided by Stephen Toub.
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "This is a Task wrapper, not an asynchronous method.")]
public static Task<TResult> ContinueWithAfterDelay<TInput, TResult>(
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods
this Task<TInput> task,
Func<Task<TInput>, TResult> continuationFunction,
CancellationToken cancellationToken,
......@@ -288,9 +277,8 @@ TResult outerFunction(Task t)
cancellationToken, taskContinuationOptions, scheduler).Unwrap();
}
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "This is a Task wrapper, not an asynchronous method.")]
public static Task<TNResult> ContinueWithAfterDelay<TNResult>(
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods
this Task task,
Func<TNResult> continuationFunction,
CancellationToken cancellationToken,
......@@ -306,9 +294,8 @@ TResult outerFunction(Task t)
cancellationToken, taskContinuationOptions, scheduler).Unwrap();
}
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "This is a Task wrapper, not an asynchronous method.")]
public static Task<TNResult> ContinueWithAfterDelay<TNResult>(
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods
this Task task,
Func<Task, TNResult> continuationFunction,
CancellationToken cancellationToken,
......@@ -324,9 +311,8 @@ TResult outerFunction(Task t)
cancellationToken, taskContinuationOptions, scheduler).Unwrap();
}
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "This is a Task wrapper, not an asynchronous method.")]
public static Task ContinueWithAfterDelay(
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods
this Task task,
Action continuationAction,
CancellationToken cancellationToken,
......
......@@ -12,12 +12,11 @@ namespace Roslyn.Utilities
{
// TODO: revisit https://github.com/dotnet/roslyn/issues/39222
[SuppressMessage("ApiDesign", "CA1068", Justification = "Matching TPL Signatures")]
[SuppressMessage("ApiDesign", "CA1068:CancellationToken parameters must come last", Justification = "Matching TPL Signatures")]
internal static partial class TaskFactoryExtensions
{
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "This is a Task wrapper, not an asynchronous method.")]
public static Task SafeStartNew(this TaskFactory factory, Action action, CancellationToken cancellationToken, TaskScheduler scheduler)
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods
{
void wrapped()
{
......@@ -34,9 +33,8 @@ void wrapped()
return factory.StartNew(wrapped, cancellationToken, TaskCreationOptions.None, scheduler);
}
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "This is a Task wrapper, not an asynchronous method.")]
public static Task<TResult> SafeStartNew<TResult>(this TaskFactory factory, Func<TResult> func, CancellationToken cancellationToken, TaskScheduler scheduler)
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods
{
TResult wrapped()
{
......
......@@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.
using System;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.Threading.Tasks;
......@@ -16,32 +17,28 @@ internal interface IWorkspaceTaskScheduler
/// <summary>
/// Execute the task action on a thread owned by a task scheduler.
/// </summary>
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "This is a Task wrapper, not an asynchronous method.")]
Task ScheduleTask(Action taskAction, string taskName, CancellationToken cancellationToken = default);
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods
/// <summary>
/// Execute the task function on a thread owned by a task scheduler and return the schedule
/// task that can be used to wait for the result.
/// </summary>
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "This is a Task wrapper, not an asynchronous method.")]
Task<T> ScheduleTask<T>(Func<T> taskFunc, string taskName, CancellationToken cancellationToken = default);
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods
/// <summary>
/// Execute the task function on a thread owned by a task scheduler and return the schedule
/// task that can be used to wait for the result.
/// </summary>
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "This is a Task wrapper, not an asynchronous method.")]
Task ScheduleTask(Func<Task> taskFunc, string taskName, CancellationToken cancellationToken = default);
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods
/// <summary>
/// Execute the task function on a thread owned by a task scheduler and return the schedule
/// task that can be used to wait for the result.
/// </summary>
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "This is a Task wrapper, not an asynchronous method.")]
Task<T> ScheduleTask<T>(Func<Task<T>> taskFunc, string taskName, CancellationToken cancellationToken = default);
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods
}
}
......@@ -8,6 +8,7 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
......@@ -233,9 +234,8 @@ internal void UpdateCurrentSolutionOnOptionsChanged()
/// <summary>
/// Executes an action as a background task, as part of a sequential queue of tasks.
/// </summary>
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "This is a Task wrapper, not an asynchronous method.")]
protected internal Task ScheduleTask(Action action, string taskName = "Workspace.Task")
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods
{
return _taskQueue.ScheduleTask(action, taskName);
}
......@@ -243,9 +243,8 @@ protected internal Task ScheduleTask(Action action, string taskName = "Workspace
/// <summary>
/// Execute a function as a background task, as part of a sequential queue of tasks.
/// </summary>
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "This is a Task wrapper, not an asynchronous method.")]
protected internal Task<T> ScheduleTask<T>(Func<T> func, string taskName = "Workspace.Task")
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods
{
return _taskQueue.ScheduleTask(func, taskName);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册