Reduce warnings noise and provide more info on some unexpect field errors (#516)
This commit is contained in:
Родитель
2b49bb9edc
Коммит
4d1d453ecc
|
@ -541,9 +541,18 @@ namespace CommunityToolkit.WinUI.Lottie.LottieData.Serialization
|
|||
// Property expression. Currently ignored because we don't support expressions.
|
||||
case "x":
|
||||
reader._issues.Expressions();
|
||||
break;
|
||||
case "l":
|
||||
// Ignore field "l" with value of "2" to produce less warnings noise.
|
||||
// TODO: This value is not yet specified in lottie repository.
|
||||
if (property.Value.Kind != JsonValueKind.Number || property.Value.AsInt32() != 2)
|
||||
{
|
||||
reader._issues.UnexpectedFieldValue(property.Key, property.Value.ToString());
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
reader._issues.UnexpectedField(property.Key);
|
||||
reader._issues.UnexpectedFieldValue(property.Key, property.Value.ToString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,9 +65,15 @@ namespace CommunityToolkit.WinUI.Lottie.LottieData.Serialization
|
|||
width = reader.ParseDouble();
|
||||
break;
|
||||
|
||||
case "nm": // Name - rare property, ignore
|
||||
reader.Skip();
|
||||
break;
|
||||
case "fr": // Framerate - rare property. Report it with details anyway.
|
||||
_issues.UnexpectedFieldValueInfo(currentProperty, reader.ParseDouble().ToString(), "framerate");
|
||||
break;
|
||||
|
||||
// Report but ignore unexpected properties.
|
||||
case "xt":
|
||||
case "nm":
|
||||
default:
|
||||
_issues.UnexpectedField(currentProperty);
|
||||
reader.Skip();
|
||||
|
|
|
@ -206,7 +206,16 @@ namespace CommunityToolkit.WinUI.Lottie.LottieData.Serialization
|
|||
{
|
||||
if (pair.unread)
|
||||
{
|
||||
_owner._issues.UnexpectedField($"{memberName}.{pair.property.Name}");
|
||||
// Ignore property "l" with value "2" to reduce warnings noise.
|
||||
// TODO: This property is not yet specified in lottie repo.
|
||||
if (pair.property.Name == "l" &&
|
||||
pair.property.Value.ValueKind == JsonValueKind.Number &&
|
||||
pair.property.Value.GetInt32() == 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
_owner._issues.UnexpectedFieldValue($"{memberName}.{pair.property.Name}", pair.property.Value.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,7 +64,20 @@ namespace CommunityToolkit.WinUI.Lottie.LottieData.Serialization
|
|||
// LP0016 has been deprecated.
|
||||
// Was: Ignored field: {field}.
|
||||
|
||||
internal void UnexpectedField(string field) => Report("LP0017", $"Unexpected field: {field}.");
|
||||
internal void UnexpectedFieldValue(string field, string value)
|
||||
{
|
||||
Report("LP0017", $"Unexpected field: \"{field}\" with value \"{value}\".");
|
||||
}
|
||||
|
||||
internal void UnexpectedFieldValueInfo(string field, string value, string info)
|
||||
{
|
||||
Report("LP0017", $"Unexpected field: \"{field}\" with value \"{value}\" ({info}).");
|
||||
}
|
||||
|
||||
internal void UnexpectedField(string field)
|
||||
{
|
||||
Report("LP0017", $"Unexpected field: \"{field}\".");
|
||||
}
|
||||
|
||||
internal void UnexpectedValueForType(string type, string value) => Report("LP0018", $"Unexpected {type} type value: {value}.");
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче