mirror of
https://github.com/JustArchiNET/ArchiSteamFarm
synced 2024-11-10 07:04:27 +00:00
Resolve CA1062
This commit is contained in:
parent
9a8a61e111
commit
559fdb34c6
5 changed files with 74 additions and 8 deletions
|
@ -111,7 +111,6 @@ dotnet_diagnostic.ca1028.severity = silent
|
||||||
dotnet_diagnostic.ca1031.severity = silent
|
dotnet_diagnostic.ca1031.severity = silent
|
||||||
|
|
||||||
# TODO - one at a time
|
# TODO - one at a time
|
||||||
dotnet_diagnostic.ca1062.severity = silent
|
|
||||||
dotnet_diagnostic.ca1063.severity = silent
|
dotnet_diagnostic.ca1063.severity = silent
|
||||||
dotnet_diagnostic.ca1303.severity = silent
|
dotnet_diagnostic.ca1303.severity = silent
|
||||||
dotnet_diagnostic.ca1307.severity = silent
|
dotnet_diagnostic.ca1307.severity = silent
|
||||||
|
|
|
@ -70,6 +70,10 @@ namespace ArchiSteamFarm.Collections {
|
||||||
public void CopyTo(T[] array, int arrayIndex) => BackingCollection.Keys.CopyTo(array, arrayIndex);
|
public void CopyTo(T[] array, int arrayIndex) => BackingCollection.Keys.CopyTo(array, arrayIndex);
|
||||||
|
|
||||||
public void ExceptWith(IEnumerable<T> other) {
|
public void ExceptWith(IEnumerable<T> other) {
|
||||||
|
if (other == null) {
|
||||||
|
throw new ArgumentNullException(nameof(other));
|
||||||
|
}
|
||||||
|
|
||||||
foreach (T item in other) {
|
foreach (T item in other) {
|
||||||
Remove(item);
|
Remove(item);
|
||||||
}
|
}
|
||||||
|
@ -146,6 +150,10 @@ namespace ArchiSteamFarm.Collections {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UnionWith(IEnumerable<T> other) {
|
public void UnionWith(IEnumerable<T> other) {
|
||||||
|
if (other == null) {
|
||||||
|
throw new ArgumentNullException(nameof(other));
|
||||||
|
}
|
||||||
|
|
||||||
foreach (T otherElement in other) {
|
foreach (T otherElement in other) {
|
||||||
Add(otherElement);
|
Add(otherElement);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,14 @@ namespace ArchiSteamFarm.RuntimeCompatibility {
|
||||||
public static class Path {
|
public static class Path {
|
||||||
public static string GetRelativePath(string relativeTo, string path) {
|
public static string GetRelativePath(string relativeTo, string path) {
|
||||||
#if NETFRAMEWORK
|
#if NETFRAMEWORK
|
||||||
|
if (relativeTo == null) {
|
||||||
|
throw new ArgumentNullException(nameof(relativeTo));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (path == null) {
|
||||||
|
throw new ArgumentNullException(nameof(path));
|
||||||
|
}
|
||||||
|
|
||||||
if (!path.StartsWith(relativeTo, StringComparison.Ordinal)) {
|
if (!path.StartsWith(relativeTo, StringComparison.Ordinal)) {
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,15 +60,31 @@ namespace ArchiSteamFarm.RuntimeCompatibility {
|
||||||
}
|
}
|
||||||
|
|
||||||
#if NETFRAMEWORK
|
#if NETFRAMEWORK
|
||||||
public static Task<byte[]> ComputeHashAsync(this HashAlgorithm hashAlgorithm, Stream inputStream) => Task.FromResult(hashAlgorithm.ComputeHash(inputStream));
|
public static Task<byte[]> ComputeHashAsync(this HashAlgorithm hashAlgorithm, Stream inputStream) {
|
||||||
|
if (hashAlgorithm == null) {
|
||||||
|
throw new ArgumentNullException(nameof(hashAlgorithm));
|
||||||
|
}
|
||||||
|
|
||||||
|
return Task.FromResult(hashAlgorithm.ComputeHash(inputStream));
|
||||||
|
}
|
||||||
|
|
||||||
public static IWebHostBuilder ConfigureWebHostDefaults(this IWebHostBuilder builder, Action<IWebHostBuilder> configure) {
|
public static IWebHostBuilder ConfigureWebHostDefaults(this IWebHostBuilder builder, Action<IWebHostBuilder> configure) {
|
||||||
|
if (configure == null) {
|
||||||
|
throw new ArgumentNullException(nameof(configure));
|
||||||
|
}
|
||||||
|
|
||||||
configure(builder);
|
configure(builder);
|
||||||
|
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool Contains(this string input, string value, StringComparison comparisonType) => input.IndexOf(value, comparisonType) >= 0;
|
public static bool Contains(this string input, string value, StringComparison comparisonType) {
|
||||||
|
if (input == null) {
|
||||||
|
throw new ArgumentNullException(nameof(input));
|
||||||
|
}
|
||||||
|
|
||||||
|
return input.IndexOf(value, comparisonType) >= 0;
|
||||||
|
}
|
||||||
|
|
||||||
// ReSharper disable once UseDeconstructionOnParameter - we actually implement deconstruction here
|
// ReSharper disable once UseDeconstructionOnParameter - we actually implement deconstruction here
|
||||||
public static void Deconstruct<TKey, TValue>(this KeyValuePair<TKey, TValue> kv, out TKey key, out TValue value) {
|
public static void Deconstruct<TKey, TValue>(this KeyValuePair<TKey, TValue> kv, out TKey key, out TValue value) {
|
||||||
|
@ -77,15 +93,38 @@ namespace ArchiSteamFarm.RuntimeCompatibility {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ValueTask DisposeAsync(this IDisposable disposable) {
|
public static ValueTask DisposeAsync(this IDisposable disposable) {
|
||||||
|
if (disposable == null) {
|
||||||
|
throw new ArgumentNullException(nameof(disposable));
|
||||||
|
}
|
||||||
|
|
||||||
disposable.Dispose();
|
disposable.Dispose();
|
||||||
|
|
||||||
return default(ValueTask);
|
return default(ValueTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<WebSocketReceiveResult> ReceiveAsync(this WebSocket webSocket, byte[] buffer, CancellationToken cancellationToken) => await webSocket.ReceiveAsync(new ArraySegment<byte>(buffer), cancellationToken).ConfigureAwait(false);
|
public static async Task<WebSocketReceiveResult> ReceiveAsync(this WebSocket webSocket, byte[] buffer, CancellationToken cancellationToken) {
|
||||||
public static async Task SendAsync(this WebSocket webSocket, byte[] buffer, WebSocketMessageType messageType, bool endOfMessage, CancellationToken cancellationToken) => await webSocket.SendAsync(new ArraySegment<byte>(buffer), messageType, endOfMessage, cancellationToken).ConfigureAwait(false);
|
if (webSocket == null) {
|
||||||
|
throw new ArgumentNullException(nameof(webSocket));
|
||||||
|
}
|
||||||
|
|
||||||
public static string[] Split(this string text, char separator, StringSplitOptions options = StringSplitOptions.None) => text.Split(new[] { separator }, options);
|
return await webSocket.ReceiveAsync(new ArraySegment<byte>(buffer), cancellationToken).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async Task SendAsync(this WebSocket webSocket, byte[] buffer, WebSocketMessageType messageType, bool endOfMessage, CancellationToken cancellationToken) {
|
||||||
|
if (webSocket == null) {
|
||||||
|
throw new ArgumentNullException(nameof(webSocket));
|
||||||
|
}
|
||||||
|
|
||||||
|
await webSocket.SendAsync(new ArraySegment<byte>(buffer), messageType, endOfMessage, cancellationToken).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string[] Split(this string text, char separator, StringSplitOptions options = StringSplitOptions.None) {
|
||||||
|
if (text == null) {
|
||||||
|
throw new ArgumentNullException(nameof(text));
|
||||||
|
}
|
||||||
|
|
||||||
|
return text.Split(new[] { separator }, options);
|
||||||
|
}
|
||||||
|
|
||||||
public static void TrimExcess<TKey, TValue>(this Dictionary<TKey, TValue> _) { } // no-op
|
public static void TrimExcess<TKey, TValue>(this Dictionary<TKey, TValue> _) { } // no-op
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -235,13 +235,25 @@ namespace ArchiSteamFarm {
|
||||||
public static IEnumerable<IElement> SelectElementNodes(this IElement element, string xpath) => element.SelectNodes(xpath).OfType<IElement>();
|
public static IEnumerable<IElement> SelectElementNodes(this IElement element, string xpath) => element.SelectNodes(xpath).OfType<IElement>();
|
||||||
|
|
||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
public static IEnumerable<IElement> SelectNodes(this IDocument document, string xpath) => document.Body.SelectNodes(xpath).OfType<IElement>();
|
public static IEnumerable<IElement> SelectNodes(this IDocument document, string xpath) {
|
||||||
|
if (document == null) {
|
||||||
|
throw new ArgumentNullException(nameof(document));
|
||||||
|
}
|
||||||
|
|
||||||
|
return document.Body.SelectNodes(xpath).OfType<IElement>();
|
||||||
|
}
|
||||||
|
|
||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
public static IElement? SelectSingleElementNode(this IElement element, string xpath) => (IElement?) element.SelectSingleNode(xpath);
|
public static IElement? SelectSingleElementNode(this IElement element, string xpath) => (IElement?) element.SelectSingleNode(xpath);
|
||||||
|
|
||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
public static IElement? SelectSingleNode(this IDocument document, string xpath) => (IElement?) document.Body.SelectSingleNode(xpath);
|
public static IElement? SelectSingleNode(this IDocument document, string xpath) {
|
||||||
|
if (document == null) {
|
||||||
|
throw new ArgumentNullException(nameof(document));
|
||||||
|
}
|
||||||
|
|
||||||
|
return (IElement?) document.Body.SelectSingleNode(xpath);
|
||||||
|
}
|
||||||
|
|
||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
public static IEnumerable<T> ToEnumerable<T>(this T item) {
|
public static IEnumerable<T> ToEnumerable<T>(this T item) {
|
||||||
|
|
Loading…
Reference in a new issue