flamencist / flamencist/Core.System.Configuration.Install

Evaluate replacing JsonConvert serialization

Đang mở
#1 3 bình luận 1 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
C#
Star
26
Fork
12
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

It looks like you're just using JSON.net to serialize `IDictionary` in savedState and this could be accomplished with built-in serializers that would remove the dependency on JSON.net (so that a different version can be used or just not bring that dependency along with someone using System.Configuration.Install).

I looked at the reference source and the built-in classes use `NetDataContractSerializer` which can serialize/deserialize arbitrary types in an `IDictionary`. We don't have that in `netstandard2.0`. Another possibility is `BinaryFormatter`, but that requires `ISerializable` which `IDictionary` is not. The concrete type is `Hashtable` in the underlying implementation for installers.

@flamencist thought [this approach](https://blogs.msdn.microsoft.com/adam/2010/09/10/how-to-serialize-a-dictionary-or-hashtable-in-c/) might work, but it relies on `ToString()` to put it in a key value store. Since `IDictionary` (and `Hashtable`) can hold any object, this doesn't really work. Some objects may not have a sensible `ToString()` which would end up with the type name in the output, and they can't really be deserialized in this manner.

In the `Installer` source I looked at, it appeared that it was putting an integer in there for the count of `Installer`s and then saving all the child `Installer` states (which can be any object since anyone can inherit `Installer`).

The reason `JsonConvert` works is that it serializes the type information too. Is it possible to replace it with something we have in `netstandard2.0` so that we don't have to bring along a JSON.Net dependency?

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

Start by tracing how Installer savedState is serialized and deserialized, then compare the netstandard2.0 serializer options discussed in the issue, including NetDataContractSerializer and BinaryFormatter. Verify whether arbitrary IDictionary and child Installer state can round-trip without Json.NET; done means identifying a compatible replacement or documenting why the dependency must remain.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
csharp
Lĩnh vực
tooling
Loại issue
Tái cấu trúc
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
25/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.