3

我有一个这样的 JSON 类:

public class UpdateCheck
{
    public bool UpdatesAvailable { get; set; }
    public string LinkOfNewVersion { get; set; }
}

但是当我使用 ConfuserEx 混淆我的程序集时, UpdatesAvailableand的值是空的:/LinkOfNewVersion

我已经尝试了以下所有方法:

在我的 JSON 类上方添加[Obfuscation(Exclude = false, Feature = "-rename")]属性:

[Obfuscation(Exclude = false, Feature = "-rename")]
public class UpdateCheck
{
    public bool UpdatesAvailable { get; set; }
    public string LinkOfNewVersion { get; set; }
}

在我的 JSON 类上方添加[Serializable]属性:

[Serializable]
public class UpdateCheck
{
    public bool UpdatesAvailable { get; set; }
    public string LinkOfNewVersion { get; set; }
}

在我的 JSON 类上方添加两个属性:

[Serializable]
[Obfuscation(Exclude = false, Feature = "-rename")]
public class UpdateCheck
{
    public bool UpdatesAvailable { get; set; }
    public string LinkOfNewVersion { get; set; }
}

但是我尝试过的所有方法都失败了:/

我的混淆属性:

  <rule pattern="true" preset="maximum" inherit="false">
    <protection id="anti ildasm" />
    <protection id="anti tamper" />
    <protection id="constants" />
    <protection id="ctrl flow" />
    <protection id="anti dump" />
    <protection id="anti debug" />
    <protection id="invalid metadata" />
    <protection id="ref proxy" />
    <protection id="resources" />
    <protection id="typescramble" />
    <protection id="rename" />
  </rule>

当我从 ConfuserEx 配置文件中删除“重命名”保护时,我的程序集会像这样崩溃: 在此处输入图像描述

任何帮助,将不胜感激。

谢谢!

4

2 回答 2

5

尝试使用JsonProperty属性将字段名称设置为其固定值:

public class UpdateCheck
{
    [JsonProperty("UpdatesAvailable")]
    public bool UpdatesAvailable { get; set; }

    [JsonProperty("LinkOfNewVersion")]
    public string LinkOfNewVersion { get; set; }
}
于 2018-09-13T10:57:17.033 回答
0

您必须专门删除“名称”和“类型争夺”选项。使用“无”以上的任何预设都包括“名称”,这是主要问题。我在没有这两个的情况下使用最大预设,没有关于 Json 的问题。

于 2021-11-21T00:49:18.307 回答