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
Visual Studio WinForms designer unable to display forms exported from VB.NET assembly #2602
Comments
I just tried this with a brand-new Windows Forms project and Visual Studio 2019 is able to open and display the Designer even though the generated code is not separated. Granted I only tried a very simple project with no changes. Of course VS did take some time until it realized that the file was a WinForms Form. Opening the file in the code-editor helped speed up a lot. As far as I know, the VS WinForms designer is not required to have a .Designer.cs file, because If you want me to take a closer look and analyze the problem, you will have to provide a binary for me to reproduce this. You can use a private channel: siegfried.pammer@gmail.com is my address.
Thanks! |
i updated it to to visual studio 2022 also i think maybe because there is no FormMain.Designer.cs because it gets generated when compiled maybe thats the problem there |
As far as I know, there is no generation at compile-time only at design-time. Is it possible for you to share more information and the assembly? Otherwise, I fear there is nothing I can do to improve the situation. Sorry! |
Yeah, I now understand what the problem is: You are trying to decompile a VB.NET application and of course ILSpy only can generate C# code. However, the VB.NET Forms Designer and C# Forms Designer generate completely different code. So the code is not recognized by the C# version. ILSpy would have to add more support for this, however, I don't see this happen any time soon. As soon as you do the following, the errors go away: [field: AccessedThroughProperty("Button3")]
internal virtual Button Button3
{
get;
[MethodImpl(MethodImplOptions.Synchronized)] set;
} should be replaced with internal Button Button3; Hope this helps! |
ok if you can point the right direction i possibly can add support for it or are you going to eventually go to add support |
I think we can add support for this. Would you be willing to contribute it? I will post some sample code on how to extend the decompiler in the evening. |
yes possibly do you have discord so we can chat live |
I don't think support for this is going to be easy -- effectively what needs to happen is that a |
yes i can see them when trying to decompile but it might take a while to get it sorted though i guess |
As far as I can tell, WithEvents fields are implemented as CLR properties, which are already transformed to C# auto-properties, if there are no event assignments. @modz2014 So you would have to add a transform that analyzes the properties of all classes that are derived from System.Windows.Forms.Control and check if they follow this pattern: public virtual Button Button1
{
[CompilerGenerated]
get
{
return _Button1;
}
[MethodImpl(MethodImplOptions.Synchronized)]
[CompilerGenerated]
set
{
EventHandler value2 = Button1_Click;
Button button = _Button1;
if (button != null)
{
button.Click -= value2; // event removal
}
_Button1 = value;
button = _Button1;
if (button != null)
{
button.Click += value2; // event add
}
}
} If there are no event assignments, you will already get C# auto-properties, which can simply be replaced with fields. While this can be done, I am sure it is impossible to cover all cases, because it is theoretically possible that a control is re-assigned outside of the InitializeComponent method and then the event assignments would not be adjusted. Maybe you are better off doing manual adjustments. If you still want to implement a transform, you can take a look at #2584 (comment) for a general setup. Also the code in https://github.com/icsharpcode/ILSpy/blob/master/ICSharpCode.Decompiler/CSharp/Transforms/PatternStatementTransform.cs#L613 will help you, because your transform will probably be very similar. Hope this helps! If you have questions, please feel free to ask them here. |
yer i have edited the form and added a designer form when decompiled from ILSpy in C# in took me 20mins to get the designer to show because of the project i was trying to do ill give it and shot and let you guys know what happens My computer stuff up trying yo add code to this project keep instilling and uninstalling laptop didn't like it |
yer i had a look i dont think its possible the only way is to do it manually i think |
hi im not sure if this is a bug or something but the it doesn't decompile FormMain.Designer.cs from a compiled exe just testing it with my own code i cant still run and build the project no problem but does not show the designer files
The text was updated successfully, but these errors were encountered: