c# - vs2015 - vs2017 regenerate designer file




Automatic regenerate designer files (2)

Employ form's inheritance instead of maintaining changes over 300 controls.

Recently I've been making some improvements to a lot of the controls we use, for example give properties default values and making buttons private instead of protected. By making this kind of adjustments you need to regenerate the designer files of the forms which have this control on it or controls which inherit from the control.

In the past this wasn't really a problem because we only had 20-30 forms. At the moment we've got more than 300 forms which would mean opening the same amount of designers in VS2010.

So my question: do you know a way of automating this process so all of the forms get regenerated?

I've been thinking about a macro which looks for designer files and opens the file (with a max of 25-50 files open to make sure VS won't crash), but I've not been able to get this working.

I hope someone has a suggestion!


I also ran into this problem (see also: Force WinForms to regenerate .designer.cs files).

In the end, most of the properties I removed were uniquely named, and I was able to write a shell script to remove lines from the designer files that contained the property names.

Note, this actually removes the line, not just leaving a blank line.
It needs to be run from a Bash Shell, if you have msysgit installed, that shell is fine.
In this one, TextForeColor was the property being removed.

#!/bin/bash
files=$(find . -type f -name '*.Designer.cs' -print0 | xargs -0 grep -l 'TextForeColor')
for file in $files
do
    echo $file
    sed '/TextForeColor/ d' $file >$file.tmp
    mv $file.tmp $file
done




automated-refactoring