Skip to content

Conversation

@daxian-dbw
Copy link
Member

@daxian-dbw daxian-dbw commented Jun 10, 2021

PR Summary

Fixes #15535

AppDomain.CreateAppDomain and AppDomain.Unload were used for binary module analysis originally -- loading the binary module into another AppDomain so the analysis doesn't pollute the current app domain. However, the code path was disabled when moving to .NET Core because there has been only one AppDomain since the beginning in .NET Core.

That code path was for analyzing a DLL module (without a module manifest .psd1 file), and it's really not that useful in real world scenarios because all modules should have a module manifest file, which defines what commands are exposed from the module. Therefore, nothing is really affected even though that code path was disabled since 2016.

This cleanup removed that code path that creates an AppDomain all together, as well as the relevant code for cleaning up the AppDomain.

Also, a simple NullReferenceException is fixed in Parser.ParseInput.

PR Checklist

@daxian-dbw
Copy link
Member Author

daxian-dbw commented Jun 10, 2021

It's easier to review by ignoring the white space changes: https://github.com/PowerShell/PowerShell/pull/15554/files?w=1

GitHub
PR Summary Address #15535 AppDomain.CreateAppDomain and AppDomain.Unload were used for binary module analysis originally -- loading the binary module into another AppDomain so the analysis doesn�...

@iSazonov iSazonov added the CL-CodeCleanup Indicates that a PR should be marked as a Code Cleanup change in the Change Log label Jun 10, 2021
Copy link
Collaborator

@rjmholt rjmholt left a comment

Choose a reason for hiding this comment

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

Also a note: .NET has made it possible to analyse an assembly safely again with the MetadataLoadContext. See #6653.

@rjmholt rjmholt merged commit e2ee8e7 into PowerShell:master Jun 10, 2021
@daxian-dbw daxian-dbw deleted the nullref branch June 10, 2021 16:18
@ghost
Copy link

ghost commented Jun 17, 2021

🎉v7.2.0-preview.7 has been released which incorporates this pull request.:tada:

Handy links:

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

Labels

CL-CodeCleanup Indicates that a PR should be marked as a Code Cleanup change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AppDomain.Unload usage is deprecated and should be removed

3 participants