I have a form in Winforms that contains the following code :
//MainForm.Designer.cs
partial class MainForm
{
...
private void InitializeComponent()
{
...
}
}
//MainForm.cs
public partial class MainForm : Form
{
readonly form = new AnotherForm(); //won't be called by designer
}
What I found out: once the form is opened in Visual Studio, the form designer will initialize everything declared in InitializeComponent() (as it should) but won't instantiate AnotherForm (which is OK behavior but weird on a pure C# point of view).
I'm just wondering how it works. It feels like the designer is able to instantiate a partial class without calling constructor and initializing all fields declared in that class. It this something possible with reflection ?