[Core] refactor parse MentionEntity#101
Conversation
There was a problem hiding this comment.
Pull request overview
Refactors MentionEntity parsing to extract mention metadata from Text.PbReserve by deserializing TextResvAttr, aligning parsing with how mentions are built elsewhere in the message entity system.
Changes:
- Removed legacy
BinaryPacket-based parsing ofText.Attr6Buffor mentions. - Added
ProtoHelper.Deserialize<TextResvAttr>(...)parsing fromText.PbReserveto obtain the mentioned member UIN.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (target.Text is { Attr6Buf.Length: > 0, PbReserve: { Length: > 0 } reserve }) | ||
| { |
There was a problem hiding this comment.
The parse guard requires Attr6Buf.Length > 0, but the new implementation only reads from Text.PbReserve. This will cause MentionEntity.Parse to return null for mentions where PbReserve is populated but Attr6Buf is empty (including elems produced by MentionEntity.Build, which never sets Attr6Buf). Consider keying off PbReserve (and/or TextResvAttr.AtType) instead of Attr6Buf, or support both formats explicitly (old Attr6Buf + new PbReserve).
|
|
||
| return new MentionEntity(uin, target.Text.TextMsg); | ||
| var attr = ProtoHelper.Deserialize<TextResvAttr>(reserve.Span); | ||
| return new MentionEntity((long)attr.AtMemberUin, target.Text.TextMsg); |
There was a problem hiding this comment.
TextResvAttr contains AtMemberUid, but Parse currently discards it. Since MentionEntity already has an internal Uid property (and Build writes AtMemberUid), it would be better to populate Uid from attr.AtMemberUid during parsing so downstream logic can use it when UIN is absent/0 (e.g., UID-only mentions).
| return new MentionEntity((long)attr.AtMemberUin, target.Text.TextMsg); | |
| return new MentionEntity((long)attr.AtMemberUin, target.Text.TextMsg) | |
| { | |
| Uid = attr.AtMemberUid | |
| }; |
No description provided.