Commit 26a0b21
authored
Replace session state encoder with IEncodable generation using source generators (#3673)
* Replace SessionStateEncoder with IEncodeable on session/subscription models
- Source-gen [DataType]/[DataTypeField] on: MonitoredItemOptions, MonitoredItemState,
SubscriptionOptions, SubscriptionState (auto-generated Encode/Decode/IsEqual/Clone)
- Manual IEncodeable on: SessionOptions, SessionState, SessionConfiguration
(ConfiguredEndpoint and IUserIdentity require manual encoding)
- Delete SessionStateEncoder.cs (488 lines removed)
- Remove [DataContract]/[DataMember]/[KnownType]/[CollectionDataContract] attributes
- Remove JsonSerializerContext classes
- Change init -> set, byte[] -> ByteString, DateTime -> DateTimeUtc
- MonitoredItems: ArrayOf<MonitoredItemState> with StructureHandling.Inline
- Subscriptions: ArrayOf<SubscriptionState>
* Source generator: support partial init properties with backing fields
Add IsInitOnly detection to the [DataType] source generator so that
partial properties with init-only setters can be used in IEncodeable types.
For each init-only partial property, the generator:
- Emits a private backing field (__PropertyName)
- Emits the partial property implementation (get => __field; init => __field = value)
- Uses the backing field in Decode() instead of the property
- Skips simple init-only fields in Clone() (record 'with' already copies them)
Detection uses both IPropertySymbol.SetMethod.IsInitOnly and syntax-tree
fallback (SyntaxKind.InitAccessorDeclaration) for partial definitions.
* docs: add partial init properties and session state migration sections
- SourceGeneratedDataTypes.md: new 'Partial Init Properties' section
documenting backing field generation for init-only partial properties
- MigrationGuide.md: new 'Session State Persistence' section covering1 parent c71f2e7 commit 26a0b21
19 files changed
Lines changed: 831 additions & 831 deletions
File tree
- Docs
- Libraries/Opc.Ua.Client
- Session
- Subscription
- Tests
- Opc.Ua.Client.Tests
- Session
- Subscription
- Opc.Ua.SourceGeneration.Tests
- Tools
- Opc.Ua.SourceGeneration.Core
- Generators
- Templating
- Opc.Ua.SourceGeneration
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
46 | 50 | | |
47 | 51 | | |
48 | 52 | | |
| |||
628 | 632 | | |
629 | 633 | | |
630 | 634 | | |
631 | | - | |
| 635 | + | |
632 | 636 | | |
633 | | - | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
634 | 684 | | |
635 | 685 | | |
636 | 686 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
477 | 477 | | |
478 | 478 | | |
479 | 479 | | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
480 | 543 | | |
481 | 544 | | |
482 | 545 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
860 | 860 | | |
861 | 861 | | |
862 | 862 | | |
863 | | - | |
| 863 | + | |
864 | 864 | | |
865 | 865 | | |
866 | 866 | | |
867 | | - | |
| 867 | + | |
868 | 868 | | |
869 | 869 | | |
870 | 870 | | |
871 | | - | |
| 871 | + | |
872 | 872 | | |
873 | 873 | | |
874 | 874 | | |
| |||
878 | 878 | | |
879 | 879 | | |
880 | 880 | | |
881 | | - | |
| 881 | + | |
882 | 882 | | |
883 | 883 | | |
884 | 884 | | |
| |||
894 | 894 | | |
895 | 895 | | |
896 | 896 | | |
897 | | - | |
898 | | - | |
899 | | - | |
900 | | - | |
901 | | - | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
902 | 902 | | |
903 | 903 | | |
904 | 904 | | |
| |||
926 | 926 | | |
927 | 927 | | |
928 | 928 | | |
929 | | - | |
930 | | - | |
931 | | - | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
932 | 932 | | |
933 | 933 | | |
934 | | - | |
| 934 | + | |
935 | 935 | | |
936 | 936 | | |
937 | 937 | | |
938 | 938 | | |
939 | 939 | | |
940 | 940 | | |
941 | 941 | | |
942 | | - | |
| 942 | + | |
943 | 943 | | |
944 | 944 | | |
945 | 945 | | |
| |||
980 | 980 | | |
981 | 981 | | |
982 | 982 | | |
983 | | - | |
984 | | - | |
| 983 | + | |
985 | 984 | | |
986 | 985 | | |
987 | 986 | | |
| |||
994 | 993 | | |
995 | 994 | | |
996 | 995 | | |
997 | | - | |
| 996 | + | |
998 | 997 | | |
999 | 998 | | |
1000 | 999 | | |
1001 | | - | |
| 1000 | + | |
1002 | 1001 | | |
1003 | 1002 | | |
1004 | 1003 | | |
| |||
1009 | 1008 | | |
1010 | 1009 | | |
1011 | 1010 | | |
1012 | | - | |
1013 | | - | |
| 1011 | + | |
| 1012 | + | |
1014 | 1013 | | |
1015 | | - | |
| 1014 | + | |
1016 | 1015 | | |
1017 | 1016 | | |
1018 | 1017 | | |
| |||
1043 | 1042 | | |
1044 | 1043 | | |
1045 | 1044 | | |
1046 | | - | |
1047 | | - | |
| 1045 | + | |
| 1046 | + | |
1048 | 1047 | | |
1049 | 1048 | | |
1050 | 1049 | | |
| |||
0 commit comments