-
Notifications
You must be signed in to change notification settings - Fork 258
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
Remove or improve configuration change events #8479
Comments
I reached this issue via the |
If you're using it in a process that is short lived, use the overload without the If you're using in a long running process, then it's best to use this constructor which is marked as obsolesce and be prepared that in future versions of NuGet there's an increased risk of breaking changes. |
@zivkan If the idea is to disable package source changed events then none of the non-obsolete ctors support that scenario. The only option takes a So if I am understanding things correctly we really don't have a way to disable events without using an obsoleted ctor. Is this correct? |
@JakeSays yes, you're right. If you have a long-lived process where you need to create Unfortunately I was between a rock and a hard place. We didn't want to break API & ABI compatibility when making the change, so removing the "useless" events was ruled out. But, in the long term the new ctor will not be needed, the extra parameter would do nothing, so I didn't want people depending on it and therefore getting a breaking change when we finally get rid of it. I was constrained by previous design decisions and a fear of breaking changes, so for better or worse, this is the decision I made. |
Currently I'm using the following code when dynamically loading packages.
How can I get the default nuget.org repositories without using sourceRepositoryProvider and avoid the Obsolete Warning?. |
I've found a solution: Just use the respository Factory. |
There does not seem to be a solution for the old implementation, that infers the sources from the NuGet.config of a directory and uses all of them. Strange that this is obsolete without a replacement. |
Here is a solution that works for me: var settings = Settings.LoadDefaultSettings(directoryUnderNuGetConfig);
var repositories = new PackageSourceProvider(settings)
.LoadPackageSources()
.Where(source => source.IsEnabled)
.Select(source => Repository.Factory.GetCoreV3(source.Source)); |
ISettings
andIPackageSourceProvider
have events about changes to settings. However, the only place this appears to be used is inExtensibleSourceRespositoryProvider
and the only place it appears to be raised is inVSSettings
when solutions are opened or closed.The easier option would be to make
ExtensibleSourceRespositoryProvider
subscribe to the solution open and close events directly and remove all the configuration event code.Alternatively, events should be unsubscribed properly, probably by making everything related
IDisposable
and making sure they get disposed correctly.The text was updated successfully, but these errors were encountered: