Skip to content

Commit 267f77c

Browse files
Add .NET 6
1 parent 71c9555 commit 267f77c

File tree

4 files changed

+16
-15
lines changed

4 files changed

+16
-15
lines changed

PdfFileWriter/PdfDocument.cs

+8-1
Original file line numberDiff line numberDiff line change
@@ -1392,10 +1392,17 @@ int Length
13921392
)
13931393
{
13941394
byte[] ByteArray = new byte[Length];
1395-
using(RNGCryptoServiceProvider RandNumGen = new RNGCryptoServiceProvider())
1395+
#if NET6_0_OR_GREATER
1396+
using (RandomNumberGenerator RandNumGen = RandomNumberGenerator.Create())
13961397
{
13971398
RandNumGen.GetBytes(ByteArray);
13981399
}
1400+
#else
1401+
using (RNGCryptoServiceProvider RandNumGen = new RNGCryptoServiceProvider())
1402+
{
1403+
RandNumGen.GetBytes(ByteArray);
1404+
}
1405+
#endif
13991406
return ByteArray;
14001407
}
14011408

PdfFileWriter/PdfEncryption.cs

+4
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,11 @@ public class PdfEncryption : PdfObject, IDisposable
121121
internal EncryptionType EncryptionType;
122122
internal byte[] MasterKey;
123123
internal MD5 MD5 = MD5.Create();
124+
#if NET6_0_OR_GREATER
125+
internal Aes AES = Aes.Create();
126+
#else
124127
internal AesCryptoServiceProvider AES = new AesCryptoServiceProvider();
128+
#endif
125129

126130
private static readonly byte[] PasswordPad =
127131
{

PdfFileWriter/PdfFileWriter.csproj

+2-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net472;netcoreapp3.1;net5.0-windows</TargetFrameworks>
4+
<TargetFrameworks>net472;netcoreapp3.1;net5.0-windows;net6.0-windows</TargetFrameworks>
55
<AssemblyProduct>PdfFileWriter</AssemblyProduct>
66
<AssemblyName>PdfFileWriter</AssemblyName>
77
<AssemblyVersion>1.28.0</AssemblyVersion>
@@ -23,20 +23,10 @@
2323
<UseWindowsForms>true</UseWindowsForms>
2424
</PropertyGroup>
2525

26-
<PropertyGroup Condition="'$(TargetFramework)' == 'net472' Or '$(TargetFramework)' == 'net48'">
27-
<DefineConstants>$(DefineConstants);NET4</DefineConstants>
28-
</PropertyGroup>
29-
<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
30-
<DefineConstants>$(DefineConstants);NETCORE</DefineConstants>
31-
</PropertyGroup>
32-
<PropertyGroup Condition="'$(TargetFramework)' == 'net5.0-windows'">
33-
<DefineConstants>$(DefineConstants);NET5</DefineConstants>
34-
</PropertyGroup>
35-
3626
<ItemGroup Condition="'$(TargetFramework)' == 'net472' Or '$(TargetFramework)' == 'net48'">
3727
<Reference Include="System.Windows.Forms.DataVisualization" />
3828
</ItemGroup>
39-
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1' Or '$(TargetFramework)' == 'net5.0-windows'">
29+
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1' Or '$(TargetFramework)' == 'net5.0-windows' Or '$(TargetFramework)' == 'net6.0-windows'">
4030
<PackageReference Include="System.Windows.Forms.DataVisualization" Version="1.0.0-prerelease.20110.1" />
4131
</ItemGroup>
4232

Samples/TestPdfFileWriter.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>WinExe</OutputType>
5-
<TargetFrameworks>net472;netcoreapp3.1;net5.0-windows</TargetFrameworks>
5+
<TargetFrameworks>net472;netcoreapp3.1;net5.0-windows;net6.0-windows</TargetFrameworks>
66
<AssemblyTitle>TestPdfFileWriter</AssemblyTitle>
77
<AssemblyName>TestPdfFileWriter</AssemblyName>
88
<AssemblyVersion>1.28.0</AssemblyVersion>
@@ -26,7 +26,7 @@
2626
<ItemGroup Condition="'$(TargetFramework)' == 'net472' Or '$(TargetFramework)' == 'net48'">
2727
<Reference Include="System.Windows.Forms.DataVisualization" />
2828
</ItemGroup>
29-
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1' Or '$(TargetFramework)' == 'net5.0-windows'">
29+
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1' Or '$(TargetFramework)' == 'net5.0-windows' Or '$(TargetFramework)' == 'net6.0-windows'">
3030
<PackageReference Include="System.Windows.Forms.DataVisualization" Version="1.0.0-prerelease.20110.1" />
3131
</ItemGroup>
3232

0 commit comments

Comments
 (0)