-
Notifications
You must be signed in to change notification settings - Fork 832
implement IDisposable interfaces explicitly #3447
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
Conversation
|
Cool |
|
How would this change actually be consumed? What code today needs this change, or what will this change enable? Thanks |
|
@KevinRansom Any code that obtains sequence enumerator and then tries to dispose it (e.g. with a use statement). This just fixes inconsistensies, most of the sequence enumerators already had the IDisposable interface, there were only a few that did not. |
|
with this change: The generated enumerator doesn't really need collection. It is implemented as: Dispose may be necessary if one were to generate a derived class with an enumeration over a COM collection. But since that would be special code it should add IDisposable to the derived class. |
|
@KevinRansom |
|
@ncave Generated classes like this do all have the IDisposable interface, it's just not listed explicitly. It's implied by inheritance via the However it may be that Fable translation wants to see these as explicit interface implementations? I don't mind making this explicit. The one change we can't take is that change to the public API surface of the |
|
@KevinRansom As long as this change is undone then AFAICS this is simply code cleanup, making interfaces that are already implemented implicitly more explicit. |
|
@dsyme I'll take it out, but do you mind elaborating a bit, as this Dispose is only supposed to be called by compiled code? The change I made preserves existing functionality and fixes some use cases when code is generated to dispose things that don't implement IDisposable. |
|
Oh wow ... I didn't know that about IEnumerator and I think it's kind of silly, however, are we going to teach the compiler to work for: |
|
@KevinRansom If we add IDisposable.Dispose somewhere here, then yes, why not. |
Strictly speaking removing a generic constraint isn't a breaking change to the API of a component (other changes to method signatures would be). However this is a little subtle and I'd just rather avoid that change in what is otherwise a cleanup PR |
To be clear, this PR doesn't do that. IDisposable is only implied by |
|
@dsyme @KevinRansom Ok, Dispose change reverted. It really does help alleviate some code generation issues on lesser platforms, so it's a nice to have, but yeah, I'll leave it at that. Thanks for reviewing! |
@ncave does this change help Fable in some way, e.g. by making the IDisposable implementation explicit in the generated classes? |
|
@dsyme I'm sure it will, in a way, in the sense that it makes all the sequence enumerators consistent (most of them already have the explicit IDispose). It's just a code cleanup, as you said, but it also helps platforms that can't handle non-explicit interfaces. |
So Fable can't handle non-explicit interfaces? We should add an implement-all-interfaces-explicitly option, is that already in Fable compiler? |
* Document project options and mark lots of things as deprecated (#3449) * Document project options and mark lots of things as deprecated * delete some code that is no longer used * fix packaging of FSharp.Core. (#3452) * implement IDisposable interfaces explicitly (#3447) * added IDisposable * reverted Dispose change * ngen open source install (#3456) * handle "Blue (high contrast)" theme (#3443)
* Document project options and mark lots of things as deprecated (dotnet#3449) * Document project options and mark lots of things as deprecated * delete some code that is no longer used * fix packaging of FSharp.Core. (dotnet#3452) * implement IDisposable interfaces explicitly (dotnet#3447) * added IDisposable * reverted Dispose change * ngen open source install (dotnet#3456) * handle "Blue (high contrast)" theme (dotnet#3443)
added some missing IDisposable interfaces