-
Notifications
You must be signed in to change notification settings - Fork 1
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
Added implementation. #1
base: main
Are you sure you want to change the base?
Conversation
GitHub Actions has been set up. I'll review here shortly. |
Ah ok. |
src/LuzFaltex.Extensions.DependencyInjection/ServiceLookup/CallSiteFactory.cs
Outdated
Show resolved
Hide resolved
src/LuzFaltex.Extensions.DependencyInjection/ServiceLookup/ServiceProviderCallSite.cs
Show resolved
Hide resolved
src/LuzFaltex.Extensions.DependencyInjection/ServiceLookup/ServiceProviderEngineScope.cs
Show resolved
Hide resolved
Public Types: - MutableServiceProvider - MutableServiceProviderFactory Signed-off-by: AraHaan <[email protected]>
592e8d1
to
c82d4bd
Compare
Alright, these changes might require As well as this: https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=cmd#enable-long-paths-in-windows-10-version-1607-and-later |
Alright, I tested it locally with my Discord bot with Remora.Plugins using this code and for some reason it crashes with an resource load exception. |
src/LuzFaltex.Extensions.DependencyInjection/ServiceLookup/CallSiteFactory.cs
Outdated
Show resolved
Hide resolved
31c70e6
to
cbe7386
Compare
Remora.Plugins now works with this.
I am not sure what happens in Remora/Remora.Discord#231 but perhaps CallSiteFactory tries to restart all Singleton instances every time new ServiceCollections are added? |
Issue in Remora.Discord turns out to have been fixed there (ironically with this it now runs as if the code was for a sharded bot). |
var serviceCount = _serviceCollections.CountServices(); | ||
for (int i = serviceCount.Count - 1; i >= 0; i--) | ||
{ | ||
var descriptor = serviceCount[i]; | ||
var callSite = TryCreateExact(descriptor, itemType, callSiteChain, slot) ?? | ||
TryCreateOpenGeneric(descriptor, itemType, callSiteChain, slot, false); | ||
|
||
if (callSite != null) | ||
{ | ||
slot++; | ||
|
||
cacheLocation = GetCommonCacheLocation(cacheLocation, callSite.Cache.Location); | ||
callSites.Add(callSite); | ||
} | ||
} |
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.
It seems that every time a service collection is added, that then new callsites are created (even ones that already existed) which results in new instances being created. Oops.
Welp I think this is a failure somewhat, In terms of singleton instances getting restarted it seems whenever service collections are added/removed from the CallSiteFactory. The sad part is that code is complex as well making it hard to figure out a way to not have that happen. |
Public Types: