Skip to content
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

Only subscribe to AppDomain.AssemblyResolve once #53166

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jasonmalinowski
Copy link
Member

No description provided.

@jasonmalinowski jasonmalinowski requested a review from a team as a code owner May 5, 2021 03:34
@jasonmalinowski jasonmalinowski self-assigned this May 5, 2021
@@ -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)
Copy link
Member

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?

Copy link
Member Author

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.

jasonmalinowski added a commit to jasonmalinowski/omnisharp-roslyn that referenced this pull request May 5, 2021
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.
@JoeRobich
Copy link
Member

Changing target branch to 16.11 servicing branch

@JoeRobich JoeRobich changed the base branch from release/dev16.11 to release/dev16.11-vs-deps August 16, 2021 20:14
@jasonmalinowski jasonmalinowski changed the base branch from release/dev16.11-vs-deps to main September 1, 2021 00:34
@CyrusNajmabadi
Copy link
Member

@jasonmalinowski can we take this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants