Evaluate replacing JsonConvert serialization

未关闭
#1 3 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
重构
描述清晰度
需要澄清
活跃度
停滞
技术栈
csharp
领域
tooling

调研方向

首先跟踪 Installer 的 savedState 是如何序列化和反序列化的,然后比较 issue 中讨论的 netstandard2.0 serializer 选项,包括 NetDataContractSerializer 和 BinaryFormatter。验证任意 IDictionary 和子 Installer 状态是否可以在不使用 Json.NET 的情况下完成往返;完成的标准是确定一个兼容的替代方案,或记录必须保留该依赖项的原因。

由索引模型根据 Issue 内容生成。

描述

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 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 Installers 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?

主要语言
C#
星标
26
派生
12
PR 合并指标
30 天内没有已合并 PR

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

flamencist/Core.System.Configuration.Install 的其他 Issue

查看 flamencist/Core.System.Configuration.Install 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。