Skip to content

Instantly share code, notes, and snippets.

@daveneeley
Forked from Porges/gist:1603793
Created January 12, 2012 23:44
Show Gist options
  • Save daveneeley/1603849 to your computer and use it in GitHub Desktop.
Save daveneeley/1603849 to your computer and use it in GitHub Desktop.
Repro for StackOverflow #8609110
using System;
using System.ComponentModel;
using System.Diagnostics.Contracts;
using System.Linq.Expressions;
namespace ConsoleApplication
{
class MyViewModel<T> : INotifyPropertyChanged
{
/// <summary>
/// Get / Set the actual value of the property
/// </summary>
public T Value
{
get;
set;
}
public event PropertyChangedEventHandler PropertyChanged;
}
public class Program
{
public static void Main()
{
var myObserver = new PropertyObserver<MyViewModel<bool>>();
//this line throws the error, within the n => n.Value expression
myObserver.RegisterHandler(n => n.Value);
}
}
public class PropertyObserver<TPropertySource> where TPropertySource : INotifyPropertyChanged
{
public PropertyObserver<TPropertySource> RegisterHandler(Expression<Func<TPropertySource, object>> expression)
{
//what this does is irrelevant; the violation occurs in the method call
throw new NotImplementedException();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment