Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
6614768e
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,体验更适合开发者的 AI 搜索 >>
提交
6614768e
编写于
1月 14, 2020
作者:
M
Manish Vasani
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Address PR feedback
上级
e06510e9
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
56 addition
and
78 deletion
+56
-78
src/EditorFeatures/CSharpTest/Completion/CompletionProviders/DeclarationNameCompletionProviderTests.cs
...letionProviders/DeclarationNameCompletionProviderTests.cs
+27
-53
src/EditorFeatures/CSharpTest/Completion/CompletionProviders/PartialMethodCompletionProviderTests.cs
...mpletionProviders/PartialMethodCompletionProviderTests.cs
+6
-15
src/EditorFeatures/CSharpTest/Formatting/CodeCleanupTests.cs
src/EditorFeatures/CSharpTest/Formatting/CodeCleanupTests.cs
+1
-2
src/EditorFeatures/CSharpTest/Formatting/FormattingEngineTestBase.cs
...eatures/CSharpTest/Formatting/FormattingEngineTestBase.cs
+5
-2
src/EditorFeatures/CSharpTest/Workspaces/WorkspaceTests.cs
src/EditorFeatures/CSharpTest/Workspaces/WorkspaceTests.cs
+13
-3
src/EditorFeatures/Test/CodeGeneration/CodeGenerationTests.cs
...EditorFeatures/Test/CodeGeneration/CodeGenerationTests.cs
+4
-2
src/VisualStudio/CSharp/Impl/Options/AutomationObject.cs
src/VisualStudio/CSharp/Impl/Options/AutomationObject.cs
+0
-1
未找到文件。
src/EditorFeatures/CSharpTest/Completion/CompletionProviders/DeclarationNameCompletionProviderTests.cs
浏览文件 @
6614768e
...
...
@@ -1265,24 +1265,16 @@ void M()
public
async
Task
DisabledByOption
()
{
var
workspace
=
WorkspaceFixture
.
GetWorkspace
();
var
originalOptions
=
workspace
.
CurrentSolution
.
Options
;
try
{
workspace
.
TryApplyChanges
(
workspace
.
CurrentSolution
.
WithOptions
(
originalOptions
.
WithChangedOption
(
CompletionOptions
.
ShowNameSuggestions
,
LanguageNames
.
CSharp
,
false
)));
workspace
.
TryApplyChanges
(
workspace
.
CurrentSolution
.
WithOptions
(
workspace
.
Options
.
WithChangedOption
(
CompletionOptions
.
ShowNameSuggestions
,
LanguageNames
.
CSharp
,
false
)));
var
markup
=
@"
var
markup
=
@"
class Test
{
Test $$
}
"
;
await
VerifyNoItemsExistAsync
(
markup
);
}
finally
{
workspace
.
TryApplyChanges
(
workspace
.
CurrentSolution
.
WithOptions
(
originalOptions
));
}
await
VerifyNoItemsExistAsync
(
markup
);
}
[
WorkItem
(
23590
,
"https://github.com/dotnet/roslyn/issues/23590"
)]
...
...
@@ -1458,48 +1450,35 @@ public void Method()
public
async
Task
CustomNamingStyleInsideClass
()
{
var
workspace
=
WorkspaceFixture
.
GetWorkspace
();
var
originalOptions
=
workspace
.
Options
;
workspace
.
TryApplyChanges
(
workspace
.
CurrentSolution
.
WithOptions
(
workspace
.
Options
.
WithChangedOption
(
new
OptionKey
(
SimplificationOptions
.
NamingPreferences
,
LanguageNames
.
CSharp
),
NamesEndWithSuffixPreferences
())));
try
{
workspace
.
TryApplyChanges
(
workspace
.
CurrentSolution
.
WithOptions
(
originalOptions
.
WithChangedOption
(
new
OptionKey
(
SimplificationOptions
.
NamingPreferences
,
LanguageNames
.
CSharp
),
NamesEndWithSuffixPreferences
())));
var
markup
=
@"
var
markup
=
@"
class Configuration
{
Configuration $$
}
"
;
await
VerifyItemExistsAsync
(
markup
,
"ConfigurationField"
,
glyph
:
(
int
)
Glyph
.
FieldPublic
,
expectedDescriptionOrNull
:
CSharpFeaturesResources
.
Suggested_name
);
await
VerifyItemExistsAsync
(
markup
,
"ConfigurationProperty"
,
glyph
:
(
int
)
Glyph
.
PropertyPublic
,
expectedDescriptionOrNull
:
CSharpFeaturesResources
.
Suggested_name
);
await
VerifyItemExistsAsync
(
markup
,
"ConfigurationMethod"
,
glyph
:
(
int
)
Glyph
.
MethodPublic
,
expectedDescriptionOrNull
:
CSharpFeaturesResources
.
Suggested_name
);
await
VerifyItemIsAbsentAsync
(
markup
,
"ConfigurationLocal"
);
await
VerifyItemIsAbsentAsync
(
markup
,
"ConfigurationLocalFunction"
);
}
finally
{
workspace
.
TryApplyChanges
(
workspace
.
CurrentSolution
.
WithOptions
(
originalOptions
));
}
await
VerifyItemExistsAsync
(
markup
,
"ConfigurationField"
,
glyph
:
(
int
)
Glyph
.
FieldPublic
,
expectedDescriptionOrNull
:
CSharpFeaturesResources
.
Suggested_name
);
await
VerifyItemExistsAsync
(
markup
,
"ConfigurationProperty"
,
glyph
:
(
int
)
Glyph
.
PropertyPublic
,
expectedDescriptionOrNull
:
CSharpFeaturesResources
.
Suggested_name
);
await
VerifyItemExistsAsync
(
markup
,
"ConfigurationMethod"
,
glyph
:
(
int
)
Glyph
.
MethodPublic
,
expectedDescriptionOrNull
:
CSharpFeaturesResources
.
Suggested_name
);
await
VerifyItemIsAbsentAsync
(
markup
,
"ConfigurationLocal"
);
await
VerifyItemIsAbsentAsync
(
markup
,
"ConfigurationLocalFunction"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
public
async
Task
CustomNamingStyleInsideMethod
()
{
var
workspace
=
WorkspaceFixture
.
GetWorkspace
();
var
originalOptions
=
workspace
.
Options
;
workspace
.
TryApplyChanges
(
workspace
.
CurrentSolution
.
WithOptions
(
workspace
.
Options
.
WithChangedOption
(
new
OptionKey
(
SimplificationOptions
.
NamingPreferences
,
LanguageNames
.
CSharp
),
NamesEndWithSuffixPreferences
())));
try
{
workspace
.
TryApplyChanges
(
workspace
.
CurrentSolution
.
WithOptions
(
originalOptions
.
WithChangedOption
(
new
OptionKey
(
SimplificationOptions
.
NamingPreferences
,
LanguageNames
.
CSharp
),
NamesEndWithSuffixPreferences
())));
var
markup
=
@"
var
markup
=
@"
class Configuration
{
void M()
...
...
@@ -1508,18 +1487,13 @@ void M()
}
}
"
;
await
VerifyItemExistsAsync
(
markup
,
"ConfigurationLocal"
,
glyph
:
(
int
)
Glyph
.
Local
,
expectedDescriptionOrNull
:
CSharpFeaturesResources
.
Suggested_name
);
await
VerifyItemExistsAsync
(
markup
,
"ConfigurationLocalFunction"
,
glyph
:
(
int
)
Glyph
.
MethodPublic
,
expectedDescriptionOrNull
:
CSharpFeaturesResources
.
Suggested_name
);
await
VerifyItemIsAbsentAsync
(
markup
,
"ConfigurationField"
);
await
VerifyItemIsAbsentAsync
(
markup
,
"ConfigurationMethod"
);
await
VerifyItemIsAbsentAsync
(
markup
,
"ConfigurationProperty"
);
}
finally
{
workspace
.
TryApplyChanges
(
workspace
.
CurrentSolution
.
WithOptions
(
originalOptions
));
}
await
VerifyItemExistsAsync
(
markup
,
"ConfigurationLocal"
,
glyph
:
(
int
)
Glyph
.
Local
,
expectedDescriptionOrNull
:
CSharpFeaturesResources
.
Suggested_name
);
await
VerifyItemExistsAsync
(
markup
,
"ConfigurationLocalFunction"
,
glyph
:
(
int
)
Glyph
.
MethodPublic
,
expectedDescriptionOrNull
:
CSharpFeaturesResources
.
Suggested_name
);
await
VerifyItemIsAbsentAsync
(
markup
,
"ConfigurationField"
);
await
VerifyItemIsAbsentAsync
(
markup
,
"ConfigurationMethod"
);
await
VerifyItemIsAbsentAsync
(
markup
,
"ConfigurationProperty"
);
}
[
WorkItem
(
31304
,
"https://github.com/dotnet/roslyn/issues/31304"
)]
...
...
src/EditorFeatures/CSharpTest/Completion/CompletionProviders/PartialMethodCompletionProviderTests.cs
浏览文件 @
6614768e
...
...
@@ -483,15 +483,11 @@ partial class PClass
public
async
Task
ExpressionBodyMethod
()
{
var
workspace
=
WorkspaceFixture
.
GetWorkspace
();
var
originalOptions
=
workspace
.
Options
;
workspace
.
TryApplyChanges
(
workspace
.
CurrentSolution
.
WithOptions
(
workspace
.
Options
.
WithChangedOption
(
CSharpCodeStyleOptions
.
PreferExpressionBodiedMethods
,
new
CodeStyleOption
<
ExpressionBodyPreference
>(
ExpressionBodyPreference
.
WhenPossible
,
NotificationOption
.
Silent
))));
try
{
workspace
.
TryApplyChanges
(
workspace
.
CurrentSolution
.
WithOptions
(
originalOptions
.
WithChangedOption
(
CSharpCodeStyleOptions
.
PreferExpressionBodiedMethods
,
new
CodeStyleOption
<
ExpressionBodyPreference
>(
ExpressionBodyPreference
.
WhenPossible
,
NotificationOption
.
Silent
))));
var
text
=
@"using System;
var
text
=
@"using System;
partial class Bar
{
partial void Foo();
...
...
@@ -500,7 +496,7 @@ partial class Bar
"
;
var
expected
=
@"using System;
var
expected
=
@"using System;
partial class Bar
{
partial void Foo();
...
...
@@ -509,12 +505,7 @@ partial class Bar
"
;
await
VerifyCustomCommitProviderAsync
(
text
,
"Foo()"
,
expected
);
}
finally
{
workspace
.
TryApplyChanges
(
workspace
.
CurrentSolution
.
WithOptions
(
originalOptions
));
}
await
VerifyCustomCommitProviderAsync
(
text
,
"Foo()"
,
expected
);
}
}
}
src/EditorFeatures/CSharpTest/Formatting/CodeCleanupTests.cs
浏览文件 @
6614768e
...
...
@@ -257,8 +257,7 @@ protected static async Task AssertCodeCleanupResult(string expected, string code
using
var
workspace
=
TestWorkspace
.
CreateCSharp
(
code
,
exportProvider
:
exportProvider
);
workspace
.
TryApplyChanges
(
workspace
.
CurrentSolution
.
WithOptions
(
workspace
.
Options
.
WithChangedOption
(
GenerationOptions
.
PlaceSystemNamespaceFirst
,
LanguageNames
.
CSharp
,
systemUsingsFirst
)));
workspace
.
TryApplyChanges
(
workspace
.
CurrentSolution
.
WithOptions
(
workspace
.
Options
.
WithChangedOption
(
GenerationOptions
.
PlaceSystemNamespaceFirst
,
LanguageNames
.
CSharp
,
systemUsingsFirst
)
.
WithChangedOption
(
GenerationOptions
.
SeparateImportDirectiveGroups
,
LanguageNames
.
CSharp
,
separateUsingGroups
)));
// register this workspace to solution crawler so that analyzer service associate itself with given workspace
...
...
src/EditorFeatures/CSharpTest/Formatting/FormattingEngineTestBase.cs
浏览文件 @
6614768e
...
...
@@ -127,13 +127,16 @@ internal static void AssertFormat(Workspace workspace, string expected, OptionSe
protected
static
void
AssertFormatWithView
(
string
expectedWithMarker
,
string
codeWithMarker
,
params
(
PerLanguageOption
<
bool
>
option
,
bool
enabled
)[]
options
)
{
using
var
workspace
=
TestWorkspace
.
CreateCSharp
(
codeWithMarker
);
if
(
options
!=
null
)
{
var
optionSet
=
workspace
.
Options
;
foreach
(
var
option
in
options
)
{
workspace
.
TryApplyChanges
(
workspace
.
CurrentSolution
.
WithOptions
(
workspace
.
Options
.
WithChangedOption
(
option
.
option
,
LanguageNames
.
CSharp
,
option
.
enabled
)));
optionSet
=
optionSet
.
WithChangedOption
(
option
.
option
,
LanguageNames
.
CSharp
,
option
.
enabled
);
}
workspace
.
TryApplyChanges
(
workspace
.
CurrentSolution
.
WithOptions
(
optionSet
));
}
// set up caret position
...
...
src/EditorFeatures/CSharpTest/Workspaces/WorkspaceTests.cs
浏览文件 @
6614768e
...
...
@@ -1212,8 +1212,9 @@ public void TestSolutionWithOptions()
Assert
.
Equal
(
BackgroundAnalysisScope
.
ActiveFile
,
currentOptionValue
);
}
[
Fact
,
WorkItem
(
19284
,
"https://github.com/dotnet/roslyn/issues/19284"
)]
public
void
TestOptionChangedHandlerInvokedAfterCurrentSolutionChanged
()
[
CombinatorialData
]
[
Theory
,
WorkItem
(
19284
,
"https://github.com/dotnet/roslyn/issues/19284"
)]
public
void
TestOptionChangedHandlerInvokedAfterCurrentSolutionChanged
(
bool
testDeprecatedOptionsSetter
)
{
// Create workspaces with shared global options to replicate the true global options service shared between workspaces.
using
var
primaryWorkspace
=
CreateWorkspace
(
workspaceKind
:
TestWorkspaceName
.
NameWithSharedGlobalOptions
);
...
...
@@ -1238,7 +1239,16 @@ public void TestOptionChangedHandlerInvokedAfterCurrentSolutionChanged()
optionService
.
OptionChanged
+=
OptionService_OptionChanged
;
// Change workspace options through primary workspace
primaryWorkspace
.
SetOptions
(
primaryWorkspace
.
Options
.
WithChangedOption
(
optionKey
,
BackgroundAnalysisScope
.
ActiveFile
));
if
(
testDeprecatedOptionsSetter
)
{
#pragma warning disable CS0618 // Type or member is obsolete - this test ensures that deprecated "Workspace.set_Options" API's functionality is preserved.
primaryWorkspace
.
Options
=
primaryWorkspace
.
Options
.
WithChangedOption
(
optionKey
,
BackgroundAnalysisScope
.
ActiveFile
);
#pragma warning restore CS0618 // Type or member is obsolete
}
else
{
primaryWorkspace
.
SetOptions
(
primaryWorkspace
.
Options
.
WithChangedOption
(
optionKey
,
BackgroundAnalysisScope
.
ActiveFile
));
}
// Verify current solution and option change for both workspaces.
VerifyCurrentSolutionAndOptionChange
(
primaryWorkspace
,
beforeSolutionForPrimaryWorkspace
);
...
...
src/EditorFeatures/Test/CodeGeneration/CodeGenerationTests.cs
浏览文件 @
6614768e
...
...
@@ -357,11 +357,13 @@ public partial class CodeGenerationTests
var
workspace
=
context
.
Workspace
;
if
(
options
!=
null
)
{
var
optionSet
=
workspace
.
Options
;
foreach
(
var
kvp
in
options
)
{
workspace
.
TryApplyChanges
(
workspace
.
CurrentSolution
.
WithOptions
(
workspace
.
Options
.
WithChangedOption
(
kvp
.
Key
,
kvp
.
Value
)));
optionSet
=
optionSet
.
WithChangedOption
(
kvp
.
Key
,
kvp
.
Value
);
}
workspace
.
TryApplyChanges
(
workspace
.
CurrentSolution
.
WithOptions
(
optionSet
));
}
var
typeSymbol
=
GetTypeSymbol
(
type
)(
context
.
SemanticModel
);
...
...
src/VisualStudio/CSharp/Impl/Options/AutomationObject.cs
浏览文件 @
6614768e
...
...
@@ -13,7 +13,6 @@
using
Microsoft.CodeAnalysis.Editor.Shared.Options
;
using
Microsoft.CodeAnalysis.ExtractMethod
;
using
Microsoft.CodeAnalysis.Options
;
using
Microsoft.CodeAnalysis.Shared.Options
;
using
Microsoft.CodeAnalysis.Simplification
;
using
Microsoft.CodeAnalysis.SymbolSearch
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录