diff --git a/TwitchDownloaderCore/ChatRenderer.cs b/TwitchDownloaderCore/ChatRenderer.cs index 78fc1265..4059f8b4 100644 --- a/TwitchDownloaderCore/ChatRenderer.cs +++ b/TwitchDownloaderCore/ChatRenderer.cs @@ -5,6 +5,7 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; using System.Linq; @@ -814,7 +815,7 @@ private void DrawFragmentPart(List<(SKImageInfo info, SKBitmap bitmap)> sectionI DrawRegularMessage(sectionImages, emotePositionList, ref drawPos, defaultPos, bitsCount, fragmentPart, highlightWords); } - static bool TryGetTwitchEmote(List twitchEmoteList, ReadOnlySpan emoteName, out TwitchEmote twitchEmote) + static bool TryGetTwitchEmote(List twitchEmoteList, ReadOnlySpan emoteName, [NotNullWhen(true)] out TwitchEmote twitchEmote) { // Enumerating over a span is faster than a list var emoteListSpan = CollectionsMarshal.AsSpan(twitchEmoteList); @@ -827,7 +828,7 @@ static bool TryGetTwitchEmote(List twitchEmoteList, ReadOnlySpan sectio DrawText(fragmentString, messageFont, true, sectionImages, ref drawPos, defaultPos, highlightWords); } - static bool TryGetCheerEmote(List cheerEmoteList, ReadOnlySpan prefix, out CheerEmote cheerEmote) + static bool TryGetCheerEmote(List cheerEmoteList, ReadOnlySpan prefix, [NotNullWhen(true)] out CheerEmote cheerEmote) { // Enumerating over a span is faster than a list var cheerEmoteListSpan = CollectionsMarshal.AsSpan(cheerEmoteList); @@ -1089,7 +1090,7 @@ static bool TryGetCheerEmote(List cheerEmoteList, ReadOnlySpan } } - cheerEmote = default; + cheerEmote = null; return false; } } @@ -1125,7 +1126,7 @@ private void DrawFirstPartyEmote(List<(SKImageInfo info, SKBitmap bitmap)> secti DrawText(fragment.text, messageFont, true, sectionImages, ref drawPos, defaultPos, highlightWords); } - static bool TryGetTwitchEmote(List twitchEmoteList, ReadOnlySpan emoteId, out TwitchEmote twitchEmote) + static bool TryGetTwitchEmote(List twitchEmoteList, ReadOnlySpan emoteId, [NotNullWhen(true)] out TwitchEmote twitchEmote) { // Enumerating over a span is faster than a list var emoteListSpan = CollectionsMarshal.AsSpan(twitchEmoteList); @@ -1138,7 +1139,7 @@ static bool TryGetTwitchEmote(List twitchEmoteList, ReadOnlySpanThe was public static BitmapImage GetThumb(string thumbUrl, BitmapCacheOption cacheOption = BitmapCacheOption.OnLoad) { ArgumentNullException.ThrowIfNull(thumbUrl); @@ -25,7 +27,7 @@ public static BitmapImage GetThumb(string thumbUrl, BitmapCacheOption cacheOptio return img; } - public static bool TryGetThumb(string thumbUrl, out BitmapImage thumbnail) + public static bool TryGetThumb(string thumbUrl, [NotNullWhen(true)] out BitmapImage thumbnail) { if (string.IsNullOrWhiteSpace(thumbUrl)) {