-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Avoid a first-chance FileNotFoundException when a ruleset include is not found. #34696
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
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.
Is there even a reason to have a separate function here? There appears to be only a single caller.
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.
Agree with the premise of the change. But given there is a single caller think it would be simpler to just inline this changed method. Makes it clearer this has no other impact on the code.
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.
Good point, I've inlined the method.
|
@dotnet/roslyn-compiler for review |
AlekseyTs
left a comment
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 (iteration 2)
…not found. When a .ruleset file includes a non-existing ruleset reference we receive null from ResolveIncludePath and throw a FileNotFoundException, which is the immediately caught in LoadRuleSet. We can avoid the first-chance exception and the associated allocations if we just return null. A missing ruleset is not an exceptional situation so no need to use exceptions for control flow here if we can avoid it.
f6764ff to
96d5ee0
Compare
|
@mavasani is there a way to reset the integration tests? Wondering if anything else is blocking merging this. Thanks! |
|
@KirillOsenkov You can manually do a Retry by following the failure links: I have kicked it off for you here. |
|
It's green! Who can help merge this? |
|
@agocke, did you want to take a look at this PR? |
|
Let's merge this? |
|
@KirillOsenkov Done, thanks! |

When a .ruleset file includes a non-existing ruleset reference we receive null from ResolveIncludePath and throw a FileNotFoundException, which is the immediately caught in LoadRuleSet.
We can avoid the first-chance exception and the associated allocations if we just return null. A missing ruleset is not an exceptional situation so no need to use exceptions for control flow here if we can avoid it.
This is not blocking anything and not urgent, I was just passing by and noticed this and decided to fix.