[Designer discussion] Make InitializeComponent
code-gen more configurable
#10153
Replies: 3 comments 4 replies
-
Should really the code-gen serializer be so configurable? How about a simple legacy/modern switch? I thing the problematic is only about being compatible with the inproc vs outofproc designer. Maybe in the future you want to change some serialization code to use more recent c# features and any shared code would need to disable this specific code-style in the csproj. Why not having a single ApplicationCodeGenLegacyStyle: True/False (false by default). Even more: why not setting this setting to true implicitely as soon as the the project |
Beta Was this translation helpful? Give feedback.
-
If you decide to go down this route, please consider
|
Beta Was this translation helpful? Give feedback.
-
I don't see how we can do the latter, without breaking dock layouts and dedicated overlapping controls. |
Beta Was this translation helpful? Give feedback.
-
Hey Community,
we would love your take on this issue, which we have been discussing internally.
From some comments and issues from the Community feedback channel, we feel it might be a good idea, to make the code-gen for
IntializeComponent
more configurable, especially around automatic delegate method group conversion when hooking up events in C# and the shortening of type names in general.While we had positive feedback in general, there were some dev teams using WinForms, which had problems, when they were sharing UI code between Framework and .NET and In-Proc and Out-Of-Proc Designer. In this case, the Forms/UserControls would basically roundtrip, but the different type-name serialization was annoying. In the case of using the delegate conversion, the In-Proc designer cannot even process that code-style - it would lead to code loss.
New style:
Old Style:
So, the issue to discuss is: Should we introduce additional configuration options or should we hard code to omit the delegate conversion per se and live with the differences between out-of-proc and in-proc designer, which just would lead to different coding-styles, but would round-trip OK (Everything would work out of the box).
Here is the internal Designer-Repo PR description:
Currently, when we generate Visual Studio and C# InitializeComponent Code in the Out-Of-Proc Designer, we are taking .editorConfig settings for a couple of code item styles into account:
this
orMe
(or rather their omission, where it's ok in the context).But we have other areas, though, where we're applying a certain code style without asking.
This PR is an approach to expand the configuration option for the latter.
It introduces the Project settings:
ApplicationCodeGenMethodGroupConversions: True/False
ApplicationCodeGenSimplifiedTypeNames: True/False
It also introduces the necessary code changes, to actually honor the option to generate the instantiation of the Event Handlers, when the respective option is set to false.
The reason we cannot use .editorConfig for this, are:
a) There isn't really a respective setting, which would make sense to use.
b) We cannot extend the schema of the .editorConfig in a meaning full way,
c) It wouldn't also not make sense conceptionally, since those changes folks most likely would like to address ONLY in the context of
InitializeComponent
to be backwards compatible with the In-Proc-Designer. They don't want to have those coding styles for analyzers or code fixers. Also, it makes sense to just do it on project level, because it's a project which would be most likely contain Forms, which need to be shared (for example during a project migration) for a longer period of time (or even forever).Beta Was this translation helpful? Give feedback.
All reactions