Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
818cb28e
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,发现更多精彩内容 >>
未验证
提交
818cb28e
编写于
8月 20, 2019
作者:
S
Sam Harwell
提交者:
GitHub
8月 20, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #38107 from sharwell/show-code
Show code instead of designer if the designer is not installed
上级
285a373e
f4ecf3ae
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
26 addition
and
8 deletion
+26
-8
src/VisualStudio/Core/Def/Implementation/AbstractEditorFactory.cs
...alStudio/Core/Def/Implementation/AbstractEditorFactory.cs
+26
-8
未找到文件。
src/VisualStudio/Core/Def/Implementation/AbstractEditorFactory.cs
浏览文件 @
818cb28e
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#
nullable
enable
using
System
;
using
System.IO
;
using
System.Runtime.InteropServices
;
...
...
@@ -25,10 +27,10 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation
/// <summary>
/// The base class of both the Roslyn editor factories.
/// </summary>
internal
abstract
partial
class
AbstractEditorFactory
:
IVsEditorFactory
,
IVsEditorFactoryNotify
internal
abstract
class
AbstractEditorFactory
:
IVsEditorFactory
,
IVsEditorFactoryNotify
{
private
readonly
IComponentModel
_componentModel
;
private
Microsoft
.
VisualStudio
.
OLE
.
Interop
.
IServiceProvider
_oleServiceProvider
;
private
Microsoft
.
VisualStudio
.
OLE
.
Interop
.
IServiceProvider
?
_oleServiceProvider
;
private
bool
_encoding
;
protected
AbstractEditorFactory
(
IComponentModel
componentModel
)
...
...
@@ -52,7 +54,7 @@ int IVsEditorFactory.Close()
public
int
CreateEditorInstance
(
uint
grfCreateDoc
,
string
pszMkDocument
,
string
pszPhysicalView
,
string
?
pszPhysicalView
,
IVsHierarchy
vsHierarchy
,
uint
itemid
,
IntPtr
punkDocDataExisting
,
...
...
@@ -72,7 +74,7 @@ int IVsEditorFactory.Close()
?
"Code"
:
pszPhysicalView
;
IVsTextBuffer
textBuffer
=
null
;
IVsTextBuffer
?
textBuffer
=
null
;
// Is this document already open? If so, let's see if it's a IVsTextBuffer we should re-use. This allows us
// to properly handle multiple windows open for the same document.
...
...
@@ -130,6 +132,10 @@ int IVsEditorFactory.Close()
// We must create the WinForms designer here
var
loaderName
=
GetWinFormsLoaderName
(
vsHierarchy
);
if
(
loaderName
is
null
)
{
goto
case
"Code"
;
}
var
designerService
=
(
IVSMDDesignerService
)
_oleServiceProvider
.
QueryService
<
SVSMDDesignerService
>();
var
designerLoader
=
(
IVSMDDesignerLoader
)
designerService
.
CreateDesignerLoader
(
loaderName
);
...
...
@@ -173,7 +179,7 @@ int IVsEditorFactory.Close()
return
VSConstants
.
S_OK
;
}
private
st
atic
string
GetWinFormsLoaderName
(
IVsHierarchy
vsHierarchy
)
private
st
ring
?
GetWinFormsLoaderName
(
IVsHierarchy
vsHierarchy
)
{
const
string
LoaderName
=
"Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader"
;
const
string
NewLoaderName
=
"Microsoft.VisualStudio.Design.Core.Serialization.CodeDom.VSCodeDomDesignerLoader"
;
...
...
@@ -193,6 +199,18 @@ private static string GetWinFormsLoaderName(IVsHierarchy vsHierarchy)
if
(
frameworkName
.
Identifier
==
".NETCoreApp"
&&
frameworkName
.
Version
?.
Major
>=
3
)
{
if
(!(
_oleServiceProvider
.
QueryService
<
SVsShell
>()
is
IVsShell
shell
))
{
return
null
;
}
var
newWinFormsDesignerPackage
=
new
Guid
(
"c78ca057-cc29-421f-ad6d-3b0943debdfc"
);
if
(!
ErrorHandler
.
Succeeded
(
shell
.
IsPackageInstalled
(
newWinFormsDesignerPackage
,
out
var
installed
))
||
installed
==
0
)
{
return
null
;
}
return
NewLoaderName
;
}
}
...
...
@@ -205,7 +223,7 @@ private static string GetWinFormsLoaderName(IVsHierarchy vsHierarchy)
return
LoaderName
;
}
public
int
MapLogicalView
(
ref
Guid
rguidLogicalView
,
out
string
pbstrPhysicalView
)
public
int
MapLogicalView
(
ref
Guid
rguidLogicalView
,
out
string
?
pbstrPhysicalView
)
{
pbstrPhysicalView
=
null
;
...
...
@@ -267,7 +285,7 @@ private void FormatDocumentCreatedFromTemplate(IVsHierarchy hierarchy, uint item
var
workspace
=
_componentModel
.
GetService
<
VisualStudioWorkspace
>();
var
solution
=
workspace
.
CurrentSolution
;
ProjectId
projectIdToAddTo
=
null
;
ProjectId
?
projectIdToAddTo
=
null
;
foreach
(
var
projectId
in
solution
.
ProjectIds
)
{
...
...
@@ -292,7 +310,7 @@ private void FormatDocumentCreatedFromTemplate(IVsHierarchy hierarchy, uint item
var
documentId
=
DocumentId
.
CreateNewId
(
projectIdToAddTo
);
var
forkedSolution
=
solution
.
AddDocument
(
DocumentInfo
.
Create
(
documentId
,
filePath
,
loader
:
new
FileTextLoader
(
filePath
,
defaultEncoding
:
null
),
filePath
:
filePath
));
var
addedDocument
=
forkedSolution
.
GetDocument
(
documentId
);
var
addedDocument
=
forkedSolution
.
GetDocument
(
documentId
)
!
;
var
rootToFormat
=
addedDocument
.
GetSyntaxRootSynchronously
(
cancellationToken
);
var
documentOptions
=
ThreadHelper
.
JoinableTaskFactory
.
Run
(()
=>
addedDocument
.
GetOptionsAsync
(
cancellationToken
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录