Bugs - DateTime.Parse, undefined js objects, ToString(format), Decimal types, etc

Please report bugs here. If you are unsure whether something is a bug or an expected behavior, please post it on the "Technical Support" forum instead, and wait for a moderator to handle/move the post.
TaterJuice
Posts: 147
Joined: Thu Mar 16, 2017 5:40 am
Contact:

Bugs - DateTime.Parse, undefined js objects, ToString(format), Decimal types, etc

Postby TaterJuice » Sat Apr 07, 2018 2:28 pm

Could you please take a look at the following issues?

DateTime.Parse(string) outputs WRONG VALUE in browser - Parse() assumes all values are Universal\GMT.

Cause:

Code: Select all

DateTime.Parse("2018-01-01"); // Returns  '12-31-2017 16:00:00' in browser!

In Simulator: Works as expected: Returns a DateTime object of '01-01-2018'
In Browser: Returns GMT Offset DateTime, ie in Pacific TimeZone it returns '12-31-2017 16:00:00'
Workaround: NONE (Must manually parse the DateTime string, or manually adjust based on current TZO) - Breaks Shared Project code!

----------------------------------------------------

The external method 'System.Boolean Equals(System.DateTime)' of type 'System.DateTime' has not been implemented.

Cause:

Code: Select all

var today = DateTime.Now;
var isToday = today.Equals(today); // ERROR

In Simulator: Works as expected
In Browser: Returns undefined object, causes NullReferenceException in consuming code! (Console displays the above warning) - Breaks Shared Project code!
Workaround: use '=='

Code: Select all

var today = DateTime.Now;
var isToday = today == today;


----------------------------------------------------

The external method 'System.Boolean Equals(System.TimeSpan)' of type 'System.TimeSpan' has not been implemented.

Cause:

Code: Select all

DateTime.Now.TimeOfDay.Equals(DateTime.Now.TimeOfDay);

In Simulator: Works as expected
In Browser: Returns undefined object, causes NullReferenceException in consuming code! (Console displays the above warning) - Breaks Shared Project code!
Workaround: NONE (using '==' has the same effect as using Equals())

----------------------------------------------------

The external method 'System.String ToString(System.String)' of type 'System.DateTime' has not been implemented.

Cause:

Code: Select all

DateTime.Now.ToString("MM/dd/yyyy");

In Simulator: Works as expected
In Browser: Returns undefined object, causes NullReferenceException in consuming code! (Console displays the above warning) - Breaks Shared Project code!
Workaround: Manually Format DateTime parts

Code: Select all

var now = DateTime.Now;
return String.Format("{0}/{1}/{2}", now.Month, now.Day, now.Year);


----------------------------------------------------

The external method 'System.String ToString(System.String)' of type 'System.TimeSpan' has not been implemented.

Cause:

Code: Select all

DateTime.Now.TimeOfDay.ToString("c");
DateTime.Now.TimeOfDay.ToString("g");
DateTime.Now.TimeOfDay.ToString("G");

In Simulator: Works as expected
In Browser: Returns undefined object, causes NullReferenceException in consuming code! (Console displays the above warning) - Breaks Shared Project code!
Workaround: Manually Format TimeSpan parts, or just using timeSpan.ToString(). which is the equivilant of timeSpan.ToString("c");

Code: Select all

var now = DateTime.Now.TimeOfDay;
var timeStr = String.Format("{0}:{1}:{2}.{3}", now.Hours, now.Minutes, now.Seconds, now.Milliseconds);


----------------------------------------------------
Multiple issues with Decimal types
----------------------------------------------------

Uncaught Error: No overload of .ctor can accept 5 argument(s).
at Object.JSIL.RuntimeError (JSIL.Core.js:10531)
at System_Decimal__ctor [as _ctor] (jsil://closure/System.Decimal..ctor:12)
at new System_Decimal__ctor (jsil://closure/System.Decimal._ctor:7)
at JSIL.ConstructorSignature.ConstructorSignature_Construct$5 [as Construct] (jsil://closure/ConstructorSignature.Construct$5:6)

Cause:

Code: Select all

Decimal decimalValue = 100.0m;

In Simulator: Works as expected
In Browser: FATAL ERROR
Workaround: NONE - must use double or float

----------------------------------------------------

The external method 'System.Decimal ToDecimal(System.Object)' of type 'System.Convert' has not been implemented.

Cause:

Code: Select all

double value = 10.0;
Decimal decimalValue = Convert.ToDecimal(value);

In Simulator: Works as expected
In Browser: Returns undefined object, causes NullReferenceException in consuming code! (Console displays the above warning)
Workaround: NONE - must use double or float

----------------------------------------------------

The method "Decimal.op_Division" is not yet supported.

Code: Select all

Decimal decimalValue = 100.0m;
var result = decimalValue / 10;


----------------------------------------------------
Use Cases
I am working in a Universal App using CSHTML5 and Xamarin.Forms, where all my ViewModels\Presenters, Models\Converters and Repositories are in a Shared Project that is consumed by a CSHTML5 assembly and a Xamarin.Forms assembly. These issues have caused me to move Core Business logic out of my shared project and into platform-specific projects, causing a lot of fragmentation and many rewrites just to use types that consume decimals and parse DateTimes.

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

Re: Bugs - DateTime.Parse, undefined js objects, ToString(format), Decimal types, etc

Postby JS-Support @Userware » Mon Apr 09, 2018 1:19 am

Hi,
Thanks for your message.
We have good news: we have made a PoC for a new version of CSHTML5 (v2.0) that will be fully compatible with .NET Standard so all those issues are going to be fixed soon.
We will keep you updated asap.
Thanks.
Regards,
JS-Support

wilson
Posts: 3
Joined: Sat May 06, 2017 10:08 pm

Re: Bugs - DateTime.Parse, undefined js objects, ToString(format), Decimal types, etc

Postby wilson » Sun Jul 15, 2018 8:55 pm

Dear JS Support,
can you give any estimate (Roadmap, deadline, etc), when it will be cstml5 fully compatible with the .NET standard?


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 32 guests