Skip to content

Commit a7d86ec

Browse files
authored
feat/code-quality (#350)
* Chore: file scoped namespace * Feat: sign assembly Fix: documentation on public methodes * Fix: documentation and warnings * Chore: split IPNetwork2 into multiple partial classes * Chore: split IPNetwork2 * Chore: document partial classes * Fix: order methodes * Chore: documentd * Chore: cleanup
1 parent 61f96a7 commit a7d86ec

File tree

108 files changed

+6839
-5088
lines changed

Some content is hidden

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

108 files changed

+6839
-5088
lines changed

src/ConsoleApplication/ActionEnum.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
namespace System.Net;
66

7+
/// <summary>
8+
/// Switch and actions
9+
/// </summary>
710
public enum ActionEnum
811
{
912
Usage,

src/ConsoleApplication/ArgParsed.cs

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,41 @@
44

55
namespace System.Net;
66

7+
/// <summary>
8+
/// The args from the command line.
9+
/// </summary>
710
public class ArgParsed
811
{
12+
/// <summary>
13+
/// Position.
14+
/// </summary>
915
public int Arg { get; set; }
1016

1117
private event ArgParsedDelegate OnArgParsed;
1218

19+
/// <summary>
20+
/// An arg has been parsed.
21+
/// </summary>
1322
public delegate void ArgParsedDelegate(ProgramContext ac, string arg);
1423

24+
/// <summary>
25+
/// Run the program with the args.
26+
/// </summary>
27+
/// <param name="ac">The context.</param>
28+
/// <param name="arg">The arg.</param>
1529
public void Run(ProgramContext ac, string arg)
1630
{
17-
this.OnArgParsed?.Invoke(ac, arg);
18-
}
31+
this.OnArgParsed?.Invoke(ac, arg);
32+
}
1933

34+
/// <summary>
35+
/// Initializes a new instance of the <see cref="ArgParsed"/> class.
36+
/// </summary>
37+
/// <param name="arg">The arg.</param>
38+
/// <param name="onArgParsed">The event on parse.</param>
2039
public ArgParsed(int arg, ArgParsedDelegate onArgParsed)
2140
{
22-
this.Arg = arg;
23-
this.OnArgParsed += onArgParsed;
24-
}
41+
this.Arg = arg;
42+
this.OnArgParsed += onArgParsed;
43+
}
2544
}

src/ConsoleApplication/CidrParseTypeEnum.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
namespace System.Net;
66

7+
/// <summary>
8+
/// CidrParseEnum.
9+
/// </summary>
710
public enum CidrParseEnum
811
{
912
Default,

src/ConsoleApplication/ConsoleApplication.csproj

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2-
32
<PropertyGroup>
43
<OutputType>Exe</OutputType>
54
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
6-
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">net9.0</TargetFrameworks>
75
<ImplicitUsings>disable</ImplicitUsings>
86
<SignAssembly>True</SignAssembly>
97
<AssemblyOriginatorKeyFile>..\System.Net.IPNetwork.snk</AssemblyOriginatorKeyFile>
@@ -13,6 +11,14 @@
1311

1412
</PropertyGroup>
1513

14+
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
15+
<NoWarn />
16+
</PropertyGroup>
17+
18+
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
19+
<NoWarn />
20+
</PropertyGroup>
21+
1622
<ItemGroup>
1723
<None Remove="stylecop.json" />
1824
</ItemGroup>
@@ -29,9 +35,7 @@
2935
</PackageReference>
3036
</ItemGroup>
3137

32-
3338
<ItemGroup>
34-
<!-- ProjectReference Include="..\Gnu.Getopt\Gnu.Getopt.csproj" /-->
3539
<ProjectReference Include="..\System.Net.IPNetwork\System.Net.IPNetwork.csproj" />
3640
</ItemGroup>
3741

src/ConsoleApplication/Program.cs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,19 @@
44

55
namespace System.Net;
66

7+
using System.Collections.Generic;
78
using System.Diagnostics;
89
using System.IO;
910
using System.Numerics;
1011
using System.Reflection;
1112
using Gnu.Getopt;
1213

13-
14-
using System.Collections.Generic;
15-
1614
/// <summary>
1715
/// Console app for IPNetwork.
1816
/// </summary>
1917
public class Program
2018
{
21-
private static readonly Dictionary<int, ArgParsed> Args = new();
19+
private static readonly Dictionary<int, ArgParsed> Args = new ();
2220

2321
private static readonly ArgParsed[] ArgsList = new[]
2422
{
@@ -408,10 +406,7 @@ private static bool TryParseIPNetwork(string ip, CidrParseEnum cidrParseEnum, by
408406

409407
private static bool PrintNoValue(ProgramContext ac)
410408
{
411-
if (ac == null)
412-
{
413-
throw new ArgumentNullException(nameof(ac));
414-
}
409+
ArgumentNullException.ThrowIfNull(ac);
415410

416411
return ac.IPNetwork == false
417412
&& ac.Network == false
@@ -426,10 +421,7 @@ private static bool PrintNoValue(ProgramContext ac)
426421

427422
private static void PrintAll(ProgramContext ac)
428423
{
429-
if (ac == null)
430-
{
431-
throw new ArgumentNullException(nameof(ac));
432-
}
424+
ArgumentNullException.ThrowIfNull(ac);
433425

434426
ac.IPNetwork = true;
435427
ac.Network = true;

src/ConsoleApplication/ProgramContext.cs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,98 @@
44

55
namespace System.Net;
66

7+
/// <summary>
8+
/// The execution context.
9+
/// </summary>
710
public class ProgramContext
811
{
12+
/// <summary>
13+
/// Get or set the IPNetwork.
14+
/// </summary>
915
public bool IPNetwork { get; set; }
1016

17+
/// <summary>
18+
/// Get or set the Network.
19+
/// </summary>
1120
public bool Network { get; set; }
1221

22+
/// <summary>
23+
/// Get or set the Netmask.
24+
/// </summary>
1325
public bool Netmask { get; set; }
1426

27+
/// <summary>
28+
/// Get or set the Cidr.
29+
/// </summary>
1530
public bool Cidr { get; set; }
1631

32+
/// <summary>
33+
/// Get or set the Broadcast.
34+
/// </summary>
1735
public bool Broadcast { get; set; }
1836

37+
/// <summary>
38+
/// Get or set the FirstUsable.
39+
/// </summary>
1940
public bool FirstUsable { get; set; }
2041

42+
/// <summary>
43+
/// Get or set the LastUsable.
44+
/// </summary>
2145
public bool LastUsable { get; set; }
2246

47+
/// <summary>
48+
/// Get or set the Usable.
49+
/// </summary>
2350
public bool Usable { get; set; }
2451

52+
/// <summary>
53+
/// Get or set the Total.
54+
/// </summary>
2555
public bool Total { get; set; }
2656

57+
/// <summary>
58+
/// Get or set the CidrParse.
59+
/// </summary>
2760
public CidrParseEnum CidrParse { get; set; } = CidrParseEnum.Value;
2861

62+
/// <summary>
63+
/// Get or set the CidrParsed.
64+
/// </summary>
2965
public byte CidrParsed { get; set; } = 32;
3066

67+
/// <summary>
68+
/// Get or set the ContainNetwork.
69+
/// </summary>
3170
public IPNetwork2 ContainNetwork { get; set; }
3271

72+
/// <summary>
73+
/// Get or set the OverlapNetwork.
74+
/// </summary>
3375
public IPNetwork2 OverlapNetwork { get; set; }
3476

77+
/// <summary>
78+
/// Get or set the SubtractNetwork.
79+
/// </summary>
3580
public IPNetwork2 SubtractNetwork { get; set; }
3681

82+
/// <summary>
83+
/// Get or set the Action.
84+
/// </summary>
3785
public ActionEnum Action { get; set; } = ActionEnum.PrintNetworks;
3886

87+
/// <summary>
88+
/// Get or set the SubnetCidr.
89+
/// </summary>
3990
public byte SubnetCidr { get; set; }
4091

92+
/// <summary>
93+
/// Get or set the NetworksString.
94+
/// </summary>
4195
public string[] NetworksString { get; set; }
4296

97+
/// <summary>
98+
/// Get or set the Networks.
99+
/// </summary>
43100
public IPNetwork2[] Networks { get; set; }
44101
}

0 commit comments

Comments
 (0)