-
-
Save daveneeley/1603849 to your computer and use it in GitHub Desktop.
Repro for StackOverflow #8609110
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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