Skip to content

Commit 4c2009f

Browse files
committed
Make StyleCop a GlobalPackageReference.
Add style checking to tests; fix errors.
1 parent 246735c commit 4c2009f

Some content is hidden

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

57 files changed

+482
-290
lines changed

Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
<PackageVersion Include="MySql.Data" Version="9.2.0" />
2020
<PackageVersion Include="NLog" Version="4.7.15" />
2121
<PackageVersion Include="Serilog" Version="2.12.0" />
22-
<PackageVersion Include="StyleCop.Analyzers" Version="1.2.0-beta.556" />
2322
<PackageVersion Include="System.Diagnostics.DiagnosticSource" Version="8.0.1" />
2423
<PackageVersion Include="System.Text.Json" Version="9.0.1" />
2524
<PackageVersion Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
@@ -31,6 +30,7 @@
3130
<ItemGroup>
3231
<GlobalPackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
3332
<GlobalPackageReference Include="MinVer" Version="6.0.0" />
33+
<GlobalPackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556" />
3434
</ItemGroup>
3535

3636
</Project>

src/Directory.Build.props

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,6 @@
2727
<MinVerDefaultPreReleaseIdentifiers>beta.0</MinVerDefaultPreReleaseIdentifiers>
2828
</PropertyGroup>
2929

30-
<ItemGroup>
31-
<PackageReference Include="StyleCop.Analyzers">
32-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
33-
<PrivateAssets>all</PrivateAssets>
34-
</PackageReference>
35-
</ItemGroup>
36-
3730
<ItemGroup>
3831
<None Include="..\..\docs\static\img\logo.png" Pack="true" PackagePath="\" />
3932
</ItemGroup>

tests/Conformance.Tests/ConnectionStringBuilderTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,3 @@ public ConnectionStringBuilderTests(DbFactoryFixture fixture)
99
{
1010
}
1111
}
12-

tests/Conformance.Tests/DataReaderTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,7 @@ public DataReaderTests(SelectValueFixture fixture)
1111
}
1212

1313
[Fact(Skip = "Deliberately throws InvalidCastException")]
14-
public override void GetTextReader_returns_empty_for_null_String() { }
14+
public override void GetTextReader_returns_empty_for_null_String()
15+
{
16+
}
1517
}

tests/Conformance.Tests/GetValueConversionTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,6 @@ public GetValueConversionTests(SelectValueFixture fixture)
270270
public override void GetByte_throws_for_zero_Decimal_with_GetFieldValue() => TestGetValue(DbType.Decimal, ValueKind.Zero, x => x.GetFieldValue<byte>(0), (byte) 0);
271271
public override Task GetByte_throws_for_zero_Decimal_with_GetFieldValueAsync() => TestGetValueAsync(DbType.Decimal, ValueKind.Zero, x => x.GetFieldValueAsync<byte>(0), (byte) 0);
272272

273-
274273
// the minimum date permitted by MySQL is 1000-01-01; override the minimum value for DateTime tests
275274
public override void GetDateTime_for_minimum_Date() => TestGetValue(DbType.Date, ValueKind.Minimum, x => x.GetDateTime(0), new DateTime(1000, 1, 1));
276275
public override void GetDateTime_for_minimum_Date_with_GetFieldValue() => TestGetValue(DbType.Date, ValueKind.Minimum, x => x.GetFieldValue<DateTime>(0), new DateTime(1000, 1, 1));

tests/Conformance.Tests/packages.lock.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@
4040
"resolved": "6.0.0",
4141
"contentHash": "+/SsmiySsXJlvQLCGBqaZKNVt3s/Y/HbAdwtop7Km2CnuZbaScoqkWJEBQ5Cy9ebkn6kCYKrHsXgwrFdTgcb3g=="
4242
},
43+
"StyleCop.Analyzers": {
44+
"type": "Direct",
45+
"requested": "[1.2.0-beta.556, )",
46+
"resolved": "1.2.0-beta.556",
47+
"contentHash": "llRPgmA1fhC0I0QyFLEcjvtM2239QzKr/tcnbsjArLMJxJlu0AA5G7Fft0OI30pHF3MW63Gf4aSSsjc5m82J1Q==",
48+
"dependencies": {
49+
"StyleCop.Analyzers.Unstable": "1.2.0.556"
50+
}
51+
},
4352
"xunit": {
4453
"type": "Direct",
4554
"requested": "[2.9.3, )",
@@ -107,6 +116,11 @@
107116
"resolved": "13.0.1",
108117
"contentHash": "ppPFpBcvxdsfUonNcvITKqLl3bqxWbDCZIzDWHzjpdAHRFfZe0Dw9HmA0+za13IdyrgJwpkDTDA9fHaxOrt20A=="
109118
},
119+
"StyleCop.Analyzers.Unstable": {
120+
"type": "Transitive",
121+
"resolved": "1.2.0.556",
122+
"contentHash": "zvn9Mqs/ox/83cpYPignI8hJEM2A93s2HkHs8HYMOAQW0PkampyoErAiIyKxgTLqbbad29HX/shv/6LGSjPJNQ=="
123+
},
110124
"System.Reflection.Metadata": {
111125
"type": "Transitive",
112126
"resolved": "1.6.0",

tests/Directory.Build.props

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project>
2+
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
3+
4+
<PropertyGroup>
5+
<NoWarn>$(NoWarn);SA0001</NoWarn>
6+
</PropertyGroup>
7+
8+
</Project>

tests/IntegrationTests/BatchTests.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,6 @@ public void SingleRow(bool prepare)
278278
Assert.Equal(3, reader.GetInt32(0));
279279
Assert.False(reader.Read());
280280
}
281-
282281
}
283282

284283
[Fact]
@@ -344,7 +343,7 @@ public void PrepareNeedsCommandsWithText()
344343
private static string GetIgnoreCommandTransactionConnectionString() =>
345344
new MySqlConnectionStringBuilder(AppConfig.ConnectionString)
346345
{
347-
IgnoreCommandTransaction = true
346+
IgnoreCommandTransaction = true,
348347
}.ConnectionString;
349348
}
350349
#endif

tests/IntegrationTests/BulkLoaderAsync.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public async Task BulkLoadLocalCsvFileNotFound()
160160
await connection.OpenAsync();
161161
MySqlBulkLoader bl = new MySqlBulkLoader(connection)
162162
{
163-
Timeout = 3, //Set a short timeout for this test because the file not found exception takes a long time otherwise, the timeout does not change the result
163+
Timeout = 3, // Set a short timeout for this test because the file not found exception takes a long time otherwise, the timeout does not change the result
164164
FileName = AppConfig.MySqlBulkLoaderLocalCsvFile + "-junk",
165165
TableName = m_testTable,
166166
CharacterSet = "UTF8",
@@ -197,7 +197,7 @@ public async Task BulkLoadLocalCsvFileNotFound()
197197
}
198198
catch (Exception exception)
199199
{
200-
//We know that the exception is not a MySqlException, just use the assertion to fail the test
200+
// We know that the exception is not a MySqlException, just use the assertion to fail the test
201201
Assert.IsType<MySqlException>(exception);
202202
}
203203
}
@@ -640,6 +640,6 @@ public async Task BulkCopyNullDataReader()
640640
private static string GetConnectionString() => BulkLoaderSync.GetConnectionString();
641641
private static string GetLocalConnectionString() => BulkLoaderSync.GetLocalConnectionString();
642642

643-
readonly string m_testTable;
644-
readonly byte[] m_memoryStreamBytes;
643+
private readonly string m_testTable;
644+
private readonly byte[] m_memoryStreamBytes;
645645
}

tests/IntegrationTests/BulkLoaderSync.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public void BulkLoadLocalCsvFileNotFound()
179179
connection.Open();
180180
MySqlBulkLoader bl = new MySqlBulkLoader(connection)
181181
{
182-
Timeout = 3, //Set a short timeout for this test because the file not found exception takes a long time otherwise, the timeout does not change the result
182+
Timeout = 3, // Set a short timeout for this test because the file not found exception takes a long time otherwise, the timeout does not change the result
183183
FileName = AppConfig.MySqlBulkLoaderLocalCsvFile + "-junk",
184184
TableName = m_testTable,
185185
CharacterSet = "UTF8",
@@ -216,7 +216,7 @@ public void BulkLoadLocalCsvFileNotFound()
216216
}
217217
catch (Exception exception)
218218
{
219-
//We know that the exception is not a MySqlException, just use the assertion to fail the test
219+
// We know that the exception is not a MySqlException, just use the assertion to fail the test
220220
Assert.IsType<MySqlException>(exception);
221221
}
222222
}
@@ -1048,7 +1048,7 @@ public void BulkCopyColumnMappings()
10481048
new object[] { 1, 100, "a", "A", new byte[] { 0x33, 0x30 } },
10491049
new object[] { 2, 200, "bb", "BB", new byte[] { 0x33, 0x31 } },
10501050
new object[] { 3, 300, "ccc", "CCC", new byte[] { 0x33, 0x32 } },
1051-
}
1051+
},
10521052
};
10531053

10541054
var result = bulkCopy.WriteToServer(dataTable);
@@ -1102,7 +1102,7 @@ public void BulkCopyColumnMappingsInvalidSourceOrdinal()
11021102
new object[] { 1 },
11031103
new object[] { 2 },
11041104
new object[] { 3 },
1105-
}
1105+
},
11061106
};
11071107

11081108
Assert.Throws<InvalidOperationException>(() => bulkCopy.WriteToServer(dataTable));
@@ -1139,7 +1139,7 @@ public void BulkCopyColumnMappingsInvalidDestinationColumn()
11391139
new object[] { 1 },
11401140
new object[] { 2 },
11411141
new object[] { 3 },
1142-
}
1142+
},
11431143
};
11441144

11451145
Assert.Throws<InvalidOperationException>(() => bulkCopy.WriteToServer(dataTable));
@@ -1156,7 +1156,7 @@ public void BulkCopyDoesNotInsertAllRows()
11561156

11571157
var bcp = new MySqlBulkCopy(connection)
11581158
{
1159-
DestinationTableName = "bulk_copy_duplicate_pk"
1159+
DestinationTableName = "bulk_copy_duplicate_pk",
11601160
};
11611161

11621162
var dataTable = new DataTable()
@@ -1171,7 +1171,7 @@ public void BulkCopyDoesNotInsertAllRows()
11711171
new object[] { 1, "a" },
11721172
new object[] { 1, "b" },
11731173
new object[] { 3, "c" },
1174-
}
1174+
},
11751175
};
11761176

11771177
var ex = Assert.Throws<MySqlException>(() => bcp.WriteToServer(dataTable));
@@ -1295,6 +1295,6 @@ internal static string GetLocalConnectionString()
12951295
return csb.ConnectionString;
12961296
}
12971297

1298-
readonly string m_testTable;
1299-
readonly byte[] m_memoryStreamBytes;
1298+
private readonly string m_testTable;
1299+
private readonly byte[] m_memoryStreamBytes;
13001300
}

0 commit comments

Comments
 (0)