Comments (3)
I didn't find a list of what was supported/unsupported by Wire so the following issues may be 'by design'.
All tests uses the following method:
public override T Duplicate<T>(T obj)
{
using (var ms = new MemoryStream())
{
SerializerOptions opt = new SerializerOptions(preserveObjectReferences: true);
var s = new Wire.Serializer(opt);
s.Serialize(obj, ms);
ms.Position = 0;
return s.Deserialize<T>(ms);
}
}
1 - Serializing a list of IQueryable results in an "Ambiguous match found" exception:
var list = new List<int> { 123, 123, 123 };
List<IQueryable<int>> instance = new List<IQueryable<int>> { list.AsQueryable() };
var duplicatedValue = Duplicate(instance);
2 - Fields marked with [NonSerialized]
should not be serialized.
3 - I have a bunch of tests that uses custom dictionaries that throws "Generic IDictionary<TKey,TValue> are not yet supported" but I guess this is expected for now.
4 - Serializing/Deserializing a Dictionary<byte, char> does not deserialize the values.
var instance = new Dictionary<byte, char>();
instance.Add(0, 'z');
instance.Add(255, 'z');
instance.Add(3, char.MinValue);
var duplicatedValue = Duplicate(instance);
Assert.AreEqual(instance.Count, duplicatedValue.Count);
CollectionAssert.AreEquivalent(instance.Keys, duplicatedValue.Keys);
foreach (var kvp in instance)
{
Assert.AreEqual(kvp.Value, duplicatedValue[kvp.Key]);
}
5 - Dictionary/HashTable comparer are not serialized.
var instance = new Dictionary<string, object>(StringComparer.InvariantCultureIgnoreCase)
{
{"a", 123},
{"", "abc"}
};
var duplicatedValue = Duplicate(instance);
Assert.AreEqual(instance.Comparer.GetType(), duplicatedValue.Comparer.GetType());
6 - Serializing/Deserializing an ExpandoObject results in the following exceptions:
threw exception System.NullReferenceException, but exception System.NotSupportedException was expected. Exception message: System.NullReferenceException: Object reference not set to an instance of an object.
dynamic instance = new ExpandoObject();
instance.Property1 = 123;
Duplicate(instance);
7 - Serializing/Deserializing a HashTable throws this exception:
threw exception System.Reflection.TargetParameterCountException, but exception System.NotSupportedException was expected. Exception message: System.Reflection.TargetParameterCountException: Parameter count mismatch.
var instance = new Hashtable { {1, 2}, {"a", "b"}, };
var duplicatedValue = Duplicate(instance);
8 - Serializing/Deserializing a multidimentional array:
threw exception System.ArgumentException, but exception System.NotSupportedException was expected. Exception message: System.ArgumentException: Value was invalid.
var instance = new int[1,2,3,4,5];
var duplicatedValue = Duplicate(instance);
instance.Should().BeEquivalentTo(duplicatedValue);
9 - Serializing a null array is not supported but this looks like a design decision.
object[] instance = null;
var duplicatedValue = Duplicate(instance);
10 - Serializing a pointer throws this exception:
threw exception System.Security.VerificationException, but exception System.NotSupportedException was expected. Exception message: System.Security.VerificationException: Operation could destabilize the runtime.
int[] a = new int[5] { 10, 20, 30, 40, 50 };
fixed (int* p = &a[0])
{
var instance = new ClassWithPointer();
instance.Value = p;
Duplicate(instance);
}
public unsafe class ClassWithPointer
{
public int* Value { get; set; }
}
11 - Serializing an Expression throws exception:
threw exception System.Reflection.AmbiguousMatchException, but exception System.NotSupportedException was expected. Exception message: System.Reflection.AmbiguousMatchException: Ambiguous match found.
var testData = new List<int> { 1, 2, 3, 4, 5, 6 };
Expression<System.Func<int, bool>> instance = x => x > 3;
var duplicatedValue = Duplicate(instance);
12 - Serializing a delegate/Func<>/Action<> should not be allowed because the types will not exists in another computer.
from wire.
- Not planned, an IQueryable could be just anything, an EF query or whatever, they are highly context bound. we will not support anything that magic out of the box.
- This should be the case as we filter out those fields, are you seeing a different behavior?
- Planned, not implemented.
- Bug, it works with string values, so something wrong with Char values ATM.
- Not implemented, it should probably be possible to just serialize the comparer. need to research this one a bit.
- Not planned, PR would be accepted though.
- Bug
- Planned, not implemented.
- serializing null as the root object is not supported. it could be, but I don't think it makes sense.
- Not planned. I dont see how this could be useful as the pointer would be useless when deserialized.
Would it make more sense to just ignore it? - Planned, not implemented.
- works if both systems reference the same assembly.
And TBH. all of these should be reported as individual issues
from wire.
2 - The field with the [NonSerialized] was serialized
5 - You could support the ISerializable
interface for this.
6 - I have my own serializer to take care of so I will not be able to do a PR. However if you decide to support it you can treat ExpandoObject as a Dictionary<string, object>
10 - I think it would be best if you can throw your own exception with more detail (e.g.: pointer is not supported for Type X, field Y) it would help the user consuming your library instead of letting the framework handle it.
I was just wondering how well Wire worked. I'll close this issue and let you open issues for what you want to fix.
from wire.
Related Issues (20)
- NVM
- Serialization of F# Map HOT 4
- No support for struct with a non-default constructor? HOT 8
- Is Serializer thread safe? HOT 2
- AmbiguousMatchException when serializing a type with multiple AddRange methods HOT 1
- Invalid code generation on fields of interface type HOT 5
- Wire performance improvements HOT 3
- CollectionTests.CanSerializeDictionaryKeysAndValuesByteChar is failing HOT 1
- Wire 0.8.2 is not compatible with 0.8.1 HOT 6
- Stack overflow when serializing/deserializing LinkedList
- OSS license for Wire HOT 2
- Support for IDictionary HOT 3
- Serialize - DeSerialize between similar types. HOT 4
- Speedup dials to compare performance with bond simple binary protocol.
- .NET Core serialization issues
- Signed Wire NuGet package
- support DataContract/DataMember/IgnoreDataMember
- Does wire do zig-zag / 7bit encoding?
- Wire.Extensions.TypeEx CoreAssemblyName ignore mscorelib/System.Private.CoreLib
- .NET Core 3 - Cannot Deserialize
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wire.