Resharper breaks WinForms Designer

Hi,
When I use Resharper's auto optimization (Ctrl-Alt-F) on a WinForm that has been converted from a VS2003 solution to VS2005, it often breaks the designer, thus making the Form unusable.
It seems that the problem is with converted forms only, because they have the generated InitializeComponent() method inside the (only) form class file, unlike forms created in VS2005, where a partial file is used for the generated section.
To reproduce, create a C# form in VS2003, add some controls to it from the designer, save, and then open in VS2005 (it'll be converted). Then open the form source code, and optimize everything using resharper (Ctrl-Alt-F, select all options, OK). Trying to open the designer now results in exceptions.
Omer.

5 comments
Comment actions Permalink

Hello Omer,

Does it break code if you uncheck "Shorten qualified references" checkbox
before doing reformat?

Sincerely,
Ilya Ryzhenkov

JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"


OM> Hi,
OM>
OM> When I use Resharper's auto optimization (Ctrl-Alt-F) on a WinForm
OM> that has been converted from a VS2003 solution to VS2005, it often
OM> breaks the designer, thus making the Form unusable.
OM>
OM> It seems that the problem is with converted forms only, because they
OM> have the generated InitializeComponent() method inside the (only)
OM> form class file, unlike forms created in VS2005, where a partial
OM> file is used for the generated section.
OM>
OM> To reproduce, create a C# form in VS2003, add some controls to it
OM> from the designer, save, and then open in VS2005 (it'll be
OM> converted). Then open the form source code, and optimize everything
OM> using resharper (Ctrl-Alt-F, select all options, OK). Trying to open
OM> the designer now results in exceptions.
OM>
OM> Omer.
OM>


0
Comment actions Permalink

I'll have to check that at work next week, since I don't have vs2003 installed on my home machine.
However, I think you should ignore the whole generated region completly. Currently you also issue lots of warnings for the generated section, which is bad because fixing those warnings will result again in a broken form.

I think the best option should be a new refactoring that will allow me to convert the form to the new vs2005 format, i.e. splitting the form to the 2 partial form.cs and form.designer.cs files.

Omer.

0
Comment actions Permalink

OK, I checked this out, and apparently the bug was fixed in a recent build, because I could not reproduce it.
I happily noticed that there were no warnings in the InitializeComponents() method, and that auto-formatting the file did not touch that section.
Great job, JetBrains!

Still, do you think a refactoring that will transform the converted form to the new partial main + designer file structure can be added to ReSharper?

Omer.

0
Comment actions Permalink

Still, do you think a refactoring that will transform the converted form to the new partial main + designer file structure can be added to ReSharper?


Count me in :)

0
Comment actions Permalink

Hello Omer,

I don't think we will do this special-case feature, but we have plans to
introduce context actions to move members between parts. I think, we may
also need feature "Create dependent part", which will create class part in
the new project file, which is under original one in project hierarchy. Not
for 3.0, as feature list for this version is (almost) frozen.

Sincerely,
Ilya Ryzhenkov

JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"


OM> OK, I checked this out, and apparently the bug was fixed in a recent
OM> build, because I could not reproduce it.
OM>
OM> I happily noticed that there were no warnings in the
OM> InitializeComponents() method, and that auto-formatting the file did
OM> not touch that section.
OM>
OM> Great job, JetBrains!
OM>
OM> Still, do you think a refactoring that will transform the converted
OM> form to the new partial main + designer file structure can be added
OM> to ReSharper?
OM>
OM> Omer.
OM>


0

Please sign in to leave a comment.