Skip to content

Commit c609507

Browse files
committed
Got rid of 1200 resharper warnings.
1 parent a01596c commit c609507

31 files changed

+130
-110
lines changed

AdoNetCore.AseClient.sln.DotSettings

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
11
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
2-
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=DB/@EntryIndexedValue">DB</s:String></wpf:ResourceDictionary>
2+
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=DB/@EntryIndexedValue">DB</s:String>
3+
<s:Boolean x:Key="/Default/UserDictionary/Words/=colindex/@EntryIndexedValue">True</s:Boolean>
4+
<s:Boolean x:Key="/Default/UserDictionary/Words/=MAXOUTPUTPRECISION/@EntryIndexedValue">True</s:Boolean>
5+
<s:Boolean x:Key="/Default/UserDictionary/Words/=MAXOUTPUTSCALE/@EntryIndexedValue">True</s:Boolean>
6+
<s:Boolean x:Key="/Default/UserDictionary/Words/=MAXPRECISION/@EntryIndexedValue">True</s:Boolean>
7+
<s:Boolean x:Key="/Default/UserDictionary/Words/=MAXSCALE/@EntryIndexedValue">True</s:Boolean>
8+
<s:Boolean x:Key="/Default/UserDictionary/Words/=Sendable/@EntryIndexedValue">True</s:Boolean>
9+
<s:Boolean x:Key="/Default/UserDictionary/Words/=Unpooled/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

src/AdoNetCore.AseClient/AseClientPermission.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if ENABLE_DB_DATAPERMISSION
1+
#if ENABLE_DB_DATAPERMISSION
22
using System;
33
using System.Data;
44
using System.Data.Common;
@@ -23,7 +23,7 @@ public AseClientPermission() : base(default(PermissionState)) { }
2323
public AseClientPermission(PermissionState state) : base(default(PermissionState)) { }
2424
public AseClientPermission(PermissionState state, bool allowBlankPassword) : base(default(PermissionState)) { }
2525
public override void Add(string connectionString, string restrictions, KeyRestrictionBehavior behavior) { }
26-
public override System.Security.IPermission Copy() { return null; }
26+
public override System.Security.IPermission Copy() { return new AseClientPermission(); }
2727
}
2828
}
2929
#endif

src/AdoNetCore.AseClient/AseCommand.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Data;
33
using System.Data.Common;
44
using System.IO;
@@ -159,7 +159,7 @@ public override int ExecuteNonQuery()
159159
}
160160

161161
LogExecution(nameof(ExecuteNonQuery));
162-
return _connection.InternalConnection.ExecuteNonQuery(this, (AseTransaction)Transaction);
162+
return _connection.InternalConnection.ExecuteNonQuery(this, Transaction);
163163
}
164164

165165
/// <summary>
@@ -180,7 +180,7 @@ public override int ExecuteNonQuery()
180180
}
181181

182182
LogExecution(nameof(ExecuteReader));
183-
return (AseDataReader)_connection.InternalConnection.ExecuteReader(behavior, this, (AseTransaction)Transaction);
183+
return (AseDataReader)_connection.InternalConnection.ExecuteReader(behavior, this, Transaction);
184184
}
185185

186186
/// <summary>
@@ -221,7 +221,7 @@ public override object ExecuteScalar()
221221
}
222222

223223
LogExecution(nameof(ExecuteScalar));
224-
return _connection.InternalConnection.ExecuteScalar(this, (AseTransaction)Transaction);
224+
return _connection.InternalConnection.ExecuteScalar(this, Transaction);
225225
}
226226

227227
private void LogExecution(string methodName)
@@ -519,7 +519,7 @@ public override Task<int> ExecuteNonQueryAsync(CancellationToken cancellationTok
519519
throw new ObjectDisposedException(nameof(AseCommand));
520520
}
521521

522-
return InternalExecuteAsync(() => _connection.InternalConnection.ExecuteNonQueryTaskRunnable(this, (AseTransaction)Transaction), cancellationToken);
522+
return InternalExecuteAsync(() => _connection.InternalConnection.ExecuteNonQueryTaskRunnable(this, Transaction), cancellationToken);
523523
}
524524

525525
protected override Task<DbDataReader> ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
@@ -529,7 +529,7 @@ protected override Task<DbDataReader> ExecuteDbDataReaderAsync(CommandBehavior b
529529
throw new ObjectDisposedException(nameof(AseCommand));
530530
}
531531

532-
return InternalExecuteAsync(() => _connection.InternalConnection.ExecuteReaderTaskRunnable(behavior, this, (AseTransaction)Transaction), cancellationToken);
532+
return InternalExecuteAsync(() => _connection.InternalConnection.ExecuteReaderTaskRunnable(behavior, this, Transaction), cancellationToken);
533533
}
534534

535535
public override Task<object> ExecuteScalarAsync(CancellationToken cancellationToken)

src/AdoNetCore.AseClient/AseDataReader.cs

+9-2
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,21 @@ public sealed class AseDataReader : DbDataReader
1919
#if ENABLE_SYSTEM_DATA_COMMON_EXTENSIONS
2020
private readonly AseCommand _command;
2121
private DataTable _currentSchemaTable;
22-
#endif
2322

2423
internal AseDataReader(IEnumerable<TableResult> results, AseCommand command, CommandBehavior behavior)
2524
{
2625
_results = results.ToArray();
27-
#if ENABLE_SYSTEM_DATA_COMMON_EXTENSIONS
2826
_command = command;
27+
28+
_behavior = behavior;
29+
NextResult();
30+
}
2931
#endif
32+
33+
internal AseDataReader(IEnumerable<TableResult> results, CommandBehavior behavior)
34+
{
35+
_results = results.ToArray();
36+
3037
_behavior = behavior;
3138
NextResult();
3239
}

src/AdoNetCore.AseClient/AseDataReaderEnumerator.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections;
33

44
namespace AdoNetCore.AseClient
@@ -12,7 +12,7 @@ internal sealed class AseDataReaderEnumerator : IEnumerator
1212

1313
public AseDataReaderEnumerator(AseDataReader dataReader)
1414
{
15-
this._dataReader = dataReader;
15+
_dataReader = dataReader;
1616
}
1717

1818
public void Reset()
@@ -37,4 +37,4 @@ public bool MoveNext()
3737
return _dataReader.Read();
3838
}
3939
}
40-
}
40+
}

src/AdoNetCore.AseClient/AseDbType.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System.Data;
21
// ReSharper disable UnusedMember.Global
32

43
namespace AdoNetCore.AseClient

src/AdoNetCore.AseClient/AseDecimal.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ public static explicit operator AseDecimal(int value)
486486

487487
public static explicit operator AseDecimal(double value)
488488
{
489-
return new AseDecimal((BigDecimal) value);
489+
return new AseDecimal(value);
490490
}
491491

492492
public static explicit operator AseDecimal(decimal value)

src/AdoNetCore.AseClient/AseException.cs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
1+
using System;
32
#if ENABLE_SYSTEMEXCEPTION
43
using System.Runtime.Serialization;
54
#endif
@@ -27,13 +26,13 @@ public sealed class AseException :
2726
/// </remarks>
2827
public AseErrorCollection Errors
2928
{
30-
get; private set;
29+
get;
3130
}
3231

3332
/// <summary>
3433
/// This method returns the message of the most severe error.
3534
/// </summary>
36-
public override string Message => this.Errors.MainError == null ? string.Empty : this.Errors.MainError.Message;
35+
public override string Message => Errors.MainError == null ? string.Empty : Errors.MainError.Message;
3736

3837
/// <summary>
3938
/// Constructor function for an <see cref="AseException" /> instance.

src/AdoNetCore.AseClient/AseParameterCollection.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,10 @@ public override void RemoveAt(int index)
521521
/// <param name="index">The starting index of the array.</param>
522522
public override void CopyTo(Array array, int index)
523523
{
524-
((IList)_parameters).CopyTo(array, index);
524+
if (array != null)
525+
{
526+
((IList)_parameters).CopyTo(array, index);
527+
}
525528
}
526529

527530
/// <summary>

src/AdoNetCore.AseClient/Internal/IniReader.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ private IniEntry QueryFirstService(StreamReader reader)
4545
{
4646
var serviceNameLine = reader.ReadLine();
4747

48-
if (ServiceRegex.IsMatch(serviceNameLine))
48+
if (serviceNameLine != null && ServiceRegex.IsMatch(serviceNameLine))
4949
{
5050
while (!reader.EndOfStream)
5151
{
52-
var dataLine = reader.ReadLine().Trim();
52+
var dataLine = reader.ReadLine()?.Trim();
5353

5454
// If we are still reading data.
55-
if (!ServiceRegex.IsMatch(dataLine))
55+
if (dataLine != null && !ServiceRegex.IsMatch(dataLine))
5656
{
5757
var match = IniEntryRegex.Match(dataLine);
5858

@@ -82,14 +82,14 @@ private IniEntry QueryServiceByServiceName(StreamReader reader, string serviceNa
8282
{
8383
var serviceNameLine = reader.ReadLine();
8484

85-
if (serviceNameRegex.IsMatch(serviceNameLine))
85+
if (serviceNameLine != null && serviceNameRegex.IsMatch(serviceNameLine))
8686
{
8787
while (!reader.EndOfStream)
8888
{
89-
var dataLine = reader.ReadLine().Trim();
89+
var dataLine = reader.ReadLine()?.Trim();
9090

9191
// If we are still reading data.
92-
if (!ServiceRegex.IsMatch(dataLine))
92+
if (dataLine != null && !ServiceRegex.IsMatch(dataLine))
9393
{
9494
var match = IniEntryRegex.Match(dataLine);
9595

src/AdoNetCore.AseClient/Internal/InternalConnection.cs

+6-2
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,11 @@ private void InternalExecuteQueryAsync(AseCommand command, AseTransaction transa
298298
}
299299
else
300300
{
301+
#if ENABLE_SYSTEM_DATA_COMMON_EXTENSIONS
301302
readerSource.TrySetResult(new AseDataReader(dataReaderHandler.Results(), command, behavior));
303+
#else
304+
readerSource.TrySetResult(new AseDataReader(dataReaderHandler.Results(), behavior));
305+
#endif
302306
}
303307
}
304308
catch (Exception ex)
@@ -360,7 +364,7 @@ public int ExecuteNonQuery(AseCommand command, AseTransaction transaction)
360364
}
361365
catch (AggregateException ae)
362366
{
363-
ExceptionDispatchInfo.Capture(ae.InnerException).Throw();
367+
ExceptionDispatchInfo.Capture(ae.InnerException ?? ae).Throw();
364368
throw;
365369
}
366370
}
@@ -382,7 +386,7 @@ public DbDataReader ExecuteReader(CommandBehavior behavior, AseCommand command,
382386
}
383387
catch (AggregateException ae)
384388
{
385-
ExceptionDispatchInfo.Capture(ae.InnerException).Throw();
389+
ExceptionDispatchInfo.Capture(ae.InnerException ?? ae).Throw();
386390
throw;
387391
}
388392
}

src/AdoNetCore.AseClient/Internal/InternalConnectionFactory.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ public Task<IInternalConnection> GetNewConnection(CancellationToken token, IInfo
3333
}
3434
catch (AseException)
3535
{
36-
connection?.Dispose();
36+
connection.Dispose();
3737
socket?.Dispose();
3838
throw;
3939
}
4040
catch(Exception ex)
4141
{
4242
Logger.Instance?.WriteLine($"{nameof(InternalConnectionFactory)}.{nameof(GetNewConnection)} encountered exception: {ex}");
43-
connection?.Dispose();
43+
connection.Dispose();
4444
socket?.Dispose();
4545
throw new OperationCanceledException();
4646
}
@@ -117,7 +117,7 @@ private static IPAddress ResolveAddress(string server, CancellationToken token)
117117
}
118118
catch (AggregateException ae)
119119
{
120-
ExceptionDispatchInfo.Capture(ae.InnerException).Throw();
120+
ExceptionDispatchInfo.Capture(ae.InnerException ?? ae).Throw();
121121
throw;
122122
}
123123

src/AdoNetCore.AseClient/Internal/ParameterValueExtensions.cs

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
42

53
namespace AdoNetCore.AseClient.Internal
64
{

src/AdoNetCore.AseClient/Internal/ReadablePartialStream.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System;
2-
using System.Diagnostics;
1+
using System;
32
using System.IO;
43

54
namespace AdoNetCore.AseClient.Internal

src/AdoNetCore.AseClient/Internal/SqlDecimal.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
1+
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
/*
@@ -34,8 +34,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
3434
using System;
3535
using System.Diagnostics;
3636
using System.Globalization;
37-
// ReSharper disable InconsistentNaming
38-
// ReSharper disable MemberCanBePrivate.Global
37+
38+
// ReSharper disable All
3939

4040
namespace AdoNetCore.AseClient.Internal
4141
{
@@ -1770,4 +1770,4 @@ public override int GetHashCode()
17701770

17711771
public static readonly SqlDecimal Null = new SqlDecimal(true);
17721772
} // SqlDecimal
1773-
} // namespace System.Data.SqlTypes
1773+
} // namespace System.Data.SqlTypes

src/AdoNetCore.AseClient/Packet/AttentionPacket.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System.IO;
2-
using System.Text;
1+
using System.IO;
32
using AdoNetCore.AseClient.Enum;
43
using AdoNetCore.AseClient.Interface;
54
using AdoNetCore.AseClient.Internal;

src/AdoNetCore.AseClient/Packet/NormalPacket.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
using System.Collections.Generic;
1+
using System.Collections.Generic;
22
using System.IO;
3-
using System.Text;
43
using AdoNetCore.AseClient.Enum;
54
using AdoNetCore.AseClient.Interface;
65
using AdoNetCore.AseClient.Internal;

src/AdoNetCore.AseClient/Token/CatchAllToken.cs

-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ public void Read(Stream stream, DbEnvironment env, IFormatToken previous)
3434
/// The token's length or the length of its remaining length indicator is encoded in the token's type.
3535
/// </summary>
3636
/// <param name="stream"></param>
37-
/// <param name="type"></param>
3837
/// <returns></returns>
3938
private uint CalculateRemainingLength(Stream stream)
4039
{

test/AdoNetCore.AseClient.Tests/Benchmark/Benchmarks.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ public partial class Benchmarks<T> where T : IConnectionProvider
1010
{
1111
// This connection string is used for setting up the database. It requires DDL permissions. Adjust accordingly.
1212
private string _setupConnectionString;
13-
private IConnectionProvider _connectionProvider;
13+
private T _connectionProvider;
1414

1515
public string UnpooledConnectionString { get; } =ConnectionStrings.NonPooled;
1616

1717
public string PooledConnectionString => ConnectionStrings.Pooled10;
1818

1919

20-
private void Initialise(IConnectionProvider connectionProvider)
20+
private void Initialise(T connectionProvider)
2121
{
2222
_connectionProvider = connectionProvider;
2323
_setupConnectionString = _setupConnectionString ?? UnpooledConnectionString;
@@ -259,6 +259,7 @@ public sealed class DataItem
259259
/// <summary>
260260
/// The Name of the records from the database.
261261
/// </summary>
262+
// ReSharper disable once UnusedAutoPropertyAccessor.Global
262263
public string Name { get; set; }
263264

264265
/// <summary>

test/AdoNetCore.AseClient.Tests/CodeSamples.cs

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Linq;
88
using Dapper;
99
using NUnit.Framework;
10+
// ReSharper disable All
1011
#pragma warning disable 219
1112

1213
namespace AdoNetCore.AseClient.Tests

test/AdoNetCore.AseClient.Tests/Integration/Connection/InfoMessageTests.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ public void ExecuteRaiseError_OutputsInfoMessages()
8585
{
8686
connection.Execute(@"raiserror 17001 'AAA'", commandType: CommandType.Text);
8787
}
88-
catch { }
88+
catch
89+
{
90+
// ignored
91+
}
8992

9093
connection.InfoMessage -= handlerFunc;
9194

test/AdoNetCore.AseClient.Tests/Integration/LoginTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public void Login_Blitz(int size, int threads, string cs)
9191
}
9292
catch (AggregateException ae)
9393
{
94-
ExceptionDispatchInfo.Capture(ae.InnerException).Throw();
94+
ExceptionDispatchInfo.Capture(ae.InnerException ?? ae).Throw();
9595
throw;
9696
}
9797

test/AdoNetCore.AseClient.Tests/Integration/TestEnvironmentHealthTests.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System;
21
using NUnit.Framework;
32

43
namespace AdoNetCore.AseClient.Tests.Integration

test/AdoNetCore.AseClient.Tests/ParameterProvider/CoreFxParameterProvider.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public class CoreFxParameterProvider : IParameterProvider
77
{
88
public DbParameter GetParameter()
99
{
10-
return new AdoNetCore.AseClient.AseParameter();
10+
return new AseParameter();
1111
}
1212
public DbParameter GetParameter(string parameterName, string aseDbType)
1313
{

0 commit comments

Comments
 (0)