postsharp

Which Tools Perform Post-Compile Modification of IL?

A recent mention of PostSharp reminded me of this: Last year where I worked, we were thinking of using PostSharp to inject instrumentation into our code. This was in a Team Foundation Server Team Build / Continuous Integration environment. Thinking about it, I got a nagging feeling about the way PostSharp operates - it edits the IL tha...

PostSharp OnExceptionAspect not working as expected

Created a simple class to test out the OnExceptionAspect in PostSharp. [Serializable] [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)] public class ExceptionSwallower : OnExceptionAspect { public override void OnException(MethodExecutionEventArgs eventArgs) { eventArgs.FlowBehavior = FlowBehavior.Retur...

Error using PostSharp: "PostSharp.AssertionFailedException: Invalid image"

I'm looking into PostSharp as a means to bring logging into my team's projects. I'm running into an error when I try to create a sample aspect. I have some room to debug it, but I'd like to get some thoughts on where I might look. I installed PostSharp, and when I first reference the PS dlls from my project, I get this exception on bu...

Postsharp: how does it work?

Following the advice got on another question of mine, I converted the code there quoted to be used with PostSharp: Attribute: [Serializable] public sealed class InitAttribute : OnMethodBoundaryAspect { public override void OnEntry(MethodExecutionEventArgs eventArgs) { Console.Write("Works!"); } } static class Logg...

Running unit tests from within VS2008 vs using mstest on the command line.

Dear ladies and sirs. I have recently encountered some inconsistencies in running unit tests inside VS2008 vs running the same unit tests with mstest on the command line. My scenario is a bit advanced, so I have probably hit some corners. I have many data driven unit tests running against the same DataSource. I also like experimenting ...

Does MethodBase provide file name and line number?

I'm trying to write a CompileTimeValidate(MethodBase method) for postsharp. the problem is when a violation occurs it only shows Description in the Error List. The 'File' and 'Line' columns are empty. The only info that I get to work with is a MethodBase instance of the method that the attribute was applied to. is there a way to get th...

Looking for good tutorials / documents for Postsharp laos, understanding of "Librarian" samples.

Hi, Can anyone point me to good learning material on PostSharp / laos plugin. I liked the "Librarian" sample shipped with Postsharp, it does cover lots of stuff, but is difficult to understand. Is there any explanation / writeup on samples too? Thanks & Regards, Ajay ...

Postsharp : is it good for my requirements.

I am considering PostSharp (www.postsharp.org) at this time to write my own custom logging system (sitting on top of log4net) as part of my application. Do you think PostSharp qualifies in all these requirements? This are my requirements: I want to be able to write custom "Aspects" that work on methods, properties, fields, class and a...

Postsharp and NLog, general design question

Hi, This is what i intend to do: I want to write a Aspect oriented NLog specific onmethodexecutionaspect class. But i still want to ensure that the calling code is attributed using a general attribute class which will internally load the NLog or TraceX etc specific implementation of methodexecutionaspect depending on what is specified...

Using PostSharp to retry method on Exception

Hi, For one of my DAL modules I have lots of duplicated plumbing in the shape of: while (retry) { ... try { ...do something retry = false; } catch (SqlException sqlEx) { // Retry only if -2 = Connection Time Out or 1205 = Deadlock if (sqlEx.Number == -2 || sqlEx.Number == 1205) { ..retry if attempt < max } .....

OnExit is not entering via PostSharp in asp.net project.

Hi there, I have setup PostSharp and it appears to be working but i don't get it entering OnExit (i have logged setup to ensure it is working) ... Its a bit tricky to configure with asp.net - or is it just me ... I am using the 1.5 new version I basically have the following in my web.config and i had to add the SearchPath otherwise it...

Any experience of using PostSharp with ReSharper

Has anyone used PostSharp with ReSharper, if so what problems should I expect? ...

Mono Cecil vs. PostSharp Core vs. Microsoft CCI for implementing AOP framework

Which is the better in terms of capabilities, easy of use, documentation, samples, community/support, VS integration, known implementations, long-term viability, and build speed to implement a custom AOP framework? I'll start with what I know (I have only tried PostSharp to so far): Microsoft Common Compiler Instrastruture (CCI): I've...

PostSharp and debugging problems?

I've made a very simple aspect, and found a problem when debugging it (see code). I set a breakpoint on the method exit, and it hits inside "entry" method actually. PostSharp 1.5, Visual Studio 2008 SP1 Is this a known bug, are there any workarounds? class Program { [MyAspect] static void Main(string[] args) { Console.WriteLine("bo...

PostSharp: OnMethodBoundaryAspect doesn't get called

Hi I'm using PostSharp to apply a CompoundAspect to a ActiveRecord class (from CastleProject). The code looks like this: public override void ProvideAspects(object targetElement, LaosReflectionAspectCollection collection) { Type targetType = (Type)targetElement; RevertibleSubAspect revertible = new RevertibleSubAspect(); re...

Adding aspect to an abstract method?

PostSharp gives this error: PostSharp: Cannot apply an OnMethodInvocation aspect (...) with target-site weaving on the abstract or external method "...". Consider excluding the aspect from this method or use call-site weaving. Suggested call-site weaving is not an appropriate solution for me. Is there any way to add pre/p...

Aspect Oriented Programming: What do you use PostSharp for?

Hi, I would like to ask users of the AOP framework Postsharp, what specifically are you using the framework for? Also, I know it's use has a big negative impact on build times, but how about runtime performace? Is there much of a hit? Thanks, S ...

Why use a post compiler?

I am battling to understand why a post compiler, like PostSharp, should ever be needed? My understanding is that it just inserts code where attributed in the original code, so why doesn't the developer just do that code writing themselves? I expect that someone will say it's easier to write since you can use attributes on methods and ...

Code Generation based on method Attributes

I was reading through some articles on Caching and Memoization and how to implement it easily using delegates and generics. The syntax was pretty straightforward, and it is surprisingly easy to implement, but I just feel due to the repetitive nature it should be possible to generate code based on an Attribute, instead of having to write ...

PostSharp: Custom attributes are removed when using OnMethodInvocationAspect

I've got some aspect like this: public class MyAttribute : OnMethodInvocationAspect { public int Offset { get; internal set; } public MyAttribute(int offset) { this.Offset = offset; } public override void OnInvocation(MethodInvocationEventArgs eventArgs) { //do some stuff } } Now I'm havi...