Skip to content

Commit 0577957

Browse files
dotnet format/spellchecking (#5988)
1 parent cc5e639 commit 0577957

File tree

332 files changed

+1273
-1189
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

332 files changed

+1273
-1189
lines changed

.editorconfig

+19-1
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,10 @@ dotnet_diagnostic.IDE2004.severity = warning
306306
dotnet_diagnostic.CA1822.severity = suggestion
307307

308308
[test/**/*.cs]
309+
# IDE0044: Don't force readonly for tests
310+
dotnet_diagnostic.IDE0044.severity = none
311+
dotnet_style_readonly_field = false
312+
309313
# MSML_GeneralName: This name should be PascalCased
310314
dotnet_diagnostic.MSML_GeneralName.severity = none
311315

@@ -322,4 +326,18 @@ dotnet_diagnostic.MSML_ExtendBaseTestClass.severity = none
322326

323327
# The MSML_RelaxTestNaming suppressor for VSTHRD200 is not active for CodeAnalyzer.Tests, so we disable it altogether.
324328
# VSTHRD200: Use "Async" suffix for async methods
325-
dotnet_diagnostic.VSTHRD200.severity = none
329+
dotnet_diagnostic.VSTHRD200.severity = none
330+
331+
[docs/**/*.cs]
332+
# IDE0073: Dont want license file header in samples
333+
dotnet_diagnostic.IDE0073.severity = none
334+
file_header_template = unset
335+
336+
# IDE0044: Don't force readonly for samples
337+
dotnet_diagnostic.IDE0044.severity = none
338+
dotnet_style_readonly_field = false
339+
340+
[test/Microsoft.ML.TestFrameworkCommon/Utility/*.cs]
341+
# IDE0073: Dont want license file header in code we are using from elsewhere
342+
dotnet_diagnostic.IDE0073.severity = none
343+
file_header_template = unset

Directory.Build.props

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<DebugType>portable</DebugType>
1818
<DebugSymbols>true</DebugSymbols>
1919
<LangVersion>latest</LangVersion>
20+
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
2021
</PropertyGroup>
2122

2223
<PropertyGroup>

docs/samples/Microsoft.ML.AutoML.Samples/RankingExperiment.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Text;
43
using System.IO;
54
using System.Linq;
6-
using Microsoft.ML.Data;
5+
using System.Text;
76
using Microsoft.ML.AutoML.Samples.DataStructures;
7+
using Microsoft.ML.Data;
88

99
namespace Microsoft.ML.AutoML.Samples
1010
{

docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/MulticlassClassification/ImageClassification/ResnetV2101TransferLearningEarlyStopping.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
using System;
33
using System.Collections.Generic;
44
using System.IO;
5+
using System.IO.Compression;
6+
using System.Linq;
7+
using System.Net;
8+
using System.Threading;
59
using System.Threading.Tasks;
610
using Microsoft.ML;
7-
using static Microsoft.ML.DataOperationsCatalog;
8-
using System.Linq;
911
using Microsoft.ML.Data;
10-
using System.IO.Compression;
11-
using System.Threading;
12-
using System.Net;
1312
using Microsoft.ML.Vision;
13+
using static Microsoft.ML.DataOperationsCatalog;
1414

1515
namespace Samples.Dynamic
1616
{

docs/samples/Microsoft.ML.Samples/Dynamic/Transforms/CustomMappingWithInMemoryCustomType.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class CustomMappingWithInMemoryCustomType
1818
// AlienBody members to produce a SuperAlienHero entity with a "Name" member of type
1919
// string and a single "Merged" member of type AlienBody, where the merger is just
2020
// the addition of the various members of AlienBody.
21-
static public void Example()
21+
public static void Example()
2222
{
2323
var mlContext = new MLContext();
2424
// Build in-memory data.

docs/samples/Microsoft.ML.Samples/Dynamic/Transforms/ImageAnalytics/ConvertToGrayScaleInMemory.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace Samples.Dynamic
77
{
88
class ConvertToGrayScaleInMemory
99
{
10-
static public void Example()
10+
public static void Example()
1111
{
1212
var mlContext = new MLContext();
1313
// Create an image list.

docs/samples/Microsoft.ML.Samples/Dynamic/Transforms/TimeSeries/ForecastingWithConfidenceInterval.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.IO;
34
using Microsoft.ML;
45
using Microsoft.ML.Transforms.TimeSeries;
5-
using System.IO;
66

77
namespace Samples.Dynamic
88
{

src/Microsoft.Data.Analysis/ArrowStringDataFrameColumn.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ namespace Microsoft.Data.Analysis
2020
/// </summary>
2121
public partial class ArrowStringDataFrameColumn : DataFrameColumn, IEnumerable<string>
2222
{
23-
private IList<ReadOnlyDataFrameBuffer<byte>> _dataBuffers;
24-
private IList<ReadOnlyDataFrameBuffer<int>> _offsetsBuffers;
25-
private IList<ReadOnlyDataFrameBuffer<byte>> _nullBitMapBuffers;
23+
private readonly IList<ReadOnlyDataFrameBuffer<byte>> _dataBuffers;
24+
private readonly IList<ReadOnlyDataFrameBuffer<int>> _offsetsBuffers;
25+
private readonly IList<ReadOnlyDataFrameBuffer<byte>> _nullBitMapBuffers;
2626

2727
/// <summary>
2828
/// Constructs an empty <see cref="ArrowStringDataFrameColumn"/> with the given <paramref name="name"/>.
@@ -40,7 +40,7 @@ public ArrowStringDataFrameColumn(string name) : base(name, 0, typeof(string))
4040
/// </summary>
4141
/// <param name="name">The name of the column.</param>
4242
/// <param name="values">The Arrow formatted string values in this column.</param>
43-
/// <param name="offsets">The Arrow formatted offets in this column.</param>
43+
/// <param name="offsets">The Arrow formatted offsets in this column.</param>
4444
/// <param name="nullBits">The Arrow formatted null bits in this column.</param>
4545
/// <param name="length">The length of the column.</param>
4646
/// <param name="nullCount">The number of <see langword="null" /> values in this column.</param>

src/Microsoft.Data.Analysis/DataFrame.IO.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,10 @@ private static DataFrame ReadCsvLinesIntoDataFrame(WrappedStreamReaderOrStringRe
293293

294294
private class WrappedStreamReaderOrStringReader
295295
{
296-
private Stream _stream;
297-
private long _initialPosition;
298-
private Encoding _encoding;
299-
private string _csvString;
296+
private readonly Stream _stream;
297+
private readonly long _initialPosition;
298+
private readonly Encoding _encoding;
299+
private readonly string _csvString;
300300

301301
public WrappedStreamReaderOrStringReader(Stream stream, Encoding encoding)
302302
{

src/Microsoft.Data.Analysis/DataFrame.Join.cs

+16-16
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public DataFrame Join(DataFrame other, string leftSuffix = "_left", string right
142142
return ret;
143143
}
144144

145-
private static bool IsAnyNullValueInColumns (IReadOnlyCollection<DataFrameColumn> columns, long index)
145+
private static bool IsAnyNullValueInColumns(IReadOnlyCollection<DataFrameColumn> columns, long index)
146146
{
147147
foreach (var column in columns)
148148
{
@@ -176,19 +176,19 @@ private static HashSet<long> Merge(DataFrame retainedDataFrame, DataFrame supple
176176
throw new ArgumentNullException(nameof(supplemetaryJoinColumnNames));
177177

178178
if (retainedJoinColumnNames.Length != supplemetaryJoinColumnNames.Length)
179-
throw new ArgumentException(Strings.MismatchedArrayLengths, nameof(retainedJoinColumnNames));
180-
179+
throw new ArgumentException(Strings.MismatchedArrayLengths, nameof(retainedJoinColumnNames));
180+
181181

182182
HashSet<long> intersection = calculateIntersection ? new HashSet<long>() : null;
183183

184184
// Get occurrences of values in columns used for join in the retained and supplementary dataframes
185185
Dictionary<long, ICollection<long>> occurrences = null;
186186
Dictionary<long, long> retainedIndicesReverseMapping = null;
187-
187+
188188
HashSet<long> supplementaryJoinColumnsNullIndices = new HashSet<long>();
189189

190-
191-
for (int colNameIndex = 0; colNameIndex < retainedJoinColumnNames.Length; colNameIndex++)
190+
191+
for (int colNameIndex = 0; colNameIndex < retainedJoinColumnNames.Length; colNameIndex++)
192192
{
193193
DataFrameColumn shrinkedRetainedColumn = retainedDataFrame.Columns[retainedJoinColumnNames[colNameIndex]];
194194

@@ -211,7 +211,7 @@ private static HashSet<long> Merge(DataFrame retainedDataFrame, DataFrame supple
211211
retainedIndicesReverseMapping = newRetainedIndicesReverseMapping;
212212
shrinkedRetainedColumn = shrinkedRetainedColumn.Clone(new Int64DataFrameColumn("Indices", shrinkedRetainedIndices));
213213
}
214-
214+
215215
DataFrameColumn supplementaryColumn = supplementaryDataFrame.Columns[supplemetaryJoinColumnNames[colNameIndex]];
216216

217217
//Find occurrenses on current step (join column)
@@ -222,7 +222,7 @@ private static HashSet<long> Merge(DataFrame retainedDataFrame, DataFrame supple
222222
newOccurrences = newOccurrences.ToDictionary(kvp => retainedIndicesReverseMapping[kvp.Key], kvp => kvp.Value);
223223

224224
supplementaryJoinColumnsNullIndices.UnionWith(supplementaryColumnNullIndices);
225-
225+
226226
// shrink join result on current column by previous join columns (if any)
227227
// (we have to remove occurrences that doesn't exist in previous columns, because JOIN happens only if ALL left and right columns in JOIN are matched)
228228
if (occurrences != null)
@@ -242,7 +242,7 @@ private static HashSet<long> Merge(DataFrame retainedDataFrame, DataFrame supple
242242

243243
occurrences = newOccurrences;
244244
}
245-
245+
246246
retainedRowIndices = new Int64DataFrameColumn("RetainedIndices");
247247
supplementaryRowIndices = new Int64DataFrameColumn("SupplementaryIndices");
248248

@@ -280,18 +280,18 @@ private static HashSet<long> Merge(DataFrame retainedDataFrame, DataFrame supple
280280
}
281281
}
282282
else
283-
{
283+
{
284284
foreach (long row in supplementaryJoinColumnsNullIndices)
285285
{
286286
retainedRowIndices.Append(i);
287287
supplementaryRowIndices.Append(row);
288288
}
289289
}
290290
}
291-
291+
292292
return intersection;
293293
}
294-
294+
295295
public DataFrame Merge(DataFrame other, string[] leftJoinColumns, string[] rightJoinColumns, string leftSuffix = "_left", string rightSuffix = "_right", JoinAlgorithm joinAlgorithm = JoinAlgorithm.Left)
296296
{
297297
if (other == null)
@@ -335,7 +335,7 @@ public DataFrame Merge(DataFrame other, string[] leftJoinColumns, string[] right
335335
else if (joinAlgorithm == JoinAlgorithm.FullOuter)
336336
{
337337
//In full outer join we would like to retain data from both side, so we do it into 2 steps: one first we do LEFT JOIN and then add lost data from the RIGHT side
338-
338+
339339
//Step 1
340340
//Do LEFT JOIN
341341
isLeftDataFrameRetained = true;
@@ -347,7 +347,7 @@ public DataFrame Merge(DataFrame other, string[] leftJoinColumns, string[] right
347347
var retainedJoinColumns = isLeftDataFrameRetained ? leftJoinColumns : rightJoinColumns;
348348

349349
var intersection = Merge(retainedDataFrame, supplementaryDataFrame, retainedJoinColumns, supplementaryJoinColumns, out retainedRowIndices, out supplementaryRowIndices, calculateIntersection: true);
350-
350+
351351
//Step 2
352352
//Do RIGHT JOIN to retain all data from supplementary DataFrame too (take into account data intersection from the first step to avoid duplicates)
353353
for (long i = 0; i < supplementaryDataFrame.Columns.RowCount; i++)
@@ -365,9 +365,9 @@ public DataFrame Merge(DataFrame other, string[] leftJoinColumns, string[] right
365365
}
366366
else
367367
throw new NotImplementedException(nameof(joinAlgorithm));
368-
368+
369369
DataFrame ret = new DataFrame();
370-
370+
371371
//insert columns from left dataframe (this)
372372
for (int i = 0; i < this.Columns.Count; i++)
373373
{

src/Microsoft.Data.Analysis/DataFrameColumn.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ protected Dictionary<long, ICollection<long>> GetGroupedOccurrences<TKey>(DataFr
244244
ret.Add(i, otherRowIndices);
245245
}
246246
}
247-
247+
248248
return ret;
249249
}
250250

src/Microsoft.Data.Analysis/DataFrameColumnCollection.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ namespace Microsoft.Data.Analysis
1313
/// </summary>
1414
public class DataFrameColumnCollection : Collection<DataFrameColumn>
1515
{
16-
private Action ColumnsChanged;
16+
private readonly Action ColumnsChanged;
1717

18-
private List<string> _columnNames = new List<string>();
18+
private readonly List<string> _columnNames = new List<string>();
1919

20-
private Dictionary<string, int> _columnNameToIndexDictionary = new Dictionary<string, int>(StringComparer.Ordinal);
20+
private readonly Dictionary<string, int> _columnNameToIndexDictionary = new Dictionary<string, int>(StringComparer.Ordinal);
2121

2222
internal long RowCount { get; set; }
2323

src/Microsoft.Data.Analysis/GroupBy.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ IEnumerator IEnumerable.GetEnumerator()
101101

102102
#endregion
103103

104-
private int _groupByColumnIndex;
105-
private IDictionary<TKey, ICollection<long>> _keyToRowIndicesMap;
106-
private DataFrame _dataFrame;
104+
private readonly int _groupByColumnIndex;
105+
private readonly IDictionary<TKey, ICollection<long>> _keyToRowIndicesMap;
106+
private readonly DataFrame _dataFrame;
107107

108108
public GroupBy(DataFrame dataFrame, int groupByColumnIndex, IDictionary<TKey, ICollection<long>> keyToRowIndices)
109109
{

src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace Microsoft.Data.Analysis
2020
public partial class PrimitiveDataFrameColumn<T> : DataFrameColumn, IEnumerable<T?>
2121
where T : unmanaged
2222
{
23-
private PrimitiveColumnContainer<T> _columnContainer;
23+
private readonly PrimitiveColumnContainer<T> _columnContainer;
2424

2525
internal PrimitiveColumnContainer<T> ColumnContainer => _columnContainer;
2626

src/Microsoft.Data.Analysis/StringDataFrameColumn.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace Microsoft.Data.Analysis
1717
/// <remarks> Is NOT Arrow compatible </remarks>
1818
public partial class StringDataFrameColumn : DataFrameColumn, IEnumerable<string>
1919
{
20-
private List<List<string>> _stringBuffers = new List<List<string>>(); // To store more than intMax number of strings
20+
private readonly List<List<string>> _stringBuffers = new List<List<string>>(); // To store more than intMax number of strings
2121

2222
public StringDataFrameColumn(string name, long length = 0) : base(name, length, typeof(string))
2323
{

0 commit comments

Comments
 (0)