| Severity | Error |
| Reported by | PostSharp |
| Message | The processing of multicast attributes cannot continue because of the previous errors. |
Cause
Before it applies aspects, PostSharp reads every multicast attribute of the project, including aspects, and computes where each one applies: it reads the MulticastAttributeUsageAttribute of the attribute class and the filter properties of each instance, such as AttributeTargetTypes. When this step reports an error, PostSharp cannot know where the attributes apply, so it stops the build and reports PS0055.
PS0055 is therefore always reported together with at least one other error, which describes the actual problem. Common ones are:
- PS0093: a filter property, such as AttributeTargetTypes or AttributeTargetMembers, contains an invalid regular expression.
- PS0072: the MulticastAttributeUsageAttribute of an aspect class allows more than the one of its base class.
- PS0090 or PS0171: the usage or the filter of a multicast attribute is invalid.
PS0055 has no location.
In the following example, the regular expression of AttributeTargetTypes lacks a closing parenthesis, so PostSharp reports PS0093 and stops with PS0055.
using System;
using PostSharp.Aspects;
using PostSharp.Serialization;
// The regular expression lacks its closing parenthesis.
[assembly: Errors.PS0055_Error.Trace( AttributeTargetTypes = "regex:^Errors\\.PS0055_Error\\.(Order|CustomerService$" )]
namespace Errors.PS0055_Error;
[PSerializable]
public class TraceAttribute : OnMethodBoundaryAspect
{
public override void OnEntry( MethodExecutionArgs args )
{
Console.WriteLine( $"Entering {args.Method.DeclaringType!.Name}.{args.Method.Name}." );
}
}
public class OrderService
{
public void PlaceOrder() => Console.WriteLine( "Order placed." );
}
public class CustomerService
{
public void Register() => Console.WriteLine( "Customer registered." );
}
public static class Program
{
public static void Main()
{
new OrderService().PlaceOrder();
new CustomerService().Register();
}
}
error PS0055: The processing of multicast attributes cannot continue because of the previous errors.
error PS0093: Invalid expression for property AttributeTargetTypes of the custom attribute "Errors.PS0055_Error.TraceAttribute" on assembly "ps0055_error, version=0.0.0.0, culture=neutral, publickeytoken=null, processorarchitecture=msil": Invalid pattern '^Errors\.PS0055_Error\.(Order|CustomerService$' at offset 46. Not enough )'s.
Resolution
Fix the other errors that PostSharp reports with PS0055, and PS0055 disappears with them. The location of the other error points to the multicast attribute or the attribute class at fault.
In the following example, the regular expression is corrected, and the aspect applies to the two service classes.
using System;
using PostSharp.Aspects;
using PostSharp.Serialization;
// The parentheses of the regular expression are balanced.
[assembly: Errors.PS0055_Fixed.Trace( AttributeTargetTypes = "regex:^Errors\\.PS0055_Fixed\\.(Order|Customer)Service$" )]
namespace Errors.PS0055_Fixed;
[PSerializable]
public class TraceAttribute : OnMethodBoundaryAspect
{
public override void OnEntry( MethodExecutionArgs args )
{
Console.WriteLine( $"Entering {args.Method.DeclaringType!.Name}.{args.Method.Name}." );
}
}
public class OrderService
{
public void PlaceOrder() => Console.WriteLine( "Order placed." );
}
public class CustomerService
{
public void Register() => Console.WriteLine( "Customer registered." );
}
public static class Program
{
public static void Main()
{
new OrderService().PlaceOrder();
new CustomerService().Register();
}
}
Entering OrderService..ctor.
Entering OrderService.PlaceOrder.
Order placed.
Entering CustomerService..ctor.
Entering CustomerService.Register.
Customer registered.
See Also
Reference
MulticastAttribute
MulticastAttributeUsageAttribute
Other Resources
Adding Aspects to Multiple Declarations Using Attributes
Understanding Attribute Multicasting