diff --git a/source/BaseGeneratorCommand.cs b/source/Commands/BaseGeneratorCommand.cs
similarity index 100%
rename from source/BaseGeneratorCommand.cs
rename to source/Commands/BaseGeneratorCommand.cs
diff --git a/source/BuildCommand.cs b/source/Commands/BuildCommand.cs
similarity index 100%
rename from source/BuildCommand.cs
rename to source/Commands/BuildCommand.cs
diff --git a/source/CheckLinkCommand.cs b/source/Commands/CheckLinkCommand.cs
similarity index 94%
rename from source/CheckLinkCommand.cs
rename to source/Commands/CheckLinkCommand.cs
index a98dc92339aa191cc13a3cd6ea058b8348867e5c..b8fd4c361ca135913329300c7665c7d0d864581b 100644
--- a/source/CheckLinkCommand.cs
+++ b/source/Commands/CheckLinkCommand.cs
@@ -12,7 +12,6 @@ namespace SuCoS;
///
public sealed partial class CheckLinkCommand(CheckLinkOptions settings, ILogger logger)
{
-
[GeneratedRegex(@"https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9@:%_\+.~#?&\/=]*)")]
private static partial Regex URLRegex();
private static readonly Regex urlRegex = URLRegex();
@@ -40,7 +39,7 @@ public sealed partial class CheckLinkCommand(CheckLinkOptions settings, ILogger
httpClient = GetHttpClient();
var files = GetFiles(directoryPath, settings.Filters);
- var linksAreValid = await CheckLinks(directoryPath, files, httpClient);
+ var linksAreValid = await CheckLinks(directoryPath, files, httpClient).ConfigureAwait(false);
if (!linksAreValid)
{
@@ -120,7 +119,7 @@ public sealed partial class CheckLinkCommand(CheckLinkOptions settings, ILogger
var linkIsValid = false;
for (var j = 0; j < retriesCount && !linkIsValid; j++)
{
- linkIsValid |= await CheckLink(fileNameSanitized, link, httpClient);
+ linkIsValid |= await CheckLink(fileNameSanitized, link, httpClient).ConfigureAwait(false);
if (!linkIsValid && j < retriesCount - 1)
{
LogInformation("{fileName}: {link} retrying...", fileNameSanitized, link);
@@ -140,7 +139,7 @@ public sealed partial class CheckLinkCommand(CheckLinkOptions settings, ILogger
result &= linkIsValid;
}
- });
+ }).ConfigureAwait(false);
return result;
}
@@ -201,22 +200,23 @@ public sealed partial class CheckLinkCommand(CheckLinkOptions settings, ILogger
return files;
}
- void LogInformation(string message, string fileName, string? link = null, string? arg = null)
+ private void LogInformation(string message, string fileName, string? link = null, string? arg = null)
{
- if (settings.Verbose && false)
+ if (settings.Verbose)
{
logger.Information(message, fileName, link, arg);
}
}
- void LogError(string message, string fileName, string? link = null, string? arg = null)
+ private void LogError(string message, string fileName, string? link = null, string? arg = null)
{
if (settings.Verbose)
{
logger.Error(message, fileName, link, arg);
}
}
- void LogError(string message, string fileName, string? link, HttpStatusCode arg)
+
+ private void LogError(string message, string fileName, string? link, HttpStatusCode arg)
{
if (settings.Verbose)
{
diff --git a/source/NewSiteCommand.cs b/source/Commands/NewSiteCommand.cs
similarity index 100%
rename from source/NewSiteCommand.cs
rename to source/Commands/NewSiteCommand.cs
diff --git a/source/NewThemeCommand.cs b/source/Commands/NewThemeCommand.cs
similarity index 100%
rename from source/NewThemeCommand.cs
rename to source/Commands/NewThemeCommand.cs
diff --git a/source/ServeCommand.cs b/source/Commands/ServeCommand.cs
similarity index 99%
rename from source/ServeCommand.cs
rename to source/Commands/ServeCommand.cs
index 6d7757410ae5581427230523bf65b7d7baaf863d..966593310831c7abf24bf2d826353f8f09cfceb0 100644
--- a/source/ServeCommand.cs
+++ b/source/Commands/ServeCommand.cs
@@ -205,7 +205,7 @@ public sealed class ServeCommand : BaseGeneratorCommand, IDisposable
if (resultType is null)
{
resultType = "404";
- await HandleNotFoundRequest(context).ConfigureAwait(true);
+ await HandleNotFoundRequest(context).ConfigureAwait(false);
}
else
{
@@ -228,7 +228,10 @@ public sealed class ServeCommand : BaseGeneratorCommand, IDisposable
/// The FileSystemEventArgs containing information about the file change.
private void OnSourceFileChanged(object sender, FileSystemEventArgs e)
{
- if (e.FullPath.Contains("\\.git\\", StringComparison.InvariantCulture)) return;
+ if (e.FullPath.Contains("\\.git\\", StringComparison.InvariantCulture))
+ {
+ return;
+ }
// File changes are firing multiple events in a short time.
// Debounce the event handler to prevent multiple events from firing in a short time
diff --git a/source/Helpers/FileUtils.cs b/source/Helpers/FileUtils.cs
index 0afcb810407ef154fdbd3545804d7aa8ab9888fa..fd1ae1ded53540518a40158e45290160dbb0a4a6 100644
--- a/source/Helpers/FileUtils.cs
+++ b/source/Helpers/FileUtils.cs
@@ -26,7 +26,9 @@ public static class FileUtils
// Check if the template content is already cached
if (cache.TryGetValue(index, out var content))
+ {
return content;
+ }
var templatePaths = GetTemplateLookupOrder(themePath, page, isBaseTemplate);
content = GetTemplate(templatePaths);
diff --git a/source/Helpers/SourceFileWatcher.cs b/source/Helpers/SourceFileWatcher.cs
index 2a3bcce13e6c68393a16bbb37362acb58b71f006..2a8e2156dfabbca6bab55b7b9b4744223bf1dc85 100644
--- a/source/Helpers/SourceFileWatcher.cs
+++ b/source/Helpers/SourceFileWatcher.cs
@@ -1,5 +1,3 @@
-using System;
-
namespace SuCoS.Helpers;
///
@@ -48,7 +46,7 @@ public sealed class SourceFileWatcher : IFileWatcher, IDisposable
GC.SuppressFinalize(this);
}
- void Dispose(bool disposing)
+ private void Dispose(bool disposing)
{
if (disposing)
{
diff --git a/source/Models/CommandLineOptions/NewOptions.cs b/source/Models/CommandLineOptions/NewOptions.cs
deleted file mode 100644
index 71d5be246e37ace329e5a84fae7504aa08f7bfee..0000000000000000000000000000000000000000
--- a/source/Models/CommandLineOptions/NewOptions.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using CommandLine;
-
-namespace SuCoS.Models.CommandLineOptions;
-
-///
-/// Command line options to generate a simple site from scratch.
-///
-[Verb("new", false, HelpText = "Generate a simple theme from scratch")]
-public class NewOptions
-{
-}
diff --git a/source/Models/IFrontMatter.cs b/source/Models/IFrontMatter.cs
index 27d6c2a1809c369d6387bcd26b9464cf3d07e69d..2a6f176b397e91d7866c0ae4b313b444b5a0e6a1 100644
--- a/source/Models/IFrontMatter.cs
+++ b/source/Models/IFrontMatter.cs
@@ -1,4 +1,3 @@
-using System.Collections.ObjectModel;
using SuCoS.Models.CommandLineOptions;
namespace SuCoS.Models;
diff --git a/source/Models/Page.cs b/source/Models/Page.cs
index 503ef968ee0859588f427dcad310949caaa3daba..cec47bfdfc377eb136ff52d2ac18e02129a8de9b 100644
--- a/source/Models/Page.cs
+++ b/source/Models/Page.cs
@@ -393,8 +393,14 @@ endif
private void ScanForResources()
{
- if (string.IsNullOrEmpty(SourceFullPathDirectory)) return;
- if (BundleType == BundleType.none) return;
+ if (string.IsNullOrEmpty(SourceFullPathDirectory))
+ {
+ return;
+ }
+ if (BundleType == BundleType.none)
+ {
+ return;
+ }
try
{
diff --git a/source/Program.cs b/source/Program.cs
index 53c15fff3197b68e0a0abffb8d56f0b36ba0169d..d99daa7148f2ed68744affc87850641220f27d57 100644
--- a/source/Program.cs
+++ b/source/Program.cs
@@ -32,7 +32,7 @@ public class Program(ILogger logger)
public static async Task Main(string[] args)
{
var program = new Program(CreateLogger());
- return await program.RunCommandLine(args);
+ return await program.RunCommandLine(args).ConfigureAwait(false);
}
///
@@ -112,7 +112,7 @@ public class Program(ILogger logger)
return Task.FromResult(command.Run());
},
errs => Task.FromResult(0)
- );
+ ).ConfigureAwait(false);
}
///
diff --git a/source/ServerHandlers/RegisteredPageRequest.cs b/source/ServerHandlers/RegisteredPageRequest.cs
index 7c285aa3dc45dc03400ad1db3eec4454947f45c9..12e06c7b03ebbe8babd3d4850e85d5561a806a8c 100644
--- a/source/ServerHandlers/RegisteredPageRequest.cs
+++ b/source/ServerHandlers/RegisteredPageRequest.cs
@@ -8,7 +8,7 @@ namespace SuCoS.ServerHandlers;
///
public class RegisteredPageRequest : IServerHandlers
{
- readonly ISite site;
+ private readonly ISite site;
///
/// Constructor