Skip to content

Commit 2791e76

Browse files
committed
nullチェックをArgumentNullException.ThrowIfNullへ統一
1 parent c02e0dd commit 2791e76

6 files changed

Lines changed: 30 additions & 24 deletions

File tree

Models/FileDiffResultLists.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,7 @@ public static void RecordDisassemblerToolVersion(string toolName, string version
244244
/// <exception cref="ArgumentNullException">items が null の場合。</exception>
245245
private static void ReplaceQueueItems(ConcurrentQueue<string> targetQueue, IEnumerable<string> items, string paramName)
246246
{
247-
if (items is null)
248-
{
249-
throw new ArgumentNullException(paramName);
250-
}
247+
ArgumentNullException.ThrowIfNull(items, paramName);
251248

252249
targetQueue.Clear();
253250
foreach (var item in items)
@@ -265,10 +262,7 @@ private static void ReplaceQueueItems(ConcurrentQueue<string> targetQueue, IEnum
265262
/// <exception cref="ArgumentNullException">path が null の場合。</exception>
266263
private static void EnqueuePath(ConcurrentQueue<string> targetQueue, string path, string paramName)
267264
{
268-
if (path is null)
269-
{
270-
throw new ArgumentNullException(paramName);
271-
}
265+
ArgumentNullException.ThrowIfNull(path, paramName);
272266
targetQueue.Enqueue(path);
273267
}
274268
}

Services/Caching/ILCache.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -519,10 +519,7 @@ private static void LogPrecomputeProgress(int totalFiles, int processed, ref lon
519519
/// <exception cref="ArgumentNullException"><paramref name="ilCacheKey"/> が null の場合。</exception>
520520
private void StoreInMemoryCache(string ilCacheKey, string ilText)
521521
{
522-
if (ilCacheKey == null)
523-
{
524-
throw new ArgumentNullException(nameof(ilCacheKey));
525-
}
522+
ArgumentNullException.ThrowIfNull(ilCacheKey);
526523
EnsureMemoryCapacity();
527524
_memoryILCacheDictionary[ilCacheKey] = (ilText, DateTime.UtcNow, DateTime.UtcNow);
528525
}

Services/DotNetDisassembleService.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ public sealed class DotNetDisassembleService
217217
/// <exception cref="ArgumentNullException"></exception>
218218
public DotNetDisassembleService(ConfigSettings config, ILCache ilCache)
219219
{
220-
_config = config ?? throw new ArgumentNullException(nameof(config));
220+
ArgumentNullException.ThrowIfNull(config);
221+
_config = config;
221222
_ilCache = ilCache;
222223
}
223224

Services/FileDiffService.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,15 @@ public sealed class FileDiffService
6666
/// </summary>
6767
public FileDiffService(ConfigSettings config, ILOutputService ilOutputService, string oldFolderAbsolutePath, string newFolderAbsolutePath, bool optimizeForNetworkShares)
6868
{
69-
_config = config ?? throw new ArgumentNullException(nameof(config));
70-
_ilOutputService = ilOutputService ?? throw new ArgumentNullException(nameof(ilOutputService));
71-
_oldFolderAbsolutePath = oldFolderAbsolutePath ?? throw new ArgumentNullException(nameof(oldFolderAbsolutePath));
72-
_newFolderAbsolutePath = newFolderAbsolutePath ?? throw new ArgumentNullException(nameof(newFolderAbsolutePath));
69+
ArgumentNullException.ThrowIfNull(config);
70+
ArgumentNullException.ThrowIfNull(ilOutputService);
71+
ArgumentNullException.ThrowIfNull(oldFolderAbsolutePath);
72+
ArgumentNullException.ThrowIfNull(newFolderAbsolutePath);
73+
74+
_config = config;
75+
_ilOutputService = ilOutputService;
76+
_oldFolderAbsolutePath = oldFolderAbsolutePath;
77+
_newFolderAbsolutePath = newFolderAbsolutePath;
7378
_optimizeForNetworkShares = optimizeForNetworkShares;
7479
}
7580

Services/FolderDiffService.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,18 @@ public sealed class FolderDiffService
183183
/// <exception cref="ArgumentNullException">config または progressReporter または oldFolderAbsolutePath または newFolderAbsolutePath または reportsFolderAbsolutePath が null の場合。</exception>
184184
public FolderDiffService(ConfigSettings config, ProgressReportService progressReporter, string oldFolderAbsolutePath, string newFolderAbsolutePath, string reportsFolderAbsolutePath)
185185
{
186-
_config = config ?? throw new ArgumentNullException(nameof(config));
187-
_progressReporter = progressReporter ?? throw new ArgumentNullException(nameof(progressReporter));
186+
ArgumentNullException.ThrowIfNull(config);
187+
ArgumentNullException.ThrowIfNull(progressReporter);
188+
ArgumentNullException.ThrowIfNull(oldFolderAbsolutePath);
189+
ArgumentNullException.ThrowIfNull(newFolderAbsolutePath);
190+
ArgumentNullException.ThrowIfNull(reportsFolderAbsolutePath);
191+
192+
_config = config;
193+
_progressReporter = progressReporter;
188194
_progressReporter.SetLabel(SPINNER_LABEL_FOLDER_DIFF);
189-
_oldFolderAbsolutePath = oldFolderAbsolutePath ?? throw new ArgumentNullException(nameof(oldFolderAbsolutePath));
190-
_newFolderAbsolutePath = newFolderAbsolutePath ?? throw new ArgumentNullException(nameof(newFolderAbsolutePath));
191-
_reportsFolderAbsolutePath = reportsFolderAbsolutePath ?? throw new ArgumentNullException(nameof(reportsFolderAbsolutePath));
195+
_oldFolderAbsolutePath = oldFolderAbsolutePath;
196+
_newFolderAbsolutePath = newFolderAbsolutePath;
197+
_reportsFolderAbsolutePath = reportsFolderAbsolutePath;
192198
_ilOutputFolderAbsolutePath = Path.Combine(_reportsFolderAbsolutePath, IL_FOLDER_NAME);
193199
_ilOldFolderAbsolutePath = Path.Combine(_ilOutputFolderAbsolutePath, IL_OLD_SUB_DIR);
194200
_ilNewFolderAbsolutePath = Path.Combine(_ilOutputFolderAbsolutePath, IL_NEW_SUB_DIR);

Services/ILOutput/ILTextOutputService.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,11 @@ public sealed class ILTextOutputService
4040
/// <param name="ilNewFolderAbsolutePath">新 IL フォルダの絶対パス</param>
4141
public ILTextOutputService(string ilOldFolderAbsolutePath, string ilNewFolderAbsolutePath)
4242
{
43-
_ilOldFolderAbsolutePath = ilOldFolderAbsolutePath ?? throw new ArgumentNullException(nameof(ilOldFolderAbsolutePath));
44-
_ilNewFolderAbsolutePath = ilNewFolderAbsolutePath ?? throw new ArgumentNullException(nameof(ilNewFolderAbsolutePath));
43+
ArgumentNullException.ThrowIfNull(ilOldFolderAbsolutePath);
44+
ArgumentNullException.ThrowIfNull(ilNewFolderAbsolutePath);
45+
46+
_ilOldFolderAbsolutePath = ilOldFolderAbsolutePath;
47+
_ilNewFolderAbsolutePath = ilNewFolderAbsolutePath;
4548
}
4649

4750
/// <summary>

0 commit comments

Comments
 (0)