refactor!: fixed missed namespaces

- reformatted code and cleaned up references
This commit is contained in:
D. Moonfire 2023-01-14 18:19:42 -06:00
parent 6a397f5284
commit 9e93eb6ce6
109 changed files with 748 additions and 432 deletions

View File

@ -7,20 +7,20 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\MfGames.Nitride.IO\MfGames.Nitride.IO.csproj" />
<ProjectReference Include="..\..\src\MfGames.Nitride\MfGames.Nitride.csproj" />
<ProjectReference Include="..\..\tests\MfGames.Nitride.Tests\MfGames.Nitride.Tests.csproj" />
<ProjectReference Include="..\..\src\MfGames.Nitride.IO\MfGames.Nitride.IO.csproj"/>
<ProjectReference Include="..\..\src\MfGames.Nitride\MfGames.Nitride.csproj"/>
<ProjectReference Include="..\..\tests\MfGames.Nitride.Tests\MfGames.Nitride.Tests.csproj"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="CliWrap" Version="3.5.0" />
<PackageReference Include="JunitXml.TestLogger" Version="3.0.114" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="CliWrap" Version="3.5.0"/>
<PackageReference Include="JunitXml.TestLogger" Version="3.0.114"/>
<PackageReference Include="xunit" Version="2.4.2"/>
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="MfGames.IO" Version="1.2.7" />
<PackageReference Include="MfGames.IO" Version="1.2.7"/>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>

View File

@ -1,9 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using MfGames.Gallium;
using MfGames.Nitride;
using MfGames.Nitride.IO.Contents;
using MfGames.Nitride.IO.Directories;

View File

@ -4,7 +4,6 @@ using System.Threading.Tasks;
using Autofac;
using MfGames.IO.Extensions;
using MfGames.Nitride;
using MfGames.Nitride.IO;
@ -27,7 +26,8 @@ public static class CopyFilesProgram
// system. At the moment, we set the "root" directory which will
// contains all the paths, both input and output.
DirectoryInfo rootDir =
typeof(CopyFilesProgram).GetDirectory()!.FindGitRoot()!.GetDirectory("examples/CopyFiles");
typeof(CopyFilesProgram).GetDirectory()!.FindGitRoot()!
.GetDirectory("examples/CopyFiles");
builder.WithRootDirectory(rootDir);

View File

@ -4,7 +4,6 @@ using System.Threading.Tasks;
using CliWrap;
using MfGames.IO.Extensions;
using MfGames.Nitride.Tests;
using Xunit;
@ -27,7 +26,8 @@ public class CopyFilesTest : NitrideTestBase
{
// Figure out the paths for this test.
DirectoryInfo rootDir =
typeof(CopyFilesProgram).GetDirectory()!.FindGitRoot()!.GetDirectory("examples/CopyFiles");
typeof(CopyFilesProgram).GetDirectory()!.FindGitRoot()!
.GetDirectory("examples/CopyFiles");
DirectoryInfo outputDir = rootDir.GetDirectory("output");
FileInfo projectFile = rootDir.GetFile("CopyFiles.csproj");

View File

@ -4,12 +4,11 @@ using System.Linq;
using FluentValidation;
using MfGames.Gallium;
using Ical.Net.CalendarComponents;
using Ical.Net.DataTypes;
using Ical.Net.Serialization;
using MfGames.Gallium;
using MfGames.Nitride.Contents;
using MfGames.Nitride.Temporal;
@ -62,12 +61,14 @@ public partial class CreateCalender : OperationBase
this.validator.ValidateAndThrow(this);
SplitEntityEnumerations split = input.SplitEntity<Instant>();
IEnumerable<Entity> datedAndCalendars = this.CreateCalendarEntity(split.HasAll);
IEnumerable<Entity> datedAndCalendars =
this.CreateCalendarEntity(split.HasAll);
return datedAndCalendars.Union(split.NotHasAll);
}
private IEnumerable<Entity> CreateCalendarEntity(IEnumerable<Entity> entities)
private IEnumerable<Entity> CreateCalendarEntity(
IEnumerable<Entity> entities)
{
// Create the calendar in the same time zone as the rest of the system.
var calendar = new Ical.Net.Calendar();
@ -76,7 +77,8 @@ public partial class CreateCalender : OperationBase
// Go through the events and add all of them.
var input = entities.ToList();
IEnumerable<CalendarEvent> events = input.Select(this.CreateCalendarEvent);
IEnumerable<CalendarEvent> events =
input.Select(this.CreateCalendarEvent);
calendar.Events.AddRange(events);

View File

@ -10,16 +10,16 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\MfGames.Nitride.IO\MfGames.Nitride.IO.csproj" />
<ProjectReference Include="..\MfGames.Nitride.Temporal\MfGames.Nitride.Temporal.csproj" />
<ProjectReference Include="..\MfGames.Nitride\MfGames.Nitride.csproj" />
<ProjectReference Include="..\MfGames.Nitride.IO\MfGames.Nitride.IO.csproj"/>
<ProjectReference Include="..\MfGames.Nitride.Temporal\MfGames.Nitride.Temporal.csproj"/>
<ProjectReference Include="..\MfGames.Nitride\MfGames.Nitride.csproj"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="MfGames.Gallium" Version="0.3.0" />
<PackageReference Include="Ical.Net" Version="4.2.0" />
<PackageReference Include="NodaTime" Version="3.1.2" />
<PackageReference Include="Zio" Version="0.15.0" />
<PackageReference Include="MfGames.Gallium" Version="0.3.0"/>
<PackageReference Include="Ical.Net" Version="4.2.0"/>
<PackageReference Include="NodaTime" Version="3.1.2"/>
<PackageReference Include="Zio" Version="0.15.0"/>
</ItemGroup>
<!-- Include the source generator -->

View File

@ -8,7 +8,8 @@ public static class NitrideCalendarBuilderExtensions
{
public static NitrideBuilder UseCalendar(this NitrideBuilder builder)
{
return builder.UseTemporal()
return builder
.UseTemporal()
.ConfigureContainer(x => x.RegisterModule<NitrideCalendarModule>());
}
}

View File

@ -5,7 +5,6 @@ using System.Linq;
using FluentValidation;
using MfGames.Gallium;
using MfGames.Nitride.Contents;
using MfGames.Nitride.Feeds.Structure;

View File

@ -10,15 +10,15 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\MfGames.Nitride.IO\MfGames.Nitride.IO.csproj" />
<ProjectReference Include="..\MfGames.Nitride.Temporal\MfGames.Nitride.Temporal.csproj" />
<ProjectReference Include="..\MfGames.Nitride\MfGames.Nitride.csproj" />
<ProjectReference Include="..\MfGames.Nitride.IO\MfGames.Nitride.IO.csproj"/>
<ProjectReference Include="..\MfGames.Nitride.Temporal\MfGames.Nitride.Temporal.csproj"/>
<ProjectReference Include="..\MfGames.Nitride\MfGames.Nitride.csproj"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="MfGames.Gallium" Version="0.3.0" />
<PackageReference Include="NodaTime" Version="3.1.2" />
<PackageReference Include="Zio" Version="0.15.0" />
<PackageReference Include="MfGames.Gallium" Version="0.3.0"/>
<PackageReference Include="NodaTime" Version="3.1.2"/>
<PackageReference Include="Zio" Version="0.15.0"/>
</ItemGroup>
<!-- Include the source generator -->

View File

@ -29,7 +29,10 @@ public partial class AtomAuthor
if (!string.IsNullOrEmpty(this.Name))
{
author.Add(new XElement(XmlConstants.AtomNamespace + "name", new XText(this.Name)));
author.Add(
new XElement(
XmlConstants.AtomNamespace + "name",
new XText(this.Name)));
}
return author;

View File

@ -36,7 +36,9 @@ public partial class AtomCategory
throw new NullReferenceException("Category term cannot be null.");
}
var elem = new XElement(XmlConstants.AtomNamespace + "category", new XAttribute("term", this.Term));
var elem = new XElement(
XmlConstants.AtomNamespace + "category",
new XAttribute("term", this.Term));
if (this.Scheme != null)
{

View File

@ -24,7 +24,10 @@ public static class AtomHelper
{
if (!string.IsNullOrWhiteSpace(text))
{
elem.Add(new XElement(XmlConstants.AtomNamespace + name, new XText(text)));
elem.Add(
new XElement(
XmlConstants.AtomNamespace + name,
new XText(text)));
}
}
}

View File

@ -10,10 +10,12 @@ public static class XmlConstants
/// <summary>
/// The XML namespace for Atom feeds.
/// </summary>
public static readonly XNamespace AtomNamespace = "http://www.w3.org/2005/Atom";
public static readonly XNamespace AtomNamespace =
"http://www.w3.org/2005/Atom";
/// <summary>
/// The XML namespace for media.
/// </summary>
public static readonly XNamespace MediaNamespace = "http://search.yahoo.com/mrss/";
public static readonly XNamespace MediaNamespace =
"http://search.yahoo.com/mrss/";
}

View File

@ -6,6 +6,7 @@ public static class NitrideGemtextBuilderExtensions
{
public static NitrideBuilder UseGemtext(this NitrideBuilder builder)
{
return builder.ConfigureContainer(x => x.RegisterModule<NitrideGemtextModule>());
return builder.ConfigureContainer(
x => x.RegisterModule<NitrideGemtextModule>());
}
}

View File

@ -38,7 +38,12 @@ public static class CodeAnalysisExtensions
string format,
params object[] parameters)
{
context.Message(messageCode, location, DiagnosticSeverity.Error, format, parameters);
context.Message(
messageCode,
location,
DiagnosticSeverity.Error,
format,
parameters);
}
/// <summary>
@ -72,7 +77,12 @@ public static class CodeAnalysisExtensions
string format,
params object[] parameters)
{
context.Message(messageCode, location, DiagnosticSeverity.Info, format, parameters);
context.Message(
messageCode,
location,
DiagnosticSeverity.Info,
format,
parameters);
}
/// <summary>
@ -106,7 +116,12 @@ public static class CodeAnalysisExtensions
string format,
params object[] parameters)
{
context.Message(messageCode, location, DiagnosticSeverity.Warning, format, parameters);
context.Message(
messageCode,
location,
DiagnosticSeverity.Warning,
format,
parameters);
}
/// <summary>
@ -134,7 +149,10 @@ public static class CodeAnalysisExtensions
severity,
severity,
true,
severity is DiagnosticSeverity.Warning or DiagnosticSeverity.Info ? 4 : 0,
severity is DiagnosticSeverity.Warning
or DiagnosticSeverity.Info
? 4
: 0,
location: location));
}
}

View File

@ -10,10 +10,10 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MfGames.Gallium" Version="0.3.0" />
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.3.1" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.3.1" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.3.1" />
<PackageReference Include="MfGames.Gallium" Version="0.3.0"/>
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.3.1"/>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.3.1"/>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.3.1"/>
</ItemGroup>
</Project>

View File

@ -22,7 +22,8 @@ public class WithPropertySourceGenerator : ISourceGenerator
// Get the generator infrastructure will create a receiver and
// populate it we can retrieve the populated instance via the
// context.
var syntaxReceiver = (WithPropertySyntaxReceiver?)context.SyntaxReceiver;
var syntaxReceiver =
(WithPropertySyntaxReceiver?)context.SyntaxReceiver;
if (syntaxReceiver == null)
{
@ -37,7 +38,9 @@ public class WithPropertySourceGenerator : ISourceGenerator
Location.Create(
"Temporary.g.cs",
TextSpan.FromBounds(0, 0),
new LinePositionSpan(new LinePosition(0, 0), new LinePosition(0, 0))),
new LinePositionSpan(
new LinePosition(0, 0),
new LinePosition(0, 0))),
"Generating additional identifier code: {0}",
message);
}
@ -58,7 +61,8 @@ public class WithPropertySourceGenerator : ISourceGenerator
public void Initialize(GeneratorInitializationContext context)
{
// Register a factory that can create our custom syntax receiver
context.RegisterForSyntaxNotifications(() => new WithPropertySyntaxReceiver(context));
context.RegisterForSyntaxNotifications(
() => new WithPropertySyntaxReceiver(context));
}
private void GenerateClassFile(
@ -96,7 +100,10 @@ public class WithPropertySourceGenerator : ISourceGenerator
foreach (PropertyDeclarationSyntax pds in properties)
{
// See if we have a setter.
bool found = pds.AccessorList?.Accessors.Any(x => x.Keyword.ToString() == "set") ?? false;
bool found =
pds.AccessorList?.Accessors.Any(
x => x.Keyword.ToString() == "set")
?? false;
if (!found)
{
@ -132,7 +139,8 @@ public class WithPropertySourceGenerator : ISourceGenerator
pds.Type));
buffer.AppendLine(" {");
buffer.AppendLine(string.Format(" this.{0} = value;", pds.Identifier));
buffer.AppendLine(
string.Format(" this.{0} = value;", pds.Identifier));
buffer.AppendLine(" return this;");
buffer.AppendLine(" }");
}

View File

@ -3,10 +3,9 @@ using System.Collections.Generic;
using FluentValidation;
using MfGames.Gallium;
using HandlebarsDotNet;
using MfGames.Gallium;
using MfGames.Nitride.Contents;
namespace MfGames.Nitride.Handlebars;
@ -61,7 +60,8 @@ public partial class ApplyStyleTemplate : OperationBase
{
object model = this.CreateModelCallback!(entity);
string name = this.GetTemplateName!(entity);
HandlebarsTemplate<object, object> template = this.cache.GetNamedTemplate(name);
HandlebarsTemplate<object, object> template =
this.cache.GetNamedTemplate(name);
string result = template(model!);
return entity.SetTextContent(result);

View File

@ -23,12 +23,14 @@ public class ForEachHandlebarsBlock<TModel> : HandlebarsBlockBase
/// <summary>
/// Gets or sets the callback that is called when nothing is found.
/// </summary>
public Action<EncodedTextWriter, BlockHelperOptions, Context, Arguments>? NothingFound { get; set; }
public Action<EncodedTextWriter, BlockHelperOptions, Context, Arguments>?
NothingFound { get; set; }
/// <inheritdoc />
protected override string HelperName { get; }
public ForEachHandlebarsBlock<TModel> WithGetList(Func<TModel, IEnumerable<object>>? callback)
public ForEachHandlebarsBlock<TModel> WithGetList(
Func<TModel, IEnumerable<object>>? callback)
{
this.GetList = callback;
@ -36,7 +38,8 @@ public class ForEachHandlebarsBlock<TModel> : HandlebarsBlockBase
}
public ForEachHandlebarsBlock<TModel> WithNothingFoundText(
Action<EncodedTextWriter, BlockHelperOptions, Context, Arguments>? callback)
Action<EncodedTextWriter, BlockHelperOptions, Context, Arguments>?
callback)
{
this.NothingFound = callback;

View File

@ -16,13 +16,15 @@ public class HandlebarsTemplateCache
private readonly ModificationSynchronizer locker;
private readonly Dictionary<string, HandlebarsTemplate<object, object>> templates;
private readonly Dictionary<string, HandlebarsTemplate<object, object>>
templates;
public HandlebarsTemplateCache(IHandlebars handlebars)
{
this.handlebars = handlebars;
this.locker = new ModificationSynchronizer();
this.templates = new Dictionary<string, HandlebarsTemplate<object, object>>();
this.templates =
new Dictionary<string, HandlebarsTemplate<object, object>>();
}
/// <summary>
@ -39,7 +41,8 @@ public class HandlebarsTemplateCache
() => !this.templates.ContainsKey(literal),
() =>
{
HandlebarsTemplate<object, object> template = this.handlebars!.Compile(literal);
HandlebarsTemplate<object, object> template =
this.handlebars!.Compile(literal);
this.templates[literal] = template;
@ -56,7 +59,8 @@ public class HandlebarsTemplateCache
/// </summary>
/// <param name="templateName"></param>
/// <returns></returns>
public HandlebarsTemplate<object, object> GetNamedTemplate(string templateName)
public HandlebarsTemplate<object, object> GetNamedTemplate(
string templateName)
{
string template = $"{{{{> {templateName}}}}}";

View File

@ -17,7 +17,8 @@ public partial class IdentifyHandlebarsFromComponent : IOperation
{
private readonly IValidator<IdentifyHandlebarsFromComponent> validator;
public IdentifyHandlebarsFromComponent(IValidator<IdentifyHandlebarsFromComponent> validator)
public IdentifyHandlebarsFromComponent(
IValidator<IdentifyHandlebarsFromComponent> validator)
{
this.validator = validator;
}
@ -30,6 +31,8 @@ public partial class IdentifyHandlebarsFromComponent : IOperation
this.validator.ValidateAndThrow(this);
return input.Select(
(entity) => this.HasHandlebarsTest.Invoke(entity) ? entity.Set(HasHandlebarsTemplate.Instance) : entity);
(entity) => this.HasHandlebarsTest.Invoke(entity)
? entity.Set(HasHandlebarsTemplate.Instance)
: entity);
}
}

View File

@ -2,7 +2,8 @@ using FluentValidation;
namespace MfGames.Nitride.Handlebars;
public class IdentifyHandlebarsFromComponentValidator : AbstractValidator<IdentifyHandlebarsFromComponent>
public class IdentifyHandlebarsFromComponentValidator
: AbstractValidator<IdentifyHandlebarsFromComponent>
{
public IdentifyHandlebarsFromComponentValidator()
{

View File

@ -1,7 +1,6 @@
using System.Collections.Generic;
using MfGames.Gallium;
using MfGames.Nitride.Contents;
namespace MfGames.Nitride.Handlebars;

View File

@ -10,15 +10,15 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Autofac" Version="6.4.0" />
<PackageReference Include="MfGames.Gallium" Version="0.3.0" />
<PackageReference Include="Handlebars.Net" Version="2.1.2" />
<PackageReference Include="NodaTime.Testing" Version="3.1.2" />
<PackageReference Include="Open.Threading" Version="2.2.1" />
<PackageReference Include="Autofac" Version="6.4.0"/>
<PackageReference Include="MfGames.Gallium" Version="0.3.0"/>
<PackageReference Include="Handlebars.Net" Version="2.1.2"/>
<PackageReference Include="NodaTime.Testing" Version="3.1.2"/>
<PackageReference Include="Open.Threading" Version="2.2.1"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MfGames.Nitride\MfGames.Nitride.csproj" />
<ProjectReference Include="..\MfGames.Nitride\MfGames.Nitride.csproj"/>
</ItemGroup>
<!-- Include the source generator -->

View File

@ -12,7 +12,8 @@ public static class NitrideHandlebarsBuilderExtensions
public static NitrideBuilder UseHandlebars(this NitrideBuilder builder)
{
return builder
.ConfigureContainer(x => x.RegisterModule<NitrideHandlebarsModule>());
.ConfigureContainer(
x => x.RegisterModule<NitrideHandlebarsModule>());
}
public static NitrideBuilder UseHandlebars(

View File

@ -23,8 +23,10 @@ public class NitrideHandlebarsModule : Module
builder.Register(
(context) =>
{
IHandlebars handlebars = HandlebarsDotNet.Handlebars.Create();
IEnumerable<IHandlebarsLoader> helpers = context.Resolve<IEnumerable<IHandlebarsLoader>>();
IHandlebars handlebars =
HandlebarsDotNet.Handlebars.Create();
IEnumerable<IHandlebarsLoader> helpers =
context.Resolve<IEnumerable<IHandlebarsLoader>>();
foreach (IHandlebarsLoader helper in helpers)
{

View File

@ -3,10 +3,9 @@ using System.Collections.Generic;
using FluentValidation;
using MfGames.Gallium;
using HandlebarsDotNet;
using MfGames.Gallium;
using MfGames.Nitride.Contents;
namespace MfGames.Nitride.Handlebars;
@ -43,7 +42,8 @@ public partial class RenderContentTemplate : OperationBase
{
this.validator.ValidateAndThrow(this);
return input.SelectEntity<HasHandlebarsTemplate, ITextContent>(this.Apply);
return input.SelectEntity<HasHandlebarsTemplate, ITextContent>(
this.Apply);
}
private Entity Apply(
@ -52,7 +52,8 @@ public partial class RenderContentTemplate : OperationBase
ITextContent content)
{
string text = content.GetText();
HandlebarsTemplate<object, object> template = this.cache.GetLiteralTemplate(text);
HandlebarsTemplate<object, object> template =
this.cache.GetLiteralTemplate(text);
object model = this.CreateModelCallback!(entity);
string result = template(model!);

View File

@ -2,7 +2,8 @@ using FluentValidation;
namespace MfGames.Nitride.Handlebars;
public class RenderContentTemplateValidator : AbstractValidator<RenderContentTemplate>
public class RenderContentTemplateValidator
: AbstractValidator<RenderContentTemplate>
{
public RenderContentTemplateValidator()
{

View File

@ -2,7 +2,6 @@ using System.Collections.Generic;
using System.Net;
using MfGames.Gallium;
using MfGames.Nitride.Contents;
namespace MfGames.Nitride.Html;

View File

@ -9,7 +9,7 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\MfGames.Nitride\MfGames.Nitride.csproj" />
<ProjectReference Include="..\MfGames.Nitride\MfGames.Nitride.csproj"/>
</ItemGroup>
<!-- Include the source generator -->
@ -25,7 +25,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="MfGames.Gallium" Version="0.3.0" />
<PackageReference Include="MfGames.Gallium" Version="0.3.0"/>
</ItemGroup>
</Project>

View File

@ -6,6 +6,7 @@ public static class NitrideHtmlBuilderExtensions
{
public static NitrideBuilder UseHtml(this NitrideBuilder builder)
{
return builder.ConfigureContainer(x => x.RegisterModule<NitrideHtmlModule>());
return builder.ConfigureContainer(
x => x.RegisterModule<NitrideHtmlModule>());
}
}

View File

@ -22,7 +22,9 @@ public class FileEntryTextContent : ITextContent, IBinaryContentConvertable
/// <inheritdoc />
public TextReader GetReader()
{
return new StreamReader(this.entry.Open(FileMode.Open, FileAccess.Read, FileShare.Read), Encoding.UTF8);
return new StreamReader(
this.entry.Open(FileMode.Open, FileAccess.Read, FileShare.Read),
Encoding.UTF8);
}
/// <inheritdoc />

View File

@ -8,7 +8,6 @@ using DotNet.Globbing;
using FluentValidation;
using MfGames.Gallium;
using MfGames.Nitride.Contents;
using Zio;
@ -59,7 +58,8 @@ public partial class ReadFiles : FileSystemOperationBase
var glob = Glob.Parse(this.Pattern);
IEnumerable<FileEntry> files = this.FileSystem.EnumerateFileEntries("/", "*", SearchOption.AllDirectories)
IEnumerable<FileEntry> files = this.FileSystem
.EnumerateFileEntries("/", "*", SearchOption.AllDirectories)
.Where(x => glob.IsMatch(x.Path.ToString()));
IEnumerable<Entity> entities = files.Select(this.ToEntity);

View File

@ -7,7 +7,6 @@ using System.Text;
using FluentValidation;
using MfGames.Gallium;
using MfGames.Nitride.Contents;
using Serilog;
@ -48,7 +47,8 @@ public partial class WriteFiles : FileSystemOperationBase, IOperation
public Dictionary<Type, Func<IContent, Stream>> StreamFactories
{
get => this.factories;
set => this.factories = value ?? throw new ArgumentNullException(nameof(value));
set => this.factories =
value ?? throw new ArgumentNullException(nameof(value));
}
/// <summary>
@ -102,7 +102,9 @@ public partial class WriteFiles : FileSystemOperationBase, IOperation
.ReadToEnd();
var stream = new MemoryStream();
var writer = new StreamWriter(stream, this.TextEncoding ?? Encoding.UTF8);
var writer = new StreamWriter(
stream,
this.TextEncoding ?? Encoding.UTF8);
writer.Write(text);
writer.Flush();
@ -133,7 +135,9 @@ public partial class WriteFiles : FileSystemOperationBase, IOperation
// First see if we have a factory for the exact type of content.
IContent content = entity.GetContent();
if (this.factories.TryGetValue(content.GetType(), out Func<IContent, Stream>? getStream))
if (this.factories.TryGetValue(
content.GetType(),
out Func<IContent, Stream>? getStream))
{
Stream stream = getStream(content);
@ -143,7 +147,9 @@ public partial class WriteFiles : FileSystemOperationBase, IOperation
// If we have an easy conversion, then use that so we don't have to
// walk up the tree looking for one we do have.
if (content is IBinaryContentConvertable binaryConvertable
&& this.factories.TryGetValue(typeof(IBinaryContent), out Func<IContent, Stream>? binaryContent))
&& this.factories.TryGetValue(
typeof(IBinaryContent),
out Func<IContent, Stream>? binaryContent))
{
Stream stream = binaryContent(binaryConvertable.ToBinaryContent());
@ -151,7 +157,9 @@ public partial class WriteFiles : FileSystemOperationBase, IOperation
}
if (content is ITextContentConvertable textConvertable
&& this.factories.TryGetValue(typeof(ITextContent), out Func<IContent, Stream>? textContent))
&& this.factories.TryGetValue(
typeof(ITextContent),
out Func<IContent, Stream>? textContent))
{
Stream stream = textContent(textConvertable.ToTextContent());
@ -167,7 +175,12 @@ public partial class WriteFiles : FileSystemOperationBase, IOperation
{
// Check to see if we have any of these types.
Func<IContent, Stream>? found = types
.Select(x => this.factories.TryGetValue(x, out Func<IContent, Stream>? factory) ? factory : null)
.Select(
x => this.factories.TryGetValue(
x,
out Func<IContent, Stream>? factory)
? factory
: null)
.FirstOrDefault(x => x != null);
if (found != null)
@ -179,7 +192,8 @@ public partial class WriteFiles : FileSystemOperationBase, IOperation
// We didn't find one, so add all the parent types and try
// again with the new list.
types = types.SelectMany(x => new[] { x.BaseType }.Union(x.GetInterfaces()))
types = types
.SelectMany(x => new[] { x.BaseType }.Union(x.GetInterfaces()))
.Where(x => x != null)
.Select(x => x!)
.ToList();

View File

@ -71,7 +71,8 @@ public partial class ClearDirectory : FileSystemOperationBase, IOperation
// Clear out the contents.
IEnumerable<UPath> files = this.FileSystem.EnumerateFiles(path);
IEnumerable<UPath> directories = this.FileSystem.EnumerateDirectories(path);
IEnumerable<UPath> directories =
this.FileSystem.EnumerateDirectories(path);
foreach (UPath file in files)
{

View File

@ -8,17 +8,17 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Autofac" Version="6.4.0" />
<PackageReference Include="DotNet.Glob" Version="3.1.3" />
<PackageReference Include="FluentValidation" Version="11.2.1" />
<PackageReference Include="MfGames.Gallium" Version="0.3.0" />
<PackageReference Include="MAB.DotIgnore" Version="3.0.2" />
<PackageReference Include="Serilog" Version="2.11.0" />
<PackageReference Include="Zio" Version="0.15.0" />
<PackageReference Include="Autofac" Version="6.4.0"/>
<PackageReference Include="DotNet.Glob" Version="3.1.3"/>
<PackageReference Include="FluentValidation" Version="11.2.1"/>
<PackageReference Include="MfGames.Gallium" Version="0.3.0"/>
<PackageReference Include="MAB.DotIgnore" Version="3.0.2"/>
<PackageReference Include="Serilog" Version="2.11.0"/>
<PackageReference Include="Zio" Version="0.15.0"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MfGames.Nitride\MfGames.Nitride.csproj" />
<ProjectReference Include="..\MfGames.Nitride\MfGames.Nitride.csproj"/>
</ItemGroup>
<!-- Include the source generator -->

View File

@ -6,6 +6,7 @@ public static class NitrideIOBuilderExtensions
{
public static NitrideBuilder UseIO(this NitrideBuilder builder)
{
return builder.ConfigureContainer(x => x.RegisterModule<NitrideIOModule>());
return builder.ConfigureContainer(
x => x.RegisterModule<NitrideIOModule>());
}
}

View File

@ -1,9 +1,9 @@
using System.Collections.Generic;
using MfGames.Gallium;
using MAB.DotIgnore;
using MfGames.Gallium;
using Zio;
namespace MfGames.Nitride.IO;

View File

@ -2,7 +2,8 @@ using FluentValidation;
namespace MfGames.Nitride.IO.Paths;
public class ChangePathExtensionValidator : AbstractValidator<ChangePathExtension>
public class ChangePathExtensionValidator
: AbstractValidator<ChangePathExtension>
{
public ChangePathExtensionValidator()
{

View File

@ -3,7 +3,6 @@ using System.Collections.Generic;
using FluentValidation;
using MfGames.Gallium;
using MfGames.Nitride.Entities;
using Zio;
@ -41,6 +40,8 @@ public partial class DirectChildPathScanner : EntityScanner
// If we are using directory indexes, skip when we have an index root.
// Otherwise, get the parent and use that as the key.
return path.GetDirectoryIndexPath() == "/" ? null : new[] { path.GetParentDirectoryIndexPath() };
return path.GetDirectoryIndexPath() == "/"
? null
: new[] { path.GetParentDirectoryIndexPath() };
}
}

View File

@ -4,7 +4,6 @@ using System.Linq;
using FluentValidation;
using MfGames.Gallium;
using MfGames.Nitride.Entities;
using Serilog;

View File

@ -4,9 +4,9 @@ This assembly contains the primary system for reading and writing from the disk,
along with various processes to manipulate paths. It contains three primary
components:
- File System I/O
- Path Normalization
- Disk-Based Content
- File System I/O
- Path Normalization
- Disk-Based Content
## File System I/O

View File

@ -3,10 +3,9 @@ using System.Collections.Generic;
using FluentValidation;
using MfGames.Gallium;
using Markdig;
using MfGames.Gallium;
using MfGames.Nitride.Contents;
namespace MfGames.Nitride.Markdown;

View File

@ -2,7 +2,8 @@ using FluentValidation;
namespace MfGames.Nitride.Markdown;
public class ConvertMarkdownToBaseValidator : AbstractValidator<ConvertMarkdownToBase>
public class ConvertMarkdownToBaseValidator
: AbstractValidator<ConvertMarkdownToBase>
{
public ConvertMarkdownToBaseValidator()
{

View File

@ -2,12 +2,10 @@ using System;
using FluentValidation;
using MfGames.Gallium;
using Markdig;
using MfGames.Gallium;
using MfGames.Markdown.Gemtext;
using MfGames.Nitride.Contents;
using MfGames.Nitride.Gemtext;
@ -26,7 +24,8 @@ public class ConvertMarkdownToGemtext : ConvertMarkdownToBase
}
/// <inheritdoc />
public override ConvertMarkdownToGemtext WithConfigureMarkdown(Action<MarkdownPipelineBuilder>? value)
public override ConvertMarkdownToGemtext WithConfigureMarkdown(
Action<MarkdownPipelineBuilder>? value)
{
base.WithConfigureMarkdown(value);

View File

@ -2,10 +2,9 @@ using System;
using FluentValidation;
using MfGames.Gallium;
using Markdig;
using MfGames.Gallium;
using MfGames.Nitride.Contents;
using MfGames.Nitride.Html;
@ -23,7 +22,8 @@ public class ConvertMarkdownToHtml : ConvertMarkdownToBase
}
/// <inheritdoc />
public override ConvertMarkdownToHtml WithConfigureMarkdown(Action<MarkdownPipelineBuilder>? value)
public override ConvertMarkdownToHtml WithConfigureMarkdown(
Action<MarkdownPipelineBuilder>? value)
{
base.WithConfigureMarkdown(value);

View File

@ -4,7 +4,6 @@ using System.Collections.Generic;
using FluentValidation;
using MfGames.Gallium;
using MfGames.Nitride.Contents;
using Zio;

View File

@ -18,11 +18,12 @@ public class IdentifyMarkdownFromPath : IdentifyMarkdown
Entity entity,
UPath path)
{
return (path.GetExtensionWithDot() ?? string.Empty).ToLowerInvariant() switch
{
".md" => true,
".markdown" => true,
_ => false,
};
return (path.GetExtensionWithDot() ?? string.Empty).ToLowerInvariant()
switch
{
".md" => true,
".markdown" => true,
_ => false,
};
}
}

View File

@ -85,9 +85,6 @@ public class MakeSingleLinkListItems : IOperation
match =>
{
string link1 = match.Groups["label"].ToString();
string path1 = string.Format(
"/{0}/",
this.slugs.ToSlug(link1.Split('|').First()));
string label1 = link1.Split('|').Last();
return label1;

View File

@ -10,17 +10,17 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\MfGames.Nitride.Gemtext\MfGames.Nitride.Gemtext.csproj" />
<ProjectReference Include="..\MfGames.Nitride.Html\MfGames.Nitride.Html.csproj" />
<ProjectReference Include="..\MfGames.Nitride.Slugs\MfGames.Nitride.Slugs.csproj" />
<ProjectReference Include="..\MfGames.Nitride\MfGames.Nitride.csproj" />
<ProjectReference Include="..\MfGames.Nitride.Gemtext\MfGames.Nitride.Gemtext.csproj"/>
<ProjectReference Include="..\MfGames.Nitride.Html\MfGames.Nitride.Html.csproj"/>
<ProjectReference Include="..\MfGames.Nitride.Slugs\MfGames.Nitride.Slugs.csproj"/>
<ProjectReference Include="..\MfGames.Nitride\MfGames.Nitride.csproj"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="MfGames.Gallium" Version="0.3.0" />
<PackageReference Include="Markdig" Version="0.30.3" />
<PackageReference Include="MfGames.Markdown.Gemtext" Version="1.2.2" />
<PackageReference Include="Zio" Version="0.15.0" />
<PackageReference Include="MfGames.Gallium" Version="0.3.0"/>
<PackageReference Include="Markdig" Version="0.30.3"/>
<PackageReference Include="MfGames.Markdown.Gemtext" Version="1.2.2"/>
<PackageReference Include="Zio" Version="0.15.0"/>
</ItemGroup>
<!-- Include the source generator -->

View File

@ -6,6 +6,7 @@ public static class NitrideMarkdownBuilderExtensions
{
public static NitrideBuilder UseMarkdown(this NitrideBuilder builder)
{
return builder.ConfigureContainer(x => x.RegisterModule<NitrideMarkdownModule>());
return builder.ConfigureContainer(
x => x.RegisterModule<NitrideMarkdownModule>());
}
}

View File

@ -21,7 +21,8 @@ public class SimpleSlugConverter : ISlugConverter, IEnumerable<string>
public SimpleSlugConverter(
IDictionary<string, string> replacements,
StringComparison comparison = StringComparison.InvariantCultureIgnoreCase)
StringComparison comparison =
StringComparison.InvariantCultureIgnoreCase)
: this()
{
foreach (KeyValuePair<string, string> pair in replacements)
@ -44,7 +45,8 @@ public class SimpleSlugConverter : ISlugConverter, IEnumerable<string>
public void Add(
string search,
string replace,
StringComparison comparison = StringComparison.InvariantCultureIgnoreCase)
StringComparison comparison =
StringComparison.InvariantCultureIgnoreCase)
{
this.replacements.Add((search, replace, comparison));
}
@ -62,12 +64,15 @@ public class SimpleSlugConverter : ISlugConverter, IEnumerable<string>
// If we have null or whitespace, we have a problem.
if (string.IsNullOrWhiteSpace(input))
{
throw new ArgumentException("Cannot have a blank or null input", nameof(input));
throw new ArgumentException(
"Cannot have a blank or null input",
nameof(input));
}
// We need to do the replacements before we slugify.
// Perform any additional replacements.
foreach ((string search, string replace, StringComparison comparison) in this.replacements)
foreach ((string search, string replace, StringComparison comparison) in
this.replacements)
{
input = input.Replace(search, replace, comparison);
}

View File

@ -18,7 +18,8 @@ public class UnicodeNormalizingSlugConverter : SimpleSlugConverter
}
/// <inheritdoc />
public UnicodeNormalizingSlugConverter(IDictionary<string, string> replacements)
public UnicodeNormalizingSlugConverter(
IDictionary<string, string> replacements)
: base(replacements)
{
}
@ -29,7 +30,9 @@ public class UnicodeNormalizingSlugConverter : SimpleSlugConverter
// If we have null or whitespace, we have a problem.
if (string.IsNullOrWhiteSpace(input))
{
throw new ArgumentException("Cannot have a blank or null input", nameof(input));
throw new ArgumentException(
"Cannot have a blank or null input",
nameof(input));
}
// Normalize the Unicode objects.
@ -38,7 +41,8 @@ public class UnicodeNormalizingSlugConverter : SimpleSlugConverter
.Where(this.IsNonSpacingMark)
.ToArray();
string normalized = new string(chars).Normalize(NormalizationForm.FormC);
string normalized =
new string(chars).Normalize(NormalizationForm.FormC);
// Return the base implementation.
return base.ToSlug(normalized);

View File

@ -44,14 +44,16 @@ public class DatePipelineCommandOption : IPipelineCommandOption
{
// If we got a date, then use NodaTime's fake clock to set it so
// everything will use that.
var value = (DateTime?)context.ParseResult.GetValueForOption(this.Option);
var value =
(DateTime?)context.ParseResult.GetValueForOption(this.Option);
if (value.HasValue && value.Value != DateTime.MinValue)
{
// We have a date, so we need to create a fake clock that has this
// date for the entire run.
var local = LocalDateTime.FromDateTime(value.Value);
ZonedDateTime zoned = local.InZoneStrictly(this.timekeeper.DateTimeZone);
ZonedDateTime zoned =
local.InZoneStrictly(this.timekeeper.DateTimeZone);
var instant = zoned.ToInstant();
this.timekeeper.Clock = new FakeClock(instant);

View File

@ -32,7 +32,8 @@ public class ExpiresPipelineCommandOption : IPipelineCommandOption
this.Option = new Option<string?>("--expires", () => defaultValue)
{
Description = "Sets the expiration time as time before the current date",
Description =
"Sets the expiration time as time before the current date",
ArgumentHelpName = "TIMESPAN",
};
}
@ -46,7 +47,8 @@ public class ExpiresPipelineCommandOption : IPipelineCommandOption
// If we have a format, then we are going to set one. If the format
// is blank or never, then we are going to treat it as not
// expiring anything.
string? value = (string?)context.ParseResult.GetValueForOption(this.Option);
string? value =
(string?)context.ParseResult.GetValueForOption(this.Option);
if (value != null && value.ToLowerInvariant() != "never")
{
@ -65,7 +67,9 @@ public class ExpiresPipelineCommandOption : IPipelineCommandOption
// Figure out when we are going to be expiring.
Instant when = this.clock.Expiration.Value;
ZonedDateTime dateTime = when.InZone(this.clock.DateTimeZone);
string formatted = dateTime.ToString("yyyy-MM-dd HH:mm:ss x", CultureInfo.CurrentCulture);
string formatted = dateTime.ToString(
"yyyy-MM-dd HH:mm:ss x",
CultureInfo.CurrentCulture);
this.logger.Information("Expiring entries before {When:l}", formatted);
}

View File

@ -10,21 +10,6 @@ using NodaTime;
namespace MfGames.Nitride.Temporal;
public class CreateDateIndexesValidator : AbstractValidator<CreateDateIndexes>
{
public CreateDateIndexesValidator()
{
this.RuleFor(a => a.Timekeeper)
.NotNull();
this.RuleFor(a => a.CreateIndex)
.NotNull();
this.RuleFor(a => a.Formats)
.NotNull();
}
}
/// <summary>
/// Constructs indexes for any arbitrary formatting of date time to allow for
/// nested structures. This takes a list
@ -116,17 +101,24 @@ public partial class CreateDateIndexes : OperationBase, IResolvingOperation
// The new entities are going to always be added, but if the new + seen is <= the threshold, we'll be
// including both of them.
List<Entity>? childEntities = (newEntities.Count + seenEntities.Count) <= this.LessThanEqualCollapse
? pair.Value
: newEntities;
List<Entity>? childEntities =
(newEntities.Count + seenEntities.Count)
<= this.LessThanEqualCollapse
? pair.Value
: newEntities;
// Figure out which child indexes need to be included. If there isn't a list, then return an empty one.
List<Entity>? childIndexes = indexes.TryGetValue(pair.Key, out List<Entity>? list)
? list
: new List<Entity>();
List<Entity>? childIndexes =
indexes.TryGetValue(pair.Key, out List<Entity>? list)
? list
: new List<Entity>();
// Create the index then add it to the output list.
var index = new DateIndex(pair.Key, this.Formats[i], childEntities, childIndexes);
var index = new DateIndex(
pair.Key,
this.Formats[i],
childEntities,
childIndexes);
Entity? indexEntity = this.CreateIndex!(index);
output.Add(indexEntity);
@ -140,7 +132,8 @@ public partial class CreateDateIndexes : OperationBase, IResolvingOperation
Entity? first = pair.Value[0];
string? nextKey = this.Timekeeper.ToDateTime(first.Get<Instant>())
string? nextKey = this.Timekeeper
.ToDateTime(first.Get<Instant>())
.ToString(this.Formats[i + 1]);
if (!indexes.ContainsKey(nextKey))
@ -176,7 +169,7 @@ public partial class CreateDateIndexes : OperationBase, IResolvingOperation
string? formatted = dateTime.ToString(this.Formats[i]);
if (!grouped[i]
.ContainsKey(formatted))
.ContainsKey(formatted))
{
grouped[i][formatted] = new List<Entity>();
}

View File

@ -0,0 +1,18 @@
using FluentValidation;
namespace MfGames.Nitride.Temporal;
public class CreateDateIndexesValidator : AbstractValidator<CreateDateIndexes>
{
public CreateDateIndexesValidator()
{
this.RuleFor(a => a.Timekeeper)
.NotNull();
this.RuleFor(a => a.CreateIndex)
.NotNull();
this.RuleFor(a => a.Formats)
.NotNull();
}
}

View File

@ -2,7 +2,8 @@ using FluentValidation;
namespace MfGames.Nitride.Temporal;
public class FilterOutExpiredInstantValidator : AbstractValidator<FilterOutExpiredInstant>
public class FilterOutExpiredInstantValidator
: AbstractValidator<FilterOutExpiredInstant>
{
public FilterOutExpiredInstantValidator()
{

View File

@ -2,7 +2,8 @@ using FluentValidation;
namespace MfGames.Nitride.Temporal;
public class FilterOutFutureInstantValidator : AbstractValidator<FilterOutFutureInstant>
public class FilterOutFutureInstantValidator
: AbstractValidator<FilterOutFutureInstant>
{
public FilterOutFutureInstantValidator()
{

View File

@ -11,18 +11,18 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Autofac" Version="6.4.0" />
<PackageReference Include="MfGames.Gallium" Version="0.3.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="6.0.0" />
<PackageReference Include="NodaTime" Version="3.1.2" />
<PackageReference Include="NodaTime.Testing" Version="3.1.2" />
<PackageReference Include="Serilog" Version="2.11.0" />
<PackageReference Include="TimeSpanParserUtil" Version="1.2.0" />
<PackageReference Include="Zio" Version="0.15.0" />
<PackageReference Include="Autofac" Version="6.4.0"/>
<PackageReference Include="MfGames.Gallium" Version="0.3.0"/>
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="6.0.0"/>
<PackageReference Include="NodaTime" Version="3.1.2"/>
<PackageReference Include="NodaTime.Testing" Version="3.1.2"/>
<PackageReference Include="Serilog" Version="2.11.0"/>
<PackageReference Include="TimeSpanParserUtil" Version="1.2.0"/>
<PackageReference Include="Zio" Version="0.15.0"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MfGames.Nitride\MfGames.Nitride.csproj" />
<ProjectReference Include="..\MfGames.Nitride\MfGames.Nitride.csproj"/>
</ItemGroup>
<!-- Include the source generator -->

View File

@ -7,8 +7,6 @@ using MfGames.Nitride.Temporal.Cli;
using Serilog;
using Expires = MfGames.Nitride.Temporal.Cli.ExpiresPipelineCommandOption;
namespace MfGames.Nitride.Temporal;
public static class NitrideTemporalBuilderExtensions
@ -40,15 +38,20 @@ public static class NitrideTemporalBuilderExtensions
.As<IPipelineCommandOption>();
}
if (config.AddExpireOptionToCommandLine && config.Expiration != null)
if (config.AddExpireOptionToCommandLine
&& config.Expiration != null)
{
x.Register(
context =>
{
ILogger logger = context.Resolve<ILogger>();
Timekeeper clock = context.Resolve<Timekeeper>();
Timekeeper
clock = context.Resolve<Timekeeper>();
return new Expires(logger, clock, config.Expiration);
return new ExpiresPipelineCommandOption(
logger,
clock,
config.Expiration);
})
.As<IPipelineCommandOption>();
}
@ -65,7 +68,9 @@ public static class NitrideTemporalBuilderExtensions
Timekeeper timekeeper = scope.Resolve<Timekeeper>();
timekeeper.DateTimeZone = config.DateTimeZone;
logger.Verbose("Setting time zone to {Zone:l}", timekeeper.DateTimeZone);
logger.Verbose(
"Setting time zone to {Zone:l}",
timekeeper.DateTimeZone);
});
}

View File

@ -44,7 +44,8 @@ public partial class NitrideTemporalConfiguration
/// such
/// as "500000:00:00.0".
/// </summary>
public NitrideTemporalConfiguration WithExpiresCommandLineOption(TimeSpan? timeSpan)
public NitrideTemporalConfiguration WithExpiresCommandLineOption(
TimeSpan? timeSpan)
{
return this.WithExpiresCommandLineOption(timeSpan?.ToString());
}
@ -54,7 +55,8 @@ public partial class NitrideTemporalConfiguration
/// "XXX" is a format like "5y" or "500000:00:00.0". This is parsed by
/// TimeSpanParser which gives an easy format.
/// </summary>
public NitrideTemporalConfiguration WithExpiresCommandLineOption(string? defaultValue)
public NitrideTemporalConfiguration WithExpiresCommandLineOption(
string? defaultValue)
{
this.AddExpireOptionToCommandLine = defaultValue != null;
this.Expiration = defaultValue;

View File

@ -50,7 +50,8 @@ public class SetInstantFromComponent<TComponent> : OperationBase
/// into an Instant automatically. This can handle DateTime,
/// DateTimeOffset, LocalDate, and Instant. Nulls are skipped.
/// </summary>
public SetInstantFromComponent<TComponent> WithGetDateTimeObject(Func<Entity, TComponent, object?>? callback)
public SetInstantFromComponent<TComponent> WithGetDateTimeObject(
Func<Entity, TComponent, object?>? callback)
{
this.GetDateTimeObject = callback;

View File

@ -2,7 +2,8 @@ using FluentValidation;
namespace MfGames.Nitride.Temporal;
public class SetInstantFromComponentValidator<TComponent> : AbstractValidator<SetInstantFromComponent<TComponent>>
public class SetInstantFromComponentValidator
<TComponent> : AbstractValidator<SetInstantFromComponent<TComponent>>
{
public SetInstantFromComponentValidator()
{

View File

@ -31,7 +31,8 @@ public partial class SetInstantFromPath : OperationBase
{
this.validator = validator;
this.clock = clock;
this.PathRegex = new Regex(@"(?<year>\d{4})[/-](?<month>\d{2})[/-](?<day>\d{2})");
this.PathRegex = new Regex(
@"(?<year>\d{4})[/-](?<month>\d{2})[/-](?<day>\d{2})");
}
/// <summary>

View File

@ -10,12 +10,12 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\MfGames.Nitride\MfGames.Nitride.csproj" />
<ProjectReference Include="..\MfGames.Nitride\MfGames.Nitride.csproj"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="MfGames.Gallium" Version="0.3.0" />
<PackageReference Include="YamlDotNet" Version="12.0.0" />
<PackageReference Include="MfGames.Gallium" Version="0.3.0"/>
<PackageReference Include="YamlDotNet" Version="12.0.0"/>
</ItemGroup>
<!-- Include the source generator -->

View File

@ -6,6 +6,7 @@ public static class NitrideYamlBuilderExtensions
{
public static NitrideBuilder UseYaml(this NitrideBuilder builder)
{
return builder.ConfigureContainer(x => x.RegisterModule<NitrideYamlModule>());
return builder.ConfigureContainer(
x => x.RegisterModule<NitrideYamlModule>());
}
}

View File

@ -1,7 +1,6 @@
using System;
using MfGames.Gallium;
using MfGames.Nitride.Contents;
using YamlDotNet.Serialization;

View File

@ -4,7 +4,6 @@ using System.IO;
using System.Text;
using MfGames.Gallium;
using MfGames.Nitride.Contents;
using YamlDotNet.Serialization;
@ -31,7 +30,8 @@ public class ParseYamlHeader<TModel> : OperationBase
this.RemoveHeader = true;
}
public Func<Entity, string, Exception, ParseYamlHeaderErrorHandling>? EntityError { get; set; }
public Func<Entity, string, Exception, ParseYamlHeaderErrorHandling>?
EntityError { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the header should be removed
@ -43,7 +43,9 @@ public class ParseYamlHeader<TModel> : OperationBase
public override IEnumerable<Entity> Run(IEnumerable<Entity> input)
{
// Set up the YAML parsing.
DeserializerBuilder builder = new DeserializerBuilder().WithNamingConvention(this.namingConvention);
DeserializerBuilder builder =
new DeserializerBuilder().WithNamingConvention(
this.namingConvention);
if (this.ignoreUnmatchedProperties)
{
@ -62,7 +64,8 @@ public class ParseYamlHeader<TModel> : OperationBase
content) => this.Parse(entity, content, deserializer));
}
public ParseYamlHeader<TModel> WithEntityError(Func<Entity, string, Exception, ParseYamlHeaderErrorHandling>? value)
public ParseYamlHeader<TModel> WithEntityError(
Func<Entity, string, Exception, ParseYamlHeaderErrorHandling>? value)
{
this.EntityError = value;
@ -157,7 +160,8 @@ public class ParseYamlHeader<TModel> : OperationBase
}
catch (Exception exception)
{
ParseYamlHeaderErrorHandling disposition = this.EntityError?.Invoke(entity, yaml, exception)
ParseYamlHeaderErrorHandling disposition =
this.EntityError?.Invoke(entity, yaml, exception)
?? ParseYamlHeaderErrorHandling.Throw;
if (disposition == ParseYamlHeaderErrorHandling.Ignore)

View File

@ -49,7 +49,9 @@ public class BuildCommand : Command, ICommandHandler
public async Task<int> InvokeAsync(InvocationContext context)
{
// Process any injected options.
this.logger.Debug("Processing {Count:N0} pipeline options", this.pipelineOptions.Count);
this.logger.Debug(
"Processing {Count:N0} pipeline options",
this.pipelineOptions.Count);
foreach (IPipelineCommandOption? option in this.pipelineOptions)
{

View File

@ -28,7 +28,11 @@ public class FileBinaryContent : IBinaryContent, ITextContentConvertable
/// <inheritdoc />
public Stream GetStream()
{
return File.Open(this.path, FileMode.Open, FileAccess.Read, FileShare.Read);
return File.Open(
this.path,
FileMode.Open,
FileAccess.Read,
FileShare.Read);
}
/// <inheritdoc />

View File

@ -29,7 +29,13 @@ public class FileTextContent : ITextContent, IBinaryContentConvertable
/// <inheritdoc />
public TextReader GetReader()
{
return new StreamReader(File.Open(this.path, FileMode.Open, FileAccess.Read, FileShare.Read), Encoding.UTF8);
return new StreamReader(
File.Open(
this.path,
FileMode.Open,
FileAccess.Read,
FileShare.Read),
Encoding.UTF8);
}
/// <inheritdoc />

View File

@ -41,7 +41,8 @@ public partial class CreateOrUpdateIndex : OperationBase
/// index that has been already created. If this is null, no new indexes
/// will be made.
/// </summary>
public Func<string, IList<Entity>, Entity>? CreateIndex { get; set; } = null!;
public Func<string, IList<Entity>, Entity>? CreateIndex { get; set; } =
null!;
/// <summary>
/// Gets or sets the function to retrieve the key from an existing
@ -58,7 +59,11 @@ public partial class CreateOrUpdateIndex : OperationBase
/// <summary>
/// Updates an existing index entity to include new information.
/// </summary>
public Func<Entity, string, IEnumerable<Entity>, Entity> UpdateIndex { get; set; } = null!;
public Func<Entity, string, IEnumerable<Entity>, Entity> UpdateIndex
{
get;
set;
} = null!;
/// <inheritdoc />
public override IEnumerable<Entity> Run(IEnumerable<Entity> input)
@ -89,7 +94,9 @@ public partial class CreateOrUpdateIndex : OperationBase
{
// This is an existing entity page that needs to be updated.
IEnumerable<Entity> entries =
scanned.TryGetValue(key, out List<Entity>? list) ? list : Array.Empty<Entity>();
scanned.TryGetValue(key, out List<Entity>? list)
? list
: Array.Empty<Entity>();
existing.Add(key);
@ -100,7 +107,8 @@ public partial class CreateOrUpdateIndex : OperationBase
// Once we're done with the list, we need to create the missing indexes.
if (this.CreateIndex != null)
{
foreach (string key in scanned.Keys.Where(key => !existing.Contains(key)))
foreach (string key in scanned.Keys.Where(
key => !existing.Contains(key)))
{
yield return this.CreateIndex(key, scanned[key]);
}

View File

@ -2,7 +2,8 @@ using FluentValidation;
namespace MfGames.Nitride.Entities;
public class CreateOrUpdateIndexValidator : AbstractValidator<CreateOrUpdateIndex>
public class CreateOrUpdateIndexValidator
: AbstractValidator<CreateOrUpdateIndex>
{
public CreateOrUpdateIndexValidator()
{

View File

@ -39,7 +39,8 @@ public partial class EntityScanner : OperationBase
/// Gets or sets a callback function that gets the keys associated with
/// the given entity.
/// </summary>
public Func<Entity, IEnumerable<string>?> GetKeysFromEntity { get; set; } = null!;
public Func<Entity, IEnumerable<string>?> GetKeysFromEntity { get; set; } =
null!;
/// <summary>
/// Gets the list of entities associated with the given key. if the key has not
@ -106,7 +107,8 @@ public partial class EntityScanner : OperationBase
{
// Scan the given entity and see where it needs to be included.
// The entity is added to each of the keys returned by this class.
IEnumerable<string>? keysFromEntity = this.GetKeysFromEntity(entity);
IEnumerable<string>? keysFromEntity =
this.GetKeysFromEntity(entity);
if (keysFromEntity != null)
{

View File

@ -25,11 +25,13 @@ public class EntitySequence
public bool IsFirst => this.Sequence.Count > 0 && this.Index == 0;
public bool IsLast => this.Sequence.Count > 0 && this.Index == this.Sequence.Count - 1;
public bool IsLast => this.Sequence.Count > 0
&& this.Index == this.Sequence.Count - 1;
public Entity? Next => this.HasNext ? this.Sequence[this.Index + 1] : null;
public Entity? Previous => this.HasPrevious ? this.Sequence[this.Index - 1] : null;
public Entity? Previous =>
this.HasPrevious ? this.Sequence[this.Index - 1] : null;
public IReadOnlyList<Entity> Sequence { get; }
}

View File

@ -38,7 +38,11 @@ public partial class LinkEntitySequence : OperationBase, IResolvingOperation
/// <summary>
/// Gets or sets the function used to create the sequence index.
/// </summary>
public Func<IReadOnlyList<Entity>, int, EntitySequence> CreateSequenceIndex { get; set; }
public Func<IReadOnlyList<Entity>, int, EntitySequence> CreateSequenceIndex
{
get;
set;
}
/// <inheritdoc />
public override IEnumerable<Entity> Run(IEnumerable<Entity> input)
@ -56,7 +60,9 @@ public partial class LinkEntitySequence : OperationBase, IResolvingOperation
for (int i = 0; i < list.Count; i++)
{
Entity entity = list[i];
EntitySequence index = this.CreateSequenceIndex(list.AsReadOnly(), i);
EntitySequence index = this.CreateSequenceIndex(
list.AsReadOnly(),
i);
yield return this.AddSequenceIndex(entity, index);
}

View File

@ -10,12 +10,14 @@ namespace MfGames.Nitride;
/// </summary>
public static class ExpressionHelper
{
public static string GetMemberName<T>(Expression<Func<T, object?>> expression)
public static string GetMemberName<T>(
Expression<Func<T, object?>> expression)
{
return GetMemberName(expression.Body);
}
public static IEnumerable<string> GetMemberNames<T>(params Expression<Func<T, object?>>[] expressions)
public static IEnumerable<string> GetMemberNames<T>(
params Expression<Func<T, object?>>[] expressions)
{
return expressions.Select(x => GetMemberName(x.Body));
}
@ -54,7 +56,8 @@ public static class ExpressionHelper
private static string GetMemberName(UnaryExpression unaryExpression)
{
if (unaryExpression.Operand is MethodCallExpression methodCallExpression)
if (unaryExpression.Operand is MethodCallExpression
methodCallExpression)
{
return methodCallExpression.Method.Name;
}

View File

@ -15,22 +15,22 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Autofac" Version="6.4.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="FluentValidation" Version="11.2.1" />
<PackageReference Include="MfGames.Gallium" Version="0.3.0" />
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
<PackageReference Include="MfGames.ToolBuilder" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="6.0.0" />
<PackageReference Include="Serilog" Version="2.11.0" />
<PackageReference Include="Serilog.Extensions.Autofac.DependencyInjection" Version="5.0.0" />
<PackageReference Include="Serilog.Extensions.Hosting" Version="5.0.1" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
<PackageReference Include="SerilogAnalyzer" Version="0.15.0" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
<PackageReference Include="Zio" Version="0.15.0" />
<PackageReference Include="Autofac" Version="6.4.0"/>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="8.0.0"/>
<PackageReference Include="FluentValidation" Version="11.2.1"/>
<PackageReference Include="MfGames.Gallium" Version="0.3.0"/>
<PackageReference Include="Humanizer.Core" Version="2.14.1"/>
<PackageReference Include="MfGames.ToolBuilder" Version="1.0.0"/>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1"/>
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="6.0.0"/>
<PackageReference Include="Serilog" Version="2.11.0"/>
<PackageReference Include="Serilog.Extensions.Autofac.DependencyInjection" Version="5.0.0"/>
<PackageReference Include="Serilog.Extensions.Hosting" Version="5.0.1"/>
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0"/>
<PackageReference Include="SerilogAnalyzer" Version="0.15.0"/>
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1"/>
<PackageReference Include="System.Linq.Async" Version="6.0.1"/>
<PackageReference Include="Zio" Version="0.15.0"/>
</ItemGroup>
<!-- Include the source generator -->

View File

@ -32,14 +32,16 @@ public class NitrideBuilder
/// An event that is called after the container is built but before
/// the application runs.
/// </summary>
private readonly List<Action<NitrideBuilder, ILifetimeScope>> configureSiteCallbacks;
private readonly List<Action<NitrideBuilder, ILifetimeScope>>
configureSiteCallbacks;
private readonly NitrideModule nitrideModule;
public NitrideBuilder(string[] arguments)
{
this.arguments = arguments;
this.configureSiteCallbacks = new List<Action<NitrideBuilder, ILifetimeScope>>();
this.configureSiteCallbacks =
new List<Action<NitrideBuilder, ILifetimeScope>>();
this.configureContainerCallbacks = new List<Action<ContainerBuilder>>();
this.nitrideModule = new NitrideModule();
@ -74,7 +76,8 @@ public class NitrideBuilder
/// </summary>
/// <param name="callback">The callback to register.</param>
/// <returns>The builder for chaining.</returns>
public NitrideBuilder ConfigureSite(Action<NitrideBuilder, ILifetimeScope> callback)
public NitrideBuilder ConfigureSite(
Action<NitrideBuilder, ILifetimeScope> callback)
{
this.configureSiteCallbacks.Add(callback);
@ -173,12 +176,14 @@ public class NitrideBuilder
this.RegisterRootDirectory(Log.Logger, builder);
// Finish up the registration by running our events.
foreach (Action<NitrideBuilder, ILifetimeScope>? callback in this.configureSiteCallbacks)
foreach (Action<NitrideBuilder, ILifetimeScope>? callback in this
.configureSiteCallbacks)
{
builder.RegisterBuildCallback(scope => callback(this, scope));
}
foreach (Action<ContainerBuilder>? configureContainer in this.configureContainerCallbacks)
foreach (Action<ContainerBuilder>? configureContainer in this
.configureContainerCallbacks)
{
configureContainer.Invoke(builder);
}
@ -195,10 +200,14 @@ public class NitrideBuilder
return;
}
logger.Debug("Setting root directory to {Path}", this.RootDirectory.FullName);
logger.Debug(
"Setting root directory to {Path}",
this.RootDirectory.FullName);
var rootFileSystem = new PhysicalFileSystem();
var subFileSystem = new SubFileSystem(rootFileSystem, this.RootDirectory.FullName);
var subFileSystem = new SubFileSystem(
rootFileSystem,
this.RootDirectory.FullName);
builder.RegisterInstance(subFileSystem)
.As<IFileSystem>()

View File

@ -59,7 +59,8 @@ public class NitrideModule : Module
;
// Add in the commands.
IEnumerable<Command> commands = c.Resolve<IEnumerable<Command>>();
IEnumerable<Command> commands =
c.Resolve<IEnumerable<Command>>();
foreach (Command command in commands)
{

View File

@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using MfGames.Gallium;

View File

@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using MfGames.Gallium;
@ -31,7 +30,8 @@ public abstract class PipelineBase : IPipeline
}
/// <inheritdoc />
public abstract IAsyncEnumerable<Entity> RunAsync(IEnumerable<Entity> entities);
public abstract IAsyncEnumerable<Entity> RunAsync(
IEnumerable<Entity> entities);
/// <inheritdoc />
public override string ToString()

View File

@ -40,7 +40,8 @@ public class PipelineManager
public ICollection<IPipeline> Pipelines
{
get => this.pipelines;
set => this.pipelines = value ?? throw new ArgumentNullException(nameof(value));
set => this.pipelines =
value ?? throw new ArgumentNullException(nameof(value));
}
/// <summary>
@ -60,9 +61,12 @@ public class PipelineManager
// Go through all the entries and start each one. We gather the
// resulting tasks and then wait for all of them to end.
this.logger.Verbose("Starting {Count:l}", "pipeline".ToQuantity(this.pipelines.Count));
this.logger.Verbose(
"Starting {Count:l}",
"pipeline".ToQuantity(this.pipelines.Count));
Task[] tasks = this.entries.Select(x => Task.Run(async () => await x.RunAsync()))
Task[] tasks = this.entries
.Select(x => Task.Run(async () => await x.RunAsync()))
.ToArray();
var report = TimeSpan.FromSeconds(15);
@ -72,13 +76,17 @@ public class PipelineManager
var waiting = this.entries.Where(x => !x.IsFinished)
.ToList();
this.logger.Debug("Waiting for {Count:l} to finish running", "pipeline".ToQuantity(waiting.Count));
this.logger.Debug(
"Waiting for {Count:l} to finish running",
"pipeline".ToQuantity(waiting.Count));
IOrderedEnumerable<IGrouping<PipelineRunnerState, PipelineRunner>> states =
waiting.GroupBy(x => x.State, x => x)
.OrderBy(x => (int)x.Key);
IOrderedEnumerable<IGrouping<PipelineRunnerState, PipelineRunner>>
states =
waiting.GroupBy(x => x.State, x => x)
.OrderBy(x => (int)x.Key);
foreach (IGrouping<PipelineRunnerState, PipelineRunner>? state in states)
foreach (IGrouping<PipelineRunnerState, PipelineRunner>? state in
states)
{
var statePipelines = state.OrderBy(x => x.Pipeline.ToString())
.ToList();
@ -90,15 +98,20 @@ public class PipelineManager
string.Join(
", ",
state.Key == PipelineRunnerState.Started
? statePipelines.Select(x => $"{x.Pipeline} ({x.ElapsedFromState})")
: statePipelines.Select(x => x.Pipeline.ToString())));
? statePipelines.Select(
x => $"{x.Pipeline} ({x.ElapsedFromState})")
: statePipelines.Select(
x => x.Pipeline.ToString())));
}
}
// Figure out our return code.
bool hasErrors = this.entries.Any(x => x.State == PipelineRunnerState.Errored);
bool hasErrors =
this.entries.Any(x => x.State == PipelineRunnerState.Errored);
this.logger.Information("Completed in {Elapsed}", DateTime.UtcNow - started);
this.logger.Information(
"Completed in {Elapsed}",
DateTime.UtcNow - started);
return Task.FromResult(hasErrors ? 2 : 0);
}
@ -119,12 +132,15 @@ public class PipelineManager
if (this.pipelines.Count == 0)
{
this.logger.Error(
"There are no registered pipelines run, use" + " ConfigureContainer to include IPipeline instances");
"There are no registered pipelines run, use"
+ " ConfigureContainer to include IPipeline instances");
return false;
}
this.logger.Verbose("Setting up {Count:l}", "pipeline".ToQuantity(this.pipelines.Count));
this.logger.Verbose(
"Setting up {Count:l}",
"pipeline".ToQuantity(this.pipelines.Count));
// Wrap all the pipelines into entries. We do this before the next
// step so we can have the entries depend on the entries.
@ -140,7 +156,8 @@ public class PipelineManager
foreach (IPipeline? dependency in dependencies)
{
// Get the entry for the dependency.
PipelineRunner dependencyPipeline = this.entries.Single(x => x.Pipeline == dependency);
PipelineRunner dependencyPipeline =
this.entries.Single(x => x.Pipeline == dependency);
// Set up the bi-directional connection.
entry.Incoming.Add(dependencyPipeline);

View File

@ -4,10 +4,10 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using MfGames.Gallium;
using Humanizer;
using MfGames.Gallium;
using Serilog;
namespace MfGames.Nitride.Pipelines;
@ -50,7 +50,8 @@ public class PipelineRunner
ILogger logger,
IPipeline pipeline)
{
this.Pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline));
this.Pipeline =
pipeline ?? throw new ArgumentNullException(nameof(pipeline));
this.Incoming = new List<PipelineRunner>();
this.Outgoing = new List<PipelineRunner>();
this.Outputs = new List<Entity>();
@ -84,7 +85,8 @@ public class PipelineRunner
/// <summary>
/// Gets a value indicating whether this pipeline is done running.
/// </summary>
public bool IsFinished => this.State is PipelineRunnerState.Finalized or PipelineRunnerState.Errored;
public bool IsFinished => this.State is PipelineRunnerState.Finalized
or PipelineRunnerState.Errored;
/// <summary>
/// Gets a value indicating whether this entry is a starting one
@ -123,7 +125,10 @@ public class PipelineRunner
{
int current = Interlocked.Decrement(ref this.waitingOnConsumers);
this.logger.Verbose("{Pipeline:l}: Consumer signalled, waiting for {Count:n0}", this.Pipeline, current);
this.logger.Verbose(
"{Pipeline:l}: Consumer signalled, waiting for {Count:n0}",
this.Pipeline,
current);
if (current == 0)
{
@ -205,7 +210,10 @@ public class PipelineRunner
catch (Exception exception)
{
// Report the exception.
this.logger.Error(exception, "{Pipeline:l}: There was an exception running pipeline", this.Pipeline);
this.logger.Error(
exception,
"{Pipeline:l}: There was an exception running pipeline",
this.Pipeline);
// Change our state and then release any pipeline waiting for us
// so they can pick up the error and fail themselves.
@ -287,7 +295,9 @@ public class PipelineRunner
}
// Make sure our internal wait for the consumers it set.
this.logger.Verbose("{Pipeline:l}: Setting up internal thread controls", this.Pipeline);
this.logger.Verbose(
"{Pipeline:l}: Setting up internal thread controls",
this.Pipeline);
this.waitingOnConsumers = this.Outgoing.Count;
this.consumersDone.Reset();
@ -300,7 +310,9 @@ public class PipelineRunner
// Release our manual reset to allow operations to continue.
this.ChangeState(PipelineRunnerState.Providing);
this.logger.Verbose("{Pipeline:l}: Release manual reset for consumers", this.Pipeline);
this.logger.Verbose(
"{Pipeline:l}: Release manual reset for consumers",
this.Pipeline);
this.blockDependencies.Set();
// Wait until all consumers have finished processing.
@ -316,7 +328,10 @@ public class PipelineRunner
this.signaledDoneWithInputs = true;
this.logger.Debug("{Pipeline:l}: Signaling {Count:n0} dependencies done", this.Pipeline, this.Incoming.Count);
this.logger.Debug(
"{Pipeline:l}: Signaling {Count:n0} dependencies done",
this.Pipeline,
this.Incoming.Count);
foreach (PipelineRunner? dependency in this.Incoming)
{
@ -346,14 +361,17 @@ public class PipelineRunner
// Check for any error state in the dependency, if we have one,
// then we need to stop ourselves.
bool hasError = this.Incoming.Any(x => x.State == PipelineRunnerState.Errored);
bool hasError =
this.Incoming.Any(x => x.State == PipelineRunnerState.Errored);
if (!hasError)
{
return false;
}
this.logger.Error("{Pipeline:l}: There was an exception in an dependency", this.Pipeline);
this.logger.Error(
"{Pipeline:l}: There was an exception in an dependency",
this.Pipeline);
this.ChangeState(PipelineRunnerState.Errored);
this.blockDependencies.Set();

View File

@ -16,7 +16,7 @@ A pipeline implements the `IPipeline` interface or extends the convenience
class `Pipeline`.
```c#
using Nitride.Pipelines;
using MfGames.Nitride.Pipelines;
public class LoadFilesPipeline : Pipeline {}
```

View File

@ -2,8 +2,8 @@
## Immediate
- Switch the various operations to be async
- ReadFiles
- WriteFiles
- Implement mime type determination
- Implement a convert to text content based on mime type
- Switch the various operations to be async
- ReadFiles
- WriteFiles
- Implement mime type determination
- Implement a convert to text content based on mime type

View File

@ -6,22 +6,22 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\MfGames.Nitride.IO\MfGames.Nitride.IO.csproj" />
<ProjectReference Include="..\MfGames.Nitride.Tests\MfGames.Nitride.Tests.csproj" />
<ProjectReference Include="..\..\src\MfGames.Nitride.IO\MfGames.Nitride.IO.csproj"/>
<ProjectReference Include="..\MfGames.Nitride.Tests\MfGames.Nitride.Tests.csproj"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="CompareNETObjects" Version="4.78.0" />
<PackageReference Include="MfGames.Gallium" Version="0.3.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1" />
<PackageReference Include="JunitXml.TestLogger" Version="3.0.114" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="CompareNETObjects" Version="4.78.0"/>
<PackageReference Include="MfGames.Gallium" Version="0.3.0"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1"/>
<PackageReference Include="JunitXml.TestLogger" Version="3.0.114"/>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1"/>
<PackageReference Include="xunit" Version="2.4.2"/>
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Zio" Version="0.15.0" />
<PackageReference Include="Zio" Version="0.15.0"/>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>

View File

@ -8,7 +8,7 @@ using Xunit.Abstractions;
using Zio;
namespace MfGames.Nitride.IO.Tests;
namespace MfGames.Nitride.IO.Tests.Paths;
public class AddPathPrefixTest : NitrideIOTestBase
{
@ -36,9 +36,10 @@ public class AddPathPrefixTest : NitrideIOTestBase
.WithPathPrefix("/prefix");
// Read and replace the paths.
IOrderedEnumerable<string> output = readFiles.WithPattern("/**")
.Run()
.Run(op)
IOrderedEnumerable<string> output = NitrideOperationExtensions.Run(
readFiles.WithPattern("/**")
.Run(),
op)
.Select(
x => x.Get<UPath>()
.ToString())

View File

@ -10,7 +10,7 @@ using Xunit.Abstractions;
using Zio;
namespace MfGames.Nitride.IO.Tests;
namespace MfGames.Nitride.IO.Tests.Paths;
public class DirectChildPathScannerTests : NitrideIOTestBase
{
@ -45,9 +45,10 @@ public class DirectChildPathScannerTests : NitrideIOTestBase
DirectChildPathScanner op = context.Resolve<DirectChildPathScanner>();
// Read and replace the paths.
var _ = readFiles.WithPattern("/**")
.Run()
.Run(op)
var _ = NitrideOperationExtensions.Run(
readFiles.WithPattern("/**")
.Run(),
op)
.ToList();
KeyValuePair<string, string[]>[] actual = op.GetScannedResults()
@ -64,9 +65,15 @@ public class DirectChildPathScannerTests : NitrideIOTestBase
// Verify the results.
KeyValuePair<string, string[]>[] expected = new[]
{
new KeyValuePair<string, string[]>("/", new[] { "/a/index.md", "/b/index.md" }),
new KeyValuePair<string, string[]>("/a/", new[] { "/a/c/index.md", "/a/d/index.md" }),
new KeyValuePair<string, string[]>("/a/d/", new[] { "/a/d/e/index.md" }),
new KeyValuePair<string, string[]>(
"/",
new[] { "/a/index.md", "/b/index.md" }),
new KeyValuePair<string, string[]>(
"/a/",
new[] { "/a/c/index.md", "/a/d/index.md" }),
new KeyValuePair<string, string[]>(
"/a/d/",
new[] { "/a/d/e/index.md" }),
};
TestHelper.CompareObjects(expected, actual);

View File

@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using MfGames.Gallium;
using MfGames.Nitride.IO.Contents;
using Xunit;
@ -9,7 +9,7 @@ using Xunit.Abstractions;
using Zio;
namespace MfGames.Nitride.IO.Tests;
namespace MfGames.Nitride.IO.Tests.Paths;
public class GetEntityByPathTests : NitrideIOTestBase
{
@ -34,9 +34,12 @@ public class GetEntityByPathTests : NitrideIOTestBase
ReadFiles readFiles = context.Resolve<ReadFiles>();
// Read and replace the paths.
IOrderedEnumerable<string> output = readFiles.WithPattern("/**")
.Run()
.GetEntityByPath("/c1.md", out Entity? found)
IOrderedEnumerable<string> output = NitrideIOEnumerableEntityExtensions
.GetEntityByPath(
readFiles.WithPattern("/**")
.Run(),
"/c1.md",
out Entity? found)
.Select(
x => x.Get<UPath>()
.ToString())
@ -70,9 +73,13 @@ public class GetEntityByPathTests : NitrideIOTestBase
ReadFiles readFiles = context.Resolve<ReadFiles>();
// Read and replace the paths.
IOrderedEnumerable<string> output = readFiles.WithPattern("/**")
.Run()
.GetEntityByPath("/c1.md", out Entity? found, IfFoundOutput.ReturnInOutput)
IOrderedEnumerable<string> output = NitrideIOEnumerableEntityExtensions
.GetEntityByPath(
(IEnumerable<Entity>)readFiles.WithPattern("/**")
.Run(),
(UPath)"/c1.md",
out Entity? found,
(IfFoundOutput)IfFoundOutput.ReturnInOutput)
.Select(
x => x.Get<UPath>()
.ToString())
@ -107,9 +114,12 @@ public class GetEntityByPathTests : NitrideIOTestBase
ReadFiles readFiles = context.Resolve<ReadFiles>();
// Read and replace the paths.
IOrderedEnumerable<string> output = readFiles.WithPattern("/**")
.Run()
.GetEntityByPath("/not-found.md", out Entity? found)
IOrderedEnumerable<string> output = NitrideIOEnumerableEntityExtensions
.GetEntityByPath(
readFiles.WithPattern("/**")
.Run(),
"/not-found.md",
out Entity? found)
.Select(
x => x.Get<UPath>()
.ToString())

View File

@ -11,7 +11,7 @@ using Xunit.Abstractions;
using Zio;
namespace MfGames.Nitride.IO.Tests;
namespace MfGames.Nitride.IO.Tests.Paths;
public class LinkDirectChildrenTests : NitrideIOTestBase
{
@ -43,15 +43,17 @@ public class LinkDirectChildrenTests : NitrideIOTestBase
// Set up the operation.
ReadFiles readFiles = context.Resolve<ReadFiles>();
DirectChildPathScanner scanner = context.Resolve<DirectChildPathScanner>();
DirectChildPathScanner scanner =
context.Resolve<DirectChildPathScanner>();
CreateOrUpdateIndex op = context.Resolve<LinkDirectChildren>()
.WithScanner(scanner);
// Read and replace the paths.
Tuple<string, string[]?>[]? actual = readFiles.WithPattern("/**")
.Run()
.Run(scanner)
Tuple<string, string[]?>[]? actual = NitrideOperationExtensions.Run(
readFiles.WithPattern("/**")
.Run(),
scanner)
.ToList()
.Run(op)
.Select(
@ -72,10 +74,16 @@ public class LinkDirectChildrenTests : NitrideIOTestBase
{
new Tuple<string, string[]?>("/a/c/index.md", new string[] { }),
new Tuple<string, string[]?>("/a/d/e/index.md", new string[] { }),
new Tuple<string, string[]?>("/a/d/index.md", new[] { "/a/d/e/index.md" }),
new Tuple<string, string[]?>("/a/index.md", new[] { "/a/c/index.md", "/a/d/index.md" }),
new Tuple<string, string[]?>(
"/a/d/index.md",
new[] { "/a/d/e/index.md" }),
new Tuple<string, string[]?>(
"/a/index.md",
new[] { "/a/c/index.md", "/a/d/index.md" }),
new Tuple<string, string[]?>("/b/index.md", new string[] { }),
new Tuple<string, string[]?>("/index.md", new[] { "/a/index.md", "/b/index.md" }),
new Tuple<string, string[]?>(
"/index.md",
new[] { "/a/index.md", "/b/index.md" }),
};
TestHelper.CompareObjects(expected, actual);

View File

@ -8,7 +8,7 @@ using Xunit.Abstractions;
using Zio;
namespace MfGames.Nitride.IO.Tests;
namespace MfGames.Nitride.IO.Tests.Paths;
public class MoveToIndexPathsTest : NitrideIOTestBase
{
@ -30,9 +30,10 @@ public class MoveToIndexPathsTest : NitrideIOTestBase
MoveToIndexPath op = context.Resolve<MoveToIndexPath>();
// Read and replace the paths.
IOrderedEnumerable<string> output = readFiles.WithPattern("/**")
.Run()
.Run(op)
IOrderedEnumerable<string> output = NitrideOperationExtensions.Run(
readFiles.WithPattern("/**")
.Run(),
op)
.Select(
x => x.Get<UPath>()
.ToString())
@ -67,9 +68,10 @@ public class MoveToIndexPathsTest : NitrideIOTestBase
.Contains("a1"));
// Read and replace the paths.
IOrderedEnumerable<string> output = readFiles.WithPattern("/**")
.Run()
.Run(op)
IOrderedEnumerable<string> output = NitrideOperationExtensions.Run(
readFiles.WithPattern("/**")
.Run(),
op)
.Select(
x => x.Get<UPath>()
.ToString())

View File

@ -8,7 +8,7 @@ using Xunit.Abstractions;
using Zio;
namespace MfGames.Nitride.IO.Tests;
namespace MfGames.Nitride.IO.Tests.Paths;
public class RemovePathPrefixTest : NitrideIOTestBase
{
@ -38,9 +38,10 @@ public class RemovePathPrefixTest : NitrideIOTestBase
.WithPathPrefix("/a");
// Read and replace the paths.
IOrderedEnumerable<string> output = readFiles.WithPattern("/**")
.Run()
.Run(op)
IOrderedEnumerable<string> output = NitrideOperationExtensions.Run(
readFiles.WithPattern("/**")
.Run(),
op)
.Select(
x => x.Get<UPath>()
.ToString())

View File

@ -1,7 +1,9 @@
using System.Collections.Generic;
using System.Linq;
using MAB.DotIgnore;
using MfGames.Gallium;
using MfGames.Nitride.IO.Contents;
using Xunit;
@ -9,7 +11,7 @@ using Xunit.Abstractions;
using Zio;
namespace MfGames.Nitride.IO.Tests;
namespace MfGames.Nitride.IO.Tests.Paths;
public class WhereNotIgnoredTests : NitrideIOTestBase
{
@ -39,9 +41,11 @@ public class WhereNotIgnoredTests : NitrideIOTestBase
ReadFiles readFiles = context.Resolve<ReadFiles>();
// Read and replace the paths.
IOrderedEnumerable<string> output = readFiles.WithPattern("/**")
.Run()
.WhereNotIgnored(ignore)
IOrderedEnumerable<string> output = NitrideIOEnumerableEntityExtensions
.WhereNotIgnored(
(IEnumerable<Entity>)readFiles.WithPattern("/**")
.Run(),
ignore)
.Select(
x => x.Get<UPath>()
.ToString())

View File

@ -51,7 +51,9 @@ public class WriteFilesTest : NitrideIOTestBase
.Run()
.Select(
x => x.Get<UPath>() == "/b1/b.md"
? x.SetTextContent(((ITextContentConvertable)x.GetBinaryContent()).ToTextContent())
? x.SetTextContent(
((ITextContentConvertable)x.GetBinaryContent())
.ToTextContent())
: x)
.Run(op);

View File

@ -3,14 +3,12 @@ using System.Linq;
using MfGames.Gallium;
using MfGames.Nitride.Contents;
using MfGames.Nitride.Markdown;
using MfGames.Nitride.Tests;
using MfGames.TestSetup;
using Xunit;
using Xunit.Abstractions;
namespace MfGames.Nitride.Slugs.Tests;
namespace MfGames.Nitride.Markdown.Tests;
/// <summary>
/// Tests the functionality of the WriteFiles().

View File

@ -1,9 +1,9 @@
using Autofac;
using MfGames.Nitride.Markdown;
using MfGames.Nitride.Slugs;
using MfGames.Nitride.Tests;
namespace MfGames.Nitride.Slugs.Tests;
namespace MfGames.Nitride.Markdown.Tests;
public class MarkdownTestContext : NitrideTestContext
{

View File

@ -6,18 +6,18 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\MfGames.Nitride.Markdown\MfGames.Nitride.Markdown.csproj" />
<ProjectReference Include="..\MfGames.Nitride.Tests\MfGames.Nitride.Tests.csproj" />
<ProjectReference Include="..\..\src\MfGames.Nitride.Markdown\MfGames.Nitride.Markdown.csproj"/>
<ProjectReference Include="..\MfGames.Nitride.Tests\MfGames.Nitride.Tests.csproj"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Markdig" Version="0.30.4" />
<PackageReference Include="MfGames.Gallium" Version="0.3.0" />
<PackageReference Include="MfGames.Markdown.Gemtext" Version="1.2.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1" />
<PackageReference Include="JunitXml.TestLogger" Version="3.0.114" />
<PackageReference Include="Slugify.Core" Version="3.0.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="Markdig" Version="0.30.4"/>
<PackageReference Include="MfGames.Gallium" Version="0.3.0"/>
<PackageReference Include="MfGames.Markdown.Gemtext" Version="1.2.2"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1"/>
<PackageReference Include="JunitXml.TestLogger" Version="3.0.114"/>
<PackageReference Include="Slugify.Core" Version="3.0.0"/>
<PackageReference Include="xunit" Version="2.4.2"/>
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

View File

@ -6,21 +6,21 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\MfGames.Nitride.IO\MfGames.Nitride.IO.csproj" />
<ProjectReference Include="..\..\src\MfGames.Nitride.Slugs\MfGames.Nitride.Slugs.csproj" />
<ProjectReference Include="..\MfGames.Nitride.Tests\MfGames.Nitride.Tests.csproj" />
<ProjectReference Include="..\..\src\MfGames.Nitride.IO\MfGames.Nitride.IO.csproj"/>
<ProjectReference Include="..\..\src\MfGames.Nitride.Slugs\MfGames.Nitride.Slugs.csproj"/>
<ProjectReference Include="..\MfGames.Nitride.Tests\MfGames.Nitride.Tests.csproj"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="MfGames.Gallium" Version="0.3.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1" />
<PackageReference Include="JunitXml.TestLogger" Version="3.0.114" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="MfGames.Gallium" Version="0.3.0"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1"/>
<PackageReference Include="JunitXml.TestLogger" Version="3.0.114"/>
<PackageReference Include="xunit" Version="2.4.2"/>
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Zio" Version="0.15.0" />
<PackageReference Include="Zio" Version="0.15.0"/>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>

Some files were not shown because too many files have changed in this diff Show More