Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
9e64998d
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,发现更多精彩内容 >>
提交
9e64998d
编写于
8月 25, 2020
作者:
S
Sam Harwell
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use SpecializedTasks where appropriate
上级
bbd26ab8
变更
26
隐藏空白更改
内联
并排
Showing
26 changed file
with
47 addition
and
35 deletion
+47
-35
src/EditorFeatures/Core/Implementation/EditAndContinue/ActiveStatementTrackingService.cs
...ntation/EditAndContinue/ActiveStatementTrackingService.cs
+1
-1
src/EditorFeatures/Core/SymbolSearch/SymbolSearchUpdateEngineFactory.cs
...ures/Core/SymbolSearch/SymbolSearchUpdateEngineFactory.cs
+4
-3
src/Features/CSharp/Portable/Completion/KeywordRecommenders/DynamicKeywordRecommender.cs
...mpletion/KeywordRecommenders/DynamicKeywordRecommender.cs
+1
-1
src/Features/CSharp/Portable/Completion/KeywordRecommenders/NotnullKeywordRecommender.cs
...mpletion/KeywordRecommenders/NotnullKeywordRecommender.cs
+1
-1
src/Features/CSharp/Portable/Completion/KeywordRecommenders/UnmanagedKeywordRecommender.cs
...letion/KeywordRecommenders/UnmanagedKeywordRecommender.cs
+1
-1
src/Features/CSharp/Portable/Completion/KeywordRecommenders/VarKeywordRecommender.cs
...e/Completion/KeywordRecommenders/VarKeywordRecommender.cs
+1
-1
src/Features/Core/Portable/Completion/CommonCompletionProvider.cs
...ures/Core/Portable/Completion/CommonCompletionProvider.cs
+2
-1
src/Features/Core/Portable/Diagnostics/Analyzers/EditAndContinueDiagnosticAnalyzer.cs
...iagnostics/Analyzers/EditAndContinueDiagnosticAnalyzer.cs
+1
-1
src/Features/Core/Portable/Diagnostics/EngineV2/DiagnosticIncrementalAnalyzer_GetDiagnostics.cs
.../EngineV2/DiagnosticIncrementalAnalyzer_GetDiagnostics.cs
+1
-1
src/Features/Core/Portable/EditAndContinue/EditAndContinueWorkspaceService.cs
...rtable/EditAndContinue/EditAndContinueWorkspaceService.cs
+1
-1
src/Features/Core/Portable/ExternalAccess/VSTypeScript/VSTypeScriptDocumentDiagnosticAnalyzer.cs
...ss/VSTypeScript/VSTypeScriptDocumentDiagnosticAnalyzer.cs
+3
-2
src/Features/Core/Portable/ExternalAccess/VSTypeScript/VSTypeScriptProjectDiagnosticAnalyzer.cs
...ess/VSTypeScript/VSTypeScriptProjectDiagnosticAnalyzer.cs
+2
-1
src/Features/Core/Portable/InitializeParameter/AbstractInitializeMemberFromParameterCodeRefactoringProviderMemberCreation.cs
...mberFromParameterCodeRefactoringProviderMemberCreation.cs
+1
-1
src/Features/Core/Portable/SplitOrMergeIfStatements/Consecutive/AbstractMergeConsecutiveIfStatementsCodeRefactoringProvider.cs
...actMergeConsecutiveIfStatementsCodeRefactoringProvider.cs
+5
-4
src/Features/Core/Portable/SplitOrMergeIfStatements/Nested/AbstractMergeNestedIfStatementsCodeRefactoringProvider.cs
...AbstractMergeNestedIfStatementsCodeRefactoringProvider.cs
+3
-2
src/Features/Core/Portable/UpgradeProject/AbstractUpgradeProjectCodeFixProvider.cs
...e/UpgradeProject/AbstractUpgradeProjectCodeFixProvider.cs
+2
-1
src/Features/LanguageServer/Protocol/Handler/ProjectContext/GetTextDocumentWithContextHandler.cs
...ndler/ProjectContext/GetTextDocumentWithContextHandler.cs
+2
-1
src/Features/VisualBasic/Portable/CodeFixes/Async/VisualBasicAddAwaitCodeFixProvider.vb
...ble/CodeFixes/Async/VisualBasicAddAwaitCodeFixProvider.vb
+2
-2
src/Features/VisualBasic/Portable/CodeFixes/Iterator/VisualBasicChangeToYieldCodeFixProvider.vb
...Fixes/Iterator/VisualBasicChangeToYieldCodeFixProvider.vb
+1
-1
src/Features/VisualBasic/Portable/CodeRefactorings/SyncNamespace/VisualBasicChangeNamespaceService.vb
...orings/SyncNamespace/VisualBasicChangeNamespaceService.vb
+1
-1
src/Workspaces/CoreTestUtilities/Remote/InProcRemostHostClient.cs
...spaces/CoreTestUtilities/Remote/InProcRemostHostClient.cs
+1
-1
src/Workspaces/CoreTestUtilities/TestDynamicFileInfoProviderThatProducesNoFiles.cs
...ilities/TestDynamicFileInfoProviderThatProducesNoFiles.cs
+2
-1
src/Workspaces/Remote/Core/ServiceHubRemoteHostClient.cs
src/Workspaces/Remote/Core/ServiceHubRemoteHostClient.cs
+3
-1
src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/CustomCodeActions.cs
...dExtensions/Workspace/Core/CodeFixes/CustomCodeActions.cs
+2
-1
src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/FixAll/FixAllState.FixMultipleDiagnosticProvider.cs
...Fixes/FixAll/FixAllState.FixMultipleDiagnosticProvider.cs
+2
-2
src/Workspaces/VisualBasic/Portable/FindSymbols/VisualBasicReferenceFinder.vb
...lBasic/Portable/FindSymbols/VisualBasicReferenceFinder.vb
+1
-1
未找到文件。
src/EditorFeatures/Core/Implementation/EditAndContinue/ActiveStatementTrackingService.cs
浏览文件 @
9e64998d
...
...
@@ -96,7 +96,7 @@ public bool TryGetSpan(ActiveStatementId id, SourceText source, out TextSpan spa
}
public
Task
<
ImmutableArray
<
ActiveStatementTrackingSpan
>>
GetLatestSpansAsync
(
Document
document
,
ITextSnapshot
snapshot
,
CancellationToken
cancellationToken
)
=>
_session
?.
GetLatestSpansAsync
(
document
,
snapshot
,
cancellationToken
)
??
Task
.
FromResult
(
ImmutableArray
<
ActiveStatementTrackingSpan
>.
Empty
);
=>
_session
?.
GetLatestSpansAsync
(
document
,
snapshot
,
cancellationToken
)
??
SpecializedTasks
.
EmptyImmutableArray
<
ActiveStatementTrackingSpan
>(
);
// internal for testing
internal
sealed
class
TrackingSession
...
...
src/EditorFeatures/Core/SymbolSearch/SymbolSearchUpdateEngineFactory.cs
浏览文件 @
9e64998d
...
...
@@ -10,6 +10,7 @@
using
System.Threading
;
using
System.Threading.Tasks
;
using
Microsoft.CodeAnalysis.Remote
;
using
Roslyn.Utilities
;
namespace
Microsoft.CodeAnalysis.SymbolSearch
{
...
...
@@ -53,13 +54,13 @@ public static ISymbolSearchUpdateEngine CreateEngineInProcess(ISymbolSearchLogSe
private
sealed
class
NoOpUpdateEngine
:
ISymbolSearchUpdateEngine
{
public
Task
<
ImmutableArray
<
PackageWithAssemblyResult
>>
FindPackagesWithAssemblyAsync
(
string
source
,
string
assemblyName
,
CancellationToken
cancellationToken
)
=>
Task
.
FromResult
(
ImmutableArray
<
PackageWithAssemblyResult
>.
Empty
);
=>
SpecializedTasks
.
EmptyImmutableArray
<
PackageWithAssemblyResult
>(
);
public
Task
<
ImmutableArray
<
PackageWithTypeResult
>>
FindPackagesWithTypeAsync
(
string
source
,
string
name
,
int
arity
,
CancellationToken
cancellationToken
)
=>
Task
.
FromResult
(
ImmutableArray
<
PackageWithTypeResult
>.
Empty
);
=>
SpecializedTasks
.
EmptyImmutableArray
<
PackageWithTypeResult
>(
);
public
Task
<
ImmutableArray
<
ReferenceAssemblyWithTypeResult
>>
FindReferenceAssembliesWithTypeAsync
(
string
name
,
int
arity
,
CancellationToken
cancellationToken
)
=>
Task
.
FromResult
(
ImmutableArray
<
ReferenceAssemblyWithTypeResult
>.
Empty
);
=>
SpecializedTasks
.
EmptyImmutableArray
<
ReferenceAssemblyWithTypeResult
>(
);
public
Task
UpdateContinuouslyAsync
(
string
sourceName
,
string
localSettingsDirectory
)
=>
Task
.
CompletedTask
;
...
...
src/Features/CSharp/Portable/Completion/KeywordRecommenders/DynamicKeywordRecommender.cs
浏览文件 @
9e64998d
...
...
@@ -32,7 +32,7 @@ public Task<IEnumerable<RecommendedKeyword>> RecommendKeywordsAsync(int position
return
Task
.
FromResult
(
SpecializedCollections
.
SingletonEnumerable
(
new
RecommendedKeyword
(
"dynamic"
)));
}
return
Task
.
FromResult
<
IEnumerable
<
RecommendedKeyword
>>(
null
);
return
SpecializedTasks
.
Null
<
IEnumerable
<
RecommendedKeyword
>>(
);
}
protected
static
bool
IsDynamicTypeContext
(
...
...
src/Features/CSharp/Portable/Completion/KeywordRecommenders/NotnullKeywordRecommender.cs
浏览文件 @
9e64998d
...
...
@@ -20,7 +20,7 @@ public Task<IEnumerable<RecommendedKeyword>> RecommendKeywordsAsync(int position
return
Task
.
FromResult
(
SpecializedCollections
.
SingletonEnumerable
(
new
RecommendedKeyword
(
"notnull"
)));
}
return
Task
.
FromResult
<
IEnumerable
<
RecommendedKeyword
>>(
null
);
return
SpecializedTasks
.
Null
<
IEnumerable
<
RecommendedKeyword
>>(
);
}
}
}
src/Features/CSharp/Portable/Completion/KeywordRecommenders/UnmanagedKeywordRecommender.cs
浏览文件 @
9e64998d
...
...
@@ -20,7 +20,7 @@ public Task<IEnumerable<RecommendedKeyword>> RecommendKeywordsAsync(int position
return
Task
.
FromResult
(
SpecializedCollections
.
SingletonEnumerable
(
new
RecommendedKeyword
(
"unmanaged"
)));
}
return
Task
.
FromResult
<
IEnumerable
<
RecommendedKeyword
>>(
null
);
return
SpecializedTasks
.
Null
<
IEnumerable
<
RecommendedKeyword
>>(
);
}
}
}
src/Features/CSharp/Portable/Completion/KeywordRecommenders/VarKeywordRecommender.cs
浏览文件 @
9e64998d
...
...
@@ -37,7 +37,7 @@ public Task<IEnumerable<RecommendedKeyword>> RecommendKeywordsAsync(int position
return
Task
.
FromResult
(
SpecializedCollections
.
SingletonEnumerable
(
new
RecommendedKeyword
(
"var"
)));
}
return
Task
.
FromResult
<
IEnumerable
<
RecommendedKeyword
>>(
null
);
return
SpecializedTasks
.
Null
<
IEnumerable
<
RecommendedKeyword
>>(
);
}
}
}
src/Features/Core/Portable/Completion/CommonCompletionProvider.cs
浏览文件 @
9e64998d
...
...
@@ -13,6 +13,7 @@
using
Microsoft.CodeAnalysis.Shared.Extensions
;
using
Microsoft.CodeAnalysis.Snippets
;
using
Microsoft.CodeAnalysis.Text
;
using
Roslyn.Utilities
;
namespace
Microsoft.CodeAnalysis.Completion
{
...
...
@@ -92,7 +93,7 @@ public override async Task<CompletionChange> GetChangeAsync(Document document, C
=>
GetTextChangeAsync
(
selectedItem
,
ch
,
cancellationToken
);
protected
virtual
Task
<
TextChange
?>
GetTextChangeAsync
(
CompletionItem
selectedItem
,
char
?
ch
,
CancellationToken
cancellationToken
)
=>
Task
.
FromResult
<
TextChange
?>(
null
);
=>
SpecializedTasks
.
Default
<
TextChange
?>(
);
private
static
readonly
CompletionItemRules
s_suggestionItemRules
=
CompletionItemRules
.
Create
(
enterKeyRule
:
EnterKeyRule
.
Never
);
...
...
src/Features/Core/Portable/Diagnostics/Analyzers/EditAndContinueDiagnosticAnalyzer.cs
浏览文件 @
9e64998d
...
...
@@ -33,7 +33,7 @@ public override Task<ImmutableArray<Diagnostic>> AnalyzeSyntaxAsync(Document doc
public
override
Task
<
ImmutableArray
<
Diagnostic
>>
AnalyzeSemanticsAsync
(
Document
document
,
CancellationToken
cancellationToken
)
{
var
encService
=
document
.
Project
.
Solution
.
Workspace
.
Services
.
GetService
<
IEditAndContinueWorkspaceService
>();
return
(
encService
!=
null
)
?
encService
.
GetDocumentDiagnosticsAsync
(
document
,
cancellationToken
)
:
Task
.
FromResult
(
ImmutableArray
<
Diagnostic
>.
Empty
);
return
(
encService
!=
null
)
?
encService
.
GetDocumentDiagnosticsAsync
(
document
,
cancellationToken
)
:
SpecializedTasks
.
EmptyImmutableArray
<
Diagnostic
>(
);
}
}
}
src/Features/Core/Portable/Diagnostics/EngineV2/DiagnosticIncrementalAnalyzer_GetDiagnostics.cs
浏览文件 @
9e64998d
...
...
@@ -20,7 +20,7 @@ public Task<ImmutableArray<DiagnosticData>> GetSpecificCachedDiagnosticsAsync(So
{
if
(!(
id
is
LiveDiagnosticUpdateArgsId
argsId
))
{
return
Task
.
FromResult
(
ImmutableArray
<
DiagnosticData
>.
Empty
);
return
SpecializedTasks
.
EmptyImmutableArray
<
DiagnosticData
>(
);
}
var
(
documentId
,
projectId
)
=
(
argsId
.
ProjectOrDocumentId
is
DocumentId
docId
)
?
(
docId
,
docId
.
ProjectId
)
:
(
null
,
(
ProjectId
)
argsId
.
ProjectOrDocumentId
);
...
...
src/Features/Core/Portable/EditAndContinue/EditAndContinueWorkspaceService.cs
浏览文件 @
9e64998d
...
...
@@ -365,7 +365,7 @@ public Task<bool> HasChangesAsync(Solution solution, string? sourceFilePath, Can
var
editSession
=
_editSession
;
if
(
editSession
==
null
)
{
return
Task
.
FromResult
(
false
)
;
return
SpecializedTasks
.
False
;
}
return
editSession
.
HasChangesAsync
(
solution
,
sourceFilePath
,
cancellationToken
);
...
...
src/Features/Core/Portable/ExternalAccess/VSTypeScript/VSTypeScriptDocumentDiagnosticAnalyzer.cs
浏览文件 @
9e64998d
...
...
@@ -8,6 +8,7 @@
using
System.Threading
;
using
System.Threading.Tasks
;
using
Microsoft.CodeAnalysis.Diagnostics
;
using
Roslyn.Utilities
;
namespace
Microsoft.CodeAnalysis.ExternalAccess.VSTypeScript
{
...
...
@@ -21,7 +22,7 @@ public override Task<ImmutableArray<Diagnostic>> AnalyzeSyntaxAsync(Document doc
var
analyzer
=
document
.
Project
.
LanguageServices
.
GetRequiredService
<
VSTypeScriptDiagnosticAnalyzerLanguageService
>().
Implementation
;
if
(
analyzer
==
null
)
{
return
Task
.
FromResult
(
ImmutableArray
<
Diagnostic
>.
Empty
);
return
SpecializedTasks
.
EmptyImmutableArray
<
Diagnostic
>(
);
}
return
analyzer
.
AnalyzeDocumentSyntaxAsync
(
document
,
cancellationToken
);
...
...
@@ -32,7 +33,7 @@ public override Task<ImmutableArray<Diagnostic>> AnalyzeSemanticsAsync(Document
var
analyzer
=
document
.
Project
.
LanguageServices
.
GetRequiredService
<
VSTypeScriptDiagnosticAnalyzerLanguageService
>().
Implementation
;
if
(
analyzer
==
null
)
{
return
Task
.
FromResult
(
ImmutableArray
<
Diagnostic
>.
Empty
);
return
SpecializedTasks
.
EmptyImmutableArray
<
Diagnostic
>(
);
}
return
analyzer
.
AnalyzeDocumentSemanticsAsync
(
document
,
cancellationToken
);
...
...
src/Features/Core/Portable/ExternalAccess/VSTypeScript/VSTypeScriptProjectDiagnosticAnalyzer.cs
浏览文件 @
9e64998d
...
...
@@ -8,6 +8,7 @@
using
System.Threading
;
using
System.Threading.Tasks
;
using
Microsoft.CodeAnalysis.Diagnostics
;
using
Roslyn.Utilities
;
namespace
Microsoft.CodeAnalysis.ExternalAccess.VSTypeScript
{
...
...
@@ -21,7 +22,7 @@ public override Task<ImmutableArray<Diagnostic>> AnalyzeProjectAsync(Project pro
var
analyzer
=
project
.
LanguageServices
.
GetRequiredService
<
VSTypeScriptDiagnosticAnalyzerLanguageService
>().
Implementation
;
if
(
analyzer
==
null
)
{
return
Task
.
FromResult
(
ImmutableArray
<
Diagnostic
>.
Empty
);
return
SpecializedTasks
.
EmptyImmutableArray
<
Diagnostic
>(
);
}
return
analyzer
.
AnalyzeProjectAsync
(
project
,
cancellationToken
);
...
...
src/Features/Core/Portable/InitializeParameter/AbstractInitializeMemberFromParameterCodeRefactoringProviderMemberCreation.cs
浏览文件 @
9e64998d
...
...
@@ -51,7 +51,7 @@ internal abstract partial class AbstractInitializeMemberFromParameterCodeRefacto
Document
document
,
SyntaxNode
functionDeclaration
,
IMethodSymbol
method
,
IBlockOperation
?
blockStatementOpt
,
ImmutableArray
<
SyntaxNode
>
listOfParameterNodes
,
TextSpan
parameterSpan
,
CancellationToken
cancellationToken
)
{
return
Task
.
FromResult
(
ImmutableArray
<
CodeAction
>.
Empty
);
return
SpecializedTasks
.
EmptyImmutableArray
<
CodeAction
>(
);
}
protected
override
async
Task
<
ImmutableArray
<
CodeAction
>>
GetRefactoringsForSingleParameterAsync
(
...
...
src/Features/Core/Portable/SplitOrMergeIfStatements/Consecutive/AbstractMergeConsecutiveIfStatementsCodeRefactoringProvider.cs
浏览文件 @
9e64998d
...
...
@@ -14,6 +14,7 @@
using
Microsoft.CodeAnalysis.LanguageServices
;
using
Microsoft.CodeAnalysis.Shared.Extensions
;
using
Microsoft.CodeAnalysis.Utilities
;
using
Roslyn.Utilities
;
namespace
Microsoft.CodeAnalysis.SplitOrMergeIfStatements
{
...
...
@@ -52,7 +53,7 @@ protected sealed override CodeAction CreateCodeAction(Func<CancellationToken, Ta
var
ifGenerator
=
document
.
GetLanguageService
<
IIfLikeStatementGenerator
>();
if
(
CanBeMergedWithParent
(
syntaxFacts
,
ifGenerator
,
ifOrElseIf
,
out
firstIfOrElseIf
))
return
Task
.
FromResult
(
true
)
;
return
SpecializedTasks
.
True
;
return
CanBeMergedWithPreviousStatementAsync
(
document
,
syntaxFacts
,
ifGenerator
,
ifOrElseIf
,
cancellationToken
,
out
firstIfOrElseIf
);
}
...
...
@@ -64,7 +65,7 @@ protected sealed override CodeAction CreateCodeAction(Func<CancellationToken, Ta
var
ifGenerator
=
document
.
GetLanguageService
<
IIfLikeStatementGenerator
>();
if
(
CanBeMergedWithElseIf
(
syntaxFacts
,
ifGenerator
,
ifOrElseIf
,
out
secondIfOrElseIf
))
return
Task
.
FromResult
(
true
)
;
return
SpecializedTasks
.
True
;
return
CanBeMergedWithNextStatementAsync
(
document
,
syntaxFacts
,
ifGenerator
,
ifOrElseIf
,
cancellationToken
,
out
secondIfOrElseIf
);
}
...
...
@@ -154,7 +155,7 @@ protected sealed override SyntaxNode GetChangedRoot(Document document, SyntaxNod
{
return
TryGetSiblingStatement
(
syntaxFacts
,
ifOrElseIf
,
relativeIndex
:
-
1
,
out
previousStatement
)
?
CanStatementsBeMergedAsync
(
document
,
syntaxFacts
,
ifGenerator
,
previousStatement
,
ifOrElseIf
,
cancellationToken
)
:
Task
.
FromResult
(
false
)
;
:
SpecializedTasks
.
False
;
}
private
static
Task
<
bool
>
CanBeMergedWithNextStatementAsync
(
...
...
@@ -167,7 +168,7 @@ protected sealed override SyntaxNode GetChangedRoot(Document document, SyntaxNod
{
return
TryGetSiblingStatement
(
syntaxFacts
,
ifOrElseIf
,
relativeIndex
:
1
,
out
nextStatement
)
?
CanStatementsBeMergedAsync
(
document
,
syntaxFacts
,
ifGenerator
,
ifOrElseIf
,
nextStatement
,
cancellationToken
)
:
Task
.
FromResult
(
false
)
;
:
SpecializedTasks
.
False
;
}
private
static
async
Task
<
bool
>
CanStatementsBeMergedAsync
(
...
...
src/Features/Core/Portable/SplitOrMergeIfStatements/Nested/AbstractMergeNestedIfStatementsCodeRefactoringProvider.cs
浏览文件 @
9e64998d
...
...
@@ -13,6 +13,7 @@
using
Microsoft.CodeAnalysis.LanguageServices
;
using
Microsoft.CodeAnalysis.Shared.Extensions
;
using
Microsoft.CodeAnalysis.Utilities
;
using
Roslyn.Utilities
;
namespace
Microsoft.CodeAnalysis.SplitOrMergeIfStatements
{
...
...
@@ -40,7 +41,7 @@ protected sealed override CodeAction CreateCodeAction(Func<CancellationToken, Ta
var
ifGenerator
=
document
.
GetLanguageService
<
IIfLikeStatementGenerator
>();
if
(!
IsFirstStatementOfIfOrElseIf
(
syntaxFacts
,
ifGenerator
,
ifOrElseIf
,
out
outerIfOrElseIf
))
return
Task
.
FromResult
(
false
)
;
return
SpecializedTasks
.
False
;
return
CanBeMergedAsync
(
document
,
syntaxFacts
,
ifGenerator
,
outerIfOrElseIf
,
ifOrElseIf
,
cancellationToken
);
}
...
...
@@ -52,7 +53,7 @@ protected sealed override CodeAction CreateCodeAction(Func<CancellationToken, Ta
var
ifGenerator
=
document
.
GetLanguageService
<
IIfLikeStatementGenerator
>();
if
(!
IsFirstStatementIfStatement
(
syntaxFacts
,
ifGenerator
,
ifOrElseIf
,
out
innerIfStatement
))
return
Task
.
FromResult
(
false
)
;
return
SpecializedTasks
.
False
;
return
CanBeMergedAsync
(
document
,
syntaxFacts
,
ifGenerator
,
ifOrElseIf
,
innerIfStatement
,
cancellationToken
);
}
...
...
src/Features/Core/Portable/UpgradeProject/AbstractUpgradeProjectCodeFixProvider.cs
浏览文件 @
9e64998d
...
...
@@ -10,6 +10,7 @@
using
System.Threading.Tasks
;
using
Microsoft.CodeAnalysis.CodeActions
;
using
Microsoft.CodeAnalysis.CodeFixes
;
using
Roslyn.Utilities
;
using
static
Microsoft
.
CodeAnalysis
.
CodeActions
.
CodeAction
;
namespace
Microsoft.CodeAnalysis.UpgradeProject
...
...
@@ -100,6 +101,6 @@ public ProjectOptionsChangeAction(string title, Func<CancellationToken, Task<Sol
}
protected
override
Task
<
IEnumerable
<
CodeActionOperation
>>
ComputePreviewOperationsAsync
(
CancellationToken
cancellationToken
)
=>
Task
.
FromResult
(
Enumerable
.
Empty
<
CodeActionOperation
>()
);
=>
SpecializedTasks
.
EmptyEnumerable
<
CodeActionOperation
>(
);
}
}
src/Features/LanguageServer/Protocol/Handler/ProjectContext/GetTextDocumentWithContextHandler.cs
浏览文件 @
9e64998d
...
...
@@ -13,6 +13,7 @@
using
Microsoft.CodeAnalysis.Host.Mef
;
using
Microsoft.CodeAnalysis.Shared.Extensions
;
using
Microsoft.VisualStudio.LanguageServer.Protocol
;
using
Roslyn.Utilities
;
namespace
Microsoft.CodeAnalysis.LanguageServer.Handler
{
...
...
@@ -32,7 +33,7 @@ public GetTextDocumentWithContextHandler(ILspSolutionProvider solutionProvider)
if
(!
documents
.
Any
())
{
return
Task
.
FromResult
<
ActiveProjectContexts
?>(
null
);
return
SpecializedTasks
.
Null
<
ActiveProjectContexts
>(
);
}
var
contexts
=
new
List
<
ProjectContext
>();
...
...
src/Features/VisualBasic/Portable/CodeFixes/Async/VisualBasicAddAwaitCodeFixProvider.vb
浏览文件 @
9e64998d
...
...
@@ -56,12 +56,12 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeFixes.Async
Select
Case
diagnostic
.
Id
Case
BC30311
If
Not
DoesExpressionReturnGenericTaskWhoseArgumentsMatchLeftSide
(
expression
,
semanticModel
,
document
.
Project
,
cancellationToken
)
Then
Return
Task
.
FromResult
(
Of
SyntaxNode
)(
Nothing
)
Return
SpecializedTasks
.
Null
(
Of
SyntaxNode
)(
)
End
If
Return
Task
.
FromResult
(
root
.
ReplaceNode
(
oldNode
,
ConverToAwaitExpression
(
expression
)))
Case
BC37055
If
Not
DoesExpressionReturnTask
(
expression
,
semanticModel
)
Then
Return
Task
.
FromResult
(
Of
SyntaxNode
)(
Nothing
)
Return
SpecializedTasks
.
Null
(
Of
SyntaxNode
)(
)
End
If
Return
Task
.
FromResult
(
root
.
ReplaceNode
(
oldNode
,
ConverToAwaitExpression
(
expression
)))
Case
BC42358
...
...
src/Features/VisualBasic/Portable/CodeFixes/Iterator/VisualBasicChangeToYieldCodeFixProvider.vb
浏览文件 @
9e64998d
...
...
@@ -35,7 +35,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeFixes.Iterator
Protected
Overrides
Function
GetCodeFixAsync
(
root
As
SyntaxNode
,
node
As
SyntaxNode
,
document
As
Document
,
diagnostics
As
Diagnostic
,
cancellationToken
As
CancellationToken
)
As
Task
(
Of
CodeAction
)
If
Not
node
.
IsKind
(
SyntaxKind
.
ReturnStatement
)
Then
Return
Task
.
FromResult
(
Of
CodeAction
)(
Nothing
)
Return
SpecializedTasks
.
Null
(
Of
CodeAction
)(
)
End
If
Dim
returnStatement
=
TryCast
(
node
,
ReturnStatementSyntax
)
...
...
src/Features/VisualBasic/Portable/CodeRefactorings/SyncNamespace/VisualBasicChangeNamespaceService.vb
浏览文件 @
9e64998d
...
...
@@ -58,7 +58,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ChangeNamespace
' TODO: Implement the service for VB
Protected
Overrides
Function
GetValidContainersFromAllLinkedDocumentsAsync
(
document
As
Document
,
container
As
SyntaxNode
,
cancellationToken
As
CancellationToken
)
As
Task
(
Of
ImmutableArray
(
Of
(
DocumentId
,
SyntaxNode
)))
Return
Task
.
FromResult
(
CType
(
Nothing
,
ImmutableArray
(
Of
(
DocumentId
,
SyntaxNode
)))
)
Return
SpecializedTasks
.
Default
(
Of
ImmutableArray
(
Of
(
DocumentId
,
SyntaxNode
)))(
)
End
Function
' This is only reachable when called from a VB service, which is not implemented yet.
...
...
src/Workspaces/CoreTestUtilities/Remote/InProcRemostHostClient.cs
浏览文件 @
9e64998d
...
...
@@ -93,7 +93,7 @@ public Task GetAssetsAsync(int scopeId, Checksum[] checksums, string pipeName, C
/// Remote API.
/// </summary>
public
Task
<
bool
>
IsExperimentEnabledAsync
(
string
experimentName
,
CancellationToken
cancellationToken
)
=>
Task
.
FromResult
(
_services
.
GetRequiredService
<
IExperimentationService
>().
IsExperimentEnabled
(
experimentName
))
;
=>
_services
.
GetRequiredService
<
IExperimentationService
>().
IsExperimentEnabled
(
experimentName
)
?
SpecializedTasks
.
True
:
SpecializedTasks
.
False
;
public
RemoteHostTestData
TestData
=>
_inprocServices
.
TestData
;
...
...
src/Workspaces/CoreTestUtilities/TestDynamicFileInfoProviderThatProducesNoFiles.cs
浏览文件 @
9e64998d
...
...
@@ -8,6 +8,7 @@
using
System.Threading.Tasks
;
using
Microsoft.CodeAnalysis.Host
;
using
Microsoft.CodeAnalysis.Host.Mef
;
using
Roslyn.Utilities
;
namespace
Microsoft.CodeAnalysis.Test.Utilities
{
...
...
@@ -25,7 +26,7 @@ public TestDynamicFileInfoProviderThatProducesNoFiles()
event
EventHandler
<
string
>
IDynamicFileInfoProvider
.
Updated
{
add
{
}
remove
{
}
}
public
Task
<
DynamicFileInfo
>
GetDynamicFileInfoAsync
(
ProjectId
projectId
,
string
projectFilePath
,
string
filePath
,
CancellationToken
cancellationToken
)
=>
Task
.
FromResult
<
DynamicFileInfo
>(
null
);
=>
SpecializedTasks
.
Null
<
DynamicFileInfo
>(
);
public
Task
RemoveDynamicFileInfoAsync
(
ProjectId
projectId
,
string
projectFilePath
,
string
filePath
,
CancellationToken
cancellationToken
)
=>
Task
.
CompletedTask
;
...
...
src/Workspaces/Remote/Core/ServiceHubRemoteHostClient.cs
浏览文件 @
9e64998d
...
...
@@ -214,7 +214,9 @@ public Task<bool> IsExperimentEnabledAsync(string experimentName, CancellationTo
{
try
{
return
Task
.
FromResult
(
_services
.
GetRequiredService
<
IExperimentationService
>().
IsExperimentEnabled
(
experimentName
));
return
_services
.
GetRequiredService
<
IExperimentationService
>().
IsExperimentEnabled
(
experimentName
)
?
SpecializedTasks
.
True
:
SpecializedTasks
.
False
;
}
catch
(
Exception
ex
)
when
(
FatalError
.
ReportWithoutCrashUnlessCanceledAndPropagate
(
ex
,
cancellationToken
))
{
...
...
src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/CustomCodeActions.cs
浏览文件 @
9e64998d
...
...
@@ -5,6 +5,7 @@
using
System
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
Roslyn.Utilities
;
namespace
Microsoft.CodeAnalysis.CodeActions
{
...
...
@@ -22,7 +23,7 @@ public SimpleCodeAction(string title, string equivalenceKey)
public
sealed
override
string
EquivalenceKey
{
get
;
}
protected
override
Task
<
Document
>
GetChangedDocumentAsync
(
CancellationToken
cancellationToken
)
=>
Task
.
FromResult
<
Document
>(
null
);
=>
SpecializedTasks
.
Null
<
Document
>(
);
}
internal
class
DocumentChangeAction
:
SimpleCodeAction
...
...
src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/FixAll/FixAllState.FixMultipleDiagnosticProvider.cs
浏览文件 @
9e64998d
...
...
@@ -63,7 +63,7 @@ public override Task<IEnumerable<Diagnostic>> GetDocumentDiagnosticsAsync(Docume
return
Task
.
FromResult
<
IEnumerable
<
Diagnostic
>>(
diagnostics
);
}
return
Task
.
FromResult
(
SpecializedCollections
.
EmptyEnumerable
<
Diagnostic
>()
);
return
SpecializedTasks
.
EmptyEnumerable
<
Diagnostic
>(
);
}
public
override
Task
<
IEnumerable
<
Diagnostic
>>
GetProjectDiagnosticsAsync
(
Project
project
,
CancellationToken
cancellationToken
)
...
...
@@ -73,7 +73,7 @@ public override Task<IEnumerable<Diagnostic>> GetProjectDiagnosticsAsync(Project
return
Task
.
FromResult
<
IEnumerable
<
Diagnostic
>>(
diagnostics
);
}
return
Task
.
FromResult
(
SpecializedCollections
.
EmptyEnumerable
<
Diagnostic
>()
);
return
SpecializedTasks
.
EmptyEnumerable
<
Diagnostic
>(
);
}
}
}
...
...
src/Workspaces/VisualBasic/Portable/FindSymbols/VisualBasicReferenceFinder.vb
浏览文件 @
9e64998d
...
...
@@ -29,7 +29,7 @@ Namespace Microsoft.CodeAnalysis.FindSymbols
Return
DetermineCascadedSymbolsAsync
(
DirectCast
(
symbol
,
INamedTypeSymbol
),
project
,
cancellationToken
)
Else
Return
Task
.
FromResult
(
ImmutableArray
(
Of
ISymbol
).
Empty
)
Return
SpecializedTasks
.
EmptyImmutableArray
(
Of
ISymbol
)(
)
End
If
End
Function
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录