Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5886f88

Browse filesBrowse files
committed
Fixing build warnings and errors
1 parent 5f1f2f0 commit 5886f88
Copy full SHA for 5886f88

File tree

2 files changed

+16
-3
lines changed
Filter options

2 files changed

+16
-3
lines changed

‎Source/Common/SchemaEnumJsonConverter{T}.cs

Copy file name to clipboardExpand all lines: Source/Common/SchemaEnumJsonConverter{T}.cs
+14-1Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ public SchemaEnumJsonConverter()
4141
/// <returns>The enumeration value.</returns>
4242
public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
4343
{
44+
if (typeToConvert is null)
45+
{
46+
throw new ArgumentNullException(nameof(typeToConvert));
47+
}
48+
4449
var valueString = reader.GetString();
4550
if (EnumHelper.TryParseEnumFromSchemaUri(typeToConvert, valueString, out var result))
4651
{
@@ -56,6 +61,14 @@ public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerial
5661
/// <param name="writer">The JSON writer.</param>
5762
/// <param name="value">The enumeration value.</param>
5863
/// <param name="options">The JSON serializer options.</param>
59-
public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options) => writer.WriteStringValue(this.valueNameMap[value]);
64+
public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
65+
{
66+
if (writer is null)
67+
{
68+
throw new ArgumentNullException(nameof(writer));
69+
}
70+
71+
writer.WriteStringValue(this.valueNameMap[value]);
72+
}
6073
}
6174
}

‎Source/Common/ValuesJsonConverter.cs

Copy file name to clipboardExpand all lines: Source/Common/ValuesJsonConverter.cs
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ public virtual void WriteObject(Utf8JsonWriter writer, object? value, JsonSerial
177177
}
178178
else if (value is decimal decimalNumber)
179179
{
180-
//TODO: Potential unnecessary allocation - may be able to write to a stackalloc span.
180+
// TODO: Potential unnecessary allocation - may be able to write to a stackalloc span.
181181
writer.WriteRawValue(decimalNumber.ToString("G0", CultureInfo.InvariantCulture));
182182
}
183183
else if (value is double doubleNumber)
@@ -407,7 +407,7 @@ private static bool TryGetConcreteType(
407407
try
408408
{
409409
var localType = Type.GetType(typeName, false);
410-
if (typeof(IThing).IsAssignableFrom(localType))
410+
if (localType is not null && typeof(IThing).IsAssignableFrom(localType))
411411
{
412412
type = localType;
413413
return true;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.