提交 1de24fdc 编写于 作者: S Sam Harwell

Support "Fix One" analyzer test scenarios

上级 55f25bd9
......@@ -28,7 +28,7 @@
<!-- Versions used by several individual references below -->
<RoslynDiagnosticsNugetPackageVersion>3.0.0-beta2.20059.3+77df2220</RoslynDiagnosticsNugetPackageVersion>
<CodeStyleLayerCodeAnalysisVersion>3.3.1</CodeStyleLayerCodeAnalysisVersion>
<MicrosoftCodeAnalysisTestingVersion>1.0.1-beta1.20118.1</MicrosoftCodeAnalysisTestingVersion>
<MicrosoftCodeAnalysisTestingVersion>1.0.1-beta1.20126.2</MicrosoftCodeAnalysisTestingVersion>
<CodeStyleAnalyzerVersion>3.5.0-beta3-20078-04</CodeStyleAnalyzerVersion>
<VisualStudioEditorPackagesVersion>16.4.248</VisualStudioEditorPackagesVersion>
<ILToolsPackageVersion>5.0.0-alpha1.19409.1</ILToolsPackageVersion>
......
......@@ -82,10 +82,18 @@ public Test()
/// </summary>
public OptionsCollection Options { get; } = new OptionsCollection(LanguageNames.CSharp);
public Func<ImmutableArray<Diagnostic>, Diagnostic?>? DiagnosticSelector { get; set; }
protected override AnalyzerOptions GetAnalyzerOptions(Project project)
{
return new WorkspaceAnalyzerOptions(base.GetAnalyzerOptions(project), project.Solution);
}
protected override Diagnostic? TrySelectDiagnosticToFix(ImmutableArray<Diagnostic> fixableDiagnostics)
{
return DiagnosticSelector?.Invoke(fixableDiagnostics)
?? base.TrySelectDiagnosticToFix(fixableDiagnostics);
}
}
}
}
......@@ -4,6 +4,8 @@
#nullable enable
using System;
using System.Collections.Immutable;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Shared.Extensions;
......@@ -53,10 +55,18 @@ public Test()
/// </summary>
public OptionsCollection Options { get; } = new OptionsCollection(LanguageNames.VisualBasic);
public Func<ImmutableArray<Diagnostic>, Diagnostic?>? DiagnosticSelector { get; set; }
protected override AnalyzerOptions GetAnalyzerOptions(Project project)
{
return new WorkspaceAnalyzerOptions(base.GetAnalyzerOptions(project), project.Solution);
}
protected override Diagnostic? TrySelectDiagnosticToFix(ImmutableArray<Diagnostic> fixableDiagnostics)
{
return DiagnosticSelector?.Invoke(fixableDiagnostics)
?? base.TrySelectDiagnosticToFix(fixableDiagnostics);
}
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册