Skip to content
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

Imported Resources don't provide a finalizer #58

Open
kaivol opened this issue Nov 17, 2024 · 4 comments
Open

Imported Resources don't provide a finalizer #58

kaivol opened this issue Nov 17, 2024 · 4 comments

Comments

@kaivol
Copy link

kaivol commented Nov 17, 2024

Currently, projections for imported resources implement IDisposable, but they do not provide a finalizer. This means that if the user forgets to manually dispose the resource, its [resource-drop] function is never called.

I believe this is incorrect, and the resource should provide a finalizer that calls the resource's [resource-drop] function.


Version:

<PackageReference Include="BytecodeAlliance.Componentize.DotNet.Wasm.SDK" Version="0.4.0-preview00007" />
@yowl
Copy link
Contributor

yowl commented Nov 17, 2024

Seems like a bug, but with wit-bindgen, rather than this tooling, so should be https://github.com/bytecodealliance/wit-bindgen/issues I think

@kaivol
Copy link
Author

kaivol commented Nov 19, 2024

Okay, never mind, this seems to be intended: bytecodealliance/wit-bindgen@c648fc7

Nevertheless, it might be helpful to mention in the readme that resources must be disposed/dropped manually.
Perhaps recommending to enable the corresponding warnings (CA2000, CA1001, CA2213)?

Feel free to close this issue if this is not the correct repository for these suggestions.

@yowl
Copy link
Contributor

yowl commented Nov 19, 2024

You are right, I'd forgotten about the child resources problem.

@jsturtevant
Copy link
Contributor

The warnings look reasonable to turn on, Do you have an example where this triggers?

Not sure the best place to document, but we can certainly add a note the readme here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants