Skip to content

Conversation

@sqljeff
Copy link

@sqljeff sqljeff commented Jan 20, 2026

Summary

This PR adds full support for displaying icons when working with file and folder objects from PowerShell remoting sessions. When users run commands like Invoke-Command or Enter-PSSession, objects are deserialized during transmission, changing their type names to Deserialized.System.IO.DirectoryInfo and Deserialized.System.IO.FileInfo. Previously, Terminal-Icons did not handle these deserialized objects correctly.

Problem

When using Terminal-Icons with remote PowerShell sessions, users encountered issues because:

  • The format.ps1xml file did not recognize deserialized type names
  • Direct property access failed on deserialized objects (properties may be missing or behave differently)
  • Parameter validation rejected deserialized objects as they didn't match [IO.FileSystemInfo] type

Solution

This PR implements comprehensive support for deserialized objects through:

  1. Format File Updates - Added deserialized type names to the SelectionSet
  2. Safe Property Access - Implemented null-safe property access patterns throughout Resolve-Icon
  3. Flexible Parameter Validation - Updated parameter types to accept both local and deserialized objects
  4. Helper Function - Created Test-DeserializedFileSystemInfo for detecting deserialized objects
  5. Comprehensive Testing - Added 14 new unit tests covering all scenarios
  6. Documentation - Updated README with remoting examples and usage guidance

Changes Made

Modified Files

  • Terminal-Icons.format.ps1xml - Added deserialized type names to SelectionSet
  • Terminal-Icons/Private/Resolve-Icon.ps1 - Safe property access for all FileSystemInfo properties
  • Terminal-Icons/Public/Format-TerminalIcons.ps1 - Updated parameter validation and help text
  • README.md - Added "PowerShell Remoting Support" section with examples
  • tests/unit/Format-TerminalIcons.tests.ps1 - Added 6 tests for deserialized objects

New Files

  • Terminal-Icons/Private/Test-DeserializedFileSystemInfo.ps1 - Helper function for detection
  • tests/unit/Test-DeserializedFileSystemInfo.tests.ps1 - 8 new unit tests

Testing

Unit Tests

All existing tests pass, plus 14 new tests specifically for remoting scenarios:

Invoke-Pester ./tests/unit/Format-TerminalIcons.tests.ps1
Invoke-Pester ./tests/unit/Test-DeserializedFileSystemInfo.tests.ps1

Manual Testing

Test with actual PowerShell remoting:

# Import the module
Import-Module Terminal-Icons

# Test with remote session
Invoke-Command -ComputerName YourServer -ScriptBlock { Get-ChildItem }

# Test with interactive session
Enter-PSSession -ComputerName YourServer
Get-ChildItem

Backward Compatibility

✅ All changes are fully backward compatible
✅ Existing functionality for local files preserved
✅ No breaking changes to public APIs
✅ All existing tests continue to pass

Checklist

  • Code follows project style and conventions
  • Comprehensive unit tests added
  • Documentation updated with examples
  • Backward compatibility maintained
  • All tests passing

🤖 Generated with Claude Code

…emoting

This change enables Terminal-Icons to work seamlessly with file and folder
objects returned from remote PowerShell sessions (Invoke-Command, Enter-PSSession).

When objects cross PowerShell remoting boundaries, they are deserialized and
their type names become "Deserialized.System.IO.DirectoryInfo" and
"Deserialized.System.IO.FileInfo". These objects behave differently from
local FileSystemInfo objects, requiring special handling.

Changes:
- Updated format.ps1xml to recognize deserialized type names in SelectionSet
- Added Test-DeserializedFileSystemInfo helper function for object detection
- Updated Resolve-Icon with safe property access patterns for all FileSystemInfo properties
- Updated Format-TerminalIcons parameter validation to accept deserialized objects
- Added comprehensive unit tests for deserialized object handling (14 new tests)
- Updated README with PowerShell remoting examples and documentation

All changes are backward compatible and preserve existing functionality for
local file system operations.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
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