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

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: 143
Joined: Thu Mar 16, 2017 5:40 am
Contact:

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

Postby TaterJuice » Fri Jul 19, 2019 8:06 am

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
}

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

Re: malformed guids from Guid.Parse

Postby JS-Support @Userware » Tue Jul 23, 2019 4:22 am

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.


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 2 guests

 

 

cron