Skip to content

Commit 6bfb270

Browse files
authored
Camel Case the world (#769)
1 parent 547e178 commit 6bfb270

File tree

81 files changed

+288
-492
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+288
-492
lines changed

lib/PuppeteerSharp.DevicesFetcher/Models.cs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,31 @@ namespace PuppeteerSharp.DevicesFetcher
44
{
55
public class RootObject
66
{
7-
[JsonProperty("extensions")]
87
public Extension[] Extensions { get; set; }
98

109
public class Extension
1110
{
12-
[JsonProperty("type")]
1311
public string Type { get; set; }
14-
[JsonProperty("device")]
1512
public Device Device { get; set; }
1613
}
1714

1815
public class Device
1916
{
2017
[JsonProperty("show-by-default")]
2118
public bool ShowByDefault { get; set; }
22-
[JsonProperty("title")]
2319
public string Title { get; set; }
24-
[JsonProperty("screen")]
2520
public Screen Screen { get; set; }
26-
[JsonProperty("capabilities")]
2721
public string[] Capabilities { get; set; }
2822
[JsonProperty("user-agent")]
2923
public string UserAgent { get; set; }
30-
[JsonProperty("type")]
31-
public string Type { get; set; }
24+
public string Type { get; set; }
3225
}
3326

3427
public class Screen
3528
{
36-
[JsonProperty("horizontal")]
3729
public ViewportPayload Horizontal { get; set; }
3830
[JsonProperty("device-pixel-ratio")]
3931
public double DevicePixelRatio { get; set; }
40-
[JsonProperty("vertical")]
4132
public ViewportPayload Vertical { get; set; }
4233
}
4334
}

lib/PuppeteerSharp.DevicesFetcher/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Threading.Tasks;
88
using Newtonsoft.Json;
99
using Newtonsoft.Json.Linq;
10+
using Newtonsoft.Json.Serialization;
1011

1112
namespace PuppeteerSharp.DevicesFetcher
1213
{

lib/PuppeteerSharp.DevicesFetcher/ViewportPayload.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ namespace PuppeteerSharp.DevicesFetcher
44
{
55
public class ViewportPayload
66
{
7-
[JsonProperty("width")]
87
public double Width { get; set; }
9-
10-
[JsonProperty("height")]
118
public double Height { get; set; }
129
}
1310
}

lib/PuppeteerSharp.Tests/InputTests/Dimensions.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,9 @@ namespace PuppeteerSharp.Tests.InputTests
55
{
66
public class Dimensions
77
{
8-
[JsonProperty("x")]
98
public decimal X { get; set; }
10-
[JsonProperty("y")]
119
public decimal Y { get; set; }
12-
[JsonProperty("width")]
1310
public decimal Width { get; set; }
14-
[JsonProperty("height")]
1511
public decimal Height { get; set; }
1612
}
1713
}

lib/PuppeteerSharp.Tests/PageTests/EvaluateTests.cs

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
1+
using System.Collections.Generic;
42
using System.Threading.Tasks;
3+
using Newtonsoft.Json;
54
using Newtonsoft.Json.Linq;
65
using Xunit;
76
using Xunit.Abstractions;
7+
using PuppeteerSharp.Helpers;
88

99
namespace PuppeteerSharp.Tests.PageTests
1010
{
@@ -69,6 +69,24 @@ public async Task SouldReturnComplexObjects()
6969
Assert.Equal("bar!", result.foo.ToString());
7070
}
7171

72+
[Fact]
73+
public async Task ShouldWorkWithDifferentSerializerSettings()
74+
{
75+
var result = await Page.EvaluateFunctionAsync<ComplexObjectTestClass>("() => { return { foo: 'bar' }}");
76+
Assert.Equal("bar", result.Foo);
77+
78+
result = (await Page.EvaluateFunctionAsync<JToken>("() => { return { Foo: 'bar' }}"))
79+
.ToObject<ComplexObjectTestClass>(new JsonSerializerSettings());
80+
Assert.Equal("bar", result.Foo);
81+
82+
result = await Page.EvaluateExpressionAsync<ComplexObjectTestClass>("var obj = { foo: 'bar' }; obj;");
83+
Assert.Equal("bar", result.Foo);
84+
85+
result = (await Page.EvaluateExpressionAsync<JToken>("var obj = { Foo: 'bar' }; obj;"))
86+
.ToObject<ComplexObjectTestClass>(new JsonSerializerSettings());
87+
Assert.Equal("bar", result.Foo);
88+
}
89+
7290
[Theory]
7391
[InlineData("() => NaN", double.NaN)] //ShouldReturnNaN
7492
[InlineData("() => -0", -0)] //ShouldReturnNegative0
@@ -265,5 +283,10 @@ public async Task ShouldWorkWithoutGenerics()
265283
Assert.Equal(11111111111111, await Page.EvaluateExpressionAsync("11111111111111"));
266284
Assert.Equal(1.1, await Page.EvaluateExpressionAsync("1.1"));
267285
}
286+
287+
public class ComplexObjectTestClass
288+
{
289+
public string Foo { get; set; }
290+
}
268291
}
269292
}

lib/PuppeteerSharp.Tests/TargetTests/CreateCDPSessionTests.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
53
using System.Threading.Tasks;
64
using Newtonsoft.Json.Linq;
75
using Xunit;

lib/PuppeteerSharp.sln

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
# Visual Studio 15
33
VisualStudioVersion = 15.0.27703.2035
44
MinimumVisualStudioVersion = 10.0.40219.1
5-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PuppeteerSharp", "PuppeteerSharp\PuppeteerSharp.csproj", "{19B9B1ED-AF6C-4DAF-8B73-401570111F88}"
5+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PuppeteerSharp", "PuppeteerSharp\PuppeteerSharp.csproj", "{19B9B1ED-AF6C-4DAF-8B73-401570111F88}"
66
EndProject
7-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PuppeteerSharp.Tests", "PuppeteerSharp.Tests\PuppeteerSharp.Tests.csproj", "{1682289E-5ED3-405F-8ABC-01A3ED58CBC6}"
7+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PuppeteerSharp.Tests", "PuppeteerSharp.Tests\PuppeteerSharp.Tests.csproj", "{1682289E-5ED3-405F-8ABC-01A3ED58CBC6}"
88
EndProject
9-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PuppeteerSharp.TestServer", "PuppeteerSharp.TestServer\PuppeteerSharp.TestServer.csproj", "{0CC393AB-10C2-4CDB-8353-78924D3DD5D3}"
9+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PuppeteerSharp.TestServer", "PuppeteerSharp.TestServer\PuppeteerSharp.TestServer.csproj", "{0CC393AB-10C2-4CDB-8353-78924D3DD5D3}"
1010
EndProject
11-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PuppeteerSharp.Tests.DumpIO", "PuppeteerSharp.Tests.DumpIO\PuppeteerSharp.Tests.DumpIO.csproj", "{B1892212-CEE3-4DC3-ADB8-04A2D9A081A0}"
11+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PuppeteerSharp.Tests.DumpIO", "PuppeteerSharp.Tests.DumpIO\PuppeteerSharp.Tests.DumpIO.csproj", "{B1892212-CEE3-4DC3-ADB8-04A2D9A081A0}"
1212
EndProject
13-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PuppeteerSharp.Tests.CloseMe", "PuppeteerSharp.Tests.CloseMe\PuppeteerSharp.Tests.CloseMe.csproj", "{B1B0358F-88A2-4038-9974-7850D906C76B}"
13+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PuppeteerSharp.Tests.CloseMe", "PuppeteerSharp.Tests.CloseMe\PuppeteerSharp.Tests.CloseMe.csproj", "{B1B0358F-88A2-4038-9974-7850D906C76B}"
1414
EndProject
1515
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PuppeteerSharp.DevicesFetcher", "PuppeteerSharp.DevicesFetcher\PuppeteerSharp.DevicesFetcher.csproj", "{A500694A-3649-4474-BC71-C835FA19B865}"
1616
EndProject

lib/PuppeteerSharp/BoundingBox.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,21 @@ public class BoundingBox : IEquatable<BoundingBox>
1313
/// The x coordinate of the element in pixels.
1414
/// </summary>
1515
/// <value>The x.</value>
16-
[JsonProperty("x")]
1716
public decimal X { get; set; }
1817
/// <summary>
1918
/// The y coordinate of the element in pixels.
2019
/// </summary>
2120
/// <value>The y.</value>
22-
[JsonProperty("y")]
2321
public decimal Y { get; set; }
2422
/// <summary>
2523
/// The width of the element in pixels.
2624
/// </summary>
2725
/// <value>The width.</value>
28-
[JsonProperty("width")]
2926
public decimal Width { get; set; }
3027
/// <summary>
3128
/// The height of the element in pixels.
3229
/// </summary>
3330
/// <value>The height.</value>
34-
[JsonProperty("height")]
3531
public decimal Height { get; set; }
3632

3733
/// <summary>

lib/PuppeteerSharp/Browser.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public Browser(
152152
/// <summary>
153153
/// Dafault wait time in milliseconds. Defaults to 30 seconds.
154154
/// </summary>
155-
public int DefaultWaitForTimeout { get; set; } = 30000;
155+
public int DefaultWaitForTimeout { get; set; } = 30000;
156156

157157
#endregion
158158

@@ -397,15 +397,15 @@ private async void Connect_MessageReceived(object sender, MessageEventArgs e)
397397
switch (e.MessageID)
398398
{
399399
case "Target.targetCreated":
400-
await CreateTargetAsync(e.MessageData.ToObject<TargetCreatedResponse>()).ConfigureAwait(false);
400+
await CreateTargetAsync(e.MessageData.ToObject<TargetCreatedResponse>(true)).ConfigureAwait(false);
401401
return;
402402

403403
case "Target.targetDestroyed":
404-
await DestroyTargetAsync(e.MessageData.ToObject<TargetDestroyedResponse>()).ConfigureAwait(false);
404+
await DestroyTargetAsync(e.MessageData.ToObject<TargetDestroyedResponse>(true)).ConfigureAwait(false);
405405
return;
406406

407407
case "Target.targetInfoChanged":
408-
ChangeTargetInfo(e.MessageData.ToObject<TargetCreatedResponse>());
408+
ChangeTargetInfo(e.MessageData.ToObject<TargetCreatedResponse>(true));
409409
return;
410410
}
411411
}

lib/PuppeteerSharp/CDPSession.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using Microsoft.Extensions.Logging;
88
using Newtonsoft.Json;
99
using Newtonsoft.Json.Linq;
10+
using Newtonsoft.Json.Serialization;
1011
using PuppeteerSharp.Helpers;
1112
using PuppeteerSharp.Messaging;
1213

@@ -118,7 +119,7 @@ public async Task<T> SendAsync<T>(string method, dynamic args = null)
118119
{
119120
JObject content = await SendAsync(method, args).ConfigureAwait(false);
120121

121-
return content.ToObject<T>();
122+
return content.ToObject<T>(true);
122123
}
123124

124125
/// <summary>
@@ -147,7 +148,8 @@ public async Task<JObject> SendAsync(string method, dynamic args = null, bool wa
147148
{ MessageKeys.Id, id },
148149
{ MessageKeys.Method, method },
149150
{ MessageKeys.Params, args }
150-
});
151+
}, JsonHelper.DefaultJsonSerializerSettings);
152+
151153
_logger.LogTrace("Send ► {Id} Method {Method} Params {@Params}", id, method, (object)args);
152154

153155
MessageTask callback = null;

0 commit comments

Comments
 (0)