Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
5458b371
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,发现更多精彩内容 >>
提交
5458b371
编写于
2月 18, 2015
作者:
H
Heejae Chang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rename some locals add async operation waiter
cleaned code little bit based on PR feedback
上级
6771d030
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
76 addition
and
46 deletion
+76
-46
src/EditorFeatures/Core/Shared/Preview/PreviewWorkspace.cs
src/EditorFeatures/Core/Shared/Preview/PreviewWorkspace.cs
+7
-7
src/EditorFeatures/Test/Diagnostics/DiagnosticTagSourceTests.cs
...itorFeatures/Test/Diagnostics/DiagnosticTagSourceTests.cs
+3
-3
src/EditorFeatures/Test/Preview/PreviewWorkspaceTests.cs
src/EditorFeatures/Test/Preview/PreviewWorkspaceTests.cs
+2
-2
src/EditorFeatures/Test/SolutionCrawler/WorkCoordinatorTests.cs
...itorFeatures/Test/SolutionCrawler/WorkCoordinatorTests.cs
+16
-1
src/EditorFeatures/Test/Squiggles/AbstractSquiggleProducerTests.cs
...rFeatures/Test/Squiggles/AbstractSquiggleProducerTests.cs
+2
-2
src/EditorFeatures/Test2/Diagnostics/DiagnosticProviderTests.vb
...itorFeatures/Test2/Diagnostics/DiagnosticProviderTests.vb
+2
-2
src/Features/Core/SolutionCrawler/ISolutionCrawlerProgressReporter.cs
.../Core/SolutionCrawler/ISolutionCrawlerProgressReporter.cs
+1
-1
src/Features/Core/SolutionCrawler/SolutionCrawlerProgressReporter.cs
...s/Core/SolutionCrawler/SolutionCrawlerProgressReporter.cs
+19
-5
src/Features/Core/SolutionCrawler/SolutionCrawlerRegistrationService.cs
...ore/SolutionCrawler/SolutionCrawlerRegistrationService.cs
+2
-1
src/Interactive/EditorFeatures/Core/Implementation/Interactive/InteractiveWorkspace.cs
...s/Core/Implementation/Interactive/InteractiveWorkspace.cs
+4
-4
src/VisualStudio/Core/Def/Implementation/ProjectSystem/MiscellaneousFilesWorkspace.cs
...plementation/ProjectSystem/MiscellaneousFilesWorkspace.cs
+9
-9
src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspaceImpl.cs
...Implementation/ProjectSystem/VisualStudioWorkspaceImpl.cs
+9
-9
未找到文件。
src/EditorFeatures/Core/Shared/Preview/PreviewWorkspace.cs
浏览文件 @
5458b371
...
...
@@ -10,7 +10,7 @@ namespace Microsoft.CodeAnalysis.Editor.Shared.Preview
{
internal
class
PreviewWorkspace
:
Workspace
{
private
ISolutionCrawlerRegistrationService
_
workCoordinator
Service
;
private
ISolutionCrawlerRegistrationService
_
registration
Service
;
public
PreviewWorkspace
()
:
base
(
MefHostServices
.
DefaultHost
,
WorkspaceKind
.
Preview
)
...
...
@@ -33,10 +33,10 @@ public PreviewWorkspace(Solution solution)
public
void
EnableDiagnostic
()
{
_
workCoordinator
Service
=
this
.
Services
.
GetService
<
ISolutionCrawlerRegistrationService
>();
if
(
_
workCoordinator
Service
!=
null
)
_
registration
Service
=
this
.
Services
.
GetService
<
ISolutionCrawlerRegistrationService
>();
if
(
_
registration
Service
!=
null
)
{
_
workCoordinator
Service
.
Register
(
this
);
_
registration
Service
.
Register
(
this
);
}
}
...
...
@@ -90,10 +90,10 @@ protected override void Dispose(bool finalize)
{
base
.
Dispose
(
finalize
);
if
(
_
workCoordinator
Service
!=
null
)
if
(
_
registration
Service
!=
null
)
{
_
workCoordinator
Service
.
Unregister
(
this
);
_
workCoordinator
Service
=
null
;
_
registration
Service
.
Unregister
(
this
);
_
registration
Service
=
null
;
}
this
.
ClearSolution
();
...
...
src/EditorFeatures/Test/Diagnostics/DiagnosticTagSourceTests.cs
浏览文件 @
5458b371
...
...
@@ -42,11 +42,11 @@ public void Test_TagSourceDiffer()
Assert
.
True
(
arg
.
Spans
.
First
().
Span
.
Contains
(
new
Span
(
0
,
1
)));
};
var
s
olutionWorkCoordinator
=
workspace
.
Services
.
GetService
<
ISolutionCrawlerRegistrationService
>()
as
SolutionCrawlerRegistrationService
;
var
s
ervice
=
workspace
.
Services
.
GetService
<
ISolutionCrawlerRegistrationService
>()
as
SolutionCrawlerRegistrationService
;
var
incrementalAnalyzers
=
ImmutableArray
.
Create
(
analyzerService
.
CreateIncrementalAnalyzer
(
workspace
));
// test first update
s
olutionWorkCoordinator
.
WaitUntilCompletion_ForTestingPurposesOnly
(
workspace
,
incrementalAnalyzers
);
s
ervice
.
WaitUntilCompletion_ForTestingPurposesOnly
(
workspace
,
incrementalAnalyzers
);
diagnosticWaiter
.
CreateWaitTask
().
PumpingWait
();
squiggleWaiter
.
CreateWaitTask
().
PumpingWait
();
...
...
@@ -58,7 +58,7 @@ public void Test_TagSourceDiffer()
var
text
=
document
.
GetTextAsync
().
Result
;
workspace
.
TryApplyChanges
(
document
.
WithText
(
text
.
WithChanges
(
new
TextChange
(
new
TextSpan
(
text
.
Length
-
1
,
1
),
string
.
Empty
))).
Project
.
Solution
);
s
olutionWorkCoordinator
.
WaitUntilCompletion_ForTestingPurposesOnly
(
workspace
,
incrementalAnalyzers
);
s
ervice
.
WaitUntilCompletion_ForTestingPurposesOnly
(
workspace
,
incrementalAnalyzers
);
diagnosticWaiter
.
CreateWaitTask
().
PumpingWait
();
squiggleWaiter
.
CreateWaitTask
().
PumpingWait
();
...
...
src/EditorFeatures/Test/Preview/PreviewWorkspaceTests.cs
浏览文件 @
5458b371
...
...
@@ -127,8 +127,8 @@ public void TestPreviewServices()
{
using
(
var
previewWorkspace
=
new
PreviewWorkspace
(
MefV1HostServices
.
Create
(
TestExportProvider
.
ExportProviderWithCSharpAndVisualBasic
.
AsExportProvider
())))
{
var
workcoordinatorS
ervice
=
previewWorkspace
.
Services
.
GetService
<
ISolutionCrawlerRegistrationService
>();
Assert
.
True
(
workcoordinatorS
ervice
is
PreviewSolutionCrawlerRegistrationService
);
var
s
ervice
=
previewWorkspace
.
Services
.
GetService
<
ISolutionCrawlerRegistrationService
>();
Assert
.
True
(
s
ervice
is
PreviewSolutionCrawlerRegistrationService
);
var
persistentService
=
previewWorkspace
.
Services
.
GetService
<
IPersistentStorageService
>();
Assert
.
NotNull
(
persistentService
);
...
...
src/EditorFeatures/Test/SolutionCrawler/WorkCoordinatorTests.cs
浏览文件 @
5458b371
...
...
@@ -701,6 +701,7 @@ public void ProgressReporterTest()
var
reporter
=
service
.
GetProgressReporter
(
workspace
);
Assert
.
False
(
reporter
.
InProgress
);
// set up events
bool
started
=
false
;
reporter
.
Started
+=
(
o
,
a
)
=>
{
started
=
true
;
};
...
...
@@ -710,13 +711,27 @@ public void ProgressReporterTest()
var
registrationService
=
workspace
.
Services
.
GetService
<
ISolutionCrawlerRegistrationService
>();
registrationService
.
Register
(
workspace
);
// first mutation
workspace
.
OnSolutionAdded
(
solution
);
Wait
((
SolutionCrawlerRegistrationService
)
registrationService
,
workspace
);
registrationService
.
Unregister
(
workspace
);
Assert
.
True
(
started
);
Assert
.
True
(
stopped
);
// reset
started
=
false
;
stopped
=
false
;
// second mutation
workspace
.
OnDocumentAdded
(
DocumentInfo
.
Create
(
DocumentId
.
CreateNewId
(
solution
.
Projects
[
0
].
Id
),
"D6"
));
Wait
((
SolutionCrawlerRegistrationService
)
registrationService
,
workspace
);
Assert
.
True
(
started
);
Assert
.
True
(
stopped
);
registrationService
.
Unregister
(
workspace
);
}
}
...
...
src/EditorFeatures/Test/Squiggles/AbstractSquiggleProducerTests.cs
浏览文件 @
5458b371
...
...
@@ -40,8 +40,8 @@ protected static IEnumerable<ITagSpan<IErrorTag>> GetErrorSpans(TestWorkspace wo
var
foregroundService
=
new
TestForegroundNotificationService
();
var
taggerSource
=
new
DiagnosticsSquiggleTaggerProvider
.
TagSource
(
buffer
,
foregroundService
,
diagnosticService
,
optionsService
,
squiggleWaiter
);
var
s
olutionWorkCoordinator
=
workspace
.
Services
.
GetService
<
ISolutionCrawlerRegistrationService
>()
as
SolutionCrawlerRegistrationService
;
s
olutionWorkCoordinator
.
WaitUntilCompletion_ForTestingPurposesOnly
(
workspace
,
ImmutableArray
.
Create
(
analyzerService
.
CreateIncrementalAnalyzer
(
workspace
)));
var
s
ervice
=
workspace
.
Services
.
GetService
<
ISolutionCrawlerRegistrationService
>()
as
SolutionCrawlerRegistrationService
;
s
ervice
.
WaitUntilCompletion_ForTestingPurposesOnly
(
workspace
,
ImmutableArray
.
Create
(
analyzerService
.
CreateIncrementalAnalyzer
(
workspace
)));
diagnosticWaiter
.
CreateWaitTask
().
PumpingWait
();
squiggleWaiter
.
CreateWaitTask
().
PumpingWait
();
...
...
src/EditorFeatures/Test2/Diagnostics/DiagnosticProviderTests.vb
浏览文件 @
5458b371
...
...
@@ -293,8 +293,8 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.Diagnostics.UnitTests
Dim
analyzerService
=
New
DiagnosticAnalyzerService
(
compilerAnalyzersMap
)
' CollectErrors generates interleaved background and foreground tasks.
Dim
s
olutionWorkCoordinator
=
DirectCast
(
workspace
.
Services
.
GetService
(
Of
ISolutionCrawlerRegistrationService
)(),
SolutionCrawlerRegistrationService
)
s
olutionWorkCoordinator
.
WaitUntilCompletion_ForTestingPurposesOnly
(
workspace
,
SpecializedCollections
.
SingletonEnumerable
(
analyzerService
.
CreateIncrementalAnalyzer
(
workspace
)).
WhereNotNull
().
ToImmutableArray
())
Dim
s
ervice
=
DirectCast
(
workspace
.
Services
.
GetService
(
Of
ISolutionCrawlerRegistrationService
)(),
SolutionCrawlerRegistrationService
)
s
ervice
.
WaitUntilCompletion_ForTestingPurposesOnly
(
workspace
,
SpecializedCollections
.
SingletonEnumerable
(
analyzerService
.
CreateIncrementalAnalyzer
(
workspace
)).
WhereNotNull
().
ToImmutableArray
())
Return
analyzerService
End
Function
...
...
src/Features/Core/SolutionCrawler/ISolutionCrawlerProgressReporter.cs
浏览文件 @
5458b371
...
...
@@ -20,7 +20,7 @@ internal interface ISolutionCrawlerProgressReporter
event
EventHandler
Started
;
/// <summary>
/// Raised when there is no more pending work in soluti
no
crawler.
/// Raised when there is no more pending work in soluti
on
crawler.
/// </summary>
event
EventHandler
Stopped
;
}
...
...
src/Features/Core/SolutionCrawler/SolutionCrawlerProgressReporter.cs
浏览文件 @
5458b371
...
...
@@ -3,6 +3,7 @@
using
System
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
Microsoft.CodeAnalysis.Shared.TestHooks
;
using
Roslyn.Utilities
;
namespace
Microsoft.CodeAnalysis.SolutionCrawler
...
...
@@ -18,12 +19,23 @@ internal partial class SolutionCrawlerRegistrationService : ISolutionCrawlerRegi
/// </summary>
private
class
SolutionCrawlerProgressReporter
:
ISolutionCrawlerProgressReporter
{
private
IAsynchronousOperationListener
_listener
;
// use event map and event queue so that we can guarantee snapshot and sequencial ordering of events from
// multiple consumer from possibly multiple threads
private
readonly
SimpleTaskQueue
_eventQueue
=
new
SimpleTaskQueue
(
TaskScheduler
.
Default
);
private
readonly
EventMap
_eventMap
=
new
EventMap
();
private
readonly
SimpleTaskQueue
_eventQueue
;
private
readonly
EventMap
_eventMap
;
private
int
_count
;
private
int
_count
=
0
;
public
SolutionCrawlerProgressReporter
(
IAsynchronousOperationListener
listener
)
{
_listener
=
listener
;
_eventQueue
=
new
SimpleTaskQueue
(
TaskScheduler
.
Default
);
_eventMap
=
new
EventMap
();
_count
=
0
;
}
public
bool
InProgress
{
...
...
@@ -63,7 +75,8 @@ public Task Start()
{
if
(
Interlocked
.
Increment
(
ref
_count
)
==
1
)
{
return
RaiseStarted
();
var
asyncToken
=
_listener
.
BeginAsyncOperation
(
"ProgressReportStart"
);
return
RaiseStarted
().
CompletesAsyncOperation
(
asyncToken
);
}
return
SpecializedTasks
.
EmptyTask
;
...
...
@@ -73,7 +86,8 @@ public Task Stop()
{
if
(
Interlocked
.
Decrement
(
ref
_count
)
==
0
)
{
return
RaiseStopped
();
var
asyncToken
=
_listener
.
BeginAsyncOperation
(
"ProgressReportStop"
);
return
RaiseStopped
().
CompletesAsyncOperation
(
asyncToken
);
}
return
SpecializedTasks
.
EmptyTask
;
...
...
src/Features/Core/SolutionCrawler/SolutionCrawlerRegistrationService.cs
浏览文件 @
5458b371
...
...
@@ -29,11 +29,12 @@ internal partial class SolutionCrawlerRegistrationService : ISolutionCrawlerRegi
[
ImportMany
]
IEnumerable
<
Lazy
<
IAsynchronousOperationListener
,
FeatureMetadata
>>
asyncListeners
)
{
_gate
=
new
object
();
_progressReporter
=
new
SolutionCrawlerProgressReporter
();
_analyzerProviders
=
analyzerProviders
.
ToImmutableArray
();
_documentWorkCoordinatorMap
=
new
Dictionary
<
Workspace
,
WorkCoordinator
>(
ReferenceEqualityComparer
.
Instance
);
_listener
=
new
AggregateAsynchronousOperationListener
(
asyncListeners
,
FeatureAttribute
.
SolutionCrawler
);
_progressReporter
=
new
SolutionCrawlerProgressReporter
(
_listener
);
}
public
void
Register
(
Workspace
workspace
)
...
...
src/Interactive/EditorFeatures/Core/Implementation/Interactive/InteractiveWorkspace.cs
浏览文件 @
5458b371
...
...
@@ -10,7 +10,7 @@ namespace Microsoft.CodeAnalysis.Editor.Implementation.Interactive
{
internal
class
InteractiveWorkspace
:
Workspace
{
private
readonly
ISolutionCrawlerRegistrationService
_
workCoordinator
Service
;
private
readonly
ISolutionCrawlerRegistrationService
_
registration
Service
;
internal
InteractiveEvaluator
Engine
{
get
;
private
set
;
}
private
SourceTextContainer
_openTextContainer
;
...
...
@@ -22,14 +22,14 @@ internal InteractiveWorkspace(InteractiveEvaluator engine, HostServices hostServ
this
.
Engine
=
engine
;
// register work coordinator for this workspace
_
workCoordinator
Service
=
this
.
Services
.
GetService
<
ISolutionCrawlerRegistrationService
>();
_
workCoordinator
Service
.
Register
(
this
);
_
registration
Service
=
this
.
Services
.
GetService
<
ISolutionCrawlerRegistrationService
>();
_
registration
Service
.
Register
(
this
);
}
protected
override
void
Dispose
(
bool
finalize
)
{
// workspace is going away. unregister this workspace from work coordinator
_
workCoordinator
Service
.
Unregister
(
this
,
blockingShutdown
:
true
);
_
registration
Service
.
Unregister
(
this
,
blockingShutdown
:
true
);
base
.
Dispose
(
finalize
);
}
...
...
src/VisualStudio/Core/Def/Implementation/ProjectSystem/MiscellaneousFilesWorkspace.cs
浏览文件 @
5458b371
...
...
@@ -39,7 +39,7 @@ internal sealed partial class MiscellaneousFilesWorkspace : Workspace, IVsRunnin
private
uint
_runningDocumentTableEventsCookie
;
// document worker coordinator
private
ISolutionCrawlerRegistrationService
_
workCoordinator
Service
;
private
ISolutionCrawlerRegistrationService
_
registration
Service
;
[
ImportingConstructor
]
public
MiscellaneousFilesWorkspace
(
...
...
@@ -69,14 +69,14 @@ public void RegisterLanguage(Guid languageGuid, string languageName, string scri
internal
void
StartSolutionCrawler
()
{
if
(
_
workCoordinator
Service
==
null
)
if
(
_
registration
Service
==
null
)
{
lock
(
this
)
{
if
(
_
workCoordinator
Service
==
null
)
if
(
_
registration
Service
==
null
)
{
_
workCoordinator
Service
=
this
.
Services
.
GetService
<
ISolutionCrawlerRegistrationService
>();
_
workCoordinator
Service
.
Register
(
this
);
_
registration
Service
=
this
.
Services
.
GetService
<
ISolutionCrawlerRegistrationService
>();
_
registration
Service
.
Register
(
this
);
}
}
}
...
...
@@ -84,14 +84,14 @@ internal void StartSolutionCrawler()
internal
void
StopSolutionCrawler
()
{
if
(
_
workCoordinator
Service
!=
null
)
if
(
_
registration
Service
!=
null
)
{
lock
(
this
)
{
if
(
_
workCoordinator
Service
!=
null
)
if
(
_
registration
Service
!=
null
)
{
_
workCoordinator
Service
.
Unregister
(
this
,
blockingShutdown
:
true
);
_
workCoordinator
Service
=
null
;
_
registration
Service
.
Unregister
(
this
,
blockingShutdown
:
true
);
_
registration
Service
=
null
;
}
}
}
...
...
src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspaceImpl.cs
浏览文件 @
5458b371
...
...
@@ -44,7 +44,7 @@ internal abstract class VisualStudioWorkspaceImpl : VisualStudioWorkspace
private
VisualStudioProjectTracker
_projectTracker
;
// document worker coordinator
private
ISolutionCrawlerRegistrationService
_
workCoordinator
Service
;
private
ISolutionCrawlerRegistrationService
_
registration
Service
;
public
VisualStudioWorkspaceImpl
(
SVsServiceProvider
serviceProvider
,
...
...
@@ -913,14 +913,14 @@ public override string GetFilePath(DocumentId documentId)
internal
void
StartSolutionCrawler
()
{
if
(
_
workCoordinator
Service
==
null
)
if
(
_
registration
Service
==
null
)
{
lock
(
this
)
{
if
(
_
workCoordinator
Service
==
null
)
if
(
_
registration
Service
==
null
)
{
_
workCoordinator
Service
=
this
.
Services
.
GetService
<
ISolutionCrawlerRegistrationService
>();
_
workCoordinator
Service
.
Register
(
this
);
_
registration
Service
=
this
.
Services
.
GetService
<
ISolutionCrawlerRegistrationService
>();
_
registration
Service
.
Register
(
this
);
}
}
}
...
...
@@ -928,14 +928,14 @@ internal void StartSolutionCrawler()
internal
void
StopSolutionCrawler
()
{
if
(
_
workCoordinator
Service
!=
null
)
if
(
_
registration
Service
!=
null
)
{
lock
(
this
)
{
if
(
_
workCoordinator
Service
!=
null
)
if
(
_
registration
Service
!=
null
)
{
_
workCoordinator
Service
.
Unregister
(
this
,
blockingShutdown
:
true
);
_
workCoordinator
Service
=
null
;
_
registration
Service
.
Unregister
(
this
,
blockingShutdown
:
true
);
_
registration
Service
=
null
;
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录