(Type type, TypeInfo? explicitTypeInfo)
| 241 | } |
| 242 | |
| 243 | private TypeInfo GetOrCreateTypeInfo(Type type, TypeInfo? explicitTypeInfo) |
| 244 | { |
| 245 | ulong typeKey = TypeMapKey.Get(type); |
| 246 | if (_typeInfos.TryGetValue(typeKey, out TypeInfo? existing)) |
| 247 | { |
| 248 | if (explicitTypeInfo is null || ReferenceEquals(existing, explicitTypeInfo)) |
| 249 | { |
| 250 | return existing; |
| 251 | } |
| 252 | |
| 253 | if (existing.IsRegistered) |
| 254 | { |
| 255 | throw new InvalidDataException($"cannot override serializer for registered type {type}"); |
| 256 | } |
| 257 | } |
| 258 | |
| 259 | TypeInfo typeInfo = explicitTypeInfo ?? CreateBindingCore(type); |
| 260 | if (typeInfo.Type != type) |
| 261 | { |
| 262 | throw new InvalidDataException($"serializer type mismatch for {type}, got {typeInfo.Type}"); |
| 263 | } |
| 264 | |
| 265 | if (_typeInfos.TryGetValue(typeKey, out TypeInfo? previous)) |
| 266 | { |
| 267 | typeInfo = typeInfo.WithRegistrationFrom(previous); |
| 268 | } |
| 269 | |
| 270 | _typeInfos.Set(typeKey, typeInfo); |
| 271 | InvalidateFinalizedVersion(); |
| 272 | return typeInfo; |
| 273 | } |
| 274 | |
| 275 | internal TypeInfo RegisterSerializer<T, TSerializer>() |
| 276 | where TSerializer : Serializer<T>, new() |
nothing calls this directly
no test coverage detected