Implicitly scoped using statement without explicit assignment #8214
-
The introduction of implicitly scoped suing statments have been great for C# and have improved readbility greatly. However, they have one limitation vs traditional explicitly-scoped using statements: They require assigning a variable. There are many situations in which I want to logging: using(logger.BeginScope(myState))
{
// ...
} FluentAssertions: using(new AssertionScope())
{
// ...
} method returning IDisposable and using(RentBuffer(out Memory<T> memory))
{
// ...
} ProposalAllow implicitly-scoped using statements to exist without a(n explicit) variable assignment: logging: using logger.BeginScope(myState);
// ... FluentAssertions: using new AssertionScope();
// ... IDidposable & using RentBuffer(out Memory<T> memory);
// ... This would allow this situations to benefit from the increased readability of the implict-scoping. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Beta Was this translation helpful? Give feedback.
#7882