9

I've not used PostSharp in a number of years, but have often used the following pattern to get around life-cycle issues with DI on attributes. It's a little manual, so should be seen as the exception rather than the rule, but it's easy to follow. In your aspect, define a static factory method specifically designed to create your dependency . Define it as a ...


4

The logic feels like it's overly complex. I'm especially unhappy with the need for three booleans. Yeah, I agree that especially the logic around _invokeNext is messy, but I think that's required due to the way Proceed() behaves (the invocation is intercepted again if it's not currently being intercepted). But in cases like these, it's important to document ...


3

Use StringBuilder instead of StringBuffer since the latter is synchronized and you're not sharing the instances in a multi-threading manner. So use of StringBuilder would be a bit faster. Narrow down the scope of retVal. Generally speaking, your variables should be as close to the use places as possible. Note that you can move the retVal declaration and the ...


1

Pythonic, readable and convenient are all subjective and open to debate, even though "Pythonic" is less so than the others. That said, a simplified version may be illustrative. Comparing @foo @bar def baz(value: T) -> T: return value to def baz(value: T) -> FooT: return foo(bar(value)) there are two issues with the former: The final ...


1

I know little about AspectJ, but have a number of more basic points to call out in your code. Hygiene cachedLoggers should be private static final and not public static. Do you really want anyone to be able to replace your instance? PluggableLogger pluggableLogger is an instance field, but it should be in the method only (perhaps just called logger). As ...


Only top voted, non community-wiki answers of a minimum length are eligible