-
Notifications
You must be signed in to change notification settings - Fork 755
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
File I/O Abstraction (Part I) (#15568)
This is the first PR in a series of changes to introduce a file I/O abstraction layer to the Bicep project. Currently, `Bicep.Core` heavily relies on the large `IFileSystem` interface, `System.Uri`. This tight coupling introduces several challenges, such as making it difficult for the Bicep resource provider to supply a mock implementation of `IFileSystem`. Additionally, it prevents support for VS Code virtual workspaces because `System.Uri` is surprisingly not fully RFC-compliant (see: #11467). To address these issues, a higher-level abstraction for file I/O is required. Given the broad scope of this refactoring, this PR focuses on laying the groundwork by introducing the new abstraction layer and using it to load configuration. Subsequent PRs will replace the usage of `IFileSystem` and `System.Uri` throughout Bicep.Core and tidy up the `IFileResolver` interface with the new APIs. ## Key Changes in this PR The core of this PR is the introduction of a new `Bicep.IO` project. This project defines the new file I/O abstraction layer and includes: - `Bicep.IO.Abstraction` types: - `IFileExplorer`: Encapsulates directory and file discovery. - `IFileHandle`: A pointer to a file, abstracting operations like reading or writing. - `IDirectoryHandle`: A pointer to a directory for managing directory traversal. - `ResourceIdentifier`: An RFC3986 compliant URI (without Query and Fragment) which is going to replace `System.Uri` in `Bicep.Core`. - `Bicep.IO.FileSystem` types: - Concrete implementations of the above interfaces based on `IFileSystem`. The ultimate objective is to phase out direct usage of `Bicep.IO.FileSystem` within `Bicep.Core` and restrict it to referencing only `Bicep.IO.Abstraction` via `BannedSymbols.txt`. This design ensures cleaner separation of concerns and enables better testing, security, and support for virtual environments. Below is an architecture diagram illustrating the new design and how the layers interact: <img width="1446" alt="Untitled" src="https://github.com/user-attachments/assets/a68a8c73-31ca-4b54-bb2e-d4dc221108bf"> ###### Microsoft Reviewers: [Open in CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/Azure/bicep/pull/15568)
- Loading branch information
Showing
92 changed files
with
2,077 additions
and
564 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.