21
21
using System . Globalization ;
22
22
using System . Text ;
23
23
24
+ #nullable enable
25
+
24
26
namespace OpenQA . Selenium . Chromium
25
27
{
26
28
/// <summary>
@@ -30,15 +32,6 @@ public abstract class ChromiumDriverService : DriverService
30
32
{
31
33
private const string DefaultChromeDriverServiceExecutableName = "chromedriver" ;
32
34
33
- private string logPath = string . Empty ;
34
- private string urlPathPrefix = string . Empty ;
35
- private string portServerAddress = string . Empty ;
36
- private string allowedIPAddresses = string . Empty ;
37
- private int adbPort = - 1 ;
38
- private bool disableBuildCheck ;
39
- private bool enableVerboseLogging ;
40
- private bool enableAppendLog ;
41
-
42
35
/// <summary>
43
36
/// Initializes a new instance of the <see cref="ChromiumDriverService"/> class.
44
37
/// </summary>
@@ -51,94 +44,64 @@ protected ChromiumDriverService(string executablePath, string executableFileName
51
44
}
52
45
53
46
/// <summary>
54
- /// Gets or sets the location of the log file written to by the ChromeDriver executable.
47
+ /// <para>Gets or sets the location of the log file written to by the ChromeDriver executable.</para>
48
+ /// <para><see langword="null"/> or <see cref="string.Empty"/> signify no log path.</para>
55
49
/// </summary>
56
- public string LogPath
57
- {
58
- get { return this . logPath ; }
59
- set { this . logPath = value ; }
60
- }
50
+ public string ? LogPath { get ; set ; }
61
51
62
52
/// <summary>
63
- /// Gets or sets the base URL path prefix for commands (e.g., "wd/url").
53
+ /// <para>Gets or sets the base URL path prefix for commands (e.g., "wd/url").</para>
54
+ /// <para><see langword="null"/> or <see cref="string.Empty"/> signify no prefix.</para>
64
55
/// </summary>
65
- public string UrlPathPrefix
66
- {
67
- get { return this . urlPathPrefix ; }
68
- set { this . urlPathPrefix = value ; }
69
- }
56
+ public string ? UrlPathPrefix { get ; set ; }
70
57
71
58
/// <summary>
72
- /// Gets or sets the address of a server to contact for reserving a port.
59
+ /// <para>Gets or sets the address of a server to contact for reserving a port.</para>
60
+ /// <para><see langword="null"/> or <see cref="string.Empty"/> signify no port server.</para>
73
61
/// </summary>
74
- public string PortServerAddress
75
- {
76
- get { return this . portServerAddress ; }
77
- set { this . portServerAddress = value ; }
78
- }
62
+ public string ? PortServerAddress { get ; set ; }
79
63
80
64
/// <summary>
81
- /// Gets or sets the port on which the Android Debug Bridge is listening for commands.
65
+ /// <para>Gets or sets the port on which the Android Debug Bridge is listening for commands.</para>
66
+ /// <para>A value less than or equal to 0, or <see langword="null"/>, indicates no Android Debug Bridge specified.</para>
82
67
/// </summary>
83
- public int AndroidDebugBridgePort
84
- {
85
- get { return this . adbPort ; }
86
- set { this . adbPort = value ; }
87
- }
68
+ public int ? AndroidDebugBridgePort { get ; set ; }
88
69
89
70
/// <summary>
90
71
/// Gets or sets a value indicating whether to skip version compatibility check
91
72
/// between the driver and the browser.
92
73
/// Defaults to <see langword="false"/>.
93
74
/// </summary>
94
- public bool DisableBuildCheck
95
- {
96
- get { return this . disableBuildCheck ; }
97
- set { this . disableBuildCheck = value ; }
98
- }
75
+ public bool DisableBuildCheck { get ; set ; }
99
76
100
77
/// <summary>
101
78
/// Gets or sets a value indicating whether to enable verbose logging for the ChromeDriver executable.
102
79
/// Defaults to <see langword="false"/>.
103
80
/// </summary>
104
- public bool EnableVerboseLogging
105
- {
106
- get { return this . enableVerboseLogging ; }
107
- set { this . enableVerboseLogging = value ; }
108
- }
81
+ public bool EnableVerboseLogging { get ; set ; }
109
82
110
83
/// <summary>
111
84
/// Gets or sets a value indicating whether to enable appending to an existing ChromeDriver log file.
112
85
/// Defaults to <see langword="false"/>.
113
86
/// </summary>
114
- public bool EnableAppendLog
115
- {
116
- get { return this . enableAppendLog ; }
117
- set { this . enableAppendLog = value ; }
118
- }
87
+ public bool EnableAppendLog { get ; set ; }
119
88
120
89
/// <summary>
121
- /// Gets or sets the comma-delimited list of IP addresses that are approved to
122
- /// connect to this instance of the Chrome driver. Defaults to an empty string,
123
- /// which means only the local loopback address can connect.
90
+ /// <para>Gets or sets the comma-delimited list of IP addresses that are approved to connect to this instance of the Chrome driver.</para>
91
+ /// <para>A value of <see langword="null"/> or <see cref="string.Empty"/> means only the local loopback address can connect.</para>
124
92
/// </summary>
125
93
[ Obsolete ( $ "Use { nameof ( AllowedIPAddresses ) } ") ]
126
- public string WhitelistedIPAddresses
94
+ public string ? WhitelistedIPAddresses
127
95
{
128
- get { return this . allowedIPAddresses ; }
129
- set { this . allowedIPAddresses = value ; }
96
+ get => this . AllowedIPAddresses ;
97
+ set => this . AllowedIPAddresses = value ;
130
98
}
131
99
132
100
/// <summary>
133
- /// Gets or sets the comma-delimited list of IP addresses that are approved to
134
- /// connect to this instance of the Chrome driver. Defaults to an empty string,
135
- /// which means only the local loopback address can connect.
101
+ /// <para>Gets or sets the comma-delimited list of IP addresses that are approved to connect to this instance of the Chrome driver.</para>
102
+ /// <para>A value of <see langword="null"/> or <see cref="string.Empty"/> means only the local loopback address can connect.</para>
136
103
/// </summary>
137
- public string AllowedIPAddresses
138
- {
139
- get => this . allowedIPAddresses ;
140
- set => this . allowedIPAddresses = value ;
141
- }
104
+ public string ? AllowedIPAddresses { get ; set ; }
142
105
143
106
/// <summary>
144
107
/// Gets the command-line arguments for the driver service.
@@ -148,49 +111,49 @@ protected override string CommandLineArguments
148
111
get
149
112
{
150
113
StringBuilder argsBuilder = new StringBuilder ( base . CommandLineArguments ) ;
151
- if ( this . adbPort > 0 )
114
+ if ( this . AndroidDebugBridgePort is int adb && adb > 0 )
152
115
{
153
- argsBuilder . AppendFormat ( CultureInfo . InvariantCulture , " --adb-port={0}" , this . adbPort ) ;
116
+ argsBuilder . AppendFormat ( CultureInfo . InvariantCulture , " --adb-port={0}" , adb ) ;
154
117
}
155
118
156
119
if ( this . SuppressInitialDiagnosticInformation )
157
120
{
158
121
argsBuilder . Append ( " --silent" ) ;
159
122
}
160
123
161
- if ( this . disableBuildCheck )
124
+ if ( this . DisableBuildCheck )
162
125
{
163
126
argsBuilder . Append ( " --disable-build-check" ) ;
164
127
}
165
128
166
- if ( this . enableVerboseLogging )
129
+ if ( this . EnableVerboseLogging )
167
130
{
168
131
argsBuilder . Append ( " --verbose" ) ;
169
132
}
170
133
171
- if ( this . enableAppendLog )
134
+ if ( this . EnableAppendLog )
172
135
{
173
136
argsBuilder . Append ( " --append-log" ) ;
174
137
}
175
138
176
- if ( ! string . IsNullOrEmpty ( this . logPath ) )
139
+ if ( ! string . IsNullOrEmpty ( this . LogPath ) )
177
140
{
178
- argsBuilder . AppendFormat ( CultureInfo . InvariantCulture , " --log-path=\" {0}\" " , this . logPath ) ;
141
+ argsBuilder . AppendFormat ( CultureInfo . InvariantCulture , " --log-path=\" {0}\" " , this . LogPath ) ;
179
142
}
180
143
181
- if ( ! string . IsNullOrEmpty ( this . urlPathPrefix ) )
144
+ if ( ! string . IsNullOrEmpty ( this . UrlPathPrefix ) )
182
145
{
183
- argsBuilder . AppendFormat ( CultureInfo . InvariantCulture , " --url-base={0}" , this . urlPathPrefix ) ;
146
+ argsBuilder . AppendFormat ( CultureInfo . InvariantCulture , " --url-base={0}" , this . UrlPathPrefix ) ;
184
147
}
185
148
186
- if ( ! string . IsNullOrEmpty ( this . portServerAddress ) )
149
+ if ( ! string . IsNullOrEmpty ( this . PortServerAddress ) )
187
150
{
188
- argsBuilder . AppendFormat ( CultureInfo . InvariantCulture , " --port-server={0}" , this . portServerAddress ) ;
151
+ argsBuilder . AppendFormat ( CultureInfo . InvariantCulture , " --port-server={0}" , this . PortServerAddress ) ;
189
152
}
190
153
191
- if ( ! string . IsNullOrEmpty ( this . allowedIPAddresses ) )
154
+ if ( ! string . IsNullOrEmpty ( this . AllowedIPAddresses ) )
192
155
{
193
- argsBuilder . Append ( string . Format ( CultureInfo . InvariantCulture , " -allowed-ips={0}" , this . allowedIPAddresses ) ) ;
156
+ argsBuilder . Append ( string . Format ( CultureInfo . InvariantCulture , " -allowed-ips={0}" , this . AllowedIPAddresses ) ) ;
194
157
}
195
158
196
159
return argsBuilder . ToString ( ) ;
0 commit comments