Let's say I have a read-only interface and a specific class in which the property is created in the constructor and marked as read-only.
internal interface IExample { ObservableCollection<string> Items { get; } } internal class Example : IExample { private readonly ObservableCollection<string> _items; public Example() { _items = new ObservableCollection<string>(); } public ObservableCollection<string> Items { get { return _items; } } }
When I use the interface, Resharper warns me that I may have a possible null reference when calling the code.
public class ExampleWithWarnings { public void Show() { IExample example = new Example();
I understand that by definition, an interface does not guarantee that a property will matter. (I also admit that the properties on the interfaces are not perfect). But I know that this property will always matter.
Is there any magic attribute that I can set on an interface that prevents Resharper from showing a warning? I would prefer not to decorate all the class customs with a ban warning.
bryanbcook
source share