Skip to content

Commit 107d484

Browse files
committed
PR feedbacl
1 parent 7da1cb7 commit 107d484

12 files changed

+63
-198
lines changed

dotnet/src/webdriver/DefaultFileDetector.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ public class DefaultFileDetector : IFileDetector
3434
/// </summary>
3535
/// <param name="keySequence">The sequence to test for file existence.</param>
3636
/// <returns>This method always returns <see langword="false"/> in this implementation.</returns>
37-
public bool IsFile([NotNullWhen(true)] string? keySequence)
37+
public bool IsFile(
38+
#if NET
39+
[NotNullWhen(true)]
40+
#endif
41+
string? keySequence)
3842
{
3943
return false;
4044
}

dotnet/src/webdriver/DetachedShadowRootException.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public DetachedShadowRootException()
4141
/// a specified error message.
4242
/// </summary>
4343
/// <param name="message">The message that describes the error.</param>
44-
public DetachedShadowRootException(string message)
44+
public DetachedShadowRootException(string? message)
4545
: base(message)
4646
{
4747
}
@@ -54,7 +54,7 @@ public DetachedShadowRootException(string message)
5454
/// <param name="message">The error message that explains the reason for the exception.</param>
5555
/// <param name="innerException">The exception that is the cause of the current exception,
5656
/// or <see langword="null"/> if no inner exception is specified.</param>
57-
public DetachedShadowRootException(string message, Exception innerException)
57+
public DetachedShadowRootException(string? message, Exception? innerException)
5858
: base(message, innerException)
5959
{
6060
}

dotnet/src/webdriver/ErrorResponse.cs

Lines changed: 19 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -44,52 +44,41 @@ public ErrorResponse()
4444
/// </summary>
4545
/// <param name="responseValue">A <see cref="Dictionary{K, V}"/> containing names and values of
4646
/// the properties of this <see cref="ErrorResponse"/>.</param>
47-
public ErrorResponse(Dictionary<string, object>? responseValue)
47+
public ErrorResponse(Dictionary<string, object?>? responseValue)
4848
{
4949
if (responseValue != null)
5050
{
51-
if (responseValue.ContainsKey("message"))
51+
if (responseValue.TryGetValue("message", out object? messageObj)
52+
&& messageObj?.ToString() is string message)
5253
{
53-
if (responseValue["message"] != null)
54-
{
55-
this.message = responseValue["message"].ToString() ?? "";
56-
}
57-
else
58-
{
59-
this.message = "The error did not contain a message.";
60-
}
54+
this.message = message;
6155
}
62-
63-
if (responseValue.ContainsKey("screen") && responseValue["screen"] != null)
56+
else
6457
{
65-
this.screenshot = responseValue["screen"].ToString() ?? "";
58+
this.message = "The error did not contain a message.";
6659
}
6760

68-
if (responseValue.ContainsKey("class") && responseValue["class"] != null)
61+
if (responseValue.TryGetValue("screen", out object? screenObj)
62+
&& screenObj?.ToString() is string screen)
6963
{
70-
this.className = responseValue["class"].ToString() ?? "";
64+
this.screenshot = screen;
7165
}
7266

73-
if (responseValue.ContainsKey("stackTrace") || responseValue.ContainsKey("stacktrace"))
67+
if (responseValue.TryGetValue("class", out object? classObj)
68+
&& classObj?.ToString() is string @class)
7469
{
75-
object[]? stackTraceArray = null;
76-
77-
if (responseValue.ContainsKey("stackTrace"))
78-
{
79-
stackTraceArray = responseValue["stackTrace"] as object[];
80-
}
81-
else if (responseValue.ContainsKey("stacktrace"))
82-
{
83-
stackTraceArray = responseValue["stacktrace"] as object[];
84-
}
70+
this.className = @class;
71+
}
8572

86-
if (stackTraceArray != null)
73+
if (responseValue.TryGetValue("stackTrace", out object? stackTraceObj)
74+
|| responseValue.TryGetValue("stacktrace", out stackTraceObj))
75+
{
76+
if (stackTraceObj is object?[] stackTraceArray)
8777
{
8878
List<StackTraceElement> stackTraceList = new List<StackTraceElement>();
89-
foreach (object rawStackTraceElement in stackTraceArray)
79+
foreach (object? rawStackTraceElement in stackTraceArray)
9080
{
91-
Dictionary<string, object>? elementAsDictionary = rawStackTraceElement as Dictionary<string, object>;
92-
if (elementAsDictionary != null)
81+
if (rawStackTraceElement is Dictionary<string, object?> elementAsDictionary)
9382
{
9483
stackTraceList.Add(new StackTraceElement(elementAsDictionary));
9584
}

dotnet/src/webdriver/Firefox/FirefoxDriver.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,9 @@ public override IFileDetector FileDetector
249249
/// <summary>
250250
/// Gets a value indicating whether a DevTools session is active.
251251
/// </summary>
252+
#if NET
252253
[MemberNotNullWhen(true, nameof(devToolsSession))]
254+
#endif
253255
public bool HasActiveDevToolsSession
254256
{
255257
get { return this.devToolsSession != null; }

dotnet/src/webdriver/IFileDetector.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ public interface IFileDetector
3434
/// </summary>
3535
/// <param name="keySequence">The sequence to test for file existence.</param>
3636
/// <returns><see langword="true"/> if the key sequence represents a file; otherwise, <see langword="false"/>.</returns>
37-
bool IsFile([NotNullWhen(true)] string? keySequence);
37+
bool IsFile(
38+
#if NET
39+
[NotNullWhen(true)]
40+
#endif
41+
string? keySequence);
3842
}
3943
}

dotnet/src/webdriver/Internal/NullableAttributes.cs

Lines changed: 0 additions & 149 deletions
This file was deleted.

dotnet/src/webdriver/InvalidSelectorException.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public InvalidSelectorException(string? message, Exception? innerException)
7171
/// <returns>The final message for exception</returns>
7272
protected static string GetMessage(string? message)
7373
{
74-
return message + "; " + supportMsg + supportUrl;
74+
return $"{message}; {supportMsg}{supportUrl}";
7575
}
7676
}
7777
}

dotnet/src/webdriver/NoSuchDriverException.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public NoSuchDriverException(string? message, Exception? innerException)
7272
/// <returns>The final message for exception</returns>
7373
protected static string GetMessage(string? message)
7474
{
75-
return message + "; " + supportMsg + supportUrl;
75+
return $"{message}; {supportMsg}{supportUrl}";
7676
}
7777
}
7878
}

dotnet/src/webdriver/NoSuchElementException.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public NoSuchElementException(string? message, Exception? innerException)
7272
/// <returns>The final message for exception</returns>
7373
protected static string GetMessage(string? message)
7474
{
75-
return message + "; " + supportMsg + supportUrl;
75+
return $"{message}; {supportMsg}{supportUrl}";
7676
}
7777
}
7878
}

dotnet/src/webdriver/Remote/LocalFileDetector.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ public class LocalFileDetector : IFileDetector
3535
/// </summary>
3636
/// <param name="keySequence">The sequence to test for file existence.</param>
3737
/// <returns><see langword="true"/> if the key sequence represents a file; otherwise, <see langword="false"/>.</returns>
38-
public bool IsFile([NotNullWhen(true)] string? keySequence)
38+
public bool IsFile(
39+
#if NET
40+
[NotNullWhen(true)]
41+
#endif
42+
string? keySequence)
3943
{
4044
return File.Exists(keySequence);
4145
}

0 commit comments

Comments
 (0)