Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
0ec91a96
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,发现更多精彩内容 >>
未验证
提交
0ec91a96
编写于
3月 03, 2019
作者:
A
Andrew Hall
提交者:
GitHub
3月 03, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #33647 from CyrusNajmabadi/whenExplicit
Rename and cleanup some members in the 'use var' feature.
上级
880d35aa
cb82414a
变更
23
隐藏空白更改
内联
并排
Showing
23 changed file
with
186 addition
and
203 deletion
+186
-203
src/EditorFeatures/CSharpTest/CodeActions/ExtractMethod/ExtractMethodTests.cs
...SharpTest/CodeActions/ExtractMethod/ExtractMethodTests.cs
+2
-2
src/EditorFeatures/CSharpTest/CodeActions/IntroduceVariable/IntroduceVariableTests.cs
...t/CodeActions/IntroduceVariable/IntroduceVariableTests.cs
+3
-3
src/EditorFeatures/CSharpTest/CodeRefactorings/UseExplicitOrImplicitType/AbstractUseTypeRefactoringTests.cs
...ExplicitOrImplicitType/AbstractUseTypeRefactoringTests.cs
+30
-30
src/EditorFeatures/CSharpTest/ConvertForEachToFor/ConvertForEachToForTests.cs
...SharpTest/ConvertForEachToFor/ConvertForEachToForTests.cs
+3
-3
src/EditorFeatures/CSharpTest/ConvertForToForEach/ConvertForToForEachTests.cs
...SharpTest/ConvertForToForEach/ConvertForToForEachTests.cs
+3
-3
src/EditorFeatures/CSharpTest/Diagnostics/UseImplicitOrExplicitType/UseExplicitTypeTests.cs
...nostics/UseImplicitOrExplicitType/UseExplicitTypeTests.cs
+15
-15
src/EditorFeatures/CSharpTest/Diagnostics/UseImplicitOrExplicitType/UseImplicitTypeTests.cs
...nostics/UseImplicitOrExplicitType/UseImplicitTypeTests.cs
+18
-18
src/EditorFeatures/CSharpTest/GenerateVariable/GenerateVariableTests.cs
...ures/CSharpTest/GenerateVariable/GenerateVariableTests.cs
+3
-3
src/EditorFeatures/CSharpTest/SimplifyTypeNames/SimplifyTypeNamesTests.cs
...es/CSharpTest/SimplifyTypeNames/SimplifyTypeNamesTests.cs
+3
-3
src/EditorFeatures/CSharpTest/UseConditionalExpression/UseConditionalExpressionForAssignmentTests.cs
...lExpression/UseConditionalExpressionForAssignmentTests.cs
+6
-6
src/EditorFeatures/Test2/Simplification/TypeNameSimplifierTest.vb
...orFeatures/Test2/Simplification/TypeNameSimplifierTest.vb
+12
-12
src/Features/CSharp/Portable/Diagnostics/Analyzers/CSharpTypeStyleDiagnosticAnalyzerBase.cs
...ostics/Analyzers/CSharpTypeStyleDiagnosticAnalyzerBase.cs
+3
-3
src/Features/CSharp/Portable/InlineDeclaration/CSharpInlineDeclarationCodeFixProvider.cs
...lineDeclaration/CSharpInlineDeclarationCodeFixProvider.cs
+2
-2
src/VisualStudio/CSharp/Impl/Options/AutomationObject.cs
src/VisualStudio/CSharp/Impl/Options/AutomationObject.cs
+6
-6
src/VisualStudio/CSharp/Impl/Options/Formatting/StyleViewModel.cs
...alStudio/CSharp/Impl/Options/Formatting/StyleViewModel.cs
+3
-3
src/VisualStudio/Core/Test.Next/Services/VisualStudioDiagnosticAnalyzerExecutorTests.cs
...t/Services/VisualStudioDiagnosticAnalyzerExecutorTests.cs
+2
-2
src/Workspaces/CSharp/Portable/CodeStyle/CSharpCodeStyleOptions.cs
...paces/CSharp/Portable/CodeStyle/CSharpCodeStyleOptions.cs
+9
-9
src/Workspaces/CSharp/Portable/CodeStyle/TypeStyle/TypeStyle.cs
...rkspaces/CSharp/Portable/CodeStyle/TypeStyle/TypeStyle.cs
+4
-4
src/Workspaces/CSharp/Portable/CodeStyle/TypeStyle/TypeStyleHelper.cs
...es/CSharp/Portable/CodeStyle/TypeStyle/TypeStyleHelper.cs
+33
-50
src/Workspaces/CSharp/Portable/Utilities/CSharpTypeStyleHelper.State.cs
.../CSharp/Portable/Utilities/CSharpTypeStyleHelper.State.cs
+19
-19
src/Workspaces/CSharp/Portable/Utilities/CSharpUseExplicitTypeHelper.cs
.../CSharp/Portable/Utilities/CSharpUseExplicitTypeHelper.cs
+3
-3
src/Workspaces/CSharp/Portable/Utilities/CSharpUseImplicitTypeHelper.cs
.../CSharp/Portable/Utilities/CSharpUseImplicitTypeHelper.cs
+3
-3
src/Workspaces/CoreTest/Execution/SnapshotSerializationTests.cs
...rkspaces/CoreTest/Execution/SnapshotSerializationTests.cs
+1
-1
未找到文件。
src/EditorFeatures/CSharpTest/CodeActions/ExtractMethod/ExtractMethodTests.cs
浏览文件 @
0ec91a96
...
...
@@ -1423,7 +1423,7 @@ private static string NewMethod(int i)
return v;
}
}"
,
options
:
Option
(
CSharpCodeStyleOptions
.
UseImplicitTypeForIntrinsic
Types
,
CodeStyleOptions
.
TrueWithSuggestionEnforcement
));
}"
,
options
:
Option
(
CSharpCodeStyleOptions
.
VarForBuiltIn
Types
,
CodeStyleOptions
.
TrueWithSuggestionEnforcement
));
}
[
WorkItem
(
15219
,
"https://github.com/dotnet/roslyn/issues/15219"
)]
...
...
@@ -1471,7 +1471,7 @@ private static string NewMethod(int i)
return v;
}
}"
,
options
:
Option
(
CSharpCodeStyleOptions
.
UseImplicitTypeWhere
Apparent
,
CodeStyleOptions
.
TrueWithSuggestionEnforcement
));
}"
,
options
:
Option
(
CSharpCodeStyleOptions
.
VarWhenTypeIs
Apparent
,
CodeStyleOptions
.
TrueWithSuggestionEnforcement
));
}
[
Fact
]
...
...
src/EditorFeatures/CSharpTest/CodeActions/IntroduceVariable/IntroduceVariableTests.cs
浏览文件 @
0ec91a96
...
...
@@ -31,9 +31,9 @@ protected override ImmutableArray<CodeAction> MassageActions(ImmutableArray<Code
// specify all options explicitly to override defaults.
private
IDictionary
<
OptionKey
,
object
>
ImplicitTypingEverywhere
()
=>
OptionsSet
(
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWherePossibl
e
,
onWithInfo
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWhere
Apparent
,
onWithInfo
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeForIntrinsic
Types
,
onWithInfo
));
SingleOption
(
CSharpCodeStyleOptions
.
VarElsewher
e
,
onWithInfo
),
SingleOption
(
CSharpCodeStyleOptions
.
VarWhenTypeIs
Apparent
,
onWithInfo
),
SingleOption
(
CSharpCodeStyleOptions
.
VarForBuiltIn
Types
,
onWithInfo
));
internal
IDictionary
<
OptionKey
,
object
>
OptionSet
(
OptionKey
option
,
object
value
)
{
...
...
src/EditorFeatures/CSharpTest/CodeRefactorings/UseExplicitOrImplicitType/AbstractUseTypeRefactoringTests.cs
浏览文件 @
0ec91a96
...
...
@@ -21,53 +21,53 @@ public abstract class AbstractUseTypeRefactoringTests : AbstractCSharpCodeAction
private
readonly
CodeStyleOption
<
bool
>
onWithError
=
new
CodeStyleOption
<
bool
>(
true
,
NotificationOption
.
Error
);
protected
IDictionary
<
OptionKey
,
object
>
PreferExplicitTypeWithError
()
=>
OptionsSet
(
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWherePossibl
e
,
offWithError
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWhere
Apparent
,
offWithError
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeForIntrinsic
Types
,
offWithError
));
SingleOption
(
CSharpCodeStyleOptions
.
VarElsewher
e
,
offWithError
),
SingleOption
(
CSharpCodeStyleOptions
.
VarWhenTypeIs
Apparent
,
offWithError
),
SingleOption
(
CSharpCodeStyleOptions
.
VarForBuiltIn
Types
,
offWithError
));
protected
IDictionary
<
OptionKey
,
object
>
PreferImplicitTypeWithError
()
=>
OptionsSet
(
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWherePossibl
e
,
onWithError
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWhere
Apparent
,
onWithError
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeForIntrinsic
Types
,
onWithError
));
SingleOption
(
CSharpCodeStyleOptions
.
VarElsewher
e
,
onWithError
),
SingleOption
(
CSharpCodeStyleOptions
.
VarWhenTypeIs
Apparent
,
onWithError
),
SingleOption
(
CSharpCodeStyleOptions
.
VarForBuiltIn
Types
,
onWithError
));
protected
IDictionary
<
OptionKey
,
object
>
PreferExplicitTypeWithWarning
()
=>
OptionsSet
(
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWherePossibl
e
,
offWithWarning
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWhere
Apparent
,
offWithWarning
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeForIntrinsic
Types
,
offWithWarning
));
SingleOption
(
CSharpCodeStyleOptions
.
VarElsewher
e
,
offWithWarning
),
SingleOption
(
CSharpCodeStyleOptions
.
VarWhenTypeIs
Apparent
,
offWithWarning
),
SingleOption
(
CSharpCodeStyleOptions
.
VarForBuiltIn
Types
,
offWithWarning
));
protected
IDictionary
<
OptionKey
,
object
>
PreferImplicitTypeWithWarning
()
=>
OptionsSet
(
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWherePossibl
e
,
onWithWarning
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWhere
Apparent
,
onWithWarning
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeForIntrinsic
Types
,
onWithWarning
));
SingleOption
(
CSharpCodeStyleOptions
.
VarElsewher
e
,
onWithWarning
),
SingleOption
(
CSharpCodeStyleOptions
.
VarWhenTypeIs
Apparent
,
onWithWarning
),
SingleOption
(
CSharpCodeStyleOptions
.
VarForBuiltIn
Types
,
onWithWarning
));
protected
IDictionary
<
OptionKey
,
object
>
PreferExplicitTypeWithInfo
()
=>
OptionsSet
(
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWherePossibl
e
,
offWithInfo
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWhere
Apparent
,
offWithInfo
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeForIntrinsic
Types
,
offWithInfo
));
SingleOption
(
CSharpCodeStyleOptions
.
VarElsewher
e
,
offWithInfo
),
SingleOption
(
CSharpCodeStyleOptions
.
VarWhenTypeIs
Apparent
,
offWithInfo
),
SingleOption
(
CSharpCodeStyleOptions
.
VarForBuiltIn
Types
,
offWithInfo
));
protected
IDictionary
<
OptionKey
,
object
>
PreferImplicitTypeWithInfo
()
=>
OptionsSet
(
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWherePossibl
e
,
onWithInfo
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWhere
Apparent
,
onWithInfo
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeForIntrinsic
Types
,
onWithInfo
));
SingleOption
(
CSharpCodeStyleOptions
.
VarElsewher
e
,
onWithInfo
),
SingleOption
(
CSharpCodeStyleOptions
.
VarWhenTypeIs
Apparent
,
onWithInfo
),
SingleOption
(
CSharpCodeStyleOptions
.
VarForBuiltIn
Types
,
onWithInfo
));
protected
IDictionary
<
OptionKey
,
object
>
PreferExplicitTypeWithSilent
()
=>
OptionsSet
(
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWherePossibl
e
,
offWithSilent
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWhere
Apparent
,
offWithSilent
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeForIntrinsic
Types
,
offWithSilent
));
SingleOption
(
CSharpCodeStyleOptions
.
VarElsewher
e
,
offWithSilent
),
SingleOption
(
CSharpCodeStyleOptions
.
VarWhenTypeIs
Apparent
,
offWithSilent
),
SingleOption
(
CSharpCodeStyleOptions
.
VarForBuiltIn
Types
,
offWithSilent
));
protected
IDictionary
<
OptionKey
,
object
>
PreferImplicitTypeWithSilent
()
=>
OptionsSet
(
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWherePossibl
e
,
onWithSilent
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWhere
Apparent
,
onWithSilent
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeForIntrinsic
Types
,
onWithSilent
));
SingleOption
(
CSharpCodeStyleOptions
.
VarElsewher
e
,
onWithSilent
),
SingleOption
(
CSharpCodeStyleOptions
.
VarWhenTypeIs
Apparent
,
onWithSilent
),
SingleOption
(
CSharpCodeStyleOptions
.
VarForBuiltIn
Types
,
onWithSilent
));
protected
IDictionary
<
OptionKey
,
object
>
PreferExplicitTypeWithNone
()
=>
OptionsSet
(
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWherePossibl
e
,
offWithNone
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWhere
Apparent
,
offWithNone
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeForIntrinsic
Types
,
offWithNone
));
SingleOption
(
CSharpCodeStyleOptions
.
VarElsewher
e
,
offWithNone
),
SingleOption
(
CSharpCodeStyleOptions
.
VarWhenTypeIs
Apparent
,
offWithNone
),
SingleOption
(
CSharpCodeStyleOptions
.
VarForBuiltIn
Types
,
offWithNone
));
protected
IDictionary
<
OptionKey
,
object
>
PreferImplicitTypeWithNone
()
=>
OptionsSet
(
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWherePossibl
e
,
onWithNone
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWhere
Apparent
,
onWithNone
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeForIntrinsic
Types
,
onWithNone
));
SingleOption
(
CSharpCodeStyleOptions
.
VarElsewher
e
,
onWithNone
),
SingleOption
(
CSharpCodeStyleOptions
.
VarWhenTypeIs
Apparent
,
onWithNone
),
SingleOption
(
CSharpCodeStyleOptions
.
VarForBuiltIn
Types
,
onWithNone
));
}
}
src/EditorFeatures/CSharpTest/ConvertForEachToFor/ConvertForEachToForTests.cs
浏览文件 @
0ec91a96
...
...
@@ -23,9 +23,9 @@ public partial class ConvertForEachToForTests : AbstractCSharpCodeActionTest
private
readonly
CodeStyleOption
<
bool
>
onWithSilent
=
new
CodeStyleOption
<
bool
>(
true
,
NotificationOption
.
Silent
);
private
IDictionary
<
OptionKey
,
object
>
ImplicitTypeEverywhere
=>
OptionsSet
(
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWherePossibl
e
,
onWithSilent
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWhere
Apparent
,
onWithSilent
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeForIntrinsic
Types
,
onWithSilent
));
SingleOption
(
CSharpCodeStyleOptions
.
VarElsewher
e
,
onWithSilent
),
SingleOption
(
CSharpCodeStyleOptions
.
VarWhenTypeIs
Apparent
,
onWithSilent
),
SingleOption
(
CSharpCodeStyleOptions
.
VarForBuiltIn
Types
,
onWithSilent
));
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsConvertForEachToFor
)]
public
async
Task
EmptyBlockBody
()
...
...
src/EditorFeatures/CSharpTest/ConvertForToForEach/ConvertForToForEachTests.cs
浏览文件 @
0ec91a96
...
...
@@ -21,9 +21,9 @@ protected override CodeRefactoringProvider CreateCodeRefactoringProvider(Workspa
private
readonly
CodeStyleOption
<
bool
>
onWithSilent
=
new
CodeStyleOption
<
bool
>(
true
,
NotificationOption
.
Silent
);
private
IDictionary
<
OptionKey
,
object
>
ImplicitTypeEverywhere
()
=>
OptionsSet
(
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWherePossibl
e
,
onWithSilent
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWhere
Apparent
,
onWithSilent
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeForIntrinsic
Types
,
onWithSilent
));
SingleOption
(
CSharpCodeStyleOptions
.
VarElsewher
e
,
onWithSilent
),
SingleOption
(
CSharpCodeStyleOptions
.
VarWhenTypeIs
Apparent
,
onWithSilent
),
SingleOption
(
CSharpCodeStyleOptions
.
VarForBuiltIn
Types
,
onWithSilent
));
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsConvertForToForEach
)]
public
async
Task
TestArray1
()
...
...
src/EditorFeatures/CSharpTest/Diagnostics/UseImplicitOrExplicitType/UseExplicitTypeTests.cs
浏览文件 @
0ec91a96
...
...
@@ -31,29 +31,29 @@ internal override (DiagnosticAnalyzer, CodeFixProvider) CreateDiagnosticProvider
// specify all options explicitly to override defaults.
private
IDictionary
<
OptionKey
,
object
>
ExplicitTypeEverywhere
()
=>
OptionsSet
(
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWherePossibl
e
,
offWithInfo
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWhere
Apparent
,
offWithInfo
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeForIntrinsic
Types
,
offWithInfo
));
SingleOption
(
CSharpCodeStyleOptions
.
VarElsewher
e
,
offWithInfo
),
SingleOption
(
CSharpCodeStyleOptions
.
VarWhenTypeIs
Apparent
,
offWithInfo
),
SingleOption
(
CSharpCodeStyleOptions
.
VarForBuiltIn
Types
,
offWithInfo
));
private
IDictionary
<
OptionKey
,
object
>
ExplicitTypeExceptWhereApparent
()
=>
OptionsSet
(
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWherePossibl
e
,
offWithInfo
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWhere
Apparent
,
onWithInfo
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeForIntrinsic
Types
,
offWithInfo
));
SingleOption
(
CSharpCodeStyleOptions
.
VarElsewher
e
,
offWithInfo
),
SingleOption
(
CSharpCodeStyleOptions
.
VarWhenTypeIs
Apparent
,
onWithInfo
),
SingleOption
(
CSharpCodeStyleOptions
.
VarForBuiltIn
Types
,
offWithInfo
));
private
IDictionary
<
OptionKey
,
object
>
ExplicitTypeForBuiltInTypesOnly
()
=>
OptionsSet
(
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWherePossibl
e
,
onWithInfo
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWhere
Apparent
,
onWithInfo
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeForIntrinsic
Types
,
offWithInfo
));
SingleOption
(
CSharpCodeStyleOptions
.
VarElsewher
e
,
onWithInfo
),
SingleOption
(
CSharpCodeStyleOptions
.
VarWhenTypeIs
Apparent
,
onWithInfo
),
SingleOption
(
CSharpCodeStyleOptions
.
VarForBuiltIn
Types
,
offWithInfo
));
private
IDictionary
<
OptionKey
,
object
>
ExplicitTypeEnforcements
()
=>
OptionsSet
(
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWherePossibl
e
,
offWithWarning
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWhere
Apparent
,
offWithError
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeForIntrinsic
Types
,
offWithInfo
));
SingleOption
(
CSharpCodeStyleOptions
.
VarElsewher
e
,
offWithWarning
),
SingleOption
(
CSharpCodeStyleOptions
.
VarWhenTypeIs
Apparent
,
offWithError
),
SingleOption
(
CSharpCodeStyleOptions
.
VarForBuiltIn
Types
,
offWithInfo
));
private
IDictionary
<
OptionKey
,
object
>
ExplicitTypeSilentEnforcement
()
=>
OptionsSet
(
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWherePossibl
e
,
offWithSilent
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWhere
Apparent
,
offWithSilent
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeForIntrinsic
Types
,
offWithSilent
));
SingleOption
(
CSharpCodeStyleOptions
.
VarElsewher
e
,
offWithSilent
),
SingleOption
(
CSharpCodeStyleOptions
.
VarWhenTypeIs
Apparent
,
offWithSilent
),
SingleOption
(
CSharpCodeStyleOptions
.
VarForBuiltIn
Types
,
offWithSilent
));
private
IDictionary
<
OptionKey
,
object
>
Options
(
OptionKey
option
,
object
value
)
{
...
...
src/EditorFeatures/CSharpTest/Diagnostics/UseImplicitOrExplicitType/UseImplicitTypeTests.cs
浏览文件 @
0ec91a96
...
...
@@ -32,34 +32,34 @@ internal override (DiagnosticAnalyzer, CodeFixProvider) CreateDiagnosticProvider
// specify all options explicitly to override defaults.
public
IDictionary
<
OptionKey
,
object
>
ImplicitTypeEverywhere
()
=>
OptionsSet
(
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWherePossibl
e
,
onWithInfo
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWhere
Apparent
,
onWithInfo
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeForIntrinsic
Types
,
onWithInfo
));
SingleOption
(
CSharpCodeStyleOptions
.
VarElsewher
e
,
onWithInfo
),
SingleOption
(
CSharpCodeStyleOptions
.
VarWhenTypeIs
Apparent
,
onWithInfo
),
SingleOption
(
CSharpCodeStyleOptions
.
VarForBuiltIn
Types
,
onWithInfo
));
private
IDictionary
<
OptionKey
,
object
>
ImplicitTypeWhereApparent
()
=>
OptionsSet
(
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWherePossibl
e
,
offWithInfo
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWhere
Apparent
,
onWithInfo
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeForIntrinsic
Types
,
offWithInfo
));
SingleOption
(
CSharpCodeStyleOptions
.
VarElsewher
e
,
offWithInfo
),
SingleOption
(
CSharpCodeStyleOptions
.
VarWhenTypeIs
Apparent
,
onWithInfo
),
SingleOption
(
CSharpCodeStyleOptions
.
VarForBuiltIn
Types
,
offWithInfo
));
private
IDictionary
<
OptionKey
,
object
>
ImplicitTypeWhereApparentAndForIntrinsics
()
=>
OptionsSet
(
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWherePossibl
e
,
offWithInfo
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWhere
Apparent
,
onWithInfo
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeForIntrinsic
Types
,
onWithInfo
));
SingleOption
(
CSharpCodeStyleOptions
.
VarElsewher
e
,
offWithInfo
),
SingleOption
(
CSharpCodeStyleOptions
.
VarWhenTypeIs
Apparent
,
onWithInfo
),
SingleOption
(
CSharpCodeStyleOptions
.
VarForBuiltIn
Types
,
onWithInfo
));
public
IDictionary
<
OptionKey
,
object
>
ImplicitTypeButKeepIntrinsics
()
=>
OptionsSet
(
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWherePossibl
e
,
onWithInfo
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeForIntrinsic
Types
,
offWithInfo
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWhere
Apparent
,
onWithInfo
));
SingleOption
(
CSharpCodeStyleOptions
.
VarElsewher
e
,
onWithInfo
),
SingleOption
(
CSharpCodeStyleOptions
.
VarForBuiltIn
Types
,
offWithInfo
),
SingleOption
(
CSharpCodeStyleOptions
.
VarWhenTypeIs
Apparent
,
onWithInfo
));
private
IDictionary
<
OptionKey
,
object
>
ImplicitTypeEnforcements
()
=>
OptionsSet
(
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWherePossibl
e
,
onWithWarning
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWhere
Apparent
,
onWithError
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeForIntrinsic
Types
,
onWithInfo
));
SingleOption
(
CSharpCodeStyleOptions
.
VarElsewher
e
,
onWithWarning
),
SingleOption
(
CSharpCodeStyleOptions
.
VarWhenTypeIs
Apparent
,
onWithError
),
SingleOption
(
CSharpCodeStyleOptions
.
VarForBuiltIn
Types
,
onWithInfo
));
private
IDictionary
<
OptionKey
,
object
>
ImplicitTypeSilentEnforcement
()
=>
OptionsSet
(
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWherePossibl
e
,
onWithSilent
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWhere
Apparent
,
onWithSilent
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeForIntrinsic
Types
,
onWithSilent
));
SingleOption
(
CSharpCodeStyleOptions
.
VarElsewher
e
,
onWithSilent
),
SingleOption
(
CSharpCodeStyleOptions
.
VarWhenTypeIs
Apparent
,
onWithSilent
),
SingleOption
(
CSharpCodeStyleOptions
.
VarForBuiltIn
Types
,
onWithSilent
));
private
static
IDictionary
<
OptionKey
,
object
>
Options
(
OptionKey
option
,
object
value
)
=>
new
Dictionary
<
OptionKey
,
object
>
{
{
option
,
value
}
};
...
...
src/EditorFeatures/CSharpTest/GenerateVariable/GenerateVariableTests.cs
浏览文件 @
0ec91a96
...
...
@@ -33,9 +33,9 @@ internal override (DiagnosticAnalyzer, CodeFixProvider) CreateDiagnosticProvider
// specify all options explicitly to override defaults.
private
IDictionary
<
OptionKey
,
object
>
ImplicitTypingEverywhere
()
=>
OptionsSet
(
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWherePossibl
e
,
onWithInfo
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWhere
Apparent
,
onWithInfo
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeForIntrinsic
Types
,
onWithInfo
));
SingleOption
(
CSharpCodeStyleOptions
.
VarElsewher
e
,
onWithInfo
),
SingleOption
(
CSharpCodeStyleOptions
.
VarWhenTypeIs
Apparent
,
onWithInfo
),
SingleOption
(
CSharpCodeStyleOptions
.
VarForBuiltIn
Types
,
onWithInfo
));
internal
IDictionary
<
OptionKey
,
object
>
OptionSet
(
OptionKey
option
,
object
value
)
{
...
...
src/EditorFeatures/CSharpTest/SimplifyTypeNames/SimplifyTypeNamesTests.cs
浏览文件 @
0ec91a96
...
...
@@ -4016,9 +4016,9 @@ private async Task TestWithPredefinedTypeOptionsAsync(string code, string expect
SingleOption
(
CodeStyleOptions
.
PreferIntrinsicPredefinedTypeKeywordInDeclaration
,
this
.
offWithSilent
,
GetLanguage
()));
private
IDictionary
<
OptionKey
,
object
>
PreferImplicitTypeWithSilent
=>
OptionsSet
(
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWherePossibl
e
,
onWithSilent
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWhere
Apparent
,
onWithSilent
),
SingleOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeForIntrinsic
Types
,
onWithSilent
));
SingleOption
(
CSharpCodeStyleOptions
.
VarElsewher
e
,
onWithSilent
),
SingleOption
(
CSharpCodeStyleOptions
.
VarWhenTypeIs
Apparent
,
onWithSilent
),
SingleOption
(
CSharpCodeStyleOptions
.
VarForBuiltIn
Types
,
onWithSilent
));
private
readonly
CodeStyleOption
<
bool
>
onWithSilent
=
new
CodeStyleOption
<
bool
>(
true
,
NotificationOption
.
Silent
);
private
readonly
CodeStyleOption
<
bool
>
offWithSilent
=
new
CodeStyleOption
<
bool
>(
false
,
NotificationOption
.
Silent
);
...
...
src/EditorFeatures/CSharpTest/UseConditionalExpression/UseConditionalExpressionForAssignmentTests.cs
浏览文件 @
0ec91a96
...
...
@@ -23,9 +23,9 @@ internal override (DiagnosticAnalyzer, CodeFixProvider) CreateDiagnosticProvider
private
static
readonly
Dictionary
<
OptionKey
,
object
>
s_preferImplicitTypeAlways
=
new
Dictionary
<
OptionKey
,
object
>
{
{
CSharpCodeStyleOptions
.
UseImplicitTypeWhere
Apparent
,
CodeStyleOptions
.
TrueWithSilentEnforcement
},
{
CSharpCodeStyleOptions
.
UseImplicitTypeWherePossibl
e
,
CodeStyleOptions
.
TrueWithSilentEnforcement
},
{
CSharpCodeStyleOptions
.
UseImplicitTypeForIntrinsic
Types
,
CodeStyleOptions
.
TrueWithSilentEnforcement
},
{
CSharpCodeStyleOptions
.
VarWhenTypeIs
Apparent
,
CodeStyleOptions
.
TrueWithSilentEnforcement
},
{
CSharpCodeStyleOptions
.
VarElsewher
e
,
CodeStyleOptions
.
TrueWithSilentEnforcement
},
{
CSharpCodeStyleOptions
.
VarForBuiltIn
Types
,
CodeStyleOptions
.
TrueWithSilentEnforcement
},
};
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsUseConditionalExpression
)]
...
...
@@ -495,7 +495,7 @@ void M()
var i = true ? 0 : 1;
}
}"
,
options
:
new
Dictionary
<
OptionKey
,
object
>
{
{
CSharpCodeStyleOptions
.
UseImplicitTypeForIntrinsic
Types
,
CodeStyleOptions
.
TrueWithSilentEnforcement
}
{
CSharpCodeStyleOptions
.
VarForBuiltIn
Types
,
CodeStyleOptions
.
TrueWithSilentEnforcement
}
});
}
...
...
@@ -527,7 +527,7 @@ void M()
int i = true ? 0 : 1;
}
}"
,
options
:
new
Dictionary
<
OptionKey
,
object
>
{
{
CSharpCodeStyleOptions
.
UseImplicitTypeWhere
Apparent
,
CodeStyleOptions
.
TrueWithSilentEnforcement
}
{
CSharpCodeStyleOptions
.
VarWhenTypeIs
Apparent
,
CodeStyleOptions
.
TrueWithSilentEnforcement
}
});
}
...
...
@@ -559,7 +559,7 @@ void M()
int i = true ? 0 : 1;
}
}"
,
options
:
new
Dictionary
<
OptionKey
,
object
>
{
{
CSharpCodeStyleOptions
.
UseImplicitTypeWherePossibl
e
,
CodeStyleOptions
.
TrueWithSilentEnforcement
}
{
CSharpCodeStyleOptions
.
VarElsewher
e
,
CodeStyleOptions
.
TrueWithSilentEnforcement
}
});
}
...
...
src/EditorFeatures/Test2/Simplification/TypeNameSimplifierTest.vb
浏览文件 @
0ec91a96
...
...
@@ -1471,9 +1471,9 @@ class C1
Public
Async
Function
TestCSharpSimplifyToVarLocalDeclaration
()
As
Task
Dim
simplificationOption
=
New
Dictionary
(
Of
OptionKey
,
Object
)
From
{
{
SimplificationOptions
.
PreferImplicitTypeInLocalDeclaration
,
True
},
{
CSharpCodeStyleOptions
.
UseImplicitTypeForIntrinsic
Types
,
CodeStyleOptions
.
TrueWithSilentEnforcement
},
{
CSharpCodeStyleOptions
.
UseImplicitTypeWhere
Apparent
,
CodeStyleOptions
.
TrueWithSilentEnforcement
},
{
CSharpCodeStyleOptions
.
UseImplicitTypeWherePossibl
e
,
CodeStyleOptions
.
TrueWithSilentEnforcement
}
{
CSharpCodeStyleOptions
.
VarForBuiltIn
Types
,
CodeStyleOptions
.
TrueWithSilentEnforcement
},
{
CSharpCodeStyleOptions
.
VarWhenTypeIs
Apparent
,
CodeStyleOptions
.
TrueWithSilentEnforcement
},
{
CSharpCodeStyleOptions
.
VarElsewher
e
,
CodeStyleOptions
.
TrueWithSilentEnforcement
}
}
Dim
input
=
...
...
@@ -1510,9 +1510,9 @@ class Program
Public
Async
Function
TestCSharpSimplifyToVarForeachDecl
()
As
Task
Dim
simplificationOption
=
New
Dictionary
(
Of
OptionKey
,
Object
)
From
{
{
SimplificationOptions
.
PreferImplicitTypeInLocalDeclaration
,
True
},
{
CSharpCodeStyleOptions
.
UseImplicitTypeForIntrinsic
Types
,
CodeStyleOptions
.
TrueWithSilentEnforcement
},
{
CSharpCodeStyleOptions
.
UseImplicitTypeWhere
Apparent
,
CodeStyleOptions
.
TrueWithSilentEnforcement
},
{
CSharpCodeStyleOptions
.
UseImplicitTypeWherePossibl
e
,
CodeStyleOptions
.
TrueWithSilentEnforcement
}
{
CSharpCodeStyleOptions
.
VarForBuiltIn
Types
,
CodeStyleOptions
.
TrueWithSilentEnforcement
},
{
CSharpCodeStyleOptions
.
VarWhenTypeIs
Apparent
,
CodeStyleOptions
.
TrueWithSilentEnforcement
},
{
CSharpCodeStyleOptions
.
VarElsewher
e
,
CodeStyleOptions
.
TrueWithSilentEnforcement
}
}
Dim
input
=
...
...
@@ -1551,9 +1551,9 @@ class Program
Public
Async
Function
TestCSharpSimplifyToVarCorrect
()
As
Task
Dim
simplificationOption
=
New
Dictionary
(
Of
OptionKey
,
Object
)
From
{
{
SimplificationOptions
.
PreferImplicitTypeInLocalDeclaration
,
True
},
{
CSharpCodeStyleOptions
.
UseImplicitTypeForIntrinsic
Types
,
CodeStyleOptions
.
TrueWithSilentEnforcement
},
{
CSharpCodeStyleOptions
.
UseImplicitTypeWhere
Apparent
,
CodeStyleOptions
.
TrueWithSilentEnforcement
},
{
CSharpCodeStyleOptions
.
UseImplicitTypeWherePossibl
e
,
CodeStyleOptions
.
TrueWithSilentEnforcement
}
{
CSharpCodeStyleOptions
.
VarForBuiltIn
Types
,
CodeStyleOptions
.
TrueWithSilentEnforcement
},
{
CSharpCodeStyleOptions
.
VarWhenTypeIs
Apparent
,
CodeStyleOptions
.
TrueWithSilentEnforcement
},
{
CSharpCodeStyleOptions
.
VarElsewher
e
,
CodeStyleOptions
.
TrueWithSilentEnforcement
}
}
Dim
input
=
...
...
@@ -1622,9 +1622,9 @@ class Program
Public
Async
Function
TestCSharpSimplifyToVarCorrect_QualifiedTypeNames
()
As
Task
Dim
simplificationOption
=
New
Dictionary
(
Of
OptionKey
,
Object
)
From
{
{
SimplificationOptions
.
PreferImplicitTypeInLocalDeclaration
,
True
},
{
CSharpCodeStyleOptions
.
UseImplicitTypeForIntrinsic
Types
,
CodeStyleOptions
.
TrueWithSilentEnforcement
},
{
CSharpCodeStyleOptions
.
UseImplicitTypeWhere
Apparent
,
CodeStyleOptions
.
TrueWithSilentEnforcement
},
{
CSharpCodeStyleOptions
.
UseImplicitTypeWherePossibl
e
,
CodeStyleOptions
.
TrueWithSilentEnforcement
}
{
CSharpCodeStyleOptions
.
VarForBuiltIn
Types
,
CodeStyleOptions
.
TrueWithSilentEnforcement
},
{
CSharpCodeStyleOptions
.
VarWhenTypeIs
Apparent
,
CodeStyleOptions
.
TrueWithSilentEnforcement
},
{
CSharpCodeStyleOptions
.
VarElsewher
e
,
CodeStyleOptions
.
TrueWithSilentEnforcement
}
}
Dim
input
=
...
...
src/Features/CSharp/Portable/Diagnostics/Analyzers/CSharpTypeStyleDiagnosticAnalyzerBase.cs
浏览文件 @
0ec91a96
...
...
@@ -24,9 +24,9 @@ internal abstract partial class CSharpTypeStyleDiagnosticAnalyzerBase :
public
override
bool
OpenFileOnly
(
Workspace
workspace
)
{
var
forIntrinsicTypesOption
=
workspace
.
Options
.
GetOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeForIntrinsic
Types
).
Notification
;
var
whereApparentOption
=
workspace
.
Options
.
GetOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWhere
Apparent
).
Notification
;
var
wherePossibleOption
=
workspace
.
Options
.
GetOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWherePossibl
e
).
Notification
;
var
forIntrinsicTypesOption
=
workspace
.
Options
.
GetOption
(
CSharpCodeStyleOptions
.
VarForBuiltIn
Types
).
Notification
;
var
whereApparentOption
=
workspace
.
Options
.
GetOption
(
CSharpCodeStyleOptions
.
VarWhenTypeIs
Apparent
).
Notification
;
var
wherePossibleOption
=
workspace
.
Options
.
GetOption
(
CSharpCodeStyleOptions
.
VarElsewher
e
).
Notification
;
return
!(
forIntrinsicTypesOption
==
NotificationOption
.
Warning
||
forIntrinsicTypesOption
==
NotificationOption
.
Error
||
whereApparentOption
==
NotificationOption
.
Warning
||
whereApparentOption
==
NotificationOption
.
Error
||
...
...
src/Features/CSharp/Portable/InlineDeclaration/CSharpInlineDeclarationCodeFixProvider.cs
浏览文件 @
0ec91a96
...
...
@@ -260,11 +260,11 @@ private static bool IsVarDesired(ITypeSymbol type, OptionSet options)
// If they want it for intrinsics, and this is an intrinsic, then use var.
if
(
type
.
IsSpecialType
()
==
true
)
{
return
options
.
GetOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeForIntrinsic
Types
).
Value
;
return
options
.
GetOption
(
CSharpCodeStyleOptions
.
VarForBuiltIn
Types
).
Value
;
}
// If they want "var" whenever possible, then use "var".
return
options
.
GetOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWherePossibl
e
).
Value
;
return
options
.
GetOption
(
CSharpCodeStyleOptions
.
VarElsewher
e
).
Value
;
}
private
static
DeclarationExpressionSyntax
GetDeclarationExpression
(
...
...
src/VisualStudio/CSharp/Impl/Options/AutomationObject.cs
浏览文件 @
0ec91a96
...
...
@@ -643,20 +643,20 @@ public int Style_UseVarWhenDeclaringLocals
public
string
Style_UseImplicitTypeWherePossible
{
get
{
return
GetXmlOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWherePossibl
e
);
}
set
{
SetXmlOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWherePossibl
e
,
value
);
}
get
{
return
GetXmlOption
(
CSharpCodeStyleOptions
.
VarElsewher
e
);
}
set
{
SetXmlOption
(
CSharpCodeStyleOptions
.
VarElsewher
e
,
value
);
}
}
public
string
Style_UseImplicitTypeWhereApparent
{
get
{
return
GetXmlOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWhere
Apparent
);
}
set
{
SetXmlOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWhere
Apparent
,
value
);
}
get
{
return
GetXmlOption
(
CSharpCodeStyleOptions
.
VarWhenTypeIs
Apparent
);
}
set
{
SetXmlOption
(
CSharpCodeStyleOptions
.
VarWhenTypeIs
Apparent
,
value
);
}
}
public
string
Style_UseImplicitTypeForIntrinsicTypes
{
get
{
return
GetXmlOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeForIntrinsic
Types
);
}
set
{
SetXmlOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeForIntrinsic
Types
,
value
);
}
get
{
return
GetXmlOption
(
CSharpCodeStyleOptions
.
VarForBuiltIn
Types
);
}
set
{
SetXmlOption
(
CSharpCodeStyleOptions
.
VarForBuiltIn
Types
,
value
);
}
}
public
string
Style_PreferConditionalDelegateCall
...
...
src/VisualStudio/CSharp/Impl/Options/Formatting/StyleViewModel.cs
浏览文件 @
0ec91a96
...
...
@@ -1543,9 +1543,9 @@ internal StyleViewModel(OptionStore optionStore, IServiceProvider serviceProvide
CodeStyleItems
.
Add
(
new
BooleanCodeStyleOptionViewModel
(
CodeStyleOptions
.
PreferIntrinsicPredefinedTypeKeywordInMemberAccess
,
ServicesVSResources
.
For_member_access_expressions
,
s_intrinsicPreviewMemberAccessTrue
,
s_intrinsicPreviewMemberAccessFalse
,
this
,
optionStore
,
predefinedTypesGroupTitle
,
predefinedTypesPreferences
));
// Use var
CodeStyleItems
.
Add
(
new
BooleanCodeStyleOptionViewModel
(
CSharpCodeStyleOptions
.
UseImplicitTypeForIntrinsic
Types
,
CSharpVSResources
.
For_built_in_types
,
s_varForIntrinsicsPreviewTrue
,
s_varForIntrinsicsPreviewFalse
,
this
,
optionStore
,
varGroupTitle
,
typeStylePreferences
));
CodeStyleItems
.
Add
(
new
BooleanCodeStyleOptionViewModel
(
CSharpCodeStyleOptions
.
UseImplicitTypeWhere
Apparent
,
CSharpVSResources
.
When_variable_type_is_apparent
,
s_varWhereApparentPreviewTrue
,
s_varWhereApparentPreviewFalse
,
this
,
optionStore
,
varGroupTitle
,
typeStylePreferences
));
CodeStyleItems
.
Add
(
new
BooleanCodeStyleOptionViewModel
(
CSharpCodeStyleOptions
.
UseImplicitTypeWherePossibl
e
,
CSharpVSResources
.
Elsewhere
,
s_varWherePossiblePreviewTrue
,
s_varWherePossiblePreviewFalse
,
this
,
optionStore
,
varGroupTitle
,
typeStylePreferences
));
CodeStyleItems
.
Add
(
new
BooleanCodeStyleOptionViewModel
(
CSharpCodeStyleOptions
.
VarForBuiltIn
Types
,
CSharpVSResources
.
For_built_in_types
,
s_varForIntrinsicsPreviewTrue
,
s_varForIntrinsicsPreviewFalse
,
this
,
optionStore
,
varGroupTitle
,
typeStylePreferences
));
CodeStyleItems
.
Add
(
new
BooleanCodeStyleOptionViewModel
(
CSharpCodeStyleOptions
.
VarWhenTypeIs
Apparent
,
CSharpVSResources
.
When_variable_type_is_apparent
,
s_varWhereApparentPreviewTrue
,
s_varWhereApparentPreviewFalse
,
this
,
optionStore
,
varGroupTitle
,
typeStylePreferences
));
CodeStyleItems
.
Add
(
new
BooleanCodeStyleOptionViewModel
(
CSharpCodeStyleOptions
.
VarElsewher
e
,
CSharpVSResources
.
Elsewhere
,
s_varWherePossiblePreviewTrue
,
s_varWherePossiblePreviewFalse
,
this
,
optionStore
,
varGroupTitle
,
typeStylePreferences
));
// Code block
AddBracesOptions
(
optionStore
,
codeBlockPreferencesGroupTitle
);
...
...
src/VisualStudio/Core/Test.Next/Services/VisualStudioDiagnosticAnalyzerExecutorTests.cs
浏览文件 @
0ec91a96
...
...
@@ -53,7 +53,7 @@ void Method()
Assert
.
Equal
(
DiagnosticSeverity
.
Hidden
,
diagnostics
[
0
].
Severity
);
// set option
workspace
.
Options
=
workspace
.
Options
.
WithChangedOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWhere
Apparent
,
new
CodeStyleOption
<
bool
>(
false
,
NotificationOption
.
Suggestion
));
workspace
.
Options
=
workspace
.
Options
.
WithChangedOption
(
CSharpCodeStyleOptions
.
VarWhenTypeIs
Apparent
,
new
CodeStyleOption
<
bool
>(
false
,
NotificationOption
.
Suggestion
));
analyzerResult
=
await
AnalyzeAsync
(
workspace
,
workspace
.
CurrentSolution
.
ProjectIds
.
First
(),
analyzerType
);
diagnostics
=
analyzerResult
.
SemanticLocals
[
analyzerResult
.
DocumentIds
.
First
()];
...
...
@@ -179,7 +179,7 @@ void Method()
nameof
(
IRemoteHostService
.
SynchronizeGlobalAssetsAsync
),
(
object
)(
new
Checksum
[]
{
asset
.
Checksum
}),
CancellationToken
.
None
);
// set option
workspace
.
Options
=
workspace
.
Options
.
WithChangedOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWhere
Apparent
,
new
CodeStyleOption
<
bool
>(
false
,
NotificationOption
.
Suggestion
));
workspace
.
Options
=
workspace
.
Options
.
WithChangedOption
(
CSharpCodeStyleOptions
.
VarWhenTypeIs
Apparent
,
new
CodeStyleOption
<
bool
>(
false
,
NotificationOption
.
Suggestion
));
// run analysis
var
project
=
workspace
.
CurrentSolution
.
Projects
.
First
();
...
...
src/Workspaces/CSharp/Portable/CodeStyle/CSharpCodeStyleOptions.cs
浏览文件 @
0ec91a96
...
...
@@ -17,22 +17,22 @@ internal static partial class CSharpCodeStyleOptions
private
static
Option
<
T
>
CreateOption
<
T
>(
OptionGroup
group
,
string
name
,
T
defaultValue
,
params
OptionStorageLocation
[]
storageLocations
)
=>
CodeStyleHelpers
.
CreateOption
(
group
,
nameof
(
CSharpCodeStyleOptions
),
name
,
defaultValue
,
s_allOptionsBuilder
,
storageLocations
);
public
static
readonly
Option
<
CodeStyleOption
<
bool
>>
UseImplicitTypeForIntrinsic
Types
=
CreateOption
(
CSharpCodeStyleOptionGroups
.
VarPreferences
,
nameof
(
UseImplicitTypeForIntrinsic
Types
),
public
static
readonly
Option
<
CodeStyleOption
<
bool
>>
VarForBuiltIn
Types
=
CreateOption
(
CSharpCodeStyleOptionGroups
.
VarPreferences
,
nameof
(
VarForBuiltIn
Types
),
defaultValue
:
CodeStyleOption
<
bool
>.
Default
,
storageLocations
:
new
OptionStorageLocation
[]
{
EditorConfigStorageLocation
.
ForBoolCodeStyleOption
(
"csharp_style_var_for_built_in_types"
),
new
RoamingProfileStorageLocation
(
"TextEditor.CSharp.Specific.UseImplicitTypeForIntrinsicTypes"
)});
public
static
readonly
Option
<
CodeStyleOption
<
bool
>>
UseImplicitTypeWhere
Apparent
=
CreateOption
(
CSharpCodeStyleOptionGroups
.
VarPreferences
,
nameof
(
UseImplicitTypeWhere
Apparent
),
public
static
readonly
Option
<
CodeStyleOption
<
bool
>>
VarWhenTypeIs
Apparent
=
CreateOption
(
CSharpCodeStyleOptionGroups
.
VarPreferences
,
nameof
(
VarWhenTypeIs
Apparent
),
defaultValue
:
CodeStyleOption
<
bool
>.
Default
,
storageLocations
:
new
OptionStorageLocation
[]
{
EditorConfigStorageLocation
.
ForBoolCodeStyleOption
(
"csharp_style_var_when_type_is_apparent"
),
new
RoamingProfileStorageLocation
(
"TextEditor.CSharp.Specific.UseImplicitTypeWhereApparent"
)});
public
static
readonly
Option
<
CodeStyleOption
<
bool
>>
UseImplicitTypeWherePossibl
e
=
CreateOption
(
CSharpCodeStyleOptionGroups
.
VarPreferences
,
nameof
(
UseImplicitTypeWherePossibl
e
),
public
static
readonly
Option
<
CodeStyleOption
<
bool
>>
VarElsewher
e
=
CreateOption
(
CSharpCodeStyleOptionGroups
.
VarPreferences
,
nameof
(
VarElsewher
e
),
defaultValue
:
CodeStyleOption
<
bool
>.
Default
,
storageLocations
:
new
OptionStorageLocation
[]
{
EditorConfigStorageLocation
.
ForBoolCodeStyleOption
(
"csharp_style_var_elsewhere"
),
...
...
@@ -254,9 +254,9 @@ static CSharpCodeStyleOptions()
public
static
IEnumerable
<
Option
<
CodeStyleOption
<
bool
>>>
GetCodeStyleOptions
()
{
yield
return
UseImplicitTypeForIntrinsic
Types
;
yield
return
UseImplicitTypeWhere
Apparent
;
yield
return
UseImplicitTypeWherePossibl
e
;
yield
return
VarForBuiltIn
Types
;
yield
return
VarWhenTypeIs
Apparent
;
yield
return
VarElsewher
e
;
yield
return
PreferConditionalDelegateCall
;
yield
return
PreferPatternMatchingOverAsWithNullCheck
;
yield
return
PreferPatternMatchingOverIsWithCastCheck
;
...
...
src/Workspaces/CSharp/Portable/CodeStyle/TypeStyle/TypeStyle.cs
浏览文件 @
0ec91a96
...
...
@@ -11,11 +11,11 @@
namespace
Microsoft.CodeAnalysis.CSharp.CodeStyle.TypeStyle
{
[
Flags
]
internal
enum
TypeStyle
Preference
internal
enum
UseVar
Preference
{
None
=
0
,
ImplicitTypeForIntrinsic
Types
=
1
<<
0
,
ImplicitTypeWhere
Apparent
=
1
<<
1
,
ImplicitTypeWherePossibl
e
=
1
<<
2
,
ForBuiltIn
Types
=
1
<<
0
,
WhenTypeIs
Apparent
=
1
<<
1
,
Elsewher
e
=
1
<<
2
,
}
}
src/Workspaces/CSharp/Portable/CodeStyle/TypeStyle/TypeStyleHelper.cs
浏览文件 @
0ec91a96
...
...
@@ -5,7 +5,6 @@
using
System.Threading
;
using
Microsoft.CodeAnalysis.CSharp.Extensions
;
using
Microsoft.CodeAnalysis.CSharp.Syntax
;
using
Microsoft.CodeAnalysis.Editing
;
using
Microsoft.CodeAnalysis.Options
;
using
Microsoft.CodeAnalysis.Shared.Extensions
;
...
...
@@ -13,37 +12,6 @@ namespace Microsoft.CodeAnalysis.CSharp.CodeStyle.TypeStyle
{
internal
static
class
TypeStyleHelper
{
/// <summary>
/// Given an expression or assignment, answers whether the declaration can use var keyword,
/// by looking at the user's style preferences obtained from options and the context
/// obtained from the expression.
/// </summary>
public
static
bool
IsImplicitTypePreferred
(
ExpressionSyntax
initializerExpression
,
SemanticModel
semanticModel
,
OptionSet
optionSet
,
CancellationToken
cancellationToken
)
{
var
stylePreferences
=
GetCurrentTypeStylePreferences
(
optionSet
);
var
isBuiltInTypeContext
=
IsBuiltInType
(
initializerExpression
,
semanticModel
,
cancellationToken
);
var
isTypeApparentContext
=
IsTypeApparentInAssignmentExpression
(
stylePreferences
,
initializerExpression
,
semanticModel
,
cancellationToken
);
return
IsImplicitStylePreferred
(
stylePreferences
,
isBuiltInTypeContext
,
isTypeApparentContext
);
}
/// <summary>
/// Given an expression of assignment, answers if its type is
/// considered an intrinsic predefined type.
/// </summary>
private
static
bool
IsBuiltInType
(
ExpressionSyntax
initializerExpression
,
SemanticModel
semanticModel
,
CancellationToken
cancellationToken
)
=>
IsBuiltInType
(
semanticModel
.
GetTypeInfo
(
initializerExpression
,
cancellationToken
).
Type
);
public
static
bool
IsBuiltInType
(
ITypeSymbol
type
)
=>
type
?.
IsSpecialType
()
==
true
;
...
...
@@ -57,13 +25,13 @@ public static bool IsBuiltInType(ITypeSymbol type)
}
private
static
bool
IsImplicitStylePreferred
(
TypeStyle
Preference
stylePreferences
,
bool
isBuiltInTypeContext
,
bool
isTypeApparentContext
)
UseVar
Preference
stylePreferences
,
bool
isBuiltInTypeContext
,
bool
isTypeApparentContext
)
{
return
isBuiltInTypeContext
?
stylePreferences
.
HasFlag
(
TypeStylePreference
.
ImplicitTypeForIntrinsic
Types
)
?
stylePreferences
.
HasFlag
(
UseVarPreference
.
ForBuiltIn
Types
)
:
isTypeApparentContext
?
stylePreferences
.
HasFlag
(
TypeStylePreference
.
ImplicitTypeWhere
Apparent
)
:
stylePreferences
.
HasFlag
(
TypeStylePreference
.
ImplicitTypeWherePossibl
e
);
?
stylePreferences
.
HasFlag
(
UseVarPreference
.
WhenTypeIs
Apparent
)
:
stylePreferences
.
HasFlag
(
UseVarPreference
.
Elsewher
e
);
}
/// <summary>
...
...
@@ -75,19 +43,34 @@ public static bool IsBuiltInType(ITypeSymbol type)
/// Things (like analyzers) that do have a local declaration already, should pass this in.
/// </remarks>
public
static
bool
IsTypeApparentInAssignmentExpression
(
TypeStyle
Preference
stylePreferences
,
UseVar
Preference
stylePreferences
,
ExpressionSyntax
initializerExpression
,
SemanticModel
semanticModel
,
CancellationToken
cancellationToke
n
,
ITypeSymbol
typeInDeclaration
=
null
)
ITypeSymbol
typeInDeclaratio
n
,
CancellationToken
cancellationToken
)
{
// tuple literals
if
(
initializerExpression
.
IsKind
(
SyntaxKind
.
TupleExpression
))
{
var
tuple
=
(
TupleExpressionSyntax
)
initializerExpression
;
foreach
(
var
argument
in
tuple
.
Arguments
)
if
(
typeInDeclaration
==
null
||
!
typeInDeclaration
.
IsTupleType
)
{
return
false
;
}
var
tupleType
=
(
INamedTypeSymbol
)
typeInDeclaration
;
if
(
tupleType
.
TupleElements
.
Length
!=
tuple
.
Arguments
.
Count
)
{
return
false
;
}
for
(
int
i
=
0
,
n
=
tuple
.
Arguments
.
Count
;
i
<
n
;
i
++)
{
if
(!
IsTypeApparentInAssignmentExpression
(
stylePreferences
,
argument
.
Expression
,
semanticModel
,
cancellationToken
,
typeInDeclaration
))
var
argument
=
tuple
.
Arguments
[
i
];
var
tupleElementType
=
tupleType
.
TupleElements
[
i
].
Type
;
if
(!
IsTypeApparentInAssignmentExpression
(
stylePreferences
,
argument
.
Expression
,
semanticModel
,
tupleElementType
,
cancellationToken
))
{
return
false
;
}
...
...
@@ -105,7 +88,7 @@ public static bool IsBuiltInType(ITypeSymbol type)
// literals, use var if options allow usage here.
if
(
initializerExpression
.
IsAnyLiteralExpression
())
{
return
stylePreferences
.
HasFlag
(
TypeStylePreference
.
ImplicitTypeForIntrinsic
Types
);
return
stylePreferences
.
HasFlag
(
UseVarPreference
.
ForBuiltIn
Types
);
}
// constructor invocations cases:
...
...
@@ -255,27 +238,27 @@ private static ExpressionSyntax GetRightmostInvocationExpression(ExpressionSynta
return
node
;
}
private
static
TypeStyle
Preference
GetCurrentTypeStylePreferences
(
OptionSet
optionSet
)
private
static
UseVar
Preference
GetCurrentTypeStylePreferences
(
OptionSet
optionSet
)
{
var
stylePreferences
=
TypeStyle
Preference
.
None
;
var
stylePreferences
=
UseVar
Preference
.
None
;
var
styleForIntrinsicTypes
=
optionSet
.
GetOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeForIntrinsic
Types
);
var
styleForApparent
=
optionSet
.
GetOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWhere
Apparent
);
var
styleForElsewhere
=
optionSet
.
GetOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWherePossibl
e
);
var
styleForIntrinsicTypes
=
optionSet
.
GetOption
(
CSharpCodeStyleOptions
.
VarForBuiltIn
Types
);
var
styleForApparent
=
optionSet
.
GetOption
(
CSharpCodeStyleOptions
.
VarWhenTypeIs
Apparent
);
var
styleForElsewhere
=
optionSet
.
GetOption
(
CSharpCodeStyleOptions
.
VarElsewher
e
);
if
(
styleForIntrinsicTypes
.
Value
)
{
stylePreferences
|=
TypeStylePreference
.
ImplicitTypeForIntrinsic
Types
;
stylePreferences
|=
UseVarPreference
.
ForBuiltIn
Types
;
}
if
(
styleForApparent
.
Value
)
{
stylePreferences
|=
TypeStylePreference
.
ImplicitTypeWhere
Apparent
;
stylePreferences
|=
UseVarPreference
.
WhenTypeIs
Apparent
;
}
if
(
styleForElsewhere
.
Value
)
{
stylePreferences
|=
TypeStylePreference
.
ImplicitTypeWherePossibl
e
;
stylePreferences
|=
UseVarPreference
.
Elsewher
e
;
}
return
stylePreferences
;
...
...
src/Workspaces/CSharp/Portable/Utilities/CSharpTypeStyleHelper.State.cs
浏览文件 @
0ec91a96
...
...
@@ -16,9 +16,9 @@ internal partial class CSharpTypeStyleHelper
{
protected
class
State
{
private
readonly
Dictionary
<
TypeStyle
Preference
,
ReportDiagnostic
>
_styleToSeverityMap
;
private
readonly
Dictionary
<
UseVar
Preference
,
ReportDiagnostic
>
_styleToSeverityMap
;
public
TypeStyle
Preference
TypeStylePreference
{
get
;
private
set
;
}
public
UseVar
Preference
TypeStylePreference
{
get
;
private
set
;
}
public
bool
IsInIntrinsicTypeContext
{
get
;
private
set
;
}
public
bool
IsTypeApparentInContext
{
get
;
private
set
;
}
public
bool
IsInVariableDeclarationContext
{
get
;
}
...
...
@@ -26,7 +26,7 @@ protected class State
private
State
(
bool
isVariableDeclarationContext
)
{
this
.
IsInVariableDeclarationContext
=
isVariableDeclarationContext
;
_styleToSeverityMap
=
new
Dictionary
<
TypeStyle
Preference
,
ReportDiagnostic
>();
_styleToSeverityMap
=
new
Dictionary
<
UseVar
Preference
,
ReportDiagnostic
>();
}
public
static
State
Generate
(
...
...
@@ -43,15 +43,15 @@ public ReportDiagnostic GetDiagnosticSeverityPreference()
{
if
(
IsInIntrinsicTypeContext
)
{
return
_styleToSeverityMap
[
TypeStylePreference
.
ImplicitTypeForIntrinsic
Types
];
return
_styleToSeverityMap
[
UseVarPreference
.
ForBuiltIn
Types
];
}
else
if
(
IsTypeApparentInContext
)
{
return
_styleToSeverityMap
[
TypeStylePreference
.
ImplicitTypeWhere
Apparent
];
return
_styleToSeverityMap
[
UseVarPreference
.
WhenTypeIs
Apparent
];
}
else
{
return
_styleToSeverityMap
[
TypeStylePreference
.
ImplicitTypeWherePossibl
e
];
return
_styleToSeverityMap
[
UseVarPreference
.
Elsewher
e
];
}
}
...
...
@@ -72,7 +72,7 @@ private void Initialize(SyntaxNode declaration, SemanticModel semanticModel, Opt
/// Returns true if type information could be gleaned by simply looking at the given statement.
/// This typically means that the type name occurs in right hand side of an assignment.
/// </summary>
private
bool
IsTypeApparentInDeclaration
(
VariableDeclarationSyntax
variableDeclaration
,
SemanticModel
semanticModel
,
TypeStyle
Preference
stylePreferences
,
CancellationToken
cancellationToken
)
private
bool
IsTypeApparentInDeclaration
(
VariableDeclarationSyntax
variableDeclaration
,
SemanticModel
semanticModel
,
UseVar
Preference
stylePreferences
,
CancellationToken
cancellationToken
)
{
if
(
variableDeclaration
.
Variables
.
Count
!=
1
)
{
...
...
@@ -87,7 +87,7 @@ private bool IsTypeApparentInDeclaration(VariableDeclarationSyntax variableDecla
var
initializerExpression
=
CSharpUseImplicitTypeHelper
.
GetInitializerExpression
(
initializer
.
Value
);
var
declaredTypeSymbol
=
semanticModel
.
GetTypeInfo
(
variableDeclaration
.
Type
.
StripRefIfNeeded
(),
cancellationToken
).
Type
;
return
TypeStyleHelper
.
IsTypeApparentInAssignmentExpression
(
stylePreferences
,
initializerExpression
,
semanticModel
,
cancellationToken
,
declaredTypeSymbol
);
return
TypeStyleHelper
.
IsTypeApparentInAssignmentExpression
(
stylePreferences
,
initializerExpression
,
semanticModel
,
declaredTypeSymbol
,
cancellationToken
);
}
/// <summary>
...
...
@@ -162,31 +162,31 @@ private TypeSyntax GetTypeSyntaxFromDeclaration(SyntaxNode declarationStatement)
return
null
;
}
private
TypeStyle
Preference
GetCurrentTypeStylePreferences
(
OptionSet
optionSet
)
private
UseVar
Preference
GetCurrentTypeStylePreferences
(
OptionSet
optionSet
)
{
var
stylePreferences
=
TypeStyle
Preference
.
None
;
var
stylePreferences
=
UseVar
Preference
.
None
;
var
styleForIntrinsicTypes
=
optionSet
.
GetOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeForIntrinsic
Types
);
var
styleForApparent
=
optionSet
.
GetOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWhere
Apparent
);
var
styleForElsewhere
=
optionSet
.
GetOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWherePossibl
e
);
var
styleForIntrinsicTypes
=
optionSet
.
GetOption
(
CSharpCodeStyleOptions
.
VarForBuiltIn
Types
);
var
styleForApparent
=
optionSet
.
GetOption
(
CSharpCodeStyleOptions
.
VarWhenTypeIs
Apparent
);
var
styleForElsewhere
=
optionSet
.
GetOption
(
CSharpCodeStyleOptions
.
VarElsewher
e
);
_styleToSeverityMap
.
Add
(
TypeStylePreference
.
ImplicitTypeForIntrinsic
Types
,
styleForIntrinsicTypes
.
Notification
.
Severity
);
_styleToSeverityMap
.
Add
(
TypeStylePreference
.
ImplicitTypeWhere
Apparent
,
styleForApparent
.
Notification
.
Severity
);
_styleToSeverityMap
.
Add
(
TypeStylePreference
.
ImplicitTypeWherePossibl
e
,
styleForElsewhere
.
Notification
.
Severity
);
_styleToSeverityMap
.
Add
(
UseVarPreference
.
ForBuiltIn
Types
,
styleForIntrinsicTypes
.
Notification
.
Severity
);
_styleToSeverityMap
.
Add
(
UseVarPreference
.
WhenTypeIs
Apparent
,
styleForApparent
.
Notification
.
Severity
);
_styleToSeverityMap
.
Add
(
UseVarPreference
.
Elsewher
e
,
styleForElsewhere
.
Notification
.
Severity
);
if
(
styleForIntrinsicTypes
.
Value
)
{
stylePreferences
|=
TypeStylePreference
.
ImplicitTypeForIntrinsic
Types
;
stylePreferences
|=
UseVarPreference
.
ForBuiltIn
Types
;
}
if
(
styleForApparent
.
Value
)
{
stylePreferences
|=
TypeStylePreference
.
ImplicitTypeWhere
Apparent
;
stylePreferences
|=
UseVarPreference
.
WhenTypeIs
Apparent
;
}
if
(
styleForElsewhere
.
Value
)
{
stylePreferences
|=
TypeStylePreference
.
ImplicitTypeWherePossibl
e
;
stylePreferences
|=
UseVarPreference
.
Elsewher
e
;
}
return
stylePreferences
;
...
...
src/Workspaces/CSharp/Portable/Utilities/CSharpUseExplicitTypeHelper.cs
浏览文件 @
0ec91a96
...
...
@@ -26,15 +26,15 @@ private CSharpUseExplicitTypeHelper()
if
(
state
.
IsInIntrinsicTypeContext
)
{
return
!
stylePreferences
.
HasFlag
(
TypeStylePreference
.
ImplicitTypeForIntrinsic
Types
);
return
!
stylePreferences
.
HasFlag
(
UseVarPreference
.
ForBuiltIn
Types
);
}
else
if
(
state
.
IsTypeApparentInContext
)
{
return
!
stylePreferences
.
HasFlag
(
TypeStylePreference
.
ImplicitTypeWhere
Apparent
);
return
!
stylePreferences
.
HasFlag
(
UseVarPreference
.
WhenTypeIs
Apparent
);
}
else
{
return
!
stylePreferences
.
HasFlag
(
TypeStylePreference
.
ImplicitTypeWherePossibl
e
);
return
!
stylePreferences
.
HasFlag
(
UseVarPreference
.
Elsewher
e
);
}
}
...
...
src/Workspaces/CSharp/Portable/Utilities/CSharpUseImplicitTypeHelper.cs
浏览文件 @
0ec91a96
...
...
@@ -79,15 +79,15 @@ protected override bool ShouldAnalyzeForEachStatement(ForEachStatementSyntax for
if
(
state
.
IsInIntrinsicTypeContext
)
{
return
stylePreferences
.
HasFlag
(
TypeStylePreference
.
ImplicitTypeForIntrinsic
Types
);
return
stylePreferences
.
HasFlag
(
UseVarPreference
.
ForBuiltIn
Types
);
}
else
if
(
state
.
IsTypeApparentInContext
)
{
return
stylePreferences
.
HasFlag
(
TypeStylePreference
.
ImplicitTypeWhere
Apparent
);
return
stylePreferences
.
HasFlag
(
UseVarPreference
.
WhenTypeIs
Apparent
);
}
else
{
return
stylePreferences
.
HasFlag
(
TypeStylePreference
.
ImplicitTypeWherePossibl
e
);
return
stylePreferences
.
HasFlag
(
UseVarPreference
.
Elsewher
e
);
}
}
...
...
src/Workspaces/CoreTest/Execution/SnapshotSerializationTests.cs
浏览文件 @
0ec91a96
...
...
@@ -342,7 +342,7 @@ public async Task OptionSet_Serialization_CustomValue()
workspace
.
Options
=
workspace
.
Options
.
WithChangedOption
(
CodeStyleOptions
.
QualifyFieldAccess
,
LanguageNames
.
CSharp
,
new
CodeStyleOption
<
bool
>(
false
,
NotificationOption
.
Error
))
.
WithChangedOption
(
CodeStyleOptions
.
QualifyMethodAccess
,
LanguageNames
.
VisualBasic
,
new
CodeStyleOption
<
bool
>(
true
,
NotificationOption
.
Warning
))
.
WithChangedOption
(
CSharpCodeStyleOptions
.
UseImplicitTypeWhere
Apparent
,
new
CodeStyleOption
<
bool
>(
false
,
NotificationOption
.
Suggestion
))
.
WithChangedOption
(
CSharpCodeStyleOptions
.
VarWhenTypeIs
Apparent
,
new
CodeStyleOption
<
bool
>(
false
,
NotificationOption
.
Suggestion
))
.
WithChangedOption
(
CodeStyleOptions
.
PreferIntrinsicPredefinedTypeKeywordInMemberAccess
,
LanguageNames
.
VisualBasic
,
new
CodeStyleOption
<
bool
>(
true
,
NotificationOption
.
Silent
));
await
VerifyOptionSetsAsync
(
workspace
,
LanguageNames
.
CSharp
).
ConfigureAwait
(
false
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录