Skip to content

Commit f1fce52

Browse files
committed
Annotate CDP as AOT-unsafe
1 parent ba85340 commit f1fce52

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

dotnet/src/webdriver/DevTools/DevToolsSession.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
using OpenQA.Selenium.Internal.Logging;
2121
using System;
2222
using System.Collections.Concurrent;
23+
using System.Diagnostics.CodeAnalysis;
2324
using System.Globalization;
2425
using System.Net.Http;
2526
using System.Text.Json;
@@ -148,6 +149,8 @@ public T GetVersionSpecificDomains<T>() where T : DevToolsSessionDomains
148149
/// <param name="millisecondsTimeout">The execution timeout of the command in milliseconds.</param>
149150
/// <param name="throwExceptionIfResponseNotReceived"><see langword="true"/> to throw an exception if a response is not received; otherwise, <see langword="false"/>.</param>
150151
/// <returns>The command response object implementing the <see cref="ICommandResponse{T}"/> interface.</returns>
152+
[RequiresUnreferencedCode("SendCommand is not compatible with trimming or AOT. Use the overload that takes JsonNode parameters instead")]
153+
[RequiresDynamicCode("SendCommand is not compatible with trimming or AOT. Use the overload that takes JsonNode parameters instead")]
151154
public async Task<ICommandResponse<TCommand>> SendCommand<TCommand>(TCommand command, CancellationToken cancellationToken = default(CancellationToken), int? millisecondsTimeout = null, bool throwExceptionIfResponseNotReceived = true)
152155
where TCommand : ICommand
153156
{
@@ -181,6 +184,8 @@ public T GetVersionSpecificDomains<T>() where T : DevToolsSessionDomains
181184
/// <param name="millisecondsTimeout">The execution timeout of the command in milliseconds.</param>
182185
/// <param name="throwExceptionIfResponseNotReceived"><see langword="true"/> to throw an exception if a response is not received; otherwise, <see langword="false"/>.</param>
183186
/// <returns>The command response object implementing the <see cref="ICommandResponse{T}"/> interface.</returns>
187+
[RequiresUnreferencedCode("SendCommand is not compatible with trimming or AOT. Use the overload that takes JsonNode parameters instead")]
188+
[RequiresDynamicCode("SendCommand is not compatible with trimming or AOT. Use the overload that takes JsonNode parameters instead")]
184189
public async Task<ICommandResponse<TCommand>> SendCommand<TCommand>(TCommand command, string sessionId, CancellationToken cancellationToken = default(CancellationToken), int? millisecondsTimeout = null, bool throwExceptionIfResponseNotReceived = true)
185190
where TCommand : ICommand
186191
{
@@ -214,6 +219,8 @@ public T GetVersionSpecificDomains<T>() where T : DevToolsSessionDomains
214219
/// <param name="millisecondsTimeout">The execution timeout of the command in milliseconds.</param>
215220
/// <param name="throwExceptionIfResponseNotReceived"><see langword="true"/> to throw an exception if a response is not received; otherwise, <see langword="false"/>.</param>
216221
/// <returns>The command response object implementing the <see cref="ICommandResponse{T}"/> interface.</returns>
222+
[RequiresUnreferencedCode("SendCommand is not compatible with trimming or AOT. Use the overload that takes JsonNode parameters instead")]
223+
[RequiresDynamicCode("SendCommand is not compatible with trimming or AOT. Use the overload that takes JsonNode parameters instead")]
217224
public async Task<TCommandResponse> SendCommand<TCommand, TCommandResponse>(TCommand command, CancellationToken cancellationToken = default(CancellationToken), int? millisecondsTimeout = null, bool throwExceptionIfResponseNotReceived = true)
218225
where TCommand : ICommand
219226
where TCommandResponse : ICommandResponse<TCommand>

dotnet/src/webdriver/DevTools/IDevToolsSession.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
// </copyright>
1919

2020
using System;
21+
using System.Diagnostics.CodeAnalysis;
2122
using System.Text.Json;
2223
using System.Text.Json.Nodes;
2324
using System.Threading;
@@ -59,6 +60,8 @@ public interface IDevToolsSession : IDisposable
5960
/// <param name="millisecondsTimeout">The execution timeout of the command in milliseconds.</param>
6061
/// <param name="throwExceptionIfResponseNotReceived"><see langword="true"/> to throw an exception if a response is not received; otherwise, <see langword="false"/>.</param>
6162
/// <returns>The command response object implementing the <see cref="ICommandResponse{T}"/> interface.</returns>
63+
[RequiresUnreferencedCode("SendCommand is not compatible with trimming or AOT. Use the overload that takes JsonNode parameters instead")]
64+
[RequiresDynamicCode("SendCommand is not compatible with trimming or AOT. Use the overload that takes JsonNode parameters instead")]
6265
Task<ICommandResponse<TCommand>> SendCommand<TCommand>(TCommand command, CancellationToken cancellationToken, int? millisecondsTimeout, bool throwExceptionIfResponseNotReceived)
6366
where TCommand : ICommand;
6467

@@ -72,6 +75,8 @@ Task<ICommandResponse<TCommand>> SendCommand<TCommand>(TCommand command, Cancell
7275
/// <param name="millisecondsTimeout">The execution timeout of the command in milliseconds.</param>
7376
/// <param name="throwExceptionIfResponseNotReceived"><see langword="true"/> to throw an exception if a response is not received; otherwise, <see langword="false"/>.</param>
7477
/// <returns>The command response object implementing the <see cref="ICommandResponse{T}"/> interface.</returns>
78+
[RequiresUnreferencedCode("SendCommand is not compatible with trimming or AOT. Use the overload that takes JsonNode parameters instead")]
79+
[RequiresDynamicCode("SendCommand is not compatible with trimming or AOT. Use the overload that takes JsonNode parameters instead")]
7580
Task<TCommandResponse> SendCommand<TCommand, TCommandResponse>(TCommand command, CancellationToken cancellationToken, int? millisecondsTimeout, bool throwExceptionIfResponseNotReceived)
7681
where TCommand : ICommand
7782
where TCommandResponse : ICommandResponse<TCommand>;

dotnet/src/webdriver/DevTools/Json/JsonEnumMemberConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
namespace OpenQA.Selenium.DevTools.Json
2929
{
30-
internal sealed class JsonEnumMemberConverter<TEnum> : JsonConverter<TEnum>
30+
internal sealed class JsonEnumMemberConverter<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields)] TEnum> : JsonConverter<TEnum>
3131
where TEnum : struct, Enum
3232
{
3333
private readonly Dictionary<TEnum, string> _enumToString = new Dictionary<TEnum, string>();

0 commit comments

Comments
 (0)