Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
2215abea
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,发现更多精彩内容 >>
未验证
提交
2215abea
编写于
2月 28, 2020
作者:
A
Allison Chou
提交者:
GitHub
2月 28, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #41452 from chris-schuetz/Issue38513
Add UnitTests for Issue #38513
上级
abd2fb03
2ecb3a57
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
138 addition
and
0 deletion
+138
-0
src/EditorFeatures/CSharpTest/Diagnostics/NamingStyles/EditorConfigNamingStyleParserTests.cs
...ostics/NamingStyles/EditorConfigNamingStyleParserTests.cs
+36
-0
src/EditorFeatures/CSharpTest/Diagnostics/NamingStyles/NamingStylesTests.cs
.../CSharpTest/Diagnostics/NamingStyles/NamingStylesTests.cs
+45
-0
src/EditorFeatures/TestUtilities/Diagnostics/NamingStyles/NamingStylesTestOptionSets.cs
...es/Diagnostics/NamingStyles/NamingStylesTestOptionSets.cs
+35
-0
src/EditorFeatures/VisualBasicTest/Diagnostics/NamingStyles/NamingStylesTests.vb
...alBasicTest/Diagnostics/NamingStyles/NamingStylesTests.vb
+22
-0
未找到文件。
src/EditorFeatures/CSharpTest/Diagnostics/NamingStyles/EditorConfigNamingStyleParserTests.cs
浏览文件 @
2215abea
...
...
@@ -353,6 +353,7 @@ public static void TestNoRulesAreReturned()
[
InlineData
(
"property,method"
,
new
object
[]
{
SymbolKind
.
Property
,
MethodKind
.
Ordinary
})]
[
InlineData
(
"namespace"
,
new
object
[]
{
SymbolKind
.
Namespace
})]
[
InlineData
(
"type_parameter"
,
new
object
[]
{
SymbolKind
.
TypeParameter
})]
[
InlineData
(
"interface"
,
new
object
[]
{
TypeKind
.
Interface
})]
[
InlineData
(
"*"
,
new
object
[]
{
SymbolKind
.
Namespace
,
TypeKind
.
Class
,
TypeKind
.
Struct
,
TypeKind
.
Interface
,
TypeKind
.
Enum
,
SymbolKind
.
Property
,
MethodKind
.
Ordinary
,
MethodKind
.
LocalFunction
,
SymbolKind
.
Field
,
SymbolKind
.
Event
,
TypeKind
.
Delegate
,
SymbolKind
.
Parameter
,
SymbolKind
.
TypeParameter
,
SymbolKind
.
Local
})]
[
InlineData
(
null
,
new
object
[]
{
SymbolKind
.
Namespace
,
TypeKind
.
Class
,
TypeKind
.
Struct
,
TypeKind
.
Interface
,
TypeKind
.
Enum
,
SymbolKind
.
Property
,
MethodKind
.
Ordinary
,
MethodKind
.
LocalFunction
,
SymbolKind
.
Field
,
SymbolKind
.
Event
,
TypeKind
.
Delegate
,
SymbolKind
.
Parameter
,
SymbolKind
.
TypeParameter
,
SymbolKind
.
Local
})]
[
InlineData
(
"property,method,invalid"
,
new
object
[]
{
SymbolKind
.
Property
,
MethodKind
.
Ordinary
})]
...
...
@@ -437,5 +438,40 @@ public static void TestRequiredModifiersParse()
Assert
.
Equal
(
csharpResult
.
SymbolSpecifications
.
SelectMany
(
x
=>
x
.
RequiredModifierList
.
Select
(
y
=>
y
.
ModifierKindWrapper
)),
vbResult
.
SymbolSpecifications
.
SelectMany
(
x
=>
x
.
RequiredModifierList
.
Select
(
y
=>
y
.
ModifierKindWrapper
)));
}
[
Fact
]
[
WorkItem
(
38513
,
"https://github.com/dotnet/roslyn/issues/38513"
)]
public
static
void
TestPrefixParse
()
{
var
rule
=
new
Dictionary
<
string
,
string
>()
{
[
"dotnet_naming_style.pascal_case_and_prefix_style.required_prefix"
]
=
"I"
,
[
"dotnet_naming_style.pascal_case_and_prefix_style.capitalization"
]
=
"pascal_case"
,
[
"dotnet_naming_symbols.symbols.applicable_kinds"
]
=
"interface"
,
[
"dotnet_naming_symbols.symbols.applicable_accessibilities"
]
=
"*"
,
[
"dotnet_naming_rule.must_be_pascal_cased_and_prefixed.symbols"
]
=
"symbols"
,
[
"dotnet_naming_rule.must_be_pascal_cased_and_prefixed.style"
]
=
"pascal_case_and_prefix_style"
,
[
"dotnet_naming_rule.must_be_pascal_cased_and_prefixed.severity"
]
=
"warning"
,
};
var
result
=
ParseDictionary
(
rule
);
Assert
.
Single
(
result
.
NamingRules
);
var
namingRule
=
result
.
NamingRules
.
Single
();
Assert
.
Single
(
result
.
NamingStyles
);
var
namingStyle
=
result
.
NamingStyles
.
Single
();
Assert
.
Single
(
result
.
SymbolSpecifications
);
var
symbolSpec
=
result
.
SymbolSpecifications
.
Single
();
Assert
.
Equal
(
namingStyle
.
ID
,
namingRule
.
NamingStyleID
);
Assert
.
Equal
(
symbolSpec
.
ID
,
namingRule
.
SymbolSpecificationID
);
Assert
.
Equal
(
ReportDiagnostic
.
Warn
,
namingRule
.
EnforcementLevel
);
Assert
.
Equal
(
"symbols"
,
symbolSpec
.
Name
);
var
expectedApplicableTypeKindList
=
new
[]
{
new
SymbolKindOrTypeKind
(
TypeKind
.
Interface
)
};
AssertEx
.
SetEqual
(
expectedApplicableTypeKindList
,
symbolSpec
.
ApplicableSymbolKindList
);
Assert
.
Equal
(
"pascal_case_and_prefix_style"
,
namingStyle
.
Name
);
Assert
.
Equal
(
"I"
,
namingStyle
.
Prefix
);
Assert
.
Equal
(
""
,
namingStyle
.
Suffix
);
Assert
.
Equal
(
""
,
namingStyle
.
WordSeparator
);
Assert
.
Equal
(
Capitalization
.
PascalCase
,
namingStyle
.
CapitalizationScheme
);
}
}
}
src/EditorFeatures/CSharpTest/Diagnostics/NamingStyles/NamingStylesTests.cs
浏览文件 @
2215abea
...
...
@@ -1231,5 +1231,50 @@ public async Task TestRefactorNotify()
Assert
.
Equal
(
"c"
,
symbolRenamedOperation
.
_symbol
.
Name
);
Assert
.
Equal
(
"C"
,
symbolRenamedOperation
.
_newName
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
NamingStyle
)]
[
WorkItem
(
38513
,
"https://github.com/dotnet/roslyn/issues/38513"
)]
public
async
Task
TestRefactorNotifyInterfaceNamesStartWithI
()
{
var
markup
=
@"public interface [|test|] { }"
;
var
testParameters
=
new
TestParameters
(
options
:
options
.
InterfaceNamesStartWithI
);
using
var
workspace
=
CreateWorkspaceFromOptions
(
markup
,
testParameters
);
var
(
_
,
action
)
=
await
GetCodeActionsAsync
(
workspace
,
testParameters
);
var
previewOperations
=
await
action
.
GetPreviewOperationsAsync
(
CancellationToken
.
None
);
Assert
.
Empty
(
previewOperations
.
OfType
<
TestSymbolRenamedCodeActionOperationFactoryWorkspaceService
.
Operation
>());
var
commitOperations
=
await
action
.
GetOperationsAsync
(
CancellationToken
.
None
);
Assert
.
Equal
(
2
,
commitOperations
.
Length
);
var
symbolRenamedOperation
=
(
TestSymbolRenamedCodeActionOperationFactoryWorkspaceService
.
Operation
)
commitOperations
[
1
];
Assert
.
Equal
(
"test"
,
symbolRenamedOperation
.
_symbol
.
Name
);
Assert
.
Equal
(
"ITest"
,
symbolRenamedOperation
.
_newName
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
NamingStyle
)]
[
WorkItem
(
38513
,
"https://github.com/dotnet/roslyn/issues/38513"
)]
public
async
Task
TestRefactorNotifyTypeParameterNamesStartWithT
()
{
var
markup
=
@"public class A
{
void DoOtherThing<[|arg|]>() { }
}"
;
var
testParameters
=
new
TestParameters
(
options
:
options
.
TypeParameterNamesStartWithT
);
using
var
workspace
=
CreateWorkspaceFromOptions
(
markup
,
testParameters
);
var
(
_
,
action
)
=
await
GetCodeActionsAsync
(
workspace
,
testParameters
);
var
previewOperations
=
await
action
.
GetPreviewOperationsAsync
(
CancellationToken
.
None
);
Assert
.
Empty
(
previewOperations
.
OfType
<
TestSymbolRenamedCodeActionOperationFactoryWorkspaceService
.
Operation
>());
var
commitOperations
=
await
action
.
GetOperationsAsync
(
CancellationToken
.
None
);
Assert
.
Equal
(
2
,
commitOperations
.
Length
);
var
symbolRenamedOperation
=
(
TestSymbolRenamedCodeActionOperationFactoryWorkspaceService
.
Operation
)
commitOperations
[
1
];
Assert
.
Equal
(
"arg"
,
symbolRenamedOperation
.
_symbol
.
Name
);
Assert
.
Equal
(
"TArg"
,
symbolRenamedOperation
.
_newName
);
}
}
}
src/EditorFeatures/TestUtilities/Diagnostics/NamingStyles/NamingStylesTestOptionSets.cs
浏览文件 @
2215abea
...
...
@@ -72,6 +72,9 @@ public NamingStylesTestOptionSets(string languageName)
public
IDictionary
<
OptionKey
,
object
>
InterfaceNamesStartWithI
=>
Options
(
new
OptionKey
(
SimplificationOptions
.
NamingPreferences
,
languageName
),
InterfaceNamesStartWithIOption
());
public
IDictionary
<
OptionKey
,
object
>
TypeParameterNamesStartWithT
=>
Options
(
new
OptionKey
(
SimplificationOptions
.
NamingPreferences
,
languageName
),
TypeParameterNamesStartWithTOption
());
public
IDictionary
<
OptionKey
,
object
>
ConstantsAreUpperCase
=>
Options
(
new
OptionKey
(
SimplificationOptions
.
NamingPreferences
,
languageName
),
ConstantsAreUpperCaseOption
());
...
...
@@ -604,6 +607,38 @@ private static NamingStylePreferences InterfaceNamesStartWithIOption()
return
info
;
}
private
static
NamingStylePreferences
TypeParameterNamesStartWithTOption
()
{
var
symbolSpecification
=
new
SymbolSpecification
(
null
,
"Name"
,
ImmutableArray
.
Create
(
new
SymbolSpecification
.
SymbolKindOrTypeKind
(
SymbolKind
.
TypeParameter
)),
accessibilityList
:
default
,
modifiers
:
default
);
var
namingStyle
=
new
NamingStyle
(
Guid
.
NewGuid
(),
capitalizationScheme
:
Capitalization
.
PascalCase
,
name
:
"Name"
,
prefix
:
"T"
,
suffix
:
""
,
wordSeparator
:
""
);
var
namingRule
=
new
SerializableNamingRule
()
{
SymbolSpecificationID
=
symbolSpecification
.
ID
,
NamingStyleID
=
namingStyle
.
ID
,
EnforcementLevel
=
ReportDiagnostic
.
Error
};
var
info
=
new
NamingStylePreferences
(
ImmutableArray
.
Create
(
symbolSpecification
),
ImmutableArray
.
Create
(
namingStyle
),
ImmutableArray
.
Create
(
namingRule
));
return
info
;
}
private
static
NamingStylePreferences
ConstantsAreUpperCaseOption
()
{
var
symbolSpecification
=
new
SymbolSpecification
(
...
...
src/EditorFeatures/VisualBasicTest/Diagnostics/NamingStyles/NamingStylesTests.vb
浏览文件 @
2215abea
...
...
@@ -470,5 +470,27 @@ end module",
options
:
=
options
.
LocalsAreCamelCaseConstantsAreUpperCase
)
End
Function
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
NamingStyle
)
>
<
WorkItem
(
38513
,
"https://github.com/dotnet/roslyn/issues/38513"
)
>
Public
Async
Function
TestInterfaceNamesStartWithI
()
As
Task
Await
TestInRegularAndScriptAsync
(
"Interface [|test|]
End Interface"
,
"Interface ITest
End Interface"
,
options
:
=
options
.
InterfaceNamesStartWithI
)
End
Function
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
NamingStyle
)
>
<
WorkItem
(
38513
,
"https://github.com/dotnet/roslyn/issues/38513"
)
>
Public
Async
Function
TestTypeParameterNamesStartWithT
()
As
Task
Await
TestInRegularAndScriptAsync
(
"Public Class classHolder(Of [|type|])
End Class"
,
"Public Class classHolder(Of TType)
End Class"
,
options
:
=
options
.
TypeParameterNamesStartWithT
)
End
Function
End
Class
End
Namespace
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录