New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support abstract base class in designer #3329
Comments
The designer needs to instantiate the base class. It can't instantiate your actual class because that would mean baking the code you are trying to edit in the designer (i.e. recompiling after every single edit) It may be doable if the designer instantiated a dummy-subclass of the abstract base class. |
Either that, or let us have an option to control what designer should be designed. E.g. via an attribute like TypeDescriptionProvider. Unfortunately it doesnt always cleanly work. |
We'll consider an addition like this once we're fully at parity with the Framework designer. |
@merriemcgaw thanks, can't wait! :) |
I believe this is somewhat related to a Developer Community issue that I raised recently. In my experiences shown there, this does sometimes work in that the designer loads, but requires doing a build, then a restart of Visual Studio for the designer to be able to load the derived control successfully. So I think it is fairly close to working, but not quite there (almost a year later). |
@Olina-Zhang can your team walk through the scenario and get us an issue in the designer repo to triage soon. You can also link @StevenBonePgh's Feedback ticket he raised for more details to the team. Thanks! |
@merriemcgaw I have filed the GitHub issue: 3142 in designer repo based on details in StevenBonePgh's Feedback ticket. And the issue still occurs in the latest VS 2019 from main branch + latest .NET 6.0 SDK from main branch environment. |
I acknowledge that the issue is known to the team, and it is on our backlog (https://github.com/dotnet/winforms-designer/issues/3142). I am afraid there is nothing else I can add to this at this point. As a possible workaround you can add pragmas, to make the base form concrete during the development: #if DEBUG
public class FormBase : Form
#else
public abstract class FormBase : Form
#endif
{
protected FormBase()
{
}
} Closing due to age. |
https://github.com/dotnet/winforms-designer/issues/3142 can't be opened. I get a 404. |
Hi @nawfalhasan, it looks like you just commented on a closed issue. The team will most probably miss it. |
The winforms designer is not a public repo, the team probably linked it for internal usage. |
Hi @weltkante, it looks like you just commented on a closed issue. The team will most probably miss it. |
Is your feature request related to a problem? Please describe.
Problem: Unable to open up a form that inherits from an abstract form class.
Description:
When a form inherits from a abstract class, the designer of the more derived type cant be opened.
Example:
Now
FormDerived
in the designer wouldn't open up.Error when I try today:
From the designer:
Call stack:
Solution I would like:
Opening up the form designer should work any time from VS. Just like it opens up if base class is a regular class. The designer should design the first base class which can be instantiated (walking up the inheritance chain). In the above example it would be
Form
.What I tried:
This is the most commonly seen hack on internet:
But then again it doesn't work flawlessly. Project has to be rebuilt sometimes, sometimes VS has to be restarted etc. Doesn't work always
The text was updated successfully, but these errors were encountered: