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

DYN-7835 : adapt assembly check to ALC #15652

Merged
merged 6 commits into from
Nov 18, 2024
Merged

Conversation

BogdanZavu
Copy link
Contributor

@BogdanZavu BogdanZavu commented Nov 14, 2024

Purpose

Avoid issuing a warning when two assemblies with the same name but different versions are loaded in separate ALCs.

Declarations

Check these if you believe they are true

  • The codebase is in a better state after this PR
  • Is documented according to the standards
  • The level of testing this PR includes is appropriate
  • User facing strings, if any, are extracted into *.resx files
  • All tests pass using the self-service CI.
  • Snapshot of UI changes, if any.
  • Changes to the API follow Semantic Versioning and are documented in the API Changes document.
  • This PR modifies some build requirements and the readme is updated
  • This PR contains no files larger than 50 MB

Release Notes

Avoid issuing a warning when two assemblies with the same name but different versions are loaded in separate assembly load contexts.

Reviewers

@twastvedt @zeusongit

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the ticket for this pull request: https://jira.autodesk.com/browse/DYN-7835

Copy link

github-actions bot commented Nov 14, 2024

UI Smoke Tests

Test: success. 11 passed, 0 failed.
TestComplete Test Result
Workflow Run: UI Smoke Tests
Check: UI Smoke Tests

Copy link
Contributor

@twastvedt twastvedt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a couple tweaks, for clarity and optimization. Let me know if you disagree though!

cleanOutputs.bat Outdated Show resolved Hide resolved
// Ignore some assemblies(Revit assemblies) that we know work and have changed their version number format or do not align
// with semantic versioning.
var loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies()
.Where(a => !assemblyNamesToIgnore.Contains(a.GetName().Name))
.ToList();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aparajit-pratap any idea if AppDomain.CurrentDomain.GetAssemblies() will return all assemblies from all load contexts?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's best to use AssemblyLoadContext.All.SelectMany(context => context.Assemblies); for that purpose.
In any case, we should avoid continuing to use AppDomain going forward.

@@ -398,45 +399,55 @@ public static List<Exception> CheckAssemblyForVersionMismatches(Assembly assembl
private static List<Exception> GetVersionMismatchedReferencesInAppDomain(Assembly assembly, String[] assemblyNamesToIgnore)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BogdanZavu sounds like it might be cleaner to get the ALC of the input argument assembly. And then only check for conflicts against all assemblies loaded in that ALC ?

@mjkkirschner would MetadataLoadCOntext help in this case ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think MLC could work, but if I recall correctly, I think it may not force a load of the referenced assemblies so you may need to make that traversal yourself.

it looks like @BogdanZavu is already getting the ALC of the input assembly, so I agree it's a bit confusing why we even look in the other ALCs - is it because we're assuming the worst case, that some other referenced assembly might get loaded in the future into the current ALC?

Copy link
Contributor Author

@BogdanZavu BogdanZavu Nov 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it may not force a load of the referenced assemblies so you may need to make that traversal yourself.

So I think we never want to force load the referenced assemblies.

is it because we're assuming the worst case, that some other referenced assembly might get loaded in the future into the current ALC?

That is indeed a possibility but actually we can't really tell for sure so I guess there's no point in issuing a warning.
So I think it's better to simplify and only look at the input ALC as @pinzart90 suggested.

@BogdanZavu BogdanZavu merged commit ab2f503 into DynamoDS:master Nov 18, 2024
23 of 24 checks passed
@BogdanZavu BogdanZavu deleted the DYN-7835 branch November 18, 2024 17:46
BogdanZavu added a commit to BogdanZavu/Dynamo that referenced this pull request Nov 18, 2024
Co-authored-by: Bogdan Zavu <[email protected]>
Co-authored-by: Trygve Wastvedt <[email protected]>
Co-authored-by: Trygve Wastvedt <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants