ReSharper 2026.1 Help

Code inspection: 'void' method is annotated with the [MustDisposeResource] attribute

This inspection reports void methods annotated with [MustDisposeResource]. That attribute is intended for methods that return a resource the caller must dispose. On a void method, there is no returned resource, so the annotation is meaningless.

Example

using JetBrains.Annotations; class C { [MustDisposeResource] public void CreateResource() { } }
class C { public IDisposable CreateResource() { return new MemoryStream(); } }

Quick-fix

Remove the attribute, or change the method to return the disposable resource.

01 April 2026