Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
e5af7ed8
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,发现更多精彩内容 >>
提交
e5af7ed8
编写于
4月 20, 2020
作者:
S
Sam Harwell
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add refactoring verifiers for Microsoft.CodeAnalysis.Testing
上级
feab5e83
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
288 addition
and
24 deletion
+288
-24
eng/Versions.props
eng/Versions.props
+2
-0
src/CodeStyle/Core/Tests/Microsoft.CodeAnalysis.CodeStyle.UnitTestUtilities.csproj
...Microsoft.CodeAnalysis.CodeStyle.UnitTestUtilities.csproj
+7
-0
src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/CSharpCodeFixVerifier`2+Test.cs
...TestUtilities/CodeActions/CSharpCodeFixVerifier`2+Test.cs
+1
-24
src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/CSharpCodeRefactoringVerifier`1+Test.cs
...ities/CodeActions/CSharpCodeRefactoringVerifier`1+Test.cs
+80
-0
src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/CSharpCodeRefactoringVerifier`1.cs
...tUtilities/CodeActions/CSharpCodeRefactoringVerifier`1.cs
+42
-0
src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/CSharpVerifierHelper.cs
...gnosticsTestUtilities/CodeActions/CSharpVerifierHelper.cs
+36
-0
src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/VisualBasicCodeRefactoringVerifier`1+Test.cs
.../CodeActions/VisualBasicCodeRefactoringVerifier`1+Test.cs
+76
-0
src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/VisualBasicCodeRefactoringVerifier`1.cs
...ities/CodeActions/VisualBasicCodeRefactoringVerifier`1.cs
+42
-0
src/Workspaces/CoreTestUtilities/Roslyn.Services.UnitTests.Utilities.csproj
...eTestUtilities/Roslyn.Services.UnitTests.Utilities.csproj
+2
-0
未找到文件。
eng/Versions.props
浏览文件 @
e5af7ed8
...
...
@@ -62,10 +62,12 @@
<MicrosoftCodeAnalysisAnalyzersVersion>
3.0.0
</MicrosoftCodeAnalysisAnalyzersVersion>
<MicrosoftCodeAnalysisBuildTasksVersion>
2.0.0-rc2-61102-09
</MicrosoftCodeAnalysisBuildTasksVersion>
<MicrosoftCodeAnalysisCSharpCodeFixTestingXUnitVersion>
$(MicrosoftCodeAnalysisTestingVersion)
</MicrosoftCodeAnalysisCSharpCodeFixTestingXUnitVersion>
<MicrosoftCodeAnalysisCSharpCodeRefactoringTestingXUnitVersion>
$(MicrosoftCodeAnalysisTestingVersion)
</MicrosoftCodeAnalysisCSharpCodeRefactoringTestingXUnitVersion>
<MicrosoftCodeAnalysisCSharpCodeStyleVersion>
$(CodeStyleAnalyzerVersion)
</MicrosoftCodeAnalysisCSharpCodeStyleVersion>
<MicrosoftCodeAnalysisElfieVersion>
0.10.6
</MicrosoftCodeAnalysisElfieVersion>
<MicrosoftCodeAnalysisTestResourcesProprietaryVersion>
2.0.19
</MicrosoftCodeAnalysisTestResourcesProprietaryVersion>
<MicrosoftCodeAnalysisVisualBasicCodeFixTestingXUnitVersion>
$(MicrosoftCodeAnalysisTestingVersion)
</MicrosoftCodeAnalysisVisualBasicCodeFixTestingXUnitVersion>
<MicrosoftCodeAnalysisVisualBasicCodeRefactoringTestingXUnitVersion>
$(MicrosoftCodeAnalysisTestingVersion)
</MicrosoftCodeAnalysisVisualBasicCodeRefactoringTestingXUnitVersion>
<MicrosoftCodeAnalysisVisualBasicCodeStyleVersion>
$(CodeStyleAnalyzerVersion)
</MicrosoftCodeAnalysisVisualBasicCodeStyleVersion>
<MicrosoftCodeAnalysisAnalyzerUtilitiesVersion>
3.0.0
</MicrosoftCodeAnalysisAnalyzerUtilitiesVersion>
<MicrosoftCodeQualityAnalyzersVersion>
$(RoslynDiagnosticsNugetPackageVersion)
</MicrosoftCodeQualityAnalyzersVersion>
...
...
src/CodeStyle/Core/Tests/Microsoft.CodeAnalysis.CodeStyle.UnitTestUtilities.csproj
浏览文件 @
e5af7ed8
...
...
@@ -12,9 +12,14 @@
<Compile
Include=
"..\..\..\EditorFeatures\DiagnosticsTestUtilities\CodeActions\CodeFixVerifierHelper.cs"
Link=
"CodeFixVerifierHelper.cs"
/>
<Compile
Include=
"..\..\..\EditorFeatures\DiagnosticsTestUtilities\CodeActions\CSharpCodeFixVerifier`2+Test.cs"
Link=
"CSharpCodeFixVerifier`2+Test.cs"
/>
<Compile
Include=
"..\..\..\EditorFeatures\DiagnosticsTestUtilities\CodeActions\CSharpCodeFixVerifier`2.cs"
Link=
"CSharpCodeFixVerifier`2.cs"
/>
<Compile
Include=
"..\..\..\EditorFeatures\DiagnosticsTestUtilities\CodeActions\CSharpCodeRefactoringVerifier`1+Test.cs"
Link=
"CSharpCodeRefactoringVerifier`1+Test.cs"
/>
<Compile
Include=
"..\..\..\EditorFeatures\DiagnosticsTestUtilities\CodeActions\CSharpCodeRefactoringVerifier`1.cs"
Link=
"CSharpCodeRefactoringVerifier`1.cs"
/>
<Compile
Include=
"..\..\..\EditorFeatures\DiagnosticsTestUtilities\CodeActions\CSharpVerifierHelper.cs"
Link=
"CSharpVerifierHelper.cs"
/>
<Compile
Include=
"..\..\..\EditorFeatures\DiagnosticsTestUtilities\CodeActions\VisualBasicCodeFixVerifier`2+Test.cs"
Link=
"VisualBasicCodeFixVerifier`2+Test.cs"
/>
<Compile
Include=
"..\..\..\EditorFeatures\DiagnosticsTestUtilities\CodeActions\VisualBasicCodeFixVerifier`2.cs"
Link=
"VisualBasicCodeFixVerifier`2.cs"
/>
<Compile
Include=
"..\..\..\EditorFeatures\DiagnosticsTestUtilities\CodeActions\OptionsCollection.cs"
Link=
"OptionsCollection.cs"
/>
<Compile
Include=
"..\..\..\EditorFeatures\DiagnosticsTestUtilities\CodeActions\VisualBasicCodeRefactoringVerifier`1+Test.cs"
Link=
"VisualBasicCodeRefactoringVerifier`1+Test.cs"
/>
<Compile
Include=
"..\..\..\EditorFeatures\DiagnosticsTestUtilities\CodeActions\VisualBasicCodeRefactoringVerifier`1.cs"
Link=
"VisualBasicCodeRefactoringVerifier`1.cs"
/>
<Compile
Include=
"..\..\..\EditorFeatures\DiagnosticsTestUtilities\Diagnostics\ParenthesesOptionsProvider.cs"
Link=
"ParenthesesOptionsProvider.cs"
/>
<Compile
Include=
"..\..\..\EditorFeatures\DiagnosticsTestUtilities\NamingStyles\NamingStylesTestOptionSets.cs"
Link=
"NamingStyles\NamingStylesTestOptionSets.cs"
/>
</ItemGroup>
...
...
@@ -30,7 +35,9 @@
</ItemGroup>
<ItemGroup>
<PackageReference
Include=
"Microsoft.CodeAnalysis.CSharp.CodeFix.Testing.XUnit"
Version=
"$(MicrosoftCodeAnalysisCSharpCodeFixTestingXUnitVersion)"
/>
<PackageReference
Include=
"Microsoft.CodeAnalysis.CSharp.CodeRefactoring.Testing.XUnit"
Version=
"$(MicrosoftCodeAnalysisCSharpCodeRefactoringTestingXUnitVersion)"
/>
<PackageReference
Include=
"Microsoft.CodeAnalysis.VisualBasic.CodeFix.Testing.XUnit"
Version=
"$(MicrosoftCodeAnalysisVisualBasicCodeFixTestingXUnitVersion)"
/>
<PackageReference
Include=
"Microsoft.CodeAnalysis.VisualBasic.CodeRefactoring.Testing.XUnit"
Version=
"$(MicrosoftCodeAnalysisVisualBasicCodeRefactoringTestingXUnitVersion)"
/>
</ItemGroup>
<ItemGroup
Label=
"Project References"
>
<!-- TODO: Remove the below project references to test utility projects once all analyzer/code fix tests are switched to Microsoft.CodeAnalysis.Testing -->
...
...
src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/CSharpCodeFixVerifier`2+Test.cs
浏览文件 @
e5af7ed8
...
...
@@ -27,15 +27,6 @@ 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
()
{
MarkupOptions
=
Testing
.
MarkupOptions
.
UseFirstDescriptor
;
...
...
@@ -46,7 +37,7 @@ public Test()
solution
=
solution
.
WithProjectParseOptions
(
projectId
,
parseOptions
.
WithLanguageVersion
(
LanguageVersion
));
var
compilationOptions
=
solution
.
GetProject
(
projectId
)!.
CompilationOptions
!;
compilationOptions
=
compilationOptions
.
WithSpecificDiagnosticOptions
(
compilationOptions
.
SpecificDiagnosticOptions
.
SetItems
(
s_n
ullableWarnings
));
compilationOptions
=
compilationOptions
.
WithSpecificDiagnosticOptions
(
compilationOptions
.
SpecificDiagnosticOptions
.
SetItems
(
CSharpVerifierHelper
.
N
ullableWarnings
));
solution
=
solution
.
WithProjectCompilationOptions
(
projectId
,
compilationOptions
);
var
(
analyzerConfigSource
,
remainingOptions
)
=
CodeFixVerifierHelper
.
ConvertOptionsToAnalyzerConfig
(
DefaultFileExt
,
EditorConfig
,
Options
);
...
...
@@ -73,20 +64,6 @@ public Test()
});
}
private
static
ImmutableDictionary
<
string
,
ReportDiagnostic
>
GetNullableWarningsFromCompiler
()
{
string
[]
args
=
{
"/warnaserror:nullable"
};
var
commandLineArguments
=
CSharpCommandLineParser
.
Default
.
Parse
(
args
,
baseDirectory
:
Environment
.
CurrentDirectory
,
sdkDirectory
:
Environment
.
CurrentDirectory
);
var
nullableWarnings
=
commandLineArguments
.
CompilationOptions
.
SpecificDiagnosticOptions
;
// Workaround for https://github.com/dotnet/roslyn/issues/41610
nullableWarnings
=
nullableWarnings
.
SetItem
(
"CS8632"
,
ReportDiagnostic
.
Error
)
.
SetItem
(
"CS8669"
,
ReportDiagnostic
.
Error
);
return
nullableWarnings
;
}
/// <summary>
/// Gets or sets the language version to use for the test. The default value is
/// <see cref="LanguageVersion.CSharp8"/>.
...
...
src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/CSharpCodeRefactoringVerifier`1+Test.cs
0 → 100644
浏览文件 @
e5af7ed8
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#
nullable
enable
using
Microsoft.CodeAnalysis.CSharp
;
using
Microsoft.CodeAnalysis.CSharp.Testing
;
using
Microsoft.CodeAnalysis.Testing.Verifiers
;
using
Microsoft.CodeAnalysis.CodeRefactorings
;
#if !CODE_STYLE
using
System
;
using
Microsoft.CodeAnalysis.Diagnostics
;
using
Roslyn.Utilities
;
#endif
namespace
Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions
{
public
static
partial
class
CSharpCodeRefactoringVerifier
<
TCodeRefactoring
>
where
TCodeRefactoring
:
CodeRefactoringProvider
,
new
()
{
public
class
Test
:
CSharpCodeRefactoringTest
<
TCodeRefactoring
,
XUnitVerifier
>
{
public
Test
()
{
SolutionTransforms
.
Add
((
solution
,
projectId
)
=>
{
var
parseOptions
=
(
CSharpParseOptions
)
solution
.
GetProject
(
projectId
)!.
ParseOptions
!;
solution
=
solution
.
WithProjectParseOptions
(
projectId
,
parseOptions
.
WithLanguageVersion
(
LanguageVersion
));
var
compilationOptions
=
solution
.
GetProject
(
projectId
)!.
CompilationOptions
!;
compilationOptions
=
compilationOptions
.
WithSpecificDiagnosticOptions
(
compilationOptions
.
SpecificDiagnosticOptions
.
SetItems
(
CSharpVerifierHelper
.
NullableWarnings
));
solution
=
solution
.
WithProjectCompilationOptions
(
projectId
,
compilationOptions
);
var
(
analyzerConfigSource
,
remainingOptions
)
=
CodeFixVerifierHelper
.
ConvertOptionsToAnalyzerConfig
(
DefaultFileExt
,
EditorConfig
,
Options
);
if
(
analyzerConfigSource
is
object
)
{
foreach
(
var
id
in
solution
.
ProjectIds
)
{
var
documentId
=
DocumentId
.
CreateNewId
(
id
,
".editorconfig"
);
solution
=
solution
.
AddAnalyzerConfigDocument
(
documentId
,
".editorconfig"
,
analyzerConfigSource
,
filePath
:
"/.editorconfig"
);
}
}
#if !CODE_STYLE
var
options
=
solution
.
Options
;
foreach
(
var
(
key
,
value
)
in
remainingOptions
)
{
options
=
options
.
WithChangedOption
(
key
,
value
);
}
solution
=
solution
.
WithOptions
(
options
);
#endif
return
solution
;
});
}
/// <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>
internal
OptionsCollection
Options
{
get
;
}
=
new
OptionsCollection
(
LanguageNames
.
CSharp
);
public
string
?
EditorConfig
{
get
;
set
;
}
#if !CODE_STYLE
protected
override
AnalyzerOptions
GetAnalyzerOptions
(
Project
project
)
=>
new
WorkspaceAnalyzerOptions
(
base
.
GetAnalyzerOptions
(
project
),
project
.
Solution
);
#endif
}
}
}
src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/CSharpCodeRefactoringVerifier`1.cs
0 → 100644
浏览文件 @
e5af7ed8
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#
nullable
enable
using
System.Threading
;
using
System.Threading.Tasks
;
using
Microsoft.CodeAnalysis.CodeRefactorings
;
using
Microsoft.CodeAnalysis.Testing
;
namespace
Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions
{
public
static
partial
class
CSharpCodeRefactoringVerifier
<
TCodeRefactoring
>
where
TCodeRefactoring
:
CodeRefactoringProvider
,
new
()
{
/// <inheritdoc cref="CodeRefactoringVerifier{TCodeRefactoring, TTest, TVerifier}.VerifyRefactoringAsync(string, string)"/>
public
static
Task
VerifyRefactoringAsync
(
string
source
,
string
fixedSource
)
{
return
VerifyRefactoringAsync
(
source
,
DiagnosticResult
.
EmptyDiagnosticResults
,
fixedSource
);
}
/// <inheritdoc cref="CodeRefactoringVerifier{TCodeRefactoring, TTest, TVerifier}.VerifyRefactoringAsync(string, DiagnosticResult, string)"/>
public
static
Task
VerifyRefactoringAsync
(
string
source
,
DiagnosticResult
expected
,
string
fixedSource
)
{
return
VerifyRefactoringAsync
(
source
,
new
[]
{
expected
},
fixedSource
);
}
/// <inheritdoc cref="CodeRefactoringVerifier{TCodeRefactoring, TTest, TVerifier}.VerifyRefactoringAsync(string, DiagnosticResult[], string)"/>
public
static
Task
VerifyRefactoringAsync
(
string
source
,
DiagnosticResult
[]
expected
,
string
fixedSource
)
{
var
test
=
new
Test
{
TestCode
=
source
,
FixedCode
=
fixedSource
};
test
.
ExpectedDiagnostics
.
AddRange
(
expected
);
return
test
.
RunAsync
(
CancellationToken
.
None
);
}
}
}
src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/CSharpVerifierHelper.cs
0 → 100644
浏览文件 @
e5af7ed8
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using
System
;
using
System.Collections.Immutable
;
using
Microsoft.CodeAnalysis.CSharp
;
namespace
Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions
{
internal
static
class
CSharpVerifierHelper
{
/// <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>
internal
static
ImmutableDictionary
<
string
,
ReportDiagnostic
>
NullableWarnings
{
get
;
}
=
GetNullableWarningsFromCompiler
();
private
static
ImmutableDictionary
<
string
,
ReportDiagnostic
>
GetNullableWarningsFromCompiler
()
{
string
[]
args
=
{
"/warnaserror:nullable"
};
var
commandLineArguments
=
CSharpCommandLineParser
.
Default
.
Parse
(
args
,
baseDirectory
:
Environment
.
CurrentDirectory
,
sdkDirectory
:
Environment
.
CurrentDirectory
);
var
nullableWarnings
=
commandLineArguments
.
CompilationOptions
.
SpecificDiagnosticOptions
;
// Workaround for https://github.com/dotnet/roslyn/issues/41610
nullableWarnings
=
nullableWarnings
.
SetItem
(
"CS8632"
,
ReportDiagnostic
.
Error
)
.
SetItem
(
"CS8669"
,
ReportDiagnostic
.
Error
);
return
nullableWarnings
;
}
}
}
src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/VisualBasicCodeRefactoringVerifier`1+Test.cs
0 → 100644
浏览文件 @
e5af7ed8
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#
nullable
enable
using
Microsoft.CodeAnalysis.VisualBasic
;
using
Microsoft.CodeAnalysis.VisualBasic.Testing
;
using
Microsoft.CodeAnalysis.Testing.Verifiers
;
using
Microsoft.CodeAnalysis.CodeRefactorings
;
#if !CODE_STYLE
using
System
;
using
Microsoft.CodeAnalysis.Diagnostics
;
using
Roslyn.Utilities
;
#endif
namespace
Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions
{
public
static
partial
class
VisualBasicCodeRefactoringVerifier
<
TCodeRefactoring
>
where
TCodeRefactoring
:
CodeRefactoringProvider
,
new
()
{
public
class
Test
:
VisualBasicCodeRefactoringTest
<
TCodeRefactoring
,
XUnitVerifier
>
{
public
Test
()
{
SolutionTransforms
.
Add
((
solution
,
projectId
)
=>
{
var
parseOptions
=
(
VisualBasicParseOptions
)
solution
.
GetProject
(
projectId
)!.
ParseOptions
!;
solution
=
solution
.
WithProjectParseOptions
(
projectId
,
parseOptions
.
WithLanguageVersion
(
LanguageVersion
));
var
(
analyzerConfigSource
,
remainingOptions
)
=
CodeFixVerifierHelper
.
ConvertOptionsToAnalyzerConfig
(
DefaultFileExt
,
EditorConfig
,
Options
);
if
(
analyzerConfigSource
is
object
)
{
foreach
(
var
id
in
solution
.
ProjectIds
)
{
var
documentId
=
DocumentId
.
CreateNewId
(
id
,
".editorconfig"
);
solution
=
solution
.
AddAnalyzerConfigDocument
(
documentId
,
".editorconfig"
,
analyzerConfigSource
,
filePath
:
"/.editorconfig"
);
}
}
#if !CODE_STYLE
var
options
=
solution
.
Options
;
foreach
(
var
(
key
,
value
)
in
remainingOptions
)
{
options
=
options
.
WithChangedOption
(
key
,
value
);
}
solution
=
solution
.
WithOptions
(
options
);
#endif
return
solution
;
});
}
/// <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>
internal
OptionsCollection
Options
{
get
;
}
=
new
OptionsCollection
(
LanguageNames
.
VisualBasic
);
public
string
?
EditorConfig
{
get
;
set
;
}
#if !CODE_STYLE
protected
override
AnalyzerOptions
GetAnalyzerOptions
(
Project
project
)
=>
new
WorkspaceAnalyzerOptions
(
base
.
GetAnalyzerOptions
(
project
),
project
.
Solution
);
#endif
}
}
}
src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/VisualBasicCodeRefactoringVerifier`1.cs
0 → 100644
浏览文件 @
e5af7ed8
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#
nullable
enable
using
System.Threading
;
using
System.Threading.Tasks
;
using
Microsoft.CodeAnalysis.CodeRefactorings
;
using
Microsoft.CodeAnalysis.Testing
;
namespace
Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions
{
public
static
partial
class
VisualBasicCodeRefactoringVerifier
<
TCodeRefactoring
>
where
TCodeRefactoring
:
CodeRefactoringProvider
,
new
()
{
/// <inheritdoc cref="CodeRefactoringVerifier{TCodeRefactoring, TTest, TVerifier}.VerifyRefactoringAsync(string, string)"/>
public
static
Task
VerifyRefactoringAsync
(
string
source
,
string
fixedSource
)
{
return
VerifyRefactoringAsync
(
source
,
DiagnosticResult
.
EmptyDiagnosticResults
,
fixedSource
);
}
/// <inheritdoc cref="CodeRefactoringVerifier{TCodeRefactoring, TTest, TVerifier}.VerifyRefactoringAsync(string, DiagnosticResult, string)"/>
public
static
Task
VerifyRefactoringAsync
(
string
source
,
DiagnosticResult
expected
,
string
fixedSource
)
{
return
VerifyRefactoringAsync
(
source
,
new
[]
{
expected
},
fixedSource
);
}
/// <inheritdoc cref="CodeRefactoringVerifier{TCodeRefactoring, TTest, TVerifier}.VerifyRefactoringAsync(string, DiagnosticResult[], string)"/>
public
static
Task
VerifyRefactoringAsync
(
string
source
,
DiagnosticResult
[]
expected
,
string
fixedSource
)
{
var
test
=
new
Test
{
TestCode
=
source
,
FixedCode
=
fixedSource
};
test
.
ExpectedDiagnostics
.
AddRange
(
expected
);
return
test
.
RunAsync
(
CancellationToken
.
None
);
}
}
}
src/Workspaces/CoreTestUtilities/Roslyn.Services.UnitTests.Utilities.csproj
浏览文件 @
e5af7ed8
...
...
@@ -24,7 +24,9 @@
<ItemGroup>
<PackageReference
Include=
"Microsoft.CSharp"
Version=
"$(MicrosoftCSharpVersion)"
/>
<PackageReference
Include=
"Microsoft.CodeAnalysis.CSharp.CodeFix.Testing.XUnit"
Version=
"$(MicrosoftCodeAnalysisCSharpCodeFixTestingXUnitVersion)"
/>
<PackageReference
Include=
"Microsoft.CodeAnalysis.CSharp.CodeRefactoring.Testing.XUnit"
Version=
"$(MicrosoftCodeAnalysisCSharpCodeRefactoringTestingXUnitVersion)"
/>
<PackageReference
Include=
"Microsoft.CodeAnalysis.VisualBasic.CodeFix.Testing.XUnit"
Version=
"$(MicrosoftCodeAnalysisVisualBasicCodeFixTestingXUnitVersion)"
/>
<PackageReference
Include=
"Microsoft.CodeAnalysis.VisualBasic.CodeRefactoring.Testing.XUnit"
Version=
"$(MicrosoftCodeAnalysisVisualBasicCodeRefactoringTestingXUnitVersion)"
/>
<PackageReference
Include=
"Microsoft.VisualStudio.Composition"
Version=
"$(MicrosoftVisualStudioCompositionVersion)"
/>
<PackageReference
Include=
"Microsoft.VisualStudio.Validation"
Version=
"$(MicrosoftVisualStudioValidationVersion)"
/>
<PackageReference
Include=
"System.Threading.Tasks.Dataflow"
Version=
"$(SystemThreadingTasksDataflowVersion)"
/>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录