Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggests parameter name for IntroduceLocal on an argument #10072

Closed
wants to merge 2 commits into from

Conversation

kuhlenh
Copy link

@kuhlenh kuhlenh commented Mar 24, 2016

Fixes #2423.

@dotnet/roslyn-ide for review 🎉

}
}

public static ArgumentInfo GetArgumentInfo(this SemanticModel semanticModel, ArgumentSyntax argument)
Copy link
Member

Choose a reason for hiding this comment

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

probably shouldn't be public. Private?

Copy link
Member

Choose a reason for hiding this comment

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

Oh, I see. I didn't realize this was the SemanticModelExtensions class. This is fine to have public here.

Copy link
Member

Choose a reason for hiding this comment

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

I'm pretty certain there is an IOperation call that gives you this information directly. Ask @JohnHamby if that's true.

Copy link
Member

Choose a reason for hiding this comment

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

That'd be cool. Though this is definitely a missing SemanticModel API.

Copy link
Author

Choose a reason for hiding this comment

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

I can use IOperation but I'm waiting for #10082.

@amcasey
Copy link
Member

amcasey commented Mar 24, 2016

Would it be interesting to test parameters from things other than methods? For example, indexers, or delegates? Does it work with property setters or is inferring "value" unhelpful? Does it work with overloaded operators (e.g. if I extract the LHS of a user-defined addition operator)?

}
else
{
var argumentList = parent.Parent as ArgumentListSyntax;
Copy link
Member

Choose a reason for hiding this comment

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

What about BracketedArgumentList?

@CyrusNajmabadi
Copy link
Member

Also, the intent of my bug was that we would pick this name as the last thing we do if no other matches happen. i.e. if you write:

.Add([|x.Customer|]);

Then the variable introduces should be called "Customer", not "Item/Value/Whatever".

i.e. only if we were going to fallback to our "can't think of a good name" codepath would we do these extra checks.

{
if (parent.NameColon != null)
{
return parent.NameColon.Name.Identifier.ValueText.ToCamelCase();
Copy link
Member

Choose a reason for hiding this comment

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

  1. Do we care if the name is missing?
  2. Do we care if the name is wrong (i.e. squiggled)?
  3. Why do we need to call ToCamelCase? Shouldn't we follow the casing of the named argument?

@amcasey
Copy link
Member

amcasey commented Mar 24, 2016

Do we need to test the case where the parameter name is not a valid identifier in the calling language?

@jmarolf
Copy link
Contributor

jmarolf commented Mar 24, 2016

ETA test failures are unrelated
Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.CodeRefactorings.IntroduceVariable.InteractiveIntroduceVariableTests.TestBlockFormatting is failing because it expects variable name to be v and it is now value

@davkean
Copy link
Member

davkean commented Mar 25, 2016

@dotnet-bot retest prtest/win/dbg/eta please
// Previous failure: http://dotnet-ci.cloudapp.net/job/dotnet_roslyn_prtest_win_dbg_eta/5428/
// Retest reason: #10101

@amcasey
Copy link
Member

amcasey commented Mar 25, 2016

Does/should this work for the receiver of a reduced extension method?

@CyrusNajmabadi
Copy link
Member

IMO, using hte parameter name should only be the last resort if any other options didn't work. That's what i intended when i filed the bug.

We already have good rules for what to do based on the expression itself. This is about what we do when none of those current rules work, and we need to use some additional context to help determine the name.

@Pilchie
Copy link
Member

Pilchie commented Apr 6, 2016

@CyrusNajmabadi I disagree that a type name is in general better than a parameter name :)

@jaredpar
Copy link
Member

We apologize, but we are closing this PR due to code drift. We regret letting this PR go so long without attention, but at this point the code base has changed too much for us to revisit older PRs. Going forward, we will manage PRs better under an SLA currently under draft in issue #26266 – we encourage you to add comments to that draft as you see fit. Although that SLA is still in draft form, we nevertheless want to move forward with the identification of older PRs to give contributors as much early notice as possible to review and update them.

If you are interested in pursuing this PR, please reset it against the head of master and we will reopen it. Thank you!

@jaredpar jaredpar closed this Apr 19, 2018
@sharwell sharwell added the Resolution-Expired The request is closed due to inactivity under our contribution review policy. label Apr 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE cla-already-signed Resolution-Expired The request is closed due to inactivity under our contribution review policy.
Projects
None yet
Development

Successfully merging this pull request may close these issues.