Skip to content

Commit d7a011c

Browse files
committed
[dotnet] [bidi] Reuse RegExpValue in script Local/Remote values
1 parent 9e627ac commit d7a011c

File tree

6 files changed

+29
-16
lines changed

6 files changed

+29
-16
lines changed

dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs

-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ namespace OpenQA.Selenium.BiDi.Communication.Json;
4141
[JsonSerializable(typeof(Modules.Script.ObjectRemoteValue))]
4242
[JsonSerializable(typeof(Modules.Script.FunctionRemoteValue))]
4343
[JsonSerializable(typeof(Modules.Script.RegExpRemoteValue))]
44-
[JsonSerializable(typeof(Modules.Script.RegExpRemoteValue.RegExpValue), TypeInfoPropertyName = "Script_RegExpRemoteValue_RegExpValue")]
4544
[JsonSerializable(typeof(Modules.Script.DateRemoteValue))]
4645
[JsonSerializable(typeof(Modules.Script.MapRemoteValue))]
4746
[JsonSerializable(typeof(Modules.Script.SetRemoteValue))]

dotnet/src/webdriver/BiDi/Modules/Script/LocalValue.cs

+1-7
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,6 @@ public record MapLocalValue(IEnumerable<IEnumerable<LocalValue>> Value) : LocalV
112112

113113
public record ObjectLocalValue(IEnumerable<IEnumerable<LocalValue>> Value) : LocalValue;
114114

115-
public record RegExpLocalValue(RegExpLocalValue.RegExpValue Value) : LocalValue
116-
{
117-
public record RegExpValue(string Pattern)
118-
{
119-
public string? Flags { get; set; }
120-
}
121-
}
115+
public record RegExpLocalValue(RegExpValue Value) : LocalValue;
122116

123117
public record SetLocalValue(IEnumerable<LocalValue> Value) : LocalValue;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// <copyright file="RegExpValue.cs" company="Selenium Committers">
2+
// Licensed to the Software Freedom Conservancy (SFC) under one
3+
// or more contributor license agreements. See the NOTICE file
4+
// distributed with this work for additional information
5+
// regarding copyright ownership. The SFC licenses this file
6+
// to you under the Apache License, Version 2.0 (the
7+
// "License"); you may not use this file except in compliance
8+
// with the License. You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing,
13+
// software distributed under the License is distributed on an
14+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
// KIND, either express or implied. See the License for the
16+
// specific language governing permissions and limitations
17+
// under the License.
18+
// </copyright>
19+
20+
namespace OpenQA.Selenium.BiDi.Modules.Script;
21+
22+
public record RegExpValue(string Pattern)
23+
{
24+
public string? Flags { get; set; }
25+
}

dotnet/src/webdriver/BiDi/Modules/Script/RemoteValue.cs

+1-6
Original file line numberDiff line numberDiff line change
@@ -141,16 +141,11 @@ public record FunctionRemoteValue : RemoteValue
141141
public InternalId? InternalId { get; set; }
142142
}
143143

144-
public record RegExpRemoteValue(RegExpRemoteValue.RegExpValue Value) : RemoteValue
144+
public record RegExpRemoteValue(RegExpValue Value) : RemoteValue
145145
{
146146
public Handle? Handle { get; set; }
147147

148148
public InternalId? InternalId { get; set; }
149-
150-
public record RegExpValue(string Pattern)
151-
{
152-
public string? Flags { get; set; }
153-
}
154149
}
155150

156151
public record DateRemoteValue(string Value) : RemoteValue

dotnet/test/common/BiDi/Script/CallFunctionLocalValueTest.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ await context.Script.CallFunctionAsync($$"""
281281
[Test]
282282
public void CanCallFunctionWithArgumentRegExp()
283283
{
284-
var arg = new RegExpLocalValue(new RegExpLocalValue.RegExpValue("foo*") { Flags = "g" });
284+
var arg = new RegExpLocalValue(new RegExpValue("foo*") { Flags = "g" });
285285

286286
Assert.That(async () =>
287287
{

dotnet/test/common/BiDi/Script/CallFunctionRemoteValueTest.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ public async Task CanCallFunctionAndReturnRegExp()
177177
var response = await context.Script.CallFunctionAsync("() => { return /foo*/g; }", false);
178178

179179
Assert.That(response.Result, Is.AssignableTo<RegExpRemoteValue>());
180-
Assert.That(response.Result, Is.EqualTo(new RegExpRemoteValue(new RegExpRemoteValue.RegExpValue("foo*") { Flags = "g" })));
180+
Assert.That(response.Result, Is.EqualTo(new RegExpRemoteValue(new RegExpValue("foo*") { Flags = "g" })));
181181
}
182182

183183
[Test]

0 commit comments

Comments
 (0)