Skip to content

Commit 6c442cf

Browse files
author
Gérald Barré
committed
Update all dependencies and fix issues with new versions of analyzers
1 parent 5d2d4de commit 6c442cf

12 files changed

+212
-65
lines changed

Build.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Process {
3131
Exec { & dotnet run --project=tools/ConfigurationFilesGenerator/ConfigurationFilesGenerator.csproj --configuration Release }
3232

3333
# Pack using NuGet.exe
34-
Exec { & nuget pack Workleap.DotNet.CodingStandards.nuspec -OutputDirectory $outputDir -Version $version -ForceEnglishOutput }
34+
Exec { & dotnet pack Workleap.DotNet.CodingStandards.csproj --output $outputDir -p:NuspecProperties=version=$version }
3535

3636
# Run tests
3737
Exec { & dotnet test --configuration Release --logger "console;verbosity=detailed" }
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<NoBuild>true</NoBuild>
4+
<IncludeBuildOutput>false</IncludeBuildOutput>
5+
<TargetFramework>netstandard2.0</TargetFramework>
6+
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
7+
<PackageOutputPath>./outputs/nugets</PackageOutputPath>
8+
<NoWarn>NU5128</NoWarn>
9+
<Version>1.0.0</Version>
10+
<NuSpecFile>Workleap.DotNet.CodingStandards.nuspec</NuSpecFile>
11+
<NuspecBasePath></NuspecBasePath>
12+
</PropertyGroup>
13+
<ItemGroup>
14+
<PackageReference Remove="Workleap.DotNet.CodingStandards" />
15+
</ItemGroup>
16+
</Project>

Workleap.DotNet.CodingStandards.nuspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
<copyright>Copyright © Workleap</copyright>
1414
<repository type="git" url="$RepositoryUrl$" commit="$RepositoryCommit$" branch="$RepositoryBranch$" />
1515
<dependencies>
16-
<dependency id="Meziantou.Analyzer" version="2.0.201" />
16+
<dependency id="Meziantou.Analyzer" version="2.0.254" />
1717
<dependency id="Microsoft.CodeAnalysis.BannedApiAnalyzers" version="4.14.0" />
18-
<dependency id="Microsoft.CodeAnalysis.NetAnalyzers" version="9.0.0" />
18+
<dependency id="Microsoft.CodeAnalysis.NetAnalyzers" version="10.0.100" />
1919
<dependency id="StyleCop.Analyzers" version="1.2.0-beta.556" />
2020
</dependencies>
2121
</metadata>

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "9.0.306",
3+
"version": "10.0.100",
44
"rollForward": "latestMinor",
55
"allowPrerelease": false
66
}

src/files/analyzers/Analyzer.Meziantou.Analyzer.editorconfig

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ dotnet_diagnostic.MA0051.severity = none
257257
# Enabled: True, Severity: suggestion
258258
dotnet_diagnostic.MA0052.severity = suggestion
259259

260-
# MA0053: Make class sealed
260+
# MA0053: Make class or record sealed
261261
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0053.md
262262
# Enabled: True, Severity: suggestion
263263
dotnet_diagnostic.MA0053.severity = none
@@ -527,7 +527,7 @@ dotnet_diagnostic.MA0105.severity = none
527527
# Enabled: True, Severity: suggestion
528528
dotnet_diagnostic.MA0106.severity = none
529529

530-
# MA0107: Do not use culture-sensitive object.ToString
530+
# MA0107: Do not use object.ToString
531531
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0107.md
532532
# Enabled: False, Severity: suggestion
533533
dotnet_diagnostic.MA0107.severity = none
@@ -842,3 +842,48 @@ dotnet_diagnostic.MA0168.severity = none
842842
# Enabled: True, Severity: warning
843843
dotnet_diagnostic.MA0169.severity = none
844844

845+
# MA0170: Type cannot be used as an attribute argument
846+
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0170.md
847+
# Enabled: False, Severity: warning
848+
dotnet_diagnostic.MA0170.severity = none
849+
850+
# MA0171: Use pattern matching instead of HasValue for Nullable<T> check
851+
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0171.md
852+
# Enabled: False, Severity: suggestion
853+
dotnet_diagnostic.MA0171.severity = none
854+
855+
# MA0172: Both sides of the logical operation are identical
856+
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0172.md
857+
# Enabled: False, Severity: warning
858+
dotnet_diagnostic.MA0172.severity = none
859+
860+
# MA0173: Use LazyInitializer.EnsureInitialize
861+
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0173.md
862+
# Enabled: True, Severity: suggestion
863+
dotnet_diagnostic.MA0173.severity = suggestion
864+
865+
# MA0174: Record should use explicit 'class' keyword
866+
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0174.md
867+
# Enabled: False, Severity: suggestion
868+
dotnet_diagnostic.MA0174.severity = none
869+
870+
# MA0175: Record should not use explicit 'class' keyword
871+
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0175.md
872+
# Enabled: False, Severity: suggestion
873+
dotnet_diagnostic.MA0175.severity = none
874+
875+
# MA0176: Optimize guid creation
876+
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0176.md
877+
# Enabled: True, Severity: suggestion
878+
dotnet_diagnostic.MA0176.severity = suggestion
879+
880+
# MA0177: Use single-line XML comment syntax when possible
881+
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0177.md
882+
# Enabled: False, Severity: suggestion
883+
dotnet_diagnostic.MA0177.severity = none
884+
885+
# MA0178: Use TimeSpan.Zero instead of TimeSpan.FromXXX(0)
886+
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0178.md
887+
# Enabled: True, Severity: suggestion
888+
dotnet_diagnostic.MA0178.severity = suggestion
889+

src/files/analyzers/Analyzer.Microsoft.CodeAnalysis.CSharp.CodeStyle.editorconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,11 @@ dotnet_diagnostic.IDE0340.severity = silent
535535
# Enabled: True, Severity: silent
536536
dotnet_diagnostic.IDE0350.severity = silent
537537

538+
# IDE0360: Simplify property accessor
539+
# Help link: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0360
540+
# Enabled: True, Severity: silent
541+
dotnet_diagnostic.IDE0360.severity = silent
542+
538543
# IDE1005: Delegate invocation can be simplified.
539544
# Help link: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide1005
540545
# Enabled: True, Severity: silent

src/files/analyzers/Analyzer.Microsoft.CodeAnalysis.NetAnalyzers.editorconfig

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,11 @@ dotnet_diagnostic.CA1514.severity = suggestion
405405
# Enabled: False, Severity: warning
406406
dotnet_diagnostic.CA1515.severity = none
407407

408+
# CA1516: Use cross-platform intrinsics
409+
# Help link: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1516
410+
# Enabled: True, Severity: suggestion
411+
dotnet_diagnostic.CA1516.severity = suggestion
412+
408413
# CA1700: Do not name enum values 'Reserved'
409414
# Help link: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1700
410415
# Enabled: False, Severity: warning
@@ -801,6 +806,21 @@ dotnet_diagnostic.CA1871.severity = suggestion
801806
# Enabled: True, Severity: suggestion
802807
dotnet_diagnostic.CA1872.severity = suggestion
803808

809+
# CA1873: Avoid potentially expensive logging
810+
# Help link: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1873
811+
# Enabled: True, Severity: suggestion
812+
dotnet_diagnostic.CA1873.severity = suggestion
813+
814+
# CA1874: Use 'Regex.IsMatch'
815+
# Help link: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1874
816+
# Enabled: True, Severity: suggestion
817+
dotnet_diagnostic.CA1874.severity = suggestion
818+
819+
# CA1875: Use 'Regex.Count'
820+
# Help link: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1875
821+
# Enabled: True, Severity: suggestion
822+
dotnet_diagnostic.CA1875.severity = suggestion
823+
804824
# CA2000: Dispose objects before losing scope
805825
# Help link: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2000
806826
# Enabled: False, Severity: warning
@@ -889,6 +909,21 @@ dotnet_diagnostic.CA2021.severity = warning
889909
# Enabled: True, Severity: warning
890910
dotnet_diagnostic.CA2022.severity = warning
891911

912+
# CA2023: Invalid braces in message template
913+
# Help link: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2023
914+
# Enabled: True, Severity: warning
915+
dotnet_diagnostic.CA2023.severity = warning
916+
917+
# CA2024: Do not use 'StreamReader.EndOfStream' in async methods
918+
# Help link: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2024
919+
# Enabled: True, Severity: warning
920+
dotnet_diagnostic.CA2024.severity = warning
921+
922+
# CA2025: Do not pass 'IDisposable' instances into unawaited tasks
923+
# Help link: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2025
924+
# Enabled: False, Severity: warning
925+
dotnet_diagnostic.CA2025.severity = none
926+
892927
# CA2100: Review SQL queries for security vulnerabilities
893928
# Help link: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2100
894929
# Enabled: False, Severity: warning

tests/Workleap.DotNet.CodingStandards.Tests/CodingStandardTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ public static class Sample { }
257257
var files = Directory.GetFiles(Path.Combine(project.RootFolder, "bin", "Release"));
258258
Assert.Single(files); // Only the .nupkg should be generated
259259
var nupkg = files.Single(f => f.EndsWith(".nupkg", StringComparison.OrdinalIgnoreCase));
260-
ZipFile.ExtractToDirectory(nupkg, extractedPath);
260+
await ZipFile.ExtractToDirectoryAsync(nupkg, extractedPath);
261261

262262
var outputFiles = Directory.GetFiles(extractedPath, "*", SearchOption.AllDirectories);
263263
await AssertPdbIsEmbedded(outputFiles);
Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
using System.Text;
12
using CliWrap;
2-
using CliWrap.Buffered;
33
using Workleap.DotNet.CodingStandards.Tests.Helpers;
44

55
namespace Workleap.DotNet.CodingStandards.Tests;
@@ -12,23 +12,19 @@ public sealed class PackageFixture : IAsyncLifetime
1212

1313
public async Task InitializeAsync()
1414
{
15-
var nuspecPath = Path.Combine(PathHelpers.GetRootDirectory(), "Workleap.DotNet.CodingStandards.nuspec");
16-
string[] args = ["pack", nuspecPath, "-ForceEnglishOutput", "-Version", "999.9.9", "-OutputDirectory", this._packageDirectory.FullPath];
17-
18-
if (OperatingSystem.IsWindows())
19-
{
20-
var exe = Path.Combine(Path.GetTempPath(), $"nuget-{Guid.NewGuid()}.exe");
21-
await DownloadFileAsync("https://dist.nuget.org/win-x86-commandline/latest/nuget.exe", exe);
22-
23-
_ = await Cli.Wrap(exe)
24-
.WithArguments(args)
25-
.ExecuteAsync();
26-
}
27-
else
15+
var projectPath = Path.Combine(PathHelpers.GetRootDirectory(), "Workleap.DotNet.CodingStandards.csproj");
16+
string[] args = ["pack", projectPath, "-p:NuspecProperties=version=999.9.9", "--output", this._packageDirectory.FullPath];
17+
var output = new StringBuilder();
18+
var result = await Cli.Wrap("dotnet")
19+
.WithArguments(args)
20+
.WithStandardOutputPipe(PipeTarget.ToStringBuilder(output))
21+
.WithStandardErrorPipe(PipeTarget.ToStringBuilder(output))
22+
.WithValidation(CommandResultValidation.None)
23+
.ExecuteAsync();
24+
25+
if (!result.IsSuccess)
2826
{
29-
_ = await Cli.Wrap("nuget")
30-
.WithArguments(args)
31-
.ExecuteBufferedAsync();
27+
throw new InvalidOperationException("Error while creating the NuGet package:\n" + output);
3228
}
3329
}
3430

@@ -37,12 +33,4 @@ public Task DisposeAsync()
3733
this._packageDirectory.Dispose();
3834
return Task.CompletedTask;
3935
}
40-
41-
private static async Task DownloadFileAsync(string url, string path)
42-
{
43-
_ = Directory.CreateDirectory(Path.GetDirectoryName(path)!);
44-
await using var nugetStream = await SharedHttpClient.Instance.GetStreamAsync(url);
45-
await using var fileStream = File.Create(path);
46-
await nugetStream.CopyToAsync(fileStream);
47-
}
4836
}

tests/Workleap.DotNet.CodingStandards.Tests/Workleap.DotNet.CodingStandards.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFramework>net10.0</TargetFramework>
55
<IsPackable>false</IsPackable>
66
<IsTestProject>true</IsTestProject>
77
</PropertyGroup>

0 commit comments

Comments
 (0)