WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 8223e55

Browse files
authored
Merge pull request #25 from BenjaminAbt/feature/fix-warnings
add analyzer and fix warnings
2 parents 03e9ca5 + 471864a commit 8223e55

20 files changed

+183
-113
lines changed

.editorconfig

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,15 +288,32 @@ dotnet_naming_style.pascal_case.capitalization = pascal_case
288288

289289
# IDE0290: Use primary constructor
290290
dotnet_diagnostic.IDE0290.severity = none
291+
#################################################### SYSLIB Style
292+
293+
# SYSLIB1006: Multiple logging methods are using event id x in class y
294+
dotnet_diagnostic.SYSLIB1006.severity = error
295+
296+
#################################################### xUnit Style
297+
298+
# xUnit1048: Support for 'async void' unit tests is being removed from xUnit.net v3. To simplify upgrading, convert the test to 'async Task' instead.
299+
dotnet_diagnostic.xUnit1048.severity = error
300+
301+
#################################################### Project Style
291302

292303
# MA0016: Prefer using collection abstraction instead of implementation
293-
dotnet_diagnostic.MA0016.severity = none
304+
dotnet_diagnostic.MA0016.severity = silent
294305

295306
# MA0017: Abstract types should not have public or internal constructors
296307
dotnet_diagnostic.MA0017.severity = none
297308

298309
# MA0018: Do not declare static members on generic types (deprecated; use CA1000 instead)
299310
dotnet_diagnostic.MA0018.severity = none
300311

312+
# MA0048: File name must match type name
313+
dotnet_diagnostic.MA0048.severity = silent
314+
315+
# MA0051: Method is too long (80 lines; maximum allowed: 60)
316+
dotnet_diagnostic.MA0051.severity = suggestion
317+
301318
# MA0154: Use langword in XML comment
302-
dotnet_diagnostic.MA0154.severity = none
319+
dotnet_diagnostic.MA0154.severity = none

Directory.Build.props

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</PropertyGroup>
1818

1919
<PropertyGroup Label="Env">
20-
<IsTestProject>$(MSBuildProjectName.Contains('Test'))</IsTestProject>
20+
<IsUnitTestProject>$(MSBuildProjectName.EndsWith('UnitTests'))</IsUnitTestProject>
2121
<IsBenchmarkProject>$(MsBuildProjectName.Contains('Benchmark'))</IsBenchmarkProject>
2222
</PropertyGroup>
2323

@@ -48,7 +48,7 @@
4848
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
4949
</PropertyGroup>
5050

51-
<PropertyGroup Condition="'$(IsTestProject)' != 'true' AND '$(IsBenchmarkProject)' != 'true'">
51+
<PropertyGroup Condition="'$(IsUnitTestProject)' != 'true' AND '$(IsBenchmarkProject)' != 'true'">
5252
<GenerateDocumentationFile>true</GenerateDocumentationFile>
5353
</PropertyGroup>
5454

@@ -65,4 +65,47 @@
6565
1e91649c
6666
</PublicKey>
6767
</PropertyGroup>
68+
69+
<ItemGroup Label="Analyzers">
70+
<PackageReference Include="Roslynator.Analyzers">
71+
<PrivateAssets>all</PrivateAssets>
72+
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
73+
</PackageReference>
74+
<PackageReference Include="Roslynator.Formatting.Analyzers">
75+
<PrivateAssets>all</PrivateAssets>
76+
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
77+
</PackageReference>
78+
<PackageReference Include="Roslynator.CodeAnalysis.Analyzers">
79+
<PrivateAssets>all</PrivateAssets>
80+
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
81+
</PackageReference>
82+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" />
83+
<PackageReference Include="Microsoft.CodeAnalysis.Common" />
84+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" />
85+
<PackageReference Include="Meziantou.Analyzer">
86+
<PrivateAssets>all</PrivateAssets>
87+
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
88+
</PackageReference>
89+
</ItemGroup>
90+
91+
<ItemGroup Condition="'$(IsUnitTestProject)' == 'true'">
92+
<PackageReference Include="Microsoft.NET.Test.Sdk" />
93+
<PackageReference Include="NSubstitute" />
94+
<PackageReference Include="NSubstitute.Analyzers.CSharp">
95+
<PrivateAssets>all</PrivateAssets>
96+
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
97+
</PackageReference>
98+
<PackageReference Include="xunit.v3" />
99+
<PackageReference Include="xunit.v3.extensibility.core"/>
100+
<PackageReference Include="xunit.v3.assert" />
101+
<PackageReference Include="xunit.runner.console">
102+
<PrivateAssets>all</PrivateAssets>
103+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
104+
</PackageReference>
105+
<PackageReference Include="xunit.runner.visualstudio">
106+
<PrivateAssets>all</PrivateAssets>
107+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
108+
</PackageReference>
109+
<PackageReference Include="FluentValidation" />
110+
</ItemGroup>
68111
</Project>

Directory.Packages.props

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,33 +15,48 @@
1515
</PackageVersion>
1616
</ItemGroup>
1717

18-
<ItemGroup Label="Tests">
19-
<PackageVersion Include="FluentValidation" Version="11.10.0" />
18+
<ItemGroup Label="Benchmark">
2019
<PackageVersion Include="BenchmarkDotNet" Version="0.14.0" />
21-
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
22-
<PackageVersion Include="xunit" Version="2.9.2" />
23-
<PackageVersion Include="xunit.runner.console" Version="2.9.2">
20+
</ItemGroup>
21+
22+
<ItemGroup Label="Tests">
23+
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
24+
<PackageVersion Include="Microsoft.Extensions.Diagnostics.Testing" Version="9.1.0" />
25+
<PackageVersion Include="NSubstitute" Version="5.3.0" />
26+
<PackageVersion Include="NSubstitute.Analyzers.CSharp" Version="1.0.17">
2427
<PrivateAssets>all</PrivateAssets>
25-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
28+
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
2629
</PackageVersion>
27-
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2">
30+
<PackageVersion Include="xunit.v3" Version="1.0.1" />
31+
<PackageVersion Include="xunit.v3.extensibility.core" Version="1.0.1" />
32+
<PackageVersion Include="xunit.v3.assert" Version="1.0.1" />
33+
<PackageVersion Include="xunit.runner.console" Version="2.9.3">
2834
<PrivateAssets>all</PrivateAssets>
2935
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3036
</PackageVersion>
31-
<PackageVersion Include="coverlet.msbuild" Version="6.0.2">
37+
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.1">
3238
<PrivateAssets>all</PrivateAssets>
33-
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
39+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3440
</PackageVersion>
35-
<PackageVersion Include="NSubstitute" Version="5.0.0" />
41+
<PackageVersion Include="FluentValidation" Version="11.10.0" />
3642
</ItemGroup>
3743

3844
<ItemGroup Label="Analyzers">
39-
<PackageVersion Include="Roslynator.Analyzers" Version="4.3.0">
45+
<PackageVersion Include="Roslynator.Analyzers" Version="4.12.9">
46+
<PrivateAssets>all</PrivateAssets>
47+
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
48+
</PackageVersion>
49+
<PackageVersion Include="Roslynator.Formatting.Analyzers" Version="4.12.9">
50+
<PrivateAssets>all</PrivateAssets>
51+
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
52+
</PackageVersion>
53+
<PackageVersion Include="Roslynator.CodeAnalysis.Analyzers" Version="4.12.9">
4054
<PrivateAssets>all</PrivateAssets>
4155
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
4256
</PackageVersion>
43-
<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="4.5.0" />
44-
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.5.0" />
57+
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.11.0" />
58+
<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="4.11.0" />
59+
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.11.0" />
4560
<PackageVersion Include="Meziantou.Analyzer" Version="2.0.179">
4661
<PrivateAssets>all</PrivateAssets>
4762
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"sdk": {
3-
"version": "9.0.100"
3+
"version": "9.0.200"
44
}
55
}

public.snk

-160 Bytes
Binary file not shown.

src/StrongOf.AspNetCore/StrongOf.AspNetCore.csproj

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@
44
<AssemblyName>$(GlobalAssemblyNamePrefix).AspNetCore</AssemblyName>
55
</PropertyGroup>
66

7-
<ItemGroup Label="Analyzers">
8-
<PackageReference Include="Meziantou.Analyzer">
9-
<PrivateAssets>all</PrivateAssets>
10-
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
11-
</PackageReference>
12-
</ItemGroup>
13-
147
<PropertyGroup Label="Package">
158
<PackageId>StrongOf.AspNetCore</PackageId>
169
<IsPackable>true</IsPackable>

src/StrongOf.FluentValidation/StrongOf.FluentValidation.csproj

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@
44
<AssemblyName>$(GlobalAssemblyNamePrefix).FluentValidation</AssemblyName>
55
</PropertyGroup>
66

7-
<ItemGroup Label="Analyzers">
8-
<PackageReference Include="Meziantou.Analyzer">
9-
<PrivateAssets>all</PrivateAssets>
10-
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
11-
</PackageReference>
12-
</ItemGroup>
13-
147
<PropertyGroup Label="Package">
158
<PackageId>StrongOf.FluentValidation</PackageId>
169
<IsPackable>true</IsPackable>

src/StrongOf.Json/StrongOf.Json.csproj

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@
44
<AssemblyName>$(GlobalAssemblyNamePrefix).Json</AssemblyName>
55
</PropertyGroup>
66

7-
<ItemGroup Label="Analyzers">
8-
<PackageReference Include="Meziantou.Analyzer">
9-
<PrivateAssets>all</PrivateAssets>
10-
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
11-
</PackageReference>
12-
</ItemGroup>
13-
147
<PropertyGroup Label="Package">
158
<PackageId>StrongOf.Json</PackageId>
169
<IsPackable>true</IsPackable>

src/StrongOf/StrongDateTime.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,13 @@ public static bool TryParse(ReadOnlySpan<char> content, IFormatProvider? provide
197197
/// <returns>A string representation of value of the current StrongDateTime object as specified by format.</returns>
198198
public string ToString(string format, IFormatProvider? provider = null) => Value.ToString(format, provider);
199199

200+
/// <summary>
201+
/// Returns a string that represents the current object.
202+
/// </summary>
203+
/// <param name="provider">An IFormatProvider that supplies culture-specific formatting information.</param>
204+
/// <returns>A string that represents the current object.</returns>
205+
public string ToString(IFormatProvider? provider) => Value!.ToString(provider)!;
206+
200207
/// <summary>
201208
/// Converts the value of the current StrongDateTime object to its equivalent string representation in ISO 8601 format.
202209
/// </summary>

src/StrongOf/StrongOf.csproj

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@
44
<AssemblyName>$(GlobalAssemblyNamePrefix)</AssemblyName>
55
</PropertyGroup>
66

7-
<ItemGroup Label="Analyzers">
8-
<PackageReference Include="Meziantou.Analyzer">
9-
<PrivateAssets>all</PrivateAssets>
10-
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
11-
</PackageReference>
12-
</ItemGroup>
13-
147
<PropertyGroup Label="Package">
158
<PackageId>StrongOf</PackageId>
169
<IsPackable>true</IsPackable>

0 commit comments

Comments
 (0)