diff --git a/src/nunit.analyzers.tests/UpdateStringFormatToInterpolatableString/UpdateStringFormatToInterpolatableStringCodeFixTests.cs b/src/nunit.analyzers.tests/UpdateStringFormatToInterpolatableString/UpdateStringFormatToInterpolatableStringCodeFixTests.cs index da3ef6f8..5ebfc285 100644 --- a/src/nunit.analyzers.tests/UpdateStringFormatToInterpolatableString/UpdateStringFormatToInterpolatableStringCodeFixTests.cs +++ b/src/nunit.analyzers.tests/UpdateStringFormatToInterpolatableString/UpdateStringFormatToInterpolatableStringCodeFixTests.cs @@ -130,6 +130,22 @@ public void TestEscapedBraces() RoslynAssert.CodeFix(analyzer, fix, expectedDiagnostic, code, fixedCode); } + + [Test] + public void TestConditionalExpressionArgument() + { + var code = TestUtility.WrapInTestMethod(@" + string? someValue = ""Value""; + ↓Assert.Pass(""Value is {0}"", someValue is null ? ""null"" : someValue); + "); + + var fixedCode = TestUtility.WrapInTestMethod(@" + string? someValue = ""Value""; + Assert.Pass($""Value is {(someValue is null ? ""null"" : someValue)}""); + "); + + RoslynAssert.CodeFix(analyzer, fix, expectedDiagnostic, code, fixedCode); + } #endif } diff --git a/src/nunit.analyzers/Helpers/CodeFixHelper.cs b/src/nunit.analyzers/Helpers/CodeFixHelper.cs index 0fe35241..61ccd3ba 100644 --- a/src/nunit.analyzers/Helpers/CodeFixHelper.cs +++ b/src/nunit.analyzers/Helpers/CodeFixHelper.cs @@ -162,7 +162,7 @@ internal static IEnumerable UpdateStringFormatT .OfType() .Any()) { - // Colon is not allowed in an Interpolation, wrap expression in parenthesis: (expession). + // Colon is not allowed in an Interpolation, wrap expression in parenthesis: (expression). formatArgument = SyntaxFactory.ParenthesizedExpression(formatArgument); }