ParseAsync(
IFileInfo path,
MarkdownParserContext context,
MarkdownPipeline pipeline,
diff --git a/src/Elastic.Markdown/Myst/SectionedHeadingRenderer.cs b/src/Elastic.Markdown/Myst/SectionedHeadingRenderer.cs
index f95cce848..ae4a4e4e0 100644
--- a/src/Elastic.Markdown/Myst/SectionedHeadingRenderer.cs
+++ b/src/Elastic.Markdown/Myst/SectionedHeadingRenderer.cs
@@ -33,25 +33,25 @@ protected override void Write(HtmlRenderer renderer, HeadingBlock obj)
var anchor = obj.GetData("anchor") as string;
var slugTarget = (anchor ?? header) ?? string.Empty;
- if (slugTarget.IndexOf('$') >= 0)
+ if (slugTarget.Contains('$'))
slugTarget = HeadingAnchorParser.InlineAnchors().Replace(slugTarget, "");
var slug = slugTarget.Slugify();
- renderer.Write(@"");
- renderer.Write('<');
- renderer.Write(headingText);
- renderer.WriteAttributes(obj);
- renderer.Write('>');
- renderer.Write($"""");
- renderer.Write("");
- renderer.Write(headingText);
- renderer.WriteLine('>');
- renderer.Write("
");
- renderer.EnsureLine();
+ _ = renderer.Write(@"")
+ .Write('<')
+ .Write(headingText)
+ .WriteAttributes(obj)
+ .Write('>')
+ .Write($"""")
+ .Write("")
+ .Write(headingText)
+ .WriteLine('>')
+ .Write("
")
+ .EnsureLine();
}
}
diff --git a/src/Elastic.Markdown/Myst/Settings/StructuredSettings.cs b/src/Elastic.Markdown/Myst/Settings/StructuredSettings.cs
index c3faa0b15..afa3dbbc7 100644
--- a/src/Elastic.Markdown/Myst/Settings/StructuredSettings.cs
+++ b/src/Elastic.Markdown/Myst/Settings/StructuredSettings.cs
@@ -8,7 +8,7 @@
namespace Elastic.Markdown.Myst.Settings;
[YamlSerializable]
-public record SettingsCollection
+public record YamlSettings
{
[YamlMember(Alias = "product")]
public string? Product { get; set; }
diff --git a/src/Elastic.Markdown/Myst/Substitution/SubstitutionParser.cs b/src/Elastic.Markdown/Myst/Substitution/SubstitutionParser.cs
index 8eff207d8..cb123aadb 100644
--- a/src/Elastic.Markdown/Myst/Substitution/SubstitutionParser.cs
+++ b/src/Elastic.Markdown/Myst/Substitution/SubstitutionParser.cs
@@ -53,7 +53,7 @@ public LazySubstring(string text, int offset, int length)
Length = length;
}
- public ReadOnlySpan AsSpan() => _text.AsSpan(Offset, Length);
+ public readonly ReadOnlySpan AsSpan() => _text.AsSpan(Offset, Length);
public override string ToString()
{
@@ -123,7 +123,7 @@ public override bool Match(InlineProcessor processor, ref StringSlice slice)
if (closeSticks != 2)
return false;
- var rawContent = slice.AsSpan().Slice(0, slice.Length - span.Length);
+ var rawContent = slice.AsSpan()[..(slice.Length - span.Length)];
var content = new LazySubstring(slice.Text, slice.Start, rawContent.Length);
diff --git a/src/Elastic.Markdown/Myst/YamlSerialization.cs b/src/Elastic.Markdown/Myst/YamlSerialization.cs
index 06d0c47ad..b343f38ff 100644
--- a/src/Elastic.Markdown/Myst/YamlSerialization.cs
+++ b/src/Elastic.Markdown/Myst/YamlSerialization.cs
@@ -30,9 +30,9 @@ public static T Deserialize(string yaml)
}
[YamlStaticContext]
-[YamlSerializable(typeof(SettingsCollection))]
+[YamlSerializable(typeof(YamlSettings))]
[YamlSerializable(typeof(SettingsGrouping))]
-[YamlSerializable(typeof(SettingsCollection))]
+[YamlSerializable(typeof(YamlSettings))]
[YamlSerializable(typeof(SettingsGrouping))]
[YamlSerializable(typeof(Setting))]
[YamlSerializable(typeof(AllowedValue))]
diff --git a/src/Elastic.Markdown/Slices/Directives/ApplicableTo.cshtml b/src/Elastic.Markdown/Slices/Directives/ApplicableTo.cshtml
index b25a0e7a8..3eb1181b7 100644
--- a/src/Elastic.Markdown/Slices/Directives/ApplicableTo.cshtml
+++ b/src/Elastic.Markdown/Slices/Directives/ApplicableTo.cshtml
@@ -82,7 +82,7 @@
}
}
- private IHtmlContent RenderProduct(string name, ApplicabilityOverTime applications)
+ private IHtmlContent RenderProduct(string name, AppliesCollection applications)
{
foreach (var applicability in applications)
{
diff --git a/src/Elastic.Markdown/Slices/Directives/_ViewModels.cs b/src/Elastic.Markdown/Slices/Directives/_ViewModels.cs
index 6960dccf9..51b42782c 100644
--- a/src/Elastic.Markdown/Slices/Directives/_ViewModels.cs
+++ b/src/Elastic.Markdown/Slices/Directives/_ViewModels.cs
@@ -62,9 +62,9 @@ public string Style
{
var sb = new StringBuilder();
if (Height != null)
- sb.Append($"height: {Height};");
+ _ = sb.Append($"height: {Height};");
if (Width != null)
- sb.Append($"width: {Width};");
+ _ = sb.Append($"width: {Width};");
return sb.ToString();
}
}
@@ -73,7 +73,7 @@ public string Style
public class SettingsViewModel
{
- public required SettingsCollection SettingsCollection { get; init; }
+ public required YamlSettings SettingsCollection { get; init; }
public required Func RenderMarkdown { get; init; }
}
diff --git a/src/Elastic.Markdown/Slices/HtmlWriter.cs b/src/Elastic.Markdown/Slices/HtmlWriter.cs
index 71851cfdc..e09dd2924 100644
--- a/src/Elastic.Markdown/Slices/HtmlWriter.cs
+++ b/src/Elastic.Markdown/Slices/HtmlWriter.cs
@@ -17,7 +17,7 @@ public HtmlWriter(DocumentationSet documentationSet, IFileSystem writeFileSystem
{
_writeFileSystem = writeFileSystem;
var services = new ServiceCollection();
- services.AddLogging();
+ _ = services.AddLogging();
ServiceProvider = services.BuildServiceProvider();
LoggerFactory = ServiceProvider.GetRequiredService();
@@ -43,7 +43,7 @@ private async Task RenderNavigation(MarkdownFile markdown, Cancel ctx =
public async Task RenderLayout(MarkdownFile markdown, Cancel ctx = default)
{
var document = await markdown.ParseFullAsync(ctx);
- var html = markdown.CreateHtml(document);
+ var html = MarkdownFile.CreateHtml(document);
await DocumentationSet.Tree.Resolve(ctx);
_renderedNavigation ??= await RenderNavigation(markdown, ctx);
@@ -60,7 +60,7 @@ public async Task RenderLayout(MarkdownFile markdown, Cancel ctx = defau
Title = markdown.Title ?? "[TITLE NOT SET]",
TitleRaw = markdown.TitleRaw ?? "[TITLE NOT SET]",
MarkdownHtml = html,
- PageTocItems = markdown.TableOfContents.Values.ToList(),
+ PageTocItems = [.. markdown.TableOfContents.Values],
Tree = DocumentationSet.Tree,
CurrentDocument = markdown,
PreviousDocument = previous,
@@ -90,7 +90,7 @@ public async Task WriteAsync(IFileInfo outputFile, MarkdownFile markdown, Cancel
: Path.Combine(outputFile.Directory.FullName, Path.GetFileNameWithoutExtension(outputFile.Name));
if (dir is not null && !_writeFileSystem.Directory.Exists(dir))
- _writeFileSystem.Directory.CreateDirectory(dir);
+ _ = _writeFileSystem.Directory.CreateDirectory(dir);
path = dir is null
? Path.GetFileNameWithoutExtension(outputFile.Name) + ".html"
diff --git a/src/Elastic.Markdown/Slices/Layout/_TocTreeNav.cshtml b/src/Elastic.Markdown/Slices/Layout/_TocTreeNav.cshtml
index 512c14695..ead5995ed 100644
--- a/src/Elastic.Markdown/Slices/Layout/_TocTreeNav.cshtml
+++ b/src/Elastic.Markdown/Slices/Layout/_TocTreeNav.cshtml
@@ -1,4 +1,3 @@
-@using Elastic.Markdown.Helpers
@using Elastic.Markdown.IO.Navigation
@inherits RazorSlice
@foreach (var item in Model.SubTree.NavigationItems)
diff --git a/src/Elastic.Markdown/SourceGenerationContext.cs b/src/Elastic.Markdown/SourceGenerationContext.cs
index 7c0c77ec6..8e1769b96 100644
--- a/src/Elastic.Markdown/SourceGenerationContext.cs
+++ b/src/Elastic.Markdown/SourceGenerationContext.cs
@@ -17,4 +17,4 @@ namespace Elastic.Markdown;
[JsonSerializable(typeof(GitCheckoutInformation))]
[JsonSerializable(typeof(LinkIndex))]
[JsonSerializable(typeof(LinkIndexEntry))]
-internal partial class SourceGenerationContext : JsonSerializerContext;
+internal sealed partial class SourceGenerationContext : JsonSerializerContext;
diff --git a/src/docs-assembler/AssemblyConfiguration.cs b/src/docs-assembler/AssemblyConfiguration.cs
index 8664e79f3..aa6227204 100644
--- a/src/docs-assembler/AssemblyConfiguration.cs
+++ b/src/docs-assembler/AssemblyConfiguration.cs
@@ -35,7 +35,7 @@ public static AssemblyConfiguration Deserialize(string yaml)
}
[YamlMember(Alias = "repos")]
- public Dictionary Repositories { get; set; } = new();
+ public Dictionary Repositories { get; set; } = [];
}
public record Repository
diff --git a/src/docs-assembler/Cli/Filters.cs b/src/docs-assembler/Cli/Filters.cs
index cdf3c07fb..2d5427320 100644
--- a/src/docs-assembler/Cli/Filters.cs
+++ b/src/docs-assembler/Cli/Filters.cs
@@ -7,7 +7,7 @@
namespace Documentation.Assembler.Cli;
-internal class StopwatchFilter(ConsoleAppFilter next) : ConsoleAppFilter(next)
+internal sealed class StopwatchFilter(ConsoleAppFilter next) : ConsoleAppFilter(next)
{
public override async Task InvokeAsync(ConsoleAppContext context, Cancel ctx)
{
@@ -29,7 +29,7 @@ public override async Task InvokeAsync(ConsoleAppContext context, Cancel ctx)
}
}
-internal class CatchExceptionFilter(ConsoleAppFilter next) : ConsoleAppFilter(next)
+internal sealed class CatchExceptionFilter(ConsoleAppFilter next) : ConsoleAppFilter(next)
{
public override async Task InvokeAsync(ConsoleAppContext context, CancellationToken cancellationToken)
{
diff --git a/src/docs-assembler/Cli/LinkCommands.cs b/src/docs-assembler/Cli/LinkCommands.cs
index 8ec294b27..5bca2c38c 100644
--- a/src/docs-assembler/Cli/LinkCommands.cs
+++ b/src/docs-assembler/Cli/LinkCommands.cs
@@ -11,13 +11,15 @@
namespace Documentation.Assembler.Cli;
-internal class LinkCommands(ILoggerFactory logger)
+internal sealed class LinkCommands(ILoggerFactory logger)
{
private void AssignOutputLogger()
{
var log = logger.CreateLogger();
+#pragma warning disable CA2254
ConsoleApp.Log = msg => log.LogInformation(msg);
ConsoleApp.LogError = msg => log.LogError(msg);
+#pragma warning restore CA2254
}
///
@@ -38,7 +40,7 @@ public async Task CreateLinkIndex(Cancel ctx = default)
Console.WriteLine("--------------------------------------");
- var linkIndex = new LinkIndex { Repositories = new Dictionary>() };
+ var linkIndex = new LinkIndex { Repositories = [] };
try
{
ListObjectsV2Response response;
diff --git a/src/docs-assembler/Cli/RepositoryCommands.cs b/src/docs-assembler/Cli/RepositoryCommands.cs
index 50fcbe2c8..72c147cb1 100644
--- a/src/docs-assembler/Cli/RepositoryCommands.cs
+++ b/src/docs-assembler/Cli/RepositoryCommands.cs
@@ -21,13 +21,15 @@ public void Handle(LineOut lineOut) => lineOut.CharsOrString(
public void Handle(Exception e) { }
}
-internal class RepositoryCommands(ILoggerFactory logger)
+internal sealed class RepositoryCommands(ILoggerFactory logger)
{
private void AssignOutputLogger()
{
var log = logger.CreateLogger();
+#pragma warning disable CA2254
ConsoleApp.Log = msg => log.LogInformation(msg);
ConsoleApp.LogError = msg => log.LogError(msg);
+#pragma warning restore CA2254
}
// would love to use libgit2 so there is no git dependency but
@@ -53,14 +55,14 @@ await Task.Run(() =>
var checkoutFolder = Path.Combine(Paths.Root.FullName, $".artifacts/assembly/{name}");
var sw = Stopwatch.StartNew();
- dict.AddOrUpdate(name, sw, (_, _) => sw);
+ _ = dict.AddOrUpdate(name, sw, (_, _) => sw);
Console.WriteLine($"Checkout: {name}\t{repository}\t{checkoutFolder}");
var branch = repository.Branch ?? "main";
var args = new StartArguments(
"git", "clone", repository.Origin, checkoutFolder, "--depth", "1"
, "--single-branch", "--branch", branch
);
- Proc.StartRedirected(args, new ConsoleLineHandler(name));
+ _ = Proc.StartRedirected(args, new ConsoleLineHandler(name));
sw.Stop();
}, c);
}).ConfigureAwait(false);
@@ -70,9 +72,8 @@ await Task.Run(() =>
}
/// List all checked out repositories
- ///
[Command("list")]
- public async Task ListRepositories(Cancel ctx = default)
+ public async Task ListRepositories()
{
AssignOutputLogger();
var assemblyPath = Path.Combine(Paths.Root.FullName, $".artifacts/assembly");
diff --git a/src/docs-assembler/Program.cs b/src/docs-assembler/Program.cs
index 43f975580..021cd6315 100644
--- a/src/docs-assembler/Program.cs
+++ b/src/docs-assembler/Program.cs
@@ -12,18 +12,17 @@
var services = new ServiceCollection();
services.AddGitHubActionsCore();
-services.AddLogging(x =>
-{
- x.ClearProviders();
- x.SetMinimumLevel(LogLevel.Information);
- x.AddSimpleConsole(c =>
+services.AddLogging(x => x
+ .ClearProviders()
+ .SetMinimumLevel(LogLevel.Information)
+ .AddSimpleConsole(c =>
{
c.SingleLine = true;
c.IncludeScopes = true;
c.UseUtcTimestamp = true;
c.TimestampFormat = Environment.UserInteractive ? ":: " : "[yyyy-MM-ddTHH:mm:ss] ";
- });
-});
+ })
+);
services.AddSingleton();
services.AddSingleton();
diff --git a/src/docs-builder/Cli/CheckForUpdatesFilter.cs b/src/docs-builder/Cli/CheckForUpdatesFilter.cs
index aa9c8d4ef..aaf5728bd 100644
--- a/src/docs-builder/Cli/CheckForUpdatesFilter.cs
+++ b/src/docs-builder/Cli/CheckForUpdatesFilter.cs
@@ -8,7 +8,7 @@
namespace Documentation.Builder.Cli;
-internal class CheckForUpdatesFilter : ConsoleAppFilter
+internal sealed class CheckForUpdatesFilter : ConsoleAppFilter
{
private readonly FileInfo _stateFile;
@@ -32,7 +32,7 @@ public override async Task InvokeAsync(ConsoleAppContext context, Cancel ctx)
CompareWithAssemblyVersion(latestVersionUrl);
}
- private void CompareWithAssemblyVersion(Uri latestVersionUrl)
+ private static void CompareWithAssemblyVersion(Uri latestVersionUrl)
{
var versionPath = latestVersionUrl.AbsolutePath.Split('/').Last();
if (!SemVersion.TryParse(versionPath, out var latestVersion))
@@ -61,7 +61,7 @@ private void CompareWithAssemblyVersion(Uri latestVersionUrl)
ConsoleApp.LogError($"Unable to parse current version from docs-builder binary");
}
- private async ValueTask GetLatestVersion(CancellationToken ctx)
+ private async ValueTask GetLatestVersion(Cancel ctx)
{
if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("CI")))
return null;
@@ -83,7 +83,7 @@ private void CompareWithAssemblyVersion(Uri latestVersionUrl)
{
// ensure the 'elastic' folder exists.
if (!Directory.Exists(_stateFile.Directory.FullName))
- Directory.CreateDirectory(_stateFile.Directory.FullName);
+ _ = Directory.CreateDirectory(_stateFile.Directory.FullName);
await File.WriteAllTextAsync(_stateFile.FullName, redirectUrl.ToString(), ctx);
}
return redirectUrl;
diff --git a/src/docs-builder/Cli/Commands.cs b/src/docs-builder/Cli/Commands.cs
index 5fdb6b3ad..5c32681e4 100644
--- a/src/docs-builder/Cli/Commands.cs
+++ b/src/docs-builder/Cli/Commands.cs
@@ -13,13 +13,15 @@
namespace Documentation.Builder.Cli;
-internal class Commands(ILoggerFactory logger, ICoreService githubActionsService)
+internal sealed class Commands(ILoggerFactory logger, ICoreService githubActionsService)
{
private void AssignOutputLogger()
{
var log = logger.CreateLogger();
+#pragma warning disable CA2254
ConsoleApp.Log = msg => log.LogInformation(msg);
ConsoleApp.LogError = msg => log.LogError(msg);
+#pragma warning restore CA2254
}
///
diff --git a/src/docs-builder/Cli/Filters.cs b/src/docs-builder/Cli/Filters.cs
index aee8d557e..0f3de93ca 100644
--- a/src/docs-builder/Cli/Filters.cs
+++ b/src/docs-builder/Cli/Filters.cs
@@ -6,7 +6,7 @@
namespace Documentation.Builder.Cli;
-internal class StopwatchFilter(ConsoleAppFilter next) : ConsoleAppFilter(next)
+internal sealed class StopwatchFilter(ConsoleAppFilter next) : ConsoleAppFilter(next)
{
public override async Task InvokeAsync(ConsoleAppContext context, Cancel ctx)
{
@@ -28,9 +28,9 @@ public override async Task InvokeAsync(ConsoleAppContext context, Cancel ctx)
}
}
-internal class CatchExceptionFilter(ConsoleAppFilter next) : ConsoleAppFilter(next)
+internal sealed class CatchExceptionFilter(ConsoleAppFilter next) : ConsoleAppFilter(next)
{
- public override async Task InvokeAsync(ConsoleAppContext context, CancellationToken cancellationToken)
+ public override async Task InvokeAsync(ConsoleAppContext context, Cancel cancellationToken)
{
try
{
diff --git a/src/docs-builder/Diagnostics/Console/ConsoleDiagnosticsCollector.cs b/src/docs-builder/Diagnostics/Console/ConsoleDiagnosticsCollector.cs
index 1ac64c0d2..f4747454c 100644
--- a/src/docs-builder/Diagnostics/Console/ConsoleDiagnosticsCollector.cs
+++ b/src/docs-builder/Diagnostics/Console/ConsoleDiagnosticsCollector.cs
@@ -14,8 +14,8 @@ public class ConsoleDiagnosticsCollector(ILoggerFactory loggerFactory, ICoreServ
: DiagnosticsCollector([new Log(loggerFactory.CreateLogger()), new GithubAnnotationOutput(githubActions)]
)
{
- private readonly List _errors = new();
- private readonly List _warnings = new();
+ private readonly List _errors = [];
+ private readonly List _warnings = [];
protected override void HandleItem(Diagnostic diagnostic)
{
@@ -25,7 +25,7 @@ protected override void HandleItem(Diagnostic diagnostic)
_errors.Add(diagnostic);
}
- public override async Task StopAsync(Cancel ctx)
+ public override async Task StopAsync(Cancel cancellationToken)
{
var repository = new ErrataFileSourceRepository();
repository.WriteDiagnosticsToConsole(_errors, _warnings);
diff --git a/src/docs-builder/Diagnostics/Console/ErrataFileSourceRepository.cs b/src/docs-builder/Diagnostics/Console/ErrataFileSourceRepository.cs
index 746aede44..b9d874353 100644
--- a/src/docs-builder/Diagnostics/Console/ErrataFileSourceRepository.cs
+++ b/src/docs-builder/Diagnostics/Console/ErrataFileSourceRepository.cs
@@ -14,6 +14,7 @@ namespace Documentation.Builder.Diagnostics.Console;
public class ErrataFileSourceRepository : ISourceRepository
{
+ [SuppressMessage("Reliability", "CA2012:Use ValueTasks correctly")]
public bool TryGet(string id, [NotNullWhen(true)] out Source? source)
{
using var reader = new Utf8StreamReader(id);
@@ -48,7 +49,7 @@ public void WriteDiagnosticsToConsole(IReadOnlyCollection errors, IR
else
d = d.WithNote(item.File);
- report.AddDiagnostic(d);
+ _ = report.AddDiagnostic(d);
}
// Render the report
diff --git a/src/docs-builder/Diagnostics/LiveMode/LiveModeDiagnosticsCollector.cs b/src/docs-builder/Diagnostics/LiveMode/LiveModeDiagnosticsCollector.cs
index 3cc9e302d..63e5ba851 100644
--- a/src/docs-builder/Diagnostics/LiveMode/LiveModeDiagnosticsCollector.cs
+++ b/src/docs-builder/Diagnostics/LiveMode/LiveModeDiagnosticsCollector.cs
@@ -13,5 +13,5 @@ public class LiveModeDiagnosticsCollector(ILoggerFactory loggerFactory)
{
protected override void HandleItem(Diagnostic diagnostic) { }
- public override async Task StopAsync(Cancel ctx) => await Task.CompletedTask;
+ public override async Task StopAsync(Cancel cancellationToken) => await Task.CompletedTask;
}
diff --git a/src/docs-builder/Diagnostics/Log.cs b/src/docs-builder/Diagnostics/Log.cs
index 5803d2613..8148f3c28 100644
--- a/src/docs-builder/Diagnostics/Log.cs
+++ b/src/docs-builder/Diagnostics/Log.cs
@@ -5,8 +5,7 @@
using Elastic.Markdown.Diagnostics;
using Microsoft.Extensions.Logging;
-// ReSharper disable once CheckNamespace
-namespace Documentation.Builder;
+namespace Documentation.Builder.Diagnostics;
// named Log for terseness on console output
public class Log(ILogger logger) : IDiagnosticsOutput
@@ -14,9 +13,9 @@ public class Log(ILogger logger) : IDiagnosticsOutput
public void Write(Diagnostic diagnostic)
{
if (diagnostic.Severity == Severity.Error)
- logger.LogError($"{diagnostic.Message} ({diagnostic.File}:{diagnostic.Line})");
+ logger.LogError("{Message} ({File}:{Line})", diagnostic.Message, diagnostic.File, diagnostic.Line);
else
- logger.LogWarning($"{diagnostic.Message} ({diagnostic.File}:{diagnostic.Line})");
+ logger.LogWarning("{Message} ({File}:{Line})", diagnostic.Message, diagnostic.File, diagnostic.Line);
}
}
diff --git a/src/docs-builder/Http/DocumentationWebHost.cs b/src/docs-builder/Http/DocumentationWebHost.cs
index 86d3f9977..5b97a0bd3 100644
--- a/src/docs-builder/Http/DocumentationWebHost.cs
+++ b/src/docs-builder/Http/DocumentationWebHost.cs
@@ -29,36 +29,39 @@ public DocumentationWebHost(string? path, int port, ILoggerFactory logger, IFile
{
var builder = WebApplication.CreateSlimBuilder();
- builder.Logging.ClearProviders();
- builder.Logging.SetMinimumLevel(LogLevel.Warning)
+ _ = builder.Logging
+ .ClearProviders()
+ .SetMinimumLevel(LogLevel.Warning)
.AddFilter("Microsoft.AspNetCore.Hosting.Diagnostics", LogLevel.Error)
.AddFilter("Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware", LogLevel.Error)
.AddFilter("Microsoft.Hosting.Lifetime", LogLevel.Information)
-
.AddSimpleConsole(o => o.SingleLine = true);
_context = new BuildContext(fileSystem, fileSystem, path, null)
{
Collector = new LiveModeDiagnosticsCollector(logger)
};
- builder.Services.AddAotLiveReload(s =>
- {
- s.FolderToMonitor = _context.SourcePath.FullName;
- s.ClientFileExtensions = ".md,.yml";
- });
- builder.Services.AddSingleton(_ => new ReloadableGeneratorState(_context.SourcePath, null, _context, logger));
- builder.Services.AddHostedService();
+ _ = builder.Services
+ .AddAotLiveReload(s =>
+ {
+ s.FolderToMonitor = _context.SourcePath.FullName;
+ s.ClientFileExtensions = ".md,.yml";
+ })
+ .AddSingleton(_ =>
+ new ReloadableGeneratorState(_context.SourcePath, null, _context, logger)
+ )
+ .AddHostedService();
+
if (IsDotNetWatchBuild())
- builder.Services.AddHostedService();
+ _ = builder.Services.AddHostedService();
- builder.WebHost.UseUrls($"http://localhost:{port}");
+ _ = builder.WebHost.UseUrls($"http://localhost:{port}");
_webApplication = builder.Build();
SetUpRoutes();
}
- private bool IsDotNetWatchBuild() =>
- Environment.GetEnvironmentVariable("DOTNET_WATCH") is not null;
+ private static bool IsDotNetWatchBuild() => Environment.GetEnvironmentVariable("DOTNET_WATCH") is not null;
public async Task RunAsync(Cancel ctx)
{
@@ -74,18 +77,20 @@ public async Task StopAsync(Cancel ctx)
private void SetUpRoutes()
{
- _webApplication.UseLiveReload();
- _webApplication.UseStaticFiles(new StaticFileOptions
- {
- FileProvider = new EmbeddedOrPhysicalFileProvider(_context),
- RequestPath = "/_static"
- });
- _webApplication.UseRouting();
+ _ = _webApplication
+ .UseLiveReload()
+ .UseStaticFiles(
+ new StaticFileOptions
+ {
+ FileProvider = new EmbeddedOrPhysicalFileProvider(_context),
+ RequestPath = "/_static"
+ })
+ .UseRouting();
- _webApplication.MapGet("/", (ReloadableGeneratorState holder, Cancel ctx) =>
+ _ = _webApplication.MapGet("/", (ReloadableGeneratorState holder, Cancel ctx) =>
ServeDocumentationFile(holder, "index.md", ctx));
- _webApplication.MapGet("{**slug}", (string slug, ReloadableGeneratorState holder, Cancel ctx) =>
+ _ = _webApplication.MapGet("{**slug}", (string slug, ReloadableGeneratorState holder, Cancel ctx) =>
ServeDocumentationFile(holder, slug, ctx));
}
@@ -122,7 +127,7 @@ private static async Task ServeDocumentationFile(ReloadableGeneratorSta
}
-public class EmbeddedOrPhysicalFileProvider : IFileProvider
+public sealed class EmbeddedOrPhysicalFileProvider : IFileProvider, IDisposable
{
private readonly EmbeddedFileProvider _embeddedProvider = new(typeof(BuildContext).Assembly, "Elastic.Markdown._static");
private readonly PhysicalFileProvider? _staticFilesInDocsFolder;
@@ -184,4 +189,10 @@ public IChangeToken Watch(string filter)
changeToken = _embeddedProvider.Watch(filter);
return changeToken;
}
+
+ public void Dispose()
+ {
+ _staticFilesInDocsFolder?.Dispose();
+ _staticWebFilesDuringDebug?.Dispose();
+ }
}
diff --git a/src/docs-builder/Http/LiveReload.cs b/src/docs-builder/Http/LiveReload.cs
index 1650fb45d..d71e62c0b 100644
--- a/src/docs-builder/Http/LiveReload.cs
+++ b/src/docs-builder/Http/LiveReload.cs
@@ -8,7 +8,9 @@
using Microsoft.Extensions.DependencyInjection;
// ReSharper disable once CheckNamespace
+#pragma warning disable IDE0130
namespace Westwind.AspNetCore.LiveReload;
+#pragma warning restore IDE0130
// This exists to disable AOT trimming error messages for the LiveReload middleware's own AddLiveReload() method.
// longer term we should build our own LiveReload middleware that doesn't rely on this also to help reduce dependencies
@@ -35,13 +37,13 @@ public static IServiceCollection AddAotLiveReload(this IServiceCollection servic
var env = provider.GetService();
if (string.IsNullOrEmpty(config.FolderToMonitor))
config.FolderToMonitor = env!.ContentRootPath;
- else if (config.FolderToMonitor.StartsWith("~"))
+ else if (config.FolderToMonitor.StartsWith('~'))
{
if (config.FolderToMonitor.Length > 1)
{
- var folder = config.FolderToMonitor.Substring(1);
- if (folder.StartsWith('/') || folder.StartsWith("\\"))
- folder = folder.Substring(1);
+ var folder = config.FolderToMonitor[1..];
+ if (folder.StartsWith('/') || folder.StartsWith('\\'))
+ folder = folder[1..];
config.FolderToMonitor = Path.Combine(env!.ContentRootPath, folder);
config.FolderToMonitor = Path.GetFullPath(config.FolderToMonitor);
}
diff --git a/src/docs-builder/Http/ParcelWatchService.cs b/src/docs-builder/Http/ParcelWatchService.cs
index d942a50a8..84b84be0a 100644
--- a/src/docs-builder/Http/ParcelWatchService.cs
+++ b/src/docs-builder/Http/ParcelWatchService.cs
@@ -12,7 +12,7 @@ public class ParcelWatchService : IHostedService
{
private Process? _process;
- public Task StartAsync(CancellationToken cancellationToken)
+ public Task StartAsync(Cancel cancellationToken)
{
_process = Process.Start(new ProcessStartInfo
{
@@ -35,7 +35,7 @@ public Task StartAsync(CancellationToken cancellationToken)
return Task.CompletedTask;
}
- public Task StopAsync(CancellationToken cancellationToken)
+ public Task StopAsync(Cancel cancellationToken)
{
_process?.Kill(entireProcessTree: true);
_process?.Kill();
diff --git a/src/docs-builder/Http/ReloadGeneratorService.cs b/src/docs-builder/Http/ReloadGeneratorService.cs
index d1fea4f36..8045e8fec 100644
--- a/src/docs-builder/Http/ReloadGeneratorService.cs
+++ b/src/docs-builder/Http/ReloadGeneratorService.cs
@@ -6,9 +6,10 @@
namespace Documentation.Builder.Http;
-public class ReloadGeneratorService(
+public sealed class ReloadGeneratorService(
ReloadableGeneratorState reloadableGenerator,
- ILogger logger) : IHostedService
+ ILogger logger) : IHostedService,
+ IDisposable
{
private FileSystemWatcher? _watcher;
private ReloadableGeneratorState ReloadableGenerator { get; } = reloadableGenerator;
@@ -17,9 +18,9 @@ public class ReloadGeneratorService(
//debounce reload requests due to many file changes
private readonly Debouncer _debouncer = new(TimeSpan.FromMilliseconds(200));
- public async Task StartAsync(Cancel ctx)
+ public async Task StartAsync(Cancel cancellationToken)
{
- await ReloadableGenerator.ReloadAsync(ctx);
+ await ReloadableGenerator.ReloadAsync(cancellationToken);
var watcher = new FileSystemWatcher(ReloadableGenerator.Generator.DocumentationSet.SourcePath.FullName)
{
@@ -53,7 +54,7 @@ private void Reload() =>
Logger.LogInformation("Reload complete!");
}, default);
- public Task StopAsync(CancellationToken cancellationToken)
+ public Task StopAsync(Cancel cancellationToken)
{
_watcher?.Dispose();
return Task.CompletedTask;
@@ -69,29 +70,28 @@ private void OnChanged(object sender, FileSystemEventArgs e)
if (e.FullPath.EndsWith(".md"))
Reload();
- Logger.LogInformation($"Changed: {e.FullPath}");
+ Logger.LogInformation("Changed: {FullPath}", e.FullPath);
}
private void OnCreated(object sender, FileSystemEventArgs e)
{
- var value = $"Created: {e.FullPath}";
if (e.FullPath.EndsWith(".md"))
Reload();
- Logger.LogInformation(value);
+ Logger.LogInformation("Created: {FullPath}", e.FullPath);
}
private void OnDeleted(object sender, FileSystemEventArgs e)
{
if (e.FullPath.EndsWith(".md"))
Reload();
- Logger.LogInformation($"Deleted: {e.FullPath}");
+ Logger.LogInformation("Deleted: {FullPath}", e.FullPath);
}
private void OnRenamed(object sender, RenamedEventArgs e)
{
- Logger.LogInformation($"Renamed:");
- Logger.LogInformation($" Old: {e.OldFullPath}");
- Logger.LogInformation($" New: {e.FullPath}");
+ Logger.LogInformation("Renamed:");
+ Logger.LogInformation(" Old: {OldFullPath}", e.OldFullPath);
+ Logger.LogInformation(" New: {NewFullPath}", e.FullPath);
if (e.FullPath.EndsWith(".md"))
Reload();
}
@@ -103,19 +103,25 @@ private void PrintException(Exception? ex)
{
if (ex == null)
return;
- Logger.LogError($"Message: {ex.Message}");
+ Logger.LogError("Message: {Message}", ex.Message);
Logger.LogError("Stacktrace:");
- Logger.LogError(ex.StackTrace);
+ Logger.LogError("{StackTrace}", ex.StackTrace ?? "No stack trace available");
PrintException(ex.InnerException);
}
- private class Debouncer(TimeSpan window)
+ public void Dispose()
+ {
+ _watcher?.Dispose();
+ _debouncer.Dispose();
+ }
+
+ private sealed class Debouncer(TimeSpan window) : IDisposable
{
private readonly SemaphoreSlim _semaphore = new(1, 1);
private readonly long _windowInTicks = window.Ticks;
private long _nextRun;
- public async Task ExecuteAsync(Func innerAction, CancellationToken cancellationToken)
+ public async Task ExecuteAsync(Func innerAction, Cancel cancellationToken)
{
var requestStart = DateTime.UtcNow.Ticks;
@@ -132,8 +138,11 @@ public async Task ExecuteAsync(Func innerAction, Cancel
}
finally
{
- _semaphore.Release();
+ _ = _semaphore.Release();
}
}
+
+ public void Dispose() => _semaphore.Dispose();
}
+
}
diff --git a/src/docs-builder/Http/ReloadableGeneratorState.cs b/src/docs-builder/Http/ReloadableGeneratorState.cs
index 0ae1cdb8c..7db472e31 100644
--- a/src/docs-builder/Http/ReloadableGeneratorState.cs
+++ b/src/docs-builder/Http/ReloadableGeneratorState.cs
@@ -30,6 +30,6 @@ public async Task ReloadAsync(Cancel ctx)
var docSet = new DocumentationSet(context, logger);
var generator = new DocumentationGenerator(docSet, logger);
await generator.ResolveDirectoryTree(ctx);
- Interlocked.Exchange(ref _generator, generator);
+ _ = Interlocked.Exchange(ref _generator, generator);
}
}
diff --git a/src/docs-builder/Program.cs b/src/docs-builder/Program.cs
index 5a74ce1e1..021239ec7 100644
--- a/src/docs-builder/Program.cs
+++ b/src/docs-builder/Program.cs
@@ -11,18 +11,17 @@
var services = new ServiceCollection();
services.AddGitHubActionsCore();
-services.AddLogging(x =>
-{
- x.ClearProviders();
- x.SetMinimumLevel(LogLevel.Information);
- x.AddSimpleConsole(c =>
+services.AddLogging(x => x
+ .ClearProviders()
+ .SetMinimumLevel(LogLevel.Information)
+ .AddSimpleConsole(c =>
{
c.SingleLine = true;
c.IncludeScopes = true;
c.UseUtcTimestamp = true;
c.TimestampFormat = Environment.UserInteractive ? ":: " : "[yyyy-MM-ddTHH:mm:ss] ";
- });
-});
+ })
+);
services.AddSingleton();
services.AddSingleton();
diff --git a/tests/Elastic.Markdown.Tests/CodeBlocks/CallOutTests.cs b/tests/Elastic.Markdown.Tests/CodeBlocks/CallOutTests.cs
index 564879e95..d5e87e466 100644
--- a/tests/Elastic.Markdown.Tests/CodeBlocks/CallOutTests.cs
+++ b/tests/Elastic.Markdown.Tests/CodeBlocks/CallOutTests.cs
@@ -63,7 +63,7 @@ public class ClassicCallOutsRequiresContent(ITestOutputHelper output) : CodeBloc
public void ParsesMagicCallOuts() => Block!.CallOuts
.Should().NotBeNullOrEmpty()
.And.HaveCount(2)
- .And.OnlyContain(c => c.Text.StartsWith("<"));
+ .And.OnlyContain(c => c.Text.StartsWith('<'));
[Fact]
public void RequiresContentToFollow() => Collector.Diagnostics.Should().HaveCount(1)
@@ -86,7 +86,7 @@ public class ClassicCallOutsNotFollowedByList(ITestOutputHelper output) : CodeBl
public void ParsesMagicCallOuts() => Block!.CallOuts
.Should().NotBeNullOrEmpty()
.And.HaveCount(2)
- .And.OnlyContain(c => c.Text.StartsWith("<"));
+ .And.OnlyContain(c => c.Text.StartsWith('<'));
[Fact]
public void RequiresContentToFollow() => Collector.Diagnostics.Should().HaveCount(1)
@@ -114,7 +114,7 @@ 2. Marking the second callout
public void ParsesMagicCallOuts() => Block!.CallOuts
.Should().NotBeNullOrEmpty()
.And.HaveCount(2)
- .And.OnlyContain(c => c.Text.StartsWith("<"));
+ .And.OnlyContain(c => c.Text.StartsWith('<'));
[Fact]
public void AllowsAParagraphInBetween() => Collector.Diagnostics.Should().BeEmpty();
@@ -142,7 +142,7 @@ 2. Marking the second callout
public void ParsesMagicCallOuts() => Block!.CallOuts
.Should().NotBeNullOrEmpty()
.And.HaveCount(2)
- .And.OnlyContain(c => c.Text.StartsWith("<"));
+ .And.OnlyContain(c => c.Text.StartsWith('<'));
[Fact]
public void RequiresContentToFollow() => Collector.Diagnostics.Should().HaveCount(1)
@@ -167,7 +167,7 @@ 1. Only marking the first callout
public void ParsesMagicCallOuts() => Block!.CallOuts
.Should().NotBeNullOrEmpty()
.And.HaveCount(2)
- .And.OnlyContain(c => c.Text.StartsWith("<"));
+ .And.OnlyContain(c => c.Text.StartsWith('<'));
[Fact]
public void RequiresContentToFollow() => Collector.Diagnostics.Should().HaveCount(1)
@@ -191,13 +191,13 @@ 2. The second appears twice
public void SeesTwoUniqueCallouts() => Block!.UniqueCallOuts
.Should().NotBeNullOrEmpty()
.And.HaveCount(2)
- .And.OnlyContain(c => c.Text.StartsWith("<"));
+ .And.OnlyContain(c => c.Text.StartsWith('<'));
[Fact]
public void ParsesAllForLineInformation() => Block!.CallOuts
.Should().NotBeNullOrEmpty()
.And.HaveCount(3)
- .And.OnlyContain(c => c.Text.StartsWith("<"));
+ .And.OnlyContain(c => c.Text.StartsWith('<'));
[Fact]
public void RequiresContentToFollow() => Collector.Diagnostics.Should().BeEmpty();
@@ -264,7 +264,7 @@ public void ParsesClassicCallouts()
Block!.CallOuts
.Should().NotBeNullOrEmpty()
.And.HaveCount(9)
- .And.OnlyContain(c => c.Text.StartsWith("<"));
+ .And.OnlyContain(c => c.Text.StartsWith('<'));
Block!.UniqueCallOuts
.Should().NotBeNullOrEmpty()
@@ -291,7 +291,7 @@ 2. Second callout
public void ParsesMagicCallOuts() => Block!.CallOuts
.Should().NotBeNullOrEmpty()
.And.HaveCount(3)
- .And.OnlyContain(c => c.Text.StartsWith("<"));
+ .And.OnlyContain(c => c.Text.StartsWith('<'));
[Fact]
public void HasNoErrors() => Collector.Diagnostics.Should().HaveCount(0);
@@ -316,7 +316,7 @@ 2. Second callout
public void ParsesMagicCallOuts() => Block!.CallOuts
.Should().NotBeNullOrEmpty()
.And.HaveCount(5)
- .And.OnlyContain(c => c.Text.StartsWith("<"));
+ .And.OnlyContain(c => c.Text.StartsWith('<'));
[Fact]
public void HasNoErrors() => Collector.Diagnostics.Should().HaveCount(0);
diff --git a/tests/Elastic.Markdown.Tests/Directives/DirectiveBaseTests.cs b/tests/Elastic.Markdown.Tests/Directives/DirectiveBaseTests.cs
index 4a49046b9..fa8c5e58b 100644
--- a/tests/Elastic.Markdown.Tests/Directives/DirectiveBaseTests.cs
+++ b/tests/Elastic.Markdown.Tests/Directives/DirectiveBaseTests.cs
@@ -43,7 +43,7 @@ protected DirectiveTest(ITestOutputHelper output, [LanguageInjection("markdown")
{
var logger = new TestLoggerFactory(output);
- TestingFullDocument = string.IsNullOrEmpty(content) || content.StartsWith("---");
+ TestingFullDocument = string.IsNullOrEmpty(content) || content.StartsWith("---", StringComparison.OrdinalIgnoreCase);
var documentContents = TestingFullDocument ? content :
// language=markdown
$"""
@@ -86,7 +86,7 @@ public virtual async ValueTask InitializeAsync()
await Set.LinkResolver.FetchLinks();
Document = await File.ParseFullAsync(default);
- var html = File.CreateHtml(Document).AsSpan();
+ var html = MarkdownFile.CreateHtml(Document).AsSpan();
var find = "";
var start = html.IndexOf(find, StringComparison.Ordinal);
Html = start >= 0
@@ -97,6 +97,9 @@ public virtual async ValueTask InitializeAsync()
await Collector.StopAsync(default);
}
- public ValueTask DisposeAsync() => ValueTask.CompletedTask;
-
+ public ValueTask DisposeAsync()
+ {
+ GC.SuppressFinalize(this);
+ return ValueTask.CompletedTask;
+ }
}
diff --git a/tests/Elastic.Markdown.Tests/DocSet/NavigationTestsBase.cs b/tests/Elastic.Markdown.Tests/DocSet/NavigationTestsBase.cs
index bff00ec6c..88316f4c4 100644
--- a/tests/Elastic.Markdown.Tests/DocSet/NavigationTestsBase.cs
+++ b/tests/Elastic.Markdown.Tests/DocSet/NavigationTestsBase.cs
@@ -50,5 +50,9 @@ public async ValueTask InitializeAsync()
Configuration = Generator.DocumentationSet.Configuration;
}
- public ValueTask DisposeAsync() => ValueTask.CompletedTask;
+ public ValueTask DisposeAsync()
+ {
+ GC.SuppressFinalize(this);
+ return ValueTask.CompletedTask;
+ }
}
diff --git a/tests/Elastic.Markdown.Tests/Inline/InlineLinkTests.cs b/tests/Elastic.Markdown.Tests/Inline/InlineLinkTests.cs
index c93f0019f..708cb1b79 100644
--- a/tests/Elastic.Markdown.Tests/Inline/InlineLinkTests.cs
+++ b/tests/Elastic.Markdown.Tests/Inline/InlineLinkTests.cs
@@ -64,10 +64,7 @@ public void GeneratesHtml() =>
public void HasNoErrors() => Collector.Diagnostics.Should().HaveCount(0);
[Fact]
- public void EmitsCrossLink()
- {
- Collector.CrossLinks.Should().HaveCount(0);
- }
+ public void EmitsCrossLink() => Collector.CrossLinks.Should().HaveCount(0);
}
public class InsertPageTitleTests(ITestOutputHelper output) : LinkTestBase(output,
@@ -87,10 +84,7 @@ public void GeneratesHtml() =>
public void HasNoErrors() => Collector.Diagnostics.Should().HaveCount(0);
[Fact]
- public void EmitsCrossLink()
- {
- Collector.CrossLinks.Should().HaveCount(0);
- }
+ public void EmitsCrossLink() => Collector.CrossLinks.Should().HaveCount(0);
}
public class LinkReferenceTest(ITestOutputHelper output) : LinkTestBase(output,
@@ -112,10 +106,7 @@ public void GeneratesHtml() =>
public void HasNoErrors() => Collector.Diagnostics.Should().HaveCount(0);
[Fact]
- public void EmitsCrossLink()
- {
- Collector.CrossLinks.Should().HaveCount(0);
- }
+ public void EmitsCrossLink() => Collector.CrossLinks.Should().HaveCount(0);
}
public class CrossLinkReferenceTest(ITestOutputHelper output) : LinkTestBase(output,
diff --git a/tests/Elastic.Markdown.Tests/Inline/InlneBaseTests.cs b/tests/Elastic.Markdown.Tests/Inline/InlneBaseTests.cs
index 82fe321c6..d131aaab0 100644
--- a/tests/Elastic.Markdown.Tests/Inline/InlneBaseTests.cs
+++ b/tests/Elastic.Markdown.Tests/Inline/InlneBaseTests.cs
@@ -83,7 +83,7 @@ protected InlineTest(
Dictionary? globalVariables = null)
{
var logger = new TestLoggerFactory(output);
- TestingFullDocument = string.IsNullOrEmpty(content) || content.StartsWith("---");
+ TestingFullDocument = string.IsNullOrEmpty(content) || content.StartsWith("---", StringComparison.OrdinalIgnoreCase);
var documentContents = TestingFullDocument ? content :
// language=markdown
@@ -130,7 +130,7 @@ public virtual async ValueTask InitializeAsync()
await Set.LinkResolver.FetchLinks();
Document = await File.ParseFullAsync(default);
- var html = File.CreateHtml(Document).AsSpan();
+ var html = MarkdownFile.CreateHtml(Document).AsSpan();
var find = "\n";
var start = html.IndexOf(find, StringComparison.Ordinal);
Html = start >= 0 && !TestingFullDocument
@@ -140,6 +140,9 @@ public virtual async ValueTask InitializeAsync()
await Collector.StopAsync(default);
}
- public ValueTask DisposeAsync() => ValueTask.CompletedTask;
-
+ public ValueTask DisposeAsync()
+ {
+ GC.SuppressFinalize(this);
+ return ValueTask.CompletedTask;
+ }
}
diff --git a/tests/Elastic.Markdown.Tests/TestCrossLinkResolver.cs b/tests/Elastic.Markdown.Tests/TestCrossLinkResolver.cs
index 988a688da..1781901dd 100644
--- a/tests/Elastic.Markdown.Tests/TestCrossLinkResolver.cs
+++ b/tests/Elastic.Markdown.Tests/TestCrossLinkResolver.cs
@@ -11,11 +11,12 @@ namespace Elastic.Markdown.Tests;
public class TestCrossLinkResolver : ICrossLinkResolver
{
- public Dictionary LinkReferences { get; } = new();
- public HashSet DeclaredRepositories { get; } = new();
+ private Dictionary LinkReferences { get; } = [];
+ private HashSet DeclaredRepositories { get; } = [];
public Task FetchLinks()
{
+ // language=json
var json = """
{
"origin": {
diff --git a/tests/Elastic.Markdown.Tests/TestDiagnosticsCollector.cs b/tests/Elastic.Markdown.Tests/TestDiagnosticsCollector.cs
index 9af4bd32d..820808d23 100644
--- a/tests/Elastic.Markdown.Tests/TestDiagnosticsCollector.cs
+++ b/tests/Elastic.Markdown.Tests/TestDiagnosticsCollector.cs
@@ -20,7 +20,7 @@ public void Write(Diagnostic diagnostic)
public class TestDiagnosticsCollector(ITestOutputHelper output)
: DiagnosticsCollector([new TestDiagnosticsOutput(output)])
{
- private readonly List _diagnostics = new();
+ private readonly List _diagnostics = [];
public IReadOnlyCollection Diagnostics => _diagnostics;
diff --git a/tests/Elastic.Markdown.Tests/TestLogger.cs b/tests/Elastic.Markdown.Tests/TestLogger.cs
index dd3419178..1e69d3565 100644
--- a/tests/Elastic.Markdown.Tests/TestLogger.cs
+++ b/tests/Elastic.Markdown.Tests/TestLogger.cs
@@ -8,7 +8,7 @@ namespace Elastic.Markdown.Tests;
public class TestLogger(ITestOutputHelper output) : ILogger
{
- private class NullScope : IDisposable
+ private sealed class NullScope : IDisposable
{
public void Dispose() { }
}
@@ -23,18 +23,14 @@ public void Log(LogLevel logLevel, EventId eventId, TState state, Except
public class TestLoggerProvider(ITestOutputHelper output) : ILoggerProvider
{
- public void Dispose()
- {
- }
+ public void Dispose() => GC.SuppressFinalize(this);
public ILogger CreateLogger(string categoryName) => new TestLogger(output);
}
public class TestLoggerFactory(ITestOutputHelper output) : ILoggerFactory
{
- public void Dispose()
- {
- }
+ public void Dispose() => GC.SuppressFinalize(this);
public void AddProvider(ILoggerProvider provider) { }
diff --git a/tests/authoring/Applicability/AppliesToDirective.fs b/tests/authoring/Applicability/AppliesToDirective.fs
index 006c1c70c..2d4e76296 100644
--- a/tests/authoring/Applicability/AppliesToDirective.fs
+++ b/tests/authoring/Applicability/AppliesToDirective.fs
@@ -28,9 +28,9 @@ serverless:
directives |> appliesToDirective (ApplicableTo(
Serverless=ServerlessProjectApplicability(
- Security=ApplicabilityOverTime.op_Explicit "ga 9.0.0",
- Elasticsearch=ApplicabilityOverTime.op_Explicit "beta 9.1.0",
- Observability=ApplicabilityOverTime.op_Explicit "discontinued 9.2.0"
+ Security=AppliesCollection.op_Explicit "ga 9.0.0",
+ Elasticsearch=AppliesCollection.op_Explicit "beta 9.1.0",
+ Observability=AppliesCollection.op_Explicit "discontinued 9.2.0"
)
))
@@ -51,9 +51,9 @@ serverless:
directives |> appliesToDirective (ApplicableTo(
Serverless=ServerlessProjectApplicability(
- Security=ApplicabilityOverTime.op_Explicit "ga 9.0.0",
- Elasticsearch=ApplicabilityOverTime.op_Explicit "beta 9.1.0",
- Observability=ApplicabilityOverTime.op_Explicit "discontinued 9.2.0"
+ Security=AppliesCollection.op_Explicit "ga 9.0.0",
+ Elasticsearch=AppliesCollection.op_Explicit "beta 9.1.0",
+ Observability=AppliesCollection.op_Explicit "discontinued 9.2.0"
)
))
diff --git a/tests/authoring/Applicability/AppliesToFrontMatter.fs b/tests/authoring/Applicability/AppliesToFrontMatter.fs
index 87fcb5426..fe7e1b311 100644
--- a/tests/authoring/Applicability/AppliesToFrontMatter.fs
+++ b/tests/authoring/Applicability/AppliesToFrontMatter.fs
@@ -45,7 +45,7 @@ applies_to:
"""
[]
let ``apply matches expected`` () =
- let expectedAvailability = ApplicabilityOverTime.op_Explicit "ga 9.0.0"
+ let expectedAvailability = AppliesCollection.op_Explicit "ga 9.0.0"
markdown |> appliesTo (ApplicableTo(
Serverless=ServerlessProjectApplicability(
Elasticsearch=expectedAvailability,
@@ -66,9 +66,9 @@ applies_to:
let ``apply matches expected`` () =
markdown |> appliesTo (ApplicableTo(
Serverless=ServerlessProjectApplicability(
- Security=ApplicabilityOverTime.op_Explicit "ga 9.0.0",
- Elasticsearch=ApplicabilityOverTime.op_Explicit "beta 9.1.0",
- Observability=ApplicabilityOverTime.op_Explicit "discontinued 9.2.0"
+ Security=AppliesCollection.op_Explicit "ga 9.0.0",
+ Elasticsearch=AppliesCollection.op_Explicit "beta 9.1.0",
+ Observability=AppliesCollection.op_Explicit "discontinued 9.2.0"
)
))
@@ -80,7 +80,7 @@ applies_to:
[]
let ``apply matches expected`` () =
markdown |> appliesTo (ApplicableTo(
- Stack=ApplicabilityOverTime.op_Explicit "ga 9.1.0"
+ Stack=AppliesCollection.op_Explicit "ga 9.1.0"
))
type ``parses deployment as string to set all deployment targets`` () =
@@ -90,7 +90,7 @@ applies_to:
"""
[]
let ``apply matches expected`` () =
- let expectedAvailability = ApplicabilityOverTime.op_Explicit "ga 9.0.0"
+ let expectedAvailability = AppliesCollection.op_Explicit "ga 9.0.0"
markdown |> appliesTo (ApplicableTo(
Deployment=DeploymentApplicability(
Eck=expectedAvailability,
@@ -113,10 +113,10 @@ applies_to:
let ``apply matches expected`` () =
markdown |> appliesTo (ApplicableTo(
Deployment=DeploymentApplicability(
- Eck=ApplicabilityOverTime.op_Explicit "ga 9.0",
- Ess=ApplicabilityOverTime.op_Explicit "beta 9.1",
- Ece=ApplicabilityOverTime.op_Explicit "discontinued 9.2.0",
- Self=ApplicabilityOverTime.op_Explicit "unavailable 9.3.0"
+ Eck=AppliesCollection.op_Explicit "ga 9.0",
+ Ess=AppliesCollection.op_Explicit "beta 9.1",
+ Ece=AppliesCollection.op_Explicit "discontinued 9.2.0",
+ Self=AppliesCollection.op_Explicit "unavailable 9.3.0"
)
))
@@ -128,7 +128,7 @@ applies_to:
[]
let ``apply matches expected`` () =
markdown |> appliesTo (ApplicableTo(
- Product=ApplicabilityOverTime.op_Explicit "coming 9.5.0"
+ Product=AppliesCollection.op_Explicit "coming 9.5.0"
))
type ``parses product multiple`` () =
@@ -139,7 +139,7 @@ applies_to:
[]
let ``apply matches expected`` () =
markdown |> appliesTo (ApplicableTo(
- Product=ApplicabilityOverTime([
+ Product=AppliesCollection([
Applicability.op_Explicit "coming 9.5";
Applicability.op_Explicit "discontinued 9.7"
] |> Array.ofList)
@@ -162,16 +162,16 @@ applies_to:
let ``apply matches expected`` () =
markdown |> appliesTo (ApplicableTo(
Deployment=DeploymentApplicability(
- Eck=ApplicabilityOverTime.op_Explicit "ga 9.0",
- Ess=ApplicabilityOverTime.op_Explicit "beta 9.1",
- Ece=ApplicabilityOverTime.op_Explicit "discontinued 9.2.0",
- Self=ApplicabilityOverTime.op_Explicit "unavailable 9.3.0"
+ Eck=AppliesCollection.op_Explicit "ga 9.0",
+ Ess=AppliesCollection.op_Explicit "beta 9.1",
+ Ece=AppliesCollection.op_Explicit "discontinued 9.2.0",
+ Self=AppliesCollection.op_Explicit "unavailable 9.3.0"
),
Serverless=ServerlessProjectApplicability(
- Security=ApplicabilityOverTime.op_Explicit "ga 9.0.0",
- Elasticsearch=ApplicabilityOverTime.op_Explicit "beta 9.1.0",
- Observability=ApplicabilityOverTime.op_Explicit "discontinued 9.2.0"
+ Security=AppliesCollection.op_Explicit "ga 9.0.0",
+ Elasticsearch=AppliesCollection.op_Explicit "beta 9.1.0",
+ Observability=AppliesCollection.op_Explicit "discontinued 9.2.0"
),
- Stack=ApplicabilityOverTime.op_Explicit "ga 9.1.0",
- Product=ApplicabilityOverTime.op_Explicit "coming 9.5, discontinued 9.7"
+ Stack=AppliesCollection.op_Explicit "ga 9.1.0",
+ Product=AppliesCollection.op_Explicit "coming 9.5, discontinued 9.7"
))
diff --git a/tests/authoring/Framework/TestValues.fs b/tests/authoring/Framework/TestValues.fs
index 6fbd89da9..8399a7f25 100644
--- a/tests/authoring/Framework/TestValues.fs
+++ b/tests/authoring/Framework/TestValues.fs
@@ -91,7 +91,7 @@ and MarkdownTestContext =
// technically we do this work twice since generate all also does it
let! document = f.ParseFullAsync(ctx)
let! minimal = f.MinimalParseAsync(ctx)
- let html = f.CreateHtml(document)
+ let html = MarkdownFile.CreateHtml(document)
return { File = f; Document = document; MinimalParse = minimal; Html = html; Context = this }
})
// this is not great code, refactor or depend on FSharp.Control.TaskSeq