-
Notifications
You must be signed in to change notification settings - Fork 67
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
Add more preferences for configuring openapi search paths #424
Conversation
{ | ||
_preferences = preferences ?? throw new ArgumentNullException(nameof(preferences)); | ||
_ = preferences ?? throw new ArgumentNullException(nameof(preferences)); |
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.
This looks a little funky, though I understand the intent. Maybe put the ArgumentNullException check in the ctor of OpenApiSearchPathsProvider instead where it's actually used?
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'm assuming the "looks a little funky" was in reference to using the discard. According to Jimmy, it saves a few ops!
But yeah, since I also changed it to not store the value anymore and just pass it, moving it makes sense. Done.
|
||
namespace Microsoft.HttpRepl.Preferences | ||
{ | ||
internal class OpenApiSearchPathsProvider : IOpenApiSearchPathsProvider |
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.
Nit: sealed?
return DefaultSearchPaths.Union(addToSearchPaths).Except(removeFromSearchPaths); | ||
} | ||
|
||
private static string[] Split(string searchPaths) |
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 this function for exclusive use with search path preferences, or could it be useful for current other preferences or potential future ones down the line?
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'm not a huge fan of pipe- (or frankly anything-) delimited strings, so I'm hoping there won't be too many of those before we get to a better settings system. I believe this is the only use case right now.
|
||
namespace Microsoft.HttpRepl.Fakes | ||
{ | ||
public class FakePreferences : IPreferences |
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.
Nit: sealed? :P
public FakePreferences() | ||
{ | ||
DefaultPreferences = new Dictionary<string, string>(); | ||
_currentPreferences = new(); |
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.
What is this madness...Can you link me to this C# feature?
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.
C# 9 feature. What's new in C# 9 and Updated new
operator docs
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.
Looks good!
Resolves #360.
Adds two additional preferences:
swagger.addToSearchPaths
(adds the specified paths to the default list)swagger.removeFromSearchPaths
(removes the specified paths from the default list if they exist)and configures the original available preference (
swagger.searchPaths
) to override both the default list and the two new preferences.