diff --git a/.github/workflows/build-native-tools.yml b/.github/workflows/build-native-tools.yml index 72360d9c..2cd3cedf 100644 --- a/.github/workflows/build-native-tools.yml +++ b/.github/workflows/build-native-tools.yml @@ -18,7 +18,7 @@ jobs: - environment: ubuntu-22.04 publish-runtime-id: linux-x64 - environment: windows-2022 - publish-runtime-id: win10-x64 + publish-runtime-id: win-x64 - environment: macos-13 publish-runtime-id: osx-x64 @@ -32,7 +32,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-dotnet@v3 with: - dotnet-version: '7.0.400' + dotnet-version: '8.0.100-rc.1.23455.8' - name: Try use dotnet run: dotnet --info diff --git a/.github/workflows/publish-to-release.yml b/.github/workflows/publish-to-release.yml index 2638c6a8..38698672 100644 --- a/.github/workflows/publish-to-release.yml +++ b/.github/workflows/publish-to-release.yml @@ -16,7 +16,7 @@ jobs: - environment: ubuntu-22.04 publish-runtime-id: linux-x64 - environment: windows-2022 - publish-runtime-id: win10-x64 + publish-runtime-id: win-x64 - environment: macos-12 publish-runtime-id: osx-x64 @@ -33,7 +33,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-dotnet@v3 with: - dotnet-version: '7.0.400' + dotnet-version: '8.0.100-rc.1.23455.8' - name: Try use dotnet run: dotnet --info diff --git a/.github/workflows/test-and-publish.yml b/.github/workflows/test-and-publish.yml index f820bdf0..3d9f0111 100644 --- a/.github/workflows/test-and-publish.yml +++ b/.github/workflows/test-and-publish.yml @@ -13,7 +13,7 @@ jobs: - environment: ubuntu-22.04 publish-runtime-id: linux-x64 - environment: windows-2022 - publish-runtime-id: win10-x64 + publish-runtime-id: win-x64 - environment: macos-13 publish-runtime-id: osx-x64 @@ -27,7 +27,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-dotnet@v3 with: - dotnet-version: '7.0.400' + dotnet-version: '8.0.100-rc.1.23455.8' - name: Try use dotnet run: dotnet --info diff --git a/azure-pipelines.yml b/azure-pipelines.yml index e3dd2220..e4daf427 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -11,7 +11,7 @@ steps: - task: UseDotNet@2 inputs: packageType: 'sdk' # Options: runtime, sdk - version: '7.0.400' + version: '8.0.100-rc.1.23455.8' includePreviewVersions: true - script: dotnet --version diff --git a/implement/Dockerfile b/implement/Dockerfile index 874f1525..012ca2bc 100644 --- a/implement/Dockerfile +++ b/implement/Dockerfile @@ -1,5 +1,5 @@ # Build dotnet build image -FROM mcr.microsoft.com/dotnet/sdk:7.0.400 AS build-env +FROM mcr.microsoft.com/dotnet/sdk:8.0.100-rc.1 AS build-env WORKDIR /app # Copy everything and build @@ -8,7 +8,7 @@ WORKDIR /app/elm-time RUN dotnet publish -c Debug -o out # Build runtime image -FROM mcr.microsoft.com/dotnet/aspnet:7.0.10 AS binaries +FROM mcr.microsoft.com/dotnet/aspnet:8.0.0-rc.1 AS binaries COPY --from=build-env /app/elm-time/out /elm-time/dotnet/ diff --git a/implement/elm-time/Elm019/Elm019Binaries.cs b/implement/elm-time/Elm019/Elm019Binaries.cs index 24077b80..7a4c08d5 100644 --- a/implement/elm-time/Elm019/Elm019Binaries.cs +++ b/implement/elm-time/Elm019/Elm019Binaries.cs @@ -26,7 +26,7 @@ public record ElmMakeOk(ReadOnlyMemory producedFile); public static Result ElmMakeToJavascript( IImmutableDictionary, ReadOnlyMemory> elmCodeFiles, IReadOnlyList? workingDirectoryRelative, - IImmutableList pathToFileWithElmEntryPoint, + IReadOnlyList pathToFileWithElmEntryPoint, string? elmMakeCommandAppendix = null) => ElmMake( elmCodeFiles, @@ -212,7 +212,7 @@ An alternative would be retrying when this error is parsed from `commandResults. .ToImmutableList(); var outputFileExpectedPath = - (workingDirectoryRelative ?? ImmutableList.Empty).ToImmutableList().Add(outputFileName); + (workingDirectoryRelative ?? []).ToImmutableList().Add(outputFileName); var outputFiles = newFiles diff --git a/implement/elm-time/Elm019/ElmJsonStructure.cs b/implement/elm-time/Elm019/ElmJsonStructure.cs index a9ed1c2b..b5251512 100644 --- a/implement/elm-time/Elm019/ElmJsonStructure.cs +++ b/implement/elm-time/Elm019/ElmJsonStructure.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.Collections.Immutable; using System.Linq; using System.Text.Json.Serialization; @@ -15,7 +14,7 @@ public record ElmJsonStructure( public static RelativeDirectory ParseSourceDirectory(string sourceDirectory) { - var initialRecord = new RelativeDirectory(ParentLevel: 0, Subdirectories: ImmutableList.Empty); + var initialRecord = new RelativeDirectory(ParentLevel: 0, Subdirectories: []); if (sourceDirectory == ".") return initialRecord; @@ -37,7 +36,7 @@ public static RelativeDirectory ParseSourceDirectory(string sourceDirectory) 0 < aggregate.Subdirectories.Count ? aggregate with { - Subdirectories = aggregate.Subdirectories.RemoveAt(aggregate.Subdirectories.Count - 1) + Subdirectories = [.. aggregate.Subdirectories.SkipLast(1)] } : aggregate with @@ -47,13 +46,13 @@ aggregate with _ => aggregate with { - Subdirectories = aggregate.Subdirectories.Add(nextSegment) + Subdirectories = [.. aggregate.Subdirectories, nextSegment] } }); } public record RelativeDirectory( int ParentLevel, - IImmutableList Subdirectories); + IReadOnlyList Subdirectories); } diff --git a/implement/elm-time/ElmInteractive/ElmInteractive.cs b/implement/elm-time/ElmInteractive/ElmInteractive.cs index dd15cd58..c99c66ec 100644 --- a/implement/elm-time/ElmInteractive/ElmInteractive.cs +++ b/implement/elm-time/ElmInteractive/ElmInteractive.cs @@ -26,9 +26,9 @@ public static Result EvaluateSubmissionAndGetResult var argumentsJson = System.Text.Json.JsonSerializer.Serialize( new { - modulesTexts = modulesTexts ?? ImmutableList.Empty, + modulesTexts = modulesTexts ?? [], submission = submission, - previousLocalSubmissions = previousLocalSubmissions ?? ImmutableList.Empty, + previousLocalSubmissions = previousLocalSubmissions ?? [], } ); @@ -65,7 +65,7 @@ public static IReadOnlyList GetDefaultElmCoreModulesTexts( { var allModulesTexts = GetDefaultElmCoreModulesTexts(evalElmPreparedJavaScriptEngine) - .Concat(ModulesTextsFromAppCodeTree(appCodeTree).EmptyIfNull()) + .Concat(ModulesTextsFromAppCodeTree(appCodeTree) ?? []) .ToImmutableList(); return @@ -117,7 +117,7 @@ closestBase is not null (closestBase, compilationCacheBefore)) : CompileInteractiveEnvironmentForModules( - elmModulesTexts: ImmutableList.Empty, + elmModulesTexts: [], evalElmPreparedJavaScriptEngine: evalElmPreparedJavaScriptEngine, parentEnvironment: null, compilationCacheBefore: compilationCacheBefore); @@ -133,7 +133,7 @@ closestBase is not null { var resultBeforeCache = CompileInteractiveEnvironmentForModules( - elmModulesTexts: ImmutableList.Create(elmCoreModuleText), + elmModulesTexts: [elmCoreModuleText], evalElmPreparedJavaScriptEngine: evalElmPreparedJavaScriptEngine, parentEnvironment: prev.compileResult, compilationCacheBefore: prev.compilationCache); @@ -229,7 +229,7 @@ private ReadOnlyMemory ComputeHash() if (parent is null) return selfHash; - return PineValueHashTree.ComputeHash(PineValue.List(new[] { PineValue.Blob(selfHash), PineValue.Blob(parent.Hash) })); + return PineValueHashTree.ComputeHash(PineValue.List([PineValue.Blob(selfHash), PineValue.Blob(parent.Hash)])); } public virtual bool Equals(CompileInteractiveEnvironmentResult? other) @@ -596,7 +596,7 @@ private static PineValue ParsePineValueFromJson(PineValueJson fromJson, IReadOnl var compilationResult = ElmAppCompilation.AsCompletelyLoweredElmApp( sourceFiles: TreeToFlatDictionaryWithPathComparer(sourceTree), - workingDirectoryRelative: ImmutableList.Empty, + workingDirectoryRelative: [], ElmAppInterfaceConfig.Default with { compilationRootFilePath = compilationRootFilePath }); return @@ -641,7 +641,7 @@ public static string PrepareJavaScriptToEvaluateElm() compileElmProgramCodeFiles .Extract(error => throw new NotImplementedException(nameof(LoadCompileElmProgramCodeFiles) + ": " + error)), workingDirectoryRelative: null, - ImmutableList.Create("src", "ElmInteractiveMain.elm")); + ["src", "ElmInteractiveMain.elm"]); var javascriptFromElmMake = Encoding.UTF8.GetString( @@ -681,7 +681,7 @@ public static string PrepareJavaScriptToEvaluateElm() public static Result, ReadOnlyMemory>> LoadCompileElmProgramCodeFiles() => DotNetAssembly.LoadDirectoryFilesFromManifestEmbeddedFileProviderAsDictionary( - directoryPath: ImmutableList.Create("ElmTime", "compile-elm-program"), + directoryPath: ["ElmTime", "compile-elm-program"], assembly: typeof(ElmInteractive).Assembly); private record EvaluateSubmissionResponseStructure diff --git a/implement/elm-time/ElmInteractive/TestElmInteractive.cs b/implement/elm-time/ElmInteractive/TestElmInteractive.cs index 517475d4..f8f7cdab 100644 --- a/implement/elm-time/ElmInteractive/TestElmInteractive.cs +++ b/implement/elm-time/ElmInteractive/TestElmInteractive.cs @@ -90,10 +90,10 @@ public static ImmutableDictionary TestElm console.WriteLine( string.Join( " - ", - (failedSteps.Any() ? "Failed" : "Passed") + "!", + (!failedSteps.IsEmpty ? "Failed" : "Passed") + "!", string.Join(", ", overallStats.Select(stat => stat.label + ": " + stat.value)), scenariosTreeCompositionHash[..10] + " (elm-time " + Program.AppVersionId + ")"), - color: failedSteps.Any() ? IConsole.TextColor.Red : IConsole.TextColor.Green); + color: !failedSteps.IsEmpty ? IConsole.TextColor.Red : IConsole.TextColor.Green); var failedScenarios = failedSteps @@ -206,10 +206,10 @@ Result getResult() public static Result ParseScenario(TreeNodeWithStringPath scenarioTree) { var appCodeTree = - scenarioTree.GetNodeAtPath(new[] { "context-app" }); + scenarioTree.GetNodeAtPath(["context-app"]); var stepsDirectory = - scenarioTree.GetNodeAtPath(new[] { "steps" }); + scenarioTree.GetNodeAtPath(["steps"]); var testScenarioSteps = stepsDirectory switch @@ -251,14 +251,14 @@ public static Result ParseScenario(TreeNodeWithStringPath scen public static Result ParseScenarioStep(TreeNodeWithStringPath sessionStep) { var expectedResponse = - sessionStep.GetNodeAtPath(new[] { "expected-value.txt" }) is TreeNodeWithStringPath.BlobNode expectedValueBlob + sessionStep.GetNodeAtPath(["expected-value.txt"]) is TreeNodeWithStringPath.BlobNode expectedValueBlob ? Encoding.UTF8.GetString(expectedValueBlob.Bytes.Span) : null; return - (sessionStep.GetNodeAtPath(new[] { "submission.txt" }) switch + (sessionStep.GetNodeAtPath(["submission.txt"]) switch { TreeNodeWithStringPath.BlobNode submissionBlob => Result.ok(Encoding.UTF8.GetString(submissionBlob.Bytes.Span)), _ => Result.err("Missing submission"), diff --git a/implement/elm-time/ElmSyntax/ElmModule.cs b/implement/elm-time/ElmSyntax/ElmModule.cs index 40975ee0..0e0cf9de 100644 --- a/implement/elm-time/ElmSyntax/ElmModule.cs +++ b/implement/elm-time/ElmSyntax/ElmModule.cs @@ -35,7 +35,7 @@ public static IReadOnlyList ModulesTextOrderedForCompilationByDependenci IEnumerable> EnumerateImportsOfModuleTransitive(IReadOnlyList moduleName) => !parsedModulesByName.ContainsKey(moduleName) ? - ImmutableList>.Empty + [] : parsedModulesByName[moduleName].importedModulesNames .SelectMany( diff --git a/implement/elm-time/ElmTestRs.cs b/implement/elm-time/ElmTestRs.cs index aa9e293a..7f7bc611 100644 --- a/implement/elm-time/ElmTestRs.cs +++ b/implement/elm-time/ElmTestRs.cs @@ -124,7 +124,7 @@ public static (ExecutableFile.ProcessOutput processOutput, IReadOnlyList<(string var environmentFilesExecutable = ImmutableDictionary.Create, ReadOnlyMemory>() - .SetItem(ImmutableList.Create(elmExecutableFileName), Elm019Binaries.GetElmExecutableFile); + .SetItem([elmExecutableFileName], Elm019Binaries.GetElmExecutableFile); var executeElmTestResult = ExecutableFile.ExecuteFileWithArguments( @@ -169,12 +169,12 @@ public static (IReadOnlyList<(string text, ElmTestRsConsoleOutputColor color)> t if (@event.@event == "runStart") { return - (ImmutableList.Create( + ([ (string.Join("\n", "Running " + @event.testCount + " tests. To reproduce these results later," , "run elm-test-rs with --seed " + @event.initialSeed + " and --fuzz " + @event.fuzzRuns), ElmTestRsConsoleOutputColor.DefaultColor) - ), + ], overallSuccess: null); } @@ -189,28 +189,28 @@ public static (IReadOnlyList<(string text, ElmTestRsConsoleOutputColor color)> t ("\nTEST RUN FAILED\n\n", ElmTestRsConsoleOutputColor.RedColor); return - (ImmutableList.Create( + ([ overallSuccessText, (string.Join("\n", "Duration: " + string.Format("{0:#,##0}", @event.duration) + " ms", "Passed: " + @event.passed, "Failed: " + @event.failed), - ElmTestRsConsoleOutputColor.DefaultColor)), + ElmTestRsConsoleOutputColor.DefaultColor)], overallSuccess); } if (@event.@event == "testsCompleted" && @event.status != "pass") { var textsFromLabels = - @event.labels.EmptyIfNull().SkipLast(1).Select(label => ("\n↓ " + label, ElmTestRsConsoleOutputColor.DefaultColor)) - .Concat(@event.labels.EmptyIfNull().TakeLast(1).Select(label => ("\n✗ " + label, ElmTestRsConsoleOutputColor.RedColor))) + (@event.labels ?? []).SkipLast(1).Select(label => ("\n↓ " + label, ElmTestRsConsoleOutputColor.DefaultColor)) + .Concat((@event.labels ?? []).TakeLast(1).Select(label => ("\n✗ " + label, ElmTestRsConsoleOutputColor.RedColor))) .ToImmutableList(); static IReadOnlyList renderFailureReasonData(ElmTestRsReportJsonEntryFailureReasonData failureReasonData) { if (failureReasonData.Equality != null) { - return ImmutableList.Create( + return [ "", failureReasonData.Equality.actual, "╷", @@ -218,30 +218,29 @@ static IReadOnlyList renderFailureReasonData(ElmTestRsReportJsonEntryFai "╵", failureReasonData.Equality.expected, "" - ); + ]; } if (failureReasonData.String != null) - return ImmutableList.Create("", failureReasonData.String, ""); + return ["", failureReasonData.String, ""]; throw new Exception("Incomplete match on sum type."); } var textsFromFailures = - @event.failures.EmptyIfNull() + (@event.failures ?? []) .Select(failure => failure.reason?.data) .WhereNotNull() .SelectMany(renderFailureReasonData) .ToImmutableList(); return - (textsFromLabels.Concat( - textsFromFailures - .Select(textFromFailure => ("\n " + textFromFailure, ElmTestRsConsoleOutputColor.DefaultColor))).ToImmutableList(), + ([.. textsFromLabels + , .. textsFromFailures.Select(textFromFailure => ("\n " + textFromFailure, ElmTestRsConsoleOutputColor.DefaultColor))], null); } - return (ImmutableList<(string text, ElmTestRsConsoleOutputColor color)>.Empty, null); + return ([], null); } } diff --git a/implement/elm-time/ElmTime/ElmAppCompilation.cs b/implement/elm-time/ElmTime/ElmAppCompilation.cs index 0951355d..459b225f 100644 --- a/implement/elm-time/ElmTime/ElmAppCompilation.cs +++ b/implement/elm-time/ElmTime/ElmAppCompilation.cs @@ -10,13 +10,23 @@ using System.Text; using System.Text.RegularExpressions; +using CompilationResult = + Pine.Result< + System.Collections.Generic.IReadOnlyList, + ElmTime.ElmAppCompilation.CompilationSuccess>; + +using CompilationIterationResult = + Pine.Result< + System.Collections.Generic.IReadOnlyList, + ElmTime.ElmAppCompilation.CompilationIterationSuccess>; + namespace ElmTime { public record ElmAppInterfaceConfig(IReadOnlyList compilationRootFilePath) { public static ElmAppInterfaceConfig Default => new ( - compilationRootFilePath: ImmutableList.Create("src", "Backend", "Main.elm") + compilationRootFilePath: ["src", "Backend", "Main.elm"] ); } @@ -26,14 +36,14 @@ public struct ElmAppInterfaceConvention public const string ProcessSerializedEventFunctionName = "interfaceToHost_processEvent"; - public static IImmutableList CompilationInterfaceModuleNamePrefixes => ImmutableList.Create("CompilationInterface"); + public static ImmutableList CompilationInterfaceModuleNamePrefixes => ["CompilationInterface"]; } public class ElmAppCompilation { private static readonly System.Diagnostics.Stopwatch cacheItemTimeSource = System.Diagnostics.Stopwatch.StartNew(); - private static readonly ConcurrentDictionary, CompilationSuccess> compilationResult, TimeSpan lastUseTime)> ElmAppCompilationCache = new(); + private static readonly ConcurrentDictionary ElmAppCompilationCache = new(); private static void ElmAppCompilationCacheRemoveOlderItems(long retainedSizeLimit) => Cache.RemoveItemsToLimitRetainedSize( @@ -42,7 +52,7 @@ private static void ElmAppCompilationCacheRemoveOlderItems(long retainedSizeLimi item => item.Value.lastUseTime, retainedSizeLimit); - public static Result, CompilationSuccess> AsCompletelyLoweredElmApp( + public static CompilationResult AsCompletelyLoweredElmApp( IImmutableDictionary, ReadOnlyMemory> sourceFiles, IReadOnlyList workingDirectoryRelative, ElmAppInterfaceConfig interfaceConfig) @@ -58,17 +68,17 @@ public static Result, CompilationSuccess> interfaceConfig, })))); - Result, CompilationSuccess> compileNew() => + CompilationResult compileNew() => AsCompletelyLoweredElmApp( sourceFiles, workingDirectoryRelative: workingDirectoryRelative, compilationRootFilePath: interfaceConfig.compilationRootFilePath, interfaceToHostRootModuleName: InterfaceToHostRootModuleName.Split('.').ToImmutableList()); - (Result, CompilationSuccess> compilationResult, TimeSpan lastUseTime) BuildNextCacheEntry( - Result, CompilationSuccess>? previousEntryCompilationResult) + (CompilationResult compilationResult, TimeSpan lastUseTime) BuildNextCacheEntry( + CompilationResult? previousEntryCompilationResult) { - if (previousEntryCompilationResult is Result, CompilationSuccess>.Ok ok) + if (previousEntryCompilationResult is CompilationResult.Ok ok) return (previousEntryCompilationResult, cacheItemTimeSource.Elapsed); return (compileNew(), cacheItemTimeSource.Elapsed); @@ -97,7 +107,7 @@ public record StackFrame( IImmutableList<(CompilerSerialInterface.DependencyKey key, ReadOnlyMemory value)> discoveredDependencies, CompilationIterationReport iterationReport); - private static Result, CompilationSuccess> AsCompletelyLoweredElmApp( + private static CompilationResult AsCompletelyLoweredElmApp( IImmutableDictionary, ReadOnlyMemory> sourceFiles, IReadOnlyList workingDirectoryRelative, IReadOnlyList compilationRootFilePath, @@ -109,7 +119,7 @@ private static Result, CompilationSuccess interfaceToHostRootModuleName, ImmutableStack.Empty); - private static Result, CompilationSuccess> AsCompletelyLoweredElmApp( + private static CompilationResult AsCompletelyLoweredElmApp( IImmutableDictionary, ReadOnlyMemory> sourceFiles, IReadOnlyList workingDirectoryRelative, IReadOnlyList compilationRootFilePath, @@ -149,7 +159,7 @@ private static Result, CompilationSuccess fromOk: compilationSuccess => { return - Result, CompilationSuccess>.ok( + CompilationResult.ok( new CompilationSuccess( result: compilationSuccess, stack.Select(frame => frame.iterationReport).ToImmutableList().Add(currentIterationReport))); @@ -165,7 +175,7 @@ private static Result, CompilationSuccess if (dependencyKey != null) return ImmutableList.Create((error, dependencyKey)); - return ImmutableList<(CompilerSerialInterface.LocatedCompilationError error, CompilerSerialInterface.DependencyKey dependencyKey)>.Empty; + return []; }) .ToImmutableList(); @@ -175,7 +185,7 @@ private static Result, CompilationSuccess if (0 < otherErrors.Count) { - return Result, CompilationSuccess>.err( + return CompilationResult.err( otherErrors.Select(error => new LocatedCompilationError(error.location, error: CompilationError.AsCompilationError(error.error))).ToImmutableList()); } @@ -262,7 +272,7 @@ currentIterationReport with * */ if (0 < newDependenciesWithError.Count) { - return Result, CompilationSuccess>.err( + return CompilationResult.err( newDependenciesWithError.Select(dep => new LocatedCompilationError( location: null, error: new CompilationError( @@ -288,7 +298,7 @@ currentIterationReport with }); } - private static readonly ConcurrentDictionary, CompilationIterationSuccess> compilationResult, TimeSpan lastUseTime)> ElmAppCompilationIterationCache = new(); + private static readonly ConcurrentDictionary ElmAppCompilationIterationCache = new(); private static void ElmAppCompilationIterationCacheRemoveOlderItems(long retainedSizeLimit) => Cache.RemoveItemsToLimitRetainedSize( @@ -297,7 +307,7 @@ private static void ElmAppCompilationIterationCacheRemoveOlderItems(long retaine item => item.Value.lastUseTime, retainedSizeLimit); - private static (Result, CompilationIterationSuccess>, CompilationIterationCompilationReport report) CachedElmAppCompilationIteration( + private static (CompilationIterationResult, CompilationIterationCompilationReport report) CachedElmAppCompilationIteration( IImmutableDictionary, ReadOnlyMemory> compilerElmProgramCodeFiles, IImmutableDictionary, ReadOnlyMemory> sourceFiles, IReadOnlyList compilationRootFilePath, @@ -346,7 +356,7 @@ private static (Result, CompilationIterationSuccess> compileNew() + CompilationIterationResult compileNew() { prepareJavaScriptEngineStopwatch = System.Diagnostics.Stopwatch.StartNew(); @@ -410,16 +420,16 @@ private static (Result FilePathFromModuleName(IReadOnlyList moduleName) + public static ImmutableList FilePathFromModuleName(IReadOnlyList moduleName) { var fileName = moduleName.Last() + ".elm"; var directoryNames = moduleName.Reverse().Skip(1).Reverse(); - return new[] { "src" }.Concat(directoryNames).Concat(new[] { fileName }).ToImmutableList(); + return ["src", .. directoryNames, fileName]; } public static IImmutableList FilePathFromModuleName(string moduleName) => - FilePathFromModuleName(moduleName.Split(new[] { '.' }).ToImmutableList()); + FilePathFromModuleName(moduleName.Split('.')); public static string InterfaceToHostRootModuleName => "Backend.InterfaceToHost_Root"; @@ -457,7 +467,7 @@ private static string BuildJavascriptToCompileFileTree( Elm019Binaries.ElmMakeToJavascript( compilerElmProgramCodeFiles, workingDirectoryRelative: null, - ImmutableList.Create("src", "Main.elm")); + ["src", "Main.elm"]); var javascriptFromElmMake = Encoding.UTF8.GetString( @@ -540,7 +550,7 @@ private static string DescribeCompilationError(CompilerSerialInterface.Compilati } private static long EstimateCacheItemSizeInMemory( - Result, CompilationIterationSuccess> item) => + CompilationIterationResult item) => item.Unpack( fromErr: err => err.Sum(EstimateCacheItemSizeInMemory), fromOk: EstimateCacheItemSizeInMemory); @@ -555,7 +565,7 @@ private static long EstimateCacheItemSizeInMemory(CompilerSerialInterface.Locate private static long EstimateCacheItemSizeInMemory(CompilerSerialInterface.CompilationError compilationError) => compilationError?.MissingDependencyError?.Sum(EstimateCacheItemSizeInMemory) ?? 0; - private static long EstimateCacheItemSizeInMemory(Result, CompilationSuccess> item) => + private static long EstimateCacheItemSizeInMemory(CompilationResult item) => item.Unpack( fromErr: errors => errors.Sum(EstimateCacheItemSizeInMemory), fromOk: EstimateCacheItemSizeInMemory); diff --git a/implement/elm-time/ElmTime/PersistentProcess.cs b/implement/elm-time/ElmTime/PersistentProcess.cs index 0339242e..be25b452 100644 --- a/implement/elm-time/ElmTime/PersistentProcess.cs +++ b/implement/elm-time/ElmTime/PersistentProcess.cs @@ -1,4 +1,4 @@ -using ElmTime.JavaScript; +using ElmTime.JavaScript; using ElmTime.ProcessStore; using Pine; using System; @@ -25,7 +25,7 @@ public class PersistentProcessWithHistoryOnFileFromElm019Code : IPersistentProce { private static readonly JsonSerializerOptions recordSerializationSettings = ProcessStoreInFileStore.RecordSerializationSettings; - private byte[] lastStateHash = CompositionRecordInFile.HashFromSerialRepresentation(Array.Empty()); + private byte[] lastStateHash = CompositionRecordInFile.HashFromSerialRepresentation([]); private readonly IDisposableProcessWithStringInterface process; @@ -48,7 +48,7 @@ public PersistentProcessWithHistoryOnFileFromElm019Code( logger?.Invoke("Begin to restore the process state using the storeReader."); - var emptyInitHash = CompositionRecordInFile.HashFromSerialRepresentation(Array.Empty()); + var emptyInitHash = CompositionRecordInFile.HashFromSerialRepresentation([]); static string dictKeyForHash(byte[] hash) => Convert.ToBase64String(hash); @@ -112,7 +112,7 @@ public PersistentProcessWithHistoryOnFileFromElm019Code( .Extract(err => throw new Exception(err)); } - foreach (var appendedEvent in followingComposition.composition.AppendedEventsLiteralString.EmptyIfNull()) + foreach (var appendedEvent in followingComposition.composition.AppendedEventsLiteralString ?? []) process.ProcessEvent(appendedEvent); lastStateHash = followingComposition.hash; diff --git a/implement/elm-time/ElmTime/Process.cs b/implement/elm-time/ElmTime/Process.cs index abe12dd0..e2278b80 100644 --- a/implement/elm-time/ElmTime/Process.cs +++ b/implement/elm-time/ElmTime/Process.cs @@ -203,7 +203,7 @@ public static string PublishFunctionsFromJavascriptFromElmMake( var publicationInsertLocation = invokeExportStatementMatch.Index; var publicationInsertString = - string.Join(Environment.NewLine, new[] { "" }.Concat(publishStatements).Concat(new[] { "" })); + string.Join(Environment.NewLine, ["", .. publishStatements, ""]); return javascriptFromElmMake.Insert(publicationInsertLocation, publicationInsertString); diff --git a/implement/elm-time/ElmTime/ProcessStore.cs b/implement/elm-time/ElmTime/ProcessStore.cs index 95a38945..850ef475 100644 --- a/implement/elm-time/ElmTime/ProcessStore.cs +++ b/implement/elm-time/ElmTime/ProcessStore.cs @@ -200,14 +200,16 @@ public void AppendSerializedCompositionRecord(byte[] record) var lastFileNameIfAddRequestedFileName = CompositionLogFileOrder( - EnumerateCompositionsLogFilesPaths().Concat(new[] { compositionLogRequestedFilePathInDirectory })) + [.. EnumerateCompositionsLogFilesPaths(), compositionLogRequestedFilePathInDirectory]) .Last(); if (compositionLogRequestedFilePathInDirectory.Equals(lastFileNameIfAddRequestedFileName)) compositionLogFilePath = compositionLogRequestedFilePathInDirectory; } - compositionFileStoreWriter.AppendFileContent(compositionLogFilePath, record.Concat(Encoding.UTF8.GetBytes("\n")).ToArray()); + compositionFileStoreWriter.AppendFileContent( + compositionLogFilePath, + CommonConversion.Concat(record, Encoding.UTF8.GetBytes("\n"))); appendSerializedCompositionRecordLastFilePath = compositionLogFilePath; } diff --git a/implement/elm-time/ElmTime/StateShim/StateShim.cs b/implement/elm-time/ElmTime/StateShim/StateShim.cs index d330c098..f9852278 100644 --- a/implement/elm-time/ElmTime/StateShim/StateShim.cs +++ b/implement/elm-time/ElmTime/StateShim/StateShim.cs @@ -29,7 +29,7 @@ public static Result SetAppState( ProcessStateShimRequest( process, new StateShimRequestStruct.SetBranchesStateShimRequest( - new StateSource.JsonStateSource(stateJson), Branches: ImmutableList.Create(branchName))) + new StateSource.JsonStateSource(stateJson), Branches: [branchName])) .AndThen(decodeOk => decodeOk.Response switch { StateShimResponseStruct.SetBranchesStateShimResponse setBranchesResponse => @@ -87,7 +87,7 @@ public static Result> ListExposedFun process, request: request, stateSource: Maybe.just(MainStateBranch), - stateDestinationBranches: request.commitResultingState ? ImmutableList.Create(MainBranchName) : ImmutableList.Empty); + stateDestinationBranches: request.commitResultingState ? [MainBranchName] : []); public static Result ApplyFunction( IProcess process, @@ -108,7 +108,7 @@ public static Result> ListExposedFun { var matchingFunctions = exposedFunctions.Where(c => c.functionName == request.functionName).ToImmutableList(); - if (!matchingFunctions.Any()) + if (matchingFunctions.IsEmpty) return Result.err( "None of the exposed functions matches name '" + request.functionName + "'. This app only exposes the following " + exposedFunctions.Count + " functions: " diff --git a/implement/elm-time/Git/LibGit2Sharp.cs b/implement/elm-time/Git/LibGit2Sharp.cs index 2e6d2158..6d1750ea 100644 --- a/implement/elm-time/Git/LibGit2Sharp.cs +++ b/implement/elm-time/Git/LibGit2Sharp.cs @@ -16,25 +16,25 @@ public class LibGit2Sharp ImmutableDictionary>.Empty .Add( OSPlatform.Linux, - ImmutableList.Create( + [ new DependencyFile( HashBase16: "7ca026cf714e14fbab252d83974c04b843affe035e041aa1eda0d0bc258426be", ExpectedFileName: "libgit2-e632535.so", - RemoteSources: new[] { "https://www.nuget.org/api/v2/package/LibGit2Sharp.NativeBinaries/2.0.320" }))) + RemoteSources: ["https://www.nuget.org/api/v2/package/LibGit2Sharp.NativeBinaries/2.0.320"])]) .Add( OSPlatform.Windows, - ImmutableList.Create( + [ new DependencyFile( HashBase16: "76b97b411e73b7487825dd0f98cba7ce7f008bef3cbe8a35bf1af8c651a0f4a0", ExpectedFileName: "git2-e632535.dll", - RemoteSources: new[] { "https://www.nuget.org/api/v2/package/LibGit2Sharp.NativeBinaries/2.0.320" }))) + RemoteSources: ["https://www.nuget.org/api/v2/package/LibGit2Sharp.NativeBinaries/2.0.320"])]) .Add( OSPlatform.OSX, - ImmutableList.Create( + [ new DependencyFile( HashBase16: "9dc84237ca835b189636697cbe1439b0894303798efd95b55a3353ca4f12b1bb", ExpectedFileName: "libgit2-e632535.dylib", - RemoteSources: new[] { "https://www.nuget.org/api/v2/package/LibGit2Sharp.NativeBinaries/2.0.320" }))); + RemoteSources: ["https://www.nuget.org/api/v2/package/LibGit2Sharp.NativeBinaries/2.0.320"])]); public static readonly Lazy SetupTask = new(() => { diff --git a/implement/elm-time/Gui/MakeGuiCache.cs b/implement/elm-time/Gui/MakeGuiCache.cs index dc101ab8..7be99929 100644 --- a/implement/elm-time/Gui/MakeGuiCache.cs +++ b/implement/elm-time/Gui/MakeGuiCache.cs @@ -18,13 +18,13 @@ public static Result MakeGuiHtml() => Program.Make( sourceFiles: elmProgramCodeFiles, workingDirectoryRelative: null, - pathToFileWithElmEntryPoint: ImmutableList.Create("src", "Frontend", "Main.elm"), + pathToFileWithElmEntryPoint: ["src", "Frontend", "Main.elm"], outputFileName: "index.html", elmMakeCommandAppendix: null)) .Map(makeOk => Encoding.UTF8.GetString(makeOk.producedFile.Span)); public static Result, ReadOnlyMemory>> LoadGuiElmProgramCodeFiles() => DotNetAssembly.LoadDirectoryFilesFromManifestEmbeddedFileProviderAsDictionary( - directoryPath: ImmutableList.Create("Gui", "elm"), + directoryPath: ["Gui", "elm"], assembly: typeof(StartupAdminInterface).Assembly); } diff --git a/implement/elm-time/JavaScript/ClearScript.cs b/implement/elm-time/JavaScript/ClearScript.cs index 45572a44..7d5f181d 100644 --- a/implement/elm-time/JavaScript/ClearScript.cs +++ b/implement/elm-time/JavaScript/ClearScript.cs @@ -16,25 +16,25 @@ public class ClearScriptV8 ImmutableDictionary>.Empty .Add( OSPlatform.Linux, - ImmutableList.Create( + [ new DependencyFile( HashBase16: "4524f101eceed4c6b0344a4cb67b19443f1d42e9f3e2f27b5cb68b007c947409", ExpectedFileName: "ClearScriptV8.linux-x64.so", - RemoteSources: new[] { "https://www.nuget.org/api/v2/package/Microsoft.ClearScript.V8.Native.linux-x64/7.4.2" }))) + RemoteSources: ["https://www.nuget.org/api/v2/package/Microsoft.ClearScript.V8.Native.linux-x64/7.4.2"])]) .Add( OSPlatform.Windows, - ImmutableList.Create( + [ new DependencyFile( HashBase16: "6ef8e937639a25554be8f60830c47b720d432b8ac47b7b54d82214d1d4083d34", ExpectedFileName: "ClearScriptV8.win-x64.dll", - RemoteSources: new[] { "https://www.nuget.org/api/v2/package/Microsoft.ClearScript.V8.Native.win-x64/7.4.2" }))) + RemoteSources: ["https://www.nuget.org/api/v2/package/Microsoft.ClearScript.V8.Native.win-x64/7.4.2"])]) .Add( OSPlatform.OSX, - ImmutableList.Create( + [ new DependencyFile( HashBase16: "e9e13385c02554fa7c76d1df0307a0ca6825eff0b641ddf7826e3fbf9a546794", ExpectedFileName: "ClearScriptV8.osx-x64.dylib", - RemoteSources: new[] { "https://www.nuget.org/api/v2/package/Microsoft.ClearScript.V8.Native.osx-x64/7.4.2" }))); + RemoteSources: ["https://www.nuget.org/api/v2/package/Microsoft.ClearScript.V8.Native.osx-x64/7.4.2"])]); public static readonly Lazy SetupTask = new(() => { @@ -74,7 +74,7 @@ public static void EnsureNativeLibrariesAvailableForCurrentPlatform() AuxiliarySearchPathAsList = new[] { cacheDirectory } - .Concat(AuxiliarySearchPathAsList ?? Array.Empty()) + .Concat(AuxiliarySearchPathAsList ?? []) .Distinct() .ToList(); } diff --git a/implement/elm-time/JavaScript/ElmInteropJint.cs b/implement/elm-time/JavaScript/ElmInteropJint.cs index 32b57058..81863fd3 100644 --- a/implement/elm-time/JavaScript/ElmInteropJint.cs +++ b/implement/elm-time/JavaScript/ElmInteropJint.cs @@ -70,6 +70,6 @@ public static JsObject ElmChoiceTypeTag(Engine engine, string tagName, params Js .UpdateWith( callee: originalCallExpression.Callee, arguments: Esprima.Ast.NodeList.Create( - new[] { new Esprima.Ast.Identifier(delegateIdentifier) }))); + [new Esprima.Ast.Identifier(delegateIdentifier)]))); } } diff --git a/implement/elm-time/JavaScript/JavaScriptEngineJint.cs b/implement/elm-time/JavaScript/JavaScriptEngineJint.cs index 43dddb9c..f4257488 100644 --- a/implement/elm-time/JavaScript/JavaScriptEngineJint.cs +++ b/implement/elm-time/JavaScript/JavaScriptEngineJint.cs @@ -122,7 +122,7 @@ public override T VisitAndConvert(T node, bool allowNull = false, [CallerMemb return new Esprima.Ast.VariableDeclaration( Esprima.Ast.NodeList.Create( - new[] { new Esprima.Ast.VariableDeclarator(functionDeclaration.Id, replacement) }), + [new Esprima.Ast.VariableDeclarator(functionDeclaration.Id, replacement)]), Esprima.Ast.VariableDeclarationKind.Var) as T; } diff --git a/implement/elm-time/JavaScript/JavaScriptEngineJintOptimizedForElmApps.cs b/implement/elm-time/JavaScript/JavaScriptEngineJintOptimizedForElmApps.cs index eae0f4f8..93ed1c22 100644 --- a/implement/elm-time/JavaScript/JavaScriptEngineJintOptimizedForElmApps.cs +++ b/implement/elm-time/JavaScript/JavaScriptEngineJintOptimizedForElmApps.cs @@ -35,22 +35,22 @@ private static IEnumerable BuildDelegatesIntoHost() var callToHostExpression = new Esprima.Ast.CallExpression( new Esprima.Ast.Identifier(hostFuncName), - Esprima.Ast.NodeList.Create(new[] { getBufferExpression }), + Esprima.Ast.NodeList.Create([getBufferExpression]), optional: false); var wrapInMaybeJustExpression = new Esprima.Ast.CallExpression( new Esprima.Ast.Identifier("$elm$core$Maybe$Just"), - Esprima.Ast.NodeList.Create(new[] { callToHostExpression }), + Esprima.Ast.NodeList.Create([callToHostExpression]), optional: false); var wholeFunctionBody = new Esprima.Ast.BlockStatement( Esprima.Ast.NodeList.Create( - new[] { new Esprima.Ast.ReturnStatement(wrapInMaybeJustExpression) })); + [new Esprima.Ast.ReturnStatement(wrapInMaybeJustExpression)])); var wholeFunctionExpression = new Esprima.Ast.FunctionExpression( id: null, - parameters: Esprima.Ast.NodeList.Create(new[] { new Esprima.Ast.Identifier(dataViewParamName) }), + parameters: Esprima.Ast.NodeList.Create([new Esprima.Ast.Identifier(dataViewParamName)]), body: wholeFunctionBody, generator: false, strict: true, diff --git a/implement/elm-time/Pine/CommandLineInterface.cs b/implement/elm-time/Pine/CommandLineInterface.cs index b1d49ff8..3c663dfd 100644 --- a/implement/elm-time/Pine/CommandLineInterface.cs +++ b/implement/elm-time/Pine/CommandLineInterface.cs @@ -11,7 +11,7 @@ public static string FormatIntegerForDisplay(long integer, char thousandsSeparat integer.ToString("N", new NumberFormatInfo { - NumberGroupSizes = new[] { 3, 3, 3, 3, 3, 3 }, + NumberGroupSizes = [3, 3, 3, 3, 3, 3], NumberGroupSeparator = thousandsSeparator.ToString(), NumberDecimalDigits = 0 }); diff --git a/implement/elm-time/Pine/Console.cs b/implement/elm-time/Pine/Console.cs index 6a55f383..476b8ff7 100644 --- a/implement/elm-time/Pine/Console.cs +++ b/implement/elm-time/Pine/Console.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.Collections.Immutable; namespace Pine; @@ -9,7 +8,7 @@ void WriteLine(string text, TextColor color = TextColor.Default) => Write("\n" + text, color); void Write(string text, TextColor color) => - Write(ImmutableList.Create((text, color))); + Write([(text, color)]); void Write(IReadOnlyList<(string text, TextColor color)> coloredTexts); diff --git a/implement/elm-time/Pine/DependenciesLoader.cs b/implement/elm-time/Pine/DependenciesLoader.cs index 40ae0116..7062a2a0 100644 --- a/implement/elm-time/Pine/DependenciesLoader.cs +++ b/implement/elm-time/Pine/DependenciesLoader.cs @@ -93,7 +93,7 @@ Result> AttemptForUrl(string url) treesFromUrl .Aggregate( seed: - Result, ReadOnlyMemory>.err(ImmutableList.Empty), + Result, ReadOnlyMemory>.err([]), func: (aggregate, tree) => { diff --git a/implement/elm-time/Pine/DotNetAssembly.cs b/implement/elm-time/Pine/DotNetAssembly.cs index 1d1d7d83..ba3890eb 100644 --- a/implement/elm-time/Pine/DotNetAssembly.cs +++ b/implement/elm-time/Pine/DotNetAssembly.cs @@ -65,7 +65,7 @@ public static Result LoadTreeFromManifestEmbedde directoryContents, loadSubdirectory: subdirectory => - LoadTreeFromManifestEmbeddedFileProvider(ImmutableList.CreateRange(directoryPath).Add(subdirectory), assembly)); + LoadTreeFromManifestEmbeddedFileProvider([.. directoryPath, subdirectory], assembly)); } public static Result LoadTreeFromManifestEmbeddedFileProviderFileInfo( diff --git a/implement/elm-time/Pine/ExecutableFile.cs b/implement/elm-time/Pine/ExecutableFile.cs index d1f31c96..bd6a807c 100644 --- a/implement/elm-time/Pine/ExecutableFile.cs +++ b/implement/elm-time/Pine/ExecutableFile.cs @@ -54,7 +54,7 @@ void writeEnvironmentFile( .SetItems( (environmentPathExecutableFiles ?? ImmutableDictionary>.Empty) .Select(execFile => new KeyValuePair, ReadOnlyMemory>( - ImmutableList.Create(environmentPathContainerDirectoryName, execFile.Key + executableFileNameAppendix), execFile.Value))) + [environmentPathContainerDirectoryName, execFile.Key + executableFileNameAppendix], execFile.Value))) .SetItem(mainExecutableFilePathRelative, executableFile); foreach (var environmentFile in allExecutableFiles) @@ -65,7 +65,7 @@ void writeEnvironmentFile( var workingDirectoryAbsolute = Path.Combine( containerDirectory, - Filesystem.MakePlatformSpecificPath(workingDirectoryRelative ?? ImmutableList.Empty)) + Filesystem.MakePlatformSpecificPath(workingDirectoryRelative ?? [])) .TrimEnd(Path.DirectorySeparatorChar) + Path.DirectorySeparatorChar.ToString(); @@ -106,7 +106,7 @@ void writeEnvironmentFile( } .Where(c => 0 < c?.Length)))) : - ImmutableList>.Empty; + []; var environmentStringsWithExecutableFiles = environmentStringsDict @@ -204,7 +204,7 @@ public static IEnumerable GetExecutablePath(string executableFileName) = .Select(s => Path.Combine(s, executableFileName)) .Where(File.Exists) ?? - Array.Empty(); + []; public static char PathEnvironmentVarSeparator => RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ';' : ':'; diff --git a/implement/elm-time/Pine/FileStore.cs b/implement/elm-time/Pine/FileStore.cs index 4e4edfd1..8cd91ee8 100644 --- a/implement/elm-time/Pine/FileStore.cs +++ b/implement/elm-time/Pine/FileStore.cs @@ -136,7 +136,7 @@ public IEnumerable> ListFilesInDirectory(IImmutableList>.Empty; + return []; return Directory.GetFiles(fileSystemDirectoryPath, "*", SearchOption.AllDirectories) @@ -299,7 +299,7 @@ public class EmptyFileStoreReader : IFileStoreReader public ReadOnlyMemory? GetFileContent(IImmutableList path) => null; public IEnumerable> ListFilesInDirectory(IImmutableList directoryPath) => - ImmutableList>.Empty; + []; } public static class FileStoreExtension diff --git a/implement/elm-time/Pine/GitPartialForCommitServer.cs b/implement/elm-time/Pine/GitPartialForCommitServer.cs index 1137cb60..4a747af3 100644 --- a/implement/elm-time/Pine/GitPartialForCommitServer.cs +++ b/implement/elm-time/Pine/GitPartialForCommitServer.cs @@ -57,7 +57,7 @@ public static Task Run( return Results.BadRequest("Missing clone URL. Use one line in the request body for each clone URL."); } - if (!supportedCloneUrls.Any()) + if (supportedCloneUrls.IsEmpty) { return Results.BadRequest( "None of the given clone URLs is enabled here. Only URLs with the following " + diff --git a/implement/elm-time/Pine/LoadFromGitHubOrGitLab.cs b/implement/elm-time/Pine/LoadFromGitHubOrGitLab.cs index a0c658fa..961010bb 100644 --- a/implement/elm-time/Pine/LoadFromGitHubOrGitLab.cs +++ b/implement/elm-time/Pine/LoadFromGitHubOrGitLab.cs @@ -141,7 +141,7 @@ public static Result LoadFromUrl( getRepositoryFilesPartialForCommit( new GetRepositoryFilesPartialForCommitRequest( commit: parsedUrl.inRepository!.@ref, - cloneUrlCandidates: ImmutableList.Create(cloneUrl))) + cloneUrlCandidates: [cloneUrl])) : GetRepositoryFilesPartialForBranchViaLibGitSharpCheckout(cloneUrl, branchName); @@ -156,7 +156,7 @@ public static Result LoadFromUrl( { foreach (var fileWithPath in repositoryFilesPartial) { - var absoluteFilePath = Path.Combine(new[] { gitRepositoryLocalDirectory }.Concat(fileWithPath.Key).ToArray()); + var absoluteFilePath = Path.Combine([gitRepositoryLocalDirectory, .. fileWithPath.Key]); var absoluteDirectoryPath = Path.GetDirectoryName(absoluteFilePath)!; Directory.CreateDirectory(absoluteDirectoryPath); @@ -404,7 +404,7 @@ public static Result, ReadOnl using var gitRepository = new Repository(tempWorkingDirectory); - gitRepository.CheckoutPaths(commit, ImmutableList.Create(tempWorkingDirectory.TrimEnd('/') + "/")); + gitRepository.CheckoutPaths(commit, [tempWorkingDirectory.TrimEnd('/') + "/"]); return Result, ReadOnlyMemory>>.ok( @@ -611,9 +611,7 @@ private static byte[] GitBlobSHAFromBlobContent(byte[] blobContent) { var prefixAsText = "blob " + blobContent.Length + "\0"; - var hashedValue = Encoding.ASCII.GetBytes(prefixAsText).Concat(blobContent).ToArray(); - - return SHA1.HashData(hashedValue); + return SHA1.HashData([.. Encoding.ASCII.GetBytes(prefixAsText), .. blobContent]); } public record LoadFromUrlSuccess( diff --git a/implement/elm-time/Pine/PineVM/KernelFunction.cs b/implement/elm-time/Pine/PineVM/KernelFunction.cs index 433fec13..3d8c1d6f 100644 --- a/implement/elm-time/Pine/PineVM/KernelFunction.cs +++ b/implement/elm-time/Pine/PineVM/KernelFunction.cs @@ -103,7 +103,7 @@ public static Result concat(PineValue value) => aggregate switch { PineValue.ListValue aggregateListValue => - PineValue.List(aggregateListValue.Elements.Concat(elemListValue.Elements).ToImmutableList()), + PineValue.List([.. aggregateListValue.Elements, .. elemListValue.Elements]), _ => elemListValue }, _ => throw new NotImplementedException() diff --git a/implement/elm-time/Pine/PineVM/PineCompileToDotNet.cs b/implement/elm-time/Pine/PineVM/PineCompileToDotNet.cs index 52792e21..4472d29a 100644 --- a/implement/elm-time/Pine/PineVM/PineCompileToDotNet.cs +++ b/implement/elm-time/Pine/PineVM/PineCompileToDotNet.cs @@ -35,13 +35,8 @@ public static GenerateCSharpFileResult GenerateCSharpFile( SyntaxFactory.CompilationUnit() .WithUsings(new SyntaxList(compileCSharpClassResult.UsingDirectives)) .WithMembers( - SyntaxFactory.List( - (additionalMembers ?? Array.Empty()) - .Concat( - new MemberDeclarationSyntax[] - { - compileCSharpClassResult.ClassDeclarationSyntax - }))); + SyntaxFactory.List( + [.. (additionalMembers ?? []), compileCSharpClassResult.ClassDeclarationSyntax])); var formattedNode = new FormatCSharpSyntaxRewriter().Visit(compilationUnitSyntax.NormalizeWhitespace(eol: "\n")); @@ -401,10 +396,10 @@ void registerValueUsagesRecursive(PineValue pineValue) ClassDeclarationSyntax: SyntaxFactory.ClassDeclaration(containerConfig.containerTypeName) .WithMembers( - SyntaxFactory.List( - new MemberDeclarationSyntax[] { dictionaryMemberDeclaration } - .Concat(compiledExpressions.Select(f => f.memberDeclarationSyntax)) - .Concat(staticFieldsDeclarations).ToArray())), + SyntaxFactory.List( + [dictionaryMemberDeclaration + , .. compiledExpressions.Select(f => f.memberDeclarationSyntax) + , .. staticFieldsDeclarations])), UsingDirectives: usings)); }); } @@ -610,7 +605,7 @@ static CompiledExpression recursive( ImmutableList compiledList, ImmutableList syntaxesCs) { - if (!compiledList.Any()) + if (compiledList.IsEmpty) return combine(syntaxesCs); return @@ -625,7 +620,7 @@ static CompiledExpression recursive( recursive( combine, compiledList.ToImmutableList(), - ImmutableList.Empty); + []); } } @@ -1411,28 +1406,28 @@ private static IEnumerable EnumerateAllLiterals(Expression expression expression switch { Expression.LiteralExpression literal => - new[] { literal.Value }, + [literal.Value], Expression.EnvironmentExpression => - Enumerable.Empty(), + [], Expression.ListExpression list => - list.List.SelectMany(EnumerateAllLiterals), + list.List.SelectMany(EnumerateAllLiterals), Expression.KernelApplicationExpression kernelApplicationExpression => - EnumerateAllLiterals(kernelApplicationExpression.argument), + EnumerateAllLiterals(kernelApplicationExpression.argument), Expression.ConditionalExpression conditionalExpression => - EnumerateAllLiterals(conditionalExpression.condition) - .Concat(EnumerateAllLiterals(conditionalExpression.ifTrue) - .Concat(EnumerateAllLiterals(conditionalExpression.ifFalse))), + [.. EnumerateAllLiterals(conditionalExpression.condition) + , .. EnumerateAllLiterals(conditionalExpression.ifTrue) + , .. EnumerateAllLiterals(conditionalExpression.ifFalse)], Expression.DecodeAndEvaluateExpression decodeAndEvaluateExpression => - EnumerateAllLiterals(decodeAndEvaluateExpression.expression) - .Concat(EnumerateAllLiterals(decodeAndEvaluateExpression.environment)), + [.. EnumerateAllLiterals(decodeAndEvaluateExpression.expression) + , .. EnumerateAllLiterals(decodeAndEvaluateExpression.environment)], Expression.StringTagExpression stringTagExpression => - EnumerateAllLiterals(stringTagExpression.tagged), + EnumerateAllLiterals(stringTagExpression.tagged), _ => throw new NotImplementedException("Expression type not implemented: " + expression.GetType().FullName) }; @@ -1521,14 +1516,13 @@ private static Result EncodePineExpressionAsCSharpExpr .WithArgumentList( SyntaxFactory.ArgumentList( SyntaxFactory.SeparatedList( - new[] - { + [ SyntaxFactory.Argument( SyntaxFactory.LiteralExpression( SyntaxKind.StringLiteralExpression, SyntaxFactory.Literal(kernelApplicationExpr.functionName))), SyntaxFactory.Argument(encodedArgument) - })))), + ])))), Expression.DecodeAndEvaluateExpression decodeAndEvaluate => continueEncode(decodeAndEvaluate.expression) diff --git a/implement/elm-time/Pine/PineVM/PineVM.cs b/implement/elm-time/Pine/PineVM/PineVM.cs index 2c72f155..d718ded9 100644 --- a/implement/elm-time/Pine/PineVM/PineVM.cs +++ b/implement/elm-time/Pine/PineVM/PineVM.cs @@ -189,7 +189,7 @@ public static Result EncodeExpressionAsValue(Expression expre EncodeExpressionAsValue(stringTag.tagged) .Map(encodedTagged => EncodeChoiceTypeVariantAsPineValue( "StringTag", - PineValue.List(new[] { PineValueAsString.ValueFromString(stringTag.tag), encodedTagged }))), + PineValue.List([PineValueAsString.ValueFromString(stringTag.tag), encodedTagged]))), _ => Result.err("Unsupported expression type: " + expression.GetType().FullName) @@ -394,11 +394,10 @@ public static Result DecodeRecord2FromPineValue PineValue.List( fields.Select(field => PineValue.List( - new[] - { + [ PineValueAsString.ValueFromString(field.fieldName), field.fieldValue - })).ToArray()); + ])).ToArray()); public static Result> DecodeRecordFromPineValue(PineValue value) => @@ -415,11 +414,10 @@ public static Result> DecodeRecor public static PineValue EncodeChoiceTypeVariantAsPineValue(string tagName, PineValue tagArguments) => PineValue.List( - new[] - { + [ PineValueAsString.ValueFromString(tagName), tagArguments, - }); + ]); public static Result DecodeChoiceFromPineValue( Func> generalDecoder, diff --git a/implement/elm-time/Pine/PineVM/PineVMConfiguration.cs b/implement/elm-time/Pine/PineVM/PineVMConfiguration.cs index 86755cf4..1da21b04 100644 --- a/implement/elm-time/Pine/PineVM/PineVMConfiguration.cs +++ b/implement/elm-time/Pine/PineVM/PineVMConfiguration.cs @@ -1,5 +1,4 @@ -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using System; using System.Collections.Generic; @@ -68,6 +67,6 @@ public static PineCompileToDotNet.GenerateCSharpFileResult GenerateCSharpFile( return PineCompileToDotNet.GenerateCSharpFile( compileCSharpClassResult, - additionalMembers: new[] { configurationClassDeclarationInNamespace }); + additionalMembers: [configurationClassDeclarationInNamespace]); } } diff --git a/implement/elm-time/Pine/PineValue.cs b/implement/elm-time/Pine/PineValue.cs index cb1b840e..a0114fcf 100644 --- a/implement/elm-time/Pine/PineValue.cs +++ b/implement/elm-time/Pine/PineValue.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Collections.Immutable; using System.Linq; namespace Pine; @@ -23,7 +22,7 @@ public static PineValue Blob(ReadOnlyMemory bytes) => public static PineValue List(IReadOnlyList elements) => new ListValue(elements); - public static readonly PineValue EmptyList = List(ImmutableList.Empty); + public static readonly PineValue EmptyList = List([]); /// /// A that is a list of s. diff --git a/implement/elm-time/Pine/PineValueComposition.cs b/implement/elm-time/Pine/PineValueComposition.cs index d877dcfc..eda2c1e2 100644 --- a/implement/elm-time/Pine/PineValueComposition.cs +++ b/implement/elm-time/Pine/PineValueComposition.cs @@ -7,10 +7,10 @@ namespace Pine; public static class PineValueComposition { - public static Result, TreeNodeWithStringPath> ParseAsTreeWithStringPath( + public static Result, TreeNodeWithStringPath> ParseAsTreeWithStringPath( PineValue composition) { - static Result, TreeNodeWithStringPath> continueForListComposition( + static Result, TreeNodeWithStringPath> continueForListComposition( PineValue.ListValue compositionAsList) { var compositionResults = @@ -19,17 +19,15 @@ public static class PineValueComposition { if (element is not PineValue.ListValue elementAsList || elementAsList.Elements.Count != 2) { - return Result, (string name, TreeNodeWithStringPath - element)>.err( - ImmutableList<(int index, string name)>.Empty); + return Result, (string name, TreeNodeWithStringPath + element)>.err([]); } if (PineValueAsString.StringFromValue(elementAsList.Elements.ElementAt(0)) is not Result.Ok nameOk) { - return Result, (string name, TreeNodeWithStringPath - element)>.err( - ImmutableList<(int index, string name)>.Empty); + return Result, (string name, TreeNodeWithStringPath + element)>.err([]); } var currentIndexAndName = @@ -38,13 +36,13 @@ public static class PineValueComposition return ParseAsTreeWithStringPath(elementAsList.Elements.ElementAt(1)) switch { - Result, TreeNodeWithStringPath>.Err err => - Result, (string name, + Result, TreeNodeWithStringPath>.Err err => + Result, (string name, TreeNodeWithStringPath element)>.err( - ImmutableList.Create(currentIndexAndName).AddRange(err.Value)), + [currentIndexAndName, .. err.Value]), - Result, TreeNodeWithStringPath>.Ok ok => - Result, (string name, + Result, TreeNodeWithStringPath>.Ok ok => + Result, (string name, TreeNodeWithStringPath element)>.ok( (currentIndexAndName.name, ok.Value)), @@ -63,7 +61,7 @@ public static class PineValueComposition composition switch { PineValue.BlobValue compositionAsBlob => - Result, TreeNodeWithStringPath>.ok( + Result, TreeNodeWithStringPath>.ok( TreeNodeWithStringPath.Blob(compositionAsBlob.Bytes)), PineValue.ListValue compositionAsList => @@ -83,9 +81,10 @@ public static PineValue FromTreeWithStringPath(TreeNodeWithStringPath node) => tree.Elements .Select(treeElement => PineValue.List( - ImmutableList.Create( + [ PineValueAsString.ValueFromString(treeElement.name), - FromTreeWithStringPath(treeElement.component)) + FromTreeWithStringPath(treeElement.component) + ] )) .ToImmutableList()), diff --git a/implement/elm-time/Pine/PineValueHashTree.cs b/implement/elm-time/Pine/PineValueHashTree.cs index 6272ce50..594099e1 100644 --- a/implement/elm-time/Pine/PineValueHashTree.cs +++ b/implement/elm-time/Pine/PineValueHashTree.cs @@ -35,7 +35,7 @@ public static (ReadOnlyMemory serialRepresentation, IReadOnlyCollection.Empty); + return (serialRepresentation, []); } case PineValue.ListValue listValue: @@ -46,7 +46,7 @@ public static (ReadOnlyMemory serialRepresentation, IReadOnlyCollection)prefix }.Concat(elementsHashes).ToList()).ToArray(), + (serialRepresentation: CommonConversion.Concat([(ReadOnlyMemory)prefix, .. elementsHashes]), dependencies: listValue.Elements); } diff --git a/implement/elm-time/Pine/TreeNodeWithStringPath.cs b/implement/elm-time/Pine/TreeNodeWithStringPath.cs index 9fc0d524..81f8dca8 100644 --- a/implement/elm-time/Pine/TreeNodeWithStringPath.cs +++ b/implement/elm-time/Pine/TreeNodeWithStringPath.cs @@ -76,16 +76,16 @@ public virtual bool Equals(TreeNode? other) public static TreeNodeWithStringPath Blob(ReadOnlyMemory blobContent) => new BlobNode(blobContent); - public static TreeNodeWithStringPath SortedTree(IImmutableList<(string name, TreeNodeWithStringPath component)> treeContent) => + public static TreeNodeWithStringPath SortedTree(IReadOnlyList<(string name, TreeNodeWithStringPath component)> treeContent) => Sort(NonSortedTree(treeContent)); - public static TreeNodeWithStringPath NonSortedTree(IImmutableList<(string name, TreeNodeWithStringPath component)> treeContent) => + public static TreeNodeWithStringPath NonSortedTree(IReadOnlyList<(string name, TreeNodeWithStringPath component)> treeContent) => new TreeNode(treeContent); - public static readonly TreeNodeWithStringPath EmptyTree = new TreeNode(ImmutableList<(string name, TreeNodeWithStringPath component)>.Empty); + public static readonly TreeNodeWithStringPath EmptyTree = new TreeNode([]); - public IImmutableList<(IImmutableList path, ReadOnlyMemory blobContent)> EnumerateBlobsTransitive() => + public IEnumerable<(IImmutableList path, ReadOnlyMemory blobContent)> EnumerateBlobsTransitive() => this switch { BlobNode blob => ImmutableList.Create<(IImmutableList path, ReadOnlyMemory blobContent)>( @@ -135,13 +135,13 @@ public static TreeNodeWithStringPath NonSortedTree(IImmutableList<(string name, return ImmutableList.Create(treeNode); if (path.Count == 1) - return ImmutableList<(string name, TreeNodeWithStringPath component)>.Empty; + return []; var componentAfterRemoval = treeNode.component.RemoveNodeAtPath(path.Skip(1).ToImmutableArray()); if (componentAfterRemoval == null) - return ImmutableList<(string name, TreeNodeWithStringPath component)>.Empty; + return []; return ImmutableList.Create((treeNode.name, componentAfterRemoval)); }).ToImmutableList(); @@ -156,7 +156,7 @@ public TreeNodeWithStringPath SetNodeAtPathSorted(IReadOnlyList path, Tr var pathFirstElement = path[0]; - var childNodeBefore = GetNodeAtPath(new[] { pathFirstElement }); + var childNodeBefore = GetNodeAtPath([pathFirstElement]); var childNode = (childNodeBefore ?? EmptyTree).SetNodeAtPathSorted(path.Skip(1).ToImmutableList(), node); @@ -168,7 +168,7 @@ public TreeNodeWithStringPath SetNodeAtPathSorted(IReadOnlyList path, Tr _ => ImmutableList<(string name, TreeNodeWithStringPath component)>.Empty }) .Where(treeNode => treeNode.name != pathFirstElement) - .Concat(new[] { (pathFirstElement, childNode) }) + .Concat([(pathFirstElement, childNode)]) .Order(TreeEntryDefaultComparer) .ToImmutableList(); diff --git a/implement/elm-time/Pine/VolatileProcessCSharp.cs b/implement/elm-time/Pine/VolatileProcessCSharp.cs index 0aaca98f..ec1e1697 100644 --- a/implement/elm-time/Pine/VolatileProcessCSharp.cs +++ b/implement/elm-time/Pine/VolatileProcessCSharp.cs @@ -77,7 +77,7 @@ private RunResult RunScript(string script) .Where(d => d.Severity == DiagnosticSeverity.Error && d.Id == "CS0006") .ToImmutableList(); - if (metadataNotFoundErrors.Any()) + if (!metadataNotFoundErrors.IsEmpty) { var metadataNotFoundErrorsReports = metadataNotFoundErrors diff --git a/implement/elm-time/Platform/WebService/Configuration.cs b/implement/elm-time/Platform/WebService/Configuration.cs index 8fb791a2..aad347ac 100644 --- a/implement/elm-time/Platform/WebService/Configuration.cs +++ b/implement/elm-time/Platform/WebService/Configuration.cs @@ -1,4 +1,4 @@ -using ElmTime.JavaScript; +using ElmTime.JavaScript; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Configuration; @@ -15,9 +15,9 @@ public static class Configuration public static string AdminPasswordSettingKey => "adminPassword"; - public static string PublicWebHostUrlsSettingKey = "publicWebHostUrls"; + public static string PublicWebHostUrlsSettingKey => "publicWebHostUrls"; - public static string[] PublicWebHostUrlsDefault => new[] { "http://*", "https://*" }; + public static string[] PublicWebHostUrlsDefault => ["http://*", "https://*"]; /// /// https://en.wikipedia.org/wiki/Basic_access_authentication diff --git a/implement/elm-time/Platform/WebService/PersistentProcessLiveRepresentation.cs b/implement/elm-time/Platform/WebService/PersistentProcessLiveRepresentation.cs index de0542c4..b2940eb1 100644 --- a/implement/elm-time/Platform/WebService/PersistentProcessLiveRepresentation.cs +++ b/implement/elm-time/Platform/WebService/PersistentProcessLiveRepresentation.cs @@ -191,7 +191,7 @@ public static Result EnumerateCompositionLogRecordsForRestoreProcessAndLoadDependencies(storeReader) .ToImmutableList(); - if (!compositionEventsFromLatestReduction.Any()) + if (compositionEventsFromLatestReduction.IsEmpty) { var message = "Found no composition record, default to initial state."; @@ -369,7 +369,7 @@ private static Result Maybe.just( new StateShim.InterfaceToHost.StateSource.BranchStateSource("main")) : Maybe.nothing()), - stateDestinationBranches: ImmutableList.Create("main"))); + stateDestinationBranches: ["main"])); var eventString = JsonSerializer.Serialize(eventStateShimRequest); @@ -449,8 +449,8 @@ processBefore.lastElmAppVolatileProcess is null ? functionName: "migrate", arguments: new StateShim.InterfaceToHost.ApplyFunctionArguments>( stateArgument: Maybe.nothing(), - serializedArgumentsJson: ImmutableList.Create(elmAppStateBefore.Value)), - stateDestinationBranches: ImmutableList.Create("main")))); + serializedArgumentsJson: [elmAppStateBefore.Value]), + stateDestinationBranches: ["main"]))); return migrateEventResult @@ -497,7 +497,7 @@ processBefore.lastElmAppVolatileProcess is null ? var applyInitSerialInterfaceResult = InitBranchesInElmInJsProcess( newElmAppProcess, - stateDestinationBranches: ImmutableList.Create("main")); + stateDestinationBranches: ["main"]); return applyInitSerialInterfaceResult @@ -562,7 +562,7 @@ Result continueWithWebServiceEvent(InterfaceT functionName: "processEvent", arguments: new StateShim.InterfaceToHost.ApplyFunctionArguments( stateArgument: true, - serializedArgumentsJson: ImmutableList.Create(JsonSerializer.SerializeToElement(webServiceEvent))))); + serializedArgumentsJson: [JsonSerializer.SerializeToElement(webServiceEvent)]))); try { var webServiceEvent = JsonSerializer.Deserialize(asString); @@ -775,7 +775,7 @@ public static Result process: lastElmAppVolatileProcess, new AdminInterface.ApplyDatabaseFunctionRequest( functionName: "processEvent", - serializedArgumentsJson: ImmutableList.Create(serializedAppEvent), + serializedArgumentsJson: [serializedAppEvent], commitResultingState: true)) .Map(applyFunctionSuccess => { diff --git a/implement/elm-time/Platform/WebService/ProcessStoreSupportingMigrations/ProcessStoreSupportingMigrations.cs b/implement/elm-time/Platform/WebService/ProcessStoreSupportingMigrations/ProcessStoreSupportingMigrations.cs index 75b48f70..79fd18be 100644 --- a/implement/elm-time/Platform/WebService/ProcessStoreSupportingMigrations/ProcessStoreSupportingMigrations.cs +++ b/implement/elm-time/Platform/WebService/ProcessStoreSupportingMigrations/ProcessStoreSupportingMigrations.cs @@ -201,13 +201,13 @@ public class ProcessStoreInFileStore DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull }; - protected static IImmutableList CompositionHeadHashFilePath => - ImmutableList.Create("composition-log-head-hash"); + protected static ImmutableList CompositionHeadHashFilePath => + ["composition-log-head-hash"]; /// /// Use the 'literal' name to distinguish from other possible (future) representations, such as 'deflated'. /// - protected static readonly IImmutableList CompositionLogLiteralPath = ImmutableList.Create("composition-log", "literal"); + protected static readonly IReadOnlyList CompositionLogLiteralPath = ["composition-log", "literal"]; /* Distinguish literals from other kinds of representations. (derivations/recipes) @@ -223,7 +223,7 @@ Distinguish literals from other kinds of representations. (derivations/recipes) protected static readonly JsonSerializerOptions recordSerializationSettings = RecordSerializationSettings; public static IImmutableList GetFilePathForComponentInComponentFileStore(string componentHash) => - ImmutableList.Create(componentHash.Substring(0, 2), componentHash); + ImmutableList.Create(componentHash[..2], componentHash); private static readonly IComparer> CompositionLogFileOrderPathComparer = EnumerableExtension.Comparer>(); diff --git a/implement/elm-time/Platform/WebService/StartupAdminInterface.cs b/implement/elm-time/Platform/WebService/StartupAdminInterface.cs index 0eb51c88..b8116a74 100644 --- a/implement/elm-time/Platform/WebService/StartupAdminInterface.cs +++ b/implement/elm-time/Platform/WebService/StartupAdminInterface.cs @@ -46,18 +46,19 @@ public class StartupAdminInterface public static string PathApiGuiRequest => "/api/gui"; - public static IImmutableList WebServiceConfigFilePathDefault => ImmutableList.Create("web-service.json"); + public static IReadOnlyList WebServiceConfigFilePathDefault => ["web-service.json"]; - public static IImmutableList> WebServiceConfigFilePathAlternatives => - ImmutableList.Create( + public static IReadOnlyList> WebServiceConfigFilePathAlternatives => + [ WebServiceConfigFilePathDefault, /* * Support smooth migration of projects with backwards compatibility here: * Support the name used before 2023-05 as alternative. * */ - ImmutableList.Create("web-server.json"), - ImmutableList.Create("elm-fullstack.json")); + ["web-server.json"], + ["elm-fullstack.json"] + ]; private readonly ILogger logger; diff --git a/implement/elm-time/Program.cs b/implement/elm-time/Program.cs index 51ec28f2..581620e2 100644 --- a/implement/elm-time/Program.cs +++ b/implement/elm-time/Program.cs @@ -18,7 +18,7 @@ namespace ElmTime; public class Program { - public static string AppVersionId => "2023-09-11"; + public static string AppVersionId => "2023-09-12"; private static int AdminInterfaceDefaultPort => 4000; @@ -484,9 +484,9 @@ static string describeFunction( databaseFunction.functionName.Split('.').LastOrDefault(databaseFunction.functionName) + " :\n" + string.Join("\n", string.Join("", databaseFunction.functionDescription.parameters.Select(p => p.typeSourceCodeText) - .Concat(new[] { + .Concat([ databaseFunction.functionDescription.returnType.sourceCodeText + - " " + commentOnReturnType }) + " " + commentOnReturnType]) .Intersperse("\n-> ")) .Split("\n") .Select(line => " " + line)); @@ -766,7 +766,7 @@ ElmAppInterfaceConfig.Default with var compilationResult = ElmAppCompilation.AsCompletelyLoweredElmApp( sourceFiles: sourceFiles, - workingDirectoryRelative: ImmutableList.Empty, + workingDirectoryRelative: [], interfaceConfig: interfaceConfig); var compilationTimeSpentMilli = compilationStopwatch.ElapsedMilliseconds; @@ -907,7 +907,7 @@ private static CommandLineApplication AddInteractiveCommand(CommandLineApplicati .Where(r => !r.Value.result.IsOk()) .ToImmutableList(); - if (failedLoads.Any()) + if (!failedLoads.IsEmpty) { var failedLoad = failedLoads.First(); @@ -1361,12 +1361,12 @@ private static CommandLineApplication AddMakeCommand(CommandLineApplication app) if (pathToElmFile.StartsWith("./")) pathToElmFile = pathToElmFile.Substring(2); - if (!sourceDirectoriesNotInInputDirectory.Any()) + if (sourceDirectoriesNotInInputDirectory.IsEmpty) { return Result.ok( new LoadForMakeResult(loadInputDirectoryOk.tree, - ImmutableList.Empty, + [], pathToElmFile.Replace('\\', '/').Split('/'))); } @@ -1400,7 +1400,7 @@ string absoluteSourceDirectoryFromRelative(ElmJsonStructure.RelativeDirectory re absoluteSourceDirectoryFromRelative( new ElmJsonStructure.RelativeDirectory( ParentLevel: maxParentLevel, - Subdirectories: ImmutableList.Empty)); + Subdirectories: [])); IReadOnlyList pathRelativeToCommonParentFromAbsolute(string absolutePath) => absolutePath[commonParentDirectory.Length..].Replace('\\', '/').Trim('/').Split('/'); @@ -1509,7 +1509,7 @@ private record LoadForMakeResult( string outputFileName, string? elmMakeCommandAppendix) { - workingDirectoryRelative ??= ImmutableList.Empty; + workingDirectoryRelative ??= []; var pathToFileWithElmEntryPointFromWorkingDir = pathToFileWithElmEntryPoint.Skip(workingDirectoryRelative.Count).ToImmutableList(); diff --git a/implement/elm-time/Test/SelfTest.cs b/implement/elm-time/Test/SelfTest.cs index fac8f153..b63eb58d 100644 --- a/implement/elm-time/Test/SelfTest.cs +++ b/implement/elm-time/Test/SelfTest.cs @@ -74,7 +74,7 @@ public static int RunWebServerTest() processStorePath: null, adminInterfaceUrls: null, adminPassword: null, - publicAppUrls: new[] { "http://localhost:" + serverHttpPort }, + publicAppUrls: ["http://localhost:" + serverHttpPort], elmEngineType: ElmEngineType.JavaScript_V8, deletePreviousProcess: false, copyProcess: null, diff --git a/implement/elm-time/UserSecrets.cs b/implement/elm-time/UserSecrets.cs index ac1ea081..f23cb81d 100644 --- a/implement/elm-time/UserSecrets.cs +++ b/implement/elm-time/UserSecrets.cs @@ -2,7 +2,6 @@ using System; using System.Collections.Immutable; using System.IO; -using System.Linq; using System.Text; namespace ElmTime; diff --git a/implement/elm-time/elm-time.csproj b/implement/elm-time/elm-time.csproj index f91b5db8..7a2fac07 100644 --- a/implement/elm-time/elm-time.csproj +++ b/implement/elm-time/elm-time.csproj @@ -2,13 +2,14 @@ Exe - net7.0 + net8.0 ElmTime elm-time - 2023.0911.0.0 - 2023.0911.0.0 + 2023.0912.0.0 + 2023.0912.0.0 enable true + preview @@ -39,8 +40,8 @@ - - + + diff --git a/implement/native-tools/native-tools.csproj b/implement/native-tools/native-tools.csproj index 9ae071f1..1828f6bb 100644 --- a/implement/native-tools/native-tools.csproj +++ b/implement/native-tools/native-tools.csproj @@ -2,7 +2,7 @@ Exe - net7.0 + net8.0 native_tools enable true diff --git a/implement/test-elm-time/TestComposition.cs b/implement/test-elm-time/TestComposition.cs index 306ed27c..65433e26 100644 --- a/implement/test-elm-time/TestComposition.cs +++ b/implement/test-elm-time/TestComposition.cs @@ -1,6 +1,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Pine; using System; +using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; @@ -22,20 +23,16 @@ public void Composition_from_tree_with_string_path() new { input = TreeNodeWithStringPath.SortedTree( - new [] - { + [ (name: "ABC ä 😀", component: TreeNodeWithStringPath.Blob(new byte[]{0,1,2,3}) ), - }.ToImmutableList()), + ]), expectedOutput = PineValue.List( - new[] - { + [ PineValue.List( - new[] - { + [ PineValue.List( - new[] - { + [ PineValue.Blob(new byte[]{ 65 }), PineValue.Blob(new byte[]{ 66 }), PineValue.Blob(new byte[]{ 67 }), @@ -43,12 +40,12 @@ public void Composition_from_tree_with_string_path() PineValue.Blob(new byte[]{ 228 }), PineValue.Blob(new byte[]{ 32 }), PineValue.Blob(new byte[]{ 1,246,0 }), - }.ToImmutableList() + ] ), PineValue.Blob(new byte[]{0,1,2,3 } ) - }.ToImmutableList() + ] ) - }.ToImmutableList()) + ]) }, }; @@ -68,40 +65,36 @@ public void Parse_as_tree_with_string_path() new { input = PineValue.Blob(new byte[]{0,1,2}), - expectedOutput = Result, TreeNodeWithStringPath>.ok( + expectedOutput = Result, TreeNodeWithStringPath>.ok( TreeNodeWithStringPath.Blob(new byte[]{0,1,2})) }, new { input = PineValue.List( elements: - new[] - { + [ PineValue.List( elements: - new[] - { + [ PineValue.List( elements: - new [] - { + [ PineValue.Blob(new byte[] { 68 }), PineValue.Blob(new byte[] { 69 }), PineValue.Blob(new byte[] { 70 }), PineValue.Blob(new byte[] { 32 }), PineValue.Blob(new byte[]{ 1,243,50 }), - }.ToImmutableList()), + ]), PineValue.Blob(new byte[]{0,1,2,3}), - }.ToImmutableList()) - }.ToImmutableList()), - expectedOutput = Result, TreeNodeWithStringPath>.ok( + ]) + ]), + expectedOutput = Result, TreeNodeWithStringPath>.ok( TreeNodeWithStringPath.SortedTree( treeContent: - new [] - { + [ (name: "DEF 🌲", component: TreeNodeWithStringPath.Blob(new byte[]{0,1,2,3}) ), - }.ToImmutableList()) + ]) ) }, }; @@ -129,68 +122,58 @@ public void Composition_from_file_tree() }, expectedOutput = PineValue.List( elements: - new [] - { + [ PineValue.List( elements: - new [] - { + [ PineValue.List( elements: - new [] - { + [ PineValue.Blob(new byte[] { 97 }), - }.ToImmutableList()), + ]), PineValue.Blob(new byte[]{0,1,2}), - }.ToImmutableList()), + ]), PineValue.List( elements: - new [] - { + [ PineValue.List( elements: - new [] - { + [ PineValue.Blob(new byte[] { 98 }), - }.ToImmutableList() + ] ), PineValue.List( elements: - new [] - { + [ PineValue.List( elements: - new [] - { + [ PineValue.List( elements: - new [] - { + [ PineValue.Blob(new byte[] { 99 }), - }.ToImmutableList() + ] ), PineValue.Blob(new byte[]{3,4,5,6}), - }.ToImmutableList() + ] ), PineValue.List( elements: - new [] - { + [ PineValue.List( elements: - new [] - { + [ PineValue.Blob(new byte[] { 100 }), - }.ToImmutableList() + ] ), PineValue.Blob(new byte[]{7,8}), - }.ToImmutableList() + ] ), - }.ToImmutableList() + ] ) - }.ToImmutableList() + ] ), - }.ToImmutableList()) + ]) }, }; @@ -301,7 +284,7 @@ public void Tree_with_string_path_sorting() { input = TreeNodeWithStringPath.NonSortedTree( treeContent: - ImmutableList.Create( + [ ("ba-", TreeNodeWithStringPath.Blob(new byte[]{ 0 })), ("ba", TreeNodeWithStringPath.Blob(new byte[] { 1 })), ("bb", TreeNodeWithStringPath.Blob(new byte[] { 2 })), @@ -320,11 +303,11 @@ public void Tree_with_string_path_sorting() ) )), ("bA", TreeNodeWithStringPath.Blob(new byte[] { 12 })) - ) + ] ), expected = TreeNodeWithStringPath.NonSortedTree( treeContent: - ImmutableList.Create( + [ ("", TreeNodeWithStringPath.Blob(new byte[] { 7 })), ("a", TreeNodeWithStringPath.Blob(new byte[] { 3 })), ("bA", TreeNodeWithStringPath.Blob(new byte[] { 12 })), @@ -333,17 +316,17 @@ public void Tree_with_string_path_sorting() ("bb", TreeNodeWithStringPath.Blob(new byte[] { 2 })), ("c", TreeNodeWithStringPath.NonSortedTree( treeContent: - ImmutableList.Create( + [ ("alpha", TreeNodeWithStringPath.Blob(new byte[] { 11 })), ("gamma", TreeNodeWithStringPath.Blob(new byte[] { 10 })) - ) + ] )), ("testa", TreeNodeWithStringPath.Blob(new byte[] { 5 })), ("test😃", TreeNodeWithStringPath.Blob(new byte[] { 4 })), ("tesz", TreeNodeWithStringPath.Blob(new byte[] { 6 })), ("🌲", TreeNodeWithStringPath.Blob(new byte[] { 9 })), ("🌿", TreeNodeWithStringPath.Blob(new byte[] { 8 })) - ) + ] ), } }; diff --git a/implement/test-elm-time/TestDemoBackendState.cs b/implement/test-elm-time/TestDemoBackendState.cs index 1df2126c..ed8785f4 100644 --- a/implement/test-elm-time/TestDemoBackendState.cs +++ b/implement/test-elm-time/TestDemoBackendState.cs @@ -1,5 +1,6 @@ using ElmTime; using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; @@ -13,14 +14,14 @@ public void Test_demo_backend_state() { var sourceFiles = TestSetup.GetElmAppFromDirectoryPath( - ImmutableList.Create(".", "..", "..", "..", "..", "example-apps", "demo-backend-state")); + (IReadOnlyList)[".", "..", "..", "..", "..", "example-apps", "demo-backend-state"]); var webAppSource = TestSetup.AppConfigComponentFromFiles(sourceFiles); var compilationResult = ElmAppCompilation.AsCompletelyLoweredElmApp( sourceFiles: sourceFiles, - workingDirectoryRelative: ImmutableList.Empty, + workingDirectoryRelative: [], interfaceConfig: ElmAppInterfaceConfig.Default); var compilationSuccess = diff --git a/implement/test-elm-time/TestElmInteractive.cs b/implement/test-elm-time/TestElmInteractive.cs index 30b380cb..2349748b 100644 --- a/implement/test-elm-time/TestElmInteractive.cs +++ b/implement/test-elm-time/TestElmInteractive.cs @@ -33,7 +33,7 @@ public void TestElmInteractiveScenarios() if (!Directory.EnumerateFiles(scenarioDirectory, "*", searchOption: SearchOption.AllDirectories).Any()) { // Do not stumble over empty directory here. It could be a leftover after git checkout. - return ImmutableList<(string scenarioName, string scenarioDirectory)>.Empty; + return []; } return ImmutableList.Create((scenarioName, scenarioDirectory)); @@ -86,7 +86,7 @@ public void TestElmInteractiveScenarios() } } - if (failedScenarios.Any()) + if (!failedScenarios.IsEmpty) { throw new Exception( "Failed for " + failedScenarios.Count + " scenarios:\n" + diff --git a/implement/test-elm-time/TestModeledInElm.cs b/implement/test-elm-time/TestModeledInElm.cs index e737e20e..53b4753d 100644 --- a/implement/test-elm-time/TestModeledInElm.cs +++ b/implement/test-elm-time/TestModeledInElm.cs @@ -1,7 +1,6 @@ using ElmTime; using ElmTime.Elm019; using ElmTime.JavaScript; -using JavaScriptEngineSwitcher.V8; using Microsoft.VisualStudio.TestTools.UnitTesting; using System; using System.Collections.Generic; diff --git a/implement/test-elm-time/TestPineVM.cs b/implement/test-elm-time/TestPineVM.cs index 5eaea1ea..1c9a7269 100644 --- a/implement/test-elm-time/TestPineVM.cs +++ b/implement/test-elm-time/TestPineVM.cs @@ -2,7 +2,6 @@ using Pine; using Pine.PineVM; using System; -using System.Collections.Immutable; namespace TestElmTime; @@ -22,19 +21,17 @@ public void Evaluate_expression() }, new { - expression = (Expression)new Expression.ListExpression(ImmutableArray.Empty), - expected = Result.ok( - PineValue.List(ImmutableList.Empty)) + expression = (Expression)new Expression.ListExpression([]), + expected = Result.ok(PineValue.EmptyList) }, new { expression = (Expression)PineVM.DecodeKernelApplicationExpression ( functionName: "concat", - argument: new Expression.ListExpression(ImmutableArray.Empty) + argument: new Expression.ListExpression([]) ).Extract(fromErr: err => throw new Exception(err)), - expected = Result.ok( - PineValue.List(ImmutableList.Empty)) + expected = Result.ok(PineValue.EmptyList) } }; @@ -44,7 +41,7 @@ public void Evaluate_expression() var evaluated = pineVM.EvaluateExpression( testCase.expression, - PineValue.List(ImmutableList.Empty)); + PineValue.EmptyList); Assert.AreEqual(testCase.expected, evaluated); } diff --git a/implement/test-elm-time/TestProcessStoreSupportingMigrations.cs b/implement/test-elm-time/TestProcessStoreSupportingMigrations.cs index 6d0848e1..05f03c05 100644 --- a/implement/test-elm-time/TestProcessStoreSupportingMigrations.cs +++ b/implement/test-elm-time/TestProcessStoreSupportingMigrations.cs @@ -27,6 +27,6 @@ public void Test_ProjectFileStoreReaderForAppendedCompositionLogEvent() var compositionLogRecords = processStoreReader.EnumerateSerializedCompositionLogRecordsReverse().ToImmutableList(); - Assert.IsTrue(compositionLogRecords.Any()); + Assert.IsTrue(!compositionLogRecords.IsEmpty); } } diff --git a/implement/test-elm-time/TestSetup.cs b/implement/test-elm-time/TestSetup.cs index e181d450..0862052a 100644 --- a/implement/test-elm-time/TestSetup.cs +++ b/implement/test-elm-time/TestSetup.cs @@ -80,11 +80,11 @@ public static IImmutableDictionary, ReadOnlyMemory> public static IImmutableDictionary, ReadOnlyMemory> GetElmAppFromExampleName( string exampleName) => GetElmAppFromDirectoryPath(Path.Combine(PathToExampleElmApps, exampleName)); - private static string FilePathStringFromPath(IImmutableList path) => + private static string FilePathStringFromPath(IReadOnlyList path) => Path.Combine(path.ToArray()); public static IImmutableDictionary, ReadOnlyMemory> GetElmAppFromDirectoryPath( - IImmutableList directoryPath) => + IReadOnlyList directoryPath) => GetElmAppFromDirectoryPath(FilePathStringFromPath(directoryPath)); public static IImmutableDictionary, ReadOnlyMemory> GetElmAppFromDirectoryPath( diff --git a/implement/test-elm-time/WebHostAdminInterfaceTestSetup.cs b/implement/test-elm-time/WebHostAdminInterfaceTestSetup.cs index 041f4cde..d4295027 100644 --- a/implement/test-elm-time/WebHostAdminInterfaceTestSetup.cs +++ b/implement/test-elm-time/WebHostAdminInterfaceTestSetup.cs @@ -44,7 +44,7 @@ public IWebHost StartWebHost( (webHostBuilderMap ?? (builder => builder)) (Microsoft.AspNetCore.WebHost.CreateDefaultBuilder() .UseUrls(AdminWebHostUrl) - .WithSettingPublicWebHostUrls(new[] { PublicWebHostUrl }) + .WithSettingPublicWebHostUrls([PublicWebHostUrl]) .WithSettingAdminPassword(adminPassword) .UseStartup() .WithProcessStoreFileStore(processStoreFileStoreMap?.Invoke(fileStore) ?? fileStore)) diff --git a/implement/test-elm-time/WebServiceTests.cs b/implement/test-elm-time/WebServiceTests.cs index ab1c8cec..6fb73428 100644 --- a/implement/test-elm-time/WebServiceTests.cs +++ b/implement/test-elm-time/WebServiceTests.cs @@ -202,9 +202,9 @@ IEnumerable EnumerateStoredProcessEventsHttpRequestsBodies() => { ElmTime.Platform.WebService.InterfaceToHost.BackendEventStruct.HttpRequestEvent httpRequestEvent => httpRequestEvent.Struct.request.bodyAsBase64 - .Map(bodyAsBase64 => ImmutableList.Create(bodyAsBase64)).WithDefault(ImmutableList.Empty), + .Map(bodyAsBase64 => ImmutableList.Create(bodyAsBase64)).WithDefault([]), - _ => ImmutableList.Empty + _ => [] }) .Select(bodyBase64 => System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(bodyBase64))); @@ -302,9 +302,9 @@ IEnumerable EnumerateStoredProcessEventsHttpRequestsBodies() => ElmTime.Platform.WebService.InterfaceToHost.BackendEventStruct.HttpRequestEvent httpRequestEvent => httpRequestEvent.Struct.request.bodyAsBase64 .Map(bodyAsBase64 => ImmutableList.Create(bodyAsBase64)) - .WithDefault(ImmutableList.Empty), + .WithDefault([]), - _ => ImmutableList.Empty + _ => [] }) .Select(bodyBase64 => System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(bodyBase64))); diff --git a/implement/test-elm-time/test-elm-time.csproj b/implement/test-elm-time/test-elm-time.csproj index 16b8ca0d..4399f936 100644 --- a/implement/test-elm-time/test-elm-time.csproj +++ b/implement/test-elm-time/test-elm-time.csproj @@ -1,12 +1,13 @@ - net7.0 + net8.0 TestElmTime false enable + preview @@ -17,8 +18,8 @@ - - + + runtime; build; native; contentfiles; analyzers; buildtransitive all