RyuJit producing incorrect results

Thank you for the isolated repro program and I can confirm that this is indeed a RyuJIT bug in the optimizer which got exposed due to inlining. I’ve made a fix to the compiler and figuring the roll out details. Not to turn SO into a bug tracker, and for a quicker turnaround: ryujit@microsoft.com.

ReSharper highlights use of nameof with “Explicit argument passed to parameter with caller info attribute”

was just wondering if the above warning is something I should worry about. When you have CallerMemberName attribute attached, you don’t have to explicitly pass a value, because the attribute will do exactly that for you. It will find the caller’s name and use it, making your nameof declaration redundant. This is of course assuming … Read more

What is the optional argument in C# interpolated string for?

It’s the minimum width to use for that field, not the maximum. Since your string is longer than the 5 characters you specify for the width, the field is extended to the length of your string. You’ll see the difference more dramatically with a longer width: var p = Process.GetCurrentProcess(); $”Process name is {p.ProcessName, 50}”.Dump(); … Read more

String Interpolation with format variable

No, you can’t use string interpolation with something other than a string literal as the compiler creates a “regular” format string even when you use string interpolation. Because this: string name = “bar”; string result = $”{name}”; is compiled into this: string name = “bar”; string result = string.Format(“{0}”, name); the string in runtime must … Read more

C# 6.0 Support in Visual Studio 2012

Yes, you can install c# 6.0 into VS2012 and VS2013 on a per project basis as a NuGet package. You’ll have to install this package for every project that you want c# 6.0 features in. https://www.nuget.org/packages/Microsoft.Net.Compilers/ Installing Latest C# Compiler via Nuget Install-Package Microsoft.Net.Compilers EDIT: As pointed out in the comments below, upgrade your NuGet … Read more

String interpolation issues

The problem with this line Assert.AreEqual(formatted, $”{{countdown|{date:o}}}”); is that you have 3 curly quotes after the format string of the variable to be escaped and it starts escaping from left to right, therefore it treats the first 2 curly quotes as part of the format string and the third curly quote as the closing one. … Read more

tech