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?

有帮助吗?

解决方案

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!

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top