views:

62

answers:

1

I would like to explicitly set the order of compilation of C# files in VS2008. Order in the project file, file naming seems to have no effect.

Situation: I have dozens of partial classes, each split over two files: 1) The file containing the auto-generated parts and 2) the file containing the manually written parts. The code generator is not very good, so I have to fix the constructors every time after regenerating the code.

My fool-proof solution is this:

  • fixing the constructor in the manual file
  • After regeneration, I get compiler errors about the duplicate constructors
  • Double click on the error which takes me to the duplicated constructor and delete it.

The problem: Visual Studio marks the later compiled constructor as duplicate. It always happens to be the manual, which causes me a hassle to find back the auto-generated one. I want VS to pick the auto-generated constructor as a duplicate.

Current solution I use: After regeneration of the code, I copy the code from manual file (and comment out the original) and paste it on the TOP of the auto-generated file. Then VS picks the autogenerated constructors as duplicate. Should I paste it on the bottom of the auto-generated file, VS pick the manual constructors as duplicate.

Does anyone have a better idea how to overcome the issue?

+1  A: 

I would tackle this in a different way: write a post-build tool to automatically remove the duplicate constructors. Presumably the ones you have to remove don't change, so you should be able to spot them fairly easily.

Jon Skeet