json - Visual Studio 对 JSON 属性排序错误

标签 json visual-studio visual-studio-2017

我在使用 Visual Studio 2017(企业版,版本 15.5.2)时遇到了一个奇怪的问题,我只能在一台特定的计算机上进行复制。在其他开发机器上不会出现该问题。

给定一个包含以下内容的文件 foo.resources.json:

{
    "FooReparatur": "Reparatur",
    "FooVerlust": "Verlust",
    "FooWema": "Wema"
}

应用快速操作排序属性会导致键的顺序错误:

{
    "FooReparatur": "Reparatur",
    "FooWema": "Wema",
    "FooVerlust": "Verlust"
}

Visual Studio 的配置语言是英语,没有为给定文件选择架构。 Windows 的配置语言是爱沙尼亚语,但该字母表的排序顺序也是错误的。

我通过十六进制转储检查了是否有任何有趣的 unicode 字符或类似的内容,但也没有发现类似的内容。如前所述,该文件在所有其他计算机上都能正确排序。

我尝试禁用安装所具有的所有(默认)扩展,但这也无法解决问题。

我已经查看了一般文本编辑和特定文件类型的大部分设置,但我找不到可能导致此问题的设置。可能是什么问题?我怎样才能进一步调试这个?

最佳答案

这是爱沙尼亚排序规则的一个属性,其中“V”和“W”被视为同一字符。因此,下一个不同的字符将是重要的字符。正如使用 .Net 的 C# 代码所示。

var words1 =  new[] { "FooR", "FooVer", "FooWem" };
var words2 = new[] { "FooR", "FooVa", "FooWb" };

var estonianCultureInfo = new System.Globalization.CultureInfo("et-EE");
var estonianComparer = StringComparer.Create(estonianCultureInfo, false);

var sortedWords = words1.OrderBy(x => x, estonianComparer);
foreach (var word in sortedWords)
{
    Console.WriteLine(word);
}

Console.WriteLine("[-----]");

sortedWords = words2.OrderBy(x => x, estonianComparer);
foreach (var word in sortedWords)
{
    Console.WriteLine(word);
}

输出:

FooR
FooWem
FooVer
[-----]
FooR
FooVa
FooWb

关于json - Visual Studio 对 JSON 属性排序错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49289272/

相关文章:

c# - Silverlight 访问 ashx JSON 响应

php - 在 json 解码中下订单

c++ - 函数生成不正确的装饰名称

c++ - C4250 VC++ 警告是什么意思?

.net - 如何将 .net 标准 2.0 安装到 Visual Studio 2017 中

从 VSTS build 构建解决方案时出现 MSBuild 错误

c# - debuggerdisplay 未按预期显示字段值

c# - 没有 ASP.NET AJAX 的 JQuery/WCF :

java - 根据条件从 JSON API 中的方法返回不同的对象

c# - 未检测到 Visual Studio 2017 中的新类项