dotnet / project-system

The .NET Project System for Visual Studio
MIT License
967 stars 385 forks source link

Additional feature for renaming file should rename class #227

Open jinujoseph opened 8 years ago

jinujoseph commented 8 years ago

Related to #109

333fred commented 8 years ago

One interesting point about this: what types of characters do we want to support between classes as part of the file name? Do we want to just do + and ., or others as well? One immediate idea that comes to mind is the following algorithm:

  1. Get all class names. (foo, bar)
  2. Determine if the file name can be created by joining the class names with some character. (foo+bar.cs -> foo+baz.cs)
  3. If match, offer rename prompt. (rename bar->baz)

Making 2 smart enough is going to be the interesting part. One initial thought I have is to make it support any valid path character that is not a valid identifier character for the language. It should also handle cases like:

  1. Have file named foo+bar.cs, with top-level class foo and 2 inner classes: bar and baz.
  2. Rename file to foo+bar1.cs
  3. Inner class bar is renamed.
333fred commented 8 years ago

Another point: should ordering matter? Ie, should I be able to have a file named foo+bar+baz.cs with the following class definitions:

class baz {
    class bar {
    }
    class foo {
    }
}

rename it to test+bar+baz.cs, and expect to see:

class baz {
    class bar {
    }
    class test {
    }
}
jinujoseph commented 8 years ago

yes , we do just + and . only i had some notes here https://microsoft.sharepoint.com/teams/managedlanguages/_layouts/15/WopiFrame.aspx?sourcedoc={79b652be-6aa1-4feb-8d23-fa9127483ce9}&action=edit&wd=target%28%2F%2FProject%20System.one%7C89e7c9d2-f741-4060-a593-54327019c089%2FFileRename%7Ce2d3b337-7322-4ae0-b02a-5421594fa134%2F%29

333fred commented 8 years ago

Another complex scenario:

class c1 {
    class c2 {
        class c3 {
        }
        class c5 {
        }
    }
    class c4 {
    }
}

Do we need to specify how the name of the file is created for this? I can see arguments for naming this either c1+c2+c4+c3+c5.cs (breadth-first) or c1+c2+c3+c5+c4.cs (depth-first). Additionally, what if it's named c1+c4+c2+c5+c4.cs (reversed order of classes).