Skip to content

Commit f1e7ca3

Browse files
authored
NuGet updates and cleanup (#229)
1 parent 443d1bd commit f1e7ca3

File tree

73 files changed

+555
-343
lines changed

Some content is hidden

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

73 files changed

+555
-343
lines changed

.editorconfig

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ dotnet_diagnostic.CA1825.severity = silent
178178
# CA1835: Prefer the 'Memory'-based overloads for 'ReadAsync' and 'WriteAsync' - (TODO: more improvements needed)
179179
dotnet_diagnostic.CA1835.severity = silent
180180

181+
# CA1819: Do not return arrays.
182+
dotnet_diagnostic.CA1819.severity = suggestion
183+
181184
# All the style rules we want to enforce during build...
182185
dotnet_diagnostic.CA2211.severity = warning
183186
dotnet_diagnostic.CA2007.severity = warning
@@ -209,6 +212,26 @@ dotnet_diagnostic.IDE0305.severity = none
209212
# use primary ctor
210213
dotnet_diagnostic.IDE0290.severity = none
211214

215+
dotnet_diagnostic.CA1303.severity = silent
216+
217+
# don't use short for enum
218+
dotnet_diagnostic.CA1028.severity = silent
219+
220+
# Friendly overload for + operator
221+
dotnet_diagnostic.CA2225.severity = silent
222+
223+
# interop
224+
dotnet_diagnostic.CA5392.severity = silent
225+
226+
# Enum value Reserved
227+
dotnet_diagnostic.CA1700.severity = silent
228+
dotnet_diagnostic.CA1720.severity = silent
229+
230+
## Features not avail in all framework targets
231+
dotnet_diagnostic.CA1510.severity = silent
232+
dotnet_diagnostic.CA1512.severity = silent
233+
dotnet_diagnostic.CA1513.severity = silent
234+
212235
# Xml project files
213236
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,nativeproj,locproj}]
214237
indent_size = 2

Directory.Build.props

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project>
2+
<PropertyGroup>
3+
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
4+
<CodeAnalysisTreatWarningsAsErrors>false</CodeAnalysisTreatWarningsAsErrors>
5+
<EnableNETAnalyzers>true</EnableNETAnalyzers>
6+
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
7+
<AnalysisMode>all</AnalysisMode>
8+
<AnalysisLevel>8.0</AnalysisLevel>
9+
</PropertyGroup>
10+
11+
<PropertyGroup>
12+
<LangVersion>12.0</LangVersion>
13+
</PropertyGroup>
14+
</Project>

DnsClientDotNet.sln

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.29806.167
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.10.35013.160
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{3D3BE1AD-F551-420A-A81D-4CB88286C8CD}"
77
EndProject
@@ -11,6 +11,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1111
.gitignore = .gitignore
1212
.runsettings = .runsettings
1313
azure-pipelines-ci.yml = azure-pipelines-ci.yml
14+
directory.build.props = directory.build.props
1415
LICENSE = LICENSE
1516
README.md = README.md
1617
EndProjectSection
@@ -23,8 +24,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MiniDig", "samples\MiniDig\
2324
EndProject
2425
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DnsClient.Tests", "test\DnsClient.Tests\DnsClient.Tests.csproj", "{01902674-53A3-4E81-B08F-CFAA7CA62F56}"
2526
EndProject
26-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ApiDesign", "test-other\ApiDesign\ApiDesign.csproj", "{2F789CAA-31E5-4394-96B9-1B06A1AA5EA0}"
27-
EndProject
2827
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DnsClient", "src\DnsClient\DnsClient.csproj", "{493E6161-7F71-4A59-AB28-B4A5E45A5E27}"
2928
EndProject
3029
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Benchmarks", "test-other\Benchmarks\Benchmarks.csproj", "{7461E2C7-008E-4E61-ABC3-AF85DE37084B}"
@@ -62,10 +61,6 @@ Global
6261
{01902674-53A3-4E81-B08F-CFAA7CA62F56}.Debug|Any CPU.Build.0 = Debug|Any CPU
6362
{01902674-53A3-4E81-B08F-CFAA7CA62F56}.Release|Any CPU.ActiveCfg = Release|Any CPU
6463
{01902674-53A3-4E81-B08F-CFAA7CA62F56}.Release|Any CPU.Build.0 = Release|Any CPU
65-
{2F789CAA-31E5-4394-96B9-1B06A1AA5EA0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
66-
{2F789CAA-31E5-4394-96B9-1B06A1AA5EA0}.Debug|Any CPU.Build.0 = Debug|Any CPU
67-
{2F789CAA-31E5-4394-96B9-1B06A1AA5EA0}.Release|Any CPU.ActiveCfg = Release|Any CPU
68-
{2F789CAA-31E5-4394-96B9-1B06A1AA5EA0}.Release|Any CPU.Build.0 = Release|Any CPU
6964
{493E6161-7F71-4A59-AB28-B4A5E45A5E27}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
7065
{493E6161-7F71-4A59-AB28-B4A5E45A5E27}.Debug|Any CPU.Build.0 = Debug|Any CPU
7166
{493E6161-7F71-4A59-AB28-B4A5E45A5E27}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -97,7 +92,6 @@ Global
9792
GlobalSection(NestedProjects) = preSolution
9893
{CEC9D7AD-8000-4FC6-8EB3-AC1417B9808A} = {A1BE93CF-0106-495B-9720-008046657391}
9994
{01902674-53A3-4E81-B08F-CFAA7CA62F56} = {34E43CED-3DF4-49CE-8556-69225ABD84E6}
100-
{2F789CAA-31E5-4394-96B9-1B06A1AA5EA0} = {28CFF2BF-88D0-481F-829E-43B51DE7FB1F}
10195
{493E6161-7F71-4A59-AB28-B4A5E45A5E27} = {3D3BE1AD-F551-420A-A81D-4CB88286C8CD}
10296
{7461E2C7-008E-4E61-ABC3-AF85DE37084B} = {28CFF2BF-88D0-481F-829E-43B51DE7FB1F}
10397
{8422A76D-CC40-4B4B-AA03-C17C3D86A073} = {28CFF2BF-88D0-481F-829E-43B51DE7FB1F}

azure-pipelines-ci.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ jobs:
3131
inputs:
3232
command: 'build'
3333
projects: |
34-
src/**/*.csproj
35-
test/**/*.csproj
34+
DnsClientDotNet.sln
3635
arguments: '-c Release'
3736
name: 'Build'
3837
displayName: 'dotnet build'
@@ -42,7 +41,7 @@ jobs:
4241
command: 'test'
4342
projects: 'test/**/*.csproj'
4443
publishTestResults: true
45-
arguments: '-c Release --no-build --no-restore -f net6.0'
44+
arguments: '-c Release --no-build --no-restore -f net8.0'
4645

4746
- job: Windows
4847
displayName: 'Build & Test on Windows'
@@ -55,8 +54,7 @@ jobs:
5554
inputs:
5655
command: 'build'
5756
projects: |
58-
src/**/*.csproj
59-
test/**/*.csproj
57+
DnsClientDotNet.sln
6058
arguments: '-c Release'
6159
name: 'Build'
6260
- task: DotNetCoreCLI@2

samples/MiniDig/DigCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ protected override async Task<int> Execute()
117117
Console.WriteLine($"; Servers: {string.Join(", ", lookup.NameServers)}");
118118

119119
var parsedDnsString = DnsString.Parse(useDomain);
120-
if (parsedDnsString.NumberOfLabels == 1 && !parsedDnsString.Original.EndsWith("."))
120+
if (parsedDnsString.NumberOfLabels == 1 && !parsedDnsString.Original.EndsWith(".", StringComparison.Ordinal))
121121
{
122122
foreach (var server in lookup.NameServers)
123123
{

samples/MiniDig/DnsCommand.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
using System;
66
using System.Collections.Generic;
7+
using System.Globalization;
78
using System.Linq;
89
using System.Net;
910
using System.Threading.Tasks;
@@ -41,7 +42,7 @@ public abstract class DnsCommand
4142

4243
public CommandOption NoTcpArg { get; set; }
4344

44-
public DnsCommand(CommandLineApplication app, string[] originalArgs)
45+
protected DnsCommand(CommandLineApplication app, string[] originalArgs)
4546
{
4647
App = app ?? throw new ArgumentNullException(nameof(app));
4748
OriginalArgs = originalArgs;
@@ -64,7 +65,7 @@ public NameServer[] GetEndpointsValue()
6465
foreach (var serverPair in values)
6566
{
6667
var server = serverPair[0];
67-
var port = serverPair.Length > 1 ? int.Parse(serverPair[1]) : 53;
68+
var port = serverPair.Length > 1 ? int.Parse(serverPair[1], CultureInfo.InvariantCulture) : 53;
6869

6970
if (!IPAddress.TryParse(server, out IPAddress ip))
7071
{
@@ -110,7 +111,7 @@ public LookupClientOptions GetLookupSettings()
110111
{
111112
if (MinimumTTLArg.HasValue())
112113
{
113-
return TimeSpan.FromMilliseconds(int.Parse(MinimumTTLArg.Value()));
114+
return TimeSpan.FromMilliseconds(int.Parse(MinimumTTLArg.Value(), CultureInfo.InvariantCulture));
114115
}
115116

116117
return null;
@@ -120,20 +121,20 @@ public LookupClientOptions GetLookupSettings()
120121
{
121122
if (MaximumTTLArg.HasValue())
122123
{
123-
return TimeSpan.FromMilliseconds(int.Parse(MaximumTTLArg.Value()));
124+
return TimeSpan.FromMilliseconds(int.Parse(MaximumTTLArg.Value(), CultureInfo.InvariantCulture));
124125
}
125126

126127
return null;
127128
}
128129

129130
public int GetMaximumBufferSize()
130-
=> MaximumBufferSizeArg.HasValue() ? int.Parse(MaximumBufferSizeArg.Value()) : DnsQueryOptions.MaximumBufferSize;
131+
=> MaximumBufferSizeArg.HasValue() ? int.Parse(MaximumBufferSizeArg.Value(), CultureInfo.InvariantCulture) : DnsQueryOptions.MaximumBufferSize;
131132

132133
public bool GetRequestDnsSec() => RequestDnsSecRecordsArg.HasValue();
133134

134-
public int GetTimeoutValue() => ConnectTimeoutArg.HasValue() ? int.Parse(ConnectTimeoutArg.Value()) : 1000;
135+
public int GetTimeoutValue() => ConnectTimeoutArg.HasValue() ? int.Parse(ConnectTimeoutArg.Value(), CultureInfo.InvariantCulture) : 1000;
135136

136-
public int GetTriesValue() => TriesArg.HasValue() ? int.Parse(TriesArg.Value()) : 5;
137+
public int GetTriesValue() => TriesArg.HasValue() ? int.Parse(TriesArg.Value(), CultureInfo.InvariantCulture) : 5;
137138

138139
public bool GetUseCache()
139140
{

samples/MiniDig/MiniDig.csproj

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,10 @@
55
<AssemblyName>MiniDig</AssemblyName>
66
<OutputType>Exe</OutputType>
77
<PackageId>MiniDig</PackageId>
8+
<IsPackable>false</IsPackable>
9+
<NoWarn>$(NoWarn);CA2214;CA2008;CA5394;CA1865;CA1849;CA1307;</NoWarn>
810
</PropertyGroup>
9-
<PropertyGroup>
10-
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
11-
<CodeAnalysisTreatWarningsAsErrors>false</CodeAnalysisTreatWarningsAsErrors>
12-
<EnableNETAnalyzers>true</EnableNETAnalyzers>
13-
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
14-
</PropertyGroup>
11+
1512
<ItemGroup>
1613
<None Update="names.txt">
1714
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
@@ -24,6 +21,6 @@
2421
</ItemGroup>
2522

2623
<ItemGroup>
27-
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="4.1.0" />
24+
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="4.1.1" />
2825
</ItemGroup>
2926
</Project>

samples/MiniDig/PerfCommand.cs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System;
66
using System.Collections.Generic;
77
using System.Diagnostics;
8+
using System.Globalization;
89
using System.Linq;
910
using System.Threading;
1011
using System.Threading.Tasks;
@@ -19,8 +20,8 @@ public class PerfCommand : DnsCommand
1920
private int _tasks;
2021
private string _query;
2122
private int _runtime;
22-
private long _reportExcecutions = 0;
23-
private long _allExcecutions = 0;
23+
private long _reportExcecutions;
24+
private long _allExcecutions;
2425
private bool _running;
2526
private LookupClientOptions _settings;
2627
private int _errors;
@@ -54,19 +55,23 @@ protected override void Configure()
5455

5556
protected override async Task<int> Execute()
5657
{
57-
_clients = ClientsArg.HasValue() ? int.Parse(ClientsArg.Value()) : 10;
58+
_clients = ClientsArg.HasValue() ? int.Parse(ClientsArg.Value(), CultureInfo.InvariantCulture) : 10;
5859
if (_clients <= 0)
5960
{
6061
throw new ArgumentOutOfRangeException(nameof(ClientsArg));
6162
}
6263

63-
_tasks = TasksArg.HasValue() ? int.Parse(TasksArg.Value()) : 8;
64+
_tasks = TasksArg.HasValue() ? int.Parse(TasksArg.Value(), CultureInfo.InvariantCulture) : 8;
6465
if (_clients <= 0)
6566
{
6667
throw new ArgumentOutOfRangeException(nameof(TasksArg));
6768
}
6869

69-
_runtime = RuntimeArg.HasValue() ? int.Parse(RuntimeArg.Value()) <= 1 ? 5 : int.Parse(RuntimeArg.Value()) : 5;
70+
_runtime = RuntimeArg.HasValue()
71+
? int.Parse(RuntimeArg.Value(), CultureInfo.InvariantCulture) <= 1
72+
? 5 : int.Parse(RuntimeArg.Value(), CultureInfo.InvariantCulture)
73+
: 5;
74+
7075
_query = string.IsNullOrWhiteSpace(QueryArg.Value) ? string.Empty : QueryArg.Value;
7176
_runSync = SyncArg.HasValue();
7277

@@ -75,7 +80,10 @@ protected override async Task<int> Execute()
7580
_running = true;
7681

7782
Console.WriteLine($"; <<>> Starting perf run with {_clients} (x{_tasks}) clients running for {_runtime} seconds <<>>");
78-
Console.WriteLine($"; ({_settings.NameServers.Count} Servers, caching:{_settings.UseCache}, minttl:{_settings.MinimumCacheTimeout?.TotalMilliseconds}, maxttl:{_settings.MaximumCacheTimeout?.TotalMilliseconds})");
83+
Console.WriteLine($"; ({_settings.NameServers.Count} Servers, caching:{_settings.UseCache}, " +
84+
$"minttl:{_settings.MinimumCacheTimeout?.TotalMilliseconds}, " +
85+
$"maxttl:{_settings.MaximumCacheTimeout?.TotalMilliseconds})");
86+
7987
_spinner = new Spiner();
8088
_spinner.Start();
8189

samples/MiniDig/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99

1010
namespace DigApp
1111
{
12-
public class Program
12+
public static class Program
1313
{
1414
public static async Task<int> Main(string[] args)
1515
{
1616
DnsClient.Tracing.Source.Switch.Level = SourceLevels.Warning;
1717
DnsClient.Tracing.Source.Listeners.Add(new ConsoleTraceListener());
1818

19-
var app = new CommandLineApplication();
19+
using var app = new CommandLineApplication();
2020
app.UnrecognizedArgumentHandling = UnrecognizedArgumentHandling.Throw;
2121

2222
try

samples/MiniDig/RandomCommand.cs

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Collections.Concurrent;
77
using System.Collections.Generic;
88
using System.Diagnostics;
9+
using System.Globalization;
910
using System.IO;
1011
using System.Linq;
1112
using System.Threading;
@@ -26,8 +27,8 @@ public class RandomCommand : DnsCommand
2627
private ConcurrentQueue<string> _domainNames;
2728
private int _clients;
2829
private int _runtime;
29-
private long _reportExcecutions = 0;
30-
private long _allExcecutions = 0;
30+
private long _reportExcecutions;
31+
private long _allExcecutions;
3132
private bool _running;
3233
private LookupClientOptions _settings;
3334
private int _errors;
@@ -71,8 +72,12 @@ protected override async Task<int> Execute()
7172
var lines = File.ReadAllLines("names.txt");
7273
_domainNames = new ConcurrentQueue<string>(lines.Select(p => p.Substring(p.IndexOf(';') + 1)).OrderBy(x => s_randmom.Next(0, lines.Length * 2)));
7374

74-
_clients = ClientsArg.HasValue() ? int.Parse(ClientsArg.Value()) : 10;
75-
_runtime = RuntimeArg.HasValue() ? int.Parse(RuntimeArg.Value()) <= 1 ? 5 : int.Parse(RuntimeArg.Value()) : 5;
75+
_clients = ClientsArg.HasValue() ? int.Parse(ClientsArg.Value(), CultureInfo.InvariantCulture) : 10;
76+
_runtime = RuntimeArg.HasValue()
77+
? int.Parse(RuntimeArg.Value(), CultureInfo.InvariantCulture) <= 1
78+
? 5 : int.Parse(RuntimeArg.Value(), CultureInfo.InvariantCulture)
79+
: 5;
80+
7681
_runSync = SyncArg.HasValue();
7782

7883
_settings = GetLookupSettings();
@@ -145,15 +150,16 @@ private async Task CollectPrint()
145150
waitCount++;
146151
await Task.Delay(1000).ConfigureAwait(false);
147152

148-
var serverUpdate = from good in _successByServer
149-
join fail in _failByServer on good.Key equals fail.Key into all
150-
from row in all.DefaultIfEmpty()
151-
select new
152-
{
153-
good.Key,
154-
Fails = row.Value,
155-
Success = good.Value
156-
};
153+
var serverUpdate =
154+
from good in _successByServer
155+
join fail in _failByServer on good.Key equals fail.Key into all
156+
from row in all.DefaultIfEmpty()
157+
select new
158+
{
159+
good.Key,
160+
Fails = row.Value,
161+
Success = good.Value
162+
};
157163

158164
var updateString = string.Join(" | ", serverUpdate.Select((p, i) => $"Server{i}: +{p.Success} -{p.Fails}"));
159165

@@ -163,7 +169,7 @@ from row in all.DefaultIfEmpty()
163169
_running = false;
164170
}
165171

166-
private int _runNumber = 0;
172+
private int _runNumber;
167173

168174
private async Task ExcecuteRun()
169175
{

0 commit comments

Comments
 (0)