Clarification about System.Drawing.Font and Dispose
- Dominant language
- C#
- Stars
- 4.9k
- Forks
- 1.1k
- Avg merge
- 20h 23m
- Merged PRs (30d)
- 103
Description
- [Docs](https://docs.microsoft.com/en-us/dotnet/api/system.drawing.font.dispose?view=dotnet-plat-ext-3.1) says nothing unusual here:
> Call Dispose when you are finished using the Font. The Dispose method leaves the Font in an unusable state. After calling Dispose, you must release all references to the Font so the garbage collector can reclaim the memory that the Font was occupying.
- Designer assigning fonts this way: `someControl.Font = new System.Drawing.Font(...);` and never Dispose them.
- In .net [Font.Dispose(bool disposing)](https://referencesource.microsoft.com/System.Drawing/R/316bf22f513c0e53.html) has an `[SuppressMessage("Microsoft.Usage", "CA2213:DisposableFieldsShouldBeDisposed")]` attribute. But in core it's [gone](https://source.dot.net/System.Drawing.Common/R/316bf22f513c0e53.html).
- There are many questions about Font and Dispose on stackoverflow (with variants answers):
[Should I dispose of the old font when changing the font of a control?](https://stackoverflow.com/questions/29103522/should-i-dispose-of-the-old-font-when-changing-the-font-of-a-control)
[How and when is Font disposed for WinForms controls](https://stackoverflow.com/questions/21769908/how-and-when-is-font-disposed-for-winforms-controls)
[Calling dispose() for Font in Windows form](https://stackoverflow.com/questions/22661480/calling-dispose-for-font-in-windows-form)
[Windows Form Fonts Questions Part 1](https://stackoverflow.com/questions/5148476/windows-form-fonts-questions-part-1)
and more...
If nothing special here (docs are correct), why Designer never call Font.Dispose then? Otherwise, can we have official clarification (update docs)?
Ups, sorry about _api-suggestion_ label - my bad :( Pls remove it.
Contributor guide
Assessment
This issue has not been assessed yet.