Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
f1e5c451
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,发现更多精彩内容 >>
提交
f1e5c451
编写于
9月 01, 2017
作者:
C
Cyrus Najmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add tools|options support
上级
a1c7e5d3
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
51 addition
and
9 deletion
+51
-9
src/Features/CSharp/Portable/UseDeconstruction/CSharpUseDeconstructionDiagnosticAnalyzer.cs
...construction/CSharpUseDeconstructionDiagnosticAnalyzer.cs
+1
-1
src/VisualStudio/CSharp/Impl/Options/Formatting/StyleViewModel.cs
...alStudio/CSharp/Impl/Options/Formatting/StyleViewModel.cs
+28
-1
src/VisualStudio/Core/Def/ServicesVSResources.Designer.cs
src/VisualStudio/Core/Def/ServicesVSResources.Designer.cs
+9
-0
src/VisualStudio/Core/Def/ServicesVSResources.resx
src/VisualStudio/Core/Def/ServicesVSResources.resx
+3
-0
src/Workspaces/CSharp/Portable/CodeStyle/CSharpCodeStyleOptions.cs
...paces/CSharp/Portable/CodeStyle/CSharpCodeStyleOptions.cs
+0
-7
src/Workspaces/Core/Portable/CodeStyle/CodeStyleOptions.cs
src/Workspaces/Core/Portable/CodeStyle/CodeStyleOptions.cs
+8
-0
src/Workspaces/Core/Portable/Execution/AbstractOptionsSerializationService.cs
...Portable/Execution/AbstractOptionsSerializationService.cs
+2
-0
未找到文件。
src/Features/CSharp/Portable/UseDeconstruction/CSharpUseDeconstructionDiagnosticAnalyzer.cs
浏览文件 @
f1e5c451
...
...
@@ -47,7 +47,7 @@ private void AnalyzeNode(SyntaxNodeAnalysisContext context)
return
;
}
var
option
=
optionSet
.
GetOption
(
C
SharpCodeStyleOptions
.
PreferDeconstruction
);
var
option
=
optionSet
.
GetOption
(
C
odeStyleOptions
.
PreferDeconstructedVariableDeclaration
,
context
.
Node
.
Language
);
if
(!
option
.
Value
)
{
return
;
...
...
src/VisualStudio/CSharp/Impl/Options/Formatting/StyleViewModel.cs
浏览文件 @
f1e5c451
...
...
@@ -294,7 +294,7 @@ public C(string s)
}}
"
;
private
static
readonly
string
s_preferNullPropagation
=
$@"
private
static
readonly
string
s_preferNullPropagation
=
$@"
using System;
class C
...
...
@@ -499,6 +499,32 @@ public Customer(string value)
//]
}}
}}
"
;
private
static
readonly
string
s_preferDeconstructedVariableDeclaration
=
$@"
using System;
class Customer
{{
public
Customer
(
string
value
)
{{
//[
// {ServicesVSResources.Prefer_colon}
var
(
name
,
age
)
=
GetPersonTuple
();
Console
.
WriteLine
(
$""
{{
name
}}
{{
age
}}
""
);
(
int
x
,
int
y
)
=
GetPointTuple
();
Console
.
WriteLine
(
$""
{{
x
}}
{{
y
}}
""
);
// {ServicesVSResources.Over_colon}
var
person
=
GetPersonTuple
();
Console
.
WriteLine
(
$""
{{
person
.
name
}}
{{
person
.
age
}}
""
);
(
int
x
,
int
y
)
point
=
GetPointTuple
();
Console
.
WriteLine
(
$""
{{
point
.
x
}}
{{
point
.
y
}}
""
);
//]
}}
}}
"
;
private
static
readonly
string
s_preferBraces
=
$@"
...
...
@@ -798,6 +824,7 @@ internal StyleViewModel(OptionSet optionSet, IServiceProvider serviceProvider) :
// Variable preferences
CodeStyleItems
.
Add
(
new
BooleanCodeStyleOptionViewModel
(
CodeStyleOptions
.
PreferInlinedVariableDeclaration
,
ServicesVSResources
.
Prefer_inlined_variable_declaration
,
s_preferInlinedVariableDeclaration
,
s_preferInlinedVariableDeclaration
,
this
,
optionSet
,
variablePreferencesGroupTitle
));
CodeStyleItems
.
Add
(
new
BooleanCodeStyleOptionViewModel
(
CodeStyleOptions
.
PreferDeconstructedVariableDeclaration
,
ServicesVSResources
.
Prefer_deconstructed_variable_declaration
,
s_preferDeconstructedVariableDeclaration
,
s_preferDeconstructedVariableDeclaration
,
this
,
optionSet
,
variablePreferencesGroupTitle
));
// Null preferences.
CodeStyleItems
.
Add
(
new
BooleanCodeStyleOptionViewModel
(
CodeStyleOptions
.
PreferThrowExpression
,
CSharpVSResources
.
Prefer_throw_expression
,
s_preferThrowExpression
,
s_preferThrowExpression
,
this
,
optionSet
,
nullCheckingGroupTitle
));
...
...
src/VisualStudio/Core/Def/ServicesVSResources.Designer.cs
浏览文件 @
f1e5c451
...
...
@@ -1594,6 +1594,15 @@ internal class ServicesVSResources {
}
}
/// <summary>
/// Looks up a localized string similar to Prefer deconstructed variable declaration.
/// </summary>
internal
static
string
Prefer_deconstructed_variable_declaration
{
get
{
return
ResourceManager
.
GetString
(
"Prefer_deconstructed_variable_declaration"
,
resourceCulture
);
}
}
/// <summary>
/// Looks up a localized string similar to Prefer explicit tuple name.
/// </summary>
...
...
src/VisualStudio/Core/Def/ServicesVSResources.resx
浏览文件 @
f1e5c451
...
...
@@ -962,4 +962,7 @@ Additional information: {1}</value>
<data
name=
"Prefer_local_function_over_anonymous_function"
xml:space=
"preserve"
>
<value>
Prefere local function over anonymous function
</value>
</data>
<data
name=
"Prefer_deconstructed_variable_declaration"
xml:space=
"preserve"
>
<value>
Prefer deconstructed variable declaration
</value>
</data>
</root>
\ No newline at end of file
src/Workspaces/CSharp/Portable/CodeStyle/CSharpCodeStyleOptions.cs
浏览文件 @
f1e5c451
...
...
@@ -180,12 +180,6 @@ internal static class CSharpCodeStyleOptions
EditorConfigStorageLocation
.
ForBoolCodeStyleOption
(
"csharp_style_pattern_local_over_anonymous_function"
),
new
RoamingProfileStorageLocation
(
$"TextEditor.CSharp.Specific.
{
nameof
(
PreferLocalOverAnonymousFunction
)}
"
)});
public
static
readonly
Option
<
CodeStyleOption
<
bool
>>
PreferDeconstruction
=
new
Option
<
CodeStyleOption
<
bool
>>(
nameof
(
CodeStyleOptions
),
nameof
(
PreferDeconstruction
),
defaultValue
:
CodeStyleOptions
.
TrueWithSuggestionEnforcement
,
storageLocations
:
new
OptionStorageLocation
[]
{
EditorConfigStorageLocation
.
ForBoolCodeStyleOption
(
"csharp_prefer_deconstruction"
),
new
RoamingProfileStorageLocation
(
$"TextEditor.CSharp.Specific.
{
nameof
(
PreferDeconstruction
)}
"
)});
public
static
IEnumerable
<
Option
<
CodeStyleOption
<
bool
>>>
GetCodeStyleOptions
()
{
yield
return
UseImplicitTypeForIntrinsicTypes
;
...
...
@@ -199,7 +193,6 @@ public static IEnumerable<Option<CodeStyleOption<bool>>> GetCodeStyleOptions()
yield
return
PreferInferredTupleNames
;
yield
return
PreferInferredAnonymousTypeMemberNames
;
yield
return
PreferLocalOverAnonymousFunction
;
yield
return
PreferDeconstruction
;
}
public
static
IEnumerable
<
Option
<
CodeStyleOption
<
ExpressionBodyPreference
>>>
GetExpressionBodyOptions
()
...
...
src/Workspaces/Core/Portable/CodeStyle/CodeStyleOptions.cs
浏览文件 @
f1e5c451
...
...
@@ -126,6 +126,14 @@ public class CodeStyleOptions
EditorConfigStorageLocation
.
ForBoolCodeStyleOption
(
"csharp_style_inlined_variable_declaration"
),
new
RoamingProfileStorageLocation
(
"TextEditor.%LANGUAGE%.Specific.PreferInlinedVariableDeclaration"
)
});
internal
static
readonly
PerLanguageOption
<
CodeStyleOption
<
bool
>>
PreferDeconstructedVariableDeclaration
=
new
PerLanguageOption
<
CodeStyleOption
<
bool
>>(
nameof
(
CodeStyleOptions
),
nameof
(
PreferDeconstructedVariableDeclaration
),
defaultValue
:
TrueWithSuggestionEnforcement
,
storageLocations
:
new
OptionStorageLocation
[]
{
EditorConfigStorageLocation
.
ForBoolCodeStyleOption
(
"csharp_style_deconstructed_variable_declaration"
),
new
RoamingProfileStorageLocation
(
$"TextEditor.%LANGUAGE%.Specific.
{
nameof
(
PreferDeconstructedVariableDeclaration
)}
"
)});
internal
static
readonly
PerLanguageOption
<
CodeStyleOption
<
bool
>>
PreferExplicitTupleNames
=
new
PerLanguageOption
<
CodeStyleOption
<
bool
>>(
nameof
(
CodeStyleOptions
),
nameof
(
PreferExplicitTupleNames
),
...
...
src/Workspaces/Core/Portable/Execution/AbstractOptionsSerializationService.cs
浏览文件 @
f1e5c451
...
...
@@ -228,6 +228,7 @@ protected void WriteOptionSetTo(OptionSet options, string language, ObjectWriter
WriteOptionTo
(
options
,
language
,
CodeStyleOptions
.
PreferCollectionInitializer
,
writer
,
cancellationToken
);
WriteOptionTo
(
options
,
language
,
CodeStyleOptions
.
PreferExplicitTupleNames
,
writer
,
cancellationToken
);
WriteOptionTo
(
options
,
language
,
CodeStyleOptions
.
PreferInlinedVariableDeclaration
,
writer
,
cancellationToken
);
WriteOptionTo
(
options
,
language
,
CodeStyleOptions
.
PreferDeconstructedVariableDeclaration
,
writer
,
cancellationToken
);
WriteOptionTo
(
options
,
language
,
CodeStyleOptions
.
PreferNullPropagation
,
writer
,
cancellationToken
);
WriteOptionTo
(
options
,
language
,
CodeStyleOptions
.
PreferObjectInitializer
,
writer
,
cancellationToken
);
WriteOptionTo
(
options
,
language
,
CodeStyleOptions
.
PreferThrowExpression
,
writer
,
cancellationToken
);
...
...
@@ -249,6 +250,7 @@ protected OptionSet ReadOptionSetFrom(OptionSet options, string language, Object
options
=
ReadOptionFrom
(
options
,
language
,
CodeStyleOptions
.
PreferCollectionInitializer
,
reader
,
cancellationToken
);
options
=
ReadOptionFrom
(
options
,
language
,
CodeStyleOptions
.
PreferExplicitTupleNames
,
reader
,
cancellationToken
);
options
=
ReadOptionFrom
(
options
,
language
,
CodeStyleOptions
.
PreferInlinedVariableDeclaration
,
reader
,
cancellationToken
);
options
=
ReadOptionFrom
(
options
,
language
,
CodeStyleOptions
.
PreferDeconstructedVariableDeclaration
,
reader
,
cancellationToken
);
options
=
ReadOptionFrom
(
options
,
language
,
CodeStyleOptions
.
PreferNullPropagation
,
reader
,
cancellationToken
);
options
=
ReadOptionFrom
(
options
,
language
,
CodeStyleOptions
.
PreferObjectInitializer
,
reader
,
cancellationToken
);
options
=
ReadOptionFrom
(
options
,
language
,
CodeStyleOptions
.
PreferThrowExpression
,
reader
,
cancellationToken
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录