Skip to content

Instantly share code, notes, and snippets.

@tumtumtum
Last active August 29, 2015 14:07
Show Gist options
  • Save tumtumtum/7be3954fa404988806d3 to your computer and use it in GitHub Desktop.
Save tumtumtum/7be3954fa404988806d3 to your computer and use it in GitHub Desktop.
Visual Studio 2013 bug with calling generic virtual methods after hitting a breakpoint
using System;
namespace ConsoleApplication1
{
public class Foo<T>
{
public virtual T GetBar<K>(K foo, T value)
{
return value;
}
}
class Program
{
static void Main(string[] args)
{
var foo = new Foo<string>();
// Place a break point on this line and then stepinto it once the breakpoint is set
// GetBar never gets called and the return value is null
var bar = foo.GetBar(new Guid(), "hello");
Console.WriteLine(bar);
if (bar != "hello")
{
throw new ApplicationException("Ouch");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment