refactor: code cleanup
This commit is contained in:
parent
72582fb703
commit
443789c391
33 changed files with 79 additions and 73 deletions
|
@ -1,4 +1,5 @@
|
||||||
root = true
|
root = true
|
||||||
|
|
||||||
["*"]
|
["*"]
|
||||||
charset = "utf-8"
|
charset = "utf-8"
|
||||||
csharp_new_line_before_members_in_object_initializers = false
|
csharp_new_line_before_members_in_object_initializers = false
|
||||||
|
@ -104,7 +105,8 @@ tab_width = 4
|
||||||
["*.md"]
|
["*.md"]
|
||||||
max_line_length = "off"
|
max_line_length = "off"
|
||||||
|
|
||||||
["*.{appxmanifest,build,config,csproj,dbml,discomap,dtd,jsproj,lsproj,njsproj,nuspec,proj,props,resw,resx,StyleCop,targets,tasks,vbproj,xml,xsd}]"]
|
["*.{appxmanifest,build,config,csproj,dbml,discomap,dtd,jsproj,lsproj,njsproj,nuspec,proj,props,resw,resx,StyleCop,targets,tasks,vbproj,xml,xsd}]
|
||||||
|
"]
|
||||||
indent_size = 2
|
indent_size = 2
|
||||||
indent_style = "space"
|
indent_style = "space"
|
||||||
tab_width = 2
|
tab_width = 2
|
||||||
|
|
|
@ -40,8 +40,7 @@ public class ConfigCommand : Command, ICommandHandler, ITopCommand
|
||||||
public Task<int> InvokeAsync(InvocationContext context)
|
public Task<int> InvokeAsync(InvocationContext context)
|
||||||
{
|
{
|
||||||
// Get the settings and report that it was being created.
|
// Get the settings and report that it was being created.
|
||||||
ConfigCommandSettings settings =
|
var settings = this.service.ReadDefaultConfigFile<ConfigCommandSettings>();
|
||||||
this.service.ReadDefaultConfigFile<ConfigCommandSettings>();
|
|
||||||
|
|
||||||
if (settings == null)
|
if (settings == null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,7 +28,9 @@ public class SampleToolModule : Module
|
||||||
};
|
};
|
||||||
|
|
||||||
// Add in the top-level commands.
|
// Add in the top-level commands.
|
||||||
var commandList = c.Resolve<IList<ITopCommand>>().Cast<Command>().ToList();
|
List<Command> commandList = c.Resolve<IList<ITopCommand>>()
|
||||||
|
.Cast<Command>()
|
||||||
|
.ToList();
|
||||||
|
|
||||||
if (commandList.Count == 0)
|
if (commandList.Count == 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -38,8 +38,7 @@ public class GemtextPipeTableExtension : IMarkdownExtension
|
||||||
pipeline.BlockParsers.Insert(0, new PipeTableBlockParser());
|
pipeline.BlockParsers.Insert(0, new PipeTableBlockParser());
|
||||||
}
|
}
|
||||||
|
|
||||||
LineBreakInlineParser? lineBreakParser =
|
var lineBreakParser = pipeline.InlineParsers.FindExact<LineBreakInlineParser>();
|
||||||
pipeline.InlineParsers.FindExact<LineBreakInlineParser>();
|
|
||||||
|
|
||||||
if (!pipeline.InlineParsers.Contains<PipeTableParser>())
|
if (!pipeline.InlineParsers.Contains<PipeTableParser>())
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,7 +24,7 @@ public class IncreaseHeaderDepthsAfterFirst : IMarkdownExtension
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
HeadingRenderer? heading = gemtext.ObjectRenderers.Find<HeadingRenderer>();
|
var heading = gemtext.ObjectRenderers.Find<HeadingRenderer>();
|
||||||
|
|
||||||
if (heading != null)
|
if (heading != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -22,7 +22,7 @@ public class WikiLinkExtension : IMarkdownExtension
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public void Setup(MarkdownPipelineBuilder pipeline)
|
public void Setup(MarkdownPipelineBuilder pipeline)
|
||||||
{
|
{
|
||||||
WikiLinkInlineParser? parser = pipeline.InlineParsers.FindExact<WikiLinkInlineParser>();
|
var parser = pipeline.InlineParsers.FindExact<WikiLinkInlineParser>();
|
||||||
|
|
||||||
if (parser != null)
|
if (parser != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -68,7 +68,7 @@ public partial class CreateCalender : OperationBase
|
||||||
calendar.TimeZones.Add(new VTimeZone(this.clock.DateTimeZone.Id));
|
calendar.TimeZones.Add(new VTimeZone(this.clock.DateTimeZone.Id));
|
||||||
|
|
||||||
// Go through the events and add all of them.
|
// Go through the events and add all of them.
|
||||||
var input = entities.ToList();
|
List<Entity>? input = entities.ToList();
|
||||||
IEnumerable<CalendarEvent> events = input.Select(this.CreateCalendarEvent);
|
IEnumerable<CalendarEvent> events = input.Select(this.CreateCalendarEvent);
|
||||||
|
|
||||||
calendar.Events.AddRange(events);
|
calendar.Events.AddRange(events);
|
||||||
|
@ -89,7 +89,7 @@ public partial class CreateCalender : OperationBase
|
||||||
|
|
||||||
private CalendarEvent CreateCalendarEvent(Entity entity)
|
private CalendarEvent CreateCalendarEvent(Entity entity)
|
||||||
{
|
{
|
||||||
Instant instant = entity.Get<Instant>();
|
var instant = entity.Get<Instant>();
|
||||||
var when = this.clock.ToDateTime(instant);
|
var when = this.clock.ToDateTime(instant);
|
||||||
string summary = this.GetEventSummary!(entity);
|
string summary = this.GetEventSummary!(entity);
|
||||||
Uri? url = this.GetEventUrl?.Invoke(entity);
|
Uri? url = this.GetEventUrl?.Invoke(entity);
|
||||||
|
|
|
@ -72,7 +72,7 @@ public abstract class ClassAttributeSyntaxReceiverBase : ISyntaxReceiver
|
||||||
}
|
}
|
||||||
|
|
||||||
// See if the class has our set properties attribute.
|
// See if the class has our set properties attribute.
|
||||||
var attributes = cds.AttributeLists.AsEnumerable()
|
List<string>? attributes = cds.AttributeLists.AsEnumerable()
|
||||||
.SelectMany(x => x.Attributes)
|
.SelectMany(x => x.Attributes)
|
||||||
.Select(x => x.Name.ToString())
|
.Select(x => x.Name.ToString())
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
|
@ -88,7 +88,7 @@ public class SingletonComponentSourceGenerator
|
||||||
);
|
);
|
||||||
|
|
||||||
// Create the source text and write out the file.
|
// Create the source text and write out the file.
|
||||||
var sourceText = SourceText.From(buffer.ToString(), Encoding.UTF8);
|
SourceText? sourceText = SourceText.From(buffer.ToString(), Encoding.UTF8);
|
||||||
context.AddSource(cls + ".Generated.cs", sourceText);
|
context.AddSource(cls + ".Generated.cs", sourceText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,7 +111,7 @@ public class WithPropertiesSourceGenerator
|
||||||
buffer.AppendLine("}");
|
buffer.AppendLine("}");
|
||||||
|
|
||||||
// Create the source text and write out the file.
|
// Create the source text and write out the file.
|
||||||
var sourceText = SourceText.From(buffer.ToString(), Encoding.UTF8);
|
SourceText? sourceText = SourceText.From(buffer.ToString(), Encoding.UTF8);
|
||||||
context.AddSource(cds.Identifier + ".Generated.cs", sourceText);
|
context.AddSource(cds.Identifier + ".Generated.cs", sourceText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ public partial class ReadFiles : FileSystemOperationBase
|
||||||
// Read the files from the file system.
|
// Read the files from the file system.
|
||||||
this.validator.ValidateAndThrow(this);
|
this.validator.ValidateAndThrow(this);
|
||||||
|
|
||||||
var glob = Glob.Parse(this.Pattern);
|
Glob? glob = Glob.Parse(this.Pattern);
|
||||||
|
|
||||||
IEnumerable<FileEntry> files = this.FileSystem.EnumerateFileEntries(
|
IEnumerable<FileEntry> files = this.FileSystem.EnumerateFileEntries(
|
||||||
"/",
|
"/",
|
||||||
|
|
|
@ -3,7 +3,6 @@ using MfGames.Gallium;
|
||||||
using MfGames.Nitride.Entities;
|
using MfGames.Nitride.Entities;
|
||||||
using MfGames.Nitride.Generators;
|
using MfGames.Nitride.Generators;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Serilog;
|
|
||||||
using Zio;
|
using Zio;
|
||||||
|
|
||||||
namespace MfGames.Nitride.IO.Paths;
|
namespace MfGames.Nitride.IO.Paths;
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class StatusPipelineCommandLineOption : IPipelineCommandOption
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SpectreDisplayMode mode = value.GetEnumFuzzy<SpectreDisplayMode>("status display mode");
|
var mode = value.GetEnumFuzzy<SpectreDisplayMode>("status display mode");
|
||||||
|
|
||||||
this.observer.DisplayMode = mode;
|
this.observer.DisplayMode = mode;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ public partial class IndexedPathRegexSchedule<TSchedule> : PathRegexScheduleBase
|
||||||
protected override Entity Apply(Entity entity, int number, TimeService timeService)
|
protected override Entity Apply(Entity entity, int number, TimeService timeService)
|
||||||
{
|
{
|
||||||
// Figure out the entry in the index.
|
// Figure out the entry in the index.
|
||||||
var applicableKeys = this.Indexes.Keys.Where(a => a <= number).ToList();
|
List<int>? applicableKeys = this.Indexes.Keys.Where(a => a <= number).ToList();
|
||||||
|
|
||||||
if (applicableKeys.Count == 0)
|
if (applicableKeys.Count == 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -53,8 +53,9 @@ public partial class IndexedSchedule
|
||||||
|
|
||||||
// If the time hasn't past, then we don't apply it.
|
// If the time hasn't past, then we don't apply it.
|
||||||
Instant now = timeService.Clock.GetCurrentInstant();
|
Instant now = timeService.Clock.GetCurrentInstant();
|
||||||
|
bool isFuture = instant > now;
|
||||||
|
|
||||||
return instant > now ? entity : this.Apply(entity, number, instant);
|
return isFuture ? entity : this.Apply(entity, number, instant);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -65,7 +65,7 @@ public partial class CreateDateIndexes : OperationBase, IResolvingOperation
|
||||||
|
|
||||||
// Go through the inputs and group each one. We also use `ToList` to force the enumeration to completely
|
// Go through the inputs and group each one. We also use `ToList` to force the enumeration to completely
|
||||||
// resolve and we can get everything we need. We will append the created indexes to the end of this list.
|
// resolve and we can get everything we need. We will append the created indexes to the end of this list.
|
||||||
var output = input
|
List<Entity>? output = input
|
||||||
.SelectEntity<Instant>(
|
.SelectEntity<Instant>(
|
||||||
(entity, instant) => this.GroupOnFormats(instant, entries, entity)
|
(entity, instant) => this.GroupOnFormats(instant, entries, entity)
|
||||||
)
|
)
|
||||||
|
@ -87,9 +87,9 @@ public partial class CreateDateIndexes : OperationBase, IResolvingOperation
|
||||||
|
|
||||||
// Get all the entities at this level and split them into ones we've seen (at a lower level) and which
|
// Get all the entities at this level and split them into ones we've seen (at a lower level) and which
|
||||||
// ones are new (these always go on the index).
|
// ones are new (these always go on the index).
|
||||||
var seenEntities = pair.Value.Where(a => seen.Contains(a)).ToList();
|
List<Entity>? seenEntities = pair.Value.Where(a => seen.Contains(a)).ToList();
|
||||||
|
|
||||||
var newEntities = pair.Value.Where(a => !seen.Contains(a)).ToList();
|
List<Entity>? newEntities = pair.Value.Where(a => !seen.Contains(a)).ToList();
|
||||||
|
|
||||||
seen.AddRange(newEntities);
|
seen.AddRange(newEntities);
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class DatePipelineCommandOption : IPipelineCommandOption
|
||||||
{
|
{
|
||||||
// We have a date, so we need to create a fake clock that has this
|
// We have a date, so we need to create a fake clock that has this
|
||||||
// date for the entire run.
|
// date for the entire run.
|
||||||
var local = LocalDateTime.FromDateTime(value.Value);
|
LocalDateTime local = LocalDateTime.FromDateTime(value.Value);
|
||||||
ZonedDateTime zoned = local.InZoneStrictly(this.timeService.DateTimeZone);
|
ZonedDateTime zoned = local.InZoneStrictly(this.timeService.DateTimeZone);
|
||||||
var instant = zoned.ToInstant();
|
var instant = zoned.ToInstant();
|
||||||
|
|
||||||
|
|
|
@ -46,8 +46,8 @@ public static class NitrideTemporalBuilderExtensions
|
||||||
{
|
{
|
||||||
x.Register(context =>
|
x.Register(context =>
|
||||||
{
|
{
|
||||||
ILogger logger = context.Resolve<ILogger>();
|
var logger = context.Resolve<ILogger>();
|
||||||
TimeService clock = context.Resolve<TimeService>();
|
var clock = context.Resolve<TimeService>();
|
||||||
|
|
||||||
return new ExpiresPipelineCommandOption(logger, clock, config.Expiration);
|
return new ExpiresPipelineCommandOption(logger, clock, config.Expiration);
|
||||||
})
|
})
|
||||||
|
@ -60,8 +60,8 @@ public static class NitrideTemporalBuilderExtensions
|
||||||
builder.ConfigureSite(
|
builder.ConfigureSite(
|
||||||
(_, scope) =>
|
(_, scope) =>
|
||||||
{
|
{
|
||||||
ILogger logger = scope.Resolve<ILogger>();
|
var logger = scope.Resolve<ILogger>();
|
||||||
TimeService timeService = scope.Resolve<TimeService>();
|
var timeService = scope.Resolve<TimeService>();
|
||||||
|
|
||||||
timeService.DateTimeZone = config.DateTimeZone;
|
timeService.DateTimeZone = config.DateTimeZone;
|
||||||
logger.Verbose("Setting time zone to {Zone:l}", timeService.DateTimeZone);
|
logger.Verbose("Setting time zone to {Zone:l}", timeService.DateTimeZone);
|
||||||
|
|
|
@ -89,7 +89,7 @@ public class TimeService
|
||||||
/// <returns>An instant representing this DateTimeOffset.</returns>
|
/// <returns>An instant representing this DateTimeOffset.</returns>
|
||||||
public Instant CreateInstant(DateTimeOffset when)
|
public Instant CreateInstant(DateTimeOffset when)
|
||||||
{
|
{
|
||||||
var offset = OffsetDateTime.FromDateTimeOffset(when);
|
OffsetDateTime offset = OffsetDateTime.FromDateTimeOffset(when);
|
||||||
|
|
||||||
return offset.ToInstant();
|
return offset.ToInstant();
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ public class TimeService
|
||||||
{
|
{
|
||||||
if (when.Kind == DateTimeKind.Unspecified)
|
if (when.Kind == DateTimeKind.Unspecified)
|
||||||
{
|
{
|
||||||
var localDate = LocalDate.FromDateTime(when);
|
LocalDate localDate = LocalDate.FromDateTime(when);
|
||||||
|
|
||||||
return this.CreateInstant(localDate);
|
return this.CreateInstant(localDate);
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,7 +137,7 @@ public class ConfigToolService
|
||||||
}
|
}
|
||||||
|
|
||||||
string json = file.ReadAllText();
|
string json = file.ReadAllText();
|
||||||
TType result = JsonConvert.DeserializeObject<TType>(json)!;
|
var result = JsonConvert.DeserializeObject<TType>(json)!;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ public static class ParseResultExtensions
|
||||||
return new List<string>();
|
return new List<string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
var values = optionValues
|
List<string>? values = optionValues
|
||||||
.Split(',')
|
.Split(',')
|
||||||
.Select(x => x.Trim())
|
.Select(x => x.Trim())
|
||||||
.SelectMany(x => x.Split(' '))
|
.SelectMany(x => x.Split(' '))
|
||||||
|
|
|
@ -42,7 +42,7 @@ public static class StringCliExtensions
|
||||||
public static Result<string> GetFuzzy(this string value, ICollection<string> possible)
|
public static Result<string> GetFuzzy(this string value, ICollection<string> possible)
|
||||||
{
|
{
|
||||||
// Look for a direct match.
|
// Look for a direct match.
|
||||||
var found = possible
|
List<string>? found = possible
|
||||||
.Where(x => string.Equals(x, value, StringComparison.InvariantCultureIgnoreCase))
|
.Where(x => string.Equals(x, value, StringComparison.InvariantCultureIgnoreCase))
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ public static class StringCliExtensions
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attempt a fuzzy search.
|
// Attempt a fuzzy search.
|
||||||
var possible = Enum.GetNames(typeof(TEnum))
|
List<string>? possible = Enum.GetNames(typeof(TEnum))
|
||||||
.Select(e => e.ToLower())
|
.Select(e => e.ToLower())
|
||||||
.Where(e => e.StartsWith(input.ToLower()))
|
.Where(e => e.StartsWith(input.ToLower()))
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
|
@ -127,7 +127,7 @@ public class LoggingToolService
|
||||||
nameof(LogContextFormat.Class)
|
nameof(LogContextFormat.Class)
|
||||||
);
|
);
|
||||||
|
|
||||||
LogContextFormat format = level.GetEnumFuzzy<LogContextFormat>("log context format");
|
var format = level.GetEnumFuzzy<LogContextFormat>("log context format");
|
||||||
|
|
||||||
return format;
|
return format;
|
||||||
}
|
}
|
||||||
|
@ -140,7 +140,7 @@ public class LoggingToolService
|
||||||
"Warning"
|
"Warning"
|
||||||
);
|
);
|
||||||
|
|
||||||
LogEventLevel logLevel = level.GetEnumFuzzy<LogEventLevel>("log level");
|
var logLevel = level.GetEnumFuzzy<LogEventLevel>("log level");
|
||||||
|
|
||||||
return logLevel;
|
return logLevel;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ public class AddPathPrefixTest : NitrideIOTestBase
|
||||||
fileSystem.CreateFile("/c1.md");
|
fileSystem.CreateFile("/c1.md");
|
||||||
|
|
||||||
// Set up the operation.
|
// Set up the operation.
|
||||||
ReadFiles readFiles = context.Resolve<ReadFiles>();
|
var readFiles = context.Resolve<ReadFiles>();
|
||||||
|
|
||||||
AddPathPrefix op = context.Resolve<AddPathPrefix>().WithPathPrefix("/prefix");
|
AddPathPrefix op = context.Resolve<AddPathPrefix>().WithPathPrefix("/prefix");
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using MfGames.Gallium;
|
||||||
using MfGames.Nitride.IO.Contents;
|
using MfGames.Nitride.IO.Contents;
|
||||||
using MfGames.Nitride.IO.Paths;
|
using MfGames.Nitride.IO.Paths;
|
||||||
using MfGames.Nitride.Tests;
|
using MfGames.Nitride.Tests;
|
||||||
|
@ -36,11 +37,13 @@ public class DirectChildPathScannerTests : NitrideIOTestBase
|
||||||
fileSystem.CreateFile("/a/d/e/index.md");
|
fileSystem.CreateFile("/a/d/e/index.md");
|
||||||
|
|
||||||
// Set up the operation.
|
// Set up the operation.
|
||||||
ReadFiles readFiles = context.Resolve<ReadFiles>();
|
var readFiles = context.Resolve<ReadFiles>();
|
||||||
DirectChildPathScanner op = context.Resolve<DirectChildPathScanner>();
|
var op = context.Resolve<DirectChildPathScanner>();
|
||||||
|
|
||||||
// Read and replace the paths.
|
// Read and replace the paths.
|
||||||
var _ = NitrideOperationExtensions.Run(readFiles.WithPattern("/**").Run(), op).ToList();
|
List<Entity>? _ = NitrideOperationExtensions
|
||||||
|
.Run(readFiles.WithPattern("/**").Run(), op)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
KeyValuePair<string, string[]>[] actual = op.GetScannedResults()
|
KeyValuePair<string, string[]>[] actual = op.GetScannedResults()
|
||||||
.ToDictionary(x => x.Key, x => x.Value.Select(y => y.Get<UPath>().ToString()).ToArray())
|
.ToDictionary(x => x.Key, x => x.Value.Select(y => y.Get<UPath>().ToString()).ToArray())
|
||||||
|
|
|
@ -27,7 +27,7 @@ public class GetEntityByPathTests : NitrideIOTestBase
|
||||||
fileSystem.CreateFile("/c1.md");
|
fileSystem.CreateFile("/c1.md");
|
||||||
|
|
||||||
// Set up the operation.
|
// Set up the operation.
|
||||||
ReadFiles readFiles = context.Resolve<ReadFiles>();
|
var readFiles = context.Resolve<ReadFiles>();
|
||||||
|
|
||||||
// Read and replace the paths.
|
// Read and replace the paths.
|
||||||
IOrderedEnumerable<string> output = NitrideIOEnumerableEntityExtensions
|
IOrderedEnumerable<string> output = NitrideIOEnumerableEntityExtensions
|
||||||
|
@ -55,7 +55,7 @@ public class GetEntityByPathTests : NitrideIOTestBase
|
||||||
fileSystem.CreateFile("/c1.md");
|
fileSystem.CreateFile("/c1.md");
|
||||||
|
|
||||||
// Set up the operation.
|
// Set up the operation.
|
||||||
ReadFiles readFiles = context.Resolve<ReadFiles>();
|
var readFiles = context.Resolve<ReadFiles>();
|
||||||
|
|
||||||
// Read and replace the paths.
|
// Read and replace the paths.
|
||||||
IOrderedEnumerable<string> output = NitrideIOEnumerableEntityExtensions
|
IOrderedEnumerable<string> output = NitrideIOEnumerableEntityExtensions
|
||||||
|
@ -88,7 +88,7 @@ public class GetEntityByPathTests : NitrideIOTestBase
|
||||||
fileSystem.CreateFile("/c1.md");
|
fileSystem.CreateFile("/c1.md");
|
||||||
|
|
||||||
// Set up the operation.
|
// Set up the operation.
|
||||||
ReadFiles readFiles = context.Resolve<ReadFiles>();
|
var readFiles = context.Resolve<ReadFiles>();
|
||||||
|
|
||||||
// Read and replace the paths.
|
// Read and replace the paths.
|
||||||
IOrderedEnumerable<string> output = NitrideIOEnumerableEntityExtensions
|
IOrderedEnumerable<string> output = NitrideIOEnumerableEntityExtensions
|
||||||
|
|
|
@ -37,8 +37,8 @@ public class LinkDirectChildrenTests : NitrideIOTestBase
|
||||||
fileSystem.CreateFile("/a/d/e/index.md");
|
fileSystem.CreateFile("/a/d/e/index.md");
|
||||||
|
|
||||||
// Set up the operation.
|
// Set up the operation.
|
||||||
ReadFiles readFiles = context.Resolve<ReadFiles>();
|
var readFiles = context.Resolve<ReadFiles>();
|
||||||
DirectChildPathScanner scanner = context.Resolve<DirectChildPathScanner>();
|
var scanner = context.Resolve<DirectChildPathScanner>();
|
||||||
|
|
||||||
CreateOrUpdateIndex op = context.Resolve<LinkDirectChildren>().WithScanner(scanner);
|
CreateOrUpdateIndex op = context.Resolve<LinkDirectChildren>().WithScanner(scanner);
|
||||||
|
|
||||||
|
|
|
@ -21,8 +21,8 @@ public class MoveToIndexPathsTest : NitrideIOTestBase
|
||||||
CreateFileSystem(context);
|
CreateFileSystem(context);
|
||||||
|
|
||||||
// Set up the operation.
|
// Set up the operation.
|
||||||
ReadFiles readFiles = context.Resolve<ReadFiles>();
|
var readFiles = context.Resolve<ReadFiles>();
|
||||||
MoveToIndexPath op = context.Resolve<MoveToIndexPath>();
|
var op = context.Resolve<MoveToIndexPath>();
|
||||||
|
|
||||||
// Read and replace the paths.
|
// Read and replace the paths.
|
||||||
IOrderedEnumerable<string> output = NitrideOperationExtensions
|
IOrderedEnumerable<string> output = NitrideOperationExtensions
|
||||||
|
@ -43,7 +43,7 @@ public class MoveToIndexPathsTest : NitrideIOTestBase
|
||||||
CreateFileSystem(context);
|
CreateFileSystem(context);
|
||||||
|
|
||||||
// Set up the operation.
|
// Set up the operation.
|
||||||
ReadFiles readFiles = context.Resolve<ReadFiles>();
|
var readFiles = context.Resolve<ReadFiles>();
|
||||||
|
|
||||||
MoveToIndexPath op = context
|
MoveToIndexPath op = context
|
||||||
.Resolve<MoveToIndexPath>()
|
.Resolve<MoveToIndexPath>()
|
||||||
|
|
|
@ -27,7 +27,7 @@ public class RemovePathPrefixTest : NitrideIOTestBase
|
||||||
fileSystem.CreateFile("/a/a/c1.md");
|
fileSystem.CreateFile("/a/a/c1.md");
|
||||||
|
|
||||||
// Set up the operation.
|
// Set up the operation.
|
||||||
ReadFiles readFiles = context.Resolve<ReadFiles>();
|
var readFiles = context.Resolve<ReadFiles>();
|
||||||
|
|
||||||
RemovePathPrefix op = context.Resolve<RemovePathPrefix>().WithPathPrefix("/a");
|
RemovePathPrefix op = context.Resolve<RemovePathPrefix>().WithPathPrefix("/a");
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class WhereNotIgnoredTests : NitrideIOTestBase
|
||||||
var ignore = new IgnoreList(new[] { "*.txt" });
|
var ignore = new IgnoreList(new[] { "*.txt" });
|
||||||
|
|
||||||
// Set up the operation.
|
// Set up the operation.
|
||||||
ReadFiles readFiles = context.Resolve<ReadFiles>();
|
var readFiles = context.Resolve<ReadFiles>();
|
||||||
|
|
||||||
// Read and replace the paths.
|
// Read and replace the paths.
|
||||||
IOrderedEnumerable<string> output = NitrideIOEnumerableEntityExtensions
|
IOrderedEnumerable<string> output = NitrideIOEnumerableEntityExtensions
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class MakeSingleLinkListItemsTests : TestBase<MarkdownTestContext>
|
||||||
|
|
||||||
List<Entity> input =
|
List<Entity> input =
|
||||||
new() { new Entity().Set(IsMarkdown.Instance).SetTextContent("- [Empty](link)"), };
|
new() { new Entity().Set(IsMarkdown.Instance).SetTextContent("- [Empty](link)"), };
|
||||||
MakeSingleLinkListItems? op = context.Resolve<MakeSingleLinkListItems>();
|
var op = context.Resolve<MakeSingleLinkListItems>();
|
||||||
IEnumerable<Entity> output = op.Run(input);
|
IEnumerable<Entity> output = op.Run(input);
|
||||||
string content = output.First().GetTextContentString()!.Trim();
|
string content = output.First().GetTextContentString()!.Trim();
|
||||||
|
|
||||||
|
@ -40,7 +40,25 @@ public class MakeSingleLinkListItemsTests : TestBase<MarkdownTestContext>
|
||||||
{
|
{
|
||||||
new Entity().Set(IsMarkdown.Instance).SetTextContent("- [Empty](link) space"),
|
new Entity().Set(IsMarkdown.Instance).SetTextContent("- [Empty](link) space"),
|
||||||
};
|
};
|
||||||
MakeSingleLinkListItems? op = context.Resolve<MakeSingleLinkListItems>();
|
var op = context.Resolve<MakeSingleLinkListItems>();
|
||||||
|
IEnumerable<Entity> output = op.Run(input);
|
||||||
|
string content = output.First().GetTextContentString()!.Trim();
|
||||||
|
|
||||||
|
Assert.Equal("- [Empty space](link)", content);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void ExtendSingleMarkdownLinkSpaces()
|
||||||
|
{
|
||||||
|
// Prettier formats lists like this.
|
||||||
|
using MarkdownTestContext context = this.CreateContext();
|
||||||
|
|
||||||
|
List<Entity> input =
|
||||||
|
new()
|
||||||
|
{
|
||||||
|
new Entity().Set(IsMarkdown.Instance).SetTextContent("- [Empty](link) space"),
|
||||||
|
};
|
||||||
|
var op = context.Resolve<MakeSingleLinkListItems>();
|
||||||
IEnumerable<Entity> output = op.Run(input);
|
IEnumerable<Entity> output = op.Run(input);
|
||||||
string content = output.First().GetTextContentString()!.Trim();
|
string content = output.First().GetTextContentString()!.Trim();
|
||||||
|
|
||||||
|
@ -57,31 +75,13 @@ public class MakeSingleLinkListItemsTests : TestBase<MarkdownTestContext>
|
||||||
{
|
{
|
||||||
new Entity().Set(IsMarkdown.Instance).SetTextContent("* [Empty](link) space"),
|
new Entity().Set(IsMarkdown.Instance).SetTextContent("* [Empty](link) space"),
|
||||||
};
|
};
|
||||||
MakeSingleLinkListItems? op = context.Resolve<MakeSingleLinkListItems>();
|
var op = context.Resolve<MakeSingleLinkListItems>();
|
||||||
IEnumerable<Entity> output = op.Run(input);
|
IEnumerable<Entity> output = op.Run(input);
|
||||||
string content = output.First().GetTextContentString()!.Trim();
|
string content = output.First().GetTextContentString()!.Trim();
|
||||||
|
|
||||||
Assert.Equal("* [Empty space](link)", content);
|
Assert.Equal("* [Empty space](link)", content);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void ExtendSingleMarkdownLinkSpaces()
|
|
||||||
{
|
|
||||||
// Prettier formats lists like this.
|
|
||||||
using MarkdownTestContext context = this.CreateContext();
|
|
||||||
|
|
||||||
List<Entity> input =
|
|
||||||
new()
|
|
||||||
{
|
|
||||||
new Entity().Set(IsMarkdown.Instance).SetTextContent("- [Empty](link) space"),
|
|
||||||
};
|
|
||||||
MakeSingleLinkListItems? op = context.Resolve<MakeSingleLinkListItems>();
|
|
||||||
IEnumerable<Entity> output = op.Run(input);
|
|
||||||
string content = output.First().GetTextContentString()!.Trim();
|
|
||||||
|
|
||||||
Assert.Equal("- [Empty space](link)", content);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void NoLinksNoChange()
|
public void NoLinksNoChange()
|
||||||
{
|
{
|
||||||
|
@ -89,7 +89,7 @@ public class MakeSingleLinkListItemsTests : TestBase<MarkdownTestContext>
|
||||||
|
|
||||||
List<Entity> input =
|
List<Entity> input =
|
||||||
new() { new Entity().Set(IsMarkdown.Instance).SetTextContent("- Empty"), };
|
new() { new Entity().Set(IsMarkdown.Instance).SetTextContent("- Empty"), };
|
||||||
MakeSingleLinkListItems? op = context.Resolve<MakeSingleLinkListItems>();
|
var op = context.Resolve<MakeSingleLinkListItems>();
|
||||||
IEnumerable<Entity> output = op.Run(input);
|
IEnumerable<Entity> output = op.Run(input);
|
||||||
string content = output.First().GetTextContentString()!.Trim();
|
string content = output.First().GetTextContentString()!.Trim();
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ public class MakeSingleLinkListItemsTests : TestBase<MarkdownTestContext>
|
||||||
.Set(IsMarkdown.Instance)
|
.Set(IsMarkdown.Instance)
|
||||||
.SetTextContent("- [Empty](link) [space](link2)"),
|
.SetTextContent("- [Empty](link) [space](link2)"),
|
||||||
};
|
};
|
||||||
MakeSingleLinkListItems? op = context.Resolve<MakeSingleLinkListItems>();
|
var op = context.Resolve<MakeSingleLinkListItems>();
|
||||||
IEnumerable<Entity> output = op.Run(input);
|
IEnumerable<Entity> output = op.Run(input);
|
||||||
string content = output.First().GetTextContentString()!.Trim();
|
string content = output.First().GetTextContentString()!.Trim();
|
||||||
|
|
||||||
|
|
|
@ -241,6 +241,7 @@ public class IndexedPathRegexScheduleTest : TemporalSchedulesTestBase
|
||||||
{
|
{
|
||||||
TestModel model = entity.Get<TestModel>();
|
TestModel model = entity.Get<TestModel>();
|
||||||
model.Access = this.Access;
|
model.Access = this.Access;
|
||||||
|
|
||||||
return entity.SetAll(instant, model);
|
return entity.SetAll(instant, model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ public class TextContentYamlTests : NitrideTestBase
|
||||||
public void NoTextContent()
|
public void NoTextContent()
|
||||||
{
|
{
|
||||||
Entity entity = new();
|
Entity entity = new();
|
||||||
TestContent? output = entity.GetTextContentYaml<TestContent>();
|
var output = entity.GetTextContentYaml<TestContent>();
|
||||||
|
|
||||||
Assert.Null(output);
|
Assert.Null(output);
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ public class TextContentYamlTests : NitrideTestBase
|
||||||
public void SetAndGetContent()
|
public void SetAndGetContent()
|
||||||
{
|
{
|
||||||
Entity entity = new Entity().SetTextContentYaml(new TestContent { Value = "t1" });
|
Entity entity = new Entity().SetTextContentYaml(new TestContent { Value = "t1" });
|
||||||
TestContent? output = entity.GetTextContentYaml<TestContent>();
|
var output = entity.GetTextContentYaml<TestContent>();
|
||||||
|
|
||||||
Assert.NotNull(output);
|
Assert.NotNull(output);
|
||||||
Assert.Equal("t1", output.Value);
|
Assert.Equal("t1", output.Value);
|
||||||
|
@ -35,7 +35,7 @@ public class TextContentYamlTests : NitrideTestBase
|
||||||
Entity entity = new Entity()
|
Entity entity = new Entity()
|
||||||
.SetTextContentYaml(new TestContent { Value = "t1" })
|
.SetTextContentYaml(new TestContent { Value = "t1" })
|
||||||
.SetTextContentYaml<TestContent>(null);
|
.SetTextContentYaml<TestContent>(null);
|
||||||
TestContent? output = entity.GetTextContentYaml<TestContent>();
|
var output = entity.GetTextContentYaml<TestContent>();
|
||||||
|
|
||||||
Assert.Null(output);
|
Assert.Null(output);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue