Mini Musing #1

In C#, when you create a Winforms form, you get a “.cs” file where you can write your own code, then a “.Designer.cs” file which is autogenerated. Every time you make a change using the Design View, it will regenerate the “.Designer.cs” file, so you should never manually change it.

    #region Windows Form Designer generated code

    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()

As you see in the example, it has a region which says “generated code“, then the next part is a comment that says “do not modify the contents“. So even if you don’t previously know it’s a generate file (as I described in the first paragraph); you sure do now.

Today, I got a code review where the InitalizeComponent method had been manually changed. Idiots.

Leave a comment