Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/Microsoft.OpenApi/Attributes/TrimmingAttributes.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

#nullable enable

// This collection of attribute definitions are helpers for accessing trim-related attributes in
// projects targeting .NET 6 or lower. Since the trimmer queries for these attributes by name, having
// these attributes source included is sufficient for the trimmer to recognize them. For more information
Expand Down Expand Up @@ -339,7 +337,7 @@
/// bitwise combination of its member values.
/// </summary>
[Flags]
internal enum DynamicallyAccessedMemberTypes

Check warning on line 340 in src/Microsoft.OpenApi/Attributes/TrimmingAttributes.cs

View workflow job for this annotation

GitHub Actions / Build

Remove the 'FlagsAttribute' from this enum. (https://rules.sonarsource.com/csharp/RSPEC-4070)
{
/// <summary>
/// Specifies no members.
Expand Down
3 changes: 0 additions & 3 deletions src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
/// </summary>
public static class OpenApiTypeMapper
{
#nullable enable
/// <summary>
/// Maps a JsonSchema data type to an identifier.
/// </summary>
Expand Down Expand Up @@ -75,8 +74,6 @@
return schemaType.ToIdentifiersInternal().Single();
}

#nullable restore

/// <summary>
/// Converts a schema type's identifier into the enum equivalent
/// </summary>
Expand All @@ -89,7 +86,7 @@
"null" => JsonSchemaType.Null,
"boolean" => JsonSchemaType.Boolean,
"integer" or "int" => JsonSchemaType.Integer,
"number" or "double" or "float" or "decimal"=> JsonSchemaType.Number,

Check warning on line 89 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Build

Define a constant instead of using this literal 'double' 7 times. (https://rules.sonarsource.com/csharp/RSPEC-1192)

Check warning on line 89 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Build

Define a constant instead of using this literal 'float' 5 times. (https://rules.sonarsource.com/csharp/RSPEC-1192)
"string" => JsonSchemaType.String,
"array" => JsonSchemaType.Array,
"object" => JsonSchemaType.Object,
Expand Down Expand Up @@ -122,14 +119,14 @@
{
[typeof(bool)] = () => new() { Type = JsonSchemaType.Boolean },
[typeof(byte)] = () => new() { Type = JsonSchemaType.String, Format = "byte" },
[typeof(int)] = () => new() { Type = JsonSchemaType.Integer, Format = "int32" },

Check warning on line 122 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Build

Define a constant instead of using this literal 'int32' 6 times. (https://rules.sonarsource.com/csharp/RSPEC-1192)
[typeof(uint)] = () => new() { Type = JsonSchemaType.Integer, Format = "int32" },
[typeof(long)] = () => new() { Type = JsonSchemaType.Integer, Format = "int64" },

Check warning on line 124 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Build

Define a constant instead of using this literal 'int64' 6 times. (https://rules.sonarsource.com/csharp/RSPEC-1192)
[typeof(ulong)] = () => new() { Type = JsonSchemaType.Integer, Format = "int64" },
[typeof(float)] = () => new() { Type = JsonSchemaType.Number, Format = "float" },
[typeof(double)] = () => new() { Type = JsonSchemaType.Number, Format = "double" },
[typeof(decimal)] = () => new() { Type = JsonSchemaType.Number, Format = "double" },
[typeof(DateTime)] = () => new() { Type = JsonSchemaType.String, Format = "date-time" },

Check warning on line 129 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

View workflow job for this annotation

GitHub Actions / Build

Define a constant instead of using this literal 'date-time' 6 times. (https://rules.sonarsource.com/csharp/RSPEC-1192)
[typeof(DateTimeOffset)] = () => new() { Type = JsonSchemaType.String, Format = "date-time" },
[typeof(Guid)] = () => new() { Type = JsonSchemaType.String, Format = "uuid" },
[typeof(char)] = () => new() { Type = JsonSchemaType.String },
Expand Down
2 changes: 0 additions & 2 deletions src/Microsoft.OpenApi/Models/OpenApiComponents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
using Microsoft.OpenApi.Models.References;
using Microsoft.OpenApi.Writers;

#nullable enable

namespace Microsoft.OpenApi.Models
{
/// <summary>
Expand Down
2 changes: 0 additions & 2 deletions src/Microsoft.OpenApi/Models/OpenApiDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
using Microsoft.OpenApi.Services;
using Microsoft.OpenApi.Writers;

#nullable enable

namespace Microsoft.OpenApi.Models
{
/// <summary>
Expand Down
2 changes: 0 additions & 2 deletions src/Microsoft.OpenApi/Models/OpenApiMediaType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
using Microsoft.OpenApi.Models.Interfaces;
using Microsoft.OpenApi.Writers;

#nullable enable

namespace Microsoft.OpenApi.Models
{
/// <summary>
Expand Down
2 changes: 0 additions & 2 deletions src/Microsoft.OpenApi/Models/OpenApiOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
using Microsoft.OpenApi.Models.References;
using Microsoft.OpenApi.Writers;

#nullable enable

namespace Microsoft.OpenApi.Models
{
/// <summary>
Expand Down
2 changes: 0 additions & 2 deletions src/Microsoft.OpenApi/Models/OpenApiReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
/// <summary>
/// The OpenApiDocument that is hosting the OpenApiReference instance. This is used to enable dereferencing the reference.
/// </summary>
public OpenApiDocument? HostDocument { get => hostDocument; init => hostDocument = value; }

Check warning on line 74 in src/Microsoft.OpenApi/Models/OpenApiReference.cs

View workflow job for this annotation

GitHub Actions / Build

Make this an auto-implemented property and remove its backing field. (https://rules.sonarsource.com/csharp/RSPEC-2292)

/// <summary>
/// Gets the full reference string for v3.0.
Expand Down Expand Up @@ -281,10 +281,8 @@
Utils.CheckArgumentNull(currentDocument);
hostDocument ??= currentDocument;
}
#nullable enable
private static string? GetPropertyValueFromNode(JsonObject jsonObject, string key) =>
jsonObject.TryGetPropertyValue(key, out var valueNode) && valueNode is JsonValue valueCast && valueCast.TryGetValue<string>(out var strValue) ? strValue : null;
#nullable restore
internal void SetSummaryAndDescriptionFromMapNode(MapNode mapNode)
{
var (description, summary) = mapNode.JsonNode switch {
Expand Down
2 changes: 0 additions & 2 deletions src/Microsoft.OpenApi/OpenApiTagComparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Microsoft.OpenApi;

#nullable enable
/// <summary>
/// This comparer is used to maintain a globally unique list of tags encountered
/// in a particular OpenAPI document.
Expand Down Expand Up @@ -44,4 +43,3 @@ public bool Equals(IOpenApiTag? x, IOpenApiTag? y)
/// <inheritdoc/>
public int GetHashCode(IOpenApiTag obj) => string.IsNullOrEmpty(obj?.Name) ? 0 : StringComparer.GetHashCode(obj!.Name);
}
#nullable restore
2 changes: 0 additions & 2 deletions src/Microsoft.OpenApi/Services/OpenApiWalker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ internal void Walk(OpenApiExternalDocs? externalDocs)

_visitor.Visit(externalDocs);
}
#nullable enable
/// <summary>
/// Visits <see cref="OpenApiComponents"/> and child objects
/// </summary>
Expand Down Expand Up @@ -256,7 +255,6 @@ internal void Walk(OpenApiComponents? components)
Walk(components as IOpenApiExtensible);
}

#nullable restore
/// <summary>
/// Visits <see cref="OpenApiPaths"/> and child objects
/// </summary>
Expand Down
2 changes: 0 additions & 2 deletions src/Microsoft.OpenApi/Services/OpenApiWorkspace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
/// Registers a document's components into the workspace
/// </summary>
/// <param name="document"></param>
public void RegisterComponents(OpenApiDocument document)

Check warning on line 64 in src/Microsoft.OpenApi/Services/OpenApiWorkspace.cs

View workflow job for this annotation

GitHub Actions / Build

Refactor this method to reduce its Cognitive Complexity from 31 to the 15 allowed. (https://rules.sonarsource.com/csharp/RSPEC-3776)
{
if (document?.Components == null) return;

Expand Down Expand Up @@ -281,7 +281,6 @@
return _IOpenApiReferenceableRegistry.ContainsKey(key) || _artifactsRegistry.ContainsKey(key);
}

#nullable enable
/// <summary>
/// Resolves a reference given a key.
/// </summary>
Expand All @@ -307,7 +306,6 @@

return default;
}
#nullable restore

private Uri? ToLocationUrl(string location)
{
Expand Down
2 changes: 0 additions & 2 deletions src/Microsoft.OpenApi/Writers/OpenApiWriterExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
/// <param name="writer">The writer.</param>
/// <param name="name">The property name.</param>
/// <param name="value">The property value.</param>
public static void WriteProperty(this IOpenApiWriter writer, string name, string? value)

Check warning on line 24 in src/Microsoft.OpenApi/Writers/OpenApiWriterExtensions.cs

View workflow job for this annotation

GitHub Actions / Build

All 'WriteProperty' method overloads should be adjacent. (https://rules.sonarsource.com/csharp/RSPEC-4136)
{
if (value == null)
{
Expand Down Expand Up @@ -126,7 +126,6 @@
writer.WriteValue(value);
}

#nullable enable
/// <summary>
/// Write the optional Open API object/element.
/// </summary>
Expand Down Expand Up @@ -179,7 +178,6 @@
writer.WriteEndObject();
}
}
#nullable restore

/// <summary>
/// Write the optional of collection string.
Expand Down Expand Up @@ -245,7 +243,7 @@
/// <param name="name">The property name.</param>
/// <param name="elements">The map values.</param>
/// <param name="action">The map element writer action.</param>
public static void WriteRequiredMap(

Check warning on line 246 in src/Microsoft.OpenApi/Writers/OpenApiWriterExtensions.cs

View workflow job for this annotation

GitHub Actions / Build

All 'WriteRequiredMap' method overloads should be adjacent. (https://rules.sonarsource.com/csharp/RSPEC-4136)
this IOpenApiWriter writer,
string name,
IDictionary<string, string>? elements,
Expand Down