Make MSBuildFileSystemBase non-abstract to remove versioning and usability constraints#6475
Merged
Forgind merged 3 commits intodotnet:mainfrom May 29, 2021
Merged
Conversation
Forgind
approved these changes
May 24, 2021
Contributor
Forgind
left a comment
There was a problem hiding this comment.
Looks great! Always happy to see some code deleted 😊
cdmihai
reviewed
May 25, 2021
76b174a to
b6a357c
Compare
cdmihai
approved these changes
May 27, 2021
rainersigwald
approved these changes
May 27, 2021
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Partially fixes #6068
Context
MSBuildFileSystemBasewas introduced as a replacement ofIFileSystemin #5546. It was added as an abstract class so potentially with the same constraints as an interface:MSBuildFileSystemBaseto intercept calls or override a subset of them because the default MSBuild-provided file system is not exposed.Changes Made
To address the constraints above, I am making the class non-abstract and having it by default forward all calls to the default MSBuild file system. This way the caller may choose to override only a subset of methods (e.g. file enumeration and existence/metadata checks) leaving the rest as is (e.g. actual file reads).
As a result I was able to delete both
IFileSystemAdapter.csandMSBuildFileSystemAdapter.csbecause they're not needed anymore.The difference between
IFileSystemmethods and publicMSBuildFileSystemBasemethods was just one method having a different name. I have renamed the one on the internal interface, assuming that this does not cause any troubles with the old NuGet, as tested byTestOldNuget(). This enabled further simplification and reduce the number of the "adapter" call hops.With the changes in this PR, we have:
IFileSystem, kept around for compat reasons.MSBuildFileSystemBase, which implementsIFileSystemwith virtual methods. The class is meant to be derived from and its methods overridden.If we find ourselves adding new methods to the contract, it won't break existing
MSBuildFileSystemBasebecause the new calls will just call through to the default implementation. If the change we need to make requires an orchestrated behavior change, we can always add a virtual 'version' prop, overriding which the derived class tells us which version of the contract it supports.Testing
Existing unit test coverage.
Notes
This change is meant to be non-breaking. I'm basically just making an abstract class non-abstract (would have to be done at some point anyways if we were to add a new method). The rest of the changes are internal.