Feature: Add Shell-compatible file transfer - #17
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
ItemPropertiesViewModel.CanRename can report rename support even when no IStorageOperationService is available, leading to a predictable apply-time failure instead of disabling rename up front.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR tightens the “storage boundary” in the WinUI app layers by preventing direct physical filesystem probing (e.g., File.Exists, Directory.Exists) in Files, Files.Controls, and Files.Operations, pushing that access behind storage abstractions/adapters and enforcing the rule via Banned API analyzers.
Changes:
- Introduces repo-wide Banned API enforcement (RS0030 as error) for selected projects using
Microsoft.CodeAnalysis.BannedApiAnalyzers+BannedSymbols.txt. - Refactors item properties to isolate filesystem metadata/attribute work behind
IItemPropertiesFileSystemand routes rename throughIStorageOperationService. - Removes/avoids direct filesystem probes in clipboard prep, sidebar drag setup, command-state evaluation, and removes
Files.Operations’s on-disk debug logging; ensuresFiles.Operationsis built in CI.
File summaries
| File | Description |
|---|---|
| tests/Files.UITests/PresentationTests/ItemPropertiesViewModelTests.cs | Updates rename test to assert rename is routed via IStorageOperationService. |
| src/Files/ViewModels/FolderBrowserViewModel.cs | Reworks copy/paste and “current folder” checks to avoid filesystem probing; removes byte-count probing. |
| src/Files/MainWindow.xaml.cs | Wires IStorageOperationService into ItemPropertiesService. |
| src/Files/ItemProperties/ItemPropertiesWindow.xaml.cs | Passes storage ops + filesystem adapter into the view model. |
| src/Files/ItemProperties/ItemPropertiesViewModel.cs | Uses filesystem adapter for metadata/attribute operations and storage ops for rename. |
| src/Files/ItemProperties/ItemPropertiesService.cs | Stores and supplies storage ops + filesystem adapter for item properties windows. |
| src/Files/ItemProperties/ItemPropertiesFileSystem.cs | New adapter encapsulating the (now-isolated) direct filesystem/Win32 work for item properties. |
| src/Files/Infrastructure/FileClipboard.cs | Changes clipboard API to accept typed sources (path + folder flag) instead of probing existence. |
| src/Files.Operations/Program.cs | Removes automatic debug_server.log write; uses Debug.WriteLine instead. |
| src/Files.Operations/Helpers.cs | Adds missing System using (consistency/compilation hygiene). |
| src/Files.Operations/AppInstanceMonitor.cs | Adds missing System/Threading usings. |
| src/Files.Controls/Sidebar/SidebarItem.cs | Removes directory probing before drag storage item setup. |
| Directory.Packages.props | Adds Microsoft.CodeAnalysis.BannedApiAnalyzers package version. |
| Directory.Build.props | Enables storage-boundary enforcement for selected projects and adds analyzer configuration. |
| BannedSymbols.txt | Defines banned filesystem APIs and guidance messages. |
| .github/workflows/ci.yml | Adds a build step for Files.Operations to ensure enforcement applies in CI. |
Review details
- Files reviewed: 16/16 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| public bool HasFolders => _hasFolders; | ||
|
|
||
| public bool IsSingleFile => _fileSystemPaths.Count is 1 && File.Exists(_fileSystemPaths[0]); | ||
| public bool IsSingleFile => _isSingleFile; |
e6c131e to
989fcfd
Compare
989fcfd to
d910434
Compare
Summary
Files,Files.Controls, andFiles.Operationswith Banned API analyzers, while keeping stream contracts, I/O exceptions, and lexicalPathoperations available.StorageFile/StorageFolderpath conversion from clipboard and drag-and-drop code.IDataObjectselection used by Explorer, including Shell namespace and virtual items, and preserve preferred drop effects and asynchronous clipboard behavior.DataPackagebridge; forward the raw native data object through ShellIDropTargetsessions for folder views, item handlers, the sidebar, and breadcrumbs.pastecommand so delayed, virtual, and handler-specific formats are not filtered by the app.IStorageOperationService, and remove the operation server's automaticdebug_server.logwrite.Resolved / Related Issues
Steps used to test these changes
OpenClipboardwith error 5.IDropTargetlifecycle and modifier negotiation, preferred effects, async data-object behavior, and the inbox ZIP Shell extension.DataPackageto native ShellIDataObject/IDropTargetbridge ten times: 10/10 passed.File,Directory,StorageFile.GetFileFromPathAsync, andStorageFolder.GetFolderFromPathAsyncin each enforced project. All 12 usages were rejected withRS0030; the probes were then removed..exe,.dll, and.winmd, and completed final static checks for CRLF, line length, XML documentation, conflict markers, banned API leakage, andgit diff --check.The packaged-app, cross-process Explorer interaction matrix still requires an interactive Windows session with package registration enabled. In particular, right-drag menus, drag cancellation/hover behavior, elevated targets, OneDrive/MTP/network locations, and third-party Shell extensions remain manual end-to-end checks.