Background and motivation
Currently, when you have a control, say a button, in the visual form designer, and you double-click it, it generates a normal method in the the MyForm.cs file, such as:
private void button_Click(object sender, EventArgs e)
{
}
And in MyForm.designer.cs it just adds
this.button.Clicked += new EventHanlder<EventArgs>(this.button_Click);
Now, if you will remove this method, it will cause a designer error, and you'll have to go to the designer code and manually delete this line. For beginners it's especially problematic...
I think that a better approach would be to generate partial method, and add its signature in the designer:
this.button.Clicked += new EventHanlder<EventArgs>(this.button_Click);
...
partial void button_Click(object sender, EventArgs e);
This way, if you will delete the method implementation, it won't be an error.
API Proposal
partial class Form1 : Form
{
private partial void Button1_Click(object sender, EventArgs e)
{
}
}
API Usage
Form1.designer.cs:
private void InitializeComponent()
{
...
this.Button1.Clicked += new System.EventHandler<System.EventArgs>(this.Button1_Click);
}
private Button Button1;
private partial void Button1_Click(object sender, EventArgs e);
Alternative Designs
No response
Risks
No response
Will this feature affect UI controls?
The VS designer will need to generate event methods as partial methods.
Background and motivation
Currently, when you have a control, say a button, in the visual form designer, and you double-click it, it generates a normal method in the the MyForm.cs file, such as:
And in MyForm.designer.cs it just adds
Now, if you will remove this method, it will cause a designer error, and you'll have to go to the designer code and manually delete this line. For beginners it's especially problematic...
I think that a better approach would be to generate partial method, and add its signature in the designer:
This way, if you will delete the method implementation, it won't be an error.
API Proposal
API Usage
Form1.designer.cs:
Alternative Designs
No response
Risks
No response
Will this feature affect UI controls?
The VS designer will need to generate event methods as partial methods.