-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Fixed misleading exception when configuration file is excluded #54717
Conversation
The `PhysicalFileProvider.GetFileInfo(string)` method would previously return a `NotFoundFileInfo` if it found a file that matched the provided `ExclusionFilter`. This is misleading as the file may in fact be reachable, just excluded.
Note regarding the This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change. |
Tagging subscribers to this area: @maryamariyan, @dotnet/area-extensions-filesystem Issue DetailsThe
|
ExcludedFileInfo
Hi @YuKitsune To add a new public API you need to go through the API Review process first. Once you create a proposal issue the owners of the area take it to the review meeting. After the API gets approved, one can send a PR. You can read more about it here. Big thanks for you work and the PR, but for the reasons described above I have to close it until the API gets approved. |
@YuKitsune Maybe, as a simper intermediate fix, the same exception but with a proper message could be thrown? |
Thanks @adamsitnik @SingleAccretion Huh, don't know why I didn't think of that first... That does sound much nicer. |
@YuKitsune For just improving an exception message you can open a PR without creating an issue first. If you would like to change the exception type, which would be a breaking change, we would need an issue first. |
@adamsitnik Thanks for clarifying! New PR on the way 🙂 |
The
PhysicalFileProvider.GetFileInfo(string)
method currently returns aNotFoundFileInfo
if it the file matches any of the providedExclusionFilter
flags. This results in aFileNotFoundException
being thrown when trying to load a file using theFileConfigurationProvider
.Example:
This is misleading as the file may in fact be reachable, but excluded using the
ExclusionFilter
flags.I spent some time trying to figure out why my own app couldn't find the
.env
file I had specified, only to realise after reading the source code for the PhysicalFileProvider that it could have been found if it was not being excluded.This PR introduces an
ExcludedFileInfo
and aFileExcludedException
to provide better feedback when a file has been intentionally excluded.