-
Notifications
You must be signed in to change notification settings - Fork 654
Replace direct file system access with System.IO.Abstractions (part 2) #4443
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
replaced own IFileSystem with the one from the package replaced System.IO.(File|FileInfo|Directory|DirectoryInfo)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Overview
This PR replaces direct file system calls with abstractions from System.IO.Abstractions to improve testability and maintainability. Key changes include dependency injection updates for file system access, refactoring of utility methods to use helper methods, and updates to test files to utilize the new abstractions.
Reviewed Changes
File | Description |
---|---|
src/GitVersion.App/GlobbingResolver.cs | Changed GetDirectoryInfoWrapper from a protected virtual method to a private static method using DirectoryInfoWrapper. |
src/GitVersion.App/FileAppender.cs | Updated log file operations to use IFileSystem and injected dependency for improved file handling. |
src/GitVersion.BuildAgents.Tests/Agents/GitLabCiTests.cs | Replaced direct File calls with IFileSystem usage for file operations. |
new-cli/GitVersion.Core/CoreModule.cs | Added System.IO.Abstractions using directive to support file-system abstraction. |
src/GitVersion.App.Tests/Helpers/ProgramFixture.cs | Updated argument splitting syntax and file handling to use IFileSystem. |
src/GitVersion.App/ArgumentParser.cs | Refactored path validation and configuration file checks to use PathHelper and IFileSystem methods. |
src/GitVersion.BuildAgents.Tests/Agents/CodeBuildTests.cs | Updated test file operations to use file system abstraction methods. |
src/GitVersion.BuildAgents.Tests/Agents/JenkinsTests.cs | Modified file access in tests to utilize IFileSystem instead of static File calls. |
src/GitVersion.BuildAgents.Tests/Agents/BitBucketPipelinesTests.cs | Replaced File calls with IFileSystem-based file operations in tests. |
src/GitVersion.App/GitVersionExecutor.cs | Passed IFileSystem to logging configuration and used it for directory checks. |
src/GitVersion.BuildAgents.Tests/Agents/EnvRunTests.cs | Updated environment-related file operations to use IFileSystem. |
src/GitVersion.BuildAgents.Tests/Agents/GitHubActionsTests.cs | Updated file access and temporary file handling to use the file system abstraction. |
src/GitVersion.App.Tests/ArgumentParserTests.cs | Updated tests to create, read, and delete files via IFileSystem; note potential naming concerns in project file updates. |
src/GitVersion.BuildAgents.Tests/Agents/BuildServerBaseTests.cs | Modified inner BuildAgent class to receive IFileSystem dependency. |
src/GitVersion.App/ArgumentParserExtensions.cs | Replaced Path.DirectorySeparatorChar with PathHelper.DirectorySeparatorChar in switch argument logic. |
Copilot reviewed 111 out of 111 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (2)
src/GitVersion.App/GlobbingResolver.cs:16
- Changing GetDirectoryInfoWrapper from a protected virtual method to a private static method prevents overriding the behavior, which may impact customization or testing. Confirm that this design decision is intentional.
private static DirectoryInfoWrapper GetDirectoryInfoWrapper(string workingDirectory) => new(new DirectoryInfo(workingDirectory));
src/GitVersion.App.Tests/ArgumentParserTests.cs:327
- [nitpick] The test 'UpdateProjectFilesWithMultipleFilenames' asserts on 'UpdateAssemblyInfoFileName', which may not clearly indicate that project file updates are being validated. Consider using or introducing a more indicative property if this is not intentional.
arguments.UpdateAssemblyInfoFileName.ShouldContain(x => PathHelper.GetFileName(x).Equals("CommonAssemblyInfo.csproj"));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Thank you @arturcic for your contribution! |
🎉 This issue has been resolved in version 6.2.0 🎉 Your GitReleaseManager bot 📦🚀 |
This pull request introduces the
System.IO.Abstractions
library to the project, which affects various parts of the codebase. The changes primarily focus on replacing direct file system access with the abstractions provided by the new library. Here are the most important changes:Dependency Updates:
System.IO.Abstractions
to theDirectory.Packages.props
and relevant project files (new-cli/Directory.Packages.props
,new-cli/GitVersion.Core/GitVersion.Core.csproj
,src/Directory.Packages.props
). [1] [2] [3]Code Refactoring:
System.IO.Abstractions
Other Changes:
These changes aim to improve testability and maintainability by abstracting file system dependencies, making it easier to mock and test file operations.