Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Because of Roslyn

Because of Roslyn

Scheduled Pinned Locked Moved The Lounge
csharplinqcomdebuggingfunctional
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    honey the codewitch
    wrote on last edited by
    #1

    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

    [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.

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups