MCPcopy Create free account
hub / github.com/apache/fory / BuildTypeMetaCacheEntry

Method BuildTypeMetaCacheEntry

csharp/src/Fory/TypeInfo.cs:698–761  ·  view source on GitHub ↗
(bool trackRef)

Source from the content-addressed store, hash-verified

696 }
697
698 private TypeMetaCacheEntry BuildTypeMetaCacheEntry(bool trackRef)
699 {
700 if (!UserTypeKind.HasValue)
701 {
702 throw new InvalidDataException($"type meta is only available for user types, got {Type}");
703 }
704
705 if (!IsRegistered)
706 {
707 throw new TypeNotRegisteredException($"{Type} is not registered");
708 }
709
710 TypeId wireTypeId = TypeResolver.ResolveWireTypeId(
711 UserTypeKind.Value,
712 RegisterByName,
713 compatible: true,
714 Evolving);
715 IReadOnlyList<TypeMetaFieldInfo> fields = TypeMetaFields(trackRef);
716 TypeMeta typeMeta;
717 if (RegisterByName)
718 {
719 if (!NamespaceName.HasValue || !TypeName.HasValue)
720 {
721 throw new InvalidDataException("missing type name metadata for name-registered type");
722 }
723
724 typeMeta = new TypeMeta(
725 (uint)wireTypeId,
726 null,
727 NamespaceName.Value,
728 TypeName.Value,
729 true,
730 fields);
731 }
732 else
733 {
734 if (!UserTypeId.HasValue)
735 {
736 throw new InvalidDataException("missing user type id metadata for id-registered type");
737 }
738
739 typeMeta = new TypeMeta(
740 (uint)wireTypeId,
741 UserTypeId.Value,
742 MetaString.Empty('.', '_'),
743 MetaString.Empty('$', '_'),
744 false,
745 fields);
746 }
747
748 byte[] encoded = typeMeta.Encode();
749 ulong header = BinaryPrimitives.ReadUInt64LittleEndian(encoded);
750 ulong headerHash = header >> TypeMetaConstants.TypeMetaHashShift;
751 typeMeta = new TypeMeta(
752 typeMeta.TypeId,
753 typeMeta.UserTypeId,
754 typeMeta.NamespaceName,
755 typeMeta.TypeName,

Callers

nothing calls this directly

Calls 3

ResolveWireTypeIdMethod · 0.80
EmptyMethod · 0.45
EncodeMethod · 0.45

Tested by

no test coverage detected