-
Notifications
You must be signed in to change notification settings - Fork 635
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
Avoid duplication in package assembly list #10550
Conversation
var assemblies = packageList | ||
.SelectMany(p => p.LoadedAssemblies.Where(y => y.IsNodeLibrary)) | ||
.Select(a => a.Assembly) | ||
.ToList(); |
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.
There are basically two things that were fixed:
- The call to
EnumerateAssembliesInBinDirectory
was replaced by usingLoadedAssemblies
. This avoids re-adding assemblies toLoadedAssemblies
. - The assemblies list is materialized. Before these changes, the call to
EnumerateAssembliesInBinDirectory
was made each time the enumerable was enumerated, which happened once per event handler forPackageLoaded
. That caused triplication of the libraries for me on latest master.
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.
@mmisol you mentioned that EnumerateAssembliesInBinDirectory
was being called in a couple of other places. Do those need to be replaced with LoadedAssmeblies
as well?
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.
Yes, you are right. What I was seeing in the stack trace was actually this line of code being executed when the enumeration was materialized. This happened in two event handlers of OnPackagesLoaded
, one in DynamoModel.cs(978) and another in EngineController.cs(521).
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.
@mmisol So I assume whichever event handler called second time, with this fix, we will no longer re-adding assemblies to LoadedAssemblies
. Do we want to create a test by mocking up the situation and check the end LoadedAssemblies
?
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.
Yes, that was part of the issue. The call to TryLoadPackageIntoLibrary
is the first to call EnumerateAssembliesInBinDirectory
and after this LoadedAssemblies
should be used to read them.
I'll see to add a test. I have to think about what needs to be mocked, hopefully it's not too difficult.
@mmisol could you create a JIRA issue for this for tracking purposes. |
@mmisol thanks for fixing this issue so quickly! Are there any tests you can add for this? |
should the use of this enumerateAssemblies method also be changed here: Dynamo/src/DynamoPackages/PackageLoader.cs Line 261 in 7cbe479
|
@mjkkirschner That code seems to have the same problem. I'll check if it's being used somewhere. |
Added a test. This is ready for review @aparajit-pratap @QilongTang @mjkkirschner About the method you mentioned, it's obsoleted and there are no usages, so I left it alone. Let me know if you would like to change ti anyway, but testing it would be difficult. |
@mmisol Thank you for adding the test. LGTM. Not sure if we need to include the other spot also part of this PR, I think it is OK to not include. Oops.. Wrong button |
Re-thinking about what I wrote yesterday, unit testing the obsolete method should be easy. If you guys think it's safer to change it and unit test it rather than leaving as-is let me know and I can change it. |
I think this is good. LGTM. |
Is this PR good to be merged @QilongTang @aparajit-pratap @mjkkirschner ? If so, can I get an approval? Thank you |
@mmisol Ship it! |
Purpose
Fixes the issue described here https://forum.dynamobim.com/t/package-contents-listed-twice-in-the-package-manager/48994. Tracked as DYN-2602.
Declarations
Check these if you believe they are true
*.resx
filesReviewers
@aparajit-pratap @QilongTang
FYIs
@mjkkirschner