Page 1 of 1

malformed guids from Guid.Parse (v1.x only)

Posted: Fri Jul 19, 2019 8:06 am
by TaterJuice
This does not happen in simulator, it only happens in the JS output.

Since Guid.TryParse isn't supported yet, I usually just wrap the Guid parse in a try/catch block

Code: Select all

Guid guid = Guid.Empty;
var success = false;
try {
   guid = Guid.Parse(someValue);
   success = true;
} catch { }
if (success) {
   //do something with guid
}


BUT, in the JS output, sometimes with an empty or null string, Guid.Parse is successful and gives me a malformed Guid:

Code: Select all

00000NaN-0NaN-0NaN-NaNNaN-NaNNaNNaNNaNNaNNaN


so now, I have to do this:

Code: Select all

Guid guid = Guid.Empty;
var success = false;
try {
   guid = Guid.Parse(someValue);
   if(!guid.ToString().Contains("NaN"))
      success = true;
} catch { }
if (success) {
   //do something with guid
}

Re: malformed guids from Guid.Parse

Posted: Tue Jul 23, 2019 4:22 am
by JS-Support @Userware
Hi,

Thanks for your message.

The code for Guid parsing is totally different in CSHTML5 v2.x and should work properly.

We are adding what you reported to our backlog and see if we fix it in v1.x or if we skip it because it works in v2.x and you have a workaround for v1.x.