Click here to Skip to main content
15,893,663 members
Home / Discussions / C#
   

C#

 
QuestionWhere am I send a request about C# new language feature Pin
Higty25-Mar-14 21:52
Higty25-Mar-14 21:52 
AnswerRe: Where am I send a request about C# new language feature Pin
Chris Quinn25-Mar-14 22:05
Chris Quinn25-Mar-14 22:05 
GeneralRe: Where am I send a request about C# new language feature Pin
Higty25-Mar-14 22:50
Higty25-Mar-14 22:50 
AnswerRe: Where am I send a request about C# new language feature Pin
Nicholas Marty25-Mar-14 23:34
professionalNicholas Marty25-Mar-14 23:34 
GeneralRe: Where am I send a request about C# new language feature Pin
Higty26-Mar-14 18:04
Higty26-Mar-14 18:04 
AnswerRe: Where am I send a request about C# new language feature Pin
jschell26-Mar-14 11:57
jschell26-Mar-14 11:57 
GeneralRe: Where am I send a request about C# new language feature Pin
Higty26-Mar-14 21:01
Higty26-Mar-14 21:01 
GeneralRe: Where am I send a request about C# new language feature Pin
Pete O'Hanlon26-Mar-14 21:26
mvePete O'Hanlon26-Mar-14 21:26 
GeneralRe: Where am I send a request about C# new language feature Pin
Higty26-Mar-14 22:42
Higty26-Mar-14 22:42 
GeneralRe: Where am I send a request about C# new language feature Pin
Pete O'Hanlon26-Mar-14 23:17
mvePete O'Hanlon26-Mar-14 23:17 
GeneralRe: Where am I send a request about C# new language feature Pin
Higty27-Mar-14 13:59
Higty27-Mar-14 13:59 
GeneralRe: Where am I send a request about C# new language feature Pin
Pete O'Hanlon27-Mar-14 14:21
mvePete O'Hanlon27-Mar-14 14:21 
GeneralRe: Where am I send a request about C# new language feature Pin
Higty27-Mar-14 14:57
Higty27-Mar-14 14:57 
GeneralRe: Where am I send a request about C# new language feature Pin
Pete O'Hanlon27-Mar-14 15:07
mvePete O'Hanlon27-Mar-14 15:07 
GeneralRe: Where am I send a request about C# new language feature Pin
Higty27-Mar-14 16:00
Higty27-Mar-14 16:00 
GeneralRe: Where am I send a request about C# new language feature Pin
Pete O'Hanlon27-Mar-14 21:20
mvePete O'Hanlon27-Mar-14 21:20 
GeneralRe: Where am I send a request about C# new language feature Pin
Higty30-Mar-14 13:47
Higty30-Mar-14 13:47 
GeneralRe: Where am I send a request about C# new language feature Pin
Pete O'Hanlon30-Mar-14 20:22
mvePete O'Hanlon30-Mar-14 20:22 
GeneralRe: Where am I send a request about C# new language feature Pin
Higty30-Mar-14 21:31
Higty30-Mar-14 21:31 
GeneralRe: Where am I send a request about C# new language feature Pin
Pete O'Hanlon30-Mar-14 22:38
mvePete O'Hanlon30-Mar-14 22:38 
GeneralRe: Where am I send a request about C# new language feature Pin
Higty30-Mar-14 23:46
Higty30-Mar-14 23:46 
GeneralRe: Where am I send a request about C# new language feature Pin
BobJanova27-Mar-14 6:36
BobJanova27-Mar-14 6:36 
Code snippets and other IDE magic are working around language deficiencies, and are generally 'write helpers' rather than things that help a reader or modifier of the code (i.e. 90% of interactions with the code).

I do feel that there's a missing language feature in this area but I'm not sure it's quite been nailed here. What would solve the INPC and validation scenarios would be

class SomeClass : INotifyPropertyChanged {
 public int Value { get; set; beforeset ValidateValue; afterset Notify; }
 public string Description { get; set; afterset Notify; }

 private int ValidateValue(string property, int value) { ... }
 private void Notify<T>(string property, T value) {
  // usual stuff here
 }
}


'beforeset' and 'afterset' would take a method reference or a lambda matching Func<string, T, T> and Action<string, T> respectively where T is the property type, so beforeset methods can update the value if needed, and both methods get given the property name if they want to use it for data binding, INPC notifications or error messages.

The compiler could insert the relevant calls into the auto-generated property method very easily.
GeneralRe: Where am I send a request about C# new language feature Pin
Matt T Heffron27-Mar-14 7:21
professionalMatt T Heffron27-Mar-14 7:21 
GeneralRe: Where am I send a request about C# new language feature Pin
Pete O'Hanlon27-Mar-14 11:26
mvePete O'Hanlon27-Mar-14 11:26 
GeneralRe: Where am I send a request about C# new language feature Pin
BobJanova28-Mar-14 0:31
BobJanova28-Mar-14 0:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.