Skip to content

Conversation

@CyrusNajmabadi
Copy link
Member

@CyrusNajmabadi CyrusNajmabadi commented Nov 30, 2019

Fixes #40066

Looks like this:

image

Todo:

  • vb
  • tests

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner November 30, 2019 02:58
@CyrusNajmabadi
Copy link
Member Author

Tagging @jinujoseph @dotnet/roslyn-ide

@CyrusNajmabadi
Copy link
Member Author

@jnm2 Would you be willing to help with tests?

@jnm2
Copy link
Contributor

jnm2 commented Nov 30, 2019

@CyrusNajmabadi Sure, soon as I can.

Comment on lines 63 to 76
if (invocation.Arguments.Length == 1 &&
invocation.Arguments[0].Value.ConstantValue is { HasValue: true, Value: string format })
{
unwrapped = invocation.Instance;
formatString = format;
return;
}

if (invocation.Arguments.Length == 0)
{
unwrapped = invocation.Instance;
formatString = "";
return;
}
Copy link
Contributor

@jnm2 jnm2 Dec 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Option:

if (invocation.Arguments.Length <= 1)
{
    unwrapped = invocation.Instance;

    formatString = invocation.Arguments.FirstOrDefault()?.Value.ConstantValue.GetValueOrDefault()
        ?? string.Empty;
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm ok in the current form. seems clearer to me.

@jnm2
Copy link
Contributor

jnm2 commented Dec 1, 2019

@CyrusNajmabadi What's the best way to help with tests? PR to this branch in your fork?

@CyrusNajmabadi
Copy link
Member Author

PR to this branch in your fork?

yes please!

@jinujoseph jinujoseph added Area-IDE Community The pull request was submitted by a contributor who is not a Microsoft employee. Feature Request labels Dec 2, 2019
@CyrusNajmabadi
Copy link
Member Author

@CyrusNajmabadi I gave you failing tests on purpose (like I said in chat) and it doesn't look like you changed the feature to pass them yet.

Oh, ok. I'll take a look :)

@jnm2
Copy link
Contributor

jnm2 commented Dec 9, 2019

Did you want me to do make the feature changes too? A couple of tests are suggestions (treat them all that way) and you mentioned wanting to be the one to merge the consecutive Unnecessary spans before comparing them to the test markup.

@jnm2
Copy link
Contributor

jnm2 commented Dec 9, 2019

Ah 👍

@CyrusNajmabadi
Copy link
Member Author

@ryzngard LMK what you need here. This is ready for review.

@CyrusNajmabadi
Copy link
Member Author

@jnm2 thanks for all your help!
@ryzngard plz review when you get a chance. Thanks!

@CyrusNajmabadi
Copy link
Member Author

Hey @ryzngard could you ptal at this PR? It's been more than two weeks without any movement... :-/

[Fact]
public async Task ToStringWithNoParameterWhenBothComponentsAreSpecified()
{
await TestMissingInRegularAndScriptAsync(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should support simplifying this scenario as well. Will file a separate task

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ryzngard I wrote the test this way because I thought of it as a correctness issue. The goo format string is being applied to the return value of ToString() and is a no-op. Removing ToString() would cause it to stop being a no-op. Wouldn't it be better to put a warning squiggle on :goo than to mark ToString() as redundant?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be a separate feature though, a warning squiggle whenever it is known that the format component cannot be applied to the expression type.

@ryzngard ryzngard merged commit 2b8a9f7 into dotnet:master Dec 18, 2019
@CyrusNajmabadi
Copy link
Member Author

Thanks!


unwrapped = invocation.Instance;
alignment = alignmentSyntax as TExpressionSyntax;
negate = targetName == nameof(string.PadLeft);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😱 We did a bad thing. Fix in #41845.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-IDE Community The pull request was submitted by a contributor who is not a Microsoft employee. Feature Request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Suggestion to replace ToString at end of interpolation expression with colon and format code

5 participants