Skip to content

Commit 68339cd

Browse files
committed
Improve AOT incompatibility message
1 parent 70489a6 commit 68339cd

File tree

6 files changed

+34
-32
lines changed

6 files changed

+34
-32
lines changed

dotnet/src/webdriver/Chromium/ChromiumDriver.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,8 @@ public void SetPermission(string permissionName, string permissionValue)
299299
/// Creates a session to communicate with a browser using the Chromium Developer Tools debugging protocol.
300300
/// </summary>
301301
/// <returns>The active session to use to communicate with the Chromium Developer Tools debugging protocol.</returns>
302-
[RequiresUnreferencedCode("CDP is not compatible with trimming or AOT.")]
303-
[RequiresDynamicCode("CDP is not compatible with trimming or AOT.")]
302+
[RequiresUnreferencedCode(DevToolsSession.CDP_AOTIncompatibilityMessage)]
303+
[RequiresDynamicCode(DevToolsSession.CDP_AOTIncompatibilityMessage)]
304304
public DevToolsSession GetDevToolsSession()
305305
{
306306
return GetDevToolsSession(new DevToolsOptions() { ProtocolVersion = DevToolsSession.AutoDetectDevToolsProtocolVersion });
@@ -310,8 +310,8 @@ public DevToolsSession GetDevToolsSession()
310310
/// Creates a session to communicate with a browser using the Chromium Developer Tools debugging protocol.
311311
/// </summary>
312312
/// <returns>The active session to use to communicate with the Chromium Developer Tools debugging protocol.</returns>
313-
[RequiresUnreferencedCode("CDP is not compatible with trimming or AOT.")]
314-
[RequiresDynamicCode("CDP is not compatible with trimming or AOT.")]
313+
[RequiresUnreferencedCode(DevToolsSession.CDP_AOTIncompatibilityMessage)]
314+
[RequiresDynamicCode(DevToolsSession.CDP_AOTIncompatibilityMessage)]
315315
public DevToolsSession GetDevToolsSession(DevToolsOptions options)
316316
{
317317
if (this.devToolsSession == null)
@@ -353,8 +353,8 @@ public DevToolsSession GetDevToolsSession(DevToolsOptions options)
353353
/// <param name="devToolsProtocolVersion">The version of the Chromium Developer Tools protocol to use. Defaults to autodetect the protocol version.</param>
354354
/// <returns>The active session to use to communicate with the Chromium Developer Tools debugging protocol.</returns>
355355
[Obsolete("Use GetDevToolsSession(DevToolsOptions options)")]
356-
[RequiresUnreferencedCode("CDP is not compatible with trimming or AOT.")]
357-
[RequiresDynamicCode("CDP is not compatible with trimming or AOT.")]
356+
[RequiresUnreferencedCode(DevToolsSession.CDP_AOTIncompatibilityMessage)]
357+
[RequiresDynamicCode(DevToolsSession.CDP_AOTIncompatibilityMessage)]
358358
public DevToolsSession GetDevToolsSession(int devToolsProtocolVersion)
359359
{
360360
return GetDevToolsSession(new DevToolsOptions() { ProtocolVersion = devToolsProtocolVersion });

dotnet/src/webdriver/DevTools/DevToolsSession.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,12 @@ namespace OpenQA.Selenium.DevTools
3636
/// Represents a WebSocket connection to a running DevTools instance that can be used to send
3737
/// commands and receive events.
3838
///</summary>
39-
[RequiresUnreferencedCode("CDP is not compatible with trimming or AOT.")]
40-
[RequiresDynamicCode("CDP is not compatible with trimming or AOT.")]
39+
[RequiresUnreferencedCode(CDP_AOTIncompatibilityMessage)]
40+
[RequiresDynamicCode(CDP_AOTIncompatibilityMessage)]
4141
public class DevToolsSession : IDevToolsSession
4242
{
43+
internal const string CDP_AOTIncompatibilityMessage = "CDP is not compatible with trimming or AOT.";
44+
4345
/// <summary>
4446
/// A value indicating that the version of the DevTools protocol in use
4547
/// by the browser should be automatically detected.

dotnet/src/webdriver/DevTools/IDevTools.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ public interface IDevTools
3838
/// Creates a session to communicate with a browser using a Developer Tools debugging protocol.
3939
/// </summary>
4040
/// <returns>The active session to use to communicate with the Developer Tools debugging protocol.</returns>
41-
[RequiresUnreferencedCode("CDP is not compatible with trimming or AOT.")]
42-
[RequiresDynamicCode("CDP is not compatible with trimming or AOT.")]
41+
[RequiresUnreferencedCode(DevToolsSession.CDP_AOTIncompatibilityMessage)]
42+
[RequiresDynamicCode(DevToolsSession.CDP_AOTIncompatibilityMessage)]
4343
DevToolsSession GetDevToolsSession();
4444

4545
/// <summary>
@@ -48,8 +48,8 @@ public interface IDevTools
4848
/// <param name="options">The options for the DevToolsSession to use.</param>
4949
/// <returns>The active session to use to communicate with the Developer Tools debugging protocol.</returns>
5050
/// <exception cref="ArgumentNullException">If <paramref name="options"/> is <see langword="null"/>.</exception>
51-
[RequiresUnreferencedCode("CDP is not compatible with trimming or AOT.")]
52-
[RequiresDynamicCode("CDP is not compatible with trimming or AOT.")]
51+
[RequiresUnreferencedCode(DevToolsSession.CDP_AOTIncompatibilityMessage)]
52+
[RequiresDynamicCode(DevToolsSession.CDP_AOTIncompatibilityMessage)]
5353
DevToolsSession GetDevToolsSession(DevToolsOptions options);
5454

5555
/// <summary>
@@ -58,15 +58,15 @@ public interface IDevTools
5858
/// <param name="protocolVersion">The specific version of the Developer Tools debugging protocol to use.</param>
5959
/// <returns>The active session to use to communicate with the Developer Tools debugging protocol.</returns>
6060
[Obsolete("Use GetDevToolsSession(DevToolsOptions options)")]
61-
[RequiresUnreferencedCode("CDP is not compatible with trimming or AOT.")]
62-
[RequiresDynamicCode("CDP is not compatible with trimming or AOT.")]
61+
[RequiresUnreferencedCode(DevToolsSession.CDP_AOTIncompatibilityMessage)]
62+
[RequiresDynamicCode(DevToolsSession.CDP_AOTIncompatibilityMessage)]
6363
DevToolsSession GetDevToolsSession(int protocolVersion);
6464

6565
/// <summary>
6666
/// Closes a DevTools session
6767
/// </summary>
68-
[RequiresUnreferencedCode("CDP is not compatible with trimming or AOT.")]
69-
[RequiresDynamicCode("CDP is not compatible with trimming or AOT.")]
68+
[RequiresUnreferencedCode(DevToolsSession.CDP_AOTIncompatibilityMessage)]
69+
[RequiresDynamicCode(DevToolsSession.CDP_AOTIncompatibilityMessage)]
7070
void CloseDevToolsSession();
7171
}
7272
}

dotnet/src/webdriver/DevTools/IDevToolsSession.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ public interface IDevToolsSession : IDisposable
6464
/// <param name="throwExceptionIfResponseNotReceived"><see langword="true"/> to throw an exception if a response is not received; otherwise, <see langword="false"/>.</param>
6565
/// <returns>The command response object implementing the <see cref="ICommandResponse{T}"/> interface.</returns>
6666
/// <exception cref="ArgumentNullException">If <paramref name="command"/> is <see langword="null"/>.</exception>
67-
[RequiresUnreferencedCode("CDP is not compatible with trimming or AOT.")]
68-
[RequiresDynamicCode("CDP is not compatible with trimming or AOT.")]
67+
[RequiresUnreferencedCode(DevToolsSession.CDP_AOTIncompatibilityMessage)]
68+
[RequiresDynamicCode(DevToolsSession.CDP_AOTIncompatibilityMessage)]
6969
Task<ICommandResponse<TCommand>?> SendCommand<TCommand>(TCommand command, CancellationToken cancellationToken, int? millisecondsTimeout, bool throwExceptionIfResponseNotReceived)
7070
where TCommand : ICommand;
7171

@@ -80,8 +80,8 @@ public interface IDevToolsSession : IDisposable
8080
/// <param name="throwExceptionIfResponseNotReceived"><see langword="true"/> to throw an exception if a response is not received; otherwise, <see langword="false"/>.</param>
8181
/// <returns>The command response object implementing the <see cref="ICommandResponse{T}"/> interface.</returns>
8282
/// <exception cref="ArgumentNullException">If <paramref name="command"/> is <see langword="null"/>.</exception>
83-
[RequiresUnreferencedCode("CDP is not compatible with trimming or AOT.")]
84-
[RequiresDynamicCode("CDP is not compatible with trimming or AOT.")]
83+
[RequiresUnreferencedCode(DevToolsSession.CDP_AOTIncompatibilityMessage)]
84+
[RequiresDynamicCode(DevToolsSession.CDP_AOTIncompatibilityMessage)]
8585
Task<TCommandResponse?> SendCommand<TCommand, TCommandResponse>(TCommand command, CancellationToken cancellationToken, int? millisecondsTimeout, bool throwExceptionIfResponseNotReceived)
8686
where TCommand : ICommand
8787
where TCommandResponse : ICommandResponse<TCommand>;
@@ -96,8 +96,8 @@ public interface IDevToolsSession : IDisposable
9696
/// <param name="throwExceptionIfResponseNotReceived"><see langword="true"/> to throw an exception if a response is not received; otherwise, <see langword="false"/>.</param>
9797
/// <returns>The command response object implementing the <see cref="ICommandResponse{T}"/> interface.</returns>
9898
/// <exception cref="ArgumentNullException">If <paramref name="commandName"/> is <see langword="null"/>.</exception>
99-
[RequiresUnreferencedCode("CDP is not compatible with trimming or AOT.")]
100-
[RequiresDynamicCode("CDP is not compatible with trimming or AOT.")]
99+
[RequiresUnreferencedCode(DevToolsSession.CDP_AOTIncompatibilityMessage)]
100+
[RequiresDynamicCode(DevToolsSession.CDP_AOTIncompatibilityMessage)]
101101
Task<JsonElement?> SendCommand(string commandName, JsonNode @params, CancellationToken cancellationToken, int? millisecondsTimeout, bool throwExceptionIfResponseNotReceived);
102102
}
103103
}

dotnet/src/webdriver/Remote/RemoteWebDriver.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -427,8 +427,8 @@ public ReadOnlyCollection<IWebElement> FindElementsByCssSelector(string cssSelec
427427
/// Creates a session to communicate with a browser using a Developer Tools debugging protocol.
428428
/// </summary>
429429
/// <returns>The active session to use to communicate with the Developer Tools debugging protocol.</returns>
430-
[RequiresUnreferencedCode("CDP is not compatible with trimming or AOT.")]
431-
[RequiresDynamicCode("CDP is not compatible with trimming or AOT.")]
430+
[RequiresUnreferencedCode(DevToolsSession.CDP_AOTIncompatibilityMessage)]
431+
[RequiresDynamicCode(DevToolsSession.CDP_AOTIncompatibilityMessage)]
432432
public DevToolsSession GetDevToolsSession()
433433
{
434434
if (this.Capabilities.GetCapability(CapabilityType.BrowserName) is "firefox")
@@ -446,8 +446,8 @@ public DevToolsSession GetDevToolsSession()
446446
/// Creates a session to communicate with a browser using a Developer Tools debugging protocol.
447447
/// </summary>
448448
/// <returns>The active session to use to communicate with the Developer Tools debugging protocol.</returns>
449-
[RequiresUnreferencedCode("CDP is not compatible with trimming or AOT.")]
450-
[RequiresDynamicCode("CDP is not compatible with trimming or AOT.")]
449+
[RequiresUnreferencedCode(DevToolsSession.CDP_AOTIncompatibilityMessage)]
450+
[RequiresDynamicCode(DevToolsSession.CDP_AOTIncompatibilityMessage)]
451451
public DevToolsSession GetDevToolsSession(DevToolsOptions options)
452452
{
453453
if (options is null)
@@ -504,8 +504,8 @@ public DevToolsSession GetDevToolsSession(DevToolsOptions options)
504504
/// <param name="protocolVersion">The specific version of the Developer Tools debugging protocol to use.</param>
505505
/// <returns>The active session to use to communicate with the Developer Tools debugging protocol.</returns>
506506
[Obsolete("Use GetDevToolsSession(DevToolsOptions options)")]
507-
[RequiresUnreferencedCode("CDP is not compatible with trimming or AOT.")]
508-
[RequiresDynamicCode("CDP is not compatible with trimming or AOT.")]
507+
[RequiresUnreferencedCode(DevToolsSession.CDP_AOTIncompatibilityMessage)]
508+
[RequiresDynamicCode(DevToolsSession.CDP_AOTIncompatibilityMessage)]
509509
public DevToolsSession GetDevToolsSession(int protocolVersion)
510510
{
511511
return GetDevToolsSession(new DevToolsOptions() { ProtocolVersion = protocolVersion });
@@ -594,8 +594,8 @@ public void DeleteDownloadableFiles()
594594
/// <summary>
595595
/// Closes a DevTools session.
596596
/// </summary>
597-
[RequiresUnreferencedCode("CDP is not compatible with trimming or AOT.")]
598-
[RequiresDynamicCode("CDP is not compatible with trimming or AOT.")]
597+
[RequiresUnreferencedCode(DevToolsSession.CDP_AOTIncompatibilityMessage)]
598+
[RequiresDynamicCode(DevToolsSession.CDP_AOTIncompatibilityMessage)]
599599
public void CloseDevToolsSession()
600600
{
601601
if (this.devToolsSession != null)

dotnet/src/webdriver/Response.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ public static Response FromErrorJson(string value)
173173
/// </summary>
174174
/// <returns>A JSON-encoded string representing this <see cref="Response"/> object.</returns>
175175

176-
[RequiresUnreferencedCode("Free-form JSON serialization.")]
177-
[RequiresDynamicCode("Free-form JSON serialization.")]
176+
[RequiresUnreferencedCode("Untyped JSON serialization is not trim- or AOT- safe.")]
177+
[RequiresDynamicCode("Untyped JSON serialization is not trim- or AOT- safe.")]
178178
public string ToJson()
179179
{
180180
return JsonSerializer.Serialize(this);

0 commit comments

Comments
 (0)