pamidur / aspect-injector

AOP framework for .NET (c#, vb, etc)
Apache License 2.0
745 stars 112 forks source link

How about implements ConfigureAwait and Lazy? #152

Closed jerviscui closed 3 years ago

jerviscui commented 3 years ago

I've tried Fody add-in:

I think it is useful. How about implements that? I think requires core level support it?

pamidur commented 3 years ago

We are talking about Lazy in separate PR.

As to ConfigureAwait - these things require instruction-level injection which isn't available for user code using aspect-injector now. I'd love to have this support, but we need to figure a way for it to work in user-code. Remember for aspect-injector "if aspect compiles - it works" is a must unlike fody plugins.

So if you could come up with how to make instruction-level injection safe in user-code, that would make a big difference !

ps. only thing I can think about is something like special method in an aspect that describe this:

injector.WhereMethodCall<Task,TaskAwaiter>(t=>t.GetAwaiter()).SubstituteWith(t=>t.ConfigureAwait(false).GetAwaiter())

then we'll need to figure how to read this from an aspect properly and apply to target method, not forgetting about type safety :)

quite an interesting task, PRs are welcome! :)