Skip to content

Commit

Permalink
Some code refactoring and upgrade console project to .net6
Browse files Browse the repository at this point in the history
  • Loading branch information
Kees committed Mar 6, 2024
1 parent cbeb227 commit 72b1ebb
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 22 deletions.
18 changes: 6 additions & 12 deletions ChromiumHtmlToPdfConsole/ChromiumHtmlToPdfConsole.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<StartupObject>ChromiumHtmlToPdfConsole.Program</StartupObject>
<ApplicationIcon />
<AssemblyVersion>4.0.1.0</AssemblyVersion>
Expand All @@ -17,7 +16,8 @@
<RepositoryType>NuGet</RepositoryType>
<PackageTags>convert html pdf chrome edge</PackageTags>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<PackageReleaseNotes></PackageReleaseNotes>
<PackageReleaseNotes>
</PackageReleaseNotes>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageId />
<AssemblyName>ChromiumHtmlToPdfConsole</AssemblyName>
Expand All @@ -26,29 +26,23 @@
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="AngleSharp" Version="0.17.1" />
<PackageReference Include="AngleSharp.Io" Version="0.17.0" />
<PackageReference Include="AngleSharp.Xml" Version="0.17.0" />
<PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="System.Drawing.Common" Version="8.0.2" />
</ItemGroup>

<ItemGroup>
<None Include="Chrome-icon.png">
<Pack>True</Pack>
<PackagePath></PackagePath>
<PackagePath>
</PackagePath>
</None>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\ChromiumHtmlToPdfLib\ChromiumHtmlToPdfLib.csproj" />
</ItemGroup>

</Project>
</Project>
2 changes: 1 addition & 1 deletion ChromiumHtmlToPdfLib/ChromiumHtmlToPdfLib.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
<Version>4.2.0</Version>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Description>ChromiumHtmlToPdf is a 100% managed C# library that can be used to convert HTML to PDF or PNG format with the use of Google Chrome or Microsoft Edge</Description>
Expand Down
4 changes: 0 additions & 4 deletions ChromiumHtmlToPdfLib/Converter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2605,11 +2605,7 @@ private void KillProcessAndChildren(int processId)
try
{
var process = Process.GetProcessById(processId);
#if (NETSTANDARD2_0)
process.Kill();
#else
process.Kill(true);
#endif
}
catch (Exception exception)
{
Expand Down
2 changes: 1 addition & 1 deletion ChromiumHtmlToPdfLib/FileCache/FileCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ private class CacheItemReference : IComparable<CacheItemReference>

public int CompareTo(CacheItemReference other)
{
var i = LastAccessTime.CompareTo(other.LastAccessTime);
var i = LastAccessTime.CompareTo(other!.LastAccessTime);

// It's possible, although rare, that two different items will have
// the same LastAccessTime. So in that case, we need to check to see
Expand Down
8 changes: 4 additions & 4 deletions ChromiumHtmlToPdfLib/FileCache/HashedFileCacheManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
namespace ChromiumHtmlToPdfLib.FileCache;

/// <summary>
/// File-based caching using xxHash. Collisions are handled by appending
/// File-based caching using Md5Hash. Collisions are handled by appending
/// numerically ascending identifiers to each hash key (e.g. _1, _2, etc.).
/// </summary>
internal class HashedFileCacheManager : FileCacheManager
{
#region Fields
private static readonly MD5 md5Hash = MD5.Create();
private static readonly MD5 Md5Hash = MD5.Create();
#endregion

#region ComputeHash
Expand All @@ -24,9 +24,9 @@ internal class HashedFileCacheManager : FileCacheManager
/// <returns></returns>
public static string ComputeHash(string key)
{
var hash = md5Hash.ComputeHash(Encoding.UTF8.GetBytes(key));
var hash = Md5Hash.ComputeHash(Encoding.UTF8.GetBytes(key));

return BitConverter.ToString(hash).Replace("-", string.Empty).Substring(0,16); // Grab 64-bit value
return BitConverter.ToString(hash).Replace("-", string.Empty).Substring(0, 16); // Grab 64-bit value
}
#endregion

Expand Down

0 comments on commit 72b1ebb

Please sign in to comment.