diff --git a/src/EditorFeatures/CSharpTest/Diagnostics/ConditionalExpressionInStringInterpolation/CSharpAddParenthesisAroundConditionalExpressionInInterpolatedStringCodeFixProviderTests.cs b/src/EditorFeatures/CSharpTest/Diagnostics/ConditionalExpressionInStringInterpolation/CSharpAddParenthesesAroundConditionalExpressionInInterpolatedStringCodeFixProviderTests.cs
similarity index 87%
rename from src/EditorFeatures/CSharpTest/Diagnostics/ConditionalExpressionInStringInterpolation/CSharpAddParenthesisAroundConditionalExpressionInInterpolatedStringCodeFixProviderTests.cs
rename to src/EditorFeatures/CSharpTest/Diagnostics/ConditionalExpressionInStringInterpolation/CSharpAddParenthesesAroundConditionalExpressionInInterpolatedStringCodeFixProviderTests.cs
index acbb08789047f7f769d38cdb190f2dd7268d663d..513b6fa2b6ba99824986910f30c810f48ddeb86c 100644
--- a/src/EditorFeatures/CSharpTest/Diagnostics/ConditionalExpressionInStringInterpolation/CSharpAddParenthesisAroundConditionalExpressionInInterpolatedStringCodeFixProviderTests.cs
+++ b/src/EditorFeatures/CSharpTest/Diagnostics/ConditionalExpressionInStringInterpolation/CSharpAddParenthesesAroundConditionalExpressionInInterpolatedStringCodeFixProviderTests.cs
@@ -9,10 +9,10 @@
namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Diagnostics.ConditionalExpressionInStringInterpolation
{
- public class CSharpAddParenthesisAroundConditionalExpressionInInterpolatedStringCodeFixProviderTests : AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest
+ public class CSharpAddParenthesesAroundConditionalExpressionInInterpolatedStringCodeFixProviderTests : AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest
{
internal override (DiagnosticAnalyzer, CodeFixProvider) CreateDiagnosticProviderAndFixer(Workspace workspace)
- => (null, new CSharpAddParenthesisAroundConditionalExpressionInInterpolatedStringCodeFixProvider());
+ => (null, new CSharpAddParenthesesAroundConditionalExpressionInInterpolatedStringCodeFixProvider());
private async Task TestInMethodAsync(string initialMethodBody, string expectedMethodBody)
{
@@ -29,7 +29,7 @@ public static M()
string.Format(template, expectedMethodBody)).ConfigureAwait(false);
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesisAroundConditionalExpressionInInterpolatedString)]
+ [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesesAroundConditionalExpressionInInterpolatedString)]
public async Task TestAddParenthesisSimpleConditionalExpression()
{
await TestInMethodAsync(
@@ -37,7 +37,7 @@ public async Task TestAddParenthesisSimpleConditionalExpression()
@"var s = $""{ (true ? 1 : 2)}"";");
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesisAroundConditionalExpressionInInterpolatedString)]
+ [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesesAroundConditionalExpressionInInterpolatedString)]
public async Task TestAddParenthesisMultiLineConditionalExpression1()
{
await TestInMethodAsync(@"
@@ -51,7 +51,7 @@ public async Task TestAddParenthesisMultiLineConditionalExpression1()
");
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesisAroundConditionalExpressionInInterpolatedString)]
+ [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesesAroundConditionalExpressionInInterpolatedString)]
public async Task TestAddParenthesisMultiLineConditionalExpression2()
{
await TestInMethodAsync(@"
@@ -73,7 +73,7 @@ public async Task TestAddParenthesisMultiLineConditionalExpression2()
");
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesisAroundConditionalExpressionInInterpolatedString)]
+ [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesesAroundConditionalExpressionInInterpolatedString)]
public async Task TestAddParenthesisWithTrivia()
{
await TestInMethodAsync(
@@ -81,7 +81,7 @@ public async Task TestAddParenthesisWithTrivia()
@"var s = $""{ /* Leading1 */ (true /* Leading2 */ ? /* TruePart1 */ 1 /* TruePart2 */: /* FalsePart1 */ 2 /* FalsePart2 */ )}"";");
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesisAroundConditionalExpressionInInterpolatedString)]
+ [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesesAroundConditionalExpressionInInterpolatedString)]
public async Task TestAddParenthesisClosingBracketInFalseCondition()
{
await TestInMethodAsync(
@@ -89,7 +89,7 @@ public async Task TestAddParenthesisClosingBracketInFalseCondition()
@"var s = $""{ (true ? new int[0] : new int[] {})}"";");
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesisAroundConditionalExpressionInInterpolatedString)]
+ [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesesAroundConditionalExpressionInInterpolatedString)]
public async Task TestAddParenthesisStringLiteralInFalseCondition()
{
await TestInMethodAsync(
@@ -97,7 +97,7 @@ public async Task TestAddParenthesisStringLiteralInFalseCondition()
@"var s = $""{ (true ? ""1"" : ""2"")}"";");
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesisAroundConditionalExpressionInInterpolatedString)]
+ [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesesAroundConditionalExpressionInInterpolatedString)]
public async Task TestAddParenthesisVerbatimStringLiteralInFalseCondition()
{
await TestInMethodAsync(
@@ -105,7 +105,7 @@ public async Task TestAddParenthesisVerbatimStringLiteralInFalseCondition()
@"var s = $""{ (true ? ""1"" : @""""""2"""""")}"";");
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesisAroundConditionalExpressionInInterpolatedString)]
+ [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesesAroundConditionalExpressionInInterpolatedString)]
public async Task TestAddParenthesisStringLiteralInFalseConditionWithClosingParenthesisInLiteral()
{
await TestInMethodAsync(
@@ -113,7 +113,7 @@ public async Task TestAddParenthesisStringLiteralInFalseConditionWithClosingPare
@"var s = $""{ (true ? ""1"" : ""2)"")}"";");
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesisAroundConditionalExpressionInInterpolatedString)]
+ [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesesAroundConditionalExpressionInInterpolatedString)]
public async Task TestAddParenthesisStringLiteralInFalseConditionWithEscapedDoubleQuotes()
{
await TestInMethodAsync(
@@ -121,7 +121,7 @@ public async Task TestAddParenthesisStringLiteralInFalseConditionWithEscapedDoub
@"var s = $""{ (true ? ""1"" : ""2\"""")}"";");
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesisAroundConditionalExpressionInInterpolatedString)]
+ [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesesAroundConditionalExpressionInInterpolatedString)]
public async Task TestAddParenthesisStringLiteralInFalseConditionWithCodeLikeContent()
{
await TestInMethodAsync(
@@ -129,7 +129,7 @@ public async Task TestAddParenthesisStringLiteralInFalseConditionWithCodeLikeCon
@"var s = $""{ (true ? ""1"" : ""M(new int[] {}, \""Parameter\"");"")}"";");
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesisAroundConditionalExpressionInInterpolatedString)]
+ [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesesAroundConditionalExpressionInInterpolatedString)]
public async Task TestAddParenthesisNestedConditionalExpression1()
{
await TestInMethodAsync(
@@ -137,7 +137,7 @@ public async Task TestAddParenthesisNestedConditionalExpression1()
@"var s2 = $""{ (true ? ""1"" : (false ? ""2"" : ""3""))};");
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesisAroundConditionalExpressionInInterpolatedString)]
+ [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesesAroundConditionalExpressionInInterpolatedString)]
public async Task TestAddParenthesisNestedConditionalExpression2()
{
await TestInMethodAsync(
@@ -145,7 +145,7 @@ public async Task TestAddParenthesisNestedConditionalExpression2()
@"var s2 = $""{ (true ? ""1"" : false ? ""2"" : ""3"")};");
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesisAroundConditionalExpressionInInterpolatedString)]
+ [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesesAroundConditionalExpressionInInterpolatedString)]
public async Task TestAddParenthesisNestedConditionalWithNestedInterpolatedString()
{
await TestInMethodAsync(
@@ -153,7 +153,7 @@ public async Task TestAddParenthesisNestedConditionalWithNestedInterpolatedStrin
@"var s2 = $""{ (true ? ""1"" : false ? $""{ (true ? ""2"" : ""3"")}"" : ""4"") }""");
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesisAroundConditionalExpressionInInterpolatedString)]
+ [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesesAroundConditionalExpressionInInterpolatedString)]
public async Task TestAddParenthesisMultipleInterpolatedSections1()
{
await TestInMethodAsync(
@@ -161,7 +161,7 @@ public async Task TestAddParenthesisMultipleInterpolatedSections1()
@"var s3 = $""Text1 { (true ? ""Text2"" : ""Text3"")} Text4 { (true ? ""Text5"" : ""Text6"")} Text7"";");
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesisAroundConditionalExpressionInInterpolatedString)]
+ [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesesAroundConditionalExpressionInInterpolatedString)]
public async Task TestAddParenthesisMultipleInterpolatedSections2()
{
await TestInMethodAsync(
@@ -169,7 +169,7 @@ public async Task TestAddParenthesisMultipleInterpolatedSections2()
@"var s3 = $""Text1 { (true ? ""Text2"" : ""Text3"")} Text4 { (true ? ""Text5"" : ""Text6"")} Text7"";");
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesisAroundConditionalExpressionInInterpolatedString)]
+ [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesesAroundConditionalExpressionInInterpolatedString)]
public async Task TestAddParenthesisMultipleInterpolatedSections3()
{
await TestInMethodAsync(
@@ -177,7 +177,7 @@ public async Task TestAddParenthesisMultipleInterpolatedSections3()
@"var s3 = $""Text1 { (true ? ""Text2"" : ""Text3"")} Text4 { true ? ""Text5"" : ""Text6""} Text7"";");
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesisAroundConditionalExpressionInInterpolatedString)]
+ [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesesAroundConditionalExpressionInInterpolatedString)]
public async Task TestAddParenthesisWhileTyping1()
{
await TestInMethodAsync(
@@ -191,7 +191,7 @@ public async Task TestAddParenthesisWhileTyping1()
NextLineOfCode();");
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesisAroundConditionalExpressionInInterpolatedString)]
+ [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesesAroundConditionalExpressionInInterpolatedString)]
public async Task TestAddParenthesisWhileTyping2()
{
await TestInMethodAsync(
@@ -205,7 +205,7 @@ public async Task TestAddParenthesisWhileTyping2()
NextLineOfCode();");
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesisAroundConditionalExpressionInInterpolatedString)]
+ [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesesAroundConditionalExpressionInInterpolatedString)]
public async Task TestAddParenthesisWhileTyping3()
{
await TestInMethodAsync(
@@ -219,7 +219,7 @@ public async Task TestAddParenthesisWhileTyping3()
NextLineOfCode();");
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesisAroundConditionalExpressionInInterpolatedString)]
+ [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesesAroundConditionalExpressionInInterpolatedString)]
public async Task TestAddParenthesisWhileTyping4()
{
await TestInMethodAsync(
@@ -233,7 +233,7 @@ public async Task TestAddParenthesisWhileTyping4()
NextLineOfCode();");
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesisAroundConditionalExpressionInInterpolatedString)]
+ [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesesAroundConditionalExpressionInInterpolatedString)]
public async Task TestAddParenthesisWhileTyping5()
{
await TestInMethodAsync(
@@ -247,7 +247,7 @@ public async Task TestAddParenthesisWhileTyping5()
NextLineOfCode();");
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesisAroundConditionalExpressionInInterpolatedString)]
+ [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesesAroundConditionalExpressionInInterpolatedString)]
public async Task TestAddParenthesisWithCS1026PresentBeforeFixIsApplied1()
{
await TestInMethodAsync(
@@ -261,7 +261,7 @@ public async Task TestAddParenthesisWithCS1026PresentBeforeFixIsApplied1()
NextLineOfCode();");
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesisAroundConditionalExpressionInInterpolatedString)]
+ [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesesAroundConditionalExpressionInInterpolatedString)]
public async Task TestAddParenthesisWithCS1026PresentBeforeFixIsApplied2()
{
await TestInMethodAsync(
@@ -275,7 +275,7 @@ public async Task TestAddParenthesisWithCS1026PresentBeforeFixIsApplied2()
NextLineOfCode(");
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesisAroundConditionalExpressionInInterpolatedString)]
+ [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesesAroundConditionalExpressionInInterpolatedString)]
public async Task TestAddParenthesisWithCS1026PresentBeforeFixIsApplied3()
{
await TestInMethodAsync(
@@ -289,7 +289,7 @@ public async Task TestAddParenthesisWithCS1026PresentBeforeFixIsApplied3()
NextLineOfCode();");
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesisAroundConditionalExpressionInInterpolatedString)]
+ [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParenthesesAroundConditionalExpressionInInterpolatedString)]
public async Task TestAddParenthesisAddOpeningParenthesisOnly()
{
await TestInMethodAsync(
diff --git a/src/EditorFeatures/TestUtilities/Traits.cs b/src/EditorFeatures/TestUtilities/Traits.cs
index 60765f83f37688e2112d047765c658cae06ca774..8c6cab85256dd02dc7bed3be2a60034fd0da0f27 100644
--- a/src/EditorFeatures/TestUtilities/Traits.cs
+++ b/src/EditorFeatures/TestUtilities/Traits.cs
@@ -40,7 +40,7 @@ public static class Features
public const string CodeActionsAddNew = "CodeActions.AddNew";
public const string CodeActionsAddOverload = "CodeActions.AddOverloads";
public const string CodeActionsAddParameter = "CodeActions.AddParameter";
- public const string CodeActionsAddParenthesisAroundConditionalExpressionInInterpolatedString = "CodeActions.CodeActionsAddParenthesisAroundConditionalExpressionInInterpolatedString";
+ public const string CodeActionsAddParenthesesAroundConditionalExpressionInInterpolatedString = "CodeActions.AddParenthesesAroundConditionalExpressionInInterpolatedString";
public const string CodeActionsChangeToAsync = "CodeActions.ChangeToAsync";
public const string CodeActionsChangeToIEnumerable = "CodeActions.ChangeToIEnumerable";
public const string CodeActionsChangeToYield = "CodeActions.ChangeToYield";
diff --git a/src/Features/CSharp/Portable/CSharpFeaturesResources.Designer.cs b/src/Features/CSharp/Portable/CSharpFeaturesResources.Designer.cs
index d80e6a9808adf7f16a1e96e5b49e5e44c82e85a0..1d7a4f1c93c7d12c33ac79400d4bfdf73cc45e31 100644
--- a/src/Features/CSharp/Portable/CSharpFeaturesResources.Designer.cs
+++ b/src/Features/CSharp/Portable/CSharpFeaturesResources.Designer.cs
@@ -71,20 +71,20 @@ internal class CSharpFeaturesResources {
}
///
- /// Sucht eine lokalisierte Zeichenfolge, die Add 'this.' ähnelt.
+ /// Sucht eine lokalisierte Zeichenfolge, die Add parentheses ähnelt.
///
- internal static string Add_this {
+ internal static string Add_parentheses_around_conditional_expression_in_interpolated_string {
get {
- return ResourceManager.GetString("Add_this", resourceCulture);
+ return ResourceManager.GetString("Add_parentheses_around_conditional_expression_in_interpolated_string", resourceCulture);
}
}
///
- /// Sucht eine lokalisierte Zeichenfolge, die Add parenthesis ähnelt.
+ /// Sucht eine lokalisierte Zeichenfolge, die Add 'this.' ähnelt.
///
- internal static string AddParenthesisAroundConditionalExpressionInInterpolatedString {
+ internal static string Add_this {
get {
- return ResourceManager.GetString("AddParenthesisAroundConditionalExpressionInInterpolatedString", resourceCulture);
+ return ResourceManager.GetString("Add_this", resourceCulture);
}
}
diff --git a/src/Features/CSharp/Portable/CSharpFeaturesResources.resx b/src/Features/CSharp/Portable/CSharpFeaturesResources.resx
index 0782bb389811f8467eab398968982a2724c524f1..86a50c4d9822ce47bcf85976807b470db4e61e7e 100644
--- a/src/Features/CSharp/Portable/CSharpFeaturesResources.resx
+++ b/src/Features/CSharp/Portable/CSharpFeaturesResources.resx
@@ -524,7 +524,7 @@
Use 'is null' check
-
- Add parenthesis
+
+ Add parentheses
\ No newline at end of file
diff --git a/src/Features/CSharp/Portable/CodeFixes/ConditionalExpressionInStringInterpolation/AddParenthesisCodeAction.cs b/src/Features/CSharp/Portable/CodeFixes/ConditionalExpressionInStringInterpolation/CSharpAddParenthesesAroundConditionalExpressionInInterpolatedStringCodeFixProvider.cs
similarity index 54%
rename from src/Features/CSharp/Portable/CodeFixes/ConditionalExpressionInStringInterpolation/AddParenthesisCodeAction.cs
rename to src/Features/CSharp/Portable/CodeFixes/ConditionalExpressionInStringInterpolation/CSharpAddParenthesesAroundConditionalExpressionInInterpolatedStringCodeFixProvider.cs
index 41c729d257c84003ac61d084f802a99f87c01ac9..45df68cec097791af0217ffe0108ae420a323252 100644
--- a/src/Features/CSharp/Portable/CodeFixes/ConditionalExpressionInStringInterpolation/AddParenthesisCodeAction.cs
+++ b/src/Features/CSharp/Portable/CodeFixes/ConditionalExpressionInStringInterpolation/CSharpAddParenthesesAroundConditionalExpressionInInterpolatedStringCodeFixProvider.cs
@@ -1,14 +1,40 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+using System;
+using System.Collections.Immutable;
+using System.Composition;
+using System.Linq;
using System.Threading;
using System.Threading.Tasks;
+using Microsoft.CodeAnalysis.CodeActions;
+using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CSharp.Syntax;
+using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Text;
namespace Microsoft.CodeAnalysis.CSharp.CodeFixes.ConditionalExpressionInStringInterpolation
{
- internal partial class CSharpAddParenthesisAroundConditionalExpressionInInterpolatedStringCodeFixProvider
+ [ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.AddParenthesesAroundConditionalExpressionInInterpolatedString), Shared]
+ internal partial class CSharpAddParenthesesAroundConditionalExpressionInInterpolatedStringCodeFixProvider : CodeFixProvider
{
+ private const string CS8361 = nameof(CS8361); //A conditional expression cannot be used directly in a string interpolation because the ':' ends the interpolation.Parenthesize the conditional expression.
+
+ public override ImmutableArray FixableDiagnosticIds => ImmutableArray.Create(CS8361);
+
+ public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
+ {
+ var root = await context.Document.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false);
+ var diagnostic = context.Diagnostics.First();
+ var diagnosticSpan = diagnostic.Location.SourceSpan;
+ var token = root.FindToken(diagnosticSpan.Start);
+ var conditionalExpression = token.GetAncestor();
+ if (conditionalExpression != null)
+ {
+ var documentChangeAction = new MyCodeAction(
+ cancellationToken => GetChangedDocumentAsync(context.Document, conditionalExpression.SpanStart, cancellationToken));
+ context.RegisterCodeFix(documentChangeAction, diagnostic);
+ }
+ }
private static async Task GetChangedDocumentAsync(Document document, int conditionalExpressionSyntaxStartPosition, CancellationToken cancellationToken)
{
@@ -39,5 +65,16 @@ private static async Task GetChangedDocumentAsync(Document document, i
return documentWithOpenParenthesis;
}
+
+ private class MyCodeAction : CodeAction.DocumentChangeAction
+ {
+ public MyCodeAction(Func> createChangedDocument)
+ : base(
+ CSharpFeaturesResources.Add_parentheses_around_conditional_expression_in_interpolated_string,
+ createChangedDocument,
+ CSharpFeaturesResources.Add_parentheses_around_conditional_expression_in_interpolated_string)
+ {
+ }
+ }
}
}
diff --git a/src/Features/CSharp/Portable/CodeFixes/ConditionalExpressionInStringInterpolation/CSharpAddParenthesisAroundConditionalExpressionInInterpolatedStringCodeFixProvider.cs b/src/Features/CSharp/Portable/CodeFixes/ConditionalExpressionInStringInterpolation/CSharpAddParenthesisAroundConditionalExpressionInInterpolatedStringCodeFixProvider.cs
deleted file mode 100644
index 6ab5c593ff19f04f9c12c8ff425b1f5396696a24..0000000000000000000000000000000000000000
--- a/src/Features/CSharp/Portable/CodeFixes/ConditionalExpressionInStringInterpolation/CSharpAddParenthesisAroundConditionalExpressionInInterpolatedStringCodeFixProvider.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Immutable;
-using System.Composition;
-using System.Linq;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
-using Microsoft.CodeAnalysis.CodeFixes;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-
-namespace Microsoft.CodeAnalysis.CSharp.CodeFixes.ConditionalExpressionInStringInterpolation
-{
- [ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.AddParenthesisAroundConditionalExpressionInInterpolatedString), Shared]
- internal partial class CSharpAddParenthesisAroundConditionalExpressionInInterpolatedStringCodeFixProvider : CodeFixProvider
- {
- private const string CS8361 = nameof(CS8361); //A conditional expression cannot be used directly in a string interpolation because the ':' ends the interpolation.Parenthesize the conditional expression.
-
- public override ImmutableArray FixableDiagnosticIds => ImmutableArray.Create(CS8361);
-
- public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
- {
- var root = await context.Document.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false);
- var diagnostic = context.Diagnostics.First();
- var diagnosticSpan = diagnostic.Location.SourceSpan;
- var token = root.FindToken(diagnosticSpan.Start);
- var conditionalExpression = token.GetAncestor();
- if (conditionalExpression != null)
- {
- var documentChangeAction = new CodeAction.DocumentChangeAction(
- CSharpFeaturesResources.AddParenthesisAroundConditionalExpressionInInterpolatedString,
- cancellationToken => GetChangedDocumentAsync(context.Document, conditionalExpression.SpanStart, cancellationToken));
- context.RegisterCodeFix(documentChangeAction, diagnostic);
- }
- }
- }
-}
diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.cs.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.cs.xlf
index 089102a84236f82c1158a37c35910ba932777a2d..41452422e4335f4ec9c8af793fcb017f6b35b639 100644
--- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.cs.xlf
+++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.cs.xlf
@@ -637,9 +637,9 @@
Use 'is null' check
-
- Add parenthesis
- Add parenthesis
+
+ Add parentheses
+ Add parentheses