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

C# Change signature refactoring generates wrong syntax for named arguments in attribute constructor calls #50940

Open
vsfeedback opened this issue Feb 1, 2021 · 0 comments
Labels
Area-IDE Bug help wanted The issue is "up for grabs" - add a comment if you are interested in working on it IDE-CodeStyle Built-in analyzers, fixes, and refactorings
Projects
Milestone

Comments

@vsfeedback
Copy link

This issue has been moved from a ticket on Developer Community.


[severity:It's more difficult to complete my work]
When using the "Change signature" refactoring in C# to add a new parameter to a constructor of an attribute class and requesting to inject a value using a named argument at existing call sites, the generated syntax for that argument at the call sites where the attribute is applied to a member is wrong: using the = symbol for assigning the argument value, where it should be using the : symbol.

Steps to reproduce:

  1. Create a new C# Console App project (.NET Framework 4.8).
  2. Replace the Program class in Program.cs with the following code:
	class Program
	{
		[Foo(a: 5)]
		static void Main(string[] args)
		{
		}

class FooAttribute : Attribute
		{
			public FooAttribute(int a)
			{
			}
		}
	}
  1. Invoke the "Change signature" refactoring on the FooAttribute constructor.
  2. Press the Add button.
  3. Fill out the dialog as follows: Type name: int, Parameter name: b, Parameter kind: Required, Value to inject at all call sites: Value 2, "Use named argument" checked
  4. Press the OK button.
  5. Press the OK button of the change signature dialog.

Expected result at the call site:

		[Foo(a: 5, b: 2)]

Actual result at the call site:

		[Foo(a: 5, b = 2)]

Original Comments

Feedback Bot on 1/31/2021, 07:39 PM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.


Original Solutions

(no solutions)

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Feb 1, 2021
@jinujoseph jinujoseph added Bug help wanted The issue is "up for grabs" - add a comment if you are interested in working on it IDE-CodeStyle Built-in analyzers, fixes, and refactorings and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Feb 2, 2021
@jinujoseph jinujoseph added this to InQueue in Small Fixes via automation Feb 2, 2021
@jinujoseph jinujoseph added this to the Backlog milestone Feb 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Bug help wanted The issue is "up for grabs" - add a comment if you are interested in working on it IDE-CodeStyle Built-in analyzers, fixes, and refactorings
Projects
Small Fixes
  
InQueue
Development

No branches or pull requests

2 participants