Skip to content

Commit 02afdc0

Browse files
committed
XML Documentation update; Small cleanup
1 parent d937aef commit 02afdc0

4 files changed

Lines changed: 144 additions & 10 deletions

File tree

‎src/WGet.NET/Data/WinGetPackage.cs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ public static WinGetPackage Create(string name, string id, string version, strin
183183
ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(version, "version");
184184
ArgsHelper.ThrowIfObjectIsNull(sourceName, "sourceName");
185185

186-
PackageBuilder builder = new PackageBuilder();
186+
PackageBuilder builder = new();
187187

188188
builder.AddName(name);
189189
builder.AddId(id);
@@ -215,7 +215,7 @@ public static WinGetPackage Create(string name, string id, string version, strin
215215
ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(availableVersion, "availableVersion");
216216
ArgsHelper.ThrowIfObjectIsNull(sourceName, "sourceName");
217217

218-
PackageBuilder builder = new PackageBuilder();
218+
PackageBuilder builder = new();
219219

220220
builder.AddName(name);
221221
builder.AddId(id);
@@ -246,7 +246,7 @@ public static WinGetPackage Create(string name, string id, Version version, stri
246246
ArgsHelper.ThrowIfObjectIsNull(version, "version");
247247
ArgsHelper.ThrowIfObjectIsNull(sourceName, "sourceName");
248248

249-
PackageBuilder builder = new PackageBuilder();
249+
PackageBuilder builder = new();
250250

251251
builder.AddName(name);
252252
builder.AddId(id);
@@ -278,7 +278,7 @@ public static WinGetPackage Create(string name, string id, Version version, Vers
278278
ArgsHelper.ThrowIfObjectIsNull(availableVersion, "availableVersion");
279279
ArgsHelper.ThrowIfObjectIsNull(sourceName, "sourceName");
280280

281-
PackageBuilder builder = new PackageBuilder();
281+
PackageBuilder builder = new();
282282

283283
builder.AddName(name);
284284
builder.AddId(id);

‎src/WGet.NET/HelperClasses/ProcessOutputReader.cs‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ private static List<WinGetPackage> CreatePackageListFromOutput(string[] output,
8181
return resultList;
8282
}
8383

84-
PackageBuilder builder = new PackageBuilder();
84+
PackageBuilder builder = new();
8585

8686
for (int i = 0; i < output.Length; i++)
8787
{
@@ -237,7 +237,7 @@ private static List<WinGetPinnedPackage> CreatePinnedPackageListFromOutput(strin
237237
return resultList;
238238
}
239239

240-
PinnedPackageBuilder builder = new PinnedPackageBuilder();
240+
PinnedPackageBuilder builder = new();
241241

242242
for (int i = 0; i < output.Length; i++)
243243
{
@@ -583,7 +583,7 @@ private static WinGetInfo ReadDataForRange4(string[] output)
583583
string[] entry = output[index].Split(':');
584584
if (entry.Length == 2)
585585
{
586-
DirectoryBuilder builder = new DirectoryBuilder();
586+
DirectoryBuilder builder = new();
587587

588588
builder.AddEntryName(entry[0].Trim());
589589
builder.AddRawContent(entry[1].Trim());
@@ -610,7 +610,7 @@ private static List<WinGetDirectory> ReadDirectories(string[] output)
610610
StringBuilder nameBuilder = new();
611611
StringBuilder contentBuilder = new();
612612

613-
DirectoryBuilder directoryBuilder = new DirectoryBuilder();
613+
DirectoryBuilder directoryBuilder = new();
614614

615615
for (int i = 0; i < output.Length; i++)
616616
{
@@ -696,7 +696,7 @@ private static List<WinGetLink> ReadLinks(string[] output)
696696

697697
StringBuilder nameBuilder = new();
698698

699-
LinkBuilder linkBuilder = new LinkBuilder();
699+
LinkBuilder linkBuilder = new();
700700

701701
for (int i = 0; i < output.Length; i++)
702702
{
@@ -755,7 +755,7 @@ private static List<WinGetAdminOption> ReadAdminSettings(string[] output)
755755
{
756756
List<WinGetAdminOption> adminSetting = new();
757757

758-
AdminOptionBuilder adminOptionBuilder = new AdminOptionBuilder();
758+
AdminOptionBuilder adminOptionBuilder = new();
759759

760760
for (int i = 0; i < output.Length; i++)
761761
{

‎src/WGet.NET/HelperClasses/VersionParser.cs‎

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,18 @@
77

88
namespace WGetNET.HelperClasses
99
{
10+
/// <summary>
11+
/// Handels the parsing of strings to a <see cref="System.Version"/> instance.
12+
/// </summary>
1013
internal static class VersionParser
1114
{
15+
/// <summary>
16+
/// Parses a <see cref="System.String"/> to a <see cref="System.Version"/> instance as best as possible.
17+
/// </summary>
18+
/// <param name="input">The <see cref="System.String"/> to parse.</param>
19+
/// <returns>
20+
/// The created <see cref="System.Version"/> instance.
21+
/// </returns>
1222
public static Version Parse(string input)
1323
{
1424
if (string.IsNullOrWhiteSpace(input))
@@ -24,6 +34,16 @@ public static Version Parse(string input)
2434
return CleanParse(input);
2535
}
2636

37+
/// <summary>
38+
/// Parses a <see cref="System.String"/> to a <see cref="System.Version"/> instance as best as possible.
39+
/// </summary>
40+
/// <remarks>
41+
/// This tries to resolve the string one by one to parse it.
42+
/// </remarks>
43+
/// <param name="input">The <see cref="System.String"/> to parse.</param>
44+
/// <returns>
45+
/// The created <see cref="System.Version"/> instance.
46+
/// </returns>
2747
private static Version CleanParse(string input)
2848
{
2949
string[] versionParts = input.Split('.');
@@ -67,6 +87,14 @@ private static Version CleanParse(string input)
6787
}
6888
}
6989

90+
/// <summary>
91+
/// Parses a <see cref="System.String"/> to a <see cref="System.Int32"/> as best as possible.
92+
/// </summary>
93+
/// <param name="input">The <see cref="System.String"/> to parse.</param>
94+
/// <param name="defaultValue">Default value that is used if the input can't be parsed.</param>
95+
/// <returns>
96+
/// The created <see cref="System.Int32"/>.
97+
/// </returns>
7098
private static int ParseToInt(string input, int defaultValue = 0)
7199
{
72100
if (int.TryParse(input, out int result))
@@ -77,6 +105,18 @@ private static int ParseToInt(string input, int defaultValue = 0)
77105
return CleanParseToInt(input, defaultValue);
78106
}
79107

108+
/// <summary>
109+
/// Parses a <see cref="System.String"/> to a <see cref="System.Int32"/> as best as possible.
110+
/// </summary>
111+
/// <remarks>
112+
/// This tries to clean the provided input <see cref="System.String"/>,
113+
/// with minimal data loss, so it can be parsed to a <see cref="System.Int32"/>
114+
/// </remarks>
115+
/// <param name="input">The <see cref="System.String"/> to parse.</param>
116+
/// <param name="defaultValue">Default value that is used if the input can't be parsed.</param>
117+
/// <returns>
118+
/// The created <see cref="System.Int32"/>.
119+
/// </returns>
80120
private static int CleanParseToInt(string input, int defaultValue = 0)
81121
{
82122
string cleanInput = CleanupNumberString(input);
@@ -89,6 +129,16 @@ private static int CleanParseToInt(string input, int defaultValue = 0)
89129
return defaultValue;
90130
}
91131

132+
/// <summary>
133+
/// Cleans a <see cref="System.String"/>, with minimal version information loss, so it can be parsed to a <see cref="System.Int32"/>.
134+
/// </summary>
135+
/// <remarks>
136+
/// If the <see cref="System.String"/> looks lick this '123ABC456' it will not be cleaned, because to much information will be lost.
137+
/// </remarks>
138+
/// <param name="input">The <see cref="System.String"/> to clean up.</param>
139+
/// <returns>
140+
/// The processed <see cref="System.String"/>:
141+
/// </returns>
92142
private static string CleanupNumberString(string input)
93143
{
94144
// Remove appendix (e.g. 123456-preview1) becaue it could contain a mix of numbers and letters,
@@ -120,6 +170,16 @@ private static string CleanupNumberString(string input)
120170
return cleanString.ToString();
121171
}
122172

173+
/// <summary>
174+
/// Removes version appendixes from the string.
175+
/// </summary>
176+
/// <remarks>
177+
/// An version appendix could look like this: '-preview', '-beta2' or '-pre'.
178+
/// </remarks>
179+
/// <param name="input">The <see cref="System.String"/> to process.</param>
180+
/// <returns>
181+
/// The processed <see cref="System.String"/>.
182+
/// </returns>
123183
private static string RemoveAppendix(string input)
124184
{
125185
string[] parts = input.Split('-');

‎src/WGet.NET/XmlDocumentation/WGet.NET.xml‎

Lines changed: 74 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)