postsharp

Refactoring nasty legacy systems via AOP or other automated means?

I've recently been playing around with PostSharp, and it brought to mind a problem I faced a few years back: A client's developer had produced a web application, but they had not given a lot of thought to how they managed state information - storing it (don't ask me why) statically on the Application instance in IIS. Needless to say the ...

Whats the difference between PostSharp and Castle Dynamic Proxy?

Just wondering what the main differences are between these libraries, how they differ in features and functionality. Hoping for more information than I could find with a Google query... ...

How do I create a pointcut to intercept all methods in a class with PostSharp?

I've tried using AttributeTargetTypes, but it just won't work. What am I missing? thanks ...

How to use PostSharp with MOQ?

Hello! We are trying to use PostSharp, more specifically the OnMethodInvocationAspect, to intercept the methods of a class. The code runs fine, but when testing it with MOQ, it seems to be messing up with my mocks. If I remove the aspects, all tests succeed. But, if I turn the aspects back on, the expectations on the MOQ mocks are not...

Has anybody used any AOP products under Mono?

I'm looking into using PostSharp on one of my projects. The complicating factor is that I need PostSharp to work on both Windows x64 and Linux x64/Mono. According to the available info for PostSharp, you can compile on Windows/.NET and run under both .NET and Mono. The question is this: can I perform PostSharp builds on Linux/Mono? ...

System.AccessViolationException with Dynamic Proxy Generation

We are using PostSharp to inject caching functionality, we are only seeing this issue when we are using it. When we use Spring the issue seems to go away. Any help would be appreciated as this, the issue is very difficult to replicate. I've included the stack trace below: Attempted to read or write protected memory. This is often an in...

.NET Conditional Compiler Symbols and Unit Test Libraries

My team has a set of unit test libraries that run against our application code - unfortunately they are throwing (unexpected) exceptions. The reason for this is that our logging code is being called and the objects aren't setup. The logging code is executed via a method attribute we have setup using PostSharp (which get called before and...

What are the functional differences between AspectJ and PostSharp?

Does anyone know what AOP features are different between AspectJ and PostSharp (yes I know they are for different languages and platforms)? I'm trying to understand what kind of things AspectJ would allow that PostSharp would not, and vice versa. ...

Hiding inherited named parameters on attributes C# (3.5)

Hi all, I am using PostSharp to add some compile time logic to my attributes - in once case [IndexedCategory ("CatName", CatIndex)]. The trouble comes comes in because IndexedCategory derives from CompoundAspect - which has a reasonable number of named params. Is there any way which I can prevent these from being accessed / shown by i...

Using Reflection and PostSharp alternatively !

Is there a Code sample that uses PostSharp actively but can also use System.Reflecttion.Emit alternatively to get field value and load into LocalVariableSymbol of PostSharp ? eg. in PS Weavingcontext.InstructionWriter.EmitInstructionField(Opcodenumber.Ldsfld, Ifld); in Reflection code sample to get the current context and emit th...

Use AOP in C# to detect if return value is used

This is related to my other question, but this time very specific. Is it possible, using AOP (PostSharp in particular) to detect if function's return value was used? For example var x = y.func(); // used y.func(); // not used Note that detection should be performed for this particular call, not for the function in general. I never u...

Null reference exception on MethodExecutionEventArgs.Method using PostSharp with multiple web service projects

HI, I'm using PostSharp to log entry and exit to every method in my Application assembly. This assembly is strongly named, versioned and registered in the GAC. It is then shared by 2 web service projects hosted in separate Virtual Directories inside IIS. When the OnEntry/OnExit method of the interceptor is invoked by WebServiceProject1...

Preprocessing C# - Detecting Methods

Hey, I require the ability to preprocess a number of C# files as a prebuild step for a project, detect the start of methods, and insert generated code at the start of the method, before any existing code. I am, however, having a problem detecting the opening of a method. I initially tried a regular expression to match, but ended up wi...

Deploy multiple projects using PostSharp on a target machine without the PostSharp MSI

We have several projects hanging off of a solution, a website and some services. Each will utilise PostSharp but as we do not want to install PostSharp on the target machine using the MSI we can deploy the relevant suite of PostSharp dependencies as detailed in this blogpost by Scott Wojan. http://geekswithblogs.net/wojan/archive/2009/0...

Reduce PostSharp compile time overhead

We recently introduced PostSharp into our code base and the compile time of our ASP.NET MVC project has doubled to quadrupled. We have about 3 MVC projects and approximately 8 class library projects in our solution. Obviously there will be overhead associated with PostSharp since it is modifying the MSIL code. But a 2x to 4x overhead ...

How to get this really fast?

I have a framework that allows users to do queries to a specific datasource (the Football Manager 2010 ingame database, for those of you interested). In this framework, I have two different modes wherein my framework can run: realtime and cached mode. I want users who use this framework to be able to switch by just calling a different c...

How to convert an exception to another one using PostSharp?

I would like to automagically add the following code around the body of some methods: try { // method body } catch (Exception e) { throw new MyException("Some appropriate message", e); } I am working with PostSharp 1.0 and this is what I've done at the moment: public override void OnException(MethodExecutionEventArgs eventArgs)...

PostSharp: OnMethodBoundaryAspect on derived class's constructor

Hi I have an aspect that writes something to the console on exception. I have a base class that throws an exception on its constructor, and a derived class that have the aspect on its constructor. I would expect that the derived class aspect on constructor will catch the base class exception, but it dont. Is this by design? Is this a ...

AOP/PostSharp and dirty-checking - getting property name the better way?

My aspect: [Serializable] [MulticastAttributeUsage(MulticastTargets.Class, Inheritance = MulticastInheritance.Strict)] public sealed class NotifyPropertyChangedAttribute : InstanceLevelAspect { [OnLocationSetValueAdvice, MulticastPointcut(Targets = MulticastTargets.Property)] public voi...

PostSharp , PDB Debugging and Referenced Assemblies ...

When using PostSharp with a Referenced Assembly with proper PDB info( checked with chkmatch), it seems strange that the debug info gets lost by VStudio build and post compile process and I get the following error by using chkmatch to compare the assembly after the vstudio build. Error: Debug information not found in the executable. So ...