Skip to content

Conversation

RussKie
Copy link
Member

@RussKie RussKie commented Oct 7, 2023

Windows Forms designer requires a default constructor to be able to open a form on the design surface.

This, however, does not work in situations where some parameters must be set in the constructor (e.g., dependency injection).

Previously, we would create a default constructor specifically for the Windows Forms designer integration. However, this implies a lot of unnecessary overhead.

Emit the default constructors for the designer integration with source generators.

Merge strategy

I agree that the maintainer squash merge this PR (if the commit message is clear).


✒️ I contribute this code under The Developer Certificate of Origin.

@ghost ghost assigned RussKie Oct 7, 2023
Windows Forms designer requires a default constructor to be able
to open a form on the design surface.

This, however, does not work in situations where some parameters must be
set in the constructor (e.g., dependency injection).

Previously, we would create a default constructor specifically for the
Windows Forms designer integration. However, this implies a lot of
unnecessary overhead.

Emit the default constructors for the designer integration with source
generators.
Copy link
Member

@mstv mstv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +147 to +154
#pragma warning disable SA1513 // Closing brace should be followed by blank line
if (syntaxNode is ClassDeclarationSyntax
{
BaseList: BaseListSyntax
{
Types.Count: > 0
}
})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sharwell, StyleCop 1.2.0-beta.435 emits a warning about this.

@RussKie
Copy link
Member Author

RussKie commented Oct 7, 2023

This currently doesn't handle generic forms (e.g., such as SearchWindow<T>) but I consider this a small value item, which can be solved later.

public partial class SearchWindow<T> : Form where T : class

Merging.

@RussKie RussKie merged commit 48e7537 into gitextensions:master Oct 7, 2023
@RussKie RussKie deleted the sgen_forms_designer_ctor branch October 7, 2023 12:58
@ghost ghost added this to the vNext milestone Oct 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants