Fix some project warnings/errors

This commit is contained in:
Ben Olden-Cooligan 2022-07-02 10:30:31 -07:00
parent cc961d022d
commit 4298c0d3aa
7 changed files with 12 additions and 8 deletions

View File

@ -4,6 +4,7 @@
<TargetFrameworks>net5;net462;netcoreapp2.1;netstandard2.0</TargetFrameworks>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<RootNamespace>NAPS2.Images.Gdi</RootNamespace>
<Title>NAPS2.Images.Gdi</Title>

View File

@ -4,6 +4,7 @@
<TargetFrameworks>net5;net462;netcoreapp2.1;netstandard2.0</TargetFrameworks>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<RootNamespace>NAPS2.Images</RootNamespace>
<Title>NAPS2.Images</Title>

View File

@ -111,7 +111,7 @@ public class ProcessedImage : IDisposable, IEquatable<ProcessedImage>
/// <returns></returns>
public WeakReference GetWeakReference() => new(this);
public override bool Equals(object obj)
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net5;net462</TargetFrameworks>
<TargetFrameworks>net5;net5-windows;net462</TargetFrameworks>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<RootNamespace>NAPS2</RootNamespace>
@ -50,7 +50,9 @@
<PackageReference Include="MimeKit" Version="1.22.0" />
<PackageReference Include="NAPS2.Wia" Version="1.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="NTwain" Version="3.7.1" />
<!-- Hide compatibility warnings for NTwain as it will only be actually used on Windows. -->
<!-- TODO: Does this actually work if we build a net5 framework-dependent app and try to use Twain? -->
<PackageReference Include="NTwain" Version="3.7.1" NoWarn="NU1701" />
<PackageReference Include="Nullable" Version="1.2.0" />
<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
<PackageReference Include="System.Collections.Immutable" Version="5.0.0" />

View File

@ -7,8 +7,8 @@
<Import Project="..\NAPS2.Setup\VersionTargets.targets" />
<Target Name="FullClean" AfterTargets="Clean">
<RemoveDir Directories="$(ProjectDir)bin" />
<RemoveDir Directories="$(ProjectDir)obj" />
<RemoveDir Directories="$(ProjectDir)bin" Condition="Exists('$(ProjectDir)bin')" ContinueOnError="true" />
<RemoveDir Directories="$(ProjectDir)obj" Condition="Exists('$(ProjectDir)obj')" ContinueOnError="true" />
</Target>
<ItemGroup>

View File

@ -60,7 +60,7 @@ public class LanguageContext
var doc = XDocument.Load(file.FullName);
bool hasSomethingTranslatable = false;
foreach (var item in doc.Root.Elements("data").ToList())
foreach (var item in doc.Root!.Elements("data").ToList())
{
var prop = item.Attribute("name")?.Value;
var original = item.Element("value")?.Value;
@ -76,7 +76,7 @@ public class LanguageContext
var translation = Strings[original].Translation;
if (!string.IsNullOrWhiteSpace(translation))
{
item.Element("value").Value = prefix + Strings[original].Translation + suffix;
item.Element("value")!.Value = prefix + Strings[original].Translation + suffix;
}
}
}

View File

@ -33,7 +33,7 @@ msgstr """"
private void LoadFile(FileInfo file, bool winforms)
{
var doc = XDocument.Load(file.FullName);
foreach (var item in doc.Root.Elements("data"))
foreach (var item in doc.Root!.Elements("data"))
{
var prop = item.Attribute("name")?.Value;
var original = item.Element("value")?.Value;