Skip to content

Commit 53f6361

Browse files
committed
StyleCop and FxCop changes
1 parent 4671432 commit 53f6361

File tree

11 files changed

+189
-17
lines changed

11 files changed

+189
-17
lines changed

dotnet/src/webdriver/GlobalSuppressions.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,15 @@
4141
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings", Scope = "member", Target = "OpenQA.Selenium.Chrome.ChromeDriverService.#UrlPathPrefix", Justification = "UrlPathPrefix is a prefix for use with ChromeDriver, and should be a string.")]
4242
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings", Scope = "member", Target = "OpenQA.Selenium.Opera.OperaDriverService.#UrlPathPrefix", Justification = "UrlPathPrefix is a prefix for use with OperaDriver, and should be a string.")]
4343
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings", Scope = "member", Target = "OpenQA.Selenium.PhantomJS.PhantomJSDriverService.#GridHubUrl", Justification = "GridHubUrl is a command line for use with PhantomJS, and should properly be a string.")]
44+
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "System.Console.WriteLine(System.String,System.Object)", Scope = "member", Target = "OpenQA.Selenium.Internal.FileUtilities.#DeleteDirectory(System.String)", Justification = "Informational message only.")]
4445
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase", Scope = "member", Target = "OpenQA.Selenium.Firefox.Preferences.#SetPreferenceValue(System.String,System.Object)", Justification = "Strings are normalized to lower case by JSON wire protocol.")]
4546
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase", Scope = "member", Target = "OpenQA.Selenium.Remote.RemoteWebElement.#GetAttribute(System.String)", Justification = "Strings are normalized to lower case by JSON wire protocol.")]
4647
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase", Scope = "member", Target = "OpenQA.Selenium.Firefox.FirefoxDriverService.#CommandLineArguments", Justification = "Strings are normalized to lower case by JSON wire protocol.")]
48+
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase", Scope = "member", Target = "OpenQA.Selenium.Interactions.PointerInputDevice+PointerMoveInteraction.#Serialize()", Justification = "Strings are normalized to lower case by JSON wire protocol.")]
49+
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase", Scope = "member", Target = "OpenQA.Selenium.Interactions.PointerInputDevice.#Serialize()", Justification = "Strings are normalized to lower case by JSON wire protocol.")]
50+
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase", Scope = "member", Target = "OpenQA.Selenium.Firefox.FirefoxOptions.#GenerateFirefoxOptionsDictionary()", Justification = "Strings are normalized to lower case by JSON wire protocol.")]
51+
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase", Scope = "member", Target = "OpenQA.Selenium.Interactions.PointerInputDevice+PointerMoveInteraction.#ToDictionary()", Justification = "Strings are normalized to lower case by JSON wire protocol.")]
52+
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase", Scope = "member", Target = "OpenQA.Selenium.Interactions.PointerInputDevice.#ToDictionary()", Justification = "Strings are normalized to lower case by JSON wire protocol.")]
4753
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling", Scope = "type", Target = "OpenQA.Selenium.Remote.RemoteWebDriver", Justification = "RemoteWebDriver is a large class, and will have tight couplings with a lot of classes.")]
4854
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "OnScreen", Scope = "member", Target = "OpenQA.Selenium.Interactions.Internal.ICoordinates.#LocationOnScreen", Justification = "On Screen is properly used as two-word discrete term.")]
4955
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "OnScreen", Scope = "member", Target = "OpenQA.Selenium.ILocatable.#LocationOnScreenOnceScrolledIntoView", Justification = "On Screen is properly used as two-word discrete term.")]
@@ -62,6 +68,8 @@
6268
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Api", Scope = "member", Target = "OpenQA.Selenium.IE.InternetExplorerOptions.#ForceShellWindowsApi", Justification = "API is spelled and cased correctly for use in method names.")]
6369
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Uncached", Scope = "member", Target = "OpenQA.Selenium.Html5.AppCacheStatus.#Uncached", Justification = "Uncached property is correctly spelled.")]
6470
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Multiprocess", Scope = "member", Target = "OpenQA.Selenium.Firefox.FirefoxDriverService.#DisableBrowserMultiprocessSupport", Justification = "Multiprocess is correctly spelled.")]
71+
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "x", Scope = "member", Target = "OpenQA.Selenium.Interactions.PointerInputDevice.#CreatePointerMove(OpenQA.Selenium.IWebElement,OpenQA.Selenium.Interactions.CoordinateOrigin,System.Int32,System.Int32,System.TimeSpan)", Justification = "An x-offset is an appropriate name for the parameter.")]
72+
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "y", Scope = "member", Target = "OpenQA.Selenium.Interactions.PointerInputDevice.#CreatePointerMove(OpenQA.Selenium.IWebElement,OpenQA.Selenium.Interactions.CoordinateOrigin,System.Int32,System.Int32,System.TimeSpan)", Justification = "A y-offset is an appropriate name for the parameter.")]
6573
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "OpenQA.Selenium.Cookie.#ExpirySeconds", Justification = "This property only exists so that the JSON serializer can serialize a cookie without resorting to a custom converter.")]
6674
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", Scope = "member", Target = "OpenQA.Selenium.Remote.ErrorResponse.#StackTrace", Justification = "Specification compliance demands use of an array.")]
6775
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", Scope = "member", Target = "OpenQA.Selenium.Screenshot.#AsByteArray", Justification = "Specification compliance demands use of an array.")]
@@ -91,4 +99,3 @@
9199
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "HasWebStorage", Scope = "member", Target = "OpenQA.Selenium.Remote.RemoteWebDriver.#WebStorage", Justification = "HasWebStorage property name is properly spelled")]
92100
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "geolocation", Scope = "member", Target = "OpenQA.Selenium.Remote.RemoteWebDriver.#LocationContext", Justification = "Geolocation is properly spelled")]
93101
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors", Scope = "member", Target = "OpenQA.Selenium.Remote.RemoteWebDriver.#.ctor(OpenQA.Selenium.Remote.ICommandExecutor,OpenQA.Selenium.ICapabilities)", Justification = "Class provides a hook for subclasses to modify functionality, so virtual method call in constructor is appropriate.")]
94-
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "System.Console.WriteLine(System.String,System.Object)", Scope = "member", Target = "OpenQA.Selenium.Internal.FileUtilities.#DeleteDirectory(System.String)", Justification = "Informational message only.")]

dotnet/src/webdriver/Interactions/ActionSequence.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
using System;
2020
using System.Collections.Generic;
21+
using System.Globalization;
2122
using System.Linq;
2223
using System.Text;
2324

@@ -51,6 +52,9 @@ public ActionSequence(InputDevice device, int initialSize)
5152
}
5253
}
5354

55+
/// <summary>
56+
/// Gets the count of actions in the sequence.
57+
/// </summary>
5458
public int Count
5559
{
5660
get { return this.interactions.Count; }
@@ -70,13 +74,17 @@ public ActionSequence AddAction(Interaction interactionToAdd)
7074

7175
if (!interactionToAdd.IsValidFor(this.device.DeviceKind))
7276
{
73-
throw new ArgumentException(string.Format("Interaction {0} is invalid for device type {1}."), "interactionToAdd");
77+
throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Interaction {0} is invalid for device type {1}.", interactionToAdd.GetType(), this.device.DeviceKind), "interactionToAdd");
7478
}
7579

7680
this.interactions.Add(interactionToAdd);
7781
return this;
7882
}
7983

84+
/// <summary>
85+
/// Converts this action sequence into an object suitable for serializing across the wire.
86+
/// </summary>
87+
/// <returns>A <see cref="Dictionary{TKey, TValue}"/> containing the actions in this sequence.</returns>
8088
public Dictionary<string, object> ToDictionary()
8189
{
8290
Dictionary<string, object> toReturn = this.device.ToDictionary();

dotnet/src/webdriver/Interactions/Actions.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ public Actions KeyDown(string theKey)
9191
/// of <see cref="Keys.Shift"/>, <see cref="Keys.Control"/>, or <see cref="Keys.Alt"/>.</exception>
9292
public Actions KeyDown(IWebElement element, string theKey)
9393
{
94+
if (string.IsNullOrEmpty(theKey))
95+
{
96+
throw new ArgumentException("The key value must not be null or empty", "theKey");
97+
}
98+
9499
ILocatable target = GetLocatableFromElement(element);
95100
this.action.AddAction(new KeyDownAction(this.keyboard, this.mouse, target, theKey));
96101
this.actionBuilder.AddAction(this.defaultKeyboard.CreateKeyDown(theKey[0]));
@@ -119,6 +124,11 @@ public Actions KeyUp(string theKey)
119124
/// of <see cref="Keys.Shift"/>, <see cref="Keys.Control"/>, or <see cref="Keys.Alt"/>.</exception>
120125
public Actions KeyUp(IWebElement element, string theKey)
121126
{
127+
if (string.IsNullOrEmpty(theKey))
128+
{
129+
throw new ArgumentException("The key value must not be null or empty", "theKey");
130+
}
131+
122132
ILocatable target = GetLocatableFromElement(element);
123133
this.action.AddAction(new KeyUpAction(this.keyboard, this.mouse, target, theKey));
124134
this.actionBuilder.AddAction(this.defaultKeyboard.CreateKeyUp(theKey[0]));
@@ -143,6 +153,11 @@ public Actions SendKeys(string keysToSend)
143153
/// <returns>A self-reference to this <see cref="Actions"/>.</returns>
144154
public Actions SendKeys(IWebElement element, string keysToSend)
145155
{
156+
if (string.IsNullOrEmpty(keysToSend))
157+
{
158+
throw new ArgumentException("The key value must not be null or empty", "keysToSend");
159+
}
160+
146161
ILocatable target = GetLocatableFromElement(element);
147162
this.action.AddAction(new SendKeysAction(this.keyboard, this.mouse, target, keysToSend));
148163
foreach (char key in keysToSend)
@@ -331,7 +346,6 @@ public Actions DragAndDrop(IWebElement source, IWebElement target)
331346
/// <returns>A self-reference to this <see cref="Actions"/>.</returns>
332347
public Actions DragAndDropToOffset(IWebElement source, int offsetX, int offsetY)
333348
{
334-
ILocatable startElement = GetLocatableFromElement(source);
335349
this.ClickAndHold(source).MoveByOffset(offsetX, offsetY).Release();
336350
return this;
337351
}

dotnet/src/webdriver/Interactions/InputDevice.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ internal abstract class InputDevice
2929
{
3030
private string deviceName;
3131

32-
public InputDevice(string deviceName)
32+
/// <summary>
33+
/// Initializes a new instance of the <see cref="InputDevice"/> class.
34+
/// </summary>
35+
/// <param name="deviceName">The unique name of the input device represented by this class.</param>
36+
protected InputDevice(string deviceName)
3337
{
3438
if (string.IsNullOrEmpty(deviceName))
3539
{
@@ -39,11 +43,17 @@ public InputDevice(string deviceName)
3943
this.deviceName = deviceName;
4044
}
4145

46+
/// <summary>
47+
/// Gets the unique name of this input device.
48+
/// </summary>
4249
public string DeviceName
4350
{
4451
get { return this.deviceName; }
4552
}
4653

54+
/// <summary>
55+
/// Gets the kind of device for this input device.
56+
/// </summary>
4757
public abstract InputDeviceKind DeviceKind { get; }
4858

4959
/// <summary>

dotnet/src/webdriver/Interactions/InputDeviceKind.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,19 @@ namespace OpenQA.Selenium.Interactions
2323
/// </summary>
2424
internal enum InputDeviceKind
2525
{
26+
/// <summary>
27+
/// Represents the null device.
28+
/// </summary>
2629
None,
30+
31+
/// <summary>
32+
/// Represents a key-based device, primarily for entering text.
33+
/// </summary>
2734
Key,
35+
36+
/// <summary>
37+
/// Represents a pointer-based device, such as a mouse, pen, or stylus.
38+
/// </summary>
2839
Pointer
2940
}
3041
}

dotnet/src/webdriver/Interactions/Interaction.cs

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
1-
using System;
1+
// <copyright file="Interaction.cs" company="WebDriver Committers">
2+
// Licensed to the Software Freedom Conservancy (SFC) under one
3+
// or more contributor license agreements. See the NOTICE file
4+
// distributed with this work for additional information
5+
// regarding copyright ownership. The SFC licenses this file
6+
// to you under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
// </copyright>
18+
19+
using System;
220
using System.Collections.Generic;
321
using System.Linq;
422
using System.Text;
@@ -12,6 +30,10 @@ internal abstract class Interaction
1230
{
1331
private InputDevice sourceDevice;
1432

33+
/// <summary>
34+
/// Initializes a new instance of the <see cref="Interaction"/> class.
35+
/// </summary>
36+
/// <param name="sourceDevice">The input device which performs this action.</param>
1537
protected Interaction(InputDevice sourceDevice)
1638
{
1739
if (sourceDevice == null)
@@ -22,6 +44,9 @@ protected Interaction(InputDevice sourceDevice)
2244
this.sourceDevice = sourceDevice;
2345
}
2446

47+
/// <summary>
48+
/// Gets the device for which this action is intended.
49+
/// </summary>
2550
public InputDevice SourceDevice
2651
{
2752
get { return this.sourceDevice; }
@@ -33,9 +58,15 @@ public InputDevice SourceDevice
3358
/// <returns>A <see cref="Dictionary{TKey, TValue}"/> representing this action.</returns>
3459
public abstract Dictionary<string, object> ToDictionary();
3560

61+
/// <summary>
62+
/// Gets a value indicating whether this action is valid for the specified type of input device.
63+
/// </summary>
64+
/// <param name="sourceDeviceKind">The type of device to check.</param>
65+
/// <returns><see langword="true"/> if the action is valid for the specified type of input device;
66+
/// otherwise, <see langword="false"/>.</returns>
3667
public virtual bool IsValidFor(InputDeviceKind sourceDeviceKind)
3768
{
38-
return sourceDevice.DeviceKind == sourceDeviceKind;
69+
return this.sourceDevice.DeviceKind == sourceDeviceKind;
3970
}
4071
}
4172
}

dotnet/src/webdriver/Interactions/KeyInputDevice.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,26 @@ namespace OpenQA.Selenium.Interactions
2929
/// </summary>
3030
internal class KeyInputDevice : InputDevice
3131
{
32+
/// <summary>
33+
/// Initializes a new instance of the <see cref="KeyInputDevice"/> class.
34+
/// </summary>
3235
public KeyInputDevice()
3336
: this(Guid.NewGuid().ToString())
3437
{
3538
}
3639

40+
/// <summary>
41+
/// Initializes a new instance of the <see cref="KeyInputDevice"/> class, given the device's name.
42+
/// </summary>
43+
/// <param name="deviceName">The unique name of this input device.</param>
3744
public KeyInputDevice(string deviceName)
3845
: base(deviceName)
3946
{
4047
}
4148

49+
/// <summary>
50+
/// Gets the type of device for this input device.
51+
/// </summary>
4252
public override InputDeviceKind DeviceKind
4353
{
4454
get { return InputDeviceKind.Key; }
@@ -58,11 +68,21 @@ public override Dictionary<string, object> ToDictionary()
5868
return toReturn;
5969
}
6070

71+
/// <summary>
72+
/// Creates a key-down action for simulating a press of a key.
73+
/// </summary>
74+
/// <param name="codePoint">The unicode character to be sent.</param>
75+
/// <returns>The <see cref="Interaction"/> representing the action.</returns>
6176
public Interaction CreateKeyDown(char codePoint)
6277
{
6378
return new KeyDownInteraction(this, codePoint);
6479
}
6580

81+
/// <summary>
82+
/// Creates a key-up action for simulating a release of a key.
83+
/// </summary>
84+
/// <param name="codePoint">The unicode character to be sent.</param>
85+
/// <returns>The <see cref="Interaction"/> representing the action.</returns>
6686
public Interaction CreateKeyUp(char codePoint)
6787
{
6888
return new KeyUpInteraction(this, codePoint);
@@ -96,7 +116,6 @@ public override string ToString()
96116

97117
private class TypingInteraction : Interaction
98118
{
99-
100119
private string type;
101120
private string value;
102121

0 commit comments

Comments
 (0)