Skip to content

Commit 96b15ca

Browse files
Add XML documentation and inheritdoc to CSV classes
Added <inheritdoc /> tags to public methods and properties in CsvDataReader and numeric type converter classes for improved documentation and code clarity. Also refactored array resizing logic in CsvDataReader for better readability.
1 parent d539f51 commit 96b15ca

File tree

2 files changed

+53
-2
lines changed

2 files changed

+53
-2
lines changed

project/dbatools/Csv/Reader/CsvDataReader.cs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1887,24 +1887,38 @@ public bool IsDBNull(int ordinal)
18871887

18881888
#region Typed Accessors
18891889

1890+
/// <inheritdoc />
18901891
public bool GetBoolean(int ordinal) => (bool)GetValue(ordinal);
1892+
/// <inheritdoc />
18911893
public byte GetByte(int ordinal) => (byte)GetValue(ordinal);
1894+
/// <inheritdoc />
18921895
public char GetChar(int ordinal) => (char)GetValue(ordinal);
1896+
/// <inheritdoc />
18931897
public DateTime GetDateTime(int ordinal) => (DateTime)GetValue(ordinal);
1898+
/// <inheritdoc />
18941899
public decimal GetDecimal(int ordinal) => (decimal)GetValue(ordinal);
1900+
/// <inheritdoc />
18951901
public double GetDouble(int ordinal) => (double)GetValue(ordinal);
1902+
/// <inheritdoc />
18961903
public float GetFloat(int ordinal) => (float)GetValue(ordinal);
1904+
/// <inheritdoc />
18971905
public Guid GetGuid(int ordinal) => (Guid)GetValue(ordinal);
1906+
/// <inheritdoc />
18981907
public short GetInt16(int ordinal) => (short)GetValue(ordinal);
1908+
/// <inheritdoc />
18991909
public int GetInt32(int ordinal) => (int)GetValue(ordinal);
1910+
/// <inheritdoc />
19001911
public long GetInt64(int ordinal) => (long)GetValue(ordinal);
1912+
/// <inheritdoc />
19011913
public string GetString(int ordinal) => GetValue(ordinal)?.ToString();
19021914

1915+
/// <inheritdoc />
19031916
public long GetBytes(int ordinal, long fieldOffset, byte[] buffer, int bufferOffset, int length)
19041917
{
19051918
throw new NotSupportedException("GetBytes is not supported for CSV data");
19061919
}
19071920

1921+
/// <inheritdoc />
19081922
public long GetChars(int ordinal, long fieldOffset, char[] buffer, int bufferOffset, int length)
19091923
{
19101924
string value = GetString(ordinal);
@@ -1916,6 +1930,7 @@ public long GetChars(int ordinal, long fieldOffset, char[] buffer, int bufferOff
19161930
return copyLength;
19171931
}
19181932

1933+
/// <inheritdoc />
19191934
public IDataReader GetData(int ordinal)
19201935
{
19211936
throw new NotSupportedException("Nested data readers are not supported for CSV data");
@@ -3526,10 +3541,12 @@ public void AddStaticColumn(StaticColumn column)
35263541

35273542
_staticColumns.Add(column);
35283543

3529-
if (_convertedValues != null)
3544+
var convertedValues = _convertedValues;
3545+
if (convertedValues != null)
35303546
{
35313547
// Resize converted values array
3532-
Array.Resize(ref _convertedValues, _columns.Count + _staticColumns.Count);
3548+
Array.Resize(ref convertedValues, _columns.Count + _staticColumns.Count);
3549+
_convertedValues = convertedValues;
35333550
}
35343551
}
35353552

@@ -3546,12 +3563,17 @@ public void AddStaticColumn(StaticColumn column)
35463563

35473564
#region IDataReader Members
35483565

3566+
/// <inheritdoc />
35493567
public int Depth => 0;
3568+
/// <inheritdoc />
35503569
public bool IsClosed => _isClosed;
3570+
/// <inheritdoc />
35513571
public int RecordsAffected => -1;
35523572

3573+
/// <inheritdoc />
35533574
public bool NextResult() => false;
35543575

3576+
/// <inheritdoc />
35553577
public void Close()
35563578
{
35573579
if (!_isClosed)
@@ -3575,6 +3597,7 @@ public void Close()
35753597
}
35763598
}
35773599

3600+
/// <inheritdoc />
35783601
public void Dispose()
35793602
{
35803603
Close();

project/dbatools/Csv/TypeConverters/NumericConverters.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,21 @@ namespace Dataplat.Dbatools.Csv.TypeConverters
99
/// </summary>
1010
public sealed class Int16Converter : CultureAwareConverterBase<short>
1111
{
12+
/// <summary>Gets the default instance of the converter.</summary>
1213
public static Int16Converter Default { get; } = new Int16Converter();
1314

15+
/// <summary>Initializes a new instance of the <see cref="Int16Converter"/> class.</summary>
1416
public Int16Converter()
1517
{
1618
NumberStyles = NumberStyles.Integer;
1719
}
1820

21+
/// <inheritdoc />
1922
protected override bool TryParseCore(string value, NumberStyles styles, IFormatProvider provider, out short result)
2023
=> short.TryParse(value, styles, provider, out result);
2124

2225
#if NET8_0_OR_GREATER
26+
/// <inheritdoc />
2327
protected override bool TryParseSpan(ReadOnlySpan<char> value, NumberStyles styles, IFormatProvider provider, out short result)
2428
=> short.TryParse(value, styles, provider, out result);
2529
#endif
@@ -31,17 +35,21 @@ protected override bool TryParseSpan(ReadOnlySpan<char> value, NumberStyles styl
3135
/// </summary>
3236
public sealed class Int32Converter : CultureAwareConverterBase<int>
3337
{
38+
/// <summary>Gets the default instance of the converter.</summary>
3439
public static Int32Converter Default { get; } = new Int32Converter();
3540

41+
/// <summary>Initializes a new instance of the <see cref="Int32Converter"/> class.</summary>
3642
public Int32Converter()
3743
{
3844
NumberStyles = NumberStyles.Integer;
3945
}
4046

47+
/// <inheritdoc />
4148
protected override bool TryParseCore(string value, NumberStyles styles, IFormatProvider provider, out int result)
4249
=> int.TryParse(value, styles, provider, out result);
4350

4451
#if NET8_0_OR_GREATER
52+
/// <inheritdoc />
4553
protected override bool TryParseSpan(ReadOnlySpan<char> value, NumberStyles styles, IFormatProvider provider, out int result)
4654
=> int.TryParse(value, styles, provider, out result);
4755
#endif
@@ -53,17 +61,21 @@ protected override bool TryParseSpan(ReadOnlySpan<char> value, NumberStyles styl
5361
/// </summary>
5462
public sealed class Int64Converter : CultureAwareConverterBase<long>
5563
{
64+
/// <summary>Gets the default instance of the converter.</summary>
5665
public static Int64Converter Default { get; } = new Int64Converter();
5766

67+
/// <summary>Initializes a new instance of the <see cref="Int64Converter"/> class.</summary>
5868
public Int64Converter()
5969
{
6070
NumberStyles = NumberStyles.Integer;
6171
}
6272

73+
/// <inheritdoc />
6374
protected override bool TryParseCore(string value, NumberStyles styles, IFormatProvider provider, out long result)
6475
=> long.TryParse(value, styles, provider, out result);
6576

6677
#if NET8_0_OR_GREATER
78+
/// <inheritdoc />
6779
protected override bool TryParseSpan(ReadOnlySpan<char> value, NumberStyles styles, IFormatProvider provider, out long result)
6880
=> long.TryParse(value, styles, provider, out result);
6981
#endif
@@ -75,17 +87,21 @@ protected override bool TryParseSpan(ReadOnlySpan<char> value, NumberStyles styl
7587
/// </summary>
7688
public sealed class SingleConverter : CultureAwareConverterBase<float>
7789
{
90+
/// <summary>Gets the default instance of the converter.</summary>
7891
public static SingleConverter Default { get; } = new SingleConverter();
7992

93+
/// <summary>Initializes a new instance of the <see cref="SingleConverter"/> class.</summary>
8094
public SingleConverter()
8195
{
8296
NumberStyles = NumberStyles.Float | NumberStyles.AllowThousands;
8397
}
8498

99+
/// <inheritdoc />
85100
protected override bool TryParseCore(string value, NumberStyles styles, IFormatProvider provider, out float result)
86101
=> float.TryParse(value, styles, provider, out result);
87102

88103
#if NET8_0_OR_GREATER
104+
/// <inheritdoc />
89105
protected override bool TryParseSpan(ReadOnlySpan<char> value, NumberStyles styles, IFormatProvider provider, out float result)
90106
=> float.TryParse(value, styles, provider, out result);
91107
#endif
@@ -97,17 +113,21 @@ protected override bool TryParseSpan(ReadOnlySpan<char> value, NumberStyles styl
97113
/// </summary>
98114
public sealed class DoubleConverter : CultureAwareConverterBase<double>
99115
{
116+
/// <summary>Gets the default instance of the converter.</summary>
100117
public static DoubleConverter Default { get; } = new DoubleConverter();
101118

119+
/// <summary>Initializes a new instance of the <see cref="DoubleConverter"/> class.</summary>
102120
public DoubleConverter()
103121
{
104122
NumberStyles = NumberStyles.Float | NumberStyles.AllowThousands;
105123
}
106124

125+
/// <inheritdoc />
107126
protected override bool TryParseCore(string value, NumberStyles styles, IFormatProvider provider, out double result)
108127
=> double.TryParse(value, styles, provider, out result);
109128

110129
#if NET8_0_OR_GREATER
130+
/// <inheritdoc />
111131
protected override bool TryParseSpan(ReadOnlySpan<char> value, NumberStyles styles, IFormatProvider provider, out double result)
112132
=> double.TryParse(value, styles, provider, out result);
113133
#endif
@@ -120,17 +140,21 @@ protected override bool TryParseSpan(ReadOnlySpan<char> value, NumberStyles styl
120140
/// </summary>
121141
public sealed class DecimalConverter : CultureAwareConverterBase<decimal>
122142
{
143+
/// <summary>Gets the default instance of the converter.</summary>
123144
public static DecimalConverter Default { get; } = new DecimalConverter();
124145

146+
/// <summary>Initializes a new instance of the <see cref="DecimalConverter"/> class.</summary>
125147
public DecimalConverter()
126148
{
127149
NumberStyles = NumberStyles.Number;
128150
}
129151

152+
/// <inheritdoc />
130153
protected override bool TryParseCore(string value, NumberStyles styles, IFormatProvider provider, out decimal result)
131154
=> decimal.TryParse(value, styles, provider, out result);
132155

133156
#if NET8_0_OR_GREATER
157+
/// <inheritdoc />
134158
protected override bool TryParseSpan(ReadOnlySpan<char> value, NumberStyles styles, IFormatProvider provider, out decimal result)
135159
=> decimal.TryParse(value, styles, provider, out result);
136160
#endif
@@ -142,17 +166,21 @@ protected override bool TryParseSpan(ReadOnlySpan<char> value, NumberStyles styl
142166
/// </summary>
143167
public sealed class ByteConverter : CultureAwareConverterBase<byte>
144168
{
169+
/// <summary>Gets the default instance of the converter.</summary>
145170
public static ByteConverter Default { get; } = new ByteConverter();
146171

172+
/// <summary>Initializes a new instance of the <see cref="ByteConverter"/> class.</summary>
147173
public ByteConverter()
148174
{
149175
NumberStyles = NumberStyles.Integer;
150176
}
151177

178+
/// <inheritdoc />
152179
protected override bool TryParseCore(string value, NumberStyles styles, IFormatProvider provider, out byte result)
153180
=> byte.TryParse(value, styles, provider, out result);
154181

155182
#if NET8_0_OR_GREATER
183+
/// <inheritdoc />
156184
protected override bool TryParseSpan(ReadOnlySpan<char> value, NumberStyles styles, IFormatProvider provider, out byte result)
157185
=> byte.TryParse(value, styles, provider, out result);
158186
#endif

0 commit comments

Comments
 (0)