Skip to content

Commit

Permalink
Clean up some warnings and errors
Browse files Browse the repository at this point in the history
  • Loading branch information
colinator27 committed Aug 27, 2024
1 parent dc1e209 commit 545933a
Show file tree
Hide file tree
Showing 21 changed files with 209 additions and 128 deletions.
8 changes: 7 additions & 1 deletion UndertaleModCli/CommandOptions/DumpOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace UndertaleModCli;

#nullable enable
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor - Properties are applied via reflection.

// ReSharper disable NotNullMemberIsNotInitialized - Properties are applied via reflection.
/// <summary>
/// Cli options for the Dump command
Expand Down Expand Up @@ -37,4 +40,7 @@ public class DumpOptions
/// Determines if embedded textures should get dumped
/// </summary>
public bool Textures { get; set; }
}
}

#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor - Properties are applied via reflection.
#nullable restore
8 changes: 7 additions & 1 deletion UndertaleModCli/CommandOptions/InfoOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace UndertaleModCli;

#nullable enable
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor - Properties are applied via reflection.

// ReSharper disable NotNullMemberIsNotInitialized - Properties are applied via reflection.
/// <summary>
/// Cli options for the Info command
Expand All @@ -17,4 +20,7 @@ public class InfoOptions
/// Determines if Cli should print out verbose logs
/// </summary>
public bool Verbose { get; set; } = false;
}
}

#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor - Properties are applied via reflection.
#nullable restore
8 changes: 7 additions & 1 deletion UndertaleModCli/CommandOptions/LoadOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace UndertaleModCli;

#nullable enable
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor - Properties are applied via reflection.

// ReSharper disable NotNullMemberIsNotInitialized - Properties are applied via reflection.
/// <summary>
/// Cli options for the Load command
Expand Down Expand Up @@ -37,4 +40,7 @@ public class LoadOptions
/// Determines if Cli should print out verbose logs
/// </summary>
public bool Verbose { get; set; } = false;
}
}

#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor - Properties are applied via reflection.
#nullable restore
8 changes: 7 additions & 1 deletion UndertaleModCli/CommandOptions/NewOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace UndertaleModCli;

#nullable enable
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor - Properties are applied via reflection.

// ReSharper disable NotNullMemberIsNotInitialized - Properties are applied via reflection.
/// <summary>
/// Cli options for the New command
Expand All @@ -27,4 +30,7 @@ public class NewOptions
/// Determines if Cli should print out verbose logs
/// </summary>
public bool Verbose { get; set; } = false;
}
}

#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor - Properties are applied via reflection.
#nullable restore
8 changes: 7 additions & 1 deletion UndertaleModCli/CommandOptions/ReplaceOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace UndertaleModCli;

#nullable enable
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor - Properties are applied via reflection.

// ReSharper disable NotNullMemberIsNotInitialized - Properties are applied via reflection.
/// <summary>
/// Cli options for the Replace command
Expand Down Expand Up @@ -32,4 +35,7 @@ public class ReplaceOptions
/// Equal separated values of embedded texture and the file to replace the embedded texture with.
/// </summary>
public string[] Textures { get; set; }
}
}

#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor - Properties are applied via reflection.
#nullable restore
4 changes: 2 additions & 2 deletions UndertaleModCli/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -731,8 +731,8 @@ private void RunCSharpFile(string path)
/// Evaluates and executes given C# code.
/// </summary>
/// <param name="code">The C# string to execute</param>
/// <param name="scriptFile">The path to the script file where <see cref="code"/> was executed from.
/// Leave as null, if it wasn't executed from a script file</param>
/// <param name="scriptFile">The path to the script file where the code was loaded from.
/// Leave as null, if it wasn't executed from a script file.</param>
private void RunCSharpCode(string code, string scriptFile = null)
{
if (Verbose)
Expand Down
4 changes: 2 additions & 2 deletions UndertaleModLib/Scripting/IScriptInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,9 @@ bool AreFilesIdentical(string file1, string file2)
Task ClickableSearchOutput(string title, string query, int resultsCount, IDictionary<string, List<(int lineNum, string codeLine)>> resultsDict, bool showInDecompiledView, IEnumerable<string> failedList = null);

/// <summary>
/// Sets <see cref="isFinishedMessageEnabled"/>.
/// Sets whether or not the script's "finished message" should be enabled, upon the current script's completion.
/// </summary>
/// <param name="isFinishedMessageEnabled">The state to set it to.</param>
/// <param name="isFinishedMessageEnabled">True to enable the finished message; false otherwise.</param>
void SetFinishedMessage(bool isFinishedMessageEnabled);

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion UndertaleModLibTests/Models/StringTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void TestUnescapeText(string text, string expected)
[InlineData(null, null, false)]
[InlineData("hi", null, false)]
[InlineData(null, "null", false)]
public void TestSearchMatches(string text, string substring, bool expected)
public void TestSearchMatches(string? text, string? substring, bool expected)
{
UndertaleString utString = new UndertaleString(text);

Expand Down
14 changes: 14 additions & 0 deletions UndertaleModTests/GameScriptTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,20 @@ public string DummyString()
{
return "";
}

public Task ClickableSearchOutput(string title, string query, int resultsCount, IOrderedEnumerable<KeyValuePair<string, List<(int lineNum, string codeLine)>>> resultsDict, bool showInDecompiledView, IOrderedEnumerable<string> failedList = null)
{
throw new NotImplementedException();
}

public Task ClickableSearchOutput(string title, string query, int resultsCount, IDictionary<string, List<(int lineNum, string codeLine)>> resultsDict, bool showInDecompiledView, IEnumerable<string> failedList = null)
{
throw new NotImplementedException();
}

public void ChangeSelection(object newSelection, bool inNewTab = false)
{
}
}

[TestClass]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ public partial class EditGlyphRectangleWindow : Window, INotifyPropertyChanged
private short initShift;
private Canvas canvas;

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

public EditGlyphRectangleWindow(UndertaleFont font, UndertaleFont.Glyph selectedGlyph)
{
Expand Down
4 changes: 4 additions & 0 deletions UndertaleModTool/Editors/UndertaleRoomEditor.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma warning disable CA1416 // Validate platform compatibility

using Microsoft.Win32;
using System;
using System.Buffers;
Expand Down Expand Up @@ -2710,3 +2712,5 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu
}
}
}

#pragma warning restore CA1416 // Validate platform compatibility
6 changes: 5 additions & 1 deletion UndertaleModTool/Editors/UndertaleShaderEditor.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using ICSharpCode.AvalonEdit;
#pragma warning disable CA1416 // Validate platform compatibility

using ICSharpCode.AvalonEdit;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -68,3 +70,5 @@ private void TextEditor_LostFocus(object sender, RoutedEventArgs e)
}
}
}

#pragma warning restore CA1416 // Validate platform compatibility
6 changes: 5 additions & 1 deletion UndertaleModTool/Editors/UndertaleSoundEditor.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
#pragma warning disable CA1416 // Validate platform compatibility

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -180,3 +182,5 @@ private void Stop_Click(object sender, RoutedEventArgs e)
}
}
}

#pragma warning restore CA1416 // Validate platform compatibility
Loading

0 comments on commit 545933a

Please sign in to comment.