我已通过Visual Studio反馈工具报告了此可能的错误,但我有以下示例代码,在.Net 5中运行,但在.Net 6中无法正确工作,我觉得这要么是一个bug,要么是我漏掉了版本之间的某些更改。我在下面提供了示例代码以及两种方法的Visual Studio html可视化输出。请问是否有任何可能对此问题提供帮助的意见?
更新:经过来自@GSerg有益的建议进行不同测试后,我发现当您在插入字符串或字符串生成器中使用html标记时,此bug仅在.Net 6中发生,并将文本截断到插入变量之前并将其插入到第二行。我附加了一个新截屏,显示了使用Visual Studio Visualizer的这种行为。
var subect = "Subect Example";
var test = $"<p><strong><span style=\"font-size: 20px;\">{subject}</span></strong></p><p><span style=\"color: rgb(34, 34, 34); font-family: Arial, Helvetica, sans-serif; " +
$"font-size: small; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; " +
$"text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; " +
$"text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;\">The following information is in beta testing and isn't meant for a live portfolio. " +
$"Use this information for paper trading only until further notice.</span></p>";
StringBuilder
没有任何关系。似乎你用来显示字符串的控件已经改变了。很可能,它对输入进行转义以防止注入攻击。 - BlueRaja - Danny Pflughoefttest
变量不包含有效的html(缺少<html>标签),因此它的行为符合预期。 - Steeeve