Skip to content

Commit edc95ed

Browse files
committed
Merge remote-tracking branch 'upstream/vnext' into use-pattern-matching-in-casts
2 parents c4f02da + 170ee50 commit edc95ed

File tree

68 files changed

+594
-566
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+594
-566
lines changed

src/Microsoft.OpenApi.Hidi/Formatters/PowerShellFormatter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ private void AddAdditionalPropertiesToSchema(OpenApiSchema schema)
179179
{
180180
if (schema != null && !_schemaLoop.Contains(schema) && "object".Equals(schema.Type, StringComparison.OrdinalIgnoreCase))
181181
{
182-
schema.AdditionalProperties = new OpenApiSchema() { Type = "object" };
182+
schema.AdditionalProperties = new OpenApiSchema { Type = "object" };
183183

184184
/* Because 'additionalProperties' are now being walked,
185185
* we need a way to keep track of visited schemas to avoid

src/Microsoft.OpenApi.Hidi/OpenApiService.cs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ private static void WriteOpenApi(HidiOptions options, OpenApiFormat openApiForma
186186
using var outputStream = options.Output.Create();
187187
using var textWriter = new StreamWriter(outputStream);
188188

189-
var settings = new OpenApiWriterSettings()
189+
var settings = new OpenApiWriterSettings
190190
{
191191
InlineLocalReferences = options.InlineLocal,
192192
InlineExternalReferences = options.InlineExternal
@@ -510,13 +510,15 @@ private static async Task<Stream> GetStream(string input, ILogger logger, Cancel
510510
var fileInput = new FileInfo(input);
511511
stream = fileInput.OpenRead();
512512
}
513-
catch (Exception ex) when (ex is FileNotFoundException ||
514-
ex is PathTooLongException ||
515-
ex is DirectoryNotFoundException ||
516-
ex is IOException ||
517-
ex is UnauthorizedAccessException ||
518-
ex is SecurityException ||
519-
ex is NotSupportedException)
513+
catch (Exception ex) when (
514+
ex is
515+
FileNotFoundException or
516+
PathTooLongException or
517+
DirectoryNotFoundException or
518+
IOException or
519+
UnauthorizedAccessException or
520+
SecurityException or
521+
NotSupportedException)
520522
{
521523
throw new InvalidOperationException($"Could not open the file at {input}", ex);
522524
}
@@ -738,7 +740,7 @@ internal static async Task PluginManifest(HidiOptions options, ILogger logger, C
738740
WriteOpenApi(options, OpenApiFormat.Json, OpenApiSpecVersion.OpenApi3_0, document, logger);
739741

740742
// Create OpenAIPluginManifest from ApiDependency and OpenAPI document
741-
var manifest = new OpenAIPluginManifest()
743+
var manifest = new OpenAIPluginManifest
742744
{
743745
NameForHuman = document.Info.Title,
744746
DescriptionForHuman = document.Info.Description,

src/Microsoft.OpenApi.Hidi/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ static async Task<int> Main(string[] args)
2222

2323
internal static RootCommand CreateRootCommand()
2424
{
25-
var rootCommand = new RootCommand() { };
25+
var rootCommand = new RootCommand { };
2626

2727
var commandOptions = new CommandOptions();
2828

src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public async Task<ReadResult> ReadAsync(YamlDocument input, CancellationToken ca
133133
}
134134
}
135135

136-
return new ReadResult()
136+
return new ReadResult
137137
{
138138
OpenApiDocument = document,
139139
OpenApiDiagnostic = diagnostic
@@ -148,7 +148,7 @@ private async Task<OpenApiDiagnostic> LoadExternalRefs(OpenApiDocument document,
148148
// Load this root document into the workspace
149149
var streamLoader = new DefaultStreamLoader(_settings.BaseUrl);
150150
var workspaceLoader = new OpenApiWorkspaceLoader(openApiWorkSpace, _settings.CustomExternalLoader ?? streamLoader, _settings);
151-
return await workspaceLoader.LoadAsync(new OpenApiReference() { ExternalResource = "/" }, document, cancellationToken);
151+
return await workspaceLoader.LoadAsync(new OpenApiReference { ExternalResource = "/" }, document, cancellationToken);
152152
}
153153

154154
private void ResolveReferences(OpenApiDiagnostic diagnostic, OpenApiDocument document)

src/Microsoft.OpenApi.Readers/ParseNodes/MapNode.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public override Dictionary<string, T> CreateMapWithReference<T>(
120120
// If the component isn't a reference to another component, then point it to itself.
121121
if (entry.value.Reference == null)
122122
{
123-
entry.value.Reference = new OpenApiReference()
123+
entry.value.Reference = new OpenApiReference
124124
{
125125
Type = referenceType,
126126
Id = entry.key
@@ -183,7 +183,7 @@ public override string GetRaw()
183183
public T GetReferencedObject<T>(ReferenceType referenceType, string referenceId)
184184
where T : IOpenApiReferenceable, new()
185185
{
186-
return new T()
186+
return new T
187187
{
188188
UnresolvedReference = true,
189189
Reference = Context.VersionService.ConvertToOpenApiReference(referenceId, referenceType)

src/Microsoft.OpenApi.Readers/ParseNodes/OpenApiAnyConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public static IOpenApiAny GetSpecificOpenApiAny(IOpenApiAny openApiAny, OpenApiS
116116
return openApiAny;
117117
}
118118

119-
if (value == null || value == "null")
119+
if (value is null or "null")
120120
{
121121
return new OpenApiNull();
122122
}

src/Microsoft.OpenApi.Readers/ParseNodes/ValueNode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public override string GetScalarValue()
3434
public override IOpenApiAny CreateAny()
3535
{
3636
var value = GetScalarValue();
37-
return new OpenApiString(value, this._node.Style == ScalarStyle.SingleQuoted || this._node.Style == ScalarStyle.DoubleQuoted || this._node.Style == ScalarStyle.Literal || this._node.Style == ScalarStyle.Folded);
37+
return new OpenApiString(value, this._node.Style is ScalarStyle.SingleQuoted or ScalarStyle.DoubleQuoted or ScalarStyle.Literal or ScalarStyle.Folded);
3838
}
3939
}
4040
}

src/Microsoft.OpenApi.Readers/ParsingContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ internal OpenApiDocument Parse(YamlDocument yamlDocument)
6060

6161
switch (inputVersion)
6262
{
63-
case string version when version == "2.0":
63+
case string and "2.0":
6464
VersionService = new OpenApiV2VersionService(Diagnostic);
6565
doc = VersionService.LoadDocument(RootNode);
6666
this.Diagnostic.SpecificationVersion = OpenApiSpecVersion.OpenApi2_0;

src/Microsoft.OpenApi.Readers/V2/OpenApiDocumentDeserializer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ private static string BuildUrl(string scheme, string host, string basePath)
220220
port = int.Parse(pieces.Last(), CultureInfo.InvariantCulture);
221221
}
222222

223-
var uriBuilder = new UriBuilder()
223+
var uriBuilder = new UriBuilder
224224
{
225225
Scheme = scheme,
226226
Host = host,
@@ -327,10 +327,10 @@ public override void Visit(OpenApiOperation operation)
327327
if (body != null)
328328
{
329329
operation.Parameters.Remove(body);
330-
operation.RequestBody = new OpenApiRequestBody()
330+
operation.RequestBody = new OpenApiRequestBody
331331
{
332332
UnresolvedReference = true,
333-
Reference = new OpenApiReference()
333+
Reference = new OpenApiReference
334334
{
335335
Id = body.Reference.Id,
336336
Type = ReferenceType.RequestBody

src/Microsoft.OpenApi.Readers/V2/OpenApiOperationDeserializer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,10 @@ private static OpenApiTag LoadTagByReference(
221221
ParsingContext context,
222222
string tagName)
223223
{
224-
var tagObject = new OpenApiTag()
224+
var tagObject = new OpenApiTag
225225
{
226226
UnresolvedReference = true,
227-
Reference = new OpenApiReference() { Id = tagName, Type = ReferenceType.Tag }
227+
Reference = new OpenApiReference { Id = tagName, Type = ReferenceType.Tag }
228228
};
229229

230230
return tagObject;

0 commit comments

Comments
 (0)