File tree 3 files changed +50
-4
lines changed
3 files changed +50
-4
lines changed Original file line number Diff line number Diff line change
1
+ using System . Text . Json . Serialization ;
2
+ using PuppeteerSharp . Helpers . Json ;
3
+
1
4
namespace PuppeteerSharp
2
5
{
3
6
/// <summary>
@@ -91,7 +94,9 @@ public class CookieParam
91
94
/// <summary>
92
95
/// Cookie partition key. The site of the top-level URL the browser was visiting at the
93
96
/// start of the request to the endpoint that set the cookie. Supported only in Chrome.
97
+ /// TODO: a breaking change is needed to support other partition keys.
94
98
/// </summary>
99
+ [ JsonConverter ( typeof ( CookiePartitionKeyConverter ) ) ]
95
100
public string PartitionKey { get ; set ; }
96
101
97
102
/// <summary>
Original file line number Diff line number Diff line change
1
+ #nullable enable
2
+
3
+ using System ;
4
+ using System . Text . Json ;
5
+ using System . Text . Json . Nodes ;
6
+ using System . Text . Json . Serialization ;
7
+
8
+ namespace PuppeteerSharp . Helpers . Json
9
+ {
10
+ internal sealed class CookiePartitionKeyConverter : JsonConverter < string >
11
+ {
12
+ /// <inheritdoc cref="JsonConverter"/>
13
+ public override bool CanConvert ( Type objectType ) => typeof ( string ) . IsAssignableFrom ( objectType ) ;
14
+
15
+ /// <inheritdoc cref="JsonConverter"/>
16
+ public override string ? Read (
17
+ ref Utf8JsonReader reader ,
18
+ Type objectType ,
19
+ JsonSerializerOptions options )
20
+ {
21
+ JsonNode ? node = JsonNode . Parse ( ref reader ) ;
22
+
23
+ return node ? [ "topLevelSite" ] ? . GetValue < string > ( ) ?? null ;
24
+ }
25
+
26
+ /// <inheritdoc cref="JsonConverter"/>
27
+ public override void Write (
28
+ Utf8JsonWriter writer ,
29
+ string value ,
30
+ JsonSerializerOptions options )
31
+ {
32
+ if ( value != null && writer != null )
33
+ {
34
+ writer . WriteStartObject ( "partitionKey" ) ;
35
+ writer . WriteString ( "topLevelSite" , value ) ;
36
+ writer . WriteBoolean ( "hasCrossSiteAncestor" , false ) ;
37
+ writer . WriteEndObject ( ) ;
38
+ }
39
+ }
40
+ }
41
+ }
Original file line number Diff line number Diff line change 12
12
<Description >Headless Browser .NET API</Description >
13
13
<PackageId >PuppeteerSharp</PackageId >
14
14
<PackageReleaseNotes ></PackageReleaseNotes >
15
- <PackageVersion >20.0.1-beta1 </PackageVersion >
16
- <ReleaseVersion >20.0.1 </ReleaseVersion >
17
- <AssemblyVersion >20.0.1 </AssemblyVersion >
18
- <FileVersion >20.0.1 </FileVersion >
15
+ <PackageVersion >20.0.2 </PackageVersion >
16
+ <ReleaseVersion >20.0.2 </ReleaseVersion >
17
+ <AssemblyVersion >20.0.2 </AssemblyVersion >
18
+ <FileVersion >20.0.2 </FileVersion >
19
19
<SynchReleaseVersion >false</SynchReleaseVersion >
20
20
<StyleCopTreatErrorsAsWarnings >false</StyleCopTreatErrorsAsWarnings >
21
21
<DebugType >embedded</DebugType >
You can’t perform that action at this time.
0 commit comments