Skip to content

Commit 528fb1b

Browse files
committed
chore: removes redundant null propagation operator
Signed-off-by: Vincent Biret <[email protected]>
1 parent 269a215 commit 528fb1b

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/Microsoft.OpenApi/Writers/OpenApiWriterAnyExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ private static void WriteObject(this IOpenApiWriter writer, JsonObject? entity)
114114

115115
private static void WritePrimitive(this IOpenApiWriter writer, JsonValue jsonValue)
116116
{
117-
if (jsonValue.TryGetValue(out string? stringValue))
117+
if (jsonValue.TryGetValue(out string? stringValue) && stringValue is not null)
118118
writer.WriteValue(stringValue);
119119
else if (jsonValue.TryGetValue(out DateTime dateTimeValue))
120120
writer.WriteValue(dateTimeValue.ToString("o", CultureInfo.InvariantCulture)); // ISO 8601 format

src/Microsoft.OpenApi/Writers/OpenApiYamlWriter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public override void WritePropertyName(string name)
170170
/// <param name="value">The string value.</param>
171171
public override void WriteValue(string value)
172172
{
173-
if (!UseLiteralStyle || value?.IndexOfAny(new[] { '\n', '\r' }) == -1)
173+
if (!UseLiteralStyle || value.IndexOfAny(['\n', '\r']) == -1)
174174
{
175175
WriteValueSeparator();
176176

@@ -190,7 +190,7 @@ public override void WriteValue(string value)
190190
WriteChompingIndicator(value);
191191

192192
// Write indentation indicator when it starts with spaces
193-
if (value is not null && value.StartsWith(" ", StringComparison.OrdinalIgnoreCase))
193+
if (value[0] == ' ')
194194
{
195195
Writer.Write(IndentationString.Length);
196196
}

0 commit comments

Comments
 (0)