(ByteWriter writer, MetaString name, IReadOnlyList<MetaStringEncoding> encodings)
| 1087 | } |
| 1088 | |
| 1089 | private static void WriteName(ByteWriter writer, MetaString name, IReadOnlyList<MetaStringEncoding> encodings) |
| 1090 | { |
| 1091 | MetaString normalized = encodings.Contains(name.Encoding) |
| 1092 | ? name |
| 1093 | : (encodings.SequenceEqual(TypeMetaEncodings.NamespaceMetaStringEncodings) |
| 1094 | ? MetaStringEncoder.Namespace.Encode(name.Value, encodings) |
| 1095 | : encodings.SequenceEqual(TypeMetaEncodings.TypeNameMetaStringEncodings) |
| 1096 | ? MetaStringEncoder.TypeName.Encode(name.Value, encodings) |
| 1097 | : MetaStringEncoder.FieldName.Encode(name.Value, encodings)); |
| 1098 | |
| 1099 | int encodingIndex = TypeMetaUtils.EncodingIndexOf(encodings, normalized.Encoding); |
| 1100 | if (encodingIndex < 0) |
| 1101 | { |
| 1102 | throw new EncodingException("failed to normalize meta string encoding"); |
| 1103 | } |
| 1104 | |
| 1105 | byte[] bytes = normalized.Bytes; |
| 1106 | if (bytes.Length >= TypeMetaConstants.BigNameThreshold) |
| 1107 | { |
| 1108 | writer.WriteUInt8((byte)((TypeMetaConstants.BigNameThreshold << 2) | encodingIndex)); |
| 1109 | writer.WriteVarUInt32((uint)(bytes.Length - TypeMetaConstants.BigNameThreshold)); |
| 1110 | } |
| 1111 | else |
| 1112 | { |
| 1113 | writer.WriteUInt8((byte)((bytes.Length << 2) | encodingIndex)); |
| 1114 | } |
| 1115 | |
| 1116 | writer.WriteBytes(bytes); |
| 1117 | } |
| 1118 | |
| 1119 | private static MetaString ReadName(ByteReader reader, MetaStringDecoder decoder, IReadOnlyList<MetaStringEncoding> encodings) |
| 1120 | { |
nothing calls this directly
no test coverage detected