Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

EPiServer.Data.dll -> Identity.TryParse method doesn't prevent a crash whilst we expect it to

Vote:
 

Hello, 

We expect any TryParse to prevent a crash under the application, since .NET uses this standard for all other functions, like int.TryParse or Guid.TryParse. To our surprise, Identity.TryParse does not and uses a try / catch clause, which defeats the purpose of TryParse: 

Could Optimizely's team look at that please? 

Thank you! 

#272475
Feb 18, 2022 14:10
Vote:
 

I'm not sure what you meant but Guid.TryParse for example has the internal try/catch. The premise of TryPrase is to not throw exception (instead just return false), and I think Identity.TryParse does just that. Did I miss something 

#272479
Feb 18, 2022 14:22
Vote:
 

Hello Quan, 

You're right, though my comment remains the same. When you look under the source code of .NET regarding the TryParse method of Guid, you see that there's a lot being done before going under a try / catch clause, suggesting that Microsoft found it might be possible this part could crash under certain scenarios. 

My point is, under Identity.TryParse, there's clearly a way for Optimizely to parse the string without even try catching at all. So, instead of calling "new Identity(string)", the TryParse method could do the following instead: 

Hopes it helps understand my concern. 

Thank you!

#272483
Feb 18, 2022 14:57
Vote:
 

the part you mentioned is actually done in new Identity(string) (there is a try catch throw there). so IMO it's good enough. Yes there could be some improvements but nothing major 

#272484
Feb 18, 2022 15:03
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.