Skip to content

Commit

Permalink
Make GetValueForSerialization non-nullable.
Browse files Browse the repository at this point in the history
  • Loading branch information
huoyaoyuan committed Mar 4, 2021
1 parent 6a48567 commit cf72285
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,18 @@ public XElement ToXElement() =>
new("CodeStyleOption", // Ensure that we use "CodeStyleOption" as the name for back compat.
new XAttribute(nameof(SerializationVersion), SerializationVersion),
new XAttribute("Type", GetTypeNameForSerialization()),
new XAttribute(nameof(Value), GetValueForSerialization()!),
new XAttribute(nameof(Value), GetValueForSerialization()),
new XAttribute(nameof(DiagnosticSeverity), Notification.Severity.ToDiagnosticSeverity() ?? DiagnosticSeverity.Hidden));

private object? GetValueForSerialization()
private object GetValueForSerialization()
{
if (typeof(T) == typeof(string))
{
return Value;
return Value!;
}
else if (typeof(T) == typeof(bool))
{
return Value;
return Value!;
}
else if (IsZeroOrOneValueOfEnum())
{
Expand Down

0 comments on commit cf72285

Please sign in to comment.