Skip to content

DisposableVariableNotDisposedAnalyzer (CC0022) should not raise a diagnostic when returning a type that contains the disposable #465

@giggio

Description

@giggio

CC0022 should not be raised whenever there is a chance that the object lives longer than the method where it was created in.

It should not be raised when assigned to a field/property from another class.

public void Foo(){
  var parent = new Parent();
  var disposable = new DisposableObject();
  parent.Child = disposable;
}

It should not be raised when passed to any method, in the same class or otherwise:

public void Foo(){
  var disposable = new DisposableObject();
  Bar(disposable);
}

Note: This is coming from a comment on the extension, on the extensions gallery started by user fdsprod.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions