Skip to content

Commit ace4bff

Browse files
authored
Addressing left over review comments from #1641 (#1650)
## Why make this change? - Accidentally completed the PR #1641 before pushing the last commit that addressed review comments. I had it on my local branch, but forgot to push before merging in. This PR is to push those left over review comments into main.
1 parent ecc0778 commit ace4bff

3 files changed

Lines changed: 18 additions & 17 deletions

File tree

src/Config/Converters/EntityGraphQLOptionsConverterFactory.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public EntityGraphQLOptionsConverter(bool replaceEnvVar)
4848
/// <inheritdoc/>
4949
public override EntityGraphQLOptions? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
5050
{
51-
if (reader.TokenType == JsonTokenType.StartObject)
51+
if (reader.TokenType is JsonTokenType.StartObject)
5252
{
5353
string singular = string.Empty;
5454
string plural = string.Empty;
@@ -57,7 +57,7 @@ public EntityGraphQLOptionsConverter(bool replaceEnvVar)
5757

5858
while (reader.Read())
5959
{
60-
if (reader.TokenType == JsonTokenType.EndObject)
60+
if (reader.TokenType is JsonTokenType.EndObject)
6161
{
6262
return new EntityGraphQLOptions(singular, plural, enabled, operation);
6363
}
@@ -71,20 +71,20 @@ public EntityGraphQLOptionsConverter(bool replaceEnvVar)
7171
enabled = reader.GetBoolean();
7272
break;
7373
case "type":
74-
if (reader.TokenType == JsonTokenType.String)
74+
if (reader.TokenType is JsonTokenType.String)
7575
{
7676
singular = reader.DeserializeString(_replaceEnvVar) ?? string.Empty;
7777
}
78-
else if (reader.TokenType == JsonTokenType.StartObject)
78+
else if (reader.TokenType is JsonTokenType.StartObject)
7979
{
8080
while (reader.Read())
8181
{
82-
if (reader.TokenType == JsonTokenType.EndObject)
82+
if (reader.TokenType is JsonTokenType.EndObject)
8383
{
8484
break;
8585
}
8686

87-
if (reader.TokenType == JsonTokenType.PropertyName)
87+
if (reader.TokenType is JsonTokenType.PropertyName)
8888
{
8989
string? property2 = reader.GetString();
9090
reader.Read();
@@ -124,17 +124,17 @@ public EntityGraphQLOptionsConverter(bool replaceEnvVar)
124124
}
125125
}
126126

127-
if (reader.TokenType == JsonTokenType.True)
127+
if (reader.TokenType is JsonTokenType.True)
128128
{
129129
return new EntityGraphQLOptions(Singular: string.Empty, Plural: string.Empty, Enabled: true);
130130
}
131131

132-
if (reader.TokenType == JsonTokenType.False || reader.TokenType == JsonTokenType.Null)
132+
if (reader.TokenType is JsonTokenType.False || reader.TokenType is JsonTokenType.Null)
133133
{
134134
return new EntityGraphQLOptions(Singular: string.Empty, Plural: string.Empty, Enabled: false);
135135
}
136136

137-
if (reader.TokenType == JsonTokenType.String)
137+
if (reader.TokenType is JsonTokenType.String)
138138
{
139139
string? singular = reader.DeserializeString(_replaceEnvVar);
140140
return new EntityGraphQLOptions(singular ?? string.Empty, string.Empty);

src/Config/Converters/EntityRestOptionsConverterFactory.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ public EntityRestOptionsConverter(bool replaceEnvVar)
4848
/// <inheritdoc/>
4949
public override EntityRestOptions? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
5050
{
51-
if (reader.TokenType == JsonTokenType.StartObject)
51+
if (reader.TokenType is JsonTokenType.StartObject)
5252
{
5353
EntityRestOptions restOptions = new(Methods: Array.Empty<SupportedHttpVerb>(), Path: null, Enabled: true);
5454
while (reader.Read())
5555
{
56-
if (reader.TokenType == JsonTokenType.EndObject)
56+
if (reader.TokenType is JsonTokenType.EndObject)
5757
{
5858
break;
5959
}
@@ -66,7 +66,7 @@ public EntityRestOptionsConverter(bool replaceEnvVar)
6666
{
6767
reader.Read();
6868

69-
if (reader.TokenType == JsonTokenType.String || reader.TokenType == JsonTokenType.Null)
69+
if (reader.TokenType is JsonTokenType.String || reader.TokenType is JsonTokenType.Null)
7070
{
7171
restOptions = restOptions with { Path = reader.DeserializeString(_replaceEnvVar) };
7272
break;
@@ -80,12 +80,12 @@ public EntityRestOptionsConverter(bool replaceEnvVar)
8080
List<SupportedHttpVerb> methods = new();
8181
while (reader.Read())
8282
{
83-
if (reader.TokenType == JsonTokenType.StartArray)
83+
if (reader.TokenType is JsonTokenType.StartArray)
8484
{
8585
continue;
8686
}
8787

88-
if (reader.TokenType == JsonTokenType.EndArray)
88+
if (reader.TokenType is JsonTokenType.EndArray)
8989
{
9090
break;
9191
}
@@ -112,12 +112,12 @@ public EntityRestOptionsConverter(bool replaceEnvVar)
112112
return restOptions;
113113
}
114114

115-
if (reader.TokenType == JsonTokenType.String)
115+
if (reader.TokenType is JsonTokenType.String)
116116
{
117117
return new EntityRestOptions(Array.Empty<SupportedHttpVerb>(), reader.DeserializeString(_replaceEnvVar), true);
118118
}
119119

120-
if (reader.TokenType == JsonTokenType.True || reader.TokenType == JsonTokenType.False)
120+
if (reader.TokenType is JsonTokenType.True || reader.TokenType is JsonTokenType.False)
121121
{
122122
bool enabled = reader.GetBoolean();
123123
return new EntityRestOptions(

src/Service.Tests/Unittests/RuntimeConfigLoaderJsonDeserializerTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public void CheckConfigEnvParsingTest(
8989
else
9090
{
9191
Assert.IsTrue(RuntimeConfigLoader.TryParseConfig(
92-
GetModifiedJsonString(repKeys, @"""@env('enumVarName')"""), out expectedConfig, replaceEnvVar: replaceEnvVar),
92+
GetModifiedJsonString(repKeys, @"""mssql"""), out expectedConfig, replaceEnvVar: replaceEnvVar),
9393
"Should read the expected config");
9494
}
9595

@@ -208,6 +208,7 @@ private static void SetEnvVariables()
208208
/// fashion.
209209
/// </summary>
210210
/// <param name="reps">Replacement strings.</param>
211+
/// <param name="enumString">Replacement string to use for a test enum.</param>
211212
/// <returns>Json string with replacements.</returns>
212213
public static string GetModifiedJsonString(string[] reps, string enumString)
213214
{

0 commit comments

Comments
 (0)