WinForm button click event generated code missing RETURN

This forum is meant for questions and discussions about the X# language and tools
Post Reply
Jamal
Posts: 322
Joined: Mon Jul 03, 2017 7:02 pm

WinForm button click event generated code missing RETURN

Post by Jamal »

Create a form, add a button, double click, the double button, it creates:

Code: Select all

PRIVATE METHOD button1_Click(sender AS OBJECT, e AS System.EventArgs) AS VOID STRICT
The RETURN statement is missing.

It may not be necessary but it's not conforming the VO standard or other designer generated code which include a RETURN statement or the Start function which includes it:

Code: Select all

FUNCTION Start() AS VOID
    
    Application.EnableVisualStyles()
    Application.SetCompatibleTextRenderingDefault( FALSE )
    Application.Run( Form1{} )
   
    RETURN
Edit: Using VS 2017
FFF
Posts: 1582
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

WinForm button click event generated code missing RETURN

Post by FFF »

Jamal,
i take it, this is VS?
just did it in Xide, got:
METHOD Button1Click(sender AS System.Object , e AS System.EventArgs) AS VOID
RETURN

Karl
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
Jamal
Posts: 322
Joined: Mon Jul 03, 2017 7:02 pm

WinForm button click event generated code missing RETURN

Post by Jamal »

Karl,

Yes, I should have mentioned that I use VS 2017..
User avatar
robert
Posts: 4529
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

WinForm button click event generated code missing RETURN

Post by robert »

Jamal,
When the windows forms editor generates the event, it does not generate source code but an object model that describes the code.
The editor does not include a return statement. You should see that also in C# the generated code does not end with a return statement. But C# of course use curly braces so it is clear where the method ends.

This object model is the same as the object model that we generate when parsing the source code for forms.
I will see if we can detect that an event handler is generated from the forms editor and if we can then add the RETURN statement at the end of this code.
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
Jamal
Posts: 322
Joined: Mon Jul 03, 2017 7:02 pm

WinForm button click event generated code missing RETURN

Post by Jamal »

Robert,

I know about the C# braces thingy but that's how C# always behaved, however, if this a new feature of X# not to require that is good but there is no indication where the code ends.
I will see if we can detect that an event handler is generated from the forms editor and if we can then add the RETURN statement at the end of this code.
I think that would be better for the sake of consistency.

Jamal
Post Reply