Skip to content

[Proposal] Allow for inline creation and handling of IDisposable objects (RAAI) #181

@tpetrina

Description

@tpetrina

Proposed syntax would be

var x = using new Disposable();
var y = using new Disposable();

The code is just a shorter way of writing:

using (var x = new Disposable())
{
  using (var y = new Disposable())
  {
  }
}

Which is actually much more composable with try-catch pattern. Now we can remove one extra pair of curly braces and write:

try
{
   var x = using new Disposable();
}
catch
{
  // log and handle
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions