-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document ref enumerator disposal compat break #33367
Document ref enumerator disposal compat break #33367
Conversation
@dotnet/roslyn-compiler for review please |
@@ -81,3 +81,26 @@ Each entry should include a short description of the break, followed by either a | |||
|
|||
10. Previously, reference assemblies were emitted including embedded resources. In Visual Studio 2019, embedded resources are no longer emitted into ref assemblies. | |||
See https://github.com/dotnet/roslyn/issues/31197 | |||
|
|||
11. Ref structs now support disposal via pattern. A ref struct enumerator with an accessible `void Dispose()` method will now have it invoked at the end of enumeration, where it would not have been before: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
method [](start = 110, length = 6)
"... instance method or static extension method"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LDM disallowed extension methods. (I really need to publish the updated spec)
In reply to: 256627330 [](ancestors = 256627330)
@@ -81,3 +81,26 @@ Each entry should include a short description of the break, followed by either a | |||
|
|||
10. Previously, reference assemblies were emitted including embedded resources. In Visual Studio 2019, embedded resources are no longer emitted into ref assemblies. | |||
See https://github.com/dotnet/roslyn/issues/31197 | |||
|
|||
11. Ref structs now support disposal via pattern. A ref struct enumerator with an accessible `void Dispose()` method will now have it invoked at the end of enumeration, where it would not have been before: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where it would not have been before [](start = 168, length = 36)
" ... regardless of whether the struct type implements IDisposable
"
This should probably target the |
Agree lets put this into dev16.0 |
@chsienki I tried re-targeting the PR to |
1e2510d
to
7b57192
Compare
Rebased on dev16.0 and re-targeted. |
foreach(var x in new C()) | ||
{ | ||
} | ||
// RefEnumerator.Dispose() will be called here in C# 8.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in C# 8.0 [](start = 55, length = 9)
Just to confirm: Is this the case?
Is the LangVersion the determining factor, or the fact that you use a 3.0 (dev16) version of the compiler? If we don't already have a test for that, it would be good to add.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, it should require only C# 8.0. Let me test, and add a test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we do correctly gate on langver
roslyn/src/Compilers/CSharp/Portable/Binder/Binder_Statements.cs
Lines 682 to 686 in 12f4665
// Don't try and lookup if we're not enabled | |
if (MessageID.IDS_FeatureUsingDeclarations.RequiredVersion() > Compilation.LanguageVersion) | |
{ | |
return null; | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM Thanks
- Check that we don't call Dispose on a ref struct enumerator in language versions lower than 8.0
- Assert.Null - Add an execution test to check end to end
Documents the breaking change of calling
Dispose
on a ref struct enumerator.