Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
69cb9636
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,发现更多精彩内容 >>
提交
69cb9636
编写于
2月 15, 2020
作者:
S
Sam Harwell
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added documentation for test helpers
上级
ee754f97
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
53 addition
and
0 deletion
+53
-0
src/EditorFeatures/TestUtilities/CodeActions/CSharpCodeFixVerifier`2+Test.cs
...TestUtilities/CodeActions/CSharpCodeFixVerifier`2+Test.cs
+15
-0
src/EditorFeatures/TestUtilities/CodeActions/CSharpCodeFixVerifier`2.cs
...ures/TestUtilities/CodeActions/CSharpCodeFixVerifier`2.cs
+15
-0
src/EditorFeatures/TestUtilities/CodeActions/VisualBasicCodeFixVerifier`2+Test.cs
...tilities/CodeActions/VisualBasicCodeFixVerifier`2+Test.cs
+8
-0
src/EditorFeatures/TestUtilities/CodeActions/VisualBasicCodeFixVerifier`2.cs
...TestUtilities/CodeActions/VisualBasicCodeFixVerifier`2.cs
+15
-0
未找到文件。
src/EditorFeatures/TestUtilities/CodeActions/CSharpCodeFixVerifier`2+Test.cs
浏览文件 @
69cb9636
...
...
@@ -19,6 +19,13 @@ public static partial class CSharpCodeFixVerifier<TAnalyzer, TCodeFix>
{
public
class
Test
:
CSharpCodeFixTest
<
TAnalyzer
,
TCodeFix
,
XUnitVerifier
>
{
/// <summary>
/// By default, the compiler reports diagnostics for nullable reference types at
/// <see cref="DiagnosticSeverity.Warning"/>, and the analyzer test framework defaults to only validating
/// diagnostics at <see cref="DiagnosticSeverity.Error"/>. This map contains all compiler diagnostic IDs
/// related to nullability mapped to <see cref="ReportDiagnostic.Error"/>, which is then used to enable all
/// of these warnings for default validation during analyzer and code fix tests.
/// </summary>
private
static
readonly
ImmutableDictionary
<
string
,
ReportDiagnostic
>
s_nullableWarnings
=
GetNullableWarningsFromCompiler
();
public
Test
()
...
...
@@ -60,8 +67,16 @@ public Test()
return
nullableWarnings
;
}
/// <summary>
/// Gets or sets the language version to use for the test. The default value is
/// <see cref="LanguageVersion.CSharp8"/>.
/// </summary>
public
LanguageVersion
LanguageVersion
{
get
;
set
;
}
=
LanguageVersion
.
CSharp8
;
/// <summary>
/// Gets a collection of options to apply to <see cref="Solution.Options"/> for testing. Values may be added
/// using a collection initializer.
/// </summary>
public
OptionsCollection
Options
{
get
;
}
=
new
OptionsCollection
(
LanguageNames
.
CSharp
);
protected
override
AnalyzerOptions
GetAnalyzerOptions
(
Project
project
)
...
...
src/EditorFeatures/TestUtilities/CodeActions/CSharpCodeFixVerifier`2.cs
浏览文件 @
69cb9636
...
...
@@ -15,18 +15,30 @@ public static partial class CSharpCodeFixVerifier<TAnalyzer, TCodeFix>
where
TAnalyzer
:
DiagnosticAnalyzer
,
new
()
where
TCodeFix
:
CodeFixProvider
,
new
()
{
/// <inheritdoc cref="CodeFixVerifier{TAnalyzer, TCodeFix, TTest, TVerifier}.Diagnostic()"/>
public
static
DiagnosticResult
Diagnostic
()
=>
CSharpCodeFixVerifier
<
TAnalyzer
,
TCodeFix
,
XUnitVerifier
>.
Diagnostic
();
/// <inheritdoc cref="CodeFixVerifier{TAnalyzer, TCodeFix, TTest, TVerifier}.Diagnostic(string)"/>
public
static
DiagnosticResult
Diagnostic
(
string
diagnosticId
)
=>
CSharpCodeFixVerifier
<
TAnalyzer
,
TCodeFix
,
XUnitVerifier
>.
Diagnostic
(
diagnosticId
);
/// <inheritdoc cref="CodeFixVerifier{TAnalyzer, TCodeFix, TTest, TVerifier}.Diagnostic(DiagnosticDescriptor)"/>
public
static
DiagnosticResult
Diagnostic
(
DiagnosticDescriptor
descriptor
)
=>
CSharpCodeFixVerifier
<
TAnalyzer
,
TCodeFix
,
XUnitVerifier
>.
Diagnostic
(
descriptor
);
/// <summary>
/// Verify standard properties of <typeparamref name="TAnalyzer"/>.
/// </summary>
/// <remarks>
/// This validation method is largely specific to dotnet/roslyn scenarios.
/// </remarks>
/// <param name="verifyHelpLink"><see langword="true"/> to verify <see cref="DiagnosticDescriptor.HelpLinkUri"/>
/// property of supported diagnostics; otherwise, <see langword="false"/> to skip this validation.</param>
public
static
void
VerifyStandardProperties
(
bool
verifyHelpLink
=
false
)
=>
CodeFixVerifierHelper
.
VerifyStandardProperties
(
new
TAnalyzer
(),
verifyHelpLink
);
/// <inheritdoc cref="CodeFixVerifier{TAnalyzer, TCodeFix, TTest, TVerifier}.VerifyAnalyzerAsync(string, DiagnosticResult[])"/>
public
static
async
Task
VerifyAnalyzerAsync
(
string
source
,
params
DiagnosticResult
[]
expected
)
{
var
test
=
new
Test
...
...
@@ -38,12 +50,15 @@ public static async Task VerifyAnalyzerAsync(string source, params DiagnosticRes
await
test
.
RunAsync
();
}
/// <inheritdoc cref="CodeFixVerifier{TAnalyzer, TCodeFix, TTest, TVerifier}.VerifyCodeFixAsync(string, string)"/>
public
static
async
Task
VerifyCodeFixAsync
(
string
source
,
string
fixedSource
)
=>
await
VerifyCodeFixAsync
(
source
,
DiagnosticResult
.
EmptyDiagnosticResults
,
fixedSource
);
/// <inheritdoc cref="CodeFixVerifier{TAnalyzer, TCodeFix, TTest, TVerifier}.VerifyCodeFixAsync(string, DiagnosticResult, string)"/>
public
static
async
Task
VerifyCodeFixAsync
(
string
source
,
DiagnosticResult
expected
,
string
fixedSource
)
=>
await
VerifyCodeFixAsync
(
source
,
new
[]
{
expected
},
fixedSource
);
/// <inheritdoc cref="CodeFixVerifier{TAnalyzer, TCodeFix, TTest, TVerifier}.VerifyCodeFixAsync(string, DiagnosticResult[], string)"/>
public
static
async
Task
VerifyCodeFixAsync
(
string
source
,
DiagnosticResult
[]
expected
,
string
fixedSource
)
{
var
test
=
new
Test
...
...
src/EditorFeatures/TestUtilities/CodeActions/VisualBasicCodeFixVerifier`2+Test.cs
浏览文件 @
69cb9636
...
...
@@ -38,8 +38,16 @@ public Test()
});
}
/// <summary>
/// Gets or sets the language version to use for the test. The default value is
/// <see cref="LanguageVersion.VisualBasic16"/>.
/// </summary>
public
LanguageVersion
LanguageVersion
{
get
;
set
;
}
=
LanguageVersion
.
VisualBasic16
;
/// <summary>
/// Gets a collection of options to apply to <see cref="Solution.Options"/> for testing. Values may be added
/// using a collection initializer.
/// </summary>
public
OptionsCollection
Options
{
get
;
}
=
new
OptionsCollection
(
LanguageNames
.
VisualBasic
);
protected
override
AnalyzerOptions
GetAnalyzerOptions
(
Project
project
)
...
...
src/EditorFeatures/TestUtilities/CodeActions/VisualBasicCodeFixVerifier`2.cs
浏览文件 @
69cb9636
...
...
@@ -15,18 +15,30 @@ public static partial class VisualBasicCodeFixVerifier<TAnalyzer, TCodeFix>
where
TAnalyzer
:
DiagnosticAnalyzer
,
new
()
where
TCodeFix
:
CodeFixProvider
,
new
()
{
/// <inheritdoc cref="CodeFixVerifier{TAnalyzer, TCodeFix, TTest, TVerifier}.Diagnostic()"/>
public
static
DiagnosticResult
Diagnostic
()
=>
VisualBasicCodeFixVerifier
<
TAnalyzer
,
TCodeFix
,
XUnitVerifier
>.
Diagnostic
();
/// <inheritdoc cref="CodeFixVerifier{TAnalyzer, TCodeFix, TTest, TVerifier}.Diagnostic(string)"/>
public
static
DiagnosticResult
Diagnostic
(
string
diagnosticId
)
=>
VisualBasicCodeFixVerifier
<
TAnalyzer
,
TCodeFix
,
XUnitVerifier
>.
Diagnostic
(
diagnosticId
);
/// <inheritdoc cref="CodeFixVerifier{TAnalyzer, TCodeFix, TTest, TVerifier}.Diagnostic(DiagnosticDescriptor)"/>
public
static
DiagnosticResult
Diagnostic
(
DiagnosticDescriptor
descriptor
)
=>
VisualBasicCodeFixVerifier
<
TAnalyzer
,
TCodeFix
,
XUnitVerifier
>.
Diagnostic
(
descriptor
);
/// <summary>
/// Verify standard properties of <typeparamref name="TAnalyzer"/>.
/// </summary>
/// <remarks>
/// This validation method is largely specific to dotnet/roslyn scenarios.
/// </remarks>
/// <param name="verifyHelpLink"><see langword="true"/> to verify <see cref="DiagnosticDescriptor.HelpLinkUri"/>
/// property of supported diagnostics; otherwise, <see langword="false"/> to skip this validation.</param>
public
static
void
VerifyStandardProperties
(
bool
verifyHelpLink
=
false
)
=>
CodeFixVerifierHelper
.
VerifyStandardProperties
(
new
TAnalyzer
(),
verifyHelpLink
);
/// <inheritdoc cref="CodeFixVerifier{TAnalyzer, TCodeFix, TTest, TVerifier}.VerifyAnalyzerAsync(string, DiagnosticResult[])"/>
public
static
async
Task
VerifyAnalyzerAsync
(
string
source
,
params
DiagnosticResult
[]
expected
)
{
var
test
=
new
Test
...
...
@@ -38,12 +50,15 @@ public static async Task VerifyAnalyzerAsync(string source, params DiagnosticRes
await
test
.
RunAsync
();
}
/// <inheritdoc cref="CodeFixVerifier{TAnalyzer, TCodeFix, TTest, TVerifier}.VerifyCodeFixAsync(string, string)"/>
public
static
async
Task
VerifyCodeFixAsync
(
string
source
,
string
fixedSource
)
=>
await
VerifyCodeFixAsync
(
source
,
DiagnosticResult
.
EmptyDiagnosticResults
,
fixedSource
);
/// <inheritdoc cref="CodeFixVerifier{TAnalyzer, TCodeFix, TTest, TVerifier}.VerifyCodeFixAsync(string, DiagnosticResult, string)"/>
public
static
async
Task
VerifyCodeFixAsync
(
string
source
,
DiagnosticResult
expected
,
string
fixedSource
)
=>
await
VerifyCodeFixAsync
(
source
,
new
[]
{
expected
},
fixedSource
);
/// <inheritdoc cref="CodeFixVerifier{TAnalyzer, TCodeFix, TTest, TVerifier}.VerifyCodeFixAsync(string, DiagnosticResult[], string)"/>
public
static
async
Task
VerifyCodeFixAsync
(
string
source
,
DiagnosticResult
[]
expected
,
string
fixedSource
)
{
var
test
=
new
Test
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录