Here is my aspect:
namespace AspectExtentions
{
[MulticastAttributeUsage(MulticastTargets.Method | MulticastTargets.InstanceConstructor | MulticastTargets.StaticConstructor, TargetMemberAttributes = MulticastAttributes.Instance, AllowMultiple = true)]
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Event | AttributeTargets.Interface, AllowMultiple = true)]
[Serializable]
public class LoggingAspect : OnMethodBoundaryAspect , IAspectProvider
{
..... code not important
}
}
It is used in:
namespace SynonymRedirector
{
partial class Form1 : Form, IMainView
{
[LoggingAspect]
private void ubCreateSynonyms_Click(object sender, EventArgs e)
{
.... code not important
}
....
}
}
This appears to work as expected: However, I would like to remove this attribute and use MultiCast to define the point cut:
I have the following defined: (In SynonymRedirector.psproj)
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.postsharp.org/1.0/configuration">
<Multicast xmlns:my="clr-namespace:AspectExtentions;assembly:AspectExtentions">
<my:LoggingAspect AttributeTargetTypes="SynonymRedirector.Form1.ubCreateSynonyms_Click" AttributeTargetMemberAttributes="Private" />
</Multicast>
</Project>
I also have the following defined: (In AssemblyInfo.cs)
[assembly: AspectExtentions.LoggingAspect(AttributeTargetMembers = "SynonymRedirector.Form1.ubSaveToFiles_Click", AttributeTargetElements = PostSharp.Extensibility.MulticastTargets.Method)]
However, on build with this not commented out, I get the following error:
Attribute 'AspectExtentions.LoggingAspect' is not valid on this declaration type. It is only valid on 'method' declarations. C:\Projects\ProofOfConcept\SynonymRedirector\SynonymRedirector\Properties\AssemblyInfo.cs 18 12 SynonymRedirector
PostSharp seems to be set up correctly as the following is produced on build:
Compile complete -- 0 errors, 10 warnings
: message : PostSharp 4.1 [4.1.24.0, postsharp.srv.4.0-x86.exe, CLR 4.0.30319.379893, Release] complete -- 0 errors, 0 warnings, processed in 261 ms
SynonymRedirector -> C:\Projects\ProofOfConcept\SynonymRedirector\SynonymRedirector\bin\Debug\SynonymRedirector.exe
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========
I am using the free version of PostSharp, but according to the web site, Multicast should be available.
I have also noticed that when I have the aspect set up as an attribute on the click event handler method and do a build, I get a lot f PostScript comments (warnings). However, when I comment the attribute out and do a build, I only get the simple PostScript compile info. It appears that the PostScript code generation is not running in this case. Not sure why this is the case.
So, my question is: How do I get this attribute set up so that I can set the point cut in XML using Multicast? What do I have incorrect in the SynonymRedirector.psproj or AssemblyInfo.cs files that causes Multicast to not work?