diff --git a/QRCoder.sln b/QRCoder.sln
index 5bc09e25..2df93136 100644
--- a/QRCoder.sln
+++ b/QRCoder.sln
@@ -5,7 +5,7 @@ VisualStudioVersion = 16.0.29911.84
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "QRCoder", "QRCoder\QRCoder.csproj", "{AA6BE23A-7813-4D2A-835E-B673631AE9F1}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QRCoderConsole", "QRCoderConsole\QRCoderConsole.csproj", "{014F04C6-6099-4552-9A4F-D09C6E39D576}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "QRCoderConsole", "QRCoderConsole\QRCoderConsole.csproj", "{014F04C6-6099-4552-9A4F-D09C6E39D576}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QRCoderDemo", "QRCoderDemo\QRCoderDemo.csproj", "{CA6DB0F5-DB6C-4DDD-8B5F-EF82FBB963E9}"
EndProject
@@ -55,12 +55,12 @@ Global
{014F04C6-6099-4552-9A4F-D09C6E39D576}.Release|x64.Build.0 = Release|Any CPU
{014F04C6-6099-4552-9A4F-D09C6E39D576}.Release|x86.ActiveCfg = Release|Any CPU
{014F04C6-6099-4552-9A4F-D09C6E39D576}.Release|x86.Build.0 = Release|Any CPU
- {CA6DB0F5-DB6C-4DDD-8B5F-EF82FBB963E9}.Debug|Any CPU.ActiveCfg = Debug|x86
+ {CA6DB0F5-DB6C-4DDD-8B5F-EF82FBB963E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CA6DB0F5-DB6C-4DDD-8B5F-EF82FBB963E9}.Debug|ARM.ActiveCfg = Debug|x86
{CA6DB0F5-DB6C-4DDD-8B5F-EF82FBB963E9}.Debug|x64.ActiveCfg = Debug|x86
{CA6DB0F5-DB6C-4DDD-8B5F-EF82FBB963E9}.Debug|x86.ActiveCfg = Debug|x86
{CA6DB0F5-DB6C-4DDD-8B5F-EF82FBB963E9}.Debug|x86.Build.0 = Debug|x86
- {CA6DB0F5-DB6C-4DDD-8B5F-EF82FBB963E9}.Release|Any CPU.ActiveCfg = Release|x86
+ {CA6DB0F5-DB6C-4DDD-8B5F-EF82FBB963E9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CA6DB0F5-DB6C-4DDD-8B5F-EF82FBB963E9}.Release|ARM.ActiveCfg = Release|x86
{CA6DB0F5-DB6C-4DDD-8B5F-EF82FBB963E9}.Release|x64.ActiveCfg = Release|x86
{CA6DB0F5-DB6C-4DDD-8B5F-EF82FBB963E9}.Release|x86.ActiveCfg = Release|x86
diff --git a/QRCoder/Base64QRCode.cs b/QRCoder/Base64QRCode.cs
index cf55e21d..8f4f28d6 100644
--- a/QRCoder/Base64QRCode.cs
+++ b/QRCoder/Base64QRCode.cs
@@ -1,4 +1,4 @@
-#if NETFRAMEWORK || NETSTANDARD2_0
+#if NETFRAMEWORK || NETSTANDARD2_0 || NET5_0
using System;
using System.Drawing;
using System.Drawing.Imaging;
diff --git a/QRCoder/PayloadGenerator.cs b/QRCoder/PayloadGenerator.cs
index 9b7b8826..8f3bd0f8 100644
--- a/QRCoder/PayloadGenerator.cs
+++ b/QRCoder/PayloadGenerator.cs
@@ -1409,11 +1409,12 @@ public BezahlCode(AuthorityType authority, string name, string account, string b
}
else if (internalMode == 2)
{
+#pragma warning disable CS0612
if (authority != AuthorityType.periodicsinglepayment && authority != AuthorityType.singledirectdebit && authority != AuthorityType.singlepayment)
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.");
if (authority == AuthorityType.periodicsinglepayment && (string.IsNullOrEmpty(periodicTimeunit) || periodicTimeunitRotation == 0))
throw new BezahlCodeException("When using 'periodicsinglepayment' as authority type, the parameters 'periodicTimeunit' and 'periodicTimeunitRotation' must be set.");
-
+#pragma warning restore CS0612
}
else if (internalMode == 3)
{
@@ -1437,8 +1438,10 @@ public BezahlCode(AuthorityType authority, string name, string account, string b
var newWayFilled = (!string.IsNullOrEmpty(iban) && !string.IsNullOrEmpty(bic));
//Non-SEPA payment types
+#pragma warning disable CS0612
if (authority == AuthorityType.periodicsinglepayment || authority == AuthorityType.singledirectdebit || authority == AuthorityType.singlepayment || authority == AuthorityType.contact || (authority == AuthorityType.contact_v2 && oldWayFilled))
{
+#pragma warning restore CS0612
if (!Regex.IsMatch(account.Replace(" ", ""), @"^[0-9]{1,9}$"))
throw new BezahlCodeException("The account entered isn't valid.");
this.account = account.Replace(" ", "").ToUpper();
@@ -1500,8 +1503,9 @@ public BezahlCode(AuthorityType authority, string name, string account, string b
throw new BezahlCodeException("Execution date must be today or in future.");
this.executionDate = (DateTime)executionDate;
}
-
+#pragma warning disable CS0612
if (authority == AuthorityType.periodicsinglepayment || authority == AuthorityType.periodicsinglepaymentsepa)
+#pragma warning restore CS0612
{
if (periodicTimeunit.ToUpper() != "M" && periodicTimeunit.ToUpper() != "W")
throw new BezahlCodeException("The periodicTimeunit must be either 'M' (monthly) or 'W' (weekly).");
@@ -1530,8 +1534,9 @@ public override string ToString()
if (authority != AuthorityType.contact && authority != AuthorityType.contact_v2)
{
//Handle what is same for all payments
-
+#pragma warning disable CS0612
if (authority == AuthorityType.periodicsinglepayment || authority == AuthorityType.singledirectdebit || authority == AuthorityType.singlepayment)
+#pragma warning restore CS0612
{
bezahlCodePayload += $"account={account}&";
bezahlCodePayload += $"bnc={bnc}&";
@@ -1552,7 +1557,7 @@ public override string ToString()
bezahlCodePayload += $"creditorid={ Uri.EscapeDataString(creditorId)}&";
if (!string.IsNullOrEmpty(mandateId))
bezahlCodePayload += $"mandateid={ Uri.EscapeDataString(mandateId)}&";
- if (dateOfSignature != null)
+ if (dateOfSignature != DateTime.MinValue)
bezahlCodePayload += $"dateofsignature={dateOfSignature.ToString("ddMMyyyy")}&";
}
}
@@ -1562,16 +1567,17 @@ public override string ToString()
bezahlCodePayload += $"reason={ Uri.EscapeDataString(reason)}&";
bezahlCodePayload += $"currency={currency}&";
bezahlCodePayload += $"executiondate={executionDate.ToString("ddMMyyyy")}&";
-
+#pragma warning disable CS0612
if (authority == AuthorityType.periodicsinglepayment || authority == AuthorityType.periodicsinglepaymentsepa)
{
bezahlCodePayload += $"periodictimeunit={periodicTimeunit}&";
bezahlCodePayload += $"periodictimeunitrotation={periodicTimeunitRotation}&";
- if (periodicFirstExecutionDate != null)
+ if (periodicFirstExecutionDate != DateTime.MinValue)
bezahlCodePayload += $"periodicfirstexecutiondate={periodicFirstExecutionDate.ToString("ddMMyyyy")}&";
- if (periodicLastExecutionDate != null)
+ if (periodicLastExecutionDate != DateTime.MinValue)
bezahlCodePayload += $"periodiclastexecutiondate={periodicLastExecutionDate.ToString("ddMMyyyy")}&";
}
+#pragma warning restore CS0612
}
else
{
diff --git a/QRCoder/PdfByteQRCode.cs b/QRCoder/PdfByteQRCode.cs
index 02f70aa8..38d941b1 100644
--- a/QRCoder/PdfByteQRCode.cs
+++ b/QRCoder/PdfByteQRCode.cs
@@ -1,4 +1,4 @@
-#if NETFRAMEWORK || NETSTANDARD2_0
+#if NETFRAMEWORK || NETSTANDARD2_0 || NET5_0
using System;
using System.Collections.Generic;
using System.Drawing.Imaging;
diff --git a/QRCoder/PostscriptQRCode.cs b/QRCoder/PostscriptQRCode.cs
index ab13d804..6aee5b7d 100644
--- a/QRCoder/PostscriptQRCode.cs
+++ b/QRCoder/PostscriptQRCode.cs
@@ -1,4 +1,4 @@
-#if NETFRAMEWORK || NETSTANDARD2_0
+#if NETFRAMEWORK || NETSTANDARD2_0 || NET5_0
using System;
using System.Drawing;
using static QRCoder.QRCodeGenerator;
diff --git a/QRCoder/QRCode.cs b/QRCoder/QRCode.cs
index ccba5f55..b3e420f7 100644
--- a/QRCoder/QRCode.cs
+++ b/QRCoder/QRCode.cs
@@ -1,4 +1,4 @@
-#if NETFRAMEWORK || NETSTANDARD2_0
+#if NETFRAMEWORK || NETSTANDARD2_0 || NET5_0
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
diff --git a/QRCoder/QRCodeData.cs b/QRCoder/QRCodeData.cs
index 524b8997..8a19b5af 100644
--- a/QRCoder/QRCodeData.cs
+++ b/QRCoder/QRCodeData.cs
@@ -21,7 +21,7 @@ public QRCodeData(int version)
for (var i = 0; i < size; i++)
this.ModuleMatrix.Add(new BitArray(size));
}
-#if NETFRAMEWORK || NETSTANDARD2_0
+#if NETFRAMEWORK || NETSTANDARD2_0 || NET5_0
public QRCodeData(string pathToRawData, Compression compressMode) : this(File.ReadAllBytes(pathToRawData), compressMode)
{
}
@@ -154,7 +154,7 @@ public byte[] GetRawData(Compression compressMode)
return rawData;
}
-#if NETFRAMEWORK || NETSTANDARD2_0
+#if NETFRAMEWORK || NETSTANDARD2_0 || NET5_0
public void SaveRawData(string filePath, Compression compressMode)
{
File.WriteAllBytes(filePath, GetRawData(compressMode));
diff --git a/QRCoder/QRCodeGenerator.cs b/QRCoder/QRCodeGenerator.cs
index e16d4918..c7aa20ef 100644
--- a/QRCoder/QRCodeGenerator.cs
+++ b/QRCoder/QRCodeGenerator.cs
@@ -1104,7 +1104,7 @@ private static string ConvertToIso8859(string value, string Iso = "ISO-8859-2")
Encoding utf8 = Encoding.UTF8;
byte[] utfBytes = utf8.GetBytes(value);
byte[] isoBytes = Encoding.Convert(utf8, iso, utfBytes);
-#if NETFRAMEWORK || NETSTANDARD2_0
+#if NETFRAMEWORK || NETSTANDARD2_0 || NET5_0
return iso.GetString(isoBytes);
#else
return iso.GetString(isoBytes, 0, isoBytes.Length);
diff --git a/QRCoder/QRCoder.csproj b/QRCoder/QRCoder.csproj
index 829edc17..70fcaa3e 100644
--- a/QRCoder/QRCoder.csproj
+++ b/QRCoder/QRCoder.csproj
@@ -1,12 +1,14 @@
- net35;net40;netstandard1.1;netstandard2.0
+ net35;net40;netstandard1.1;netstandard2.0;net5.0;net5.0-windows
false
+ true
+ true
+ $(DefineConstants);NET5_0_WINDOWS
- bin\Release\
@@ -16,7 +18,6 @@
1.4.1
Raffael Herrmann
QRCoder
- QRCoder
MIT
https://github.com/codebude/QRCoder/
http://code-bude.net/downloads/qrcoder-logo.png
@@ -30,7 +31,7 @@
-
+
@@ -38,4 +39,4 @@
$(MSBuildProgramFiles32)\Reference Assemblies\Microsoft\Framework\.NETFramework\v3.5\Profile\Client
-
+
\ No newline at end of file
diff --git a/QRCoder/SvgQRCode.cs b/QRCoder/SvgQRCode.cs
index 1787c079..d9ab71a4 100644
--- a/QRCoder/SvgQRCode.cs
+++ b/QRCoder/SvgQRCode.cs
@@ -1,4 +1,4 @@
-#if NETFRAMEWORK || NETSTANDARD2_0
+#if NETFRAMEWORK || NETSTANDARD2_0 || NET5_0
using System;
using System.Collections;
using System.Drawing;
diff --git a/QRCoder/XamlQRCode.cs b/QRCoder/XamlQRCode.cs
index 348e506a..692bb8a5 100644
--- a/QRCoder/XamlQRCode.cs
+++ b/QRCoder/XamlQRCode.cs
@@ -1,4 +1,4 @@
-#if NETFRAMEWORK
+#if NETFRAMEWORK || NET5_0_WINDOWS
using System;
using System.Windows;
using System.Windows.Media;
diff --git a/QRCoderConsole/Program.cs b/QRCoderConsole/Program.cs
index c0bfcda6..5db827d4 100644
--- a/QRCoderConsole/Program.cs
+++ b/QRCoderConsole/Program.cs
@@ -164,6 +164,7 @@ private static void GenerateQRCode(string payloadString, QRCodeGenerator.ECCLeve
}
}
break;
+#if !NET5_0 && !NET5_0_WINDOWS
case SupportedImageFormat.Xaml:
using (var code = new XamlQRCode(data))
{
@@ -175,6 +176,7 @@ private static void GenerateQRCode(string payloadString, QRCodeGenerator.ECCLeve
}
}
break;
+#endif
case SupportedImageFormat.Ps:
case SupportedImageFormat.Eps:
using (var code = new PostscriptQRCode(data))
diff --git a/QRCoderConsole/Properties/AssemblyInfo.cs b/QRCoderConsole/Properties/AssemblyInfo.cs
index 84b3205f..b38355b2 100644
--- a/QRCoderConsole/Properties/AssemblyInfo.cs
+++ b/QRCoderConsole/Properties/AssemblyInfo.cs
@@ -17,11 +17,10 @@
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
-[assembly: AssemblyVersion ("1.0.*")]
+[assembly: AssemblyVersion ("1.0.0.0")]
// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
//[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("")]
-
diff --git a/QRCoderConsole/QRCoderConsole.csproj b/QRCoderConsole/QRCoderConsole.csproj
index 6d1b67e1..846940ce 100644
--- a/QRCoderConsole/QRCoderConsole.csproj
+++ b/QRCoderConsole/QRCoderConsole.csproj
@@ -1,52 +1,33 @@
-
-
+
+
- Debug
- AnyCPU
- {014F04C6-6099-4552-9A4F-D09C6E39D576}
+ net45;net5.0;net5.0-windows
+ true
+ true
+ $(DefineConstants);NET5_0_WINDOWS
+ true
Exe
- QRCoderConsole
- QRCoderConsole
- v4.5
+ false
+
- true
- full
- false
- bin\Debug
- DEBUG;
- prompt
- 4
- true
--in foo --out fooQR.png
- full
- true
- bin\Release
- prompt
- 4
- true
-
+
+
-
-
- ..\packages\NDesk.Options.0.2.1\lib\NDesk.Options.dll
-
-
-
-
-
-
+
+
-
-
+
+
{aa6be23a-7813-4d2a-835e-b673631ae9f1}
diff --git a/QRCoderConsole/packages.config b/QRCoderConsole/packages.config
deleted file mode 100644
index da45c27f..00000000
--- a/QRCoderConsole/packages.config
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/QRCoderDemo/Form1.cs b/QRCoderDemo/Form1.cs
index 12ac1154..a955d644 100644
--- a/QRCoderDemo/Form1.cs
+++ b/QRCoderDemo/Form1.cs
@@ -125,14 +125,8 @@ private void btn_save_Click(object sender, EventArgs e)
}
pictureBoxQRCode.BackgroundImage.Save(fs, imageFormat);
- fs.Close();
}
}
-
-
-
-
-
}
public void ExportToBmp(string path)
diff --git a/QRCoderDemo/QRCoderDemo.csproj b/QRCoderDemo/QRCoderDemo.csproj
index 3ff23c20..01aaef86 100644
--- a/QRCoderDemo/QRCoderDemo.csproj
+++ b/QRCoderDemo/QRCoderDemo.csproj
@@ -1,83 +1,19 @@
-
-
+
+
- Debug
- x86
- {CA6DB0F5-DB6C-4DDD-8B5F-EF82FBB963E9}
- WinExe
- Properties
- QRCoderDemo
- QRCoderDemo
- v4.5
-
-
- 512
+ net45;net5.0-windows
+ true
+ Exe
+ false
+
- x86
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
- false
- x86
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
- false
-
-
-
-
-
-
-
-
-
+
+
-
-
-
-
- Form
-
-
- Form1.cs
-
-
-
-
- Form1.cs
-
-
- ResXFileCodeGenerator
- Resources.Designer.cs
- Designer
-
-
- True
- Resources.resx
- True
-
-
-
- SettingsSingleFileGenerator
- Settings.Designer.cs
-
-
- True
- Settings.settings
- True
-
@@ -85,12 +21,4 @@
QRCoder
-
-
\ No newline at end of file
diff --git a/QRCoderTests/PayloadGeneratorTests.cs b/QRCoderTests/PayloadGeneratorTests.cs
index c7982b82..fc469062 100644
--- a/QRCoderTests/PayloadGeneratorTests.cs
+++ b/QRCoderTests/PayloadGeneratorTests.cs
@@ -1245,9 +1245,9 @@ public void bezahlcode_generator_can_generate_payload_singlepayment_minimal()
var bnc = "100205000";
var name = "Wikimedia Fördergesellschaft";
var amount = 10.00m;
-
+#pragma warning disable CS0612
var generator = new PayloadGenerator.BezahlCode(AuthorityType.singlepayment, name, account: account, bnc: bnc, amount: amount);
-
+#pragma warning restore CS0612
generator
.ToString()
.ShouldBe("bank://singlepayment?name=Wikimedia%20F%C3%B6rdergesellschaft&account=001194700&bnc=100205000&amount=10,00¤cy=EUR&executiondate=" + DateTime.Now.ToString("ddMMyyyy") + "");
@@ -1265,9 +1265,9 @@ public void bezahlcode_generator_can_generate_payload_singlepayment_full()
var amount = 10.00m;
var postingKey = 69;
Currency currency = Currency.USD;
-
+#pragma warning disable CS0612
var generator = new PayloadGenerator.BezahlCode(AuthorityType.singlepayment, name, account, bnc, amount, "", 0, null, null, reason, postingKey, currency, DateTime.Now);
-
+#pragma warning restore CS0612
generator
.ToString()
.ShouldBe("bank://singlepayment?name=Wikimedia%20F%C3%B6rdergesellschaft&account=001194700&bnc=100205000&postingkey=69&amount=10,00&reason=Thanks%20for%20all%20your%20efforts¤cy=USD&executiondate=" + DateTime.Now.ToString("ddMMyyyy") + "");
@@ -1285,9 +1285,9 @@ public void bezahlcode_generator_can_generate_payload_singledirectdebit()
var amount = 10.00m;
var postingKey = 69;
Currency currency = Currency.USD;
-
+#pragma warning disable CS0612
var generator = new PayloadGenerator.BezahlCode(AuthorityType.singledirectdebit, name, account, bnc, amount, "", 0, null, null, reason, postingKey, currency, DateTime.Now);
-
+#pragma warning restore CS0612
generator
.ToString()
.ShouldBe("bank://singledirectdebit?name=Wikimedia%20F%C3%B6rdergesellschaft&account=001194700&bnc=100205000&postingkey=69&amount=10,00&reason=Thanks%20for%20all%20your%20efforts¤cy=USD&executiondate=" + DateTime.Now.ToString("ddMMyyyy") + "");
@@ -1309,9 +1309,9 @@ public void bezahlcode_generator_can_generate_payload_periodicsinglepayment()
var periodicFirstExecutionDate = DateTime.Now;
var periodicLastExecutionDate = DateTime.Now.AddMonths(3);
Currency currency = Currency.USD;
-
+#pragma warning disable CS0612
var generator = new PayloadGenerator.BezahlCode(AuthorityType.periodicsinglepayment, name, account, bnc, amount, periodicTimeunit, periodicTimeunitRotation, periodicFirstExecutionDate, periodicLastExecutionDate, reason, postingKey, currency, DateTime.Now);
-
+#pragma warning restore CS0612
generator
.ToString()
.ShouldBe("bank://periodicsinglepayment?name=Wikimedia%20F%C3%B6rdergesellschaft&account=001194700&bnc=100205000&postingkey=69&amount=10,00&reason=Thanks%20for%20all%20your%20efforts¤cy=USD&executiondate=" + DateTime.Now.ToString("ddMMyyyy") + "&periodictimeunit=W&periodictimeunitrotation=2&periodicfirstexecutiondate=" + periodicFirstExecutionDate.ToString("ddMMyyyy") + "&periodiclastexecutiondate=" + periodicLastExecutionDate.ToString("ddMMyyyy"));
@@ -1492,9 +1492,9 @@ public void bezahlcode_generator_should_handle_account_whitespaces()
var bnc = "100205000";
var name = "Wikimedia Fördergesellschaft";
var amount = 10.00m;
-
+#pragma warning disable CS0612
var generator = new PayloadGenerator.BezahlCode(AuthorityType.singlepayment, name, account: account, bnc: bnc, amount: amount);
-
+#pragma warning restore CS0612
generator
.ToString()
.ShouldBe("bank://singlepayment?name=Wikimedia%20F%C3%B6rdergesellschaft&account=01194700&bnc=100205000&amount=10,00¤cy=EUR&executiondate=" + DateTime.Now.ToString("ddMMyyyy") + "");
@@ -1509,9 +1509,9 @@ public void bezahlcode_generator_should_handle_bnc_whitespaces()
var bnc = "10020 5000";
var name = "Wikimedia Fördergesellschaft";
var amount = 10.00m;
-
+#pragma warning disable CS0612
var generator = new PayloadGenerator.BezahlCode(AuthorityType.singlepayment, name, account: account, bnc: bnc, amount: amount);
-
+#pragma warning restore CS0612
generator
.ToString()
.ShouldBe("bank://singlepayment?name=Wikimedia%20F%C3%B6rdergesellschaft&account=001194700&bnc=100205000&amount=10,00¤cy=EUR&executiondate=" + DateTime.Now.ToString("ddMMyyyy") + "");
@@ -1560,9 +1560,9 @@ public void bezahlcode_generator_should_add_decimals()
var bnc = "10020 5000";
var name = "Wikimedia Fördergesellschaft";
var amount = 10;
-
+#pragma warning disable CS0612
var generator = new PayloadGenerator.BezahlCode(AuthorityType.singlepayment, name, account: account, bnc: bnc, amount: amount);
-
+#pragma warning restore CS0612
generator
.ToString()
.ShouldBe("bank://singlepayment?name=Wikimedia%20F%C3%B6rdergesellschaft&account=001194700&bnc=100205000&amount=10,00¤cy=EUR&executiondate=" + DateTime.Now.ToString("ddMMyyyy") + "");
@@ -1576,9 +1576,9 @@ public void bezahlcode_generator_should_throw_wrong_contact_constructor_exceptio
var account = "0001194700";
var bnc = "10020 5000";
var name = "Wikimedia Fördergesellschaft";
-
+#pragma warning disable CS0612
var exception = Record.Exception(() => new PayloadGenerator.BezahlCode(AuthorityType.singlepayment, name, account, bnc, "", "", "New business contact."));
-
+#pragma warning restore CS0612
Assert.NotNull(exception);
Assert.IsType(exception);
exception.Message.ShouldBe("The constructor without an amount may only ne used with authority types 'contact' and 'contact_v2'.");
@@ -1632,9 +1632,9 @@ public void bezahlcode_generator_should_throw_wrong_nonsepa_constructor_periodic
var periodicFirstExecutionDate = DateTime.Now;
var periodicLastExecutionDate = DateTime.Now.AddMonths(3);
Currency currency = Currency.USD;
-
+#pragma warning disable CS0612
var exception = Record.Exception(() => new PayloadGenerator.BezahlCode(AuthorityType.periodicsinglepayment, name, account, bnc, amount, periodicTimeunit, periodicTimeunitRotation, periodicFirstExecutionDate, periodicLastExecutionDate, reason, postingKey, currency, DateTime.Now));
-
+#pragma warning restore CS0612
Assert.NotNull(exception);
Assert.IsType(exception);
exception.Message.ShouldBe("When using 'periodicsinglepayment' as authority type, the parameters 'periodicTimeunit' and 'periodicTimeunitRotation' must be set.");
@@ -1649,9 +1649,9 @@ public void bezahlcode_generator_should_throw_wrong_sepa_constructor_exception()
var bic = "BFSWDE33BER";
var name = "Wikimedia Fördergesellschaft";
var amount = 10.00m;
-
+#pragma warning disable CS0612
var exception = Record.Exception(() => new PayloadGenerator.BezahlCode(AuthorityType.singlepayment, name, iban: iban, bic: bic, amount: amount));
-
+#pragma warning restore CS0612
Assert.NotNull(exception);
Assert.IsType(exception);
exception.Message.ShouldBe("The constructor with 'iban' and 'bic' may only be used with 'SEPA' authority types. Either choose another authority type or switch constructor.");
@@ -1728,9 +1728,9 @@ public void bezahlcode_generator_should_throw_invalid_account_exception()
var bnc = "100205000";
var name = "Wikimedia Fördergesellschaft";
var amount = 10.00m;
-
+#pragma warning disable CS0612
var exception = Record.Exception(() => new PayloadGenerator.BezahlCode(AuthorityType.singlepayment, name, account: account, bnc: bnc, amount: amount));
-
+#pragma warning restore CS0612
Assert.NotNull(exception);
Assert.IsType(exception);
exception.Message.ShouldBe("The account entered isn't valid.");
@@ -1745,9 +1745,9 @@ public void bezahlcode_generator_should_throw_invalid_bnc_exception()
var bnc = "10020500023545626226262";
var name = "Wikimedia Fördergesellschaft";
var amount = 10.00m;
-
+#pragma warning disable CS0612
var exception = Record.Exception(() => new PayloadGenerator.BezahlCode(AuthorityType.singlepayment, name, account: account, bnc: bnc, amount: amount));
-
+#pragma warning restore CS0612
Assert.NotNull(exception);
Assert.IsType(exception);
exception.Message.ShouldBe("The bnc entered isn't valid.");
@@ -1763,9 +1763,9 @@ public void bezahlcode_generator_should_throw_invalid_postingkey_exception()
var name = "Wikimedia Fördergesellschaft";
var postingKey = 101;
var amount = 10.00m;
-
+#pragma warning disable CS0612
var exception = Record.Exception(() => new PayloadGenerator.BezahlCode(AuthorityType.singlepayment, name, account: account, bnc: bnc, amount: amount, postingKey: postingKey));
-
+#pragma warning restore CS0612
Assert.NotNull(exception);
Assert.IsType(exception);
exception.Message.ShouldBe("PostingKey must be within 0 and 99.");
@@ -1922,10 +1922,9 @@ public void bezahlcode_generator_should_throw_invalid_executiondate_exception()
var postingKey = 69;
var executionDate = new DateTime(2017, 1, 1);
Currency currency = Currency.USD;
-
-
+#pragma warning disable CS0612
var exception = Record.Exception(() => new PayloadGenerator.BezahlCode(AuthorityType.singlepayment, name, account, bnc, amount, "", 0, null, null, reason, postingKey, currency, executionDate));
-
+#pragma warning restore CS0612
Assert.NotNull(exception);
Assert.IsType(exception);
exception.Message.ShouldBe("Execution date must be today or in future.");
diff --git a/QRCoderTests/QRCodeRendererTests.cs b/QRCoderTests/QRCodeRendererTests.cs
index 69baa0bd..fe7b6e94 100644
--- a/QRCoderTests/QRCodeRendererTests.cs
+++ b/QRCoderTests/QRCodeRendererTests.cs
@@ -38,6 +38,16 @@ public void can_create_standard_qrcode_graphic()
#if !NETCOREAPP1_1 && !NETCOREAPP2_0
+ private string GetAssemblyPath()
+ {
+ return
+#if NET5_0
+ System.Reflection.Assembly.GetExecutingAssembly().Location;
+#else
+ System.Reflection.Assembly.GetExecutingAssembly().CodeBase.Replace("file:\\", "");
+#endif
+ }
+
[Fact]
[Category("QRRenderer/QRCode")]
public void can_create_qrcode_with_transparent_logo_graphic()
@@ -45,7 +55,8 @@ public void can_create_qrcode_with_transparent_logo_graphic()
//Create QR code
var gen = new QRCodeGenerator();
var data = gen.CreateQrCode("This is a quick test! 123#?", QRCodeGenerator.ECCLevel.H);
- var bmp = new QRCode(data).GetGraphic(10, Color.Black, Color.Transparent, icon: (Bitmap)Bitmap.FromFile(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).Replace("file:\\", "") + "\\assets\\noun_software engineer_2909346.png"));
+
+ var bmp = new QRCode(data).GetGraphic(10, Color.Black, Color.Transparent, icon: (Bitmap)Image.FromFile(GetAssemblyPath() + "\\assets\\noun_software engineer_2909346.png"));
//Used logo is licensed under public domain. Ref.: https://thenounproject.com/Iconathon1/collection/redefining-women/?i=2909346
var ms = new MemoryStream();
@@ -66,7 +77,7 @@ public void can_create_qrcode_with_non_transparent_logo_graphic()
//Create QR code
var gen = new QRCodeGenerator();
var data = gen.CreateQrCode("This is a quick test! 123#?", QRCodeGenerator.ECCLevel.H);
- var bmp = new QRCode(data).GetGraphic(10, Color.Black, Color.White, icon: (Bitmap)Bitmap.FromFile(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).Replace("file:\\", "") + "\\assets\\noun_software engineer_2909346.png"));
+ var bmp = new QRCode(data).GetGraphic(10, Color.Black, Color.White, icon: (Bitmap)Bitmap.FromFile(GetAssemblyPath() + "\\assets\\noun_software engineer_2909346.png"));
//Used logo is licensed under public domain. Ref.: https://thenounproject.com/Iconathon1/collection/redefining-women/?i=2909346
var ms = new MemoryStream();
@@ -81,7 +92,4 @@ public void can_create_qrcode_with_non_transparent_logo_graphic()
}
#endif
}
-}
-
-
-
+}
\ No newline at end of file
diff --git a/QRCoderTests/QRCoderTests.csproj b/QRCoderTests/QRCoderTests.csproj
index d6649c30..0ad869ff 100644
--- a/QRCoderTests/QRCoderTests.csproj
+++ b/QRCoderTests/QRCoderTests.csproj
@@ -1,6 +1,9 @@
- net35;net452;netcoreapp1.1;netcoreapp2.0
+ net35;net452;netcoreapp1.1;netcoreapp2.0;net5.0;net5.0-windows
+ true
+ true
+ $(DefineConstants);NET5_0_WINDOWS
false
true