Search code examples
c#resharpercustom-attributesrider

Create a custom attribute that would hint to Resharper that property is used implicitly


If I define a class with a public property that is not used explicitly, but annotate it with either Newtonsoft.Json.JsonProperty or JetBrains.Annotations.UsedImplicitly, then I won't get any usage warnings.

Can I define such custom attribute? My motivation is that I already have some custom attributes to mark such properties and adding this feature on top of them would save some redundant annotations.


Solution

  • According to the Resharper Documentation you should be able to apply a MeansImplicitUseAttribute to your own attribute's definition.

    MeansImplicitUseAttribute

    Should be used on attributes so that symbols marked with such attributes are not reported as unused. The marked attribute behaves the same as UsedImplicitlyAttribute.