postsharp

PostSharp - il weaving - thoughts

I am considering using Postsharp framework to ease the burden of application method logging. It basically allows me to adorn methods with logging attribute and at compile time injects the logging code needed into the il. I like this solution as it keeps the noise out of the deign time code environment. Any thoughts, experiences or better...

Using PostSharp to intercept calls to Silverlight objects?

Hi all, I'm working with PostSharp to intercept method calls to objects I don't own, but my aspect code doesn't appear to be getting called. The documentation seems pretty lax in the Silverlight area, so I'd appreciate any help you guys can offer :) I have an attribute that looks like: public class LogAttribute : OnMethodInvocationAsp...

What is IL Weaving?

I just saw Ayende's post today about PostSharp. I downloaded the code and tried it out, and I thought it was the coolest, most easy to use way to handle AOP that I've seen. In his post, Ayende says that PostSharp accomplishes it's magic via IL Weaving. Now, at some abstract level I can deduce what that means, but I wanted to see if the...

PostSharp aspect for property setters, calling generic method

We have a base object we use for some MVC-like system, where each property in a descendant is written like this: public String FirstName { get { return GetProperty<String>("FirstName", ref _FirstName); } set { SetProperty<String>("FirstName", ref _FirstName, value); } } This is done both for debugging purposes and for notifica...

How to create an aspect checking for null references on all methods in a class in postsharp

How to create an aspect checking for null references on all methods in a class in postsharp. using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace test { [MethodParameterNullCheck] internal class Class { public Class() { } public void MethodA(int i, ClassA a, C...

Adding an OnException attribute using PostSharp

I am adventuring into some AOP and it seems with .NET PostSharp is the way to go. I want to do some simple logging to the db when an exception occurs. However I am finding it difficult to find any real solid examples of using PostSharp beyond the basics. I tried the following: [Serializable] public sealed class LogExceptionAttribute :...

Anyone with Postsharp experience in production?

Does anyone out there has used Postsharp AOP framework in production environment? Are there any pitfalls? In order to do some logging etc, can Postsharp be used in conjunction with log4net ? Any tutorials on using Postsharp with Web Apps and/or log4net will be highly appreciated. Thanks In Advance. ...

Cool PostSharp aspects

I'm looking for interesting PostSharp aspects - anything that you found useful and wouldn't mind sharing. ...

Compile time code injection

Lately, I've been working with PostSharp a bit. It is an AOP framework that allows us to do compile time code injection. You can just reference PostSharp assemblies, use it in your code and after compilation, you'll get an assembly that the desired code has been injected into it. I tried to find out how PostSharp integrates itself into t...

MSIL: "Operation could destabilize the runtime" exception

Hi! I've been playing with PostSharp a bit and I ran into a nasty problem. Following IL in Silverlight assembly: .method public hidebysig specialname newslot virtual final instance void set_AccountProfileModifiedAt(valuetype [mscorlib]System.DateTime 'value') cil managed { .maxstack 2 .locals ( [0] bool ~propertyHasCh...

Using Postsharp.Laos to track SqlConnections

Hello, I have encountered a problem I can't solve. I'm hoping someone can give me a nudge in the right direction. As one my first projects to learn AOP and PostSharp in particular, I decided to attempt to monitor SqlConnection lifespans in an application. My code looks like this: using System; using System.Collections.Generic; using Sy...

Injecting properties into .NET classes post-compile

I'd like to implement the ViewModel part of WPF's MVVM pattern without referencing WPF assemblies. The problematic part is command routing, which requires that ViewModels implement properties of type ICommand so that command bindings can work. Now, I can avoid the ICommand and simply declare the properties as object. Everything still wo...

How do I add arguments to PostSharp attributes?

I have a simple PostSharp logging attribute: [Serializable] public class MethodLoggingAttribute : OnMethodBoundaryAspect { private ILog _logger; public override void OnEntry(MethodExecutionEventArgs eventArgs) { _logger = LogManager.GetLogger(eventArgs.Method.DeclaringType.ToString()); _logger.DebugFormat("En...

ClickOnce application that uses PostSharp 1.0 seems to require 1.5 assemblies in GAC

I have installed PostSharp 1.5 on a machine that had 1.0 previously. Now, my application which links to 1.0SP1 assemblies has for some reason started requesting for 1.5 assemblies to be in the GAC on the client side. Does anyone know why this is? (I've asked on the PostSharp forum but received no reply.) ...

Whats wrong with this aspect

I only want this invoked when a property is set. Why is this not working? [DirtyTrackingAttribute(AttributeTargetElements = PostSharp.Extensibility.MulticastTargets.Property)] class Program { public static string Test { get; set; } static void Main(string[] args) { TestIt(); Test = "foo"; Console...

Postsharp and log4net and log4postsharp

I stumbled upon log4postsharp site which is a great tool that uses postsharp for injecting log4net statements into your code at compile time. The current version of log4postsharp uses Postsharp 1.0 which has some limitations. Does anyone know if there is somewhere a compiled version of log4postsharp that uses Postsharp 1.5 available? ...

Postsharp - Get Calling Assembly?

When using a Postsharp OnMethodBoundaryAspect, is there some way to get the calling assembly that initiated the call to a given method? GetCallingAssembly just returns the assembly that the method being called is in. Note - I am having trouble with the postsharp forums, otherwise I would have posted it there. ...

PostSharp for an object mapper

I'm considering using PostSharp for entity-to-DTO and DTO-to-entity mapper. To do that task manualy for about a 100 entities would be a maintenence nightmare. I've looked at AutoMapper on codeplex, but i think the overhead might be a serious problem in my case, besides i feel that PostSharp could give me some extra control over the mappi...

PostSharp - automate event subscription and collection addition

A repeating routine task that I would like to solve using PostSharp is event subscription and collection addition. I would like to subscribe parent's object procedure to each child object's event (children are conatained in a List). I would also like to add all Lists from parent to a master List on the parent. What aspec shuld i be using...

Frameworks and third-party tools

Let us suppose we'd like to use very helpful framework (for example ORM or UI framework), that in general matches you requirements, but requires installing and using third-party tool like PostSharp (tool, that implements AOP modifying compiled code on post-build stage) or something like this. On the one hand it can significantly improve...