Skip to content

Instantly share code, notes, and snippets.

@jfromaniello
Created March 28, 2010 16:32
Show Gist options
  • Save jfromaniello/346848 to your computer and use it in GitHub Desktop.
Save jfromaniello/346848 to your computer and use it in GitHub Desktop.
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