Created
March 28, 2010 16:32
-
-
Save jfromaniello/346848 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Reflection; | |
using System.Text; | |
using PostSharp.Aspects; | |
using PostSharp.Aspects.Advices; | |
using PostSharp.CodeModel; | |
using PostSharp.Extensibility; | |
namespace PortSharpError2 | |
{ | |
public class TypedBase<T> | |
{ | |
public string Something323 { get; set; } | |
} | |
[SampleAspect] | |
public class StringSample : TypedBase<string> | |
{ | |
public void DoSomething(){} | |
} | |
[Serializable] | |
[AttributeUsage(AttributeTargets.Class, Inherited = true, AllowMultiple = false)] | |
[MulticastAttributeUsage(MulticastTargets.Class, TargetMemberAttributes = MulticastAttributes.Public, | |
AllowMultiple = false)] | |
public class SampleAspectAttribute : InstanceLevelAspect | |
{ | |
public IEnumerable<MethodInfo> GetMethods(Type type) | |
{ | |
return type.GetMethods().Where(m => m.IsPublic); | |
// && m.DeclaringType.Equals(type)); | |
} | |
[MethodPointcut("GetMethods")] | |
[OnMethodExceptionAdvice] | |
public void OnException(MethodExecutionArgs eventArgs) | |
{ | |
Console.WriteLine("Exception"); | |
} | |
[MethodPointcut("GetMethods")] | |
[OnMethodEntryAdvice] | |
public void OnEntry(MethodExecutionArgs eventArgs) | |
{ | |
Console.WriteLine("Entry"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment