Skip to content

Remove obsolete code from tree#1148

Merged
dalyIsaac merged 5 commits intomainfrom
remove-obsoletecode-treelayout
Jul 10, 2025
Merged

Remove obsolete code from tree#1148
dalyIsaac merged 5 commits intomainfrom
remove-obsoletecode-treelayout

Conversation

@dalyIsaac
Copy link
Copy Markdown
Owner

No description provided.

@dalyIsaac dalyIsaac added refactor The code can be simplified/moved/cleaned up tree layout Whim.TreeLayout labels Jul 10, 2025
@dalyIsaac dalyIsaac requested a review from Copilot July 10, 2025 13:59
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR removes obsolete patterns in the tree layout code by introducing C# 12 collection expressions, refactoring to the new Store.Pick API for context lookups, and modernizing the test suite with a shared TreeCustomization fixture.

  • Refactor MapPickers and test code to use C# 12 collection expressions instead of .ToList()/.ToArray()
  • Update TreeLayoutPlugin and TreeLayoutEngine to use IContext.Store.Pick(...) instead of direct manager APIs
  • Modernize tests: remove LayoutEngineWrapper, adopt TreeCustomization, and apply new syntax across all layout‐engine tests

Reviewed Changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/Whim/Store/MapSector/MapPickers.cs Switched to C# 12 collection expression for monitor handles
src/Whim.TreeLayout/TreeLayoutPlugin.cs Rewrote constructor, replaced _context field and added SuppressMessage; use Store.Pick
src/Whim.TreeLayout/TreeLayoutEngine.cs Replaced direct manager calls with Store.Pick and collection expressions
src/Whim.TreeLayout/TreeLayoutCommands.cs Updated command callbacks to use Store.Pick
src/Whim.TreeLayout.Tests/Utils/TreeCustomization.cs Introduced shared test customization for tree layout tests
src/Whim.TreeLayout.Tests/Utils/LayoutEngineWrapper.cs Removed obsolete test helper
src/Whim.TreeLayout.Tests/TreeLayoutPluginTests.cs Migrated to TreeCustomization and new collection syntax
src/Whim.TreeLayout.Tests/TreeLayoutCommandsTests.cs Adapted to fixture and store-picker pattern
src/Whim.TreeLayout.Tests/Tree/TreeHelpersTests.cs Replaced .ToArray() with [.. ] collection expression
src/Whim.TreeLayout.Tests/LayoutEngine/SwapWindowInDirectionTests.cs Updated to use TreeCustomization and new syntax
src/Whim.TreeLayout.Tests/LayoutEngine/RemoveTests.cs Ditto
src/Whim.TreeLayout.Tests/LayoutEngine/PropertiesTests.cs Ditto
src/Whim.TreeLayout.Tests/LayoutEngine/PerformCustomActionTests.cs Ditto
src/Whim.TreeLayout.Tests/LayoutEngine/MoveWindowToPointTests.cs Ditto
src/Whim.TreeLayout.Tests/LayoutEngine/MoveWindowEdgesInDirectionTests.cs Ditto
src/Whim.TreeLayout.Tests/LayoutEngine/MinimizeWindowTests.cs Ditto
src/Whim.TreeLayout.Tests/LayoutEngine/GetFirstWindowTests.cs Ditto
src/Whim.TreeLayout.Tests/LayoutEngine/FocusWindowInDirectionTests.cs Ditto
src/Whim.TreeLayout.Tests/LayoutEngine/DoLayoutTests.cs Ditto
src/Whim.TreeLayout.Tests/LayoutEngine/BaseTests.cs Removed obsolete base test
src/Whim.TreeLayout.Tests/LayoutEngine/AddWindowTests.cs Ditto
src/Whim.TestUtils/Whim.TestUtils.csproj Added InternalsVisibleTo for TreeLayout tests
src/Whim.TestUtils/StoreTestUtils.cs Improved AddWorkspaceToManager to avoid duplicate order entries
Comments suppressed due to low confidence (2)

src/Whim/Store/MapSector/MapPickers.cs:211

  • The initializer using [ .. monitorIndices.Select(...), ] produces an array (HMONITOR[]), not a List<HMONITOR>. Either change the variable type to HMONITOR[] or wrap the collection expression in new List<HMONITOR>(...).
				List<HMONITOR> monitorHandles =

src/Whim.TreeLayout/TreeLayoutPlugin.cs:26

  • Using [] here creates an array literal, not a Dictionary<,>. Replace with new Dictionary<LayoutEngineIdentity, Direction>() to initialize the dictionary properly.
	private readonly Dictionary<LayoutEngineIdentity, Direction> _addNodeDirections = [];

@codecov
Copy link
Copy Markdown

codecov bot commented Jul 10, 2025

Codecov Report

Attention: Patch coverage is 98.03922% with 1 line in your changes missing coverage. Please review.

Project coverage is 81.11%. Comparing base (4c4eb65) to head (904ff9f).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/Whim/Store/MapSector/MapPickers.cs 83.33% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1148      +/-   ##
==========================================
+ Coverage   81.06%   81.11%   +0.05%     
==========================================
  Files         286      286              
  Lines       13148    13177      +29     
  Branches     1535     1535              
==========================================
+ Hits        10658    10689      +31     
  Misses       2288     2288              
+ Partials      202      200       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dalyIsaac dalyIsaac marked this pull request as ready for review July 10, 2025 14:01
@dalyIsaac dalyIsaac merged commit 4dbb212 into main Jul 10, 2025
11 of 12 checks passed
@dalyIsaac dalyIsaac deleted the remove-obsoletecode-treelayout branch July 10, 2025 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor The code can be simplified/moved/cleaned up tree layout Whim.TreeLayout

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants