未验证 提交 e7b90ad8 编写于 作者: C CyrusNajmabadi 提交者: GitHub

Merge pull request #41845 from jnm2/your_other_left

Fixes the bug reported very kindly by @martinstenhoff at #40066 (comment).

Fixes #41826, same bug
......@@ -198,7 +198,7 @@ void M(string someValue)
{
void M(string someValue)
{
_ = $""prefix {someValue,-3} suffix"";
_ = $""prefix {someValue,3} suffix"";
}
}");
}
......@@ -218,13 +218,13 @@ void M(string someValue)
{
void M(string someValue)
{
_ = $""prefix {someValue,3} suffix"";
_ = $""prefix {someValue,-3} suffix"";
}
}");
}
[Fact]
public async Task PadLeftWithComplexConstantExpressionRequiringParentheses()
public async Task PadLeftWithComplexConstantExpression()
{
await TestInRegularAndScriptAsync(
@"class C
......@@ -240,7 +240,7 @@ void M(string someValue)
void M(string someValue)
{
const int someConstant = 1;
_ = $""prefix {someValue,-((byte)3.3 + someConstant)} suffix"";
_ = $""prefix {someValue,(byte)3.3 + someConstant} suffix"";
}
}");
}
......@@ -260,7 +260,7 @@ void M(string someValue)
{
void M(string someValue)
{
_ = $""prefix {someValue,-3} suffix"";
_ = $""prefix {someValue,3} suffix"";
}
}");
}
......@@ -280,7 +280,7 @@ void M(string someValue)
{
void M(string someValue)
{
_ = $""prefix {someValue,3} suffix"";
_ = $""prefix {someValue,-3} suffix"";
}
}");
}
......@@ -312,7 +312,7 @@ void M(string someValue)
}
[Fact]
public async Task PadRightWithComplexConstantExpression()
public async Task PadRightWithComplexConstantExpressionRequiringParentheses()
{
await TestInRegularAndScriptAsync(
@"class C
......@@ -328,7 +328,7 @@ void M(string someValue)
void M(string someValue)
{
const int someConstant = 1;
_ = $""prefix {someValue,(byte)3.3 + someConstant} suffix"";
_ = $""prefix {someValue,-((byte)3.3 + someConstant)} suffix"";
}
}");
}
......@@ -420,7 +420,7 @@ void M(string someValue)
{
void M(string someValue)
{
_ = $""prefix {someValue,-3:goo} suffix"";
_ = $""prefix {someValue,3:goo} suffix"";
}
}");
}
......@@ -440,7 +440,7 @@ void M(string someValue)
{
void M(string someValue)
{
_ = $""prefix {someValue,3:goo} suffix"";
_ = $""prefix {someValue,-3:goo} suffix"";
}
}");
}
......@@ -511,7 +511,7 @@ void M(string someValue)
{
void M(string someValue)
{
_ = $""prefix {someValue,-3} suffix"";
_ = $""prefix {someValue,3} suffix"";
}
}");
}
......@@ -568,7 +568,7 @@ void M(string someValue)
{
void M(string someValue)
{
_ = $""prefix {someValue.PadLeft(3),3} suffix"";
_ = $""prefix {someValue.PadLeft(3),-3} suffix"";
}
}");
}
......
......@@ -131,7 +131,7 @@ private static TextSpan GetSpanWithinLiteralQuotes(IVirtualCharService virtualCh
unwrapped = invocation.Instance;
alignment = alignmentSyntax as TExpressionSyntax;
negate = targetName == nameof(string.PadLeft);
negate = targetName == nameof(string.PadRight);
unnecessarySpans.AddRange(invocation.Syntax.Span
.Subtract(invocation.Instance.Syntax.FullSpan)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册