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

Allow user to restrict scope of namespace rename changes #39426

Open
sandyarmstrong opened this issue Oct 21, 2019 · 9 comments
Open

Allow user to restrict scope of namespace rename changes #39426

sandyarmstrong opened this issue Oct 21, 2019 · 9 comments
Assignees
Labels
Area-IDE Concept-Continuous Improvement Feature - Rename Need Design Review The end user experience design needs to be reviewed and approved.
Milestone

Comments

@sandyarmstrong
Copy link
Member

From https://developercommunity.visualstudio.com/content/problem/738117/renaming-namespace-changes-namespaces-in-irreleven.html (and see also #3583):

I have a xamarin forms solution with the following projects,

  • Demo
  • Demo.Android
  • Demo.iOS

I changed the default namespace of Demo from options to Demo.UI, renamed the Demo csproj into Demo.UI, renamed the directory Demo to Demo.UI and updated the .sln file to access the Demo project (now Demo.UI).

Then I tried renaming the namespace in App.xaml.cs from Demo to Demo.UI, by right clicking on Demo namespace and chosing Rename. But this changed namespaces in other projects as well.

Ex: AppDelegate.cs in Demo.iOs’s namespace changed to “Demo.UI.iOS”

@sandyarmstrong
Copy link
Member Author

Note, the user is renaming "Demo" to "Demo.UI" by pasting the desired namespace when in inline rename mode (same user as #3583 (comment)).

@jinujoseph jinujoseph added this to the Backlog milestone Oct 23, 2019
@jinujoseph jinujoseph added the Need Design Review The end user experience design needs to be reviewed and approved. label Oct 23, 2019
@jinujoseph jinujoseph added this to In Queue in IDE: Design review via automation Oct 23, 2019
@genlu
Copy link
Member

genlu commented Nov 12, 2019

@sandyarmstrong While we don't have a way to rename a selected namespace, I think "move to namespace" refactoring could be used as a workaround.
https://docs.microsoft.com/en-us/visualstudio/ide/reference/move-type-to-namespace?view=vs-2019

@sandyarmstrong
Copy link
Member Author

@genlu I generally agree, though we don't have the "move to namespace" UI implemented yet in VSmac.

Maybe we should prevent rename from working at all on namespaces?

@genlu
Copy link
Member

genlu commented Nov 12, 2019

Maybe we should prevent rename from working at all on namespaces?

That, or we can properly support renaming selected namespace (i.e. move all enclosed types to namespace) and show an option in rename dialog. I will keep this issue open to track the design discussion

@sandyarmstrong
Copy link
Member Author

Can we at least add an option to disable rename refactorings from working on namespaces? We get a lot of customer complaints about the behavior and it would be nice to just turn it off to avoid confusion.

@genlu
Copy link
Member

genlu commented Aug 25, 2022

@Cosifne @ryzngard Thoughts? Alternatively, could we add a warning that "renaming namespace would affect all projects", or maybe an option in rename UI so user can select the scope?

@Cosifne
Copy link
Member

Cosifne commented Aug 25, 2022

My preference here is to add an option to limit the rename effect within the current project in the UI. This option only shows up in the rename UI if the selected symbol is a namespace.
Right now our RenameOptions is just a simple record containing 4 options. It would be possible to create a NamespaceRenameOptions from it.

@genlu genlu assigned Cosifne and unassigned genlu Aug 25, 2022
@jasonmalinowski jasonmalinowski moved this from In Queue to Next meeting in IDE: Design review Aug 26, 2022
@ryzngard
Copy link
Contributor

My preference here is to add an option to limit the rename effect within the current project in the UI. This option only shows up in the rename UI if the selected symbol is a namespace. Right now our RenameOptions is just a simple record containing 4 options. It would be possible to create a NamespaceRenameOptions from it.

I think we could add a checkbox, or even some sort of "Document | Project | Solution" scoping if wanted, similar to how we do with code fixes and refactorings in the light bulb. The UI would be different, but it would provide consistency with other places.

@JoeRobich
Copy link
Member

Design Meeting Notes (2022-08-29):

  • Makes sense to have this. Users could end up renaming more than they want. How would we limit this though?
    • InlineRename for namespaces doesn't fix up imports.
    • We resolve ambiguity at the use sites not the imports.
    • In the past the old name would be gone following a rename. When we do a partial rename like this we will still have the old name in parts of the Solution. This will be a new behavior.
    • In VS4Win we restrict the ability to introduce a dot when renaming a namespace. We may not have this restriction in VS4Mac.
  • If we want to provide this it should be a separate feature and not part of rename. Possibly a move multiple types to namespace. Duplicate of #3583
    • Should rename namespace also rename sub-namespaces. Is that an option we should provide?

Resolution:

  • Add test to see if the behavior when adding/removing a dot during rename does the right thing. If so, we will keep the behavior. Otherwise, we will make sure it errors.
    • New InlineRename experience should not allow pasting a dot.

@JoeRobich JoeRobich moved this from Next meeting to Complete in IDE: Design review Aug 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Concept-Continuous Improvement Feature - Rename Need Design Review The end user experience design needs to be reviewed and approved.
Projects
Status: Complete
IDE: Design review
  
Complete
Development

No branches or pull requests

7 participants