Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
27e48643
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,发现更多精彩内容 >>
提交
27e48643
编写于
3月 31, 2020
作者:
C
Cyrus Najmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update tests
上级
0c597cd5
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
232 addition
and
4 deletion
+232
-4
src/VisualStudio/CSharp/Test/CodeModel/FileCodeModelTestHelpers.cs
...lStudio/CSharp/Test/CodeModel/FileCodeModelTestHelpers.cs
+10
-1
src/VisualStudio/TestUtilities2/CodeModel/CodeModelTestHelpers.vb
...alStudio/TestUtilities2/CodeModel/CodeModelTestHelpers.vb
+222
-3
未找到文件。
src/VisualStudio/CSharp/Test/CodeModel/FileCodeModelTestHelpers.cs
浏览文件 @
27e48643
...
@@ -12,6 +12,8 @@
...
@@ -12,6 +12,8 @@
using
Microsoft.VisualStudio.LanguageServices.UnitTests
;
using
Microsoft.VisualStudio.LanguageServices.UnitTests
;
using
static
Microsoft
.
VisualStudio
.
LanguageServices
.
UnitTests
.
CodeModel
.
CodeModelTestHelpers
;
using
static
Microsoft
.
VisualStudio
.
LanguageServices
.
UnitTests
.
CodeModel
.
CodeModelTestHelpers
;
using
Microsoft.VisualStudio.LanguageServices.UnitTests.CodeModel.Mocks
;
using
Microsoft.VisualStudio.LanguageServices.UnitTests.CodeModel.Mocks
;
using
Microsoft.CodeAnalysis.Editor
;
using
Microsoft.CodeAnalysis.Shared.TestHooks
;
namespace
Microsoft.VisualStudio.LanguageServices.CSharp.UnitTests.CodeModel
namespace
Microsoft.VisualStudio.LanguageServices.CSharp.UnitTests.CodeModel
{
{
...
@@ -38,13 +40,20 @@ internal static class FileCodeModelTestHelpers
...
@@ -38,13 +40,20 @@ internal static class FileCodeModelTestHelpers
var
visualStudioWorkspaceMock
=
new
MockVisualStudioWorkspace
(
workspace
);
var
visualStudioWorkspaceMock
=
new
MockVisualStudioWorkspace
(
workspace
);
var
threadingContext
=
workspace
.
ExportProvider
.
GetExportedValue
<
IThreadingContext
>();
var
threadingContext
=
workspace
.
ExportProvider
.
GetExportedValue
<
IThreadingContext
>();
var
notificationService
=
workspace
.
ExportProvider
.
GetExportedValue
<
IForegroundNotificationService
>();
var
listenerProvider
=
workspace
.
ExportProvider
.
GetExportedValue
<
AsynchronousOperationListenerProvider
>();
var
state
=
new
CodeModelState
(
var
state
=
new
CodeModelState
(
threadingContext
,
threadingContext
,
serviceProvider
,
serviceProvider
,
project
.
LanguageServices
,
project
.
LanguageServices
,
visualStudioWorkspaceMock
,
visualStudioWorkspaceMock
,
new
ProjectCodeModelFactory
(
visualStudioWorkspaceMock
,
serviceProvider
,
threadingContext
));
new
ProjectCodeModelFactory
(
visualStudioWorkspaceMock
,
serviceProvider
,
threadingContext
,
notificationService
,
listenerProvider
));
var
codeModel
=
FileCodeModel
.
Create
(
state
,
null
,
document
,
new
MockTextManagerAdapter
()).
Handle
;
var
codeModel
=
FileCodeModel
.
Create
(
state
,
null
,
document
,
new
MockTextManagerAdapter
()).
Handle
;
...
...
src/VisualStudio/TestUtilities2/CodeModel/CodeModelTestHelpers.vb
浏览文件 @
27e48643
...
@@ -5,9 +5,13 @@
...
@@ -5,9 +5,13 @@
Imports
System.Runtime.CompilerServices
Imports
System.Runtime.CompilerServices
Imports
System.Runtime.ExceptionServices
Imports
System.Runtime.ExceptionServices
Imports
System.Runtime.InteropServices
Imports
System.Runtime.InteropServices
Imports
EnvDTE
Imports
EnvDTE80
Imports
Microsoft.CodeAnalysis
Imports
Microsoft.CodeAnalysis
Imports
Microsoft.CodeAnalysis.Editor
Imports
Microsoft.CodeAnalysis.Editor.Shared.Utilities
Imports
Microsoft.CodeAnalysis.Editor.Shared.Utilities
Imports
Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces
Imports
Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces
Imports
Microsoft.CodeAnalysis.Shared.TestHooks
Imports
Microsoft.CodeAnalysis.Test.Utilities
Imports
Microsoft.CodeAnalysis.Test.Utilities
Imports
Microsoft.VisualStudio.ComponentModelHost
Imports
Microsoft.VisualStudio.ComponentModelHost
Imports
Microsoft.VisualStudio.LanguageServices.Implementation.CodeModel
Imports
Microsoft.VisualStudio.LanguageServices.Implementation.CodeModel
...
@@ -52,13 +56,20 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.CodeModel
...
@@ -52,13 +56,20 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.CodeModel
Dim
project
=
workspace
.
CurrentSolution
.
Projects
.
Single
()
Dim
project
=
workspace
.
CurrentSolution
.
Projects
.
Single
()
Dim
threadingContext
=
workspace
.
ExportProvider
.
GetExportedValue
(
Of
IThreadingContext
)
Dim
threadingContext
=
workspace
.
ExportProvider
.
GetExportedValue
(
Of
IThreadingContext
)
Dim
notificationService
=
workspace
.
ExportProvider
.
GetExportedValue
(
Of
IForegroundNotificationService
)
Dim
listenerProvider
=
workspace
.
ExportProvider
.
GetExportedValue
(
Of
AsynchronousOperationListenerProvider
)()
Dim
state
=
New
CodeModelState
(
Dim
state
=
New
CodeModelState
(
threadingContext
,
threadingContext
,
mockServiceProvider
,
mockServiceProvider
,
project
.
LanguageServices
,
project
.
LanguageServices
,
mockVisualStudioWorkspace
,
mockVisualStudioWorkspace
,
New
ProjectCodeModelFactory
(
mockVisualStudioWorkspace
,
mockServiceProvider
,
threadingContext
))
New
ProjectCodeModelFactory
(
mockVisualStudioWorkspace
,
mockServiceProvider
,
threadingContext
,
notificationService
,
listenerProvider
))
Dim
projectCodeModel
=
DirectCast
(
state
.
ProjectCodeModelFactory
.
CreateProjectCodeModel
(
project
.
Id
,
Nothing
),
ProjectCodeModel
)
Dim
projectCodeModel
=
DirectCast
(
state
.
ProjectCodeModelFactory
.
CreateProjectCodeModel
(
project
.
Id
,
Nothing
),
ProjectCodeModel
)
...
@@ -86,9 +97,11 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.CodeModel
...
@@ -86,9 +97,11 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.CodeModel
Implements
IServiceProvider
Implements
IServiceProvider
Private
ReadOnly
_componentModel
As
MockComponentModel
Private
ReadOnly
_componentModel
As
MockComponentModel
Private
ReadOnly
_extensibility
As
MockVsExtensibility
Public
Sub
New
(
componentModel
As
MockComponentModel
)
Public
Sub
New
(
componentModel
As
MockComponentModel
)
Me
.
_componentModel
=
componentModel
_componentModel
=
componentModel
_extensibility
=
New
MockVsExtensibility
()
End
Sub
End
Sub
Public
Function
GetService
(
serviceType
As
Type
)
As
Object
Implements
IServiceProvider
.
GetService
Public
Function
GetService
(
serviceType
As
Type
)
As
Object
Implements
IServiceProvider
.
GetService
...
@@ -96,10 +109,216 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.CodeModel
...
@@ -96,10 +109,216 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.CodeModel
Return
Me
.
_componentModel
Return
Me
.
_componentModel
End
If
End
If
If
(
serviceType
=
GetType
(
EnvDTE
.
IVsExtensibility
))
Then
Return
_extensibility
End
If
Throw
New
NotImplementedException
(
$
"No service exists for {serviceType.FullName}"
)
Throw
New
NotImplementedException
(
$
"No service exists for {serviceType.FullName}"
)
End
Function
End
Function
End
Class
End
Class
Private
Class
MockVsExtensibility
Implements
EnvDTE80
.
IVsExtensibility2
Public
Sub
FireCodeModelEvent
(
dispid
As
Integer
,
pElement
As
CodeElement
,
changeKind
As
vsCMChangeKind
)
Implements
IVsExtensibility2
.
FireCodeModelEvent
End
Sub
Public
Sub
FireCodeModelEvent3
(
dispid
As
Integer
,
pParent
As
Object
,
pElement
As
CodeElement
,
changeKind
As
vsCMChangeKind
)
Implements
IVsExtensibility2
.
FireCodeModelEvent3
End
Sub
#Region "Not implemented"
Public
Sub
get_Properties
(
pParent
As
ISupportVSProperties
,
pdispPropObj
As
Object
,
ByRef
ppProperties
As
Properties
)
Implements
IVsExtensibility2
.
get_Properties
Throw
New
NotImplementedException
()
End
Sub
Public
Function
RunWizardFile
(
bstrWizFilename
As
String
,
hwndOwner
As
Integer
,
ByRef
vContextParams
()
As
Object
)
As
wizardResult
Implements
IVsExtensibility2
.
RunWizardFile
Throw
New
NotImplementedException
()
End
Function
Public
Function
Get_TextBuffer
(
pVsTextStream
As
Object
,
pParent
As
IExtensibleObjectSite
)
As
TextBuffer
Implements
IVsExtensibility2
.
Get_TextBuffer
Throw
New
NotImplementedException
()
End
Function
Public
Sub
EnterAutomationFunction
()
Implements
IVsExtensibility2
.
EnterAutomationFunction
Throw
New
NotImplementedException
()
End
Sub
Public
Sub
ExitAutomationFunction
()
Implements
IVsExtensibility2
.
ExitAutomationFunction
Throw
New
NotImplementedException
()
End
Sub
Public
Function
IsInAutomationFunction
()
As
Integer
Implements
IVsExtensibility2
.
IsInAutomationFunction
Throw
New
NotImplementedException
()
End
Function
Public
Sub
GetUserControl
(
ByRef
fUserControl
As
Boolean
)
Implements
IVsExtensibility2
.
GetUserControl
Throw
New
NotImplementedException
()
End
Sub
Public
Sub
SetUserControl
(
fUserControl
As
Boolean
)
Implements
IVsExtensibility2
.
SetUserControl
Throw
New
NotImplementedException
()
End
Sub
Public
Sub
SetUserControlUnlatched
(
fUserControl
As
Boolean
)
Implements
IVsExtensibility2
.
SetUserControlUnlatched
Throw
New
NotImplementedException
()
End
Sub
Public
Sub
LockServer
(
__MIDL_0010
As
Boolean
)
Implements
IVsExtensibility2
.
LockServer
Throw
New
NotImplementedException
()
End
Sub
Public
Function
GetLockCount
()
As
Integer
Implements
IVsExtensibility2
.
GetLockCount
Throw
New
NotImplementedException
()
End
Function
Public
Function
TestForShutdown
()
As
Boolean
Implements
IVsExtensibility2
.
TestForShutdown
Throw
New
NotImplementedException
()
End
Function
Public
Function
GetGlobalsObject
(
ExtractFrom
As
Object
)
As
Globals
Implements
IVsExtensibility2
.
GetGlobalsObject
Throw
New
NotImplementedException
()
End
Function
Public
Function
GetConfigMgr
(
pIVsProject
As
Object
,
itemid
As
UInteger
)
As
ConfigurationManager
Implements
IVsExtensibility2
.
GetConfigMgr
Throw
New
NotImplementedException
()
End
Function
Public
Sub
FireMacroReset
()
Implements
IVsExtensibility2
.
FireMacroReset
Throw
New
NotImplementedException
()
End
Sub
Public
Function
GetDocumentFromDocCookie
(
lDocCookie
As
Integer
)
As
EnvDTE
.
Document
Implements
IVsExtensibility2
.
GetDocumentFromDocCookie
Throw
New
NotImplementedException
()
End
Function
Public
Sub
IsMethodDisabled
(
ByRef
pGUID
As
Guid
,
dispid
As
Integer
)
Implements
IVsExtensibility2
.
IsMethodDisabled
Throw
New
NotImplementedException
()
End
Sub
Public
Sub
SetSuppressUI
(
[
In
]
As
Boolean
)
Implements
IVsExtensibility2
.
SetSuppressUI
Throw
New
NotImplementedException
()
End
Sub
Public
Sub
GetSuppressUI
(
ByRef
pOut
As
Boolean
)
Implements
IVsExtensibility2
.
GetSuppressUI
Throw
New
NotImplementedException
()
End
Sub
Public
Sub
FireProjectsEvent_ItemAdded
(
Project
As
EnvDTE
.
Project
)
Implements
IVsExtensibility2
.
FireProjectsEvent_ItemAdded
Throw
New
NotImplementedException
()
End
Sub
Public
Sub
FireProjectsEvent_ItemRemoved
(
Project
As
EnvDTE
.
Project
)
Implements
IVsExtensibility2
.
FireProjectsEvent_ItemRemoved
Throw
New
NotImplementedException
()
End
Sub
Public
Sub
FireProjectsEvent_ItemRenamed
(
Project
As
EnvDTE
.
Project
,
OldName
As
String
)
Implements
IVsExtensibility2
.
FireProjectsEvent_ItemRenamed
Throw
New
NotImplementedException
()
End
Sub
Public
Sub
FireProjectItemsEvent_ItemAdded
(
ProjectItem
As
ProjectItem
)
Implements
IVsExtensibility2
.
FireProjectItemsEvent_ItemAdded
Throw
New
NotImplementedException
()
End
Sub
Public
Sub
FireProjectItemsEvent_ItemRemoved
(
ProjectItem
As
ProjectItem
)
Implements
IVsExtensibility2
.
FireProjectItemsEvent_ItemRemoved
Throw
New
NotImplementedException
()
End
Sub
Public
Sub
FireProjectItemsEvent_ItemRenamed
(
ProjectItem
As
ProjectItem
,
OldName
As
String
)
Implements
IVsExtensibility2
.
FireProjectItemsEvent_ItemRenamed
Throw
New
NotImplementedException
()
End
Sub
Public
Function
BuildUIHierarchyFromTree
(
hwnd
As
Integer
,
pParent
As
Window
)
As
UIHierarchy
Implements
IVsExtensibility2
.
BuildUIHierarchyFromTree
Throw
New
NotImplementedException
()
End
Function
Public
Sub
IsFireCodeModelEventNeeded
(
ByRef
vbNeeded
As
Boolean
)
Implements
IVsExtensibility2
.
IsFireCodeModelEventNeeded
Throw
New
NotImplementedException
()
End
Sub
Public
Function
RunWizardFileEx
(
bstrWizFilename
As
String
,
hwndOwner
As
Integer
,
ByRef
vContextParams
()
As
Object
,
ByRef
vCustomParams
()
As
Object
)
As
Integer
Implements
IVsExtensibility2
.
RunWizardFileEx
Throw
New
NotImplementedException
()
End
Function
Private
Sub
IVsExtensibility_get_Properties
(
pParent
As
ISupportVSProperties
,
pdispPropObj
As
Object
,
ByRef
ppProperties
As
Properties
)
Implements
IVsExtensibility
.
get_Properties
Throw
New
NotImplementedException
()
End
Sub
Private
Function
IVsExtensibility_RunWizardFile
(
bstrWizFilename
As
String
,
hwndOwner
As
Integer
,
ByRef
vContextParams
()
As
Object
)
As
wizardResult
Implements
IVsExtensibility
.
RunWizardFile
Throw
New
NotImplementedException
()
End
Function
Private
Function
IVsExtensibility_Get_TextBuffer
(
pVsTextStream
As
Object
,
pParent
As
IExtensibleObjectSite
)
As
TextBuffer
Implements
IVsExtensibility
.
Get_TextBuffer
Throw
New
NotImplementedException
()
End
Function
Private
Sub
IVsExtensibility_EnterAutomationFunction
()
Implements
IVsExtensibility
.
EnterAutomationFunction
Throw
New
NotImplementedException
()
End
Sub
Private
Sub
IVsExtensibility_ExitAutomationFunction
()
Implements
IVsExtensibility
.
ExitAutomationFunction
Throw
New
NotImplementedException
()
End
Sub
Private
Function
IVsExtensibility_IsInAutomationFunction
()
As
Integer
Implements
IVsExtensibility
.
IsInAutomationFunction
Throw
New
NotImplementedException
()
End
Function
Private
Sub
IVsExtensibility_GetUserControl
(
ByRef
fUserControl
As
Boolean
)
Implements
IVsExtensibility
.
GetUserControl
Throw
New
NotImplementedException
()
End
Sub
Private
Sub
IVsExtensibility_SetUserControl
(
fUserControl
As
Boolean
)
Implements
IVsExtensibility
.
SetUserControl
Throw
New
NotImplementedException
()
End
Sub
Private
Sub
IVsExtensibility_SetUserControlUnlatched
(
fUserControl
As
Boolean
)
Implements
IVsExtensibility
.
SetUserControlUnlatched
Throw
New
NotImplementedException
()
End
Sub
Private
Sub
IVsExtensibility_LockServer
(
__MIDL_0010
As
Boolean
)
Implements
IVsExtensibility
.
LockServer
Throw
New
NotImplementedException
()
End
Sub
Private
Function
IVsExtensibility_GetLockCount
()
As
Integer
Implements
IVsExtensibility
.
GetLockCount
Throw
New
NotImplementedException
()
End
Function
Private
Function
IVsExtensibility_TestForShutdown
()
As
Boolean
Implements
IVsExtensibility
.
TestForShutdown
Throw
New
NotImplementedException
()
End
Function
Private
Function
IVsExtensibility_GetGlobalsObject
(
ExtractFrom
As
Object
)
As
Globals
Implements
IVsExtensibility
.
GetGlobalsObject
Throw
New
NotImplementedException
()
End
Function
Private
Function
IVsExtensibility_GetConfigMgr
(
pIVsProject
As
Object
,
itemid
As
UInteger
)
As
ConfigurationManager
Implements
IVsExtensibility
.
GetConfigMgr
Throw
New
NotImplementedException
()
End
Function
Private
Sub
IVsExtensibility_FireMacroReset
()
Implements
IVsExtensibility
.
FireMacroReset
Throw
New
NotImplementedException
()
End
Sub
Private
Function
IVsExtensibility_GetDocumentFromDocCookie
(
lDocCookie
As
Integer
)
As
EnvDTE
.
Document
Implements
IVsExtensibility
.
GetDocumentFromDocCookie
Throw
New
NotImplementedException
()
End
Function
Private
Sub
IVsExtensibility_IsMethodDisabled
(
ByRef
pGUID
As
Guid
,
dispid
As
Integer
)
Implements
IVsExtensibility
.
IsMethodDisabled
Throw
New
NotImplementedException
()
End
Sub
Private
Sub
IVsExtensibility_SetSuppressUI
(
[
In
]
As
Boolean
)
Implements
IVsExtensibility
.
SetSuppressUI
Throw
New
NotImplementedException
()
End
Sub
Private
Sub
IVsExtensibility_GetSuppressUI
(
ByRef
pOut
As
Boolean
)
Implements
IVsExtensibility
.
GetSuppressUI
Throw
New
NotImplementedException
()
End
Sub
#End Region
End
Class
Friend
Class
MockComWrapperFactory
Friend
Class
MockComWrapperFactory
Implements
IComWrapperFactory
Implements
IComWrapperFactory
...
@@ -132,7 +351,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.CodeModel
...
@@ -132,7 +351,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.CodeModel
End
Class
End
Class
<
Extension
()
>
<
Extension
()
>
Public
Function
GetDocumentAtCursor
(
state
As
CodeModelTestState
)
As
Document
Public
Function
GetDocumentAtCursor
(
state
As
CodeModelTestState
)
As
Microsoft
.
CodeAnalysis
.
Document
Dim
cursorDocument
=
state
.
Workspace
.
Documents
.
First
(
Function
(
d
)
d
.
CursorPosition
.
HasValue
)
Dim
cursorDocument
=
state
.
Workspace
.
Documents
.
First
(
Function
(
d
)
d
.
CursorPosition
.
HasValue
)
Dim
document
=
state
.
Workspace
.
CurrentSolution
.
GetDocument
(
cursorDocument
.
Id
)
Dim
document
=
state
.
Workspace
.
CurrentSolution
.
GetDocument
(
cursorDocument
.
Id
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录