Bug 38992

Summary: error CS1009: Unrecognized escape sequence '\_' in $@ String
Product: [Mono] Compilers Reporter: jeffp1618
Component: C#Assignee: Marek Safar <masafa>
Status: RESOLVED FIXED    
Severity: normal CC: mono-bugs+mono
Priority: ---    
Version: 4.0.0   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Tags: Is this bug a regression?: ---
Last known good build:
Attachments: Simple example of compilation failure

Description jeffp1618 2016-02-22 15:54:17 UTC
Created attachment 15126 [details]
Simple example of compilation failure

When compiling the following simple code (also attached as BugReport.cs)

using System;
class BugReport
{
	public static void Main(string[] args)
	{
		var timespan = new TimeSpan();
		Console.WriteLine($@"{timespan:mm\_ss\_fff}");
	}
}

with mcs BugReport.cs it reports the following error message:

error CS1009: Unrecognized escape sequence '\_'


If I try and run this on Microsoft .NET it compiles successfully and when the exe is run it outputs:
00_00_000
Comment 1 jeffp1618 2016-02-22 15:55:50 UTC
Compiler version:
Mono C# compiler version 4.2.2.0
Comment 2 Marek Safar 2016-02-23 21:52:49 UTC
Fixed in master and mono 4.4