Skip to content

Commit

Permalink
Merge pull request #490 from Shane32/allow_svg
Browse files Browse the repository at this point in the history
Allow SVG exporting under .NET 6 on Linux
  • Loading branch information
codebude authored Apr 2, 2024
2 parents dfa5209 + 95202ee commit d634b72
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 6 additions & 8 deletions QRCoder/SvgQRCode.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NETFRAMEWORK || NETSTANDARD2_0 || NET5_0 || NET6_0_WINDOWS
#if NETFRAMEWORK || NETSTANDARD2_0 || NET5_0_OR_GREATER
using QRCoder.Extensions;
using System;
using System.Collections;
Expand All @@ -11,9 +11,6 @@

namespace QRCoder
{
#if NET6_0_WINDOWS
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
#endif
public class SvgQRCode : AbstractQRCode, IDisposable
{
/// <summary>
Expand Down Expand Up @@ -270,13 +267,16 @@ public class SvgLogo
private object _logoRaw;
private bool _isEmbedded;


#if NETFRAMEWORK || NETSTANDARD2_0 || NET5_0 || NET6_0_WINDOWS
/// <summary>
/// Create a logo object to be used in SvgQRCode renderer
/// </summary>
/// <param name="iconRasterized">Logo to be rendered as Bitmap/rasterized graphic</param>
/// <param name="iconSizePercent">Degree of percentage coverage of the QR code by the logo</param>
/// <param name="fillLogoBackground">If true, the background behind the logo will be cleaned</param>
#if NET6_0_WINDOWS
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
#endif
public SvgLogo(Bitmap iconRasterized, int iconSizePercent = 15, bool fillLogoBackground = true)
{
_iconSizePercent = iconSizePercent;
Expand All @@ -293,6 +293,7 @@ public SvgLogo(Bitmap iconRasterized, int iconSizePercent = 15, bool fillLogoBac
_logoRaw = iconRasterized;
_isEmbedded = false;
}
#endif

/// <summary>
/// Create a logo object to be used in SvgQRCode renderer
Expand Down Expand Up @@ -379,9 +380,6 @@ public enum MediaType : int
}
}

#if NET6_0_WINDOWS
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
#endif
public static class SvgQRCodeHelper
{
public static string GetQRCode(string plainText, int pixelsPerModule, string darkColorHex, string lightColorHex, ECCLevel eccLevel, bool forceUtf8 = false, bool utf8BOM = false, EciMode eciMode = EciMode.Default, int requestedVersion = -1, bool drawQuietZones = true, SizingMode sizingMode = SizingMode.WidthHeightAttribute, SvgLogo logo = null)
Expand Down
4 changes: 3 additions & 1 deletion QRCoderTests/SvgQRCodeRendererTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !NETCOREAPP1_1 && !NET6_0
#if !NETCOREAPP1_1
using System;
using Xunit;
using QRCoder;
Expand Down Expand Up @@ -103,6 +103,7 @@ public void can_render_svg_qrcode_without_quietzones_hex()
result.ShouldBe("4ab0417cc6127e347ca1b2322c49ed7d");
}

#if NETFRAMEWORK || NETSTANDARD2_0 || NET5_0 || NET6_0_WINDOWS
[Fact]
[Category("QRRenderer/SvgQRCode")]
public void can_render_svg_qrcode_with_png_logo()
Expand All @@ -121,6 +122,7 @@ public void can_render_svg_qrcode_with_png_logo()
var result = HelperFunctions.StringToHash(svg);
result.ShouldBe("78e02e8ba415f15817d5ed88c4afca31");
}
#endif

[Fact]
[Category("QRRenderer/SvgQRCode")]
Expand Down

0 comments on commit d634b72

Please sign in to comment.