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.