(WriteContext context, in Stack<T> value, bool hasGenerics)
| 634 | public override Stack<T> DefaultValue => null!; |
| 635 | |
| 636 | public override void WriteData(WriteContext context, in Stack<T> value, bool hasGenerics) |
| 637 | { |
| 638 | Stack<T> safe = value ?? new Stack<T>(); |
| 639 | if (safe.Count == 0) |
| 640 | { |
| 641 | CollectionCodec.WriteCollectionData(Array.Empty<T>(), context.TypeResolver.GetSerializer<T>(), context, hasGenerics); |
| 642 | return; |
| 643 | } |
| 644 | |
| 645 | T[] topToBottom = safe.ToArray(); |
| 646 | List<T> bottomToTop = new(topToBottom.Length); |
| 647 | for (int i = topToBottom.Length - 1; i >= 0; i--) |
| 648 | { |
| 649 | bottomToTop.Add(topToBottom[i]); |
| 650 | } |
| 651 | |
| 652 | CollectionCodec.WriteCollectionData(bottomToTop, context.TypeResolver.GetSerializer<T>(), context, hasGenerics); |
| 653 | } |
| 654 | |
| 655 | public override Stack<T> ReadData(ReadContext context) |
| 656 | { |
nothing calls this directly
no test coverage detected