Strange error 0118 in comment <sic> & differences XIDE vs VS

This forum is meant for questions and discussions about the X# language and tools
Post Reply
FFF
Posts: 1580
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

Strange error 0118 in comment <sic> & differences XIDE vs VS

Post by FFF »

Following Phil's advice i got me via nuget "EasyHttp" library from github.
Made a new X# app in Xide, added the references to the two dlls involved.
Then:

Code: Select all

USING EasyHttp
USING EasyHttp.Http
FUNCTION Start( ) AS VOID
	System.Console.WriteLine("Hello x#!")               
GetFromUrl()

RETURN
FUNCTION GetFromUrl() AS VOID
	LOCAL  http := HttpClient{}  AS HttpClient                       
	      http:Get("drei-f.de")
//	http:Request:Accept := HttpContentTypes.ApplicationJson
//	VAR response := http.Get("url")
//	VAR customer := response.StaticBody<Customer>()
//	Console.WriteLine("Name: {0}", customer.Name)
RETURN 
That code is partially transferred from minimal sample from the lib, hence the commented lines.

The strange thing is: this very code produces on F9 a:
Compilation failed (1 error)
error XS0118: 'customer' is a variable but is used like a type 16,38 Start.prg EasyHttp
Line 16 is the empty line behind the closing RETURN.
Why even "reads" the compiler the commented lines?
If i remove the commented lines, it compiles.
Unfortunately, further on, Xide fails at runtime with "System.TypeLoadException: Type "EasyHttp.Http.HttpClient" in Assembly "EasyHttp, Version=0.0.0.0, Culture=neural, PublicKeyToken=null" couldn't be loaded" (Copy to bin is set, the dlls are there...).
This made me "copy" the app in VS2015, where this error does not happen. Looking further, the template for a console app in VS has about 6 references more, so to check this out, i added them to my Xide-app, but to no avail...
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
User avatar
Chris
Posts: 4899
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Strange error 0118 in comment <sic> & differences XIDE vs VS

Post by Chris »

Hi Karl,

In the code that the compiler reports an error there is this code:

Console.WriteLine("Name: {0}", customer.Name)

and indeed you are using "." on an instance ("customer") of a type to access a member ("Name") of the type, instead of using ":". If you were compiling for the core dialect, "." would had been allowed, too, but I assume you are compiling in vulcan dialect and in this dialect you need to use ":", same as in VO and vulcan. Supporting "." also in vulcan dialect is not supported because it produces several ambiguities that the compiler cannot resolve.

As for the compiler reporting error in a commented line, are you sure that you did not comment this out after you compiled the code? Or maybe something similar happened? If not, can you please send me the app to have a look? But please do include the library dll files, I'd prefer to avoid downloading them myself :-)

Chris
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
FFF
Posts: 1580
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

Strange error 0118 in comment <sic> & differences XIDE vs VS

Post by FFF »

Chris,
no, had made a new X#/Core app, wanted only a quick playground to see, if i could use the Easyhttp code.
Yes, initially the offending code was "active", then commented out, but why the error persists?
Third: this morning the error is gone. If i try to "re-get" it, i see now the errors from earlier this week re static vs. instance etc.
Can only imagine, that i managed to disturb XIDE, starting point was some VB-net code i had opened as prg, which showed rather strange display with entity dividers almost randomly placed. If you are interested, i attached this prg file, too (this code has nothing to do with the other, unfortunately the coders choose the same name for their projects)

Nevertheless, the Loadexception continues, the Code is:

Code: Select all

FUNCTION Start( ) AS VOID
	System.Console.WriteLine("Hello x#!")               
GetFromUrl()

RETURN
FUNCTION GetFromUrl() AS VOID
	LOCAL  http := HttpClient{}  AS HttpClient                 
//	http.GetAsFile("http://hadihariri.com/header.png", "C:Tempheader.png")
      
//	      http:Get("drei-f.de")                                                                    
/*
	http:Request:Accept := HttpContentTypes.ApplicationJson
	VAR response := http.Get("url")
	VAR customer := response.StaticBody<Customer>()
	Console.WriteLine("Name: {0}", customer.Name)                 */
RETURN
The two dlls are attached (@Robert: you might consider allowing 7z-ending, packs are about 25% smaller...)
Attachments
easyhttp_vb.zip
(814 Bytes) Downloaded 57 times
EasyHttp.zip
(112.49 KiB) Downloaded 68 times
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
User avatar
Chris
Posts: 4899
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Strange error 0118 in comment <sic> & differences XIDE vs VS

Post by Chris »

Hi Karl,

Unfortunately I can't reproduce the problem, this code compiles ok here and executes as expected (printing Hello x#), so can you please zip your project and send it to have a look? Maybe there's something going wrong with the way references are added or something else that doesn't come to mind without seeing the actual project.

As for incorrect entity lines in the VB code, yes I see that, too, indeed the VB net code confuses the parser which expects x# code and incorrectly thinks the METHOD identifiers mark a METHOD entity.

Chris
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
FFF
Posts: 1580
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

Strange error 0118 in comment <sic> & differences XIDE vs VS

Post by FFF »

Sigh... AEF is attached.

THX
Karl
Attachments
EasyHttp_aef.zip
(1.4 KiB) Downloaded 57 times
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
User avatar
Chris
Posts: 4899
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Strange error 0118 in comment <sic> & differences XIDE vs VS

Post by Chris »

Hi Karl,

Thanks, that helped, the problem happens because the assembly name of your exe (EasyHttp.exe) is the same with the assmebly name of the dll EasyHttp.dll and the .Net loader fails to open it. You will get the same error also with c# or vulcan.

So just change the assembly name of your .exe to something slightly different and it will work!

hth,
Chris
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
FFF
Posts: 1580
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

Strange error 0118 in comment <sic> & differences XIDE vs VS

Post by FFF »

Chris,
indeed, that did the trick - and on a closer look, i had renamed the App for VS to EasyHttp2 ;)
So much for identical naming of different things...

Now i can proceed trying to find my way in a website with login, open subpage & retrieve some data.

THX!
Karl
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
Post Reply