Skip to content

Commit 5e06f1e

Browse files
committed
Remove serialization restrictions on RemoteSessionSettings.AddMetadataSetting
1 parent 9eb1afa commit 5e06f1e

File tree

1 file changed

+3
-67
lines changed

1 file changed

+3
-67
lines changed

dotnet/src/webdriver/Remote/RemoteSessionSettings.cs

Lines changed: 3 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -116,18 +116,10 @@ public object this[string capabilityName]
116116
/// </summary>
117117
/// <param name="settingName">The name of the setting to set.</param>
118118
/// <param name="settingValue">The value of the setting.</param>
119-
/// <remarks>
120-
/// The value to be set must be serializable to JSON for transmission
121-
/// across the wire to the remote end. To be JSON-serializable, the value
122-
/// must be a string, a numeric value, a boolean value, an object that
123-
/// implmeents <see cref="IEnumerable"/> that contains JSON-serializable
124-
/// objects, or a <see cref="Dictionary{TKey, TValue}"/> where the keys
125-
/// are strings and the values are JSON-serializable.
126-
/// </remarks>
127119
/// <exception cref="ArgumentException">
128-
/// Thrown if the setting name is null, the empty string, or one of the
129-
/// reserved names of metadata settings; or if the setting value is not
130-
/// JSON serializable.
120+
/// <para>If the setting name is null or empty.</para>
121+
/// <para>-or-</para>
122+
/// <para>If one of the reserved names of metadata settings.</para>
131123
/// </exception>
132124
public void AddMetadataSetting(string settingName, object settingValue)
133125
{
@@ -141,11 +133,6 @@ public void AddMetadataSetting(string settingName, object settingValue)
141133
throw new ArgumentException(string.Format("'{0}' is a reserved name for a metadata setting, and cannot be used as a name.", settingName), nameof(settingName));
142134
}
143135

144-
if (!IsJsonSerializable(settingValue))
145-
{
146-
throw new ArgumentException("Metadata setting value must be JSON serializable.", nameof(settingValue));
147-
}
148-
149136
this.remoteMetadataSettings[settingName] = settingValue;
150137
}
151138

@@ -300,56 +287,5 @@ private List<object> GetFirstMatchOptionsAsSerializableList()
300287

301288
return optionsMatches;
302289
}
303-
304-
private static bool IsJsonSerializable(object arg)
305-
{
306-
if (arg is null)
307-
{
308-
return true;
309-
}
310-
311-
if (arg is string or float or double or int or long or bool)
312-
{
313-
return true;
314-
}
315-
316-
if (arg is JsonNode or JsonElement)
317-
{
318-
return true;
319-
}
320-
321-
if (arg is IDictionary argAsDictionary)
322-
{
323-
foreach (DictionaryEntry item in argAsDictionary)
324-
{
325-
if (item.Key is not string)
326-
{
327-
return false;
328-
}
329-
330-
if (!IsJsonSerializable(item.Value))
331-
{
332-
return false;
333-
}
334-
}
335-
336-
return true;
337-
}
338-
339-
if (arg is IEnumerable argAsEnumerable)
340-
{
341-
foreach (object item in argAsEnumerable)
342-
{
343-
if (!IsJsonSerializable(item))
344-
{
345-
return false;
346-
}
347-
}
348-
349-
return true;
350-
}
351-
352-
return false;
353-
}
354290
}
355291
}

0 commit comments

Comments
 (0)