Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
2bde9dc3
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,发现更多精彩内容 >>
未验证
提交
2bde9dc3
编写于
7月 27, 2020
作者:
J
Jason Malinowski
提交者:
GitHub
7月 27, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #45978 from jasonmalinowski/nullable-annotate-invisibleeditor
Nullable annotate InvisibleEditor.cs
上级
39ed7ebd
fb34e599
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
22 addition
and
18 deletion
+22
-18
src/VisualStudio/Core/Def/Implementation/FindReferences/VisualStudioDefinitionsAndReferencesFactory.cs
...References/VisualStudioDefinitionsAndReferencesFactory.cs
+2
-3
src/VisualStudio/Core/Def/Implementation/ProjectSystem/InvisibleEditor.cs
.../Core/Def/Implementation/ProjectSystem/InvisibleEditor.cs
+15
-14
src/VisualStudio/Core/Impl/RoslynVisualStudioWorkspace.cs
src/VisualStudio/Core/Impl/RoslynVisualStudioWorkspace.cs
+4
-0
src/VisualStudio/LiveShare/Impl/Client/RemoteLanguageServiceWorkspace.cs
...o/LiveShare/Impl/Client/RemoteLanguageServiceWorkspace.cs
+1
-1
未找到文件。
src/VisualStudio/Core/Def/Implementation/FindReferences/VisualStudioDefinitionsAndReferencesFactory.cs
浏览文件 @
2bde9dc3
...
...
@@ -64,10 +64,9 @@ public VisualStudioDefinitionsAndReferencesFactory(SVsServiceProvider servicePro
private
string
GetSourceLine
(
string
filePath
,
int
lineNumber
)
{
using
var
invisibleEditor
=
new
InvisibleEditor
(
_serviceProvider
,
filePath
,
hierarchy
Opt
:
null
,
needsSave
:
false
,
needsUndoDisabled
:
false
);
_serviceProvider
,
filePath
,
hierarchy
:
null
,
needsSave
:
false
,
needsUndoDisabled
:
false
);
var
vsTextLines
=
invisibleEditor
.
VsTextLines
;
if
(
vsTextLines
!=
null
&&
vsTextLines
.
GetLengthOfLine
(
lineNumber
,
out
var
lineLength
)
==
VSConstants
.
S_OK
&&
if
(
vsTextLines
.
GetLengthOfLine
(
lineNumber
,
out
var
lineLength
)
==
VSConstants
.
S_OK
&&
vsTextLines
.
GetLineText
(
lineNumber
,
0
,
lineNumber
,
lineLength
,
out
var
lineText
)
==
VSConstants
.
S_OK
)
{
return
lineText
;
...
...
src/VisualStudio/Core/Def/Implementation/ProjectSystem/InvisibleEditor.cs
浏览文件 @
2bde9dc3
...
...
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#
nullable
enable
using
System
;
using
System.Diagnostics
;
using
System.Runtime.InteropServices
;
...
...
@@ -28,7 +30,7 @@ internal partial class InvisibleEditor : ForegroundThreadAffinitizedObject, IInv
private
ITextBuffer
_buffer
;
private
IVsTextLines
_vsTextLines
;
private
IVsInvisibleEditor
_invisibleEditor
;
private
OLE
.
Interop
.
IOleUndoManager
_manager
;
private
OLE
.
Interop
.
IOleUndoManager
?
_manager
;
private
readonly
bool
_needsUndoRestored
;
/// <remarks>
...
...
@@ -38,7 +40,7 @@ internal partial class InvisibleEditor : ForegroundThreadAffinitizedObject, IInv
/// <see cref="IVsUIShellOpenDocument4.IsDocumentInAProject2"/>, which performs a much slower query of all
/// projects in the solution.</para>
/// </remarks>
public
InvisibleEditor
(
IServiceProvider
serviceProvider
,
string
filePath
,
IVsHierarchy
hierarchyOpt
,
bool
needsSave
,
bool
needsUndoDisabled
)
public
InvisibleEditor
(
IServiceProvider
serviceProvider
,
string
filePath
,
IVsHierarchy
?
hierarchy
,
bool
needsSave
,
bool
needsUndoDisabled
)
:
base
(
serviceProvider
.
GetMefService
<
IThreadingContext
>(),
assertIsForeground
:
true
)
{
_serviceProvider
=
serviceProvider
;
...
...
@@ -46,7 +48,7 @@ public InvisibleEditor(IServiceProvider serviceProvider, string filePath, IVsHie
_needsSave
=
needsSave
;
var
invisibleEditorManager
=
(
IIntPtrReturningVsInvisibleEditorManager
)
serviceProvider
.
GetService
(
typeof
(
SVsInvisibleEditorManager
));
var
vsProject
=
TryGetProjectOfHierarchy
(
hierarchy
Opt
);
var
vsProject
=
TryGetProjectOfHierarchy
(
hierarchy
);
Marshal
.
ThrowExceptionForHR
(
invisibleEditorManager
.
RegisterInvisibleEditor
(
filePath
,
vsProject
,
0
,
null
,
out
var
invisibleEditorPtr
));
try
...
...
@@ -59,14 +61,13 @@ public InvisibleEditor(IServiceProvider serviceProvider, string filePath, IVsHie
try
{
var
docData
=
Marshal
.
GetObjectForIUnknown
(
docDataPtr
);
_vsTextLines
=
docData
as
IVsTextLines
;
var
vsTextBuffer
=
(
IVsTextBuffer
)
docData
;
_vsTextLines
=
(
IVsTextLines
)
docData
;
var
editorAdapterFactoryService
=
serviceProvider
.
GetMefService
<
IVsEditorAdaptersFactoryService
>();
_buffer
=
editorAdapterFactoryService
.
GetDocumentBuffer
(
vsTextBuffer
);
_buffer
=
editorAdapterFactoryService
.
GetDocumentBuffer
(
_vsTextLines
);
if
(
needsUndoDisabled
)
{
Marshal
.
ThrowExceptionForHR
(
vsTextBuffer
.
GetUndoManager
(
out
_manager
));
Marshal
.
ThrowExceptionForHR
((
_manager
as
IVsUndoState
).
IsEnabled
(
out
var
isEnabled
));
Marshal
.
ThrowExceptionForHR
(
_vsTextLines
.
GetUndoManager
(
out
_manager
));
Marshal
.
ThrowExceptionForHR
((
(
IVsUndoState
)
_manager
).
IsEnabled
(
out
var
isEnabled
));
_needsUndoRestored
=
isEnabled
!=
0
;
if
(
_needsUndoRestored
)
{
...
...
@@ -87,18 +88,18 @@ public InvisibleEditor(IServiceProvider serviceProvider, string filePath, IVsHie
}
}
private
IVsProject
TryGetProjectOfHierarchy
(
IVsHierarchy
hierarchyOpt
)
private
IVsProject
?
TryGetProjectOfHierarchy
(
IVsHierarchy
?
hierarchy
)
{
// The invisible editor manager will fail in cases where the IVsProject passed to it is not consistent with
// the IVsProject known to IVsSolution (e.g. if the object is a wrapper like AbstractHostObject created by
// the CPS-based project system). This method returns an IVsProject instance known to the solution, or null
// if the project could not be determined.
if
(
hierarchy
Opt
==
null
)
if
(
hierarchy
==
null
)
{
return
null
;
}
if
(!
ErrorHandler
.
Succeeded
(
hierarchy
Opt
.
GetGuidProperty
(
if
(!
ErrorHandler
.
Succeeded
(
hierarchy
.
GetGuidProperty
(
(
uint
)
VSConstants
.
VSITEMID
.
Root
,
(
int
)
__VSHPROPID
.
VSHPROPID_ProjectIDGuid
,
out
var
projectId
)))
...
...
@@ -143,8 +144,8 @@ public void Dispose()
{
AssertIsForeground
();
_buffer
=
null
;
_vsTextLines
=
null
;
_buffer
=
null
!
;
_vsTextLines
=
null
!
;
try
{
...
...
@@ -177,7 +178,7 @@ public void Dispose()
// Clean up our RCW. This RCW is a unique RCW, so this is actually safe to do!
Marshal
.
ReleaseComObject
(
_invisibleEditor
);
_invisibleEditor
=
null
;
_invisibleEditor
=
null
!
;
GC
.
SuppressFinalize
(
this
);
}
...
...
src/VisualStudio/Core/Impl/RoslynVisualStudioWorkspace.cs
浏览文件 @
2bde9dc3
...
...
@@ -82,6 +82,10 @@ internal override IInvisibleEditor OpenInvisibleEditor(DocumentId documentId)
}
}
// Documents in the VisualStudioWorkspace always have file paths since that's how we get files given
// to us from the project system.
Contract
.
ThrowIfNull
(
textDocument
.
FilePath
);
return
new
InvisibleEditor
(
ServiceProvider
.
GlobalProvider
,
textDocument
.
FilePath
,
GetHierarchy
(
documentId
.
ProjectId
),
needsSave
,
needsUndoDisabled
);
}
...
...
src/VisualStudio/LiveShare/Impl/Client/RemoteLanguageServiceWorkspace.cs
浏览文件 @
2bde9dc3
...
...
@@ -491,7 +491,7 @@ protected override void ApplyDocumentTextChanged(DocumentId documentId, SourceTe
{
// The edits would get sent by the co-authoring service to the owner.
// The invisible editor saves the file on being disposed, which should get reflected on the owner's side.
using
(
var
invisibleEditor
=
new
InvisibleEditor
(
_serviceProvider
,
document
.
FilePath
,
hierarchyOpt
:
null
,
using
(
var
invisibleEditor
=
new
InvisibleEditor
(
_serviceProvider
,
document
.
FilePath
!,
hierarchy
:
null
,
needsSave
:
true
,
needsUndoDisabled
:
false
))
{
UpdateText
(
invisibleEditor
.
TextBuffer
,
text
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录