From 650af7ef1ac1957919ab19ec3d06af97792c54f8 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 9 Apr 2022 13:59:56 -0400 Subject: [PATCH] enable nullable annotations in log parser (#837) --- .../Controllers/LogParserController.cs | 8 +-- .../Framework/LogParsing/LogMessageBuilder.cs | 25 ++++--- .../Framework/LogParsing/LogParseException.cs | 2 - .../Framework/LogParsing/LogParser.cs | 54 +++++++------- .../Framework/LogParsing/Models/LogMessage.cs | 38 ++++++++-- .../Framework/LogParsing/Models/LogModInfo.cs | 71 +++++++++++++++---- .../Framework/LogParsing/Models/ParsedLog.cs | 20 +++--- src/SMAPI.Web/ViewModels/LogParserModel.cs | 51 +++++++++---- src/SMAPI.Web/Views/LogParser/Index.cshtml | 21 +++--- 9 files changed, 185 insertions(+), 105 deletions(-) diff --git a/src/SMAPI.Web/Controllers/LogParserController.cs b/src/SMAPI.Web/Controllers/LogParserController.cs index 524cfbcc..93f2613e 100644 --- a/src/SMAPI.Web/Controllers/LogParserController.cs +++ b/src/SMAPI.Web/Controllers/LogParserController.cs @@ -1,5 +1,3 @@ -#nullable disable - using System; using System.Linq; using System.Text; @@ -47,7 +45,7 @@ namespace StardewModdingAPI.Web.Controllers [HttpGet] [Route("log")] [Route("log/{id}")] - public async Task Index(string id = null, LogViewFormat format = LogViewFormat.Default, bool renew = false) + public async Task Index(string? id = null, LogViewFormat format = LogViewFormat.Default, bool renew = false) { // fresh page if (string.IsNullOrWhiteSpace(id)) @@ -89,7 +87,7 @@ namespace StardewModdingAPI.Web.Controllers public async Task PostAsync() { // get raw log text - string input = this.Request.Form["input"].FirstOrDefault(); + string? input = this.Request.Form["input"].FirstOrDefault(); if (string.IsNullOrWhiteSpace(input)) return this.View("Index", this.GetModel(null, uploadError: "The log file seems to be empty.")); @@ -111,7 +109,7 @@ namespace StardewModdingAPI.Web.Controllers /// When the uploaded file will no longer be available. /// A non-blocking warning while uploading the log. /// An error which occurred while uploading the log. - private LogParserModel GetModel(string pasteID, DateTime? expiry = null, string uploadWarning = null, string uploadError = null) + private LogParserModel GetModel(string? pasteID, DateTime? expiry = null, string? uploadWarning = null, string? uploadError = null) { Platform? platform = this.DetectClientPlatform(); diff --git a/src/SMAPI.Web/Framework/LogParsing/LogMessageBuilder.cs b/src/SMAPI.Web/Framework/LogParsing/LogMessageBuilder.cs index 1b692e63..a1384b8f 100644 --- a/src/SMAPI.Web/Framework/LogParsing/LogMessageBuilder.cs +++ b/src/SMAPI.Web/Framework/LogParsing/LogMessageBuilder.cs @@ -1,6 +1,5 @@ -#nullable disable - using System; +using System.Diagnostics.CodeAnalysis; using System.Text; using StardewModdingAPI.Web.Framework.LogParsing.Models; @@ -13,7 +12,7 @@ namespace StardewModdingAPI.Web.Framework.LogParsing ** Fields *********/ /// The local time when the next log was posted. - public string Time { get; set; } + public string? Time { get; set; } /// The log level for the next log message. public LogLevel Level { get; set; } @@ -22,7 +21,7 @@ namespace StardewModdingAPI.Web.Framework.LogParsing public int ScreenId { get; set; } /// The mod name for the next log message. - public string Mod { get; set; } + public string? Mod { get; set; } /// The text for the next log message. private readonly StringBuilder Text = new(); @@ -32,6 +31,7 @@ namespace StardewModdingAPI.Web.Framework.LogParsing ** Accessors *********/ /// Whether the next log message has been started. + [MemberNotNullWhen(true, nameof(LogMessageBuilder.Time), nameof(LogMessageBuilder.Mod))] public bool Started { get; private set; } @@ -72,19 +72,18 @@ namespace StardewModdingAPI.Web.Framework.LogParsing } /// Get a log message for the accumulated values. - public LogMessage Build() + public LogMessage? Build() { if (!this.Started) return null; - return new LogMessage - { - Time = this.Time, - Level = this.Level, - ScreenId = this.ScreenId, - Mod = this.Mod, - Text = this.Text.ToString() - }; + return new LogMessage( + time: this.Time, + level: this.Level, + screenId: this.ScreenId, + mod: this.Mod, + text: this.Text.ToString() + ); } /// Reset to start a new log message. diff --git a/src/SMAPI.Web/Framework/LogParsing/LogParseException.cs b/src/SMAPI.Web/Framework/LogParsing/LogParseException.cs index 4ee58433..3f815e3e 100644 --- a/src/SMAPI.Web/Framework/LogParsing/LogParseException.cs +++ b/src/SMAPI.Web/Framework/LogParsing/LogParseException.cs @@ -1,5 +1,3 @@ -#nullable disable - using System; namespace StardewModdingAPI.Web.Framework.LogParsing diff --git a/src/SMAPI.Web/Framework/LogParsing/LogParser.cs b/src/SMAPI.Web/Framework/LogParsing/LogParser.cs index 4e61ac95..55272b23 100644 --- a/src/SMAPI.Web/Framework/LogParsing/LogParser.cs +++ b/src/SMAPI.Web/Framework/LogParsing/LogParser.cs @@ -1,5 +1,3 @@ -#nullable disable - using System; using System.Collections.Generic; using System.IO; @@ -55,7 +53,7 @@ namespace StardewModdingAPI.Web.Framework.LogParsing *********/ /// Parse SMAPI log text. /// The SMAPI log text. - public ParsedLog Parse(string logText) + public ParsedLog Parse(string? logText) { try { @@ -79,8 +77,8 @@ namespace StardewModdingAPI.Web.Framework.LogParsing }; // parse log messages - LogModInfo smapiMod = new() { Name = "SMAPI", Author = "Pathoschild", Description = "", Loaded = true }; - LogModInfo gameMod = new() { Name = "game", Author = "", Description = "", Loaded = true }; + LogModInfo smapiMod = new(name: "SMAPI", author: "Pathoschild", version: "", description: "", loaded: true); + LogModInfo gameMod = new(name: "game", author: "", version: "", description: "", loaded: true); IDictionary> mods = new Dictionary>(); bool inModList = false; bool inContentPackList = false; @@ -103,7 +101,7 @@ namespace StardewModdingAPI.Web.Framework.LogParsing default: if (mods.TryGetValue(message.Mod, out var entries)) { - foreach (var entry in entries) + foreach (LogModInfo entry in entries) entry.Errors++; } break; @@ -133,9 +131,9 @@ namespace StardewModdingAPI.Web.Framework.LogParsing string author = match.Groups["author"].Value; string description = match.Groups["description"].Value; - if (!mods.TryGetValue(name, out List entries)) + if (!mods.TryGetValue(name, out List? entries)) mods[name] = entries = new List(); - entries.Add(new LogModInfo { Name = name, Author = author, Version = version, Description = description, Loaded = true }); + entries.Add(new LogModInfo(name: name, author: author, version: version, description: description, loaded: true)); message.Section = LogSection.ModsList; } @@ -156,9 +154,9 @@ namespace StardewModdingAPI.Web.Framework.LogParsing string description = match.Groups["description"].Value; string forMod = match.Groups["for"].Value; - if (!mods.TryGetValue(name, out List entries)) + if (!mods.TryGetValue(name, out List? entries)) mods[name] = entries = new List(); - entries.Add(new LogModInfo { Name = name, Author = author, Version = version, Description = description, ContentPackFor = forMod, Loaded = true }); + entries.Add(new LogModInfo(name: name, author: author, version: version, description: description, contentPackFor: forMod, loaded: true)); message.Section = LogSection.ContentPackList; } @@ -179,23 +177,19 @@ namespace StardewModdingAPI.Web.Framework.LogParsing if (mods.TryGetValue(name, out var entries)) { - foreach (var entry in entries) - { - entry.UpdateLink = link; - entry.UpdateVersion = version; - } + foreach (LogModInfo entry in entries) + entry.SetUpdate(version, link); } message.Section = LogSection.ModUpdateList; } - else if (message.Level == LogLevel.Alert && this.SmapiUpdatePattern.IsMatch(message.Text)) { Match match = this.SmapiUpdatePattern.Match(message.Text); string version = match.Groups["version"].Value; string link = match.Groups["link"].Value; - smapiMod.UpdateVersion = version; - smapiMod.UpdateLink = link; + + smapiMod.SetUpdate(version, link); } // platform info line @@ -205,7 +199,7 @@ namespace StardewModdingAPI.Web.Framework.LogParsing log.ApiVersion = match.Groups["apiVersion"].Value; log.GameVersion = match.Groups["gameVersion"].Value; log.OperatingSystem = match.Groups["os"].Value; - smapiMod.Version = log.ApiVersion; + smapiMod.OverrideVersion(log.ApiVersion); } // mod path line @@ -215,7 +209,7 @@ namespace StardewModdingAPI.Web.Framework.LogParsing log.ModPath = match.Groups["path"].Value; int lastDelimiterPos = log.ModPath.LastIndexOfAny(new[] { '/', '\\' }); log.GamePath = lastDelimiterPos >= 0 - ? log.ModPath.Substring(0, lastDelimiterPos) + ? log.ModPath[..lastDelimiterPos] : log.ModPath; } @@ -229,7 +223,8 @@ namespace StardewModdingAPI.Web.Framework.LogParsing } // finalize log - gameMod.Version = log.GameVersion; + if (log.GameVersion != null) + gameMod.OverrideVersion(log.GameVersion); log.Mods = new[] { gameMod, smapiMod }.Concat(mods.Values.SelectMany(p => p).OrderBy(p => p.Name)).ToArray(); return log; } @@ -261,7 +256,8 @@ namespace StardewModdingAPI.Web.Framework.LogParsing /// The messages to filter. private IEnumerable CollapseRepeats(IEnumerable messages) { - LogMessage next = null; + LogMessage? next = null; + foreach (LogMessage message in messages) { // new message @@ -282,7 +278,9 @@ namespace StardewModdingAPI.Web.Framework.LogParsing yield return next; next = message; } - yield return next; + + if (next != null) + yield return next; } /// Split a SMAPI log into individual log messages. @@ -295,7 +293,7 @@ namespace StardewModdingAPI.Web.Framework.LogParsing while (true) { // read line - string line = reader.ReadLine(); + string? line = reader.ReadLine(); if (line == null) break; @@ -308,17 +306,17 @@ namespace StardewModdingAPI.Web.Framework.LogParsing { if (builder.Started) { - yield return builder.Build(); + yield return builder.Build()!; builder.Clear(); } - var screenGroup = header.Groups["screen"]; + Group screenGroup = header.Groups["screen"]; builder.Start( time: header.Groups["time"].Value, level: Enum.Parse(header.Groups["level"].Value, ignoreCase: true), screenId: screenGroup.Success ? int.Parse(screenGroup.Value) : 0, // main player is always screen ID 0 mod: header.Groups["modName"].Value, - text: line.Substring(header.Length) + text: line[header.Length..] ); } else @@ -332,7 +330,7 @@ namespace StardewModdingAPI.Web.Framework.LogParsing // end last message if (builder.Started) - yield return builder.Build(); + yield return builder.Build()!; } } } diff --git a/src/SMAPI.Web/Framework/LogParsing/Models/LogMessage.cs b/src/SMAPI.Web/Framework/LogParsing/Models/LogMessage.cs index 57d28755..7a5f32e0 100644 --- a/src/SMAPI.Web/Framework/LogParsing/Models/LogMessage.cs +++ b/src/SMAPI.Web/Framework/LogParsing/Models/LogMessage.cs @@ -1,4 +1,4 @@ -#nullable disable +using System.Diagnostics.CodeAnalysis; namespace StardewModdingAPI.Web.Framework.LogParsing.Models { @@ -9,19 +9,19 @@ namespace StardewModdingAPI.Web.Framework.LogParsing.Models ** Accessors *********/ /// The local time when the log was posted. - public string Time { get; set; } + public string Time { get; } /// The log level. - public LogLevel Level { get; set; } + public LogLevel Level { get; } /// The screen ID in split-screen mode. - public int ScreenId { get; set; } + public int ScreenId { get; } /// The mod name. - public string Mod { get; set; } + public string Mod { get; } /// The log text. - public string Text { get; set; } + public string Text { get; } /// The number of times this message was repeated consecutively. public int Repeated { get; set; } @@ -30,6 +30,32 @@ namespace StardewModdingAPI.Web.Framework.LogParsing.Models public LogSection? Section { get; set; } /// Whether this message is the first one of its section. + [MemberNotNullWhen(true, nameof(LogMessage.Section))] public bool IsStartOfSection { get; set; } + + + /********* + ** Public methods + *********/ + /// Construct an instance/ + /// The local time when the log was posted. + /// The log level. + /// The screen ID in split-screen mode. + /// The mod name. + /// The log text. + /// The number of times this message was repeated consecutively. + /// The section that this log message belongs to. + /// Whether this message is the first one of its section. + public LogMessage(string time, LogLevel level, int screenId, string mod, string text, int repeated = 0, LogSection? section = null, bool isStartOfSection = false) + { + this.Time = time; + this.Level = level; + this.ScreenId = screenId; + this.Mod = mod; + this.Text = text; + this.Repeated = repeated; + this.Section = section; + this.IsStartOfSection = isStartOfSection; + } } } diff --git a/src/SMAPI.Web/Framework/LogParsing/Models/LogModInfo.cs b/src/SMAPI.Web/Framework/LogParsing/Models/LogModInfo.cs index 349312df..a6b9165c 100644 --- a/src/SMAPI.Web/Framework/LogParsing/Models/LogModInfo.cs +++ b/src/SMAPI.Web/Framework/LogParsing/Models/LogModInfo.cs @@ -1,4 +1,4 @@ -#nullable disable +using System.Diagnostics.CodeAnalysis; namespace StardewModdingAPI.Web.Framework.LogParsing.Models { @@ -9,36 +9,81 @@ namespace StardewModdingAPI.Web.Framework.LogParsing.Models ** Accessors *********/ /// The mod name. - public string Name { get; set; } + public string Name { get; } /// The mod author. - public string Author { get; set; } - - /// The update version. - public string UpdateVersion { get; set; } - - /// The update link. - public string UpdateLink { get; set; } + public string Author { get; } /// The mod version. - public string Version { get; set; } + public string Version { get; private set; } /// The mod description. - public string Description { get; set; } + public string Description { get; } + + /// The update version. + public string? UpdateVersion { get; private set; } + + /// The update link. + public string? UpdateLink { get; private set; } /// The name of the mod for which this is a content pack (if applicable). - public string ContentPackFor { get; set; } + public string? ContentPackFor { get; } /// The number of errors logged by this mod. public int Errors { get; set; } /// Whether the mod was loaded into the game. - public bool Loaded { get; set; } + public bool Loaded { get; } /// Whether the mod has an update available. + [MemberNotNullWhen(true, nameof(LogModInfo.UpdateVersion), nameof(LogModInfo.UpdateLink))] public bool HasUpdate => this.UpdateVersion != null && this.Version != this.UpdateVersion; /// Whether the mod is a content pack for another mod. + [MemberNotNullWhen(true, nameof(LogModInfo.ContentPackFor))] public bool IsContentPack => !string.IsNullOrWhiteSpace(this.ContentPackFor); + + + /********* + ** Public methods + *********/ + /// Construct an instance. + /// The mod name. + /// The mod author. + /// The mod version. + /// The mod description. + /// The update version. + /// The update link. + /// The name of the mod for which this is a content pack (if applicable). + /// The number of errors logged by this mod. + /// Whether the mod was loaded into the game. + public LogModInfo(string name, string author, string version, string description, string? updateVersion = null, string? updateLink = null, string? contentPackFor = null, int errors = 0, bool loaded = true) + { + this.Name = name; + this.Author = author; + this.Version = version; + this.Description = description; + this.UpdateVersion = updateVersion; + this.UpdateLink = updateLink; + this.ContentPackFor = contentPackFor; + this.Errors = errors; + this.Loaded = loaded; + } + + /// Add an update alert for this mod. + /// The update version. + /// The update link. + public void SetUpdate(string updateVersion, string updateLink) + { + this.UpdateVersion = updateVersion; + this.UpdateLink = updateLink; + } + + /// Override the version number, for cases like SMAPI itself where the version is only known later during parsing. + /// The new mod version. + public void OverrideVersion(string version) + { + this.Version = version; + } } } diff --git a/src/SMAPI.Web/Framework/LogParsing/Models/ParsedLog.cs b/src/SMAPI.Web/Framework/LogParsing/Models/ParsedLog.cs index dae91d84..6951e434 100644 --- a/src/SMAPI.Web/Framework/LogParsing/Models/ParsedLog.cs +++ b/src/SMAPI.Web/Framework/LogParsing/Models/ParsedLog.cs @@ -1,6 +1,5 @@ -#nullable disable - using System; +using System.Diagnostics.CodeAnalysis; namespace StardewModdingAPI.Web.Framework.LogParsing.Models { @@ -14,31 +13,32 @@ namespace StardewModdingAPI.Web.Framework.LogParsing.Models ** Metadata ****/ /// Whether the log file was successfully parsed. + [MemberNotNullWhen(true, nameof(ParsedLog.RawText))] public bool IsValid { get; set; } /// An error message indicating why the log file is invalid. - public string Error { get; set; } + public string? Error { get; set; } /// The raw log text. - public string RawText { get; set; } + public string? RawText { get; set; } /**** ** Log data ****/ /// The SMAPI version. - public string ApiVersion { get; set; } + public string? ApiVersion { get; set; } /// The game version. - public string GameVersion { get; set; } + public string? GameVersion { get; set; } /// The player's operating system. - public string OperatingSystem { get; set; } + public string? OperatingSystem { get; set; } /// The game install path. - public string GamePath { get; set; } + public string? GamePath { get; set; } /// The mod folder path. - public string ModPath { get; set; } + public string? ModPath { get; set; } /// The ISO 8601 timestamp when the log was started. public DateTimeOffset Timestamp { get; set; } @@ -47,6 +47,6 @@ namespace StardewModdingAPI.Web.Framework.LogParsing.Models public LogModInfo[] Mods { get; set; } = Array.Empty(); /// The log messages. - public LogMessage[] Messages { get; set; } + public LogMessage[] Messages { get; set; } = Array.Empty(); } } diff --git a/src/SMAPI.Web/ViewModels/LogParserModel.cs b/src/SMAPI.Web/ViewModels/LogParserModel.cs index c768a08c..d7e4d810 100644 --- a/src/SMAPI.Web/ViewModels/LogParserModel.cs +++ b/src/SMAPI.Web/ViewModels/LogParserModel.cs @@ -1,9 +1,9 @@ -#nullable disable - using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Text.RegularExpressions; +using Newtonsoft.Json; using StardewModdingAPI.Toolkit.Utilities; using StardewModdingAPI.Web.Framework.LogParsing.Models; @@ -23,40 +23,41 @@ namespace StardewModdingAPI.Web.ViewModels ** Accessors *********/ /// The paste ID. - public string PasteID { get; set; } + public string? PasteID { get; } /// The viewer's detected OS, if known. - public Platform? DetectedPlatform { get; set; } + public Platform? DetectedPlatform { get; } /// The parsed log info. - public ParsedLog ParsedLog { get; set; } + public ParsedLog? ParsedLog { get; private set; } /// Whether to show the raw unparsed log. - public bool ShowRaw { get; set; } + public bool ShowRaw { get; private set; } /// A non-blocking warning while uploading the log. - public string UploadWarning { get; set; } + public string? UploadWarning { get; set; } /// An error which occurred while uploading the log. - public string UploadError { get; set; } + public string? UploadError { get; set; } /// An error which occurred while parsing the log file. - public string ParseError => this.ParsedLog?.Error; + public string? ParseError => this.ParsedLog?.Error; /// When the uploaded file will no longer be available. public DateTime? Expiry { get; set; } + /// Whether parsed log data is available. + [MemberNotNullWhen(true, nameof(LogParserModel.PasteID), nameof(LogParserModel.ParsedLog))] + public bool HasLog => this.ParsedLog != null; + /********* ** Public methods *********/ - /// Construct an instance. - public LogParserModel() { } - /// Construct an instance. /// The paste ID. /// The viewer's detected OS, if known. - public LogParserModel(string pasteID, Platform? platform) + public LogParserModel(string? pasteID, Platform? platform) { this.PasteID = pasteID; this.DetectedPlatform = platform; @@ -64,6 +65,26 @@ namespace StardewModdingAPI.Web.ViewModels this.ShowRaw = false; } + /// Construct an instance. + /// The paste ID. + /// The viewer's detected OS, if known. + /// The parsed log info. + /// Whether to show the raw unparsed log. + /// A non-blocking warning while uploading the log. + /// An error which occurred while uploading the log. + /// When the uploaded file will no longer be available. + [JsonConstructor] + public LogParserModel(string pasteId, Platform? detectedPlatform, ParsedLog? parsedLog, bool showRaw, string? uploadWarning, string? uploadError, DateTime? expiry) + { + this.PasteID = pasteId; + this.DetectedPlatform = detectedPlatform; + this.ParsedLog = parsedLog; + this.ShowRaw = showRaw; + this.UploadWarning = uploadWarning; + this.UploadError = uploadError; + this.Expiry = expiry; + } + /// Set the log parser result. /// The parsed log info. /// Whether to show the raw unparsed log. @@ -79,14 +100,14 @@ namespace StardewModdingAPI.Web.ViewModels public IDictionary GetContentPacksByMod() { // get all mods & content packs - LogModInfo[] mods = this.ParsedLog?.Mods; + LogModInfo[]? mods = this.ParsedLog?.Mods; if (mods == null || !mods.Any()) return new Dictionary(); // group by mod return mods .Where(mod => mod.IsContentPack) - .GroupBy(mod => mod.ContentPackFor) + .GroupBy(mod => mod.ContentPackFor!) .ToDictionary(group => group.Key, group => group.ToArray()); } diff --git a/src/SMAPI.Web/Views/LogParser/Index.cshtml b/src/SMAPI.Web/Views/LogParser/Index.cshtml index cf7e0a5c..a7552888 100644 --- a/src/SMAPI.Web/Views/LogParser/Index.cshtml +++ b/src/SMAPI.Web/Views/LogParser/Index.cshtml @@ -1,7 +1,3 @@ -@{ - #nullable disable -} - @using Humanizer @using StardewModdingAPI.Toolkit.Utilities @using StardewModdingAPI.Web.Framework @@ -12,7 +8,7 @@ @{ ViewData["Title"] = "SMAPI log parser"; - ParsedLog log = Model!.ParsedLog; + ParsedLog? log = Model!.ParsedLog; IDictionary contentPacks = Model.GetContentPacksByMod(); IDictionary defaultFilters = Enum @@ -29,7 +25,7 @@ string curPageUrl = this.Url.PlainAction("Index", "LogParser", new { id = Model.PasteID }, absoluteUrl: true); - ISet screenIds = new HashSet(log?.Messages?.Select(p => p.ScreenId) ?? Array.Empty()); + ISet screenIds = new HashSet(log?.Messages.Select(p => p.ScreenId) ?? Array.Empty()); } @section Head { @@ -58,7 +54,7 @@ messages: @this.ForJson(log?.Messages), sections: @this.ForJson(logSections), logLevels: @this.ForJson(logLevels), - modSlugs: @this.ForJson(log?.Mods?.DistinctBy(p => p.Name).Select(p => new { p.Name, Slug = Model.GetSlug(p.Name) }).Where(p => p.Name != p.Slug).ToDictionary(p => p.Name, p => p.Slug)), + modSlugs: @this.ForJson(log?.Mods.DistinctBy(p => p.Name).Select(p => new { p.Name, Slug = Model.GetSlug(p.Name) }).Where(p => p.Name != p.Slug).ToDictionary(p => p.Name, p => p.Slug)), screenIds: @this.ForJson(screenIds) }, @@ -68,7 +64,7 @@ data: null, } showPopup: @this.ForJson(log == null), - showMods: @this.ForJson(log?.Mods?.Select(p => Model.GetSlug(p.Name)).Distinct().ToDictionary(slug => slug, _ => true)), + showMods: @this.ForJson(log?.Mods.Select(p => Model.GetSlug(p.Name)).Distinct().ToDictionary(slug => slug, _ => true)), showSections: @this.ForJson(Enum.GetNames(typeof(LogSection)).ToDictionary(section => section, _ => false)), showLevels: @this.ForJson(defaultFilters), enableFilters: @this.ForJson(!Model.ShowRaw) @@ -76,7 +72,7 @@ "@this.Url.PlainAction("Index", "LogParser", values: null)" ); - new Tabby('[data-tabs]'); + new Tabby("[data-tabs]"); }); } @@ -217,12 +213,12 @@ else if (log?.IsValid == true) Consider updating these mods to fix problems: - @foreach (LogModInfo mod in log.Mods.Where(mod => (mod.HasUpdate && !mod.IsContentPack) || (contentPacks.TryGetValue(mod.Name, out LogModInfo[] contentPackList) && contentPackList.Any(pack => pack.HasUpdate)))) + @foreach (LogModInfo mod in log.Mods.Where(mod => (mod.HasUpdate && !mod.IsContentPack) || (contentPacks.TryGetValue(mod.Name, out LogModInfo[]? contentPackList) && contentPackList.Any(pack => pack.HasUpdate)))) {
@mod.Name - @if (contentPacks != null && contentPacks.TryGetValue(mod.Name, out LogModInfo[] contentPackList)) + @if (contentPacks != null && contentPacks.TryGetValue(mod.Name, out LogModInfo[]? contentPackList)) {
@foreach (LogModInfo contentPack in contentPackList.Where(pack => pack.HasUpdate)) @@ -305,8 +301,7 @@ else if (log?.IsValid == true) @foreach (var mod in log.Mods.Where(p => p.Loaded && !p.IsContentPack)) { - LogModInfo[]? contentPackList; - if (contentPacks == null || !contentPacks.TryGetValue(mod.Name, out contentPackList)) + if (contentPacks == null || !contentPacks.TryGetValue(mod.Name, out LogModInfo[]? contentPackList)) contentPackList = null;