Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/NesTiler.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2022-10-25 23:46:50 +0300
committerAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2022-10-25 23:50:48 +0300
commit456183980df6aecbbf2b308a7171666c79d843c7 (patch)
tree24a0b7b177035a641df24299f93bf44d2ad9f42a
parentfaa50efea54f7dc370edf4e78e8db5895d871a02 (diff)
Some null checks.
-rw-r--r--NesTiler/NesTiler.csproj6
-rw-r--r--NesTiler/Palette.cs1
-rw-r--r--NesTiler/Program.cs9
-rw-r--r--NesTiler/Tile.cs1
4 files changed, 12 insertions, 5 deletions
diff --git a/NesTiler/NesTiler.csproj b/NesTiler/NesTiler.csproj
index b50eec4..cc5b82b 100644
--- a/NesTiler/NesTiler.csproj
+++ b/NesTiler/NesTiler.csproj
@@ -6,12 +6,15 @@
<AssemblyName>nestiler</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
+ <DebugType>portable</DebugType>
+ <WarningLevel>7</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<DebugType>none</DebugType>
<DebugSymbols>false</DebugSymbols>
+ <WarningLevel>7</WarningLevel>
</PropertyGroup>
<ItemGroup>
<None Remove=".git" />
@@ -62,6 +65,7 @@
<Authors>Alexey "Cluster" Avdyukhin</Authors>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<Product>NesTiler</Product>
+ <Nullable>disable</Nullable>
</PropertyGroup>
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="make commit buildtime&#xD;&#xA;" />
diff --git a/NesTiler/Palette.cs b/NesTiler/Palette.cs
index 0dc31ff..2e11241 100644
--- a/NesTiler/Palette.cs
+++ b/NesTiler/Palette.cs
@@ -101,6 +101,7 @@ namespace com.clusterrr.Famicom.NesTiler
public bool Equals(Palette other)
{
+ if (other == null) return false;
var colors1 = colors.Where(c => c.HasValue)
.OrderBy(c => c.Value.ToArgb())
.Select(c => c.Value)
diff --git a/NesTiler/Program.cs b/NesTiler/Program.cs
index 905d2dd..62ac1fa 100644
--- a/NesTiler/Program.cs
+++ b/NesTiler/Program.cs
@@ -28,7 +28,7 @@ namespace com.clusterrr.Famicom.NesTiler
static void PrintAppInfo()
{
- Console.WriteLine($"NesTiler v{Assembly.GetExecutingAssembly().GetName().Version.Major}.{Assembly.GetExecutingAssembly().GetName().Version.Minor}");
+ Console.WriteLine($"NesTiler v{Assembly.GetExecutingAssembly()?.GetName()?.Version?.Major}.{Assembly.GetExecutingAssembly()?.GetName()?.Version?.Minor}");
Console.WriteLine($" Commit {Properties.Resources.gitCommit} @ {REPO_PATH}");
#if DEBUG
Console.WriteLine($" Debug version, build time: {BUILD_TIME.ToLocalTime()}");
@@ -39,7 +39,7 @@ namespace com.clusterrr.Famicom.NesTiler
static void PrintHelp()
{
- Console.WriteLine($"Usage: {Path.GetFileName(Process.GetCurrentProcess().MainModule.FileName)} <options>");
+ Console.WriteLine($"Usage: {Path.GetFileName(Process.GetCurrentProcess()?.MainModule?.FileName)} <options>");
Console.WriteLine();
Console.WriteLine("Available options:");
Console.WriteLine(" {0,-40}{1}", "--in-<#> <file>[:offset[:height]]", "input file number #, optionally cropped vertically");
@@ -732,12 +732,12 @@ namespace com.clusterrr.Famicom.NesTiler
}
// Save CSV tiles report
- if (outTilesCsvLines != null)
+ if (outTilesCsv != null && outTilesCsvLines != null)
{
File.WriteAllLines(outTilesCsv, outTilesCsvLines);
}
// Save CSV palettes report
- if (outPalettesCsv != null)
+ if (outPalettesCsv != null && outPalettesCsvLines != null)
{
File.WriteAllLines(outPalettesCsv, outPalettesCsvLines);
}
@@ -781,6 +781,7 @@ namespace com.clusterrr.Famicom.NesTiler
{
var paletteJson = File.ReadAllText(filename);
var nesColorsStr = JsonSerializer.Deserialize<Dictionary<string, string>>(paletteJson);
+ if (nesColorsStr == null) throw new InvalidDataException($"can't parse {filename}");
nesColors = nesColorsStr.ToDictionary(
kv => kv.Key.ToLower().StartsWith("0x") ? (byte)Convert.ToInt32(kv.Key.Substring(2), 16) : byte.Parse(kv.Key),
kv => ColorTranslator.FromHtml(kv.Value)
diff --git a/NesTiler/Tile.cs b/NesTiler/Tile.cs
index f77352a..b1b52fd 100644
--- a/NesTiler/Tile.cs
+++ b/NesTiler/Tile.cs
@@ -44,6 +44,7 @@ namespace com.clusterrr.Famicom.NesTiler
public bool Equals(Tile other)
{
+ if (other == null) return false;
var data1 = GetAsPatternData();
var data2 = other.GetAsPatternData();
return Enumerable.SequenceEqual(data1, data2);