[suggestion] move Dispose(bool disposing) from Form1.Designer.cs to Form1.cs
See original GitHub issueIssue description
What do you think about moving this method for newly created form? This will save a few seconds of time for each form 😃
But most importantly It’s location raises many questions for beginners (ppl afraid to modify anything in *.Designer.cs
):
https://stackoverflow.com/questions/1052147/how-do-i-extend-a-winforms-dispose-method
https://stackoverflow.com/questions/672980/dispose-on-user-controls-really-meant-to-edit-the-designer-cs-file
https://stackoverflow.com/questions/4382693/when-modifying-disposebool-in-a-winforms-generated-designer-cs-file-is-it-nec
and so on…
Also it can be modernize a bit.
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
To
protected override void Dispose(bool disposing)
{
if (disposing)
{
components?.Dispose();
}
base.Dispose(disposing);
}
Or are we afraid that this method will simply be deleted, or corrupted by the user?
Issue Analytics
- State:
- Created 7 months ago
- Comments:14 (14 by maintainers)
Top Results From Across the Web
When modifying Dispose(bool) in a winforms generated . ...
When modifying Dispose(bool) in a winforms generated .Designer.cs file is it necessary to move Dispose to the main code file?
Read more >dispose (bool): no suitable method found to override
To me it seems, you try to override void Dispose(bool), to perform ... to perform some action in the moment, when the form...
Read more >Windows Forms Designer Problem When Renaming New ...
I created a solution with two test projects. I created a Windows Forms project which, of course, defaulted to names Form1.cs and Form1.Designer....
Read more >How do I dispose something defined in a form?
To dispose of resources defined in a user control, you can override the Dispose(bool disposing) method in the user control's code-behind file ( ......
Read more >Form1.Designer.cs
Dispose (disposing); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We’ll take this up internally, and explore whether or not this is the right way to ensure that our components are disposed. In general, we like this idea and just want to think about it 😄
I think this would be more correct than what we have now for the new form template. Its not “generated” code and isn’t updated as far as I know. It would allow easier visibility on what is happening. The
*designer.cs
hides implementation from users to a degree and this makes it harder to learn the lifecycle.