6 comments
Comment actions Permalink

Yes, as any other attribute

0
Comment actions Permalink

Sorry but it has a Condition.

[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Parameter | AttributeTargets.Delegate | AttributeTargets.GenericParameter)]
  [Conditional("JETBRAINS_ANNOTATIONS")]
  public sealed class NotNullAttribute : Attribute
  {
  }

It is not possible to do it like this.
var attribute in parameter.GetCustomAttributes(true)

 

0
Comment actions Permalink

In this case it is impossible to find "NotNull" attribute by reflection if the assembly was compiled without "JETBRAINS_ANNOTATIONS" flag

0
Comment actions Permalink

I am building a T4 script that I want to use to build from existing dll wrappes classes. The dll classes can contain the NotNullAttribute which is used in Visual studio with Resharper. Now I want to give the attributes to the wrapper class. For this reason I want to find out if the NotNull or CanByNull is set.

0
Comment actions Permalink

You can open the dll with any decompiler ( DotPeek or any other) and check if it contains NotNull/CanBeNull attributes for the methods. If there is no attributes in decompiled code then it is impossible to get them via reflection

0
Comment actions Permalink

I'm not sure if this is possible via T4 script.

0

Please sign in to leave a comment.