Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
cb481024
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,发现更多精彩内容 >>
提交
cb481024
编写于
2月 21, 2020
作者:
S
Sam Harwell
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Avoid loading assemblies for unrelated languages
上级
9a851975
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
34 addition
and
7 deletion
+34
-7
src/Workspaces/Core/Portable/Options/GlobalOptionService.cs
src/Workspaces/Core/Portable/Options/GlobalOptionService.cs
+34
-7
未找到文件。
src/Workspaces/Core/Portable/Options/GlobalOptionService.cs
浏览文件 @
cb481024
...
...
@@ -22,6 +22,9 @@ namespace Microsoft.CodeAnalysis.Options
[
Export
(
typeof
(
IGlobalOptionService
)),
Shared
]
internal
class
GlobalOptionService
:
IGlobalOptionService
{
private
static
readonly
ImmutableDictionary
<
string
,
(
IOption
?
option
,
IEditorConfigStorageLocation2
?
storageLocation
)>
s_emptyEditorConfigKeysToOptions
=
ImmutableDictionary
.
Create
<
string
,
(
IOption
?
option
,
IEditorConfigStorageLocation2
?
storageLocation
)>(
AnalyzerConfigOptions
.
KeyComparer
);
private
readonly
Lazy
<
ImmutableHashSet
<
IOption
>>
_lazyAllOptions
;
private
readonly
ImmutableArray
<
Lazy
<
IOptionPersister
>>
_optionSerializers
;
private
readonly
ImmutableDictionary
<
string
,
Lazy
<
ImmutableHashSet
<
IOption
>>>
_serializableOptionsByLanguage
;
...
...
@@ -29,8 +32,9 @@ internal class GlobalOptionService : IGlobalOptionService
private
readonly
object
_gate
=
new
object
();
private
ImmutableDictionary
<
string
,
(
IOption
?
option
,
IEditorConfigStorageLocation2
?
storageLocation
)>
_editorConfigKeysToOptions
=
ImmutableDictionary
.
Create
<
string
,
(
IOption
?,
IEditorConfigStorageLocation2
?)>(
AnalyzerConfigOptions
.
KeyComparer
);
private
ImmutableDictionary
<
string
,
(
IOption
?
option
,
IEditorConfigStorageLocation2
?
storageLocation
)>
_neutralEditorConfigKeysToOptions
=
s_emptyEditorConfigKeysToOptions
;
private
ImmutableDictionary
<
string
,
(
IOption
?
option
,
IEditorConfigStorageLocation2
?
storageLocation
)>
_csharpEditorConfigKeysToOptions
=
s_emptyEditorConfigKeysToOptions
;
private
ImmutableDictionary
<
string
,
(
IOption
?
option
,
IEditorConfigStorageLocation2
?
storageLocation
)>
_visualBasicEditorConfigKeysToOptions
=
s_emptyEditorConfigKeysToOptions
;
private
ImmutableDictionary
<
OptionKey
,
object
?>
_currentValues
;
private
ImmutableArray
<
Workspace
>
_registeredWorkspaces
;
...
...
@@ -105,11 +109,32 @@ public IEnumerable<IOption> GetRegisteredOptions()
public
bool
TryMapEditorConfigKeyToOption
(
string
key
,
string
?
language
,
[
NotNullWhen
(
true
)]
out
IEditorConfigStorageLocation2
?
storageLocation
,
out
OptionKey
optionKey
)
{
ImmutableDictionary
<
string
,
(
IOption
?
option
,
IEditorConfigStorageLocation2
?
storageLocation
)>
temporaryOptions
=
s_emptyEditorConfigKeysToOptions
;
ref
var
editorConfigToOptionsStorage
=
ref
temporaryOptions
;
switch
(
language
)
{
case
LanguageNames
.
CSharp
:
// Suppression required due to https://github.com/dotnet/roslyn/issues/42018
editorConfigToOptionsStorage
=
ref
_csharpEditorConfigKeysToOptions
!;
break
;
case
LanguageNames
.
VisualBasic
:
// Suppression required due to https://github.com/dotnet/roslyn/issues/42018
editorConfigToOptionsStorage
=
ref
_visualBasicEditorConfigKeysToOptions
!;
break
;
case
null
:
case
""
:
// Suppression required due to https://github.com/dotnet/roslyn/issues/42018
editorConfigToOptionsStorage
=
ref
_neutralEditorConfigKeysToOptions
!;
break
;
}
var
(
option
,
storage
)
=
ImmutableInterlocked
.
GetOrAdd
(
ref
_editorConfigKeysToOptions
,
ref
editorConfigToOptionsStorage
,
key
,
(
key
,
self
)
=>
MapToOptionWithoutLanguage
(
self
,
key
),
this
);
(
key
,
arg
)
=>
MapToOptionIgnorePerLanguage
(
arg
.
self
,
key
,
arg
.
language
),
(
self
:
this
,
language
)
);
if
(
option
is
object
)
{
...
...
@@ -124,9 +149,11 @@ public bool TryMapEditorConfigKeyToOption(string key, string? language, [NotNull
return
false
;
// Local function
static
(
IOption
?
option
,
IEditorConfigStorageLocation2
?
storageLocation
)
MapToOption
WithoutLanguage
(
GlobalOptionService
service
,
string
key
)
static
(
IOption
?
option
,
IEditorConfigStorageLocation2
?
storageLocation
)
MapToOption
IgnorePerLanguage
(
GlobalOptionService
service
,
string
key
,
string
?
language
)
{
foreach
(
var
option
in
service
.
GetRegisteredOptions
())
// Use GetRegisteredSerializableOptions instead of GetRegisteredOptions to avoid loading assemblies for
// inactive languages.
foreach
(
var
option
in
service
.
GetRegisteredSerializableOptions
(
ImmutableHashSet
.
Create
(
language
??
""
)))
{
foreach
(
var
storage
in
option
.
StorageLocations
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录