Skip to content

Commit

Permalink
Fixed a few more nullRef warnings and code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ErisApps committed Oct 27, 2020
1 parent 4ce6494 commit fc79af3
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion ChatCore/ChatCoreInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static ChatCoreInstance Create()
.AddSingleton<IChatService>(x =>
new ChatServiceMultiplexer(
x.GetService<ILogger<ChatServiceMultiplexer>>(),
new List<IChatService>()
new List<IChatService>
{
x.GetService<TwitchService>()
}
Expand Down
4 changes: 2 additions & 2 deletions ChatCore/Config/ObjectSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public void Save(object obj, string path)
File.Move(path, backupPath);
}

string lastConfigSection = null!;
string? lastConfigSection = null;
var serializedClass = new List<string>();

if (obj.GetType().GetCustomAttribute(typeof(ConfigHeader)) is ConfigHeader configHeader)
Expand Down Expand Up @@ -284,7 +284,7 @@ public void Save(object obj, string path)
lastConfigSection = configSection.Name;
}

var configMeta = (ConfigMeta)fieldInfo.GetCustomAttribute(typeof(ConfigMeta));
var configMeta = (ConfigMeta?)fieldInfo.GetCustomAttribute(typeof(ConfigMeta));
var valueStr = "";
try
{
Expand Down
2 changes: 1 addition & 1 deletion ChatCore/Interfaces/IShortcodeAuthProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ namespace ChatCore.Interfaces
public interface IShortcodeAuthProvider
{
Task<OAuthShortcodeRequest> RequestShortcode();
Task<OAuthCredentials> AwaitUserApproval(CancellationToken cancellationToken, OAuthShortcodeRequest request = null, bool launchBrowserProcess = false);
Task<OAuthCredentials> AwaitUserApproval(CancellationToken cancellationToken, OAuthShortcodeRequest? request = null, bool launchBrowserProcess = false);
}
}
2 changes: 2 additions & 0 deletions ChatCore/Models/Emoji.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class Emoji : IChatEmote
public ImageRect UVs { get; internal set; }

public Emoji() { }

public Emoji(string json)
{
var obj = JSON.Parse(json);
Expand All @@ -28,6 +29,7 @@ public Emoji(string json)
if (obj.TryGetKey(nameof(Type), out var type)) { Type = Enum.TryParse<EmoteType>(type.Value, out var typeEnum) ? typeEnum : EmoteType.SingleImage; }
if (obj.TryGetKey(nameof(UVs), out var uvs)) { UVs = new ImageRect(uvs.Value); }
}

public JSONObject ToJson()
{
var obj = new JSONObject();
Expand Down
2 changes: 1 addition & 1 deletion ChatCore/Models/Twitch/TwitchChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public JSONObject ToJson()
{
var obj = new JSONObject();
obj.Add(nameof(Id), new JSONString(Id));
obj.Add(nameof(Roomstate), Roomstate.ToJson());
obj.Add(nameof(Roomstate), Roomstate!.ToJson());
return obj;
}
}
Expand Down
2 changes: 1 addition & 1 deletion ChatCore/Services/FrwTwemojiParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public List<IChatEmote> FindEmojis(string str)
{
continue;
}
var emoji = new Emoji()
var emoji = new Emoji
{
Id = $"Emoji_{unicodeStr}",
Name = match.Value,
Expand Down
6 changes: 3 additions & 3 deletions ChatCore/Services/Twitch/TwitchService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ internal void Stop()
_isStarted = false;
_channels.Clear();

LoggedInUser = null!;
_loggedInUsername = null!;
LoggedInUser = null;
_loggedInUsername = null;

_websocketService.Disconnect();
}
Expand Down Expand Up @@ -197,7 +197,7 @@ private void _websocketService_OnMessageReceived(Assembly assembly, string rawMe
_channels[twitchMessage.Channel.Id] = twitchMessage.Channel;
_dataProvider.TryRequestChannelResources(twitchMessage.Channel.AsTwitchChannel()!, resources =>
{
ChannelResourceDataCached?.InvokeAll(assembly!, this, twitchMessage.Channel, resources);
ChannelResourceDataCached.InvokeAll(assembly!, this, twitchMessage.Channel, resources);
});
RoomStateUpdatedCallbacks?.InvokeAll(assembly!, this, twitchMessage.Channel, _logger);
continue;
Expand Down

0 comments on commit fc79af3

Please sign in to comment.