diff --git a/.gitignore b/.gitignore index d83b6fb..30ef3b4 100644 --- a/.gitignore +++ b/.gitignore @@ -482,3 +482,4 @@ $RECYCLE.BIN/ *.swp coveragereport/ +*.csproj.lscache diff --git a/CHANGELOG.md b/CHANGELOG.md index 68d7971..aa6e3bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,13 @@ The format is based on Keep a Changelog. ## [Unreleased] +## [2.0.1] - 2026-06-02 + +### Fix + +- **Esolang.Interpreter.Abstractions** / **Esolang.Processor.Abstractions** / **Esolang.Processor.Extensions.IO** : + - add AOT compatibility settings for net10.0 target framework + ## [2.0.0] - 2026-06-02 ### Added @@ -17,13 +24,16 @@ The format is based on Keep a Changelog. - **Esolang.Generator.Abstractions**: - Added comprehensive abstractions for method signature binding and type resolution. - Introduced `MethodSignatureBinder` for mapping esolang source to C# partial methods. + - Added `KnownTypes` for standardized Roslyn type resolution. + - Added `BindingError` record hierarchy for type-safe diagnostic reporting. - Added `MethodInputKind`, `MethodOutputKind`, and `MethodReturnKind` for signature classification. - **Esolang.Interpreter.Abstractions**: - Added new project for common interpreter utilities. - Introduced `RunToConsoleAsync` extension method for running processors with standard console I/O. - **Esolang.Processor.Extensions.IO**: - Extracted and standardized I/O extension methods into a dedicated project. - - Added support for `TextReader`/`TextWriter`, `string`/`StringBuilder`, and `System.IO.Pipelines` (`PipeReader`/`PipeWriter`). + - Added `RunToEndAsync` overloads for `TextReader`/`TextWriter`, `string`/`StringBuilder`, and `PipeReader`/`PipeWriter`. + - Added `RunToStringAsync` for capturing output as a string. - Enhanced testing infrastructure across all abstraction projects, significantly improving code coverage. ### Changed @@ -45,6 +55,7 @@ The format is based on Keep a Changelog. - Both text and pipe processors return exit codes (`int`) from execution. - Support for optional `CancellationToken` on all execution methods. -[Unreleased]: https://github.com/Esolang-NET/Abstractions/compare/v2.0.0...HEAD +[Unreleased]: https://github.com/Esolang-NET/Abstractions/compare/v2.0.1...HEAD +[2.0.1]: https://github.com/Esolang-NET/Abstractions/tree/v2.0.1 [2.0.0]: https://github.com/Esolang-NET/Abstractions/tree/v2.0.0 [1.0.0]: https://github.com/Esolang-NET/Abstractions/tree/v1.0.0 diff --git a/Directory.Build.props b/Directory.Build.props index 57569ca..8cbd7f6 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -4,8 +4,8 @@ enable 14 2.0.0.2 - 2.0.0.2 - 2.0.0 + 2.0.1.2 + 2.0.1 https://github.com/Esolang-NET/Abstractions/ https://github.com/Esolang-NET/Abstractions.git true diff --git a/Generator.Abstractions/README.md b/Generator.Abstractions/README.md index 4c685fa..389b12a 100644 --- a/Generator.Abstractions/README.md +++ b/Generator.Abstractions/README.md @@ -18,6 +18,10 @@ This package provides common interfaces, types, and binder utilities for impleme The `MethodSignatureBinder` is a core utility that facilitates mapping esolang source code to C# partial method signatures. It handles the identification of input, output, and return patterns to generate appropriate boilerplate. +### KnownTypes + +The `KnownTypes` struct provides a standardized way to resolve and compare common esolang types (like `PipeReader`, `TextWriter`, etc.) within a Roslyn `Compilation`. + ### Binding Kinds To support diverse esolang execution models, several "Kind" enums are provided to classify method signatures: @@ -25,3 +29,7 @@ To support diverse esolang execution models, several "Kind" enums are provided t - **MethodInputKind**: Classifies how the esolang receives input (e.g., `TextReader`, `PipeReader`, `byte[]`, or none). - **MethodOutputKind**: Classifies how the esolang sends output (e.g., `TextWriter`, `PipeWriter`, `StringBuilder`, or none). - **MethodReturnKind**: Determines the method's return pattern (e.g., `void`, `string`, `int`, `Task`, `IEnumerable`, `IAsyncEnumerable`). + +### Diagnostic Handling + +- **BindingError**: A type-safe record hierarchy representing diagnostic errors encountered during the binding process (e.g., `UnsupportedReturnType`, `DuplicateInput`, `ReturnOutputConflict`). diff --git a/Interpreter.Abstractions/Esolang.Interpreter.Abstractions.csproj b/Interpreter.Abstractions/Esolang.Interpreter.Abstractions.csproj index 346f679..fb6f3d0 100644 --- a/Interpreter.Abstractions/Esolang.Interpreter.Abstractions.csproj +++ b/Interpreter.Abstractions/Esolang.Interpreter.Abstractions.csproj @@ -7,6 +7,8 @@ README.md esolang;interpreter;abstractions;interface;execution;runtime Esolang.Interpreter + true + true diff --git a/Processor.Abstractions/Esolang.Processor.Abstractions.csproj b/Processor.Abstractions/Esolang.Processor.Abstractions.csproj index 023ced3..280cd4c 100644 --- a/Processor.Abstractions/Esolang.Processor.Abstractions.csproj +++ b/Processor.Abstractions/Esolang.Processor.Abstractions.csproj @@ -1,7 +1,7 @@ - netstandard2.0;netstandard2.1 + netstandard2.0;netstandard2.1;net10.0 enable true Core interfaces and unified abstractions for esolang execution models, providing event-driven I/O processing standards. @@ -10,6 +10,10 @@ esolang;processor;abstractions;interface;execution;event-driven;io Esolang.Processor + + true + true + diff --git a/Processor.Extensions.IO/Esolang.Processor.Extensions.IO.csproj b/Processor.Extensions.IO/Esolang.Processor.Extensions.IO.csproj index ebbab3b..f176066 100644 --- a/Processor.Extensions.IO/Esolang.Processor.Extensions.IO.csproj +++ b/Processor.Extensions.IO/Esolang.Processor.Extensions.IO.csproj @@ -1,7 +1,7 @@ - netstandard2.0;netstandard2.1 + netstandard2.0;netstandard2.1;net10.0 enable true Comprehensive I/O extension methods for IEventProcessor, supporting TextReader/Writer, System.IO.Pipelines, and string-based execution. @@ -11,6 +11,11 @@ Esolang.Processor.Extensions.IO + + true + true + + diff --git a/Processor.Extensions.IO/TextProcessorExtensions.cs b/Processor.Extensions.IO/TextProcessorExtensions.cs index 4d61bac..97acb65 100644 --- a/Processor.Extensions.IO/TextProcessorExtensions.cs +++ b/Processor.Extensions.IO/TextProcessorExtensions.cs @@ -37,7 +37,7 @@ public static async ValueTask RunToEndAsync( int read; do { -#if NETSTANDARD2_1_OR_GREATER +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_1_OR_GREATER read = await input.ReadAsync(buffer.AsMemory(0, 1), cancellationToken).ConfigureAwait(false); #else read = await input.ReadAsync(buffer, 0, 1).ConfigureAwait(false); @@ -57,7 +57,11 @@ public static async ValueTask RunToEndAsync( if (input is null) throw new ArgumentNullException(nameof(input)); { - var inputString = await input.ReadLineAsync(); +#if NET7_0_OR_GREATER + var inputString = await input.ReadLineAsync(cancellationToken).ConfigureAwait(false); +#else + var inputString = await input.ReadLineAsync().ConfigureAwait(false); +#endif if (int.TryParse(inputString, out var i)) { intInput.Write(i); @@ -68,16 +72,50 @@ public static async ValueTask RunToEndAsync( if (output is null) throw new ArgumentNullException(nameof(output)); { +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_1_OR_GREATER + var buffer =ArrayPool.Shared.Rent(1); + buffer.AsSpan(0, 1)[0] = charOutput.Output; + try { + await output.WriteAsync(buffer.AsMemory(0, 1), cancellationToken).ConfigureAwait(false); + } finally + { + ArrayPool.Shared.Return(buffer); + } +#else await output.WriteAsync(charOutput.Output).ConfigureAwait(false); +#endif +#if NET8_0_OR_GREATER + await output.FlushAsync(cancellationToken).ConfigureAwait(false); +#else await output.FlushAsync().ConfigureAwait(false); +#endif + } break; case OutputIntEvent intOutput: if (output is null) throw new ArgumentNullException(nameof(output)); { +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_1_OR_GREATER + var outputString = intOutput.Output.ToString(); + var span = intOutput.Output.ToString().AsSpan(); + var buffer =ArrayPool.Shared.Rent(span.Length); + var memory = buffer.AsMemory(0, span.Length); + span.CopyTo(memory.Span); + try { + await output.WriteAsync(memory, cancellationToken).ConfigureAwait(false); + } finally + { + ArrayPool.Shared.Return(buffer); + } +#else await output.WriteAsync(intOutput.Output.ToString()).ConfigureAwait(false); +#endif +#if NET8_0_OR_GREATER + await output.FlushAsync(cancellationToken).ConfigureAwait(false); +#else await output.FlushAsync().ConfigureAwait(false); +#endif } break; case EndEvent endEvent: