Skip to content

Commit

Permalink
Use Polyfill package to simplify net462 support
Browse files Browse the repository at this point in the history
  • Loading branch information
cyanfish committed Apr 2, 2024
1 parent 426330e commit 9a2537c
Show file tree
Hide file tree
Showing 37 changed files with 18 additions and 638 deletions.
5 changes: 0 additions & 5 deletions NAPS2.App.Tests/IsExternalInit.cs

This file was deleted.

61 changes: 0 additions & 61 deletions NAPS2.Escl.Server/CompilerAttributes.cs

This file was deleted.

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

<ItemGroup>
<PackageReference Include="EmbedIO" Version="3.5.2" />
<PackageReference Include="Nullable" Version="1.3.1" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
Expand Down
61 changes: 0 additions & 61 deletions NAPS2.Escl.Usb/CompilerAttributes.cs

This file was deleted.

1 change: 1 addition & 0 deletions NAPS2.Escl.Usb/NAPS2.Escl.Usb.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<ProjectReference Include="..\NAPS2.Escl\NAPS2.Escl.csproj" />

<PackageReference Include="LibUsbDotNet" Version="3.0.102-alpha" />
<PackageReference Include="Polyfill" Version="4.2.0" />
</ItemGroup>

</Project>
61 changes: 0 additions & 61 deletions NAPS2.Escl/CompilerAttributes.cs

This file was deleted.

2 changes: 2 additions & 0 deletions NAPS2.Escl/NAPS2.Escl.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
<ItemGroup>
<PackageReference Include="NAPS2.Mdns" Version="1.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
<PackageReference Include="Polyfill" Version="4.2.0" />
<PackageReference Include="StandardSocketsHttpHandler" Version="2.2.0.8" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 0 additions & 2 deletions NAPS2.Images.Gdi/GdiExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

namespace NAPS2.Images.Gdi;

#if NET6_0_OR_GREATER
[System.Runtime.Versioning.SupportedOSPlatform("windows7.0")]
#endif
public static class GdiExtensions
{
public static Bitmap RenderToBitmap(this IRenderableImage image)
Expand Down
2 changes: 0 additions & 2 deletions NAPS2.Images.Gdi/GdiImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ namespace NAPS2.Images.Gdi;
/// <summary>
/// An implementation of IMemoryImage that wraps a GDI+ image (System.Drawing.Bitmap).
/// </summary>
#if NET6_0_OR_GREATER
[System.Runtime.Versioning.SupportedOSPlatform("windows7.0")]
#endif
public class GdiImage : IMemoryImage
{
public GdiImage(Bitmap bitmap)
Expand Down
2 changes: 0 additions & 2 deletions NAPS2.Images.Gdi/GdiImageContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

namespace NAPS2.Images.Gdi;

#if NET6_0_OR_GREATER
[System.Runtime.Versioning.SupportedOSPlatform("windows7.0")]
#endif
public class GdiImageContext : ImageContext
{
private readonly GdiImageTransformer _imageTransformer;
Expand Down
2 changes: 0 additions & 2 deletions NAPS2.Images.Gdi/GdiImageLockState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

namespace NAPS2.Images.Gdi;

#if NET6_0_OR_GREATER
[System.Runtime.Versioning.SupportedOSPlatform("windows7.0")]
#endif
public class GdiImageLockState : ImageLockState
{
public static GdiImageLockState Create(Bitmap bitmap, LockMode lockMode, out BitwiseImageData imageData)
Expand Down
2 changes: 0 additions & 2 deletions NAPS2.Images.Gdi/GdiImageTransformer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

namespace NAPS2.Images.Gdi;

#if NET6_0_OR_GREATER
[System.Runtime.Versioning.SupportedOSPlatform("windows7.0")]
#endif
public class GdiImageTransformer : AbstractImageTransformer<GdiImage>
{
public GdiImageTransformer(ImageContext imageContext) : base(imageContext)
Expand Down
2 changes: 0 additions & 2 deletions NAPS2.Images.Gdi/GdiPixelFormatFixer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ namespace NAPS2.Images.Gdi;
/// <summary>
/// Ensures that bitmaps use a standard pixel format/palette.
/// </summary>
#if NET6_0_OR_GREATER
[System.Runtime.Versioning.SupportedOSPlatform("windows7.0")]
#endif
internal static class GdiPixelFormatFixer
{
public static bool MaybeFixPixelFormat(ref Bitmap bitmap)
Expand Down
2 changes: 0 additions & 2 deletions NAPS2.Images.Gdi/GdiTiffWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

namespace NAPS2.Images.Gdi;

#if NET6_0_OR_GREATER
[System.Runtime.Versioning.SupportedOSPlatform("windows7.0")]
#endif
internal class GdiTiffWriter : ITiffWriter
{
public bool SaveTiff(IList<IMemoryImage> images, string path,
Expand Down
5 changes: 0 additions & 5 deletions NAPS2.Images.Gdi/IsExternalInit.cs

This file was deleted.

12 changes: 7 additions & 5 deletions NAPS2.Images/ImageContext.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
using System.Diagnostics.CodeAnalysis;
using NAPS2.Util;

namespace NAPS2.Images;
Expand Down Expand Up @@ -46,8 +47,8 @@ protected ImageContext(Type imageType)
ImageType = imageType;
}

// TODO: Add NotNullWhen attribute?
private bool MaybeRenderPdf(ImageFileStorage fileStorage, IPdfRenderer? pdfRenderer, out IMemoryImage? renderedPdf)
private bool MaybeRenderPdf(ImageFileStorage fileStorage, IPdfRenderer? pdfRenderer,
[NotNullWhen(true)] out IMemoryImage? renderedPdf)
{
if (Path.GetExtension(fileStorage.FullPath).ToLowerInvariant() == ".pdf")
{
Expand All @@ -63,7 +64,8 @@ private bool MaybeRenderPdf(ImageFileStorage fileStorage, IPdfRenderer? pdfRende
return false;
}

private bool MaybeRenderPdf(ImageMemoryStorage memoryStorage, IPdfRenderer? pdfRenderer, out IMemoryImage? renderedPdf)
private bool MaybeRenderPdf(ImageMemoryStorage memoryStorage, IPdfRenderer? pdfRenderer,
[NotNullWhen(true)] out IMemoryImage? renderedPdf)
{
if (memoryStorage.TypeHint == ".pdf")
{
Expand Down Expand Up @@ -250,13 +252,13 @@ private IMemoryImage RenderFromStorage(IImageStorage storage, IPdfRenderer? pdfR
case ImageFileStorage fileStorage:
if (MaybeRenderPdf(fileStorage, pdfRenderer, out var renderedPdf))
{
return renderedPdf!;
return renderedPdf;
}
return Load(fileStorage.FullPath);
case ImageMemoryStorage memoryStorage:
if (MaybeRenderPdf(memoryStorage, pdfRenderer, out var renderedMemoryPdf))
{
return renderedMemoryPdf!;
return renderedMemoryPdf;
}
return Load(memoryStorage.Stream);
case IMemoryImage image:
Expand Down
5 changes: 0 additions & 5 deletions NAPS2.Images/IsExternalInit.cs

This file was deleted.

2 changes: 1 addition & 1 deletion NAPS2.Images/NAPS2.Images.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

<ItemGroup>
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />
<PackageReference Include="Polyfill" Version="4.2.0" />
<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" />

<ProjectReference Include="..\NAPS2.Internals\NAPS2.Internals.csproj" />
Expand Down
2 changes: 2 additions & 0 deletions NAPS2.Internals/NAPS2.Internals.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@

<ItemGroup>
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />
<PackageReference Include="Polyfill" Version="4.2.0" />
<PackageReference Include="System.Collections.Immutable" Version="8.0.0" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup>

<Import Project="..\NAPS2.Setup\targets\CommonTargets.targets" />
Expand Down
Loading

0 comments on commit 9a2537c

Please sign in to comment.