Bug 19915

Summary: new Guid("{ 0x00000001, 0x0002, ..."); throws FormatException due to whitespace
Product: [Mono] Class Libraries Reporter: Jason Stangroome <xamarinbugs>
Component: mscorlibAssignee: Marek Safar <masafa>
Status: RESOLVED FIXED    
Severity: normal CC: masafa, mono-bugs+mono
Priority: ---    
Version: 3.2.x   
Target Milestone: Untriaged   
Hardware: PC   
OS: Linux   
Tags: Is this bug a regression?: ---
Last known good build:

Description Jason Stangroome 2014-05-20 06:02:32 UTC
On Microsoft .NET 4.5 (and possibly earlier), this line successfully parses the guid from the string literal:

new Guid("{ 0x00000001, 0x0002, 0x0003, { 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b }}");

Or, as an NUnit assert:

Assert.AreEqual(
    new Guid("{ 0x00000001, 0x0002, 0x0003, { 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b }}").ToString(),
    "00000001-0002-0003-0405-060708090a0b"
);

However, on Mono 3.2.8+dfsg on Ubuntu 14.04 LTS, a System.FormatException is thrown by the Guid constructor.

However, this variation passes on Mono:

Assert.AreEqual(
    new Guid("{ 0x00000001, 0x0002, 0x0003, { 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b }}".Replace(" ", "")).ToString(),
    "00000001-0002-0003-0405-060708090a0b"
);

That is, removing white space from the literal first enabled Mono to parse the string as a Guid. The original .NET framework can handle white space though.
Comment 1 Marek Safar 2014-05-20 10:39:15 UTC
Fixed in master