Commit Graph

39 Commits

Author SHA1 Message Date
Loretta b1cdf80fad Fix SignalR binary protocol: VarUInt framing & type-safe ser
- Add type-explicit ToBinary/SerializeToBinary overloads to preserve runtime type info for object? serialization, fixing deserialization bugs.
- Refactor VarUInt encoding/decoding to a prefix-tiered scheme (1–5 bytes), replacing LEB128 and preventing buffer overrun/corruption.
- Update all SignalR and serialization call sites to use new overloads.
- Sync SignalR binary protocol VarUInt decoding logic; fix test regressions.
- Add SIGNALR_BINARY_PROTOCOL_VARUINT.md with new wire-format spec and rationale.
- Add debug logging for argument serialization.
- Update .gitignore to not ignore itself.
- Resolves 65 KB value cap and missing in-band abort marker; requires both sender/receiver to use new framing for full compatibility.
2026-05-27 05:47:23 +02:00
Loretta 8b8abb7cbc [LOADED_DOCS: .github\copilot-instructions.md]
Refactor SignalR protocol registration; add DI options

- Added AcSignalRServerProtocolExtensions and AcSignalRProtocolExtensions for idiomatic AddAcBinaryProtocol registration (server/client), using a shared BuildProtocol factory for DI/IOptions/inline config.
- Introduced AcHubConnectionOptions and AcSignalRConnectionExtensions for configuration-driven client setup.
- Refactored AcSignalRClientBase to require a preconfigured IHubConnectionBuilder, moving all connection/protocol config out of the base class.
- Removed legacy protocol constructors; all protocol instantiation is now options-based.
- Enforced WASM + AsyncSegment guard in AcBinaryHubProtocolOptions.Validate.
- Updated SIGNALR_BINARY_PROTOCOL.md and GLOSSARY.md for new DI/config patterns.
- Minor: updated settings.local.json with new DLL/plugin inspection commands.
2026-04-22 22:44:37 +02:00
Loretta 71ccff3ad4 [LOADED_DOCS: NONE]
Enhance logging for SignalR binary protocol and flush logic

- Added detailed LogInformation calls in AcBinaryHubProtocol for serialization/deserialization start/end, including chunked and non-chunked paths.
- Switched some LogInformation to LogDebug for chunk state and parsing to reduce verbosity.
- Improved chunked message logging with total sent size, chunk count, and data bytes.
- Removed .Forget() on _lastFlush in AsyncPipeWriterOutput to prevent double-await, with updated comments.
- Increased default Microsoft log level to Information in AcSignalRClientBase.
2026-04-20 07:10:03 +02:00
Loretta fe2fef55da [LOADED_DOCS: NONE]
Raise SignalR client log level to Warning

Changed the minimum log level for Microsoft.Extensions.Logging in the SignalR client configuration from Debug to Warning. This reduces log verbosity by only outputting messages with a severity of Warning or higher.
2026-04-19 18:42:16 +02:00
Loretta 82a407ff82 Chunked framing for AsyncSegment: zero-copy SignalR ser/deser
Implement self-describing chunked protocol ([201][UINT16][data], [202] end) for AsyncSegment mode, enabling true zero-copy, pipeline-parallel serialization/deserialization of large arguments in SignalR.
- AsyncPipeWriterOutput now reserves a 3-byte header per chunk and supports two backpressure modes.
- AcBinaryHubProtocol routes streamable arguments through WriteMessageChunked, with chunk accumulation and background deserialization on the receiver.
- Logging now uses ILogger; documentation and wire format details updated.
- Consumer code updated to use new mode and diagnostics.
- Improves throughput, memory usage, and maintainability for large payloads.
2026-04-11 10:35:03 +02:00
Loretta 83350e43f6 Refactor: clarify and implement protocol serialization modes
Refactored binary protocol to support three explicit serialization/transport strategies via BinaryProtocolMode: Bytes (byte[]), Segment (zerocopy PipeWriter), and AsyncSegment (async PipeWriter with pipeline parallelism). Updated AcBinaryHubProtocol and AyCodeBinaryHubProtocol to select serialization/deserialization paths based on mode. Improved documentation and XML comments to describe each mode's behavior and performance. DI registration now explicitly selects AsyncSegment mode for AyCodeBinaryHubProtocol. Default remains Bytes mode. These changes clarify protocol mechanics and enable better performance tuning.
2026-04-10 16:10:28 +02:00
Loretta f825552ae2 Refactor SignalR binary protocol for extensibility
- Move SignalParams-aware deserialization logic from AcBinaryHubProtocol to new AyCodeBinaryHubProtocol, enabling project-specific customization.
- Make key deserialization and helper methods in AcBinaryHubProtocol protected and virtual for easier extension.
- Improve byte[] handling to distinguish between AcBinary-serialized and raw data.
- Remove diagnostic serialization verification from the base protocol.
- Update DI registration to use AyCodeBinaryHubProtocol with configurable options.
- Adjust client code to support object-based response data and raw byte handling.
- Comment out SignalResponseDataMessage diagnostic logger in Program.cs.
2026-04-09 08:12:50 +02:00
Loretta 55e53c248f Improve string serialization and buffer preallocation
- Add VarUIntSize and unsafe VarUInt writers for efficient buffer sizing and writing without redundant checks.
- Update WriteStringUtf8 to preallocate for VarUInt and string body in one step, reducing reallocations and risk of overflow.
- Change ArrayBinaryOutput default initial capacity to 65535.
- Use BufferWriterChunkSize from options in AcBinarySerializer.
- Fix typo in AcBinarySerializerOptions.
- Set SignalR client log level to Warning by default.
2026-04-08 09:50:46 +02:00
Loretta d060508bd8 Add diagnostics for binary SignalR serialization bugs
Enhances debugging of custom binary serialization/deserialization in SignalR by introducing DiagnosticLogger hooks in both AcBinaryDeserializer and AcBinaryHubProtocol. Adds DEBUG-only verification methods to compare array-based and multi-segment deserialization, as well as IBufferWriter and byte[] serialization outputs, logging mismatches for easier bug isolation. Diagnostic loggers are automatically integrated with the hub and client loggers. Also includes extra debug output and a commented workaround for a known serialization issue. Diagnostics are opt-in and only active in DEBUG builds.
2026-04-07 20:53:20 +02:00
Loretta 26c8cd85ce Refactor BenchmarkTestDataProvider for flexibility & clarity
Moved BenchmarkTestDataProvider and TestDataSet to AyCode.Core.Tests.TestModels with public accessibility. Refactored dataset creation methods to accept a resetId parameter, allowing control over TestDataFactory ID resets. Improved code structure, formatting, and documentation for maintainability. The provider is now more flexible and easier to use in tests.
2026-04-07 14:27:12 +02:00
Loretta 91194fcfa3 Refactor SignalR protocol for zero-copy, typed deserialization
- Change OnReceiveMessage signature to use `object data` (was `SignalData`), enabling type-aware and raw byte[] payloads.
- Implement three-path argument deserialization: byte[] fast-path, IsRawBytesData, and eager typed deserialization via SignalDataType.
- Add SignalDataType and IsRawBytesData fields to SignalParams for protocol guidance.
- Write path now uses AcBinarySerializer zero-copy to pipe; byte[] uses fast-path.
- SequenceBinaryInput now dynamically sizes scratch buffer for large cross-segment reads.
- Deserializer now advances segments before throwing end-of-buffer, improving multi-segment support.
- Set client logging to Debug for better diagnostics.
- Update all docs and markdown to reflect new protocol, dispatch model, and field semantics.
- AyCodeBinaryHubProtocol is now an empty derived class for registration/future hooks; SignalData is no longer the primary payload type.
- SignalResponseDataMessage is now an internal DTO with RawResponseData as object? (typed or byte[]), and GetResponseData<T>() is a direct cast.
2026-04-07 03:10:09 +02:00
Loretta 05808d0d13 SignalR: Add raw byte[] fast-path for DataSource GetAll
Implements a high-performance raw byte[] protocol path for SignalR DataSource GetAll/LoadDataSource, using a new IsRawBytesData flag in SignalParams. When enabled, the server pre-serializes response data and sends it as a byte array, which the protocol passes through without further (de)serialization. The client receives the raw bytes and deserializes as needed, avoiding double serialization/deserialization and improving performance for large payloads.

Adds SerializerType selection to DataSource, propagates SignalParams through hub and protocol layers, and updates client/server/test code to support the new path. Also includes diagnostics flags for binary serialization debugging and fixes for multi-segment buffer handling.
2026-04-07 00:20:52 +02:00
Loretta 2d04b9f8f6 Zero-copy SignalR: direct object response, no SignalData
Major overhaul for SignalR response pipeline:
- All deserialization now uses byte[] (offset/length) for zero-copy, allocation-free operation; all span/memory overloads removed.
- SignalR protocol sends (signalParams, object) directly; SignalData envelope and related logic removed.
- Server sets SignalParams.SignalDataType so protocol deserializes to the correct runtime type on the client.
- SignalResponseDataMessage now only used for client request/response tracking and stream path; RawResponseData holds the actual object.
- All extension methods, helpers, and infrastructure updated to use new byte[]-based APIs.
- AcSignalRDataSource and all test/benchmark code updated for new object flow.
- Removes all diagnostics, logging, and error handling related to binary envelopes.
- Enables true zero-copy, type-safe, allocation-free SignalR response handling.
2026-04-06 22:45:00 +02:00
Loretta d147398698 Switch SignalR payloads to ArrayPool-backed SignalData
Major protocol refactor: all byte[] payloads in SignalR hub/client interfaces, plumbing, and DTOs are now wrapped in SignalData, a disposable, ArrayPool-backed type with Span access. Introduces AyCodeBinaryHubProtocol (derived from AcBinaryHubProtocol) to rent pooled buffers for SignalData on receive. All message signatures, diagnostics, and serialization logic updated. Documentation and tests revised to reflect SignalData usage. Enables zero-copy, low-GC, high-performance binary messaging for large payloads.
2026-04-06 11:17:02 +02:00
Loretta 3b7007002a Refactor SignalR param handling: SignalParams replaces old
Major protocol/API change: replace SignalReceiveParams with SignalParams everywhere. SignalParams now carries packed method parameters as a single byte[] and provides SetParameterValues/GetParameterValues for type-safe packing/unpacking. All hub/client interfaces, method signatures, and dispatch logic updated. Legacy parameter serialization helpers removed; all parameter logic is encapsulated in SignalParams. Documentation and tests updated to reflect new wire format and flow. This unifies parameter handling, clarifies the protocol, and enables robust, extensible type-guided serialization. Breaking change.
2026-04-06 08:49:12 +02:00
Loretta cdd54d3196 Refactor SignalR param serialization to pure binary format
Replaces legacy JSON-in-Binary parameter envelopes with a length-prefixed, per-parameter binary format for all client→server calls. Introduces SerializeParametersToBinary and DeserializeParametersFromBinary for type-safe, zero-copy parameter handling. Marks IdMessage, SignalPostJsonDataMessage, and related wrappers as obsolete. Updates all client CRUD/messaging helpers and server-side dispatch to use object[] binary serialization. Adds DataSerializerType to SignalReceiveParams for response format indication. Updates tests and documentation to reflect new protocol. BREAKING CHANGE: not compatible with previous JSON-in-Binary clients/servers.
2026-04-05 17:21:38 +02:00
Loretta 32018e906a Refactor SignalR: separate metadata and payload transport
Major protocol update: OnReceiveMessage now takes metadata (SignalReceiveParams) and payload (byte[]) as separate hub arguments, not a single envelope. Metadata is AcBinary-serialized; payload uses protocol fast-path. Updated all client/server code, interfaces, and docs. Added ISignalParams and SignalReceiveParams types. Improved AcBinaryHubProtocol diagnostics and made byte[] fast-path more robust. This enables clearer, more debuggable, and future-proof SignalR binary messaging.
2026-04-05 09:30:54 +02:00
Loretta f06bd5004d Remove client-to-server streaming support in SignalR client
Removed OnReceiveStreamMessage from both AcSignalRClientBase and IAcSignalRHubBase, eliminating client-to-server streaming support. Updated StreamAsync calls to use the explicit method name string. This change enforces server-to-client streaming only and cleans up related interface and method references.
2026-04-05 00:30:05 +02:00
Loretta a120cd65ff Optimize serialization lookups; add SignalR binary toggle
- Cache wrapper/metadata in serialization bridge methods to avoid redundant GetType and GetWrapper calls, improving performance.
- Update source generator to combine null/depth checks and cache depthExceeded for collections.
- Add useAcBinaryProtocol option to AcSignalRClientBase, allowing binary protocol to be toggled via constructor and registered via DI.
- Update documentation to reflect new caching rules and performance improvements.
2026-04-04 23:22:47 +02:00
Loretta 0cb2b6c2d8 SignalR: Add streaming & zero-copy binary protocol
- Introduce OnReceiveStreamMessage for server/client streaming via IAsyncEnumerable<byte[]>
- AcBinaryHubProtocol: switch argument framing to INT32, enable direct zero-copy serialization to SignalR pipe
- Optimize byte[] argument handling (fast-path, no extra alloc)
- BufferWriterBinaryOutput: support configurable chunk size, add FlushAndReset
- AcBinarySerializer: IBufferWriter overload returns bytes written
- Update docs for streaming, protocol, and performance guidance
- Minor refactoring, add InternalsVisibleTo, improve comments
2026-04-04 00:47:48 +02:00
Loretta 1a77ee4bf9 Refactor serializer options, string fast paths & analysis
- Refactor all serializer options to use properties returning new instances (no shared mutable state); update all usages accordingly
- Extract AcSerializerOptions, BinaryTypeCode, and BinaryPropertyFilterContext to dedicated files for clarity and reuse
- Add DEBUG-only string interning analysis/reporting tools to AcBinarySerializer
- Improve AcBinarySerializer string property serialization with direct typed getter and SIMD-optimized ASCII path
- Increase benchmark/test warmup iterations and add JIT warmup delays for more reliable performance measurements
- Remove redundant usings and update documentation/comments throughout
- No breaking API changes, but static readonly options fields are now properties
2026-01-25 16:40:40 +01:00
Loretta 63ab695a0b Refactor: Rename and reorganize serializer metadata classes
Replaces BinaryTypeMetadata, JsonTypeMetadata, and ToonTypeMetadata with BinarySerializeTypeMetadata, JsonSerializeTypeMetadata, and ToonSerializeTypeMetadata, moving each to its own file. Updates all references and documentation to use new names. Property accessor classes are retained and relocated. Also sets SignalR logging minimum level to Error. No changes to serialization logic; this is a structural/naming refactor for clarity and separation of concerns.
2026-01-17 09:20:06 +01:00
Loretta bbb21dbb67 Add Toon serializer: LLM-optimized format & rich metadata
Introduces Toon (Token-Oriented Object Notation), a new serialization format designed for LLM readability and token efficiency. Adds core Toon serializer, options, attribute system (ToonDescriptionAttribute), and comprehensive documentation. Supports explicit type metadata, smart fallback/placeholder logic, multi-turn workflows, reference handling, and multi-line strings. No breaking changes; Toon is opt-in and complements existing JSON/binary serializers.
2026-01-10 20:13:54 +01:00
Loretta 4b2d3f4e75 Add opt-in binary diagnostics for SignalR serialization
Introduces detailed, opt-in diagnostic logging for binary serialization and deserialization in SignalR server and client code. Adds type and binary-level diagnostics, including hex dumps and header parsing, to aid debugging of protocol and type mismatches. Improves string hash function in the binary deserializer to avoid collisions. Diagnostics are consistent and structured, and can be enabled independently on server, client, and response message classes. No impact on normal operation unless diagnostics are enabled.
2025-12-20 08:43:22 +01:00
Loretta bc30a3aede Refactor: Add high-perf JSON serializer & merge support
- Introduced AcJsonSerializer/AcJsonDeserializer in AyCode.Core.Serializers.Jsons, optimized for IId<T> reference and circular reference handling.
- Added AcJsonSerializerOptions/AcSerializerOptions for configurable reference handling and max depth.
- Implemented fast-path streaming (Utf8JsonReader/Writer) with fallback to DOM for reference scenarios.
- Added type metadata/property accessor caching for performance.
- Provided robust object/collection population with merge semantics for IId<T> collections.
- Added AcJsonDeserializationException for detailed error reporting.
- Implemented UnifiedMergeContractResolver for Newtonsoft.Json, supporting JsonNoMergeCollectionAttribute to control merge behavior.
- Added IdAwareCollectionMergeConverter<TItem, TId> for merging IId<T> collections by ID.
- Included helpers for ID extraction and semantic ID generation.
- Added DeepPopulateWithMerge extension for deep merging.
- Optimized with frozen dictionaries, pre-encoded property names, and context pooling.
- Ensured compatibility with both System.Text.Json and Newtonsoft.Json.
2025-12-14 19:34:49 +01:00
Loretta 2f1c00fd5c Remove MessagePack; unify SignalR serialization model
Major refactor to eliminate MessagePack from SignalR messaging.
All serialization now uses explicit binary methods (.ToBinary/.BinaryTo)
and Brotli-compressed JSON, managed via a new SignalRSerializationHelper.
Custom stream classes and MessagePack attributes are removed.
API is now consistent, type-safe, and easier to maintain.
Test code and all message handling updated to use the new model.
2025-12-14 01:45:17 +01:00
Loretta ac6735ebd8 Unify SignalR response serialization (JSON/Binary/Brotli)
Major refactor: all SignalR responses now use a single unified `SignalResponseDataMessage` type with binary payloads. JSON responses are Brotli-compressed for efficiency. Removed legacy JSON/Binary response types and MessagePack server-to-client serialization. Updated all serialization extensions for zero-allocation binary ops. Refactored client/server/data source/test code to use new message and serialization model. Improved deserialization robustness for primitives. Modernized and streamlined test suite.
2025-12-13 23:01:18 +01:00
Loretta 1a9e760b68 Fix Binary serialization of string DateTimes in attributes
Add regression tests for string-stored DateTime values in GenericAttribute-like collections, ensuring exact value preservation in Binary serialization. Fix AcBinaryDeserializer to only intern strings >= 4 chars, matching serializer logic and preventing intern table index mismatches. Refactor SignalR tests to run under both JSON and Binary modes, and add comprehensive tests for edge cases and production bug scenarios. Clean up test code and comments for clarity.
2025-12-12 22:59:54 +01:00
Loretta 09a4604e52 Add binary serialization support for SignalR responses
Introduces SignalResponseBinaryMessage for efficient binary serialization of response data alongside existing JSON support. Adds utilities to detect serializer type and updates both server and client logic to handle JSON or binary formats automatically. Refactors response creation, logging, and deserialization for consistency and performance. Updates benchmarks and ensures all MessagePack operations use ContractlessStandardResolver.Options. Improves robustness and backward compatibility in client callback handling.
2025-12-12 21:40:48 +01:00
Loretta ad426feba4 Refactor JSON (de)serialization: options, depth, utilities
Major overhaul of JSON serialization/deserialization:
- Introduce AcJsonSerializerOptions for reference handling and max depth
- Centralize type checks, primitive/collection logic in JsonUtilities
- Add depth limiting to serializer/deserializer (MaxDepth support)
- Make $id/$ref reference handling optional via options
- Unify and simplify public API (ToJson, JsonTo, CloneTo, CopyTo, etc.)
- Improve primitive, enum, and collection handling and caching
- Refactor contract resolver and merge logic to use new utilities
- Remove redundant code, centralize string escaping/unescaping
- Update all tests and benchmarks to use new API and options
- Fix minor bugs and improve error handling and validation

This modernizes and unifies the JSON infrastructure for better performance, flexibility, and maintainability.
2025-12-12 11:30:55 +01:00
Loretta 8e7869b3da Improve JSON deserialization and observable collection handling
- Add batch update support for IAcObservableCollection during deserialization to suppress per-item notifications and fire a single reset event.
- Throw AcJsonDeserializationException with a clear message if a type lacks a parameterless constructor during deserialization.
- Enhance IsGenericCollectionType to recognize more collection types, including ObservableCollection<T> and custom IList<T> implementations.
- Improve array and collection deserialization logic to better handle target types and fall back to List<T> if needed.
- In AcObservableCollection, catch and ignore ObjectDisposedException in event handlers to prevent errors from disposed subscribers.
- Remove redundant batch update logic from AcSignalRDataSource; rely on deserializer's handling.
- Set SkipNegotiation = true in SignalR client options for WebSockets-only optimization and comment out automatic HubConnection.StartAsync() for more controlled connection management.
2025-12-11 23:46:30 +01:00
Loretta c29b3daa0e Refactor JSON/SignalR infra; add full test & benchmark suite
Major overhaul of JSON serialization/deserialization:
- Added AcJsonDeserializationException for clearer error reporting.
- Robust JSON validation, type checking, and double-serialization detection.
- Fast-path primitive (de)serialization for all common .NET types.
- Direct support for Dictionary<TKey, TValue> and improved collection handling.
- Enhanced $id/$ref reference resolution and in-place merging.
- Optimized property metadata caching and filtering.
- Comprehensive error handling with detailed messages.
- Extensive new tests for primitives, collections, references, and error cases.
- Benchmarks for serialization, deserialization, and merge scenarios.

SignalR infrastructure improvements:
- Refactored AcSignalRClientBase/AcWebSignalRHubBase for testability (virtual methods, test constructors).
- Added SignalRRequestModelPool for efficient request/response tracking.
- Improved parameter deserialization and IdMessage handling.
- New tags (PingTag, EchoTag) for SignalR messaging.

New test and benchmark infrastructure for SignalR:
- Shared test models and data factories for DTOs, primitives, and complex graphs.
- In-memory, dependency-free SignalR client/hub for round-trip testing.
- Exhaustive test suites for message processing, method invocation, and edge cases (including prior production bugs with Task<T>).
- Benchmarks for SignalR serialization, deserialization, and round-trip performance.

Other changes:
- Improved TaskHelper.WaitTo/WaitToAsync with more accurate polling and cancellation support.
- ExtensionMethods.InvokeMethod now properly unwraps Task/ValueTask results.
- General code cleanup, improved comments, and removal of obsolete code.
- Project references updated for shared test/benchmark infrastructure.

These changes deliver a robust, high-performance, and fully tested JSON/SignalR (de)serialization system, ready for production and advanced testing scenarios.
2025-12-11 21:25:50 +01:00
Loretta f3ec941774 microsoft packages update 2025-12-01 16:18:36 +01:00
Loretta da5ba340f7 ... 2025-11-26 10:14:56 +01:00
Loretta 2ecc7b1a7a improvements, fixes 2025-11-26 09:42:00 +01:00
Loretta 1131b5675b improvements, fixes, etc... 2025-11-24 08:26:55 +01:00
Loretta dd5dc68862 TransportSendTimeout fix 2025-11-16 19:21:24 +01:00
Loretta a24f0c1681 SignalR improvements; 2025-10-30 14:55:47 +01:00
Loretta 9673b629c6 Implement SignalRLoggerClient 2025-09-02 11:48:05 +02:00