Skip to content

Commit e33f323

Browse files
Randall FlaggRandall Flagg
authored andcommitted
Add second parameter for better message when throwing ArgumentNullException
1 parent 92af085 commit e33f323

7 files changed

Lines changed: 12 additions & 10 deletions

File tree

src/LogExpert.Core/Classes/Bookmark/BookmarkDataProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public void RemoveBookmarkForLine (int lineNum)
134134
//TOOD: check if the callers are checking for null before calling
135135
public void RemoveBookmarksForLines (IEnumerable<int> lineNumList)
136136
{
137-
ArgumentNullException.ThrowIfNull(lineNumList);
137+
ArgumentNullException.ThrowIfNull(lineNumList, nameof(lineNumList));
138138

139139
foreach (var lineNum in lineNumList)
140140
{
@@ -148,7 +148,7 @@ public void RemoveBookmarksForLines (IEnumerable<int> lineNumList)
148148
//TOOD: check if the callers are checking for null before calling
149149
public void AddBookmark (Entities.Bookmark bookmark)
150150
{
151-
ArgumentNullException.ThrowIfNull(bookmark);
151+
ArgumentNullException.ThrowIfNull(bookmark, nameof(bookmark));
152152

153153
BookmarkList.Add(bookmark.LineNum, bookmark);
154154
OnBookmarkAdded();

src/LogExpert.Core/Classes/Bookmark/BookmarkExporter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public static class BookmarkExporter
1313
//TOOD: check if the callers are checking for null before calling
1414
public static void ExportBookmarkList (SortedList<int, Entities.Bookmark> bookmarkList, string logfileName, string fileName)
1515
{
16-
ArgumentNullException.ThrowIfNull(bookmarkList);
16+
ArgumentNullException.ThrowIfNull(bookmarkList, nameof(bookmarkList));
1717
FileStream fs = new(fileName, FileMode.Create, FileAccess.Write);
1818
StreamWriter writer = new(fs);
1919
writer.WriteLine("Log file name;Line number;Comment");

src/LogExpert.Core/Classes/Columnizer/ColumnizerPicker.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public static ILogLineColumnizer FindColumnizer (string fileName, IAutoLogLineCo
101101
return new DefaultLogfileColumnizer();
102102
}
103103

104-
ArgumentNullException.ThrowIfNull(registeredColumnizer);
104+
ArgumentNullException.ThrowIfNull(registeredColumnizer, nameof(registeredColumnizer));
105105

106106
List<ILogLine> loglines = [];
107107

src/LogExpert.Core/Classes/DateTimeParser/DateFormatPartAdjuster.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
namespace LogExpert.Core.Classes.DateTimeParser;
55

6+
//TODO: This should be moved into LogExpert.UI and changed to internal
67
// Ensures we have constant width (number of characters) date formats
78
public static class DateFormatPartAdjuster
89
{
@@ -18,6 +19,8 @@ public static class DateFormatPartAdjuster
1819

1920
public static string AdjustDateTimeFormatPart(string part)
2021
{
22+
ArgumentNullException.ThrowIfNull(part, nameof(part));
23+
2124
if (!_dateTimePartReplacements.TryGetValue(part, out var adjustedPart))
2225
{
2326
return part;

src/LogExpert.Core/Classes/DateTimeParser/Token.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public static class Token
77
//TOOD: check if the callers are checking for null before calling
88
public static bool IsDatePart(string token)
99
{
10-
ArgumentNullException.ThrowIfNull(token);
10+
ArgumentNullException.ThrowIfNull(token, nameof(token));
1111
return
1212
token.StartsWith("y", StringComparison.OrdinalIgnoreCase) ||
1313
token.StartsWith("m", StringComparison.OrdinalIgnoreCase) ||

src/LogExpert.UI/Controls/DateTimeDragControl.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,16 +234,15 @@ private void InitCustomRects (Section dateSection)
234234
.Select(DateFormatPartAdjuster.AdjustDateTimeFormatPart)
235235
.ToArray();
236236

237-
Rectangle rect = ClientRectangle;
238-
var oneCharWidth = rect.Width / _dateParts.Sum(s => s.Length);
239-
var left = rect.Left;
237+
var oneCharWidth = ClientRectangle.Width / _dateParts.Sum(s => s.Length);
238+
var left = ClientRectangle.Left;
240239

241240
_digitRects.Clear();
242241

243242
foreach (var datePart in _dateParts)
244243
{
245244
var s = datePart.Length * oneCharWidth;
246-
_digitRects.Add(new Rectangle(left, rect.Top, s, rect.Height));
245+
_digitRects.Add(new Rectangle(left, ClientRectangle.Top, s, ClientRectangle.Height));
247246
left += s;
248247
}
249248

src/LogExpert/Classes/CommandLine/CmdLine.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class CmdLineString (string name, bool required, string helpMessage) : Cm
1717

1818
public static implicit operator string (CmdLineString s)
1919
{
20-
ArgumentNullException.ThrowIfNull(s);
20+
ArgumentNullException.ThrowIfNull(s, nameof(s));
2121
return s.Value;
2222
}
2323

0 commit comments

Comments
 (0)