Skip to content

Commit 299f023

Browse files
authored
Merge pull request #286 from trivalik/b
* add .NET 5.0 support
2 parents 1d25386 + fd755a8 commit 299f023

20 files changed

+104
-187
lines changed

QRCoder.sln

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ VisualStudioVersion = 16.0.29911.84
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "QRCoder", "QRCoder\QRCoder.csproj", "{AA6BE23A-7813-4D2A-835E-B673631AE9F1}"
77
EndProject
8-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QRCoderConsole", "QRCoderConsole\QRCoderConsole.csproj", "{014F04C6-6099-4552-9A4F-D09C6E39D576}"
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "QRCoderConsole", "QRCoderConsole\QRCoderConsole.csproj", "{014F04C6-6099-4552-9A4F-D09C6E39D576}"
99
EndProject
1010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QRCoderDemo", "QRCoderDemo\QRCoderDemo.csproj", "{CA6DB0F5-DB6C-4DDD-8B5F-EF82FBB963E9}"
1111
EndProject
@@ -55,12 +55,12 @@ Global
5555
{014F04C6-6099-4552-9A4F-D09C6E39D576}.Release|x64.Build.0 = Release|Any CPU
5656
{014F04C6-6099-4552-9A4F-D09C6E39D576}.Release|x86.ActiveCfg = Release|Any CPU
5757
{014F04C6-6099-4552-9A4F-D09C6E39D576}.Release|x86.Build.0 = Release|Any CPU
58-
{CA6DB0F5-DB6C-4DDD-8B5F-EF82FBB963E9}.Debug|Any CPU.ActiveCfg = Debug|x86
58+
{CA6DB0F5-DB6C-4DDD-8B5F-EF82FBB963E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
5959
{CA6DB0F5-DB6C-4DDD-8B5F-EF82FBB963E9}.Debug|ARM.ActiveCfg = Debug|x86
6060
{CA6DB0F5-DB6C-4DDD-8B5F-EF82FBB963E9}.Debug|x64.ActiveCfg = Debug|x86
6161
{CA6DB0F5-DB6C-4DDD-8B5F-EF82FBB963E9}.Debug|x86.ActiveCfg = Debug|x86
6262
{CA6DB0F5-DB6C-4DDD-8B5F-EF82FBB963E9}.Debug|x86.Build.0 = Debug|x86
63-
{CA6DB0F5-DB6C-4DDD-8B5F-EF82FBB963E9}.Release|Any CPU.ActiveCfg = Release|x86
63+
{CA6DB0F5-DB6C-4DDD-8B5F-EF82FBB963E9}.Release|Any CPU.ActiveCfg = Release|Any CPU
6464
{CA6DB0F5-DB6C-4DDD-8B5F-EF82FBB963E9}.Release|ARM.ActiveCfg = Release|x86
6565
{CA6DB0F5-DB6C-4DDD-8B5F-EF82FBB963E9}.Release|x64.ActiveCfg = Release|x86
6666
{CA6DB0F5-DB6C-4DDD-8B5F-EF82FBB963E9}.Release|x86.ActiveCfg = Release|x86

QRCoder/Base64QRCode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if NETFRAMEWORK || NETSTANDARD2_0
1+
#if NETFRAMEWORK || NETSTANDARD2_0 || NET5_0
22
using System;
33
using System.Drawing;
44
using System.Drawing.Imaging;

QRCoder/PayloadGenerator.cs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,11 +1409,12 @@ public BezahlCode(AuthorityType authority, string name, string account, string b
14091409
}
14101410
else if (internalMode == 2)
14111411
{
1412+
#pragma warning disable CS0612
14121413
if (authority != AuthorityType.periodicsinglepayment && authority != AuthorityType.singledirectdebit && authority != AuthorityType.singlepayment)
14131414
throw new BezahlCodeException("The constructor with 'account' and 'bnc' may only be used with 'non SEPA' authority types. Either choose another authority type or switch constructor.");
14141415
if (authority == AuthorityType.periodicsinglepayment && (string.IsNullOrEmpty(periodicTimeunit) || periodicTimeunitRotation == 0))
14151416
throw new BezahlCodeException("When using 'periodicsinglepayment' as authority type, the parameters 'periodicTimeunit' and 'periodicTimeunitRotation' must be set.");
1416-
1417+
#pragma warning restore CS0612
14171418
}
14181419
else if (internalMode == 3)
14191420
{
@@ -1437,8 +1438,10 @@ public BezahlCode(AuthorityType authority, string name, string account, string b
14371438
var newWayFilled = (!string.IsNullOrEmpty(iban) && !string.IsNullOrEmpty(bic));
14381439

14391440
//Non-SEPA payment types
1441+
#pragma warning disable CS0612
14401442
if (authority == AuthorityType.periodicsinglepayment || authority == AuthorityType.singledirectdebit || authority == AuthorityType.singlepayment || authority == AuthorityType.contact || (authority == AuthorityType.contact_v2 && oldWayFilled))
14411443
{
1444+
#pragma warning restore CS0612
14421445
if (!Regex.IsMatch(account.Replace(" ", ""), @"^[0-9]{1,9}$"))
14431446
throw new BezahlCodeException("The account entered isn't valid.");
14441447
this.account = account.Replace(" ", "").ToUpper();
@@ -1500,8 +1503,9 @@ public BezahlCode(AuthorityType authority, string name, string account, string b
15001503
throw new BezahlCodeException("Execution date must be today or in future.");
15011504
this.executionDate = (DateTime)executionDate;
15021505
}
1503-
1506+
#pragma warning disable CS0612
15041507
if (authority == AuthorityType.periodicsinglepayment || authority == AuthorityType.periodicsinglepaymentsepa)
1508+
#pragma warning restore CS0612
15051509
{
15061510
if (periodicTimeunit.ToUpper() != "M" && periodicTimeunit.ToUpper() != "W")
15071511
throw new BezahlCodeException("The periodicTimeunit must be either 'M' (monthly) or 'W' (weekly).");
@@ -1530,8 +1534,9 @@ public override string ToString()
15301534
if (authority != AuthorityType.contact && authority != AuthorityType.contact_v2)
15311535
{
15321536
//Handle what is same for all payments
1533-
1537+
#pragma warning disable CS0612
15341538
if (authority == AuthorityType.periodicsinglepayment || authority == AuthorityType.singledirectdebit || authority == AuthorityType.singlepayment)
1539+
#pragma warning restore CS0612
15351540
{
15361541
bezahlCodePayload += $"account={account}&";
15371542
bezahlCodePayload += $"bnc={bnc}&";
@@ -1552,7 +1557,7 @@ public override string ToString()
15521557
bezahlCodePayload += $"creditorid={ Uri.EscapeDataString(creditorId)}&";
15531558
if (!string.IsNullOrEmpty(mandateId))
15541559
bezahlCodePayload += $"mandateid={ Uri.EscapeDataString(mandateId)}&";
1555-
if (dateOfSignature != null)
1560+
if (dateOfSignature != DateTime.MinValue)
15561561
bezahlCodePayload += $"dateofsignature={dateOfSignature.ToString("ddMMyyyy")}&";
15571562
}
15581563
}
@@ -1562,16 +1567,17 @@ public override string ToString()
15621567
bezahlCodePayload += $"reason={ Uri.EscapeDataString(reason)}&";
15631568
bezahlCodePayload += $"currency={currency}&";
15641569
bezahlCodePayload += $"executiondate={executionDate.ToString("ddMMyyyy")}&";
1565-
1570+
#pragma warning disable CS0612
15661571
if (authority == AuthorityType.periodicsinglepayment || authority == AuthorityType.periodicsinglepaymentsepa)
15671572
{
15681573
bezahlCodePayload += $"periodictimeunit={periodicTimeunit}&";
15691574
bezahlCodePayload += $"periodictimeunitrotation={periodicTimeunitRotation}&";
1570-
if (periodicFirstExecutionDate != null)
1575+
if (periodicFirstExecutionDate != DateTime.MinValue)
15711576
bezahlCodePayload += $"periodicfirstexecutiondate={periodicFirstExecutionDate.ToString("ddMMyyyy")}&";
1572-
if (periodicLastExecutionDate != null)
1577+
if (periodicLastExecutionDate != DateTime.MinValue)
15731578
bezahlCodePayload += $"periodiclastexecutiondate={periodicLastExecutionDate.ToString("ddMMyyyy")}&";
15741579
}
1580+
#pragma warning restore CS0612
15751581
}
15761582
else
15771583
{

QRCoder/PdfByteQRCode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if NETFRAMEWORK || NETSTANDARD2_0
1+
#if NETFRAMEWORK || NETSTANDARD2_0 || NET5_0
22
using System;
33
using System.Collections.Generic;
44
using System.Drawing.Imaging;

QRCoder/PostscriptQRCode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if NETFRAMEWORK || NETSTANDARD2_0
1+
#if NETFRAMEWORK || NETSTANDARD2_0 || NET5_0
22
using System;
33
using System.Drawing;
44
using static QRCoder.QRCodeGenerator;

QRCoder/QRCode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if NETFRAMEWORK || NETSTANDARD2_0
1+
#if NETFRAMEWORK || NETSTANDARD2_0 || NET5_0
22
using System;
33
using System.Drawing;
44
using System.Drawing.Drawing2D;

QRCoder/QRCodeData.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public QRCodeData(int version)
2121
for (var i = 0; i < size; i++)
2222
this.ModuleMatrix.Add(new BitArray(size));
2323
}
24-
#if NETFRAMEWORK || NETSTANDARD2_0
24+
#if NETFRAMEWORK || NETSTANDARD2_0 || NET5_0
2525
public QRCodeData(string pathToRawData, Compression compressMode) : this(File.ReadAllBytes(pathToRawData), compressMode)
2626
{
2727
}
@@ -154,7 +154,7 @@ public byte[] GetRawData(Compression compressMode)
154154
return rawData;
155155
}
156156

157-
#if NETFRAMEWORK || NETSTANDARD2_0
157+
#if NETFRAMEWORK || NETSTANDARD2_0 || NET5_0
158158
public void SaveRawData(string filePath, Compression compressMode)
159159
{
160160
File.WriteAllBytes(filePath, GetRawData(compressMode));

QRCoder/QRCodeGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1104,7 +1104,7 @@ private static string ConvertToIso8859(string value, string Iso = "ISO-8859-2")
11041104
Encoding utf8 = Encoding.UTF8;
11051105
byte[] utfBytes = utf8.GetBytes(value);
11061106
byte[] isoBytes = Encoding.Convert(utf8, iso, utfBytes);
1107-
#if NETFRAMEWORK || NETSTANDARD2_0
1107+
#if NETFRAMEWORK || NETSTANDARD2_0 || NET5_0
11081108
return iso.GetString(isoBytes);
11091109
#else
11101110
return iso.GetString(isoBytes, 0, isoBytes.Length);

QRCoder/QRCoder.csproj

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net35;net40;netstandard1.1;netstandard2.0</TargetFrameworks>
4+
<TargetFrameworks>net35;net40;netstandard1.1;netstandard2.0;net5.0;net5.0-windows</TargetFrameworks>
55
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
6+
<UseWindowsForms Condition="'$(TargetFramework)' == 'net5.0-windows'">true</UseWindowsForms>
7+
<UseWPF Condition="'$(TargetFramework)' == 'net5.0-windows'">true</UseWPF>
8+
<DefineConstants Condition="'$(TargetFramework)' == 'net5.0-windows'">$(DefineConstants);NET5_0_WINDOWS</DefineConstants>
69
</PropertyGroup>
710

811
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
9-
<OutputPath>bin\Release\</OutputPath>
1012
<NoWarn />
1113
</PropertyGroup>
1214

@@ -16,7 +18,6 @@
1618
<Version>1.4.1</Version>
1719
<Authors>Raffael Herrmann</Authors>
1820
<AssemblyName>QRCoder</AssemblyName>
19-
<RootNamespace>QRCoder</RootNamespace>
2021
<PackageLicenseExpression>MIT</PackageLicenseExpression>
2122
<PackageProjectUrl>https://github.com/codebude/QRCoder/</PackageProjectUrl>
2223
<PackageIconUrl>http://code-bude.net/downloads/qrcoder-logo.png</PackageIconUrl>
@@ -30,12 +31,12 @@
3031
<Reference Include="WindowsBase" />
3132
</ItemGroup>
3233

33-
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
34+
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' or '$(TargetFramework)' == 'net5.0' ">
3435
<PackageReference Include="System.Drawing.Common" Version="4.7.0" />
3536
</ItemGroup>
3637

3738
<PropertyGroup>
3839
<FrameworkPathOverride Condition="'$(TargetFramework)' == 'net35'">$(MSBuildProgramFiles32)\Reference Assemblies\Microsoft\Framework\.NETFramework\v3.5\Profile\Client</FrameworkPathOverride>
3940
</PropertyGroup>
4041

41-
</Project>
42+
</Project>

QRCoder/SvgQRCode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if NETFRAMEWORK || NETSTANDARD2_0
1+
#if NETFRAMEWORK || NETSTANDARD2_0 || NET5_0
22
using System;
33
using System.Collections;
44
using System.Drawing;

0 commit comments

Comments
 (0)