Skip to content

Commit b523526

Browse files
committed
Type name simplication
1 parent e3dc0cc commit b523526

File tree

10 files changed

+44
-42
lines changed

10 files changed

+44
-42
lines changed

src/Npgsql/NpgsqlConnection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1449,7 +1449,7 @@ public void ReloadTypes()
14491449
/// </summary>
14501450
/// <param name="sender">The source of the event.</param>
14511451
/// <param name="e">A <see cref="NpgsqlNotificationEventArgs">NpgsqlNotificationEventArgs</see> that contains the event data.</param>
1452-
public delegate void NotificationEventHandler(Object sender, NpgsqlNotificationEventArgs e);
1452+
public delegate void NotificationEventHandler(object sender, NpgsqlNotificationEventArgs e);
14531453

14541454
/// <summary>
14551455
/// Represents the method that allows the application to provide a certificate collection to be used for SSL client authentication

src/Npgsql/NpgsqlParameter.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public sealed class NpgsqlParameter : DbParameter, ICloneable
5454
NpgsqlDbType? _npgsqlDbType;
5555
DbType? _dbType;
5656
Type _specificType;
57-
string _name = String.Empty;
57+
string _name = string.Empty;
5858
object _value;
5959
object _npgsqlValue;
6060

@@ -80,7 +80,7 @@ public sealed class NpgsqlParameter : DbParameter, ICloneable
8080
/// </summary>
8181
public NpgsqlParameter()
8282
{
83-
SourceColumn = String.Empty;
83+
SourceColumn = string.Empty;
8484
Direction = ParameterDirection.Input;
8585
#if NET45 || NET451
8686
SourceVersion = DataRowVersion.Current;
@@ -101,7 +101,7 @@ public NpgsqlParameter()
101101
/// This happens when calling this constructor passing an int 0 and the compiler thinks you are passing a value of DbType.
102102
/// Use <code> Convert.ToInt32(value) </code> for example to have compiler calling the correct constructor.</p>
103103
/// </remarks>
104-
public NpgsqlParameter(String parameterName, object value) : this()
104+
public NpgsqlParameter(string parameterName, object value) : this()
105105
{
106106
ParameterName = parameterName;
107107
Value = value;
@@ -114,7 +114,7 @@ public NpgsqlParameter(String parameterName, object value) : this()
114114
/// <param name="parameterName">The name of the parameter to map.</param>
115115
/// <param name="parameterType">One of the <see cref="System.Data.DbType">DbType</see> values.</param>
116116
public NpgsqlParameter(string parameterName, NpgsqlDbType parameterType)
117-
: this(parameterName, parameterType, 0, String.Empty)
117+
: this(parameterName, parameterType, 0, string.Empty)
118118
{
119119
}
120120

@@ -124,7 +124,7 @@ public NpgsqlParameter(string parameterName, NpgsqlDbType parameterType)
124124
/// <param name="parameterName">The name of the parameter to map.</param>
125125
/// <param name="parameterType">One of the <see cref="System.Data.DbType">DbType</see> values.</param>
126126
public NpgsqlParameter(string parameterName, DbType parameterType)
127-
: this(parameterName, parameterType, 0, String.Empty)
127+
: this(parameterName, parameterType, 0, string.Empty)
128128
{
129129
}
130130

@@ -135,7 +135,7 @@ public NpgsqlParameter(string parameterName, DbType parameterType)
135135
/// <param name="parameterType">One of the <see cref="NpgsqlTypes.NpgsqlDbType">NpgsqlDbType</see> values.</param>
136136
/// <param name="size">The length of the parameter.</param>
137137
public NpgsqlParameter(string parameterName, NpgsqlDbType parameterType, int size)
138-
: this(parameterName, parameterType, size, String.Empty)
138+
: this(parameterName, parameterType, size, string.Empty)
139139
{
140140
}
141141

@@ -146,7 +146,7 @@ public NpgsqlParameter(string parameterName, NpgsqlDbType parameterType, int siz
146146
/// <param name="parameterType">One of the <see cref="System.Data.DbType">DbType</see> values.</param>
147147
/// <param name="size">The length of the parameter.</param>
148148
public NpgsqlParameter(string parameterName, DbType parameterType, int size)
149-
: this(parameterName, parameterType, size, String.Empty)
149+
: this(parameterName, parameterType, size, string.Empty)
150150
{
151151
}
152152

@@ -321,7 +321,7 @@ public object NpgsqlValue
321321
/// <see cref="NpgsqlParameter.Value">Value</see> property.
322322
/// The default value is 0, which indicates that the data provider
323323
/// sets the precision for <b>Value</b>.</value>
324-
[DefaultValue((Byte)0)]
324+
[DefaultValue((byte)0)]
325325
[Category("Data")]
326326
#if NET45
327327
// In mono .NET 4.5 is actually a later version, meaning that virtual Precision and Scale already exist in DbParameter
@@ -346,7 +346,7 @@ public override byte Precision
346346
/// </summary>
347347
/// <value>The number of decimal places to which
348348
/// <see cref="NpgsqlParameter.Value">Value</see> is resolved. The default is 0.</value>
349-
[DefaultValue((Byte)0)]
349+
[DefaultValue((byte)0)]
350350
[Category("Data")]
351351
#if NET45
352352
// In mono .NET 4.5 is actually a later version, meaning that virtual Precision and Scale already exist in DbParameter
@@ -468,7 +468,7 @@ public override string ParameterName
468468
_name = value;
469469
if (value == null)
470470
{
471-
_name = String.Empty;
471+
_name = string.Empty;
472472
}
473473
// no longer prefix with : so that The name returned is The name set
474474

@@ -492,7 +492,7 @@ public override string ParameterName
492492
/// The default is an empty string.</value>
493493
[DefaultValue("")]
494494
[Category("Data")]
495-
public override String SourceColumn { get; set; }
495+
public override string SourceColumn { get; set; }
496496

497497
#if NET45 || NET451
498498
/// <summary>

src/Npgsql/NpgsqlTypes/NpgsqlTimeSpan.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ namespace NpgsqlTypes
4949
/// with them a call to <see cref="System.Data.IDataRecord.GetValue(int)"/> on a field containing an
5050
/// <see cref="NpgsqlTimeSpan"/> value will return a <see cref="TimeSpan"/> rather than an
5151
/// <see cref="NpgsqlTimeSpan"/>. If you need the extra functionality of <see cref="NpgsqlTimeSpan"/>
52-
/// then use <see cref="NpgsqlDataReader.GetInterval(Int32)"/>.</para>
52+
/// then use <see cref="NpgsqlDataReader.GetInterval(int)"/>.</para>
5353
/// </remarks>
5454
/// <seealso cref="Ticks"/>
5555
/// <seealso cref="JustifyDays"/>
@@ -614,7 +614,7 @@ public bool Equals(NpgsqlTimeSpan other)
614614
/// Returns true if another object is an <see cref="NpgsqlTimeSpan"/>, that is exactly the same as
615615
/// this instance
616616
/// </summary>
617-
/// <param name="obj">An <see cref="Object"/> for comparison.</param>
617+
/// <param name="obj">An <see cref="object"/> for comparison.</param>
618618
/// <returns>true if the argument is an <see cref="NpgsqlTimeSpan"/> and is exactly the same
619619
/// as this one, false otherwise.</returns>
620620
public override bool Equals([CanBeNull] object obj)
@@ -696,10 +696,10 @@ public int CompareTo([CanBeNull] object other)
696696
#region String Conversions
697697

698698
/// <summary>
699-
/// Parses a <see cref="String"/> and returns a <see cref="NpgsqlTimeSpan"/> instance.
699+
/// Parses a <see cref="string"/> and returns a <see cref="NpgsqlTimeSpan"/> instance.
700700
/// Designed to use the formats generally returned by PostgreSQL.
701701
/// </summary>
702-
/// <param name="str">The <see cref="String"/> to parse.</param>
702+
/// <param name="str">The <see cref="string"/> to parse.</param>
703703
/// <returns>An <see cref="NpgsqlTimeSpan"/> represented by the argument.</returns>
704704
/// <exception cref="ArgumentNullException">The string was null.</exception>
705705
/// <exception cref="OverflowException">A value obtained from parsing the string exceeded the values allowed for the relevant component.</exception>
@@ -773,9 +773,9 @@ private static string SafeSubstring(string s, int startIndex)
773773
}
774774

775775
/// <summary>
776-
/// Attempt to parse a <see cref="String"/> to produce an <see cref="NpgsqlTimeSpan"/>.
776+
/// Attempt to parse a <see cref="string"/> to produce an <see cref="NpgsqlTimeSpan"/>.
777777
/// </summary>
778-
/// <param name="str">The <see cref="String"/> to parse.</param>
778+
/// <param name="str">The <see cref="string"/> to parse.</param>
779779
/// <param name="result">(out) The <see cref="NpgsqlTimeSpan"/> produced, or <see cref="Zero"/> if the parsing failed.</param>
780780
/// <returns>true if the parsing succeeded, false otherwise.</returns>
781781
public static bool TryParse(string str, out NpgsqlTimeSpan result)
@@ -790,7 +790,7 @@ public static bool TryParse(string str, out NpgsqlTimeSpan result)
790790
}
791791

792792
/// <summary>
793-
/// Create a <see cref="String"/> representation of the <see cref="NpgsqlTimeSpan"/> instance.
793+
/// Create a <see cref="string"/> representation of the <see cref="NpgsqlTimeSpan"/> instance.
794794
/// The format returned is of the form:
795795
/// [M mon[s]] [d day[s]] [HH:mm:ss[.f[f[f[f[f[f[f[f[f]]]]]]]]]]
796796
/// A zero <see cref="NpgsqlTimeSpan"/> is represented as 00:00:00
@@ -801,7 +801,7 @@ public static bool TryParse(string str, out NpgsqlTimeSpan result)
801801
/// and also makes this ToString() more applicable to any other use-case.
802802
/// </remarks>
803803
/// </summary>
804-
/// <returns>The <see cref="String"/> representation.</returns>
804+
/// <returns>The <see cref="string"/> representation.</returns>
805805
public override string ToString()
806806
{
807807
var sb = new StringBuilder();

src/Npgsql/NpgsqlTypes/NpgsqlTsVector.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public static NpgsqlTsVector Parse(string value)
121121
WaitWord:
122122
if (pos >= value.Length)
123123
goto Finish;
124-
if (Char.IsWhiteSpace(value[pos]))
124+
if (char.IsWhiteSpace(value[pos]))
125125
{
126126
pos++;
127127
goto WaitWord;
@@ -147,7 +147,7 @@ public static NpgsqlTsVector Parse(string value)
147147
goto WaitEndWord;
148148

149149
WaitEndWord:
150-
if (pos >= value.Length || Char.IsWhiteSpace(value[pos]))
150+
if (pos >= value.Length || char.IsWhiteSpace(value[pos]))
151151
{
152152
lexemes.Add(new Lexeme(sb.ToString()));
153153
if (pos >= value.Length)
@@ -237,7 +237,7 @@ public static NpgsqlTsVector Parse(string value)
237237
goto WaitPosDelim;
238238

239239
WaitPosDelim:
240-
if (pos >= value.Length || Char.IsWhiteSpace(value[pos]))
240+
if (pos >= value.Length || char.IsWhiteSpace(value[pos]))
241241
{
242242
if (pos < value.Length)
243243
pos++;

src/Npgsql/NpgsqlTypes/NpgsqlTypes.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -527,9 +527,9 @@ public static NpgsqlCircle Parse(string s)
527527
throw new FormatException("Not a valid circle: " + s);
528528

529529
return new NpgsqlCircle(
530-
Double.Parse(m.Groups[1].ToString(), NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat),
531-
Double.Parse(m.Groups[2].ToString(), NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat),
532-
Double.Parse(m.Groups[3].ToString(), NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat)
530+
double.Parse(m.Groups[1].ToString(), NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat),
531+
double.Parse(m.Groups[2].ToString(), NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat),
532+
double.Parse(m.Groups[3].ToString(), NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat)
533533
);
534534
}
535535

test/Npgsql.Tests/CopyTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ public void TextExport()
518518
var reader = conn.BeginTextExport("COPY data (field_text, field_int4) TO STDIN");
519519
StateAssertions(conn);
520520
Assert.That(reader.Read(chars, 0, chars.Length), Is.EqualTo(8));
521-
Assert.That(new String(chars, 0, 8), Is.EqualTo("HELLO\t1\n"));
521+
Assert.That(new string(chars, 0, 8), Is.EqualTo("HELLO\t1\n"));
522522
Assert.That(reader.Read(chars, 0, chars.Length), Is.EqualTo(0));
523523
Assert.That(reader.Read(chars, 0, chars.Length), Is.EqualTo(0));
524524
reader.Dispose();

test/Npgsql.Tests/NpgsqlParameterTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public void Constructor2_Value_DBNull()
197197
[Test]
198198
public void Constructor2_Value_Null()
199199
{
200-
var p = new NpgsqlParameter("address", (Object) null);
200+
var p = new NpgsqlParameter("address", (object) null);
201201
Assert.AreEqual(DbType.Object, p.DbType, "A:DbType");
202202
Assert.AreEqual(ParameterDirection.Input, p.Direction, "A:Direction");
203203
Assert.IsFalse(p.IsNullable, "A:IsNullable");
@@ -403,10 +403,10 @@ public void InferType_Invalid()
403403
{
404404
var notsupported = new object[]
405405
{
406-
UInt16.MaxValue,
407-
UInt32.MaxValue,
408-
UInt64.MaxValue,
409-
SByte.MaxValue,
406+
ushort.MaxValue,
407+
uint.MaxValue,
408+
ulong.MaxValue,
409+
sbyte.MaxValue,
410410
new NpgsqlParameter()
411411
};
412412

test/Npgsql.Tests/ReaderTests.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,15 +169,17 @@ public void GetStringWithParameter()
169169
{
170170
conn.ExecuteNonQuery("CREATE TEMP TABLE data (name TEXT)");
171171
const string text = "Random text";
172-
conn.ExecuteNonQuery(String.Format(@"INSERT INTO data (name) VALUES ('{0}')", text));
172+
conn.ExecuteNonQuery($@"INSERT INTO data (name) VALUES ('{text}')");
173173

174174
var command = new NpgsqlCommand("SELECT name FROM data WHERE name = :value;", conn);
175-
var param = new NpgsqlParameter();
176-
param.ParameterName = "value";
177-
param.DbType = DbType.String;
175+
var param = new NpgsqlParameter
176+
{
177+
ParameterName = "value",
178+
DbType = DbType.String,
179+
Size = text.Length,
180+
Value = text
181+
};
178182
//param.NpgsqlDbType = NpgsqlDbType.Text;
179-
param.Size = text.Length;
180-
param.Value = text;
181183
command.Parameters.Add(param);
182184

183185
using (var dr = command.ExecuteReader())

test/Npgsql.Tests/Types/ByteaTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ static string EncodeHex(ICollection<byte> buf)
476476
{
477477
var hex = new StringBuilder(@"E'\\x", buf.Count * 2 + 3);
478478
foreach (var b in buf) {
479-
hex.Append(String.Format("{0:x2}", b));
479+
hex.Append($"{b:x2}");
480480
}
481481
hex.Append("'");
482482
return hex.ToString();

test/Npgsql.Tests/Types/MiscTypeTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -536,17 +536,17 @@ public void Bug1011085()
536536
{
537537
var expectedValue = 8.99m;
538538
command.Parameters.Add("moneyvalue", NpgsqlDbType.Money).Value = expectedValue;
539-
var result = (Decimal) command.ExecuteScalar();
539+
var result = (decimal) command.ExecuteScalar();
540540
Assert.AreEqual(expectedValue, result);
541541

542542
expectedValue = 100m;
543543
command.Parameters[0].Value = expectedValue;
544-
result = (Decimal) command.ExecuteScalar();
544+
result = (decimal) command.ExecuteScalar();
545545
Assert.AreEqual(expectedValue, result);
546546

547547
expectedValue = 72.25m;
548548
command.Parameters[0].Value = expectedValue;
549-
result = (Decimal) command.ExecuteScalar();
549+
result = (decimal) command.ExecuteScalar();
550550
Assert.AreEqual(expectedValue, result);
551551
}
552552
}

0 commit comments

Comments
 (0)