lsoft / DpdtInject

Highly efficient compile-time general purpose DI container based on C# source generators.
https://www.nuget.org/packages/Dpdt.Injector/
MIT License
32 stars 3 forks source link

Custom scope object dispose guard #39

Closed lsoft closed 3 years ago

lsoft commented 3 years ago

if the user forgot to dispose custom scope object, we need to invoke dispose in finalization method. so custom scope object should implement full-blown dispose pattern with finalization machnery on.

after implementing, you need to update readme.md (section custom scope).

lsoft commented 3 years ago

the first action should be to create unit test, may be with GC.Collect

lsoft commented 3 years ago

after the digging into the code, I decided not to invoke Dispose in finalizers, due to it's a bad practice. may be some warning might be useful, but what the place it write to? Debug.WriteLine? who reads it? :)