Why doesn't Roslyn CA1001 get triggered for an auto-implemented property's backing field?

20 hours ago 3
ARTICLE AD BOX

This triggers CA1001: Types that own disposable fields should be disposable:

public class MyService1 { public System.IO.MemoryStream DataStream = new(); }

But this doesn't:

public class MyService2 { public System.IO.MemoryStream DataStream { get; } = new(); }

However, doesn't MyService2 has the exact issue as MyService1, as its backing field holds a DataStream, which is IDisposable? Why does Roslyn give no warning? And is it possible to set it to give a warning in that case?

Read Entire Article