Code Cleanup not available on certain .cs files?

Using Resharper C# 4.1.933.3 Evaluation, VS2008

We do have some classes organized in partial classes and thus in files with related filenames,
e.g.:
class= DlgAbout,
default files are: DlgAbout.cs, DlgAbout.Designer.cs, DlgAbout.resx
Now when we organize code as partial class, we have the following situation:
DlgAbout.MenuHandlers.cs, DlgAbout.Worker.cs, etc.

VS2008 displays those files neatly under the main DlgAbout.cs just as it does with the .designer and .resx files. But Resharper does not allow any code cleanup to be run on those files.

Is this a limitation or bug?

6 comments

Just saw someone else asking the same on this thread (unanswered still) http://www.jetbrains.net/devnet/message/5219481#5219481

This comes up under "related" but does not show when I search for cleanup in the forums

0

On a purely unofficial basis:

Partial classes were created specifically to support code-gen scenarios where only one file, the main file with a normal .cs extension, is maintained by the user. Automated tools are going to avoid messing with the other files, as they are assumed to be the code-gen'ed ones and changes to them will a) be lost upon re-gen and b) could confuse the code-gen process in certain scenarios.

As an aside: If you are using partial classes for anything other than the above, as is suggested by your post, you probably have one or more code smells on your hands that, if addressed, could both improve the quality of your design and implementation and get you away from your slightly-off-the-intended-path usage of partial classes.

0

While I do totally agree by theory that this should be avoided, the design of windows forms (or controls) do not really favor different approaches. When you have a slightly more complex custom control you quickly end up with hundreds of eventhandlers (key handles, mouse handlers, window messages, etc) which you can of course group with regions or comments, but it does not really improve maintainability. Splitting this into partial files makes the job a bit easier, and Visual Studios ability to group those files automatically comes in handy even it that is NOT the original intention. Using folders that purpose is also not really the best choice.

0

I hear ya, I do. The entire VS / csc (and, by extension, R#) treatment of partial classes could do with some refinement, especially in and around differentiating between generated partial classes versus human-maintained ones.

0

jeremygray wrote:

... treatment of partial classes could do with some refinement...


When?

0

Exactly.

I don't know if you've heard differently, but I don't (off the top of my head, at least) recall hearing about any improvements in this area coming in C#4/VS10

0

Please sign in to leave a comment.