-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Only subscribe to AppDomain.AssemblyResolve once #53166
base: main
Are you sure you want to change the base?
Conversation
@@ -29,7 +29,7 @@ internal class DefaultAnalyzerAssemblyLoader : AnalyzerAssemblyLoader | |||
|
|||
protected override Assembly LoadFromPathImpl(string fullPath) | |||
{ | |||
if (Interlocked.CompareExchange(ref _hookedAssemblyResolve, 0, 1) == 0) | |||
if (Interlocked.CompareExchange(ref _hookedAssemblyResolve, value: 1, comparand: 0) == 0) |
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.
Do we have any tests in this area?
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.
I'll see what I can find. Even if we did, unless the test explicitly asserted the value of the field we probably wouldn't have noticed: since AssemblyResolve stops calling further handlers after one gives a successful resolution, the extra ones just aren't called. So this is really only a memory leak given we might subscribe n times instead of 1 time, but the n is somewhat bounded by the number of analyzers loaded in the process.
This is a port of dotnet/roslyn#53166. There's a bigger question here about how to reuse this code better, but this caused a bunch of confusion while debugging an issue.
Changing target branch to 16.11 servicing branch |
@jasonmalinowski can we take this? |
No description provided.