Click here to Skip to main content
15,900,725 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Interest in tip? Pin
dandy7224-Dec-19 16:33
dandy7224-Dec-19 16:33 
GeneralRe: Interest in tip? Pin
Nelek25-Dec-19 6:41
protectorNelek25-Dec-19 6:41 
GeneralRe: Interest in tip? Pin
dandy7227-Dec-19 3:03
dandy7227-Dec-19 3:03 
GeneralRe: Interest in tip? Pin
Cp-Coder24-Dec-19 7:50
Cp-Coder24-Dec-19 7:50 
GeneralRe: Interest in tip? Pin
OriginalGriff24-Dec-19 7:48
mveOriginalGriff24-Dec-19 7:48 
GeneralRe: Interest in tip? Pin
dandy7224-Dec-19 16:32
dandy7224-Dec-19 16:32 
GeneralRe: Interest in tip? Follow up... Pin
dandy7227-Dec-19 3:06
dandy7227-Dec-19 3:06 
GeneralBecause of Roslyn Pin
honey the codewitch24-Dec-19 5:36
mvahoney the codewitch24-Dec-19 5:36 
It should now be possible (though it's not implemented) to use lambda expressions in static initializers that get the compiler to do work.

Basically, you should be able to declare delegates as fields on classes like System.Attribute.

Then you could do something like

C#
[CrossCut(Before:(callContext)=> { Debug.WriteLine("Member "+callContext.Name+" calling on employee"); }), After:(callContext)=>{Debug.WriteLine("Member "+callContext.Name+" called on employee");})]
class EmployeeEntity {
   public string Name {get; set; }
   public string Title {get; set; }
   public string Address {get; set; }
}


To add method logging to all your calls. Just as an example.

There is no reason, that with Roslyn this can't be done. The only reason I can think of why it *shouldn't* be done is it could potentially allow DoS attacks against Roslyn's compiler service by hanging the compiler running one of the lambdas in an infinite loop, but Roslyn also *should* be able to handle that.

Edit: I know you can use the .NET COM+ wrapper to do this with "context objects" or whatever they're called, but that's COM+ and it's ugly
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.

GeneralI stand corrected Pin
Richard MacCutchan24-Dec-19 1:21
mveRichard MacCutchan24-Dec-19 1:21 
GeneralRe: I stand corrected Pin
Cp-Coder24-Dec-19 2:08
Cp-Coder24-Dec-19 2:08 
GeneralRe: I stand corrected Pin
Slacker00724-Dec-19 2:25
professionalSlacker00724-Dec-19 2:25 
GeneralRe: I stand corrected Pin
Mike Hankey24-Dec-19 3:49
mveMike Hankey24-Dec-19 3:49 
GeneralRe: I stand corrected Pin
DRHuff24-Dec-19 4:16
DRHuff24-Dec-19 4:16 
GeneralRe: I stand corrected Pin
Slow Eddie24-Dec-19 4:45
professionalSlow Eddie24-Dec-19 4:45 
GeneralRe: I stand corrected Pin
Ravi Bhavnani24-Dec-19 12:09
professionalRavi Bhavnani24-Dec-19 12:09 
GeneralRe: I stand corrected Pin
Slow Eddie25-Dec-19 3:00
professionalSlow Eddie25-Dec-19 3:00 
GeneralRe: I stand corrected Pin
Ravi Bhavnani25-Dec-19 5:36
professionalRavi Bhavnani25-Dec-19 5:36 
GeneralRe: I stand corrected Pin
Ravi Bhavnani24-Dec-19 12:08
professionalRavi Bhavnani24-Dec-19 12:08 
Generalyou gotta think outside the ice-box: why i love science Pin
BillWoodruff24-Dec-19 0:53
professionalBillWoodruff24-Dec-19 0:53 
GeneralRe: you gotta think outside the ice-box: why i love science Pin
OriginalGriff24-Dec-19 0:56
mveOriginalGriff24-Dec-19 0:56 
GeneralRe: you gotta think outside the ice-box: why i love science Pin
Mike Hankey24-Dec-19 1:19
mveMike Hankey24-Dec-19 1:19 
GeneralBehold! Pin
Super Lloyd23-Dec-19 23:35
Super Lloyd23-Dec-19 23:35 
GeneralRe: Behold! Pin
Richard MacCutchan23-Dec-19 23:44
mveRichard MacCutchan23-Dec-19 23:44 
GeneralRe: Behold! Pin
Super Lloyd24-Dec-19 0:00
Super Lloyd24-Dec-19 0:00 
GeneralRe: Behold! Pin
Richard MacCutchan24-Dec-19 0:47
mveRichard MacCutchan24-Dec-19 0:47 

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.


Straw Poll

Were you affected by the geomagnetic storms this past weekend?
Communication disruptions, electrified pipes, random unexplained blue-screens in Windows - the list of effects is terrifying.
  Results   494 votes