Add more preferences for configuring openapi search paths#424
Add more preferences for configuring openapi search paths#424tlmii merged 2 commits intodotnet:masterfrom
Conversation
| public ApiConnection(IPreferences preferences, IWritable logger, bool logVerboseMessages, IOpenApiSearchPathsProvider? openApiSearchPaths = null) | ||
| { | ||
| _preferences = preferences ?? throw new ArgumentNullException(nameof(preferences)); | ||
| _ = preferences ?? throw new ArgumentNullException(nameof(preferences)); |
There was a problem hiding this comment.
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.
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 |
| return DefaultSearchPaths.Union(addToSearchPaths).Except(removeFromSearchPaths); | ||
| } | ||
|
|
||
| private static string[] Split(string searchPaths) |
There was a problem hiding this comment.
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.
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 |
| public FakePreferences() | ||
| { | ||
| DefaultPreferences = new Dictionary<string, string>(); | ||
| _currentPreferences = new(); |
There was a problem hiding this comment.
What is this madness...Can you link me to this C# feature?
There was a problem hiding this comment.
C# 9 feature. What's new in C# 9 and Updated new operator docs
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.