Skip to content

Improve ALC handling - #5482

Merged
gautamdsheth merged 4 commits into
devfrom
fix/alc-conflict
Oct 3, 2026
Merged

gautamdsheth merged 4 commits into
devfrom
fix/alc-conflict

Conversation

@gautamdsheth

Copy link
Copy Markdown
Collaborator

Type

  • Bug Fix
  • New Feature
  • Sample

Related Issues?

Fixes NA

What is in this Pull Request ?

  1. The resolver only answers PnP's own requests. It's hooked into the whole process, so before this change it gave our bundled DLLs (Microsoft.Extensions.*, MSAL and others) to any module that failed to load an assembly we ship, such as Az or Graph. That mixes PnP's private versions into other modules. Now it only answers for assemblies PnP.PowerShell.dll references directly (s_referencedAssemblyNames) and returns null for everything else, so other modules fall back to their normal loading.
  2. The import script doesn't leave variables behind. RegisterPnPAssemblyResolver.ps1 runs in the user's session, so $moduleRoot, $assembly and the others used to stay in the session after Import-Module. Its body now runs in a child scope (& { ... }), so those variables disappear.

Copilot AI balanced review requested due to automatic review settings October 3, 2026 19:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The process-wide resolver still cannot distinguish PnP requests from identical assembly requests made by other modules.

Review effort: Balanced
Findings: 1 High severity

Open (1)
What changed in this PR

This PR attempts to reduce cross-module assembly conflicts and prevent resolver variables leaking into user sessions.

Changes:

  • Filters default-context resolution by PnP’s direct assembly references.
  • Runs the resolver bootstrap script in a child scope.
File Description
src/​Commands/​Base/​PnPPowerShellModuleInitializer.cs Adds the assembly-name resolution filter.
resources/​RegisterPnPAssemblyResolver.ps1 Isolates bootstrap variables in child scope.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/Commands/Base/PnPPowerShellModuleInitializer.cs Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Matching assembly name and version cannot guarantee that a process-wide resolution request originated from PnP.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
Resolved since last review (1)

Comment thread src/Commands/Base/PnPPowerShellModuleInitializer.cs
@gautamdsheth
gautamdsheth merged commit e18a00f into dev Oct 3, 2026
3 checks passed
@gautamdsheth
gautamdsheth deleted the fix/alc-conflict branch October 5, 2026 19:24
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.

2 participants