Skip to content

Bound member invocation logging argument strings#27511

Closed
KirtiRamchandani wants to merge 1 commit into
PowerShell:masterfrom
KirtiRamchandani:codex/bound-member-invocation-logging
Closed

Bound member invocation logging argument strings#27511
KirtiRamchandani wants to merge 1 commit into
PowerShell:masterfrom
KirtiRamchandani:codex/bound-member-invocation-logging

Conversation

@KirtiRamchandani
Copy link
Copy Markdown

PR Summary

Bounds long string values included in member invocation logging while preserving the method invocation and recording the original string length.

PR Context

Addresses #21473.

MemberInvocationLoggingOps.ArgumentToString() currently returns full string arguments, so LogMemberInvocation() can build very large AMSI report content for calls such as FromBase64String with large strings. This change keeps short strings unchanged, truncates long strings to 4096 characters, and appends a marker with the original length. It also applies the same bound to special primitive-like ToString() results, such as very large BigInteger values.

PR Checklist

  • PR has a meaningful title
  • Summarized changes
  • This PR is focused on one issue
  • Make sure all .h, .cpp, .cs, .ps1 and .psm1 files have the correct copyright header
  • This PR is ready to merge and is not work-in-progress
  • Breaking change: No
  • User-facing change: Not required
  • Tests added/updated

Validation

  • Start-PSBuild -Clean -PSModuleRestore -UseNuGetOrg built pwsh.exe. The first local build surfaced analyzer CA1845 for string construction; the patch was updated to use span-based string.Concat. The follow-up build produced pwsh.exe; the Windows PowerShell 5.1 build wrapper emitted post-build ConvertFrom-Json -Depth compatibility warnings after build output was produced.
  • Start-PSPester -Path test/powershell/engine/Logging/MemberInvocationLogging.Tests.ps1 -UseNuGetOrg -ThrowOnFailure -Terse -SkipTestToolBuild passed: 2 passed, 0 failed.

@KirtiRamchandani
Copy link
Copy Markdown
Author

Closing in favor of replacement draft PR from neutral branch: #27513

@KirtiRamchandani KirtiRamchandani deleted the codex/bound-member-invocation-logging branch May 24, 2026 07:28
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.

1 participant