Repository navigation
fix(ssh): resize the PTY via public API, and cache DataGrid row-key lookups - #13
Open
xiaochengzjc wants to merge 2 commits into
Open
xiaochengzjc wants to merge 2 commits into
xiaochengzjc wants to merge 2 commits into
Conversation
added 2 commits
November 30, 2026 17:34
Reaching into SSH.NET's private _channel field and invoking SendWindowChangeRequest by reflection broke whenever the library reshaped its internals, and reflection is unavailable under NativeAOT. ShellStream exposes ChangeWindowSize publicly, so call it directly.
RebuildKeyMap runs on every selection query and scanned the item type with up to eight GetProperty calls per row, so selection cost grew with the number of properties rather than the number of rows. Resolve the nested and direct key properties once per type and reuse them, keeping the existing key format of type:property:value:instance-hash. Adds coverage for the nested, direct and no-key fallbacks.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two small, independent cleanups lifted out of #6 (thanks @heartacker). Both keep existing behaviour; neither touches the RDP bridge or persistence.
1. SSH terminal resize no longer uses reflection (
Services/SshConnectionService.cs)ResizeTerminalwas reaching into SSH.NET's private_channelfield and invoking the privateSendWindowChangeRequestby reflection, with a hand-written error message when the internals did not match.ShellStream.ChangeWindowSize(columns, rows, pixelWidth, pixelHeight)is public API on the pinnedSSH.NET 2026.0.1, takes the same arguments in the same order, and issues the same PTY window-change request — so this is a drop-in replacement that removes 34 lines and oneusing System.Reflection;.The reflection path also cannot survive NativeAOT, so this is a prerequisite for any future AOT work.
2. DataGrid row-key properties are resolved once per item type (
Controls/DataGridSourceAdapter.cs)RebuildKeyMapruns on every selection query (TryGetItem,GetKey,GetSelectedItems,GetCurrentItem,SetSelectedItems), and for each row it scanned the item type for up to three nested key properties plus five direct ones — up to eightType.GetPropertycalls per row, per query. A 1,000-row session list meant thousands of redundant reflection lookups on every click.The key plan (nested candidates, direct candidates, resolved
Idproperty per nested type) is now cached in aConcurrentDictionarykeyed by runtime type. The generated key format is unchanged:so persisted/explicit row keys stay valid across the two implementations.
Verification
dotnet build -c Release: 0 warnings, 0 errorsdotnet test: 793 passed, 0 failedCxShell.Tests/DataGridSourceAdapterTests.cspin the nested-key, direct-key and no-key-fallback paths, each asserting that selecting one row returns exactly that row (the previous reflection scan and the cache must agree).Not included
Everything else in #6 either already exists on
master(H.264/AVC444, dirty-rect copy, CLIPRDR /LockClipboardData,RdpDpiPolicy, IME focus handling, the multi-tab workspace window, .NET 11) or is part of the NativeAOT refactor, which is being evaluated separately.