コード例 #1
0
        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);
        }
コード例 #2
0
        public void NotSupportedScenarios(Type type)
        {
            var provider = RepeatedSerializers.TryGetRepeatedProvider(type);

            Assert.NotNull(provider);
            Assert.Throws <NotSupportedException>(() =>
            {
                _ = provider.Serializer;
            });
        }
コード例 #3
0
        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());
            }
        }
コード例 #4
0
        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);