Skip to content

Commit e7c4c72

Browse files
committed
Core - Remove Cookie.Creation/LastAccessed setters
Resolves #3741
1 parent e03b166 commit e7c4c72

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

CefSharp.Core.Runtime/Internals/TypeConversion.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,8 @@ namespace CefSharp
288288
cookie->Path = StringUtils::ToClr(cefCookie.path);
289289
cookie->Secure = cefCookie.secure == 1;
290290
cookie->HttpOnly = cefCookie.httponly == 1;
291-
cookie->Creation = ConvertCefTimeToDateTime(cefCookie.creation);
292-
cookie->LastAccess = ConvertCefTimeToDateTime(cefCookie.last_access);
291+
cookie->SetCreationDate(ConvertCefTimeToDateTime(cefCookie.creation));
292+
cookie->SetLastAccessDate(ConvertCefTimeToDateTime(cefCookie.last_access));
293293
cookie->SameSite = (CefSharp::Enums::CookieSameSite)cefCookie.same_site;
294294
cookie->Priority = (CefSharp::Enums::CookiePriority)cefCookie.priority;
295295

CefSharp/Cookie.cs

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
44

55
using System;
6+
using System.ComponentModel;
67
using System.Diagnostics;
78
using CefSharp.Enums;
89

@@ -49,11 +50,11 @@ public sealed class Cookie
4950
/// <summary>
5051
/// The cookie creation date. This is automatically populated by the system on cookie creation.
5152
/// </summary>
52-
public DateTime Creation { get; set; }
53+
public DateTime Creation { get; private set; }
5354
/// <summary>
5455
/// The cookie last access date. This is automatically populated by the system on access.
5556
/// </summary>
56-
public DateTime LastAccess { get; set; }
57+
public DateTime LastAccess { get; private set; }
5758
/// <summary>
5859
/// Same site.
5960
/// </summary>
@@ -62,5 +63,35 @@ public sealed class Cookie
6263
/// Priority
6364
/// </summary>
6465
public CookiePriority Priority { get; set; }
66+
67+
/// <summary>
68+
/// Used internally to set <see cref="Creation"/>.
69+
/// <see cref="Creation"/> can only be set when fecting a Cookie from Chromium
70+
/// </summary>
71+
/// <param name="dateTime">dateTime</param>
72+
/// <remarks>
73+
/// Hidden from intellisense as only meant to be used internally, unfortunately
74+
/// VC++ makes it hard to use internal classes from C#
75+
/// </remarks>
76+
[EditorBrowsable(EditorBrowsableState.Never)]
77+
public void SetCreationDate(DateTime dateTime)
78+
{
79+
Creation = dateTime;
80+
}
81+
82+
/// <summary>
83+
/// Used internally to set <see cref="LastAccess"/>.
84+
/// <see cref="LastAccess"/> can only be set when fecting a Cookie from Chromium
85+
/// </summary>
86+
/// <param name="dateTime">dateTime</param>
87+
/// <remarks>
88+
/// Hidden from intellisense as only meant to be used internally, unfortunately
89+
/// VC++ makes it hard to use internal classes from C#
90+
/// </remarks>
91+
[EditorBrowsable(EditorBrowsableState.Never)]
92+
public void SetLastAccessDate(DateTime dateTime)
93+
{
94+
LastAccess = dateTime;
95+
}
6596
}
6697
}

0 commit comments

Comments
 (0)