Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
068e0a7e
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,发现更多精彩内容 >>
提交
068e0a7e
编写于
5月 14, 2017
作者:
C
CyrusNajmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add user facing Code Style Option.
上级
4a4fedd5
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
37 addition
and
9 deletion
+37
-9
src/Features/CSharp/Portable/UseDefaultLiteral/CSharpUseDefaultLiteralDiagnosticAnalyzer.cs
...faultLiteral/CSharpUseDefaultLiteralDiagnosticAnalyzer.cs
+1
-1
src/VisualStudio/CSharp/Impl/Options/Formatting/StyleViewModel.cs
...alStudio/CSharp/Impl/Options/Formatting/StyleViewModel.cs
+16
-0
src/VisualStudio/Core/Def/ServicesVSResources.Designer.cs
src/VisualStudio/Core/Def/ServicesVSResources.Designer.cs
+10
-1
src/VisualStudio/Core/Def/ServicesVSResources.resx
src/VisualStudio/Core/Def/ServicesVSResources.resx
+5
-2
src/Workspaces/CSharp/Portable/CodeStyle/CSharpCodeStyleOptions.cs
...paces/CSharp/Portable/CodeStyle/CSharpCodeStyleOptions.cs
+5
-5
未找到文件。
src/Features/CSharp/Portable/UseDefaultLiteral/CSharpUseDefaultLiteralDiagnosticAnalyzer.cs
浏览文件 @
068e0a7e
...
...
@@ -53,7 +53,7 @@ private void AnalyzeSyntax(SyntaxNodeAnalysisContext context)
return
;
}
var
codeStyleOption
=
optionSet
.
GetOption
(
CSharpCodeStyleOptions
.
Prefer
SimpleDefault
);
var
codeStyleOption
=
optionSet
.
GetOption
(
CSharpCodeStyleOptions
.
Prefer
DefaultLiteral
);
if
(!
codeStyleOption
.
Value
)
{
return
;
...
...
src/VisualStudio/CSharp/Impl/Options/Formatting/StyleViewModel.cs
浏览文件 @
068e0a7e
...
...
@@ -425,6 +425,21 @@ public Customer()
//]
}}
}}
"
;
private
static
readonly
string
s_preferDefaultLiteral
=
$@"
using System.Threading;
class Customer
{{
//[
// {ServicesVSResources.Prefer_colon}
void
DoWork
(
CancellationToken
cancellationToken
=
default
)
{{
}}
// {ServicesVSResources.Over_colon}
void
DoWork
(
CancellationToken
cancellationToken
=
default
(
CancellationToken
))
{{
}}
//]
}}
"
;
private
static
readonly
string
s_preferInlinedVariableDeclaration
=
$@"
...
...
@@ -693,6 +708,7 @@ internal StyleViewModel(OptionSet optionSet, IServiceProvider serviceProvider) :
CodeStyleItems
.
Add
(
new
BooleanCodeStyleOptionViewModel
(
CSharpCodeStyleOptions
.
PreferPatternMatchingOverIsWithCastCheck
,
CSharpVSResources
.
Prefer_pattern_matching_over_is_with_cast_check
,
s_preferPatternMatchingOverIsWithCastCheck
,
s_preferPatternMatchingOverIsWithCastCheck
,
this
,
optionSet
,
expressionPreferencesGroupTitle
));
CodeStyleItems
.
Add
(
new
BooleanCodeStyleOptionViewModel
(
CSharpCodeStyleOptions
.
PreferPatternMatchingOverAsWithNullCheck
,
CSharpVSResources
.
Prefer_pattern_matching_over_as_with_null_check
,
s_preferPatternMatchingOverAsWithNullCheck
,
s_preferPatternMatchingOverAsWithNullCheck
,
this
,
optionSet
,
expressionPreferencesGroupTitle
));
CodeStyleItems
.
Add
(
new
BooleanCodeStyleOptionViewModel
(
CodeStyleOptions
.
PreferExplicitTupleNames
,
ServicesVSResources
.
Prefer_explicit_tuple_name
,
s_preferExplicitTupleName
,
s_preferExplicitTupleName
,
this
,
optionSet
,
expressionPreferencesGroupTitle
));
CodeStyleItems
.
Add
(
new
BooleanCodeStyleOptionViewModel
(
CSharpCodeStyleOptions
.
PreferDefaultLiteral
,
ServicesVSResources
.
Prefer_default_literal
,
s_preferDefaultLiteral
,
s_preferDefaultLiteral
,
this
,
optionSet
,
expressionPreferencesGroupTitle
));
AddExpressionBodyOptions
(
optionSet
,
expressionPreferencesGroupTitle
);
...
...
src/VisualStudio/Core/Def/ServicesVSResources.Designer.cs
浏览文件 @
068e0a7e
...
...
@@ -19,7 +19,7 @@ namespace Microsoft.VisualStudio.LanguageServices {
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[
global
::
System
.
CodeDom
.
Compiler
.
GeneratedCodeAttribute
(
"System.Resources.Tools.StronglyTypedResourceBuilder"
,
"
4
.0.0.0"
)]
[
global
::
System
.
CodeDom
.
Compiler
.
GeneratedCodeAttribute
(
"System.Resources.Tools.StronglyTypedResourceBuilder"
,
"
15
.0.0.0"
)]
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
()]
[
global
::
System
.
Runtime
.
CompilerServices
.
CompilerGeneratedAttribute
()]
internal
class
ServicesVSResources
{
...
...
@@ -1502,6 +1502,15 @@ internal class ServicesVSResources {
}
}
/// <summary>
/// Looks up a localized string similar to Prefer 'default' literal.
/// </summary>
internal
static
string
Prefer_default_literal
{
get
{
return
ResourceManager
.
GetString
(
"Prefer_default_literal"
,
resourceCulture
);
}
}
/// <summary>
/// Looks up a localized string similar to Prefer explicit tuple name.
/// </summary>
...
...
src/VisualStudio/Core/Def/ServicesVSResources.resx
浏览文件 @
068e0a7e
...
...
@@ -906,10 +906,13 @@ Additional information: {1}</value>
<data
name=
"prefer_throwing_properties"
xml:space=
"preserve"
>
<value>
prefer throwing properties
</value>
</data>
<data
name=
"When_generating_properties"
xml:space=
"preserve"
>
<data
name=
"When_generating_properties"
xml:space=
"preserve"
>
<value>
When generating properties:
</value>
</data>
</data>
<data
name=
"Options"
xml:space=
"preserve"
>
<value>
Options
</value>
</data>
<data
name=
"Prefer_default_literal"
xml:space=
"preserve"
>
<value>
Prefer 'default' literal
</value>
</data>
</root>
\ No newline at end of file
src/Workspaces/CSharp/Portable/CodeStyle/CSharpCodeStyleOptions.cs
浏览文件 @
068e0a7e
...
...
@@ -134,11 +134,11 @@ internal static class CSharpCodeStyleOptions
EditorConfigStorageLocation
.
ForBoolCodeStyleOption
(
"csharp_prefer_braces"
),
new
RoamingProfileStorageLocation
(
$"TextEditor.CSharp.Specific.
{
nameof
(
PreferBraces
)}
"
)});
public
static
readonly
Option
<
CodeStyleOption
<
bool
>>
Prefer
SimpleDefault
=
new
Option
<
CodeStyleOption
<
bool
>>(
nameof
(
CodeStyleOptions
),
nameof
(
Prefer
SimpleDefault
),
defaultValue
:
CodeStyleOptions
.
TrueWithSuggestionEnforcement
,
public
static
readonly
Option
<
CodeStyleOption
<
bool
>>
Prefer
DefaultLiteral
=
new
Option
<
CodeStyleOption
<
bool
>>(
nameof
(
CodeStyleOptions
),
nameof
(
Prefer
DefaultLiteral
),
defaultValue
:
CodeStyleOptions
.
TrueWithSuggestionEnforcement
,
storageLocations
:
new
OptionStorageLocation
[]
{
EditorConfigStorageLocation
.
ForBoolCodeStyleOption
(
"csharp_prefer_
simple_default
"
),
new
RoamingProfileStorageLocation
(
$"TextEditor.CSharp.Specific.
{
nameof
(
Prefer
SimpleDefault
)}
"
)});
EditorConfigStorageLocation
.
ForBoolCodeStyleOption
(
"csharp_prefer_
default_literal
"
),
new
RoamingProfileStorageLocation
(
$"TextEditor.CSharp.Specific.
{
nameof
(
Prefer
DefaultLiteral
)}
"
)});
public
static
IEnumerable
<
Option
<
CodeStyleOption
<
bool
>>>
GetCodeStyleOptions
()
{
...
...
@@ -149,7 +149,7 @@ public static IEnumerable<Option<CodeStyleOption<bool>>> GetCodeStyleOptions()
yield
return
PreferPatternMatchingOverAsWithNullCheck
;
yield
return
PreferPatternMatchingOverIsWithCastCheck
;
yield
return
PreferBraces
;
yield
return
Prefer
SimpleDefault
;
yield
return
Prefer
DefaultLiteral
;
}
public
static
IEnumerable
<
Option
<
CodeStyleOption
<
ExpressionBodyPreference
>>>
GetExpressionBodyOptions
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录