Skip to content

Commit d634b72

Browse files
authored
Merge pull request #490 from Shane32/allow_svg
Allow SVG exporting under .NET 6 on Linux
2 parents dfa5209 + 95202ee commit d634b72

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

QRCoder/SvgQRCode.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if NETFRAMEWORK || NETSTANDARD2_0 || NET5_0 || NET6_0_WINDOWS
1+
#if NETFRAMEWORK || NETSTANDARD2_0 || NET5_0_OR_GREATER
22
using QRCoder.Extensions;
33
using System;
44
using System.Collections;
@@ -11,9 +11,6 @@
1111

1212
namespace QRCoder
1313
{
14-
#if NET6_0_WINDOWS
15-
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
16-
#endif
1714
public class SvgQRCode : AbstractQRCode, IDisposable
1815
{
1916
/// <summary>
@@ -270,13 +267,16 @@ public class SvgLogo
270267
private object _logoRaw;
271268
private bool _isEmbedded;
272269

273-
270+
#if NETFRAMEWORK || NETSTANDARD2_0 || NET5_0 || NET6_0_WINDOWS
274271
/// <summary>
275272
/// Create a logo object to be used in SvgQRCode renderer
276273
/// </summary>
277274
/// <param name="iconRasterized">Logo to be rendered as Bitmap/rasterized graphic</param>
278275
/// <param name="iconSizePercent">Degree of percentage coverage of the QR code by the logo</param>
279276
/// <param name="fillLogoBackground">If true, the background behind the logo will be cleaned</param>
277+
#if NET6_0_WINDOWS
278+
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
279+
#endif
280280
public SvgLogo(Bitmap iconRasterized, int iconSizePercent = 15, bool fillLogoBackground = true)
281281
{
282282
_iconSizePercent = iconSizePercent;
@@ -293,6 +293,7 @@ public SvgLogo(Bitmap iconRasterized, int iconSizePercent = 15, bool fillLogoBac
293293
_logoRaw = iconRasterized;
294294
_isEmbedded = false;
295295
}
296+
#endif
296297

297298
/// <summary>
298299
/// Create a logo object to be used in SvgQRCode renderer
@@ -379,9 +380,6 @@ public enum MediaType : int
379380
}
380381
}
381382

382-
#if NET6_0_WINDOWS
383-
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
384-
#endif
385383
public static class SvgQRCodeHelper
386384
{
387385
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)

QRCoderTests/SvgQRCodeRendererTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if !NETCOREAPP1_1 && !NET6_0
1+
#if !NETCOREAPP1_1
22
using System;
33
using Xunit;
44
using QRCoder;
@@ -103,6 +103,7 @@ public void can_render_svg_qrcode_without_quietzones_hex()
103103
result.ShouldBe("4ab0417cc6127e347ca1b2322c49ed7d");
104104
}
105105

106+
#if NETFRAMEWORK || NETSTANDARD2_0 || NET5_0 || NET6_0_WINDOWS
106107
[Fact]
107108
[Category("QRRenderer/SvgQRCode")]
108109
public void can_render_svg_qrcode_with_png_logo()
@@ -121,6 +122,7 @@ public void can_render_svg_qrcode_with_png_logo()
121122
var result = HelperFunctions.StringToHash(svg);
122123
result.ShouldBe("78e02e8ba415f15817d5ed88c4afca31");
123124
}
125+
#endif
124126

125127
[Fact]
126128
[Category("QRRenderer/SvgQRCode")]

0 commit comments

Comments
 (0)