Search code examples
c#visual-studiopostsharp

PostSharp MulticastAttributeUsage MulticastTargets.Constructor option is deprecated


We use PostSharp on the project I've recently joined and I see compiler warning that MulticastTargets.Constructor option is obsolete for the following row: [MulticastAttributeUsage(MulticastTargets.Constructor | MulticastTargets.Method, AllowMultiple = true, TargetMemberAttributes = MulticastAttributes.NonAbstract)]

The warning suggests replacing it with InstanceConstructor or StaticConstructor. What I'd like to do is to get rid of the warning, but also not change anything in the system.

I suppose that I need to replace the deprecated option with both newer options, i.e.: MulticastTargets.StaticConstructor | MulticastTargets.InstanceConstructor, but would like to be 100% sure that the behaviour stays the same. So, is such replacement correct?


Solution

  • Yes.

    It is defined exactly like that:

    [Obsolete( "Use InstanceConstructor or StaticConstructor." )] 
    Constructor = InstanceConstructor | StaticConstructor