Skip to content

Commit 58caa70

Browse files
committed
Fixed references (especially net5.0 stuff) in QRCoderConsole
Note: net6.0 isn't added as target for QRCoderConsole because QRCoderConsole heavily relies on System.Drawing which isn't available on net6.0 any longer.
1 parent e9a026c commit 58caa70

File tree

4 files changed

+14
-20
lines changed

4 files changed

+14
-20
lines changed

QRCoder.Xaml/QRCoder.Xaml.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
<PropertyGroup>
44
<TargetFrameworks>net35;net40;net5.0-windows;net6.0-windows</TargetFrameworks>
55
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
6-
<UseWindowsForms Condition="'$(TargetFramework)' == 'net5.0-windows' or '$(TargetFramework)' == 'net6.0-windows'">true</UseWindowsForms>
7-
<UseWPF Condition="'$(TargetFramework)' == 'net5.0-windows' or '$(TargetFramework)' == 'net6.0-windows'">true</UseWPF>
6+
<!-- <UseWindowsForms Condition="'$(TargetFramework)' == 'net5.0-windows' or '$(TargetFramework)' == 'net6.0-windows'">true</UseWindowsForms> -->
7+
<UseWPF Condition="'$(TargetFramework)' == 'net5.0-windows' or '$(TargetFramework)' == 'net6.0-windows'">true</UseWPF>
88
<DefineConstants Condition="'$(TargetFramework)' == 'net5.0-windows'">$(DefineConstants);NET5_0_WINDOWS</DefineConstants>
99
<CheckEolTargetFramework>false</CheckEolTargetFramework>
1010
<DisableImplicitNuGetFallbackFolder>true</DisableImplicitNuGetFallbackFolder>

QRCoderConsole/SupportedImageFormat.cs renamed to QRCoderConsole/DataObjects/SupportedImageFormat.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
6-
7-
namespace QRCoderConsole
1+
namespace QRCoderConsole.DataObjects
82
{
93
public enum SupportedImageFormat
104
{
@@ -14,7 +8,9 @@ public enum SupportedImageFormat
148
Bmp,
159
Tiff,
1610
Svg,
11+
#if !NET5_0 || NET5_0_WINDOWS
1712
Xaml,
13+
#endif
1814
Ps,
1915
Eps,
2016
}

QRCoderConsole/Program.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
using System;
2-
using System.Drawing;
32
using System.Drawing.Imaging;
43
using System.IO;
54
using NDesk.Options;
6-
using System.Reflection;
5+
using QRCoderConsole.DataObjects;
76
using QRCoder;
87
using System.Text;
98
using System.Windows.Markup;
@@ -35,7 +34,7 @@ public static void Main (string[] args)
3534
value => eccLevel = setter.GetECCLevel(value)
3635
},
3736
{ "f|output-format=",
38-
"Image format for outputfile. Possible values: png, jpg, gif, bmp, tiff, svg, xaml, ps, eps (default: png)",
37+
$"Image format for outputfile. Possible values: {string.Join(", ", Enum.GetNames(typeof(SupportedImageFormat)))} (default: png)",
3938
value => { Enum.TryParse(value, true, out imageFormat); }
4039
},
4140
{
@@ -164,9 +163,9 @@ private static void GenerateQRCode(string payloadString, QRCodeGenerator.ECCLeve
164163
}
165164
}
166165
break;
167-
#if !NET5_0 && !NET5_0_WINDOWS
166+
#if NETFRAMEWORK || NET5_0_WINDOWS || NET6_0_WINDOWS
168167
case SupportedImageFormat.Xaml:
169-
using (var code = new XamlQRCode(data))
168+
using (var code = new QRCoder.Xaml.XamlQRCode(data))
170169
{
171170
var test = XamlWriter.Save(code.GetGraphic(pixelsPerModule, foreground, background, true));
172171
using (var f = File.CreateText(outputFileName))

QRCoderConsole/QRCoderConsole.csproj

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,12 @@
2525
<PackageReference Include="System.Drawing.Common" Version="4.7.0" />
2626
</ItemGroup>
2727
<ItemGroup>
28-
<PackageReference Include="NDesk.Options" Version="0.2.1" />
28+
<PackageReference Include="NDesk.Options.Core" Version="1.2.5" />
29+
</ItemGroup>
30+
<ItemGroup Condition=" '$(TargetFramework)' != 'net5.0'">
31+
<ProjectReference Include="..\QRCoder.Xaml\QRCoder.Xaml.csproj" />
2932
</ItemGroup>
30-
3133
<ItemGroup>
32-
<ProjectReference Include="..\QRCoder\QRCoder.csproj">
33-
<Project>{aa6be23a-7813-4d2a-835e-b673631ae9f1}</Project>
34-
<Name>QRCoder</Name>
35-
</ProjectReference>
34+
<ProjectReference Include="..\QRCoder\QRCoder.csproj" />
3635
</ItemGroup>
3736
</Project>

0 commit comments

Comments
 (0)