Skip to content

Commit

Permalink
Fix warnings and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
cyanfish committed Mar 1, 2024
1 parent 4ba463d commit b7140b8
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 11 deletions.
3 changes: 2 additions & 1 deletion NAPS2.App.Tests/NAPS2.App.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8</TargetFramework>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('Windows'))">net8-windows</TargetFrameworks>
<TargetFrameworks Condition="!$([MSBuild]::IsOSPlatform('Windows'))">net8</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
<Configurations>Debug;Release;DebugLang</Configurations>
Expand Down
2 changes: 1 addition & 1 deletion NAPS2.Images/ImageContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ public IMemoryImage RenderWithoutTransforms(IRenderableImage image)
return RenderFromStorage(image.Storage, (image as IPdfRendererProvider)?.PdfRenderer);
}

private IMemoryImage RenderFromStorage(IImageStorage storage, IPdfRenderer pdfRenderer)
private IMemoryImage RenderFromStorage(IImageStorage storage, IPdfRenderer? pdfRenderer)
{
switch (storage)
{
Expand Down
5 changes: 2 additions & 3 deletions NAPS2.Images/ImageExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,15 @@ public static IMemoryImage Render(this IRenderableImage image)
/// <param name="image"></param>
/// <param name="jpegPath"></param>
/// <returns></returns>
internal static bool IsUntransformedJpegFile(this IRenderableImage image,
[MaybeNullWhen(false)] out string jpegPath)
internal static bool IsUntransformedJpegFile(this IRenderableImage image, out string jpegPath)
{
if (image is { Storage: ImageFileStorage fileStorage, TransformState.IsEmpty: true } &&
ImageContext.GetFileFormatFromExtension(fileStorage.FullPath) == ImageFileFormat.Jpeg)
{
jpegPath = fileStorage.FullPath;
return true;
}
jpegPath = null;
jpegPath = null!;
return false;
}

Expand Down
1 change: 0 additions & 1 deletion NAPS2.Images/NAPS2.Images.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

<ItemGroup>
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />
<PackageReference Include="Nullable" Version="1.3.1" PrivateAssets="all" />
<PackageReference Include="System.Collections.Immutable" Version="8.0.0" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="ZXing.Net" Version="0.16.9" />
Expand Down
1 change: 1 addition & 0 deletions NAPS2.Internals/Threading/AsyncProducers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace NAPS2.Util;

public static class AsyncProducers
{
#pragma warning disable CS1998
public static async IAsyncEnumerable<T> Empty<T>()
{
yield break;
Expand Down
1 change: 1 addition & 0 deletions NAPS2.Lib.Gtk/Util/GLibLogInterceptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ private delegate void GLogWriterFunc(
nint nFields,
IntPtr user_data);

[StructLayout(LayoutKind.Sequential)]
struct GLogField
{
public string key;
Expand Down
2 changes: 1 addition & 1 deletion NAPS2.Lib.WinForms/EtoForms/Ui/WinFormsDesktopForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ protected override void UpdateProfilesToolbar()
TextAlign = ContentAlignment.MiddleLeft,
Image = Image.FromStream(new MemoryStream(Icons.control_play_blue_small))
};
item.Click += (_, _) => _desktopScanController.ScanWithProfile((ScanProfile) item.Tag);
item.Click += (_, _) => _desktopScanController.ScanWithProfile((ScanProfile) item.Tag!);
toolbarItems.Add(item);
}
for (int i = 0; i < profiles.Count; i++)
Expand Down
2 changes: 1 addition & 1 deletion NAPS2.Lib/EtoForms/Ui/OcrSetupForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ private void MoreLanguages_Click(object? sender, EventArgs e)
LoadLanguages();
}

private void OcrLang_SelectedIndexChanged(object sender, EventArgs e)
private void OcrLang_SelectedIndexChanged(object? sender, EventArgs e)
{
if (_suppressLangChangeEvent) return;
if (_ocrLang.SelectedIndex == _ocrLang.Items.Count - 1)
Expand Down
2 changes: 1 addition & 1 deletion NAPS2.Lib/Scan/ScanPerformer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,10 @@ private ScanOptions BuildOptions(ScanProfile scanProfile, ScanParams scanParams,
: TwainTransferMode.Native,
ShowProgress = scanProfile.TwainProgress,
IncludeWiaDevices = false
// TODO: Consider adding a user option for TwainOptions.ShowProgress instead of our progress window
},
SaneOptions =
{
// We use a worker process for SANE so we should clean up after each operation
KeepInitialized = false
},
KeyValueOptions = scanProfile.KeyValueOptions != null
Expand Down
2 changes: 1 addition & 1 deletion NAPS2.Sdk.ScannerTests/NAPS2.Sdk.ScannerTests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('Windows'))">net8;net462</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('Windows'))">net8-windows;net462</TargetFrameworks>
<TargetFrameworks Condition="!$([MSBuild]::IsOSPlatform('Windows'))">net8</TargetFrameworks>
<RootNamespace>NAPS2.Sdk.ScannerTests</RootNamespace>
</PropertyGroup>
Expand Down
5 changes: 4 additions & 1 deletion NAPS2.Sdk.Tests/Pdf/PdfFontTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

namespace NAPS2.Sdk.Tests.Pdf;

// As we use the same data for multiple methods, some parameters may be unused
#pragma warning disable xUnit1026

public class PdfFontTests : ContextualTests
{
private readonly PdfImporter _importer;
Expand Down Expand Up @@ -36,7 +39,7 @@ public void CheckAvailableFonts()

[Theory]
[MemberData(nameof(AlphabetTestCases))]
internal async Task MapLanguageCodeToAlphabet(Alphabet alphabet, string langCode, string text, bool rtl)
internal void MapLanguageCodeToAlphabet(Alphabet alphabet, string langCode, string text, bool rtl)
{
Assert.Equal(alphabet, PdfFontPicker.MapLanguageCodeToAlphabet(langCode));
}
Expand Down

0 comments on commit b7140b8

Please sign in to comment.