Fixes CA2213 issues on NuGet client repo#4812
Conversation
donnie-msft
left a comment
There was a problem hiding this comment.
Thanks for jumping on this! I just have some questions about testing strategy...
src/NuGet.Clients/NuGet.PackageManagement.UI/NuGet.PackageManagement.UI.csproj
Outdated
Show resolved
Hide resolved
test/NuGet.Core.Tests/NuGet.Protocol.Tests/HttpSource/HttpSourceAuthenticationHandlerTests.cs
Outdated
Show resolved
Hide resolved
test/NuGet.Core.Tests/NuGet.Protocol.Tests/HttpSource/HttpSourceAuthenticationHandlerTests.cs
Outdated
Show resolved
Hide resolved
| HttpHandlerResourceV3.CredentialsSuccessfullyUsed?.Invoke(uri, credentials); | ||
| } | ||
|
|
||
| protected override void Dispose(bool disposing) |
There was a problem hiding this comment.
Do we ever call dispose on the handler?
The thing about the dispose pattern is that it needs to be implement all the way up the stack. Are we doing that?
There was a problem hiding this comment.
It seems no.
HttpSourceAuthenticationHandler objects are created inside HttpHandlerResourceV3Provider.TryCreate() method. Objects returned by this method are INuGetResource-based. This interface does not implement any IDisposable-based interfaces.
There was a problem hiding this comment.
In short words: we don't call dispose on this class in NuGet.Client source code. We are now just being good citizens by implementing Dispose.
There was a problem hiding this comment.
How about we just accept this dispose changes as it's? But create/link another follows up issue for implementing dispose pattern all the way up the stack, fixing that part shouldn't be high priority for now.
Or just suppress with reason why it doesn't add any value by doing so.
There was a problem hiding this comment.
I'm looking forward to merging this PR. Added follow up issue to use IDisposable pattern in NuGet protocol code. NuGet/Home#12176
There was a problem hiding this comment.
Should we call GC.SuppressFinalize(this); in dispose? We're doing it for another dispose.
There was a problem hiding this comment.
Not here, that should be called in Dispose() method (without arguments) of base class
There was a problem hiding this comment.
Not here, that should be called in Dispose() method (without arguments) of base class
Sure, thank you for clarifying.
abdb7f8 to
f29615d
Compare
9daaf35 to
42779e2
Compare
42779e2 to
45bd994
Compare
|
Team review: Add tests that dispose multiple times to verify nothing else throws exceptions. |
|
This PR has been automatically marked as stale because it has no activity for 7 days. It will be closed if no further activity occurs within another 7 days of this comment. If it is closed, you may reopen it anytime when you're ready again, as long as you don't delete the branch. |
3467f70 to
714a6b6
Compare
erdembayar
left a comment
There was a problem hiding this comment.
I believe we address 1 problem at the time, so this is good enough for merging.
Fixes NuGet/Home#12116 Fixes CA2213 in HttpSourceAuthenticationHandler and in test code. Left 1 CA2213 suppression due to a Roslyn analyzer bug linked in the suppression code.
Fixes NuGet/Home#12116 Fixes CA2213 in HttpSourceAuthenticationHandler and in test code. Left 1 CA2213 suppression due to a Roslyn analyzer bug linked in the suppression code.
Fixes NuGet/Home#12116 Fixes CA2213 in HttpSourceAuthenticationHandler and in test code. Left 1 CA2213 suppression due to a Roslyn analyzer bug linked in the suppression code.
Fixes NuGet/Home#12116 Fixes CA2213 in HttpSourceAuthenticationHandler and in test code. Left 1 CA2213 suppression due to a Roslyn analyzer bug linked in the suppression code.
Fixes NuGet/Home#12116 Fixes CA2213 in HttpSourceAuthenticationHandler and in test code. Left 1 CA2213 suppression due to a Roslyn analyzer bug linked in the suppression code.
Bug
Fixes: NuGet/Home#12116
Regression? Last working version: N/A
Description
HttpSourceAuthenticationHandlerclassHttpSourceAuthenticationHandler.Dispose()PR Checklist
PR has a meaningful title
PR has a linked issue.
Described changes
Tests
Documentation