Code Quality: Replaced manual DP definitions in the Sidebar controls with the Toolkit's source generator #17865
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.
Vision towards NativeAOT in the Sidebar functionalities
The current Quick Access helper and its watcher is powered by the reflection-based
Activatorto instantiate the Quick Access'sIShellFolderto enumerate Quick Access items instead of Win32CoCreateInstancedue to UWP limitations. This is now blocking us from leveraging NAOT for faster startup and Trimming for a smaller package size.I have already refactored the codebase of the Home page, which is relatively ready for the next Storage Abstraction concept. However, that of the Sidebar controls is not yet at all, which is overly complicated and requires to a major refactoring for the NAOT/Trimming adoption.
The first example of the complication is the specifically implemented receivers of events that come from Quick Access, Drives, etc.
Files/src/Files.App/ViewModels/UserControls/SidebarViewModel.cs
Lines 607 to 633 in 868a6f1
Secondly, the decoupled control
SidebarViewtakes a view model for it. We should be passing references to DPs controlled in theMainPageViewModelinstead of having a dedicated view model for this control.Files/src/Files.App/Views/MainPage.xaml
Lines 176 to 187 in 868a6f1
Thirdly,
SidebarViewis aUserControlinstead of a control that derives fromControl, so-called being a custom control. As aforementioned, since the control depends on an instance of a dedicated view model, there's a strong bond between this control and the view model. We should make use of events instead and isolate the control from the implementation details of the view model.Files/src/Files.App.Controls/Sidebar/SidebarView.xaml.cs
Line 14 in 868a6f1
With these reasons, we should be going to refactor the sidebar implementations to get rid of the view model reference and to implement better bindings of sidebar items collection. This PR is the first one of the series of improvements, the next one would refactor the sidebar item models and probably replace the view model.
Resolved / Related Issues
Steps used to test these changes
Since this has no functionality change, this PR can be validated by just deploying and running the app.