-
-
Notifications
You must be signed in to change notification settings - Fork 49
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
Replaced FileNotFoundException with log instead (#199) #200
Open
LennardF1989
wants to merge
2
commits into
Shazwazza:develop
Choose a base branch
from
LennardF1989:develop
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<packageSources> | ||
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" /> | ||
<add key="AspNetCiDev" value="https://www.myget.org/F/aspnetcidev/api/v3/index.json" /> | ||
<add key="XUnitDev" value="https://www.myget.org/F/xunit/api/v3/index.json" /> | ||
</packageSources> | ||
</configuration> | ||
</configuration> |
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.
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.
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.
I think this should be handled differently, now fileInfo is returned even when its useless (also in MemoryCacheFileSystem).
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.
Which is as intended, as other parts of the logic will check for
.Exists
, which is precisely what a FileInfo is for (a cheap wrapper to tell you if a file exists before attempting to open it). You also annotated the old code :)Returning null here would mean a lot more code has to be touched and double-checked.
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.
It's already documented that GetRequiredFileInfo throws:
Smidge/src/Smidge.Core/ISmidgeFileSystem.cs
Line 24 in 994e945
So this would be breaking anyway.
Not all other paths check if the file exists (only SmidgeController does):
Smidge/src/Smidge.Core/FileProcessors/PreProcessManager.cs
Line 79 in 994e945
Smidge/src/Smidge.Core/FileProcessors/CssImportProcessor.cs
Line 50 in 994e945
This would also apply to other people using the library, now it doesn't throw anymore and you need to handle it differently.
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.
Remark about breaking change is fair, the other ones are easily "fixed" by reintroducing the exception right after retrieving the IFileInfo. I will push that in a second.
The two locations you pointed out are literally the only 2 places where something is done with
GetRequiredFileInfo
. They are also only called in very specific situations:@import
in CSS and during bundle creation, both of which cannot be directly manipulated by malicious users (only malicious developers :P). That said, bundle creation would also need some love as I pointed out, but for another PR.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.
Not everyone uses Smidge as-is, some have custom implementations around it. I don't mind fixing this at all, but let's try to get consistent behavior☺️
I think it's fine not to throw anymore; then PreProcessManager can bail out, and CssImportProcessor can continue with the others.
Alternatively, SmidgeController could swallow the exception. This would be the least breaking change.
@Shazwazza what would you prefer?
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.
Yeah, i don't think we should change the behavior of this method since the meaning is in the name 'GetRequired...' ... which indicates that it will throw.
One way to be less breaking would be to have an optional overload of this like
bool throwIfNotFound = true
It is a binary breaking change, but all folks nowadays build their projects before deploying so I don't think it would cause any issues.
Else I'm fine with try/catch/swallow where necessary
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.
@LennardF1989 just wanted to ping on this one?
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.
Honestly, I forgot that I did this xD I'll put it back on my list.