Skip to content

Commit a5c0dc3

Browse files
authored
Merge pull request #1894 from UnderminersTeam/warning-error-cleanup
Clean up some warnings and errors
2 parents 38933d1 + 46ff3bf commit a5c0dc3

21 files changed

+65
-42
lines changed

UndertaleModCli/CommandOptions/DumpOptions.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace UndertaleModCli;
44

5-
// ReSharper disable NotNullMemberIsNotInitialized - Properties are applied via reflection.
65
/// <summary>
76
/// Cli options for the Dump command
87
/// </summary>
@@ -16,7 +15,7 @@ public class DumpOptions
1615
/// <summary>
1716
/// Directory path to where to dump all contents
1817
/// </summary>
19-
public DirectoryInfo? Output { get; set; }
18+
public DirectoryInfo Output { get; set; }
2019

2120
/// <summary>
2221
/// Determines if Cli should print out verbose logs
@@ -37,4 +36,4 @@ public class DumpOptions
3736
/// Determines if embedded textures should get dumped
3837
/// </summary>
3938
public bool Textures { get; set; }
40-
}
39+
}

UndertaleModCli/CommandOptions/InfoOptions.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace UndertaleModCli;
44

5-
// ReSharper disable NotNullMemberIsNotInitialized - Properties are applied via reflection.
65
/// <summary>
76
/// Cli options for the Info command
87
/// </summary>
@@ -17,4 +16,4 @@ public class InfoOptions
1716
/// Determines if Cli should print out verbose logs
1817
/// </summary>
1918
public bool Verbose { get; set; } = false;
20-
}
19+
}

UndertaleModCli/CommandOptions/LoadOptions.cs

+3-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace UndertaleModCli;
44

5-
// ReSharper disable NotNullMemberIsNotInitialized - Properties are applied via reflection.
65
/// <summary>
76
/// Cli options for the Load command
87
/// </summary>
@@ -21,12 +20,12 @@ public class LoadOptions
2120
/// <summary>
2221
/// C# string that shall be executed
2322
/// </summary>
24-
public string? Line { get; set; }
23+
public string Line { get; set; }
2524

2625
/// <summary>
2726
/// File path to where to save the modified data file
2827
/// </summary>
29-
public FileInfo? Output { get; set; }
28+
public FileInfo Output { get; set; }
3029

3130
/// <summary>
3231
/// Determines if Cli should be run in interactive mode
@@ -37,4 +36,4 @@ public class LoadOptions
3736
/// Determines if Cli should print out verbose logs
3837
/// </summary>
3938
public bool Verbose { get; set; } = false;
40-
}
39+
}

UndertaleModCli/CommandOptions/NewOptions.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace UndertaleModCli;
44

5-
// ReSharper disable NotNullMemberIsNotInitialized - Properties are applied via reflection.
65
/// <summary>
76
/// Cli options for the New command
87
/// </summary>
@@ -27,4 +26,4 @@ public class NewOptions
2726
/// Determines if Cli should print out verbose logs
2827
/// </summary>
2928
public bool Verbose { get; set; } = false;
30-
}
29+
}

UndertaleModCli/CommandOptions/ReplaceOptions.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace UndertaleModCli;
44

5-
// ReSharper disable NotNullMemberIsNotInitialized - Properties are applied via reflection.
65
/// <summary>
76
/// Cli options for the Replace command
87
/// </summary>
@@ -16,7 +15,7 @@ public class ReplaceOptions
1615
/// <summary>
1716
/// File path to where to save the modified data file
1817
/// </summary>
19-
public FileInfo? Output { get; set; }
18+
public FileInfo Output { get; set; }
2019

2120
/// <summary>
2221
/// Determines if Cli should print out verbose logs
@@ -32,4 +31,4 @@ public class ReplaceOptions
3231
/// Equal separated values of embedded texture and the file to replace the embedded texture with.
3332
/// </summary>
3433
public string[] Textures { get; set; }
35-
}
34+
}

UndertaleModCli/Program.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -732,8 +732,8 @@ private void RunCSharpFile(string path)
732732
/// Evaluates and executes given C# code.
733733
/// </summary>
734734
/// <param name="code">The C# string to execute</param>
735-
/// <param name="scriptFile">The path to the script file where <see cref="code"/> was executed from.
736-
/// Leave as null, if it wasn't executed from a script file</param>
735+
/// <param name="scriptFile">The path to the script file where <paramref name="code"/> was loaded from.
736+
/// Leave as null, if it wasn't executed from a script file.</param>
737737
private void RunCSharpCode(string code, string scriptFile = null)
738738
{
739739
if (Verbose)

UndertaleModLib/Scripting/IScriptInterface.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,9 @@ bool AreFilesIdentical(string file1, string file2)
313313
Task ClickableSearchOutput(string title, string query, int resultsCount, IDictionary<string, List<(int lineNum, string codeLine)>> resultsDict, bool showInDecompiledView, IEnumerable<string> failedList = null);
314314

315315
/// <summary>
316-
/// Sets <see cref="isFinishedMessageEnabled"/>.
316+
/// Sets whether or not the current script should show a message indicating that it completed.
317317
/// </summary>
318-
/// <param name="isFinishedMessageEnabled">The state to set it to.</param>
318+
/// <param name="isFinishedMessageEnabled">True to enable the finished message; false otherwise.</param>
319319
void SetFinishedMessage(bool isFinishedMessageEnabled);
320320

321321
/// <summary>

UndertaleModLibTests/Models/StringTest.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public void TestUnescapeText(string text, string expected)
3434
[InlineData(null, null, false)]
3535
[InlineData("hi", null, false)]
3636
[InlineData(null, "null", false)]
37-
public void TestSearchMatches(string text, string substring, bool expected)
37+
public void TestSearchMatches(string? text, string? substring, bool expected)
3838
{
3939
UndertaleString utString = new UndertaleString(text);
4040

UndertaleModTests/GameScriptTests.cs

+14
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,20 @@ public string DummyString()
319319
{
320320
return "";
321321
}
322+
323+
public Task ClickableSearchOutput(string title, string query, int resultsCount, IOrderedEnumerable<KeyValuePair<string, List<(int lineNum, string codeLine)>>> resultsDict, bool showInDecompiledView, IOrderedEnumerable<string> failedList = null)
324+
{
325+
throw new NotImplementedException();
326+
}
327+
328+
public Task ClickableSearchOutput(string title, string query, int resultsCount, IDictionary<string, List<(int lineNum, string codeLine)>> resultsDict, bool showInDecompiledView, IEnumerable<string> failedList = null)
329+
{
330+
throw new NotImplementedException();
331+
}
332+
333+
public void ChangeSelection(object newSelection, bool inNewTab = false)
334+
{
335+
}
322336
}
323337

324338
[TestClass]

UndertaleModTool/Editors/UndertaleFontEditor/EditGlyphRectangleWindow.xaml.cs

+2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ public partial class EditGlyphRectangleWindow : Window, INotifyPropertyChanged
3535
private short initShift;
3636
private Canvas canvas;
3737

38+
#pragma warning disable CS0067 // Event is never used (this is actually used)
3839
public event PropertyChangedEventHandler PropertyChanged;
40+
#pragma warning restore CS0067
3941

4042
public EditGlyphRectangleWindow(UndertaleFont font, UndertaleFont.Glyph selectedGlyph)
4143
{

UndertaleModTool/Editors/UndertaleRoomEditor.xaml.cs

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#pragma warning disable CA1416 // Validate platform compatibility
2+
13
using Microsoft.Win32;
24
using System;
35
using System.Buffers;
@@ -2710,3 +2712,5 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu
27102712
}
27112713
}
27122714
}
2715+
2716+
#pragma warning restore CA1416 // Validate platform compatibility

UndertaleModTool/Editors/UndertaleShaderEditor.xaml.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using ICSharpCode.AvalonEdit;
1+
#pragma warning disable CA1416 // Validate platform compatibility
2+
3+
using ICSharpCode.AvalonEdit;
24
using System;
35
using System.Collections.Generic;
46
using System.Linq;
@@ -68,3 +70,5 @@ private void TextEditor_LostFocus(object sender, RoutedEventArgs e)
6870
}
6971
}
7072
}
73+
74+
#pragma warning restore CA1416 // Validate platform compatibility

UndertaleModTool/Editors/UndertaleSoundEditor.xaml.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using System;
1+
#pragma warning disable CA1416 // Validate platform compatibility
2+
3+
using System;
24
using System.Collections.Generic;
35
using System.IO;
46
using System.Linq;
@@ -180,3 +182,5 @@ private void Stop_Click(object sender, RoutedEventArgs e)
180182
}
181183
}
182184
}
185+
186+
#pragma warning restore CA1416 // Validate platform compatibility

UndertaleModTool/MainWindow.xaml.cs

+5-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using Microsoft.CodeAnalysis;
1+
#pragma warning disable CA1416 // Validate platform compatibility
2+
3+
using Microsoft.CodeAnalysis;
24
using Microsoft.CodeAnalysis.CSharp.Scripting;
35
using Microsoft.CodeAnalysis.Scripting;
46
using Microsoft.Win32;
@@ -775,7 +777,6 @@ public async Task<SaveResult> SaveCodeChanges()
775777
return SaveResult.Error;
776778
}
777779

778-
#pragma warning disable CA1416
779780
if (codeEditor.DecompiledChanged || codeEditor.DisassemblyChanged)
780781
{
781782
IsSaving = true;
@@ -786,7 +787,6 @@ public async Task<SaveResult> SaveCodeChanges()
786787
result = IsSaving ? SaveResult.Error : SaveResult.Saved;
787788
IsSaving = false;
788789
}
789-
#pragma warning restore CA1416
790790

791791
return result;
792792
}
@@ -1074,10 +1074,8 @@ private async Task LoadFile(string filename, bool preventClose = false, bool onl
10741074
? "Tile sets"
10751075
: "Backgrounds & Tile sets";
10761076

1077-
#pragma warning disable CA1416
10781077
UndertaleCodeEditor.gettext = null;
10791078
UndertaleCodeEditor.gettextJSON = null;
1080-
#pragma warning restore CA1416
10811079
}
10821080

10831081
dialog.Hide();
@@ -1272,9 +1270,7 @@ private async Task SaveFile(string filename, bool suppressDebug = false)
12721270
Data.ToolInfo.CurrentMD5 = BitConverter.ToString(MD5CurrentlyLoaded).Replace("-", "").ToLowerInvariant();
12731271
}
12741272

1275-
#pragma warning disable CA1416
12761273
UndertaleCodeEditor.gettextJSON = null;
1277-
#pragma warning restore CA1416
12781274

12791275
Dispatcher.Invoke(() =>
12801276
{
@@ -2477,7 +2473,6 @@ public void OpenCodeEntry(string name, int lineNum, UndertaleCodeEditor.CodeEdit
24772473
{
24782474
Focus();
24792475

2480-
#pragma warning disable CA1416
24812476
if (Selected == code)
24822477
{
24832478
var codeEditor = FindVisualChild<UndertaleCodeEditor>(DataEditor);
@@ -2512,7 +2507,6 @@ public void OpenCodeEntry(string name, int lineNum, UndertaleCodeEditor.CodeEdit
25122507
UndertaleCodeEditor.EditorTab = editorTab;
25132508
UndertaleCodeEditor.ChangeLineNumber(lineNum, editorTab);
25142509
}
2515-
#pragma warning restore CA1416
25162510

25172511
HighlightObject(code);
25182512
ChangeSelection(code, inNewTab);
@@ -2744,21 +2738,18 @@ public string PromptLoadFile(string defaultExt, string filter)
27442738
return dlg.ShowDialog() == true ? dlg.FileName : null;
27452739
}
27462740

2747-
#pragma warning disable CA1416
27482741
public string PromptChooseDirectory()
27492742
{
27502743
VistaFolderBrowserDialog folderBrowser = new VistaFolderBrowserDialog();
27512744
// vista dialog doesn't suffix the folder name with "/", so we're fixing it here.
27522745
return folderBrowser.ShowDialog() == true ? folderBrowser.SelectedPath + "/" : null;
27532746
}
27542747

2755-
#pragma warning disable CA1416
27562748
public void PlayInformationSound()
27572749
{
27582750
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
27592751
System.Media.SystemSounds.Asterisk.Play();
27602752
}
2761-
#pragma warning restore CA1416
27622753

27632754
public void ScriptMessage(string message)
27642755
{
@@ -4078,3 +4069,5 @@ public DescriptionView(string heading, string description)
40784069
}
40794070
}
40804071
}
4072+
4073+
#pragma warning restore CA1416 // Validate platform compatibility

UndertaleModTool/MessageBoxExtensions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public static MessageBoxResult ShowQuestion(this Window window, string messageBo
4141
/// <param name="messageBoxText">A <see cref="string"/> that specifies the text to display.</param>
4242
/// <param name="icon">The <see cref="MessageBoxImage"/> to display.</param>
4343
/// <param name="title">A <see cref="string"/> that specifies the title bar caption to display.</param>
44-
/// <returns><see cref="MessageBoxResult.Yes"/>, <see cref="MessageBoxResult.No"/> or <see cref="MessageBoxResult.Cancel"/> depending on the users' answer.
44+
/// <returns><see cref="MessageBoxResult.Yes"/>, <see cref="MessageBoxResult.No"/> or <see cref="MessageBoxResult.Cancel"/> depending on the users' answer.</returns>
4545
public static MessageBoxResult ShowQuestionWithCancel(this Window window, string messageBoxText, MessageBoxImage icon = MessageBoxImage.Question, string title = "UndertaleModTool")
4646
{
4747
return ShowCore(window, messageBoxText, title, MessageBoxButton.YesNoCancel, icon);

UndertaleModTool/Program.cs

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using System;
1+
#pragma warning disable CA1416 // Validate platform compatibility
2+
3+
using System;
24
using System.Collections.Generic;
35
using log4net;
46
using System.Diagnostics;
@@ -21,7 +23,7 @@ public static string GetExecutableDirectory()
2123
}
2224

2325
// https://stackoverflow.com/questions/1025843/merging-dlls-into-a-single-exe-with-wpf
24-
[STAThreadAttribute]
26+
[STAThread]
2527
public static void Main()
2628
{
2729
try
@@ -59,3 +61,5 @@ private static void GlobalThreadExceptionHandler(object sender, System.Threading
5961
}
6062
}
6163
}
64+
65+
#pragma warning restore CA1416 // Validate platform compatibility

UndertaleModTool/ScriptingFunctions.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using Microsoft.CodeAnalysis.CSharp.Scripting;
1616
using Microsoft.CodeAnalysis.Scripting;
1717
using System.IO.Pipes;
18+
using System.Threading.Tasks;
1819

1920
namespace UndertaleModTool
2021
{
@@ -29,7 +30,7 @@ public bool RunUMTScript(string path)
2930
ScriptError(path + " does not exist!");
3031
return false;
3132
}
32-
RunScript(path);
33+
RunScript(path).GetAwaiter().GetResult();
3334
if (!ScriptExecutionSuccess)
3435
ScriptError("An error of type \"" + ScriptErrorType + "\" occurred. The error is:\n\n" + ScriptErrorMessage, ScriptErrorType);
3536
return ScriptExecutionSuccess;

UndertaleModTool/Scripts/Helper Scripts/ConvertFrom17to16.csx

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ EnsureDataLoaded();
44

55
if (Data.IsVersionAtLeast(2, 3))
66
{
7-
bool x = RunUMTScript(Path.Combine(ExePath, "Scripts", "Helper Scripts", "ConvertFrom17to16_for_2.3.csx"));
7+
bool x = await RunUMTScript(Path.Combine(ExePath, "Scripts", "Helper Scripts", "ConvertFrom17to16_for_2.3.csx"));
88
if (x == false)
99
ScriptError("ConvertFrom17to16_for_2.3.csx failed!");
1010
return;

UndertaleModTool/Scripts/Technical Scripts/15_to_17_To_16.csx

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//Need to test this, once I do then I can obsolete the other two scripts
44
if (Data.IsVersionAtLeast(2, 3))
55
{
6-
bool x = RunUMTScript(Path.Combine(ExePath, "Scripts", "Helper Scripts", "ConvertFrom17to16_for_2.3.csx"));
6+
bool x = await RunUMTScript(Path.Combine(ExePath, "Scripts", "Helper Scripts", "ConvertFrom17to16_for_2.3.csx"));
77
if (x == false)
88
ScriptError("ConvertFrom17to16_for_2.3.csx failed!");
99
return;

UndertaleModTool/Windows/FindReferencesTypesDialog/UndertaleResourceReferenceMethodsMap.cs

-2
Original file line numberDiff line numberDiff line change
@@ -1455,8 +1455,6 @@ public static async Task<Dictionary<string, List<object>>> GetUnreferencedObject
14551455
{
14561456
UndertaleResourceReferenceMethodsMap.data = data;
14571457

1458-
var ver = (data.GeneralInfo.Major, data.GeneralInfo.Minor, data.GeneralInfo.Release);
1459-
14601458
Dictionary<string, List<object>> outDict = new();
14611459

14621460
List<(IList, string)> assetLists = new();

UndertaleModTool/Windows/TextInput.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using System;
1+
#pragma warning disable CA1416 // Validate platform compatibility
2+
3+
using System;
24
using System.Collections.Generic;
35
using System.ComponentModel;
46
using System.Data;
@@ -179,3 +181,5 @@ private void textCopyMenu_Opening(object sender, CancelEventArgs e)
179181
}
180182
}
181183
}
184+
185+
#pragma warning restore CA1416 // Validate platform compatibility

0 commit comments

Comments
 (0)