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

F2 Rename on class only selects a part of the name #75521

Open
vsfeedback opened this issue Oct 15, 2024 · 1 comment
Open

F2 Rename on class only selects a part of the name #75521

vsfeedback opened this issue Oct 15, 2024 · 1 comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead

Comments

@vsfeedback
Copy link

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


[severity:I’m unable to use this version] [regression] [worked-in:17.9]
With the following code:

public class GlobalAuthorizationAttribute : Attribute
{
    public List<GlobalUserRightEnum> RequiredRights { get; } = new List<GlobalUserRightEnum>();

public GlobalAuthorizationAttribute(params GlobalUserRightEnum[] requiredRights)
    {
        RequiredRights = requiredRights.ToList();
    }
}
  

Expected behavior: the whole word GlobalAuthorizationAttribute is highlighted and I can edit the end of the name to something else.

When I move the cursor to GlobalAuthorizationAttribute and click F2 Rename or Ctrl+R depends on your keyboard shortcuts setting, then the renaming is possible only in the first part.
I need to rename GlobalAuthorizationAttribute to GlobalAuthorizationAttributeBase.
This is not possible using the feature.
obrazek.png

Why do I need to do that?
Because I want to create this code:
obrazek.png


Original Comments

Feedback Bot on 8/11/2024, 06:17 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.

Feedback Bot on 8/12/2024, 07:13 AM:

Thank you for sharing your feedback! Our teams prioritize action on product issues with broad customer impact. See details at: https://docs.microsoft.com/en-us/visualstudio/ide/report-a-problem#faq. In case you need answers to common questions or need assisted support, be sure to use https://visualstudio.microsoft.com/vs/support/. We’ll keep you posted on any updates to this feedback.

Shen Chen [MSFT] on 10/8/2024, 04:24 PM:

Hi Jan,

I understand your situation. This is a by-design scenario because we don’t want the Attributes suffix modified. We definitely want to improve this experience.
As a workaround, I tested locally if you comment out the : Attribute, then rename your class to the right name it should work. Later you can comment back the base class.
Thanks for your feedback.

Best,
Shen

Jan Seris on 10/9/2024, 07:50 AM:

OK you should improve the experience definitely. Maybe instead use analyzer and not block the renaming per se?
As for example for private fields and properties - there is a hint shown in Visual Studio but there is no blocking action to prevent that (and that’s probably expected behavior).
This is a much better solution:
obrazek.png

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Oct 15, 2024
@Cosifne
Copy link
Member

Cosifne commented Oct 15, 2024

A few notes:
We will need a better solution to handle renaming the Attribute suffix case.
User is trying to rename

public class Ex$$ampleAttribute : Attribute

to ExampleAttribuiteBase

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

No branches or pull requests

2 participants