dotnet / winforms

Windows Forms is a .NET UI framework for building Windows desktop applications.
MIT License
4.4k stars 977 forks source link

Add Analyzers/CodeFixes to guide implementing Custom Control Properties according to WinForms best practices #11161

Closed KlausLoeffelmann closed 1 month ago

KlausLoeffelmann commented 6 months ago

When we author Controls, Custom Controls or User Controls, we also introduce Properties. Whenever we introduce Properties, we need to be aware, that those Properties are the Interface for all sorts of Data, which might also be available already at Design Time. The Developer of a Control therefore always should ensure to implement a property according for Best Practice to avoid unnecessary Code Generation, accidental serialization of data into resource files or serialization of nested Object graphs, which cannot correctly roundtrip.

To this end, we want to introduce Analyzers to help guide this process:

JeremyKuhne commented 2 months ago

https://github.com/dotnet/winforms/pull/11515/files

paul1956 commented 1 month ago

@KlausLoeffelmann In RC 1 and VB much of this is not working. The auto fixes add extra document comments, which case issues that VS reports or the fixer crashes. After adding the annotation manually the errors don't go away and ignoring the errors with severity none AFTER annotation does nothing. I reported this via Visual Studio feedback because none of the an available issue categories in Repo seemed correct.