Skip to content

Commit d78485d

Browse files
committed
When retrieving metadata fields from Song object to serialize to JSON, ignore the case of the field name when finding its property getter, otherwise it will fall back to WinampControllerImpl.fetchMetadataFieldValue which don't benefit from the parsing logic in Song, especially in converting the year from a string into an integer.
1 parent 97a9f6d commit d78485d

3 files changed

Lines changed: 2 additions & 4 deletions

File tree

WinampNowPlayingToFile/Facade/Song.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ public Song(Daniel15.Sharpamp.Song song) {
2828
return year;
2929
} else if (Regex.Match(song.Year, @"(?<year>\d{4})-\d\d-\d\d") is { Success: true } isoDateMatch) {
3030
return int.Parse(isoDateMatch.Groups["year"].Value);
31-
} else if (Regex.Match(song.Year, @"\d{4}") is { Success: true } yearMatch) {
32-
return int.Parse(yearMatch.Value);
3331
} else {
3432
return null;
3533
}

WinampNowPlayingToFile/Facade/Templating/UnfuckedMustacheGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ private static bool tryGetObjectPropertyValue(object values, string fieldName, o
9292
Type objectType = values.GetType();
9393
(Type objectType, string fieldName) cacheKey = (objectType, fieldName);
9494
if (!PROPERTY_ACCESSOR_CACHE.TryGetValue(cacheKey, out PropertyInfo? propertyAccessor)) {
95-
propertyAccessor = objectType.GetProperty(fieldName);
95+
propertyAccessor = objectType.GetProperty(fieldName, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance);
9696
PROPERTY_ACCESSOR_CACHE[cacheKey] = propertyAccessor;
9797
}
9898
value = propertyAccessor?.GetValue(values);

WinampNowPlayingToFile/Presentation/SettingsDialog.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)