public void SpansAreReallyReallyNotSupported(Type type) { var ex = Assert.Throws <NotSupportedException>(() => { RepeatedSerializers.TryGetRepeatedProvider(type); }); Assert.Equal("Serialization cannot work with [ReadOnly]Span<T>; [ReadOnly]Memory<T> may be enabled later", ex.Message); }
public void NotSupportedScenarios(Type type) { var provider = RepeatedSerializers.TryGetRepeatedProvider(type); Assert.NotNull(provider); Assert.Throws <NotSupportedException>(() => { _ = provider.Serializer; }); }
public void TestWhatProviderWeGet(Type type, Type expected) { var provider = RepeatedSerializers.TryGetRepeatedProvider(type); if (expected == null) { Assert.Null(provider); } else { Assert.NotNull(provider); var ser = provider.Serializer; Assert.NotNull(ser); Assert.Equal(expected, ser.GetType()); } }
internal bool IsValidProtobufMap(RuntimeTypeModel model, CompatibilityLevel compatibilityLevel, DataFormat dataFormat) { if (!IsMap) { return(false); } ResolveMapTypes(out var key, out var value); // the key must an any integral or string type (not floating point or bytes) if (!IsValidKey(key, compatibilityLevel, dataFormat)) { return(false); } // the value cannot be repeated (neither can key, but we ruled that out above) var repeated = model == null?RepeatedSerializers.TryGetRepeatedProvider(value) : model.TryGetRepeatedProvider(value); if (repeated != null) { return(false); } return(true);