Adding missing function

CyborgDE
Posts: 75
Joined: Wed Aug 12, 2015 9:21 pm

Adding missing function

Postby CyborgDE » Wed Aug 12, 2015 9:38 pm

Hello,

I have start testing CSHtml5, it looks good. But I have with a small test about 100 errors with unsupported functions.

How can I implement missing functions ?

For example, the is the function DateTime.AddDays implemented but not DateTime.AddHours. Normaly I can implement AddHours in c# code like:

Code: Select all

public static DateTime AddHours(double hours) {
   return DateTime.AddDays(hours / 24);
}


or to implement a SortedList is code ...
or Dictionary.ContainsKey ...

Thank you.

Best regards
Uwe

JS-Support @Userware
Site Admin
Posts: 1142
Joined: Tue Apr 08, 2014 3:42 pm

Re: Adding missing function

Postby JS-Support @Userware » Thu Aug 13, 2015 4:04 am

Hello,

Thanks for your message and welcome to the forums.

At the moment you can only create workarounds like the static function that you mentioned, and change the calling code to call that function instead.

In a few months (late 2015 or early 2016) we are going to open up development so that anyone can implement new features. Please stay tuned for updates.

In late 2016 we hope to have a new compiler that will allow to have full support to the full Mscorlib.

Thanks,
Regards,
JS-Support

CyborgDE
Posts: 75
Joined: Wed Aug 12, 2015 9:21 pm

Re: Adding missing function

Postby CyborgDE » Thu Aug 13, 2015 5:49 am

Hello,

thank you.

Is the compiler not able to find a function in a assembly ?
Is this not a basic feature ?

Is there no small workaround ?

I have too many error's not implemented error, especially in currently implemented classes like "Hashtable.Contains" or "ArrayList.Remove" ...

Thank you.

Best regards
Uwe

JS-Support @Userware
Site Admin
Posts: 1142
Joined: Tue Apr 08, 2014 3:42 pm

Re: Adding missing function

Postby JS-Support @Userware » Thu Aug 13, 2015 6:53 am

Hi Uwe,

Here is what you can do with the current Beta 4 to implement missing .NET Mscorlib features:

1) Modify your ".CSPROJ" file and add the following line:

Code: Select all

<IgnoreUnsupportedMethodsErrors>True</IgnoreUnsupportedMethodsErrors>

This will stop the compiler from complaining about non-implemented methods. instead, you will receive errors during runtime about non-implemented methods.


2) Go to the folder "C:\Program Files (x86)\MSBuild\CSharpXamlForHtml5\InternalStuff\Libraries"

(if this folder does not exist on your computer, go to: "C:\Program Files\MSBuild\CSharpXamlForHtml5\InternalStuff\Libraries")

There you will see a lot of JavaScript files. The files which name starts with "JSIL.Bootstrap.*" are the files that implement the features of Mscorlib. For example, "ArrayList" is implemented in "JSIL.Bootstrap.js". The "Hashtable" class must be implemented there.

Implement the missing functions, and then recompile your project. (Or, if you want to go faster, directly modify the JS files from the "Output/Libraries" folder of your project so that you do not need to recompile your project every time, but remember to backup the changes somewhere else otherwise you may loose your changes when the project is recompiled and the "Output" folder is re-generated).


Please note that implementing new features at the moment is a little difficult because you need to master the aforementioned JavaScript files. In the future we are going to make it easier to add new features, and we will document it better.

Thanks,
Regards,
JS-Support

CyborgDE
Posts: 75
Joined: Wed Aug 12, 2015 9:21 pm

Re: Adding missing function

Postby CyborgDE » Thu Aug 13, 2015 7:36 am

Hello,

thank you for your fast reply.

Can I also implement missing function also in c#, and JSIL convert this into JScript ?

Best regards,
Uwe

JS-Support @Userware
Site Admin
Posts: 1142
Joined: Tue Apr 08, 2014 3:42 pm

Re: Adding missing function

Postby JS-Support @Userware » Thu Aug 13, 2015 8:22 am

Hello,

Not directly, but you can implement the missing function in C# using an empty CSHTML5 project, then look at the generated JS code (in the "Output" directory), and then copy/paste that generated code into the JS libraries. You will need to modify the methods signature to match the style of the JS libraries, but most of the body of the functions can be used "as is".

Regards,
JS-Support


Return to “General Discussion and Other”

Who is online

Users browsing this forum: No registered users and 26 guests

 

 

cron