Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
8134e597
R
roslyn
项目概览
lwm1986
/
roslyn
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
8134e597
编写于
2月 03, 2020
作者:
S
Sam Harwell
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add rationale for remaining suppressions
上级
b7025ccf
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
58 addition
and
93 deletion
+58
-93
src/Compilers/CSharp/Portable/Binder/Binder_Await.cs
src/Compilers/CSharp/Portable/Binder/Binder_Await.cs
+2
-2
src/Compilers/CSharp/Portable/Lowering/AsyncRewriter/AsyncRewriter.AsyncIteratorRewriter.cs
...ring/AsyncRewriter/AsyncRewriter.AsyncIteratorRewriter.cs
+3
-4
src/Compilers/Core/Portable/Syntax/SyntaxTree.cs
src/Compilers/Core/Portable/Syntax/SyntaxTree.cs
+2
-2
src/EditorFeatures/Core/Implementation/SmartIndent/IIndentationService.cs
...es/Core/Implementation/SmartIndent/IIndentationService.cs
+2
-2
src/Features/Core/Portable/EditAndContinue/AbstractEditAndContinueAnalyzer.cs
...rtable/EditAndContinue/AbstractEditAndContinueAnalyzer.cs
+1
-2
src/Workspaces/Core/Portable/Editing/DeclarationModifiers.cs
src/Workspaces/Core/Portable/Editing/DeclarationModifiers.cs
+2
-2
src/Workspaces/Core/Portable/Shared/TestHooks/IExpeditableDelaySource.cs
...Core/Portable/Shared/TestHooks/IExpeditableDelaySource.cs
+2
-2
src/Workspaces/Core/Portable/Shared/TestHooks/TaskExtensions.cs
...rkspaces/Core/Portable/Shared/TestHooks/TaskExtensions.cs
+3
-4
src/Workspaces/Core/Portable/Utilities/AsyncLazy`1.cs
src/Workspaces/Core/Portable/Utilities/AsyncLazy`1.cs
+1
-2
src/Workspaces/Core/Portable/Utilities/SimpleTaskQueue.cs
src/Workspaces/Core/Portable/Utilities/SimpleTaskQueue.cs
+5
-8
src/Workspaces/Core/Portable/Utilities/SpecializedTasks.cs
src/Workspaces/Core/Portable/Utilities/SpecializedTasks.cs
+10
-18
src/Workspaces/Core/Portable/Utilities/TaskExtensions.cs
src/Workspaces/Core/Portable/Utilities/TaskExtensions.cs
+14
-28
src/Workspaces/Core/Portable/Utilities/TaskFactoryExtensions.cs
...rkspaces/Core/Portable/Utilities/TaskFactoryExtensions.cs
+3
-5
src/Workspaces/Core/Portable/Workspace/Host/TaskScheduler/IWorkspaceTaskScheduler.cs
...e/Workspace/Host/TaskScheduler/IWorkspaceTaskScheduler.cs
+5
-8
src/Workspaces/Core/Portable/Workspace/Workspace.cs
src/Workspaces/Core/Portable/Workspace/Workspace.cs
+3
-4
未找到文件。
src/Compilers/CSharp/Portable/Binder/Binder_Await.cs
浏览文件 @
8134e597
...
...
@@ -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
;
...
...
src/Compilers/CSharp/Portable/Lowering/AsyncRewriter/AsyncRewriter.AsyncIteratorRewriter.cs
浏览文件 @
8134e597
...
...
@@ -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<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 */)
...
...
src/Compilers/Core/Portable/Syntax/SyntaxTree.cs
浏览文件 @
8134e597
...
...
@@ -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.
...
...
src/EditorFeatures/Core/Implementation/SmartIndent/IIndentationService.cs
浏览文件 @
8134e597
...
...
@@ -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
...
...
src/Features/Core/Portable/EditAndContinue/AbstractEditAndContinueAnalyzer.cs
浏览文件 @
8134e597
...
...
@@ -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
))
{
...
...
src/Workspaces/Core/Portable/Editing/DeclarationModifiers.cs
浏览文件 @
8134e597
...
...
@@ -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
));
}
...
...
src/Workspaces/Core/Portable/Shared/TestHooks/IExpeditableDelaySource.cs
浏览文件 @
8134e597
...
...
@@ -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
}
}
src/Workspaces/Core/Portable/Shared/TestHooks/TaskExtensions.cs
浏览文件 @
8134e597
...
...
@@ -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
)
{
...
...
src/Workspaces/Core/Portable/Utilities/AsyncLazy`1.cs
浏览文件 @
8134e597
...
...
@@ -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
)
{
...
...
src/Workspaces/Core/Portable/Utilities/SimpleTaskQueue.cs
浏览文件 @
8134e597
...
...
@@ -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
),
...
...
src/Workspaces/Core/Portable/Utilities/SpecializedTasks.cs
浏览文件 @
8134e597
...
...
@@ -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
);
}
...
...
src/Workspaces/Core/Portable/Utilities/TaskExtensions.cs
浏览文件 @
8134e597
...
...
@@ -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
,
...
...
src/Workspaces/Core/Portable/Utilities/TaskFactoryExtensions.cs
浏览文件 @
8134e597
...
...
@@ -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
()
{
...
...
src/Workspaces/Core/Portable/Workspace/Host/TaskScheduler/IWorkspaceTaskScheduler.cs
浏览文件 @
8134e597
...
...
@@ -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
}
}
src/Workspaces/Core/Portable/Workspace/Workspace.cs
浏览文件 @
8134e597
...
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录