Skip to content

Commit 46419ae

Browse files
format and silence some warnings
1 parent 4205eed commit 46419ae

21 files changed

Lines changed: 119 additions & 58 deletions

Common.Controls/ExtendedGrid.cs

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public static Grid ExtendGrid(int columns, int rows, int width, int height, bool
9797
/// <param name="rowHeights">List of row heights in pixels.</param>
9898
/// <param name="gridLines">Indicates whether grid lines should be shown.</param>
9999
/// <returns>A <see cref="Grid" /> with custom row and column dimensions.</returns>
100-
public static Grid ExtendGrid(List<int> columnWidths, List<int> rowHeights, bool gridLines)
100+
public static Grid ExtendGrid(List<int>? columnWidths, List<int>? rowHeights, bool gridLines)
101101
{
102102
if (columnWidths == null || rowHeights == null)
103103
{
@@ -121,7 +121,7 @@ public static Grid ExtendGrid(List<int> columnWidths, List<int> rowHeights, bool
121121
/// <param name="rowHeights">Custom row heights if any, null otherwise.</param>
122122
/// <returns>A <see cref="Grid" /> configured with the specified parameters.</returns>
123123
private static Grid InitializeGridBase(bool gridLines, int width, int height,
124-
IReadOnlyCollection<int> columnWidths, IReadOnlyCollection<int> rowHeights)
124+
IReadOnlyCollection<int>? columnWidths, IReadOnlyCollection<int>? rowHeights)
125125
{
126126
var dynamicGrid = new Grid
127127
{
@@ -169,8 +169,13 @@ private static Grid InitializeGridBase(bool gridLines, int width, int height,
169169
}
170170

171171
/// <summary>
172-
/// Validates the grid parameters to ensure they are non-negative.
172+
/// Validates the grid parameters to ensure they are non-negative.
173173
/// </summary>
174+
/// <param name="columns">The columns.</param>
175+
/// <param name="rows">The rows.</param>
176+
/// <param name="width">The width.</param>
177+
/// <param name="height">The height.</param>
178+
/// <exception cref="Common.Controls.CommonControlsException"></exception>
174179
private static void ValidateParameters(int columns, int rows, int width = 1, int height = 1)
175180
{
176181
if (columns < 0 || rows < 0 || width < 1 || height < 1)
@@ -180,11 +185,19 @@ private static void ValidateParameters(int columns, int rows, int width = 1, int
180185
}
181186

182187
/// <summary>
183-
/// Calculates the total width of the grid.
188+
/// Calculates the total width of the grid.
184189
/// </summary>
185-
private static int CalculateTotalWidth(IEnumerable<int> columnWidths)
190+
/// <param name="columnWidths">The column widths.</param>
191+
/// <returns>The column width of the grid.</returns>
192+
/// <exception cref="Common.Controls.CommonControlsException"></exception>
193+
private static int CalculateTotalWidth(IEnumerable<int>? columnWidths)
186194
{
187195
var totalWidth = 0;
196+
if (columnWidths == null)
197+
{
198+
return totalWidth;
199+
}
200+
188201
foreach (var width in columnWidths)
189202
{
190203
if (width < 0)
@@ -199,11 +212,19 @@ private static int CalculateTotalWidth(IEnumerable<int> columnWidths)
199212
}
200213

201214
/// <summary>
202-
/// Calculates the total height of the grid.
215+
/// Calculates the total height of the grid.
203216
/// </summary>
204-
private static int CalculateTotalHeight(IEnumerable<int> rowHeights)
217+
/// <param name="rowHeights">The row heights.</param>
218+
/// <returns>The height we need for the grid.</returns>
219+
/// <exception cref="Common.Controls.CommonControlsException"></exception>
220+
private static int CalculateTotalHeight(IEnumerable<int>? rowHeights)
205221
{
206222
var totalHeight = 0;
223+
if (rowHeights == null)
224+
{
225+
return totalHeight;
226+
}
227+
207228
foreach (var height in rowHeights)
208229
{
209230
if (height < 0)

CommonFilter/FilterOption.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ public sealed class FilterOption
3535
/// <value>
3636
/// The entry text.
3737
/// </value>
38-
internal string EntryText { get; init; }
38+
internal string? EntryText { get; init; }
3939
}
4040
}

CommonLibraryGui.Tests/AuroraTests.cs

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,17 @@ public void Aurora()
6666
{
6767
AuroraTextures = new Dictionary<int, Texture>
6868
{
69-
{ 0, new Texture { Layer = 0, Id = 0, Path = Path.Combine(_sampleImagesFolder, "Tile.png") } },
70-
{ 1, new Texture { Layer = 1, Id = 1, Path = Path.Combine(_sampleImagesFolder, "layerOne.png") } },
71-
{ 2, new Texture { Layer = 1, Id = 1, Path = Path.Combine(_sampleImagesFolder, "LayerTwo.png") } }
69+
{
70+
0, new Texture { Layer = 0, Id = 0, Path = Path.Combine(_sampleImagesFolder, "Tile.png") }
71+
},
72+
{
73+
1,
74+
new Texture { Layer = 1, Id = 1, Path = Path.Combine(_sampleImagesFolder, "layerOne.png") }
75+
},
76+
{
77+
2,
78+
new Texture { Layer = 1, Id = 1, Path = Path.Combine(_sampleImagesFolder, "LayerTwo.png") }
79+
}
7280
},
7381
AuroraTextureSize = 100,
7482
AuroraHeight = 2,
@@ -132,9 +140,17 @@ public void Polaris()
132140
{
133141
PolarisTextures = new Dictionary<int, Texture>
134142
{
135-
{ 0, new Texture { Layer = 0, Id = 0, Path = Path.Combine(_sampleImagesFolder, "Tile.png") } },
136-
{ 1, new Texture { Layer = 1, Id = 1, Path = Path.Combine(_sampleImagesFolder, "layerOne.png") } },
137-
{ 2, new Texture { Layer = 1, Id = 1, Path = Path.Combine(_sampleImagesFolder, "LayerTwo.png") } }
143+
{
144+
0, new Texture { Layer = 0, Id = 0, Path = Path.Combine(_sampleImagesFolder, "Tile.png") }
145+
},
146+
{
147+
1,
148+
new Texture { Layer = 1, Id = 1, Path = Path.Combine(_sampleImagesFolder, "layerOne.png") }
149+
},
150+
{
151+
2,
152+
new Texture { Layer = 1, Id = 1, Path = Path.Combine(_sampleImagesFolder, "LayerTwo.png") }
153+
}
138154
},
139155
PolarisTextureSize = 100,
140156
PolarisHeight = 2,

Communication.Tests/Communication.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public async Task CommunicationsAsync()
2525
{
2626
var communication = new NetCom();
2727
// Use a URL that actually ends in a filename
28-
var url = "https://www.google.de/favicon.ico";
28+
const string url = "https://www.google.de/favicon.ico";
2929
var targetFolder = Path.Combine(Directory.GetCurrentDirectory(), "TestDownloads");
3030

3131
var success = await communication.SaveFile(targetFolder, url);

Communication/LogProtocol.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,19 @@ namespace Communication
1313
/// </summary>
1414
public enum LogProtocol
1515
{
16-
Tcp,
17-
Udp,
18-
Both
16+
/// <summary>
17+
/// The TCP Protocol
18+
/// </summary>
19+
Tcp = 0,
20+
21+
/// <summary>
22+
/// The UDP Protocol
23+
/// </summary>
24+
Udp = 1,
25+
26+
/// <summary>
27+
/// Both Protocols
28+
/// </summary>
29+
Both = 2
1930
}
2031
}

Core.Apps/CommandFactory.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
* PROGRAMMER: Peter Geinitz (Wayfarer)
77
*/
88

9+
// ReSharper disable UnusedMember.Global
10+
911
using Core.Apps.Development;
1012
using Core.Apps.Extensions;
1113
using Core.Apps.FileManager;
@@ -31,7 +33,7 @@ public static class CommandFactory
3133
/// <returns>
3234
/// All commands.
3335
/// </returns>
34-
public static IReadOnlyList<ICommand> GetCommands(Weave? weave = null)
36+
public static IEnumerable<ICommand> GetCommands(Weave? weave = null)
3537
{
3638
// 1. Use a List instead of an array so we can dynamically add commands
3739
var modules = new List<ICommand>();

DataFormatter/DataHelper.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ internal static class DataHelper
2727
/// <returns>split Parts</returns>
2828
internal static List<string> GetParts(string str, char separator)
2929
{
30-
if (string.IsNullOrEmpty(str)) return new List<string>();
31-
32-
return str.Split(separator).ToList();
30+
return string.IsNullOrEmpty(str) ? new List<string>() : str.Split(separator).ToList();
3331
}
3432

3533
/// <summary>

DataFormatter/SegmentedCsvHandler.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
* PROGRAMER: Peter Geinitz (Wayfarer)
77
*/
88

9+
// ReSharper disable MemberCanBeInternal
10+
11+
using System;
912
using System.Collections.Generic;
1013
using System.Text;
1114

@@ -63,7 +66,7 @@ public static void WriteCsvWithLayerKeywords(string filepath, char separator, Li
6366
foreach (var line in lst)
6467
// When the layer keyword is encountered, store the current layer
6568
{
66-
if (line.StartsWith(layerKeyword))
69+
if (line.StartsWith(layerKeyword, StringComparison.Ordinal))
6770
{
6871
if (currentLayer.Length > 0)
6972
{

RenderEngine/GLResourceManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,4 +512,4 @@ public void Dispose()
512512
GC.SuppressFinalize(this);
513513
}
514514
}
515-
}
515+
}

RenderEngine/Geometry2DBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,4 +197,4 @@ internal static (float x, float y, int r, int g, int b, int a)[] BuildCircleOutl
197197
return pts;
198198
}
199199
}
200-
}
200+
}

0 commit comments

Comments
 (0)