Frage

I have a factory that instantiates objects and fill in fields that are marked with a custom attribute. Resharper puts a green underline under those fields complaining that "Field 'Example' is never assigned". To suppress the warning I can add the MeansImplicitUseAttribute to my custom attribute. The problem is that attribute also suppresses the "Field 'Example' is never used" warning, which is helpful to me so I'd like to preserve it.

Can I mark my attribute such that I don't get "never assigned" warnings but I still get the "never used" ones?

War es hilfreich?

Lösung

Oh, there are parameters to the MeansImplicitUse attribute that specify the type of use, so I actually want to add [MeansImplicitUse(ImplicitUseKindFlags.Assign)] to my attribute definition. Simple!

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top