提交 93597bf1 编写于 作者: B Balaji Krishnan

Gaurd against trying to deserialize bad or ..

.. corrupted data in SimpleCodeStyleOption
上级 85865433
......@@ -34,10 +34,19 @@ public SimpleCodeStyleOption(bool isChecked, NotificationOption notification)
public static SimpleCodeStyleOption FromXElement(XElement element)
{
var isChecked = bool.Parse(element.Attribute(nameof(IsChecked)).Value);
var severity = (DiagnosticSeverity)Enum.Parse(typeof(DiagnosticSeverity), element.Attribute(nameof(DiagnosticSeverity)).Value);
NotificationOption notificationOption;
var isCheckedAttribute = element.Attribute(nameof(IsChecked));
var severityAttribute = element.Attribute(nameof(DiagnosticSeverity));
if (isCheckedAttribute == null || severityAttribute == null)
{
// data from storage is corrupt, or nothing has been stored yet.
return Default;
}
var isChecked = bool.Parse(isCheckedAttribute.Value);
var severity = (DiagnosticSeverity)Enum.Parse(typeof(DiagnosticSeverity), severityAttribute.Value);
NotificationOption notificationOption;
switch (severity)
{
case DiagnosticSeverity.Hidden:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册