T O P I C R E V I E W |
Uniwares |
Posted - Oct 03 2006 : 09:53:55 AM I've found a problem with C# classes added to class diagrams. When renaming the class, the class diagram throws an error because it does not find the class anymore - sure, the reference of the class in the .cd file was not updated.
Now, here comes the "can you do better" part: vs2005 does not update the reference either when renaming a class using the builtin refactoring tool. VAX could really do better here and scan .cd files for references too. |
7 L A T E S T R E P L I E S (Newest First) |
feline |
Posted - Oct 06 2006 : 5:54:09 PM I am able to reproduce the partial rename in VS2005. Renaming the "Form1.cs" file in the solution explorer, and then using VA to rename the form class without restarting the IDE does this. On the VA rename the "Form1.Designer.cs" (insert new name here) file is not listed in the references, so it is not updated.
for now i suggest not mixing the IDE's class renaming with VA's class renaming.
case=2888
i have put in a case for renaming inside the class diagram files as well, but i have no idea when this will be looked at.
case=2889 |
Uniwares |
Posted - Oct 05 2006 : 5:49:05 PM ok, got the files. tested.
I could not reproduce that exact problem seen in my projects. It really always updated the .cd file correctly and automatically. Might be some project property, reference, setting, whatever.
BUT: I managed to end up with something worse: a half renamed class. After playing around with renaming the Form1 class feline already provided, I added another form. The first Form1 was renamed (using various methods) to axForm1, the new form was Form1 then. Class diagram updated, showing all classes. Renamed axForm1 to xForm1 using vax rename. Vax showed properly all references (form1.cs, form1.designer.cs) and renamed it. After opening both files, the class name in form1.cs was xForm1 but in form1.designer.cs it was still axForm1, as it was also in the class diagram.
Conclusion: there is something wrong with VS2005. But, i think for cleaness' sake it would be good if VAX would also check for references in the class diagram files.
Another thing, does anybody have the slightest idea how many file types VS2005 has that may contain a reference to a symbol? I guess there are still some that are lurking somewhere. Just like those SQL query document types that exist only in memory but are shown in the OFiW dialog.
|
feline |
Posted - Oct 05 2006 : 3:48:09 PM let me have another go. somewhere along the line i discovered every time i press the Class Diagram button on solution explorer it generates a new diagram. i had expected it to open the existing diagram, so perhaps i had one of the early diagrams open without realising it.
* most tabs are now closed, only one CD file listed in solution explorer, and it is not currently open. * use VA to rename the form class * double click on the CD entry in solution explorer to open it.
the diagram has opened, and there is no star on its tab, yet it has updated its self to show the new name of the form. this is using my old C# project, without any partial classes. let me re-try with the new C# project, that uses partial classes.
* close and re-load VS2005 professional * close lots of tabs, including the class diagram * delete two class diagrams, so there is only one in solution explorer * use VA to rename the class * double click on the class diagram in solution explorer to open it. again, it says it has not been modified, but it is showing the new, correct name for the form.
i wonder if this is because my two test projects are both really simple.
I am just emailing you a copy of my test C# project. if you have time, could you try the same test on this project, to see what happens? i seem to be doing the same test as you, but i am getting different results. |
Uniwares |
Posted - Oct 05 2006 : 2:15:21 PM Thats strange then, I am seeing different behavior here. When the CD is open, there are no complaints, the file is updated and everything is happy. When the CD is closed, the class renamed using VS Refactoring, opening the CD file shows an error: "Code could not be found for one or more shapes in class diagram 'Forms.cd'. Do you want to attempt to automatically repair the class diagram?", clicking on Yes will correctly update the diagram (ok, other bug then, it does not mark the diagram as changed, so it does not offer to save it, but thats another story)
I have found now 5 ways to rename a class: 1) search/replace 2) VS Refactoring/Rename on the class name 3) VAX Refactoring/Rename on the class name 4) Renaming the .cs file in the Solution Explorer, which will implicitly rename the class too, if the class name matches the filename. 5) twice-click on the class name in the class diagram (not double click)
My forms are all standard forms created with the designer.
|
feline |
Posted - Oct 05 2006 : 2:00:47 PM I have a very basic C# form program, just a form with 4 buttons, in VS2005. I have created a class diagram and saved it out. If I then use VA to rename the form the class diagram is updating itself. If the class diagram is already open it seems to get updated as part of the rename, and if it is closed it gets updated when I re-open it.
Doing the rename with the class diagram as an open tab, the cs file is not listed by VA as one of the files to update. But as the rename takes place the cs tab gets a star, to indicate the file has been modified.
I am seeing exactly the same effect in a second, more complex C# form based program. I originally wrote this program in VS2003, when I was first learning C#, so it does not use partial classes.
Are your forms created with the designer? Or have you created them by hand? I am assuming that the IDE is monitoring my form classes for changes, and is updating the designer view, and also the class diagram, in real time. |
Uniwares |
Posted - Oct 04 2006 : 6:54:21 PM Yes, the problem seems to happen only with forms classes, probably because they are made up from the .cs file and the .designer.cs file. Not sure. |
feline |
Posted - Oct 04 2006 : 5:32:46 PM using VS2005 professional and a small C# test program of mine i opened the class diagram, which took ages, i assume generating it.
i saved and closed the .cd file and then used VA to rename one of my classes. I simply renamed it from "FileIndex" to "FileIndex2"
when i re-loaded the .cd file it picked up the class's new name, and it is showing me the details of the class.
i did not even know the class diagram existed until now, so have i missed some basic step? |
|
|