Skip to content

Commit

Permalink
Fixing static analysis (FxCop and StyleCop) warnings for .NET
Browse files Browse the repository at this point in the history
  • Loading branch information
jimevans committed Sep 15, 2016
1 parent 9f5f45c commit 4438400
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 65 deletions.
13 changes: 4 additions & 9 deletions dotnet/src/webdriver/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,10 @@
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "OpenQA.Selenium.Interactions", Justification = "Namespaces are properly scoped.")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "OpenQA.Selenium.Chrome", Justification = "Namespaces are properly scoped.")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "OpenQA.Selenium.Opera", Justification = "Namespaces are properly scoped.")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "OpenQA.Selenium.Safari", Justification = "Namespaces are properly scoped.")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Scope = "member", Target = "OpenQA.Selenium.ITakesScreenshot.#GetScreenshot()", Justification = "API specification demands method.")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1027:MarkEnumsWithFlags", Scope = "type", Target = "OpenQA.Selenium.ProxyKind", Justification = "The ProxyKind enum is not a set of flags, but has values determined by an external API.")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1027:MarkEnumsWithFlags", Scope = "type", Target = "OpenQA.Selenium.WebDriverResult", Justification = "The WebDriverResult enum is not a set of flags, but has values determined by an external API.")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1027:MarkEnumsWithFlags", Scope = "type", Target = "OpenQA.Selenium.Safari.Internal.FrameType", Justification = "Enum is not a set of flags.")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Scope = "member", Target = "OpenQA.Selenium.Safari.Internal.SocketWrapper.#OnAuthenticate(System.IAsyncResult)", Justification = "Providing event for all error types, so catching top-level exception is correct design.")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Scope = "member", Target = "OpenQA.Selenium.Safari.Internal.SocketWrapper.#OnDataSend(System.IAsyncResult)", Justification = "Providing event for all error types, so catching top-level exception is correct design.")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Scope = "member", Target = "OpenQA.Selenium.Safari.Internal.SocketWrapper.#OnDataReceive(System.IAsyncResult)", Justification = "Providing event for all error types, so catching top-level exception is correct design.")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Scope = "member", Target = "OpenQA.Selenium.Safari.Internal.SocketWrapper.#OnClientConnect(System.IAsyncResult)", Justification = "Providing event for all error types, so catching top-level exception is correct design.")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings", Scope = "member", Target = "OpenQA.Selenium.IWebDriver.#Url", Justification = "Specification demands string value for property.")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings", Scope = "member", Target = "OpenQA.Selenium.Proxy.#ProxyAutoConfigUrl", Justification = "Proxy configuration can be string instead of Uri.")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings", Scope = "member", Target = "OpenQA.Selenium.IE.InternetExplorerOptions.#InitialBrowserUrl", Justification = "InitialBrowserUrl should be string instead of Uri.")]
Expand All @@ -47,6 +43,7 @@
[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.")]
[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.")]
[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.")]
[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.")]
[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.")]
[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.")]
[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.")]
Expand All @@ -64,12 +61,10 @@
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Api", Scope = "member", Target = "OpenQA.Selenium.IE.InternetExplorerOptions.#ForceCreateProcessApi", Justification = "API is spelled and cased correctly for use in method names.")]
[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.")]
[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.")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Multiprocess", Scope = "member", Target = "OpenQA.Selenium.Firefox.FirefoxDriverService.#DisableBrowserMultiprocessSupport", Justification = "Multiprocess is correctly spelled.")]
[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.")]
[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.")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", Scope = "member", Target = "OpenQA.Selenium.Screenshot.#AsByteArray", Justification = "Specification compliance demands use of an array.")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", Scope = "member", Target = "OpenQA.Selenium.Safari.Internal.BinaryMessageHandledEventArgs.#Data", Justification = "Type is properly specified. It should be an array of bytes.")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", Scope = "member", Target = "OpenQA.Selenium.Safari.Internal.ReceivedEventArgs.#Buffer", Justification = "Type is properly specified. It should be an array of bytes.")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", Scope = "member", Target = "OpenQA.Selenium.Safari.Internal.WebSocketHttpRequest.#Payload", Justification = "Type is properly specified. It should be an array of bytes.")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Scope = "member", Target = "OpenQA.Selenium.Chrome.ChromeDriver.#.ctor(OpenQA.Selenium.Chrome.ChromeOptions)", Justification = "Driver ensures that all dependent service objects are properly disposed.")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Scope = "member", Target = "OpenQA.Selenium.Chrome.ChromeDriver.#.ctor(System.String,OpenQA.Selenium.Chrome.ChromeOptions,System.TimeSpan)", Justification = "Driver ensures that all dependent service objects are properly disposed.")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Scope = "member", Target = "OpenQA.Selenium.Edge.EdgeDriver.#.ctor(OpenQA.Selenium.Edge.EdgeOptions)", Justification = "Driver ensures that all dependent service objects are properly disposed.")]
Expand All @@ -85,11 +80,11 @@
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Scope = "member", Target = "OpenQA.Selenium.Firefox.FirefoxDriver.#.ctor()", Justification = "Driver ensures that all dependent service objects are properly disposed.")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Scope = "member", Target = "OpenQA.Selenium.Firefox.FirefoxDriver.#.ctor(OpenQA.Selenium.Firefox.FirefoxProfile)", Justification = "Driver ensures that all dependent service objects are properly disposed.")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Scope = "member", Target = "OpenQA.Selenium.Firefox.FirefoxDriver.#CreateExtensionConnection(OpenQA.Selenium.Firefox.FirefoxBinary,OpenQA.Selenium.Firefox.FirefoxProfile,System.TimeSpan)", Justification = "Driver ensures that all dependent service objects are properly disposed.")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Scope = "member", Target = "OpenQA.Selenium.Safari.Internal.SocketWrapper.#OnClientConnect(System.IAsyncResult)", Justification = "Driver ensures that all dependent socket wrappers are properly disposed.")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2202:Do not dispose objects multiple times", Scope = "member", Target = "OpenQA.Selenium.Firefox.FirefoxProfile.#FromBase64String(System.String)", Justification = "Separate disposal of the stream object is approved, and ensures disposal if there are exceptions in nested object constructor or method.")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2202:Do not dispose objects multiple times", Scope = "member", Target = "OpenQA.Selenium.Firefox.FirefoxProfile.#ReadDefaultPreferences()", Justification = "Separate disposal of the stream object is approved, and ensures disposal if there are exceptions in nested object constructor or method.")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2202:Do not dispose objects multiple times", Scope = "member", Target = "OpenQA.Selenium.Firefox.FirefoxProfile.#ToBase64String()", Justification = "Separate disposal of the stream object is approved, and ensures disposal if there are exceptions in nested object constructor or method.")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2202:Do not dispose objects multiple times", Scope = "member", Target = "OpenQA.Selenium.Remote.RemoteWebElement.#UploadFile(System.String)", Justification = "Separate disposal of the stream object is approved, and ensures disposal if there are exceptions in nested object constructor or method.")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2202:Do not dispose objects multiple times", Scope = "member", Target = "OpenQA.Selenium.Remote.RemoteWebElement.#GetAtom(System.String)", Justification = "Separate disposal of the stream object is approved, and ensures disposal if there are exceptions in nested object constructor or method.")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "WebDriver", Scope = "member", Target = "OpenQA.Selenium.Remote.HttpCommandExecutor.#CreateResponse(System.Net.WebRequest)", Justification = "WebDriver is correctly used as a single word.")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "HasApplicationCache", Scope = "member", Target = "OpenQA.Selenium.Remote.RemoteWebDriver.#ApplicationCache", Justification = "HasApplicationCache property name is properly spelled")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "HasLocationContext", Scope = "member", Target = "OpenQA.Selenium.Remote.RemoteWebDriver.#LocationContext", Justification = "HasLocationContext property name is properly spelled")]
Expand Down
34 changes: 17 additions & 17 deletions dotnet/src/webdriver/Remote/RemoteWebElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public bool Displayed
Dictionary<string, object> parameters = new Dictionary<string, object>();
if (this.driver.IsSpecificationCompliant)
{
string atom = this.GetAtom("isDisplayed.js");
string atom = GetAtom("isDisplayed.js");
parameters.Add("script", atom);
parameters.Add("args", new object[] { this.ToElementReference() });
commandResponse = this.Execute(DriverCommand.ExecuteScript, parameters);
Expand Down Expand Up @@ -417,7 +417,7 @@ public string GetAttribute(string attributeName)
Dictionary<string, object> parameters = new Dictionary<string, object>();
if (this.driver.IsSpecificationCompliant)
{
string atom = this.GetAtom("getAttribute.js");
string atom = GetAtom("getAttribute.js");
parameters.Add("script", atom);
parameters.Add("args", new object[] { this.ToElementReference(), attributeName });
commandResponse = this.Execute(DriverCommand.ExecuteScript, parameters);
Expand Down Expand Up @@ -940,6 +940,21 @@ protected Response Execute(string commandToExecute, Dictionary<string, object> p
return this.driver.InternalExecute(commandToExecute, parameters);
}

private static string GetAtom(string atomResourceName)
{
string atom = string.Empty;
using (Stream atomStream = ResourceUtilities.GetResourceStream(atomResourceName, atomResourceName))
{
using (StreamReader atomReader = new StreamReader(atomStream))
{
atom = atomReader.ReadToEnd();
}
}

string wrappedAtom = string.Format(CultureInfo.InvariantCulture, "return ({0}).apply(null, arguments);", atom);
return wrappedAtom;
}

private string UploadFile(string localFile)
{
string base64zip = string.Empty;
Expand Down Expand Up @@ -972,20 +987,5 @@ private string UploadFile(string localFile)
elementDictionary["element-6066-11e4-a52e-4f735466cecf"] = this.elementId;
return elementDictionary;
}

private string GetAtom(string atomResourceName)
{
string atom = string.Empty;
using (Stream atomStream = ResourceUtilities.GetResourceStream(atomResourceName, atomResourceName))
{
using (StreamReader atomReader = new StreamReader(atomStream))
{
atom = atomReader.ReadToEnd();
}
}

string wrappedAtom = string.Format(CultureInfo.InvariantCulture, "return ({0}).apply(null, arguments);", atom);
return wrappedAtom;
}
}
}
6 changes: 3 additions & 3 deletions dotnet/src/webdriver/Safari/SafariDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,12 @@ public override IFileDetector FileDetector

private static ICapabilities ConvertOptionsToCapabilities(SafariOptions options)
{
if (options == null)
if (options == null)
{
throw new ArgumentNullException ("options", "options must not be null");
throw new ArgumentNullException("options", "options must not be null");
}

return options.ToCapabilities ();
return options.ToCapabilities();
}
}
}
Loading

0 comments on commit 4438400

Please sign in to comment.