Commit Graph

18 Commits

Author SHA1 Message Date
Loretta 9fad870960 Support optional/default params in SignalR method calls
Added support for optional/default parameters in SignalR method invocation. The hub now fills in missing arguments with default values when not provided, and throws if required parameters are missing. Added comprehensive tests for default parameter handling, a new handler method for testing, and a tag constant. Also improved code style with C# pattern matching and made UseStringCaching immutable.
2025-12-24 17:30:28 +01:00
Loretta a2f392a247 Use 'var' for local variables in AcWebSignalRHubBase
Replaced explicit 'int' declarations with 'var' for local variables in for loops and variable initializations. This improves code conciseness and maintains consistency without altering functionality.
2025-12-23 11:11:51 +01:00
Loretta d35c7bd066 Increase log level for missing dynamic method to Warning
Changed the log level from Debug to Warning when a dynamic method
is not found for a given tag, making these events more visible
in the logs and easier to monitor.
2025-12-22 14:37:44 +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 489ef7486c Optimize JSON/Brotli serialization for zero-allocation
Major performance improvements for SignalR message transport:
- BrotliHelper now uses ArrayPool and stackalloc for zero-allocation compression/decompression; added span/IBufferWriter overloads and pooled buffer support.
- AcJsonDeserializer supports direct deserialization from UTF-8 spans, with fast path for no reference handling.
- SignalResponseDataMessage uses pooled buffers for Brotli decompression and zero-copy deserialization; implements IDisposable for buffer return.
- IdMessage serialization optimized for primitives and Guids to avoid unnecessary allocations.
- Added JsonTo<T> span/byte[] extension methods for zero-allocation deserialization.
- All changes are backward compatible and reduce GC pressure for high-throughput scenarios.
2025-12-13 23:23:16 +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 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 2147d981db Refactor: new high-performance binary serializer/deserializer
Major overhaul of binary serialization:
- Rewrote AcBinarySerializer as a static, optimized, feature-rich serializer with VarInt encoding, string interning, property name tables, reference handling, and optional metadata.
- Added AcBinaryDeserializer with matching features, including merge/populate support and robust error handling.
- Introduced AcBinarySerializerOptions and AcSerializerOptions base class for unified serializer configuration (JSON/binary).
- Added generic extension methods for "any" serialization/deserialization based on options.
- Updated tests and benchmarks for new APIs; fixed null byte code and added DateTimeKind test.
- Fixed namespace typos and improved code style and documentation.
2025-12-12 21:03:39 +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 2ecc7b1a7a improvements, fixes 2025-11-26 09:42:00 +01:00
Loretta e0666027b3 improvements, fixes 2025-11-20 08:30:37 +01:00
Loretta a24f0c1681 SignalR improvements; 2025-10-30 14:55:47 +01:00
Loretta ecdd922be2 AcLoggerBase get AppConfiguration fix 2025-10-22 06:46:30 +02:00
Loretta 0ee715ed97 improvements 2025-10-21 15:15:15 +02:00
Loretta d1ff3af365 Add SignalR common services and dependencies 2025-08-31 12:39:47 +02:00