Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
1752d19
Bump Codeuctivity.SkiaSharpCompare from 2.0.159 to 2.1.185
dependabot[bot] May 1, 2025
649ac1b
Merge pull request #173 from Codeuctivity/dependabot/nuget/Codeuctivi…
stesee May 1, 2025
8897067
Bump Codeuctivity.HtmlRenderer and 2 others
dependabot[bot] Jul 16, 2025
20398a6
Merge pull request #178 from Codeuctivity/dependabot/nuget/OpenXmlToH…
stesee Jul 29, 2025
971e6e8
Bump Codeuctivity.OpenXmlPowerTools from 8.0.314 to 8.0.369
dependabot[bot] Jul 30, 2025
a8fde99
Merge pull request #181 from Codeuctivity/dependabot/nuget/OpenXmlToH…
stesee Jul 31, 2025
94e7fa2
Bump Codeuctivity.OpenXmlPowerTools and Microsoft.NET.ILLink.Tasks
dependabot[bot] Aug 5, 2025
087b3a5
Merge pull request #183 from Codeuctivity/dependabot/nuget/OpenXmlToH…
stesee Aug 6, 2025
e68c839
Update dependencies and improve GitHub Actions workflow for .NET proj…
stesee Aug 16, 2025
e819d73
Enhance error handling in ExportImageHandler and improve Linux utilit…
stesee Aug 16, 2025
2a894f3
Apply suggestion from @Copilot
stesee Aug 17, 2025
a4f87a5
Bump Codeuctivity.OpenXmlPowerTools 8.0.374 -> 9.0.385
stesee Aug 17, 2025
8afe53e
Bump actions/checkout from 4 to 5
dependabot[bot] Aug 18, 2025
bea95f0
Merge pull request #185 from Codeuctivity/dependabot/github_actions/a…
stesee Aug 18, 2025
bddb35d
Bump Swashbuckle.AspNetCore from 9.0.3 to 9.0.4
dependabot[bot] Aug 28, 2025
a23741f
Bump actions/setup-dotnet from 4 to 5
dependabot[bot] Sep 8, 2025
dcd8b6e
Bump actions/stale from 9 to 10
dependabot[bot] Sep 8, 2025
32028c2
Merge pull request #187 from Codeuctivity/dependabot/github_actions/a…
stesee Sep 8, 2025
55cf073
Merge pull request #188 from Codeuctivity/dependabot/github_actions/a…
stesee Sep 8, 2025
fc6340b
Merge pull request #186 from Codeuctivity/dependabot/nuget/OpenXmlToH…
stesee Sep 20, 2025
fbf4421
Bump Codeuctivity.SkiaSharpCompare from 2.1.185 to 2.1.202
dependabot[bot] Sep 29, 2025
40dd096
Merge pull request #189 from Codeuctivity/dependabot/nuget/OpenXmlToH…
stesee Sep 29, 2025
03172a8
Bump Swashbuckle.AspNetCore from 9.0.4 to 9.0.5
dependabot[bot] Sep 30, 2025
1adcc7c
Merge pull request #190 from Codeuctivity/dependabot/nuget/OpenXmlToH…
stesee Sep 30, 2025
7862722
Bump Swashbuckle.AspNetCore from 9.0.5 to 9.0.6
dependabot[bot] Oct 3, 2025
ae471fa
Merge pull request #191 from Codeuctivity/dependabot/nuget/OpenXmlToH…
stesee Oct 4, 2025
9268ab3
Bump Codeuctivity.OpenXmlPowerTools from 9.0.385 to 9.0.416
dependabot[bot] Oct 13, 2025
7b96046
Merge pull request #192 from Codeuctivity/dependabot/nuget/OpenXmlToH…
stesee Oct 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
154 changes: 63 additions & 91 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,116 +14,88 @@ jobs:
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal --configuration Release
- name: Publish Unit Test Results
uses: actions/upload-artifact@v4
if: failure()
with:
name: TestResult
path: "TestResult/**/*"
- uses: actions/checkout@v5
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal --configuration Release
- name: Publish Unit Test Results
uses: actions/upload-artifact@v4
if: failure()
with:
name: TestResult
path: "TestResult/**/*"

deployRelease:
if: ${{ github.ref == 'refs/heads/release' }}
runs-on: windows-latest
needs: build
needs: build
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: |
- uses: actions/checkout@v5
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: |
dotnet build --configuration Release --no-restore
dotnet publish ./OpenXmlToHtmlOpenApi -c Release /p:WebPublishMethod=Package
dotnet publish ./OpenXmlToHtmlCli -c Release
- name: Zip
uses: thedoctor0/zip-release@main
with:
path: .\OpenXmlToHtmlCli\bin\Release\net8.0\win-x64\publish
type: 'zip'
filename: 'OpenXmlToHtmlCli.zip'
- name: NugetPush
env:
- name: Zip
run: |
Compress-Archive -Path ".\OpenXmlToHtmlCli\bin\Release\net8.0\win-x64\publish\*" -DestinationPath ".\OpenXmlToHtmlCli.zip" -Force
- name: NugetPush
env:
NUGET_TOKEN_EXISTS: ${{ secrets.NUGET_TOKEN }}
if: env.NUGET_TOKEN_EXISTS != ''
run: |
if: env.NUGET_TOKEN_EXISTS != ''
run: |
dotnet nuget push .\OpenXmlToHtml\bin\Release\*.nupkg --skip-duplicate --api-key ${{secrets.NUGET_TOKEN}} --source https://api.nuget.org/v3/index.json
- name: Github Prelease
shell: bash
env:
GITHUB_TOKEN: ${{ github.TOKEN }}
if: env.GITHUB_TOKEN != ''
run: |
- name: Github Prelease
shell: bash
env:
GITHUB_TOKEN: ${{ github.TOKEN }}
if: env.GITHUB_TOKEN != ''
run: |
gh release create ${{env.CURRENT_VERSION}} ./OpenXmlToHtmlOpenApi/bin/Release/net8.0/OpenXmlToHtmlOpenApi.zip ./OpenXmlToHtmlCli.zip ./OpenXmlToHtml/bin/Release/*.*nupkg --generate-notes


deployTest:
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: windows-latest
needs: build
needs: build
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: |
- uses: actions/checkout@v5
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: |
dotnet build --configuration Release --no-restore
dotnet publish ./OpenXmlToHtmlOpenApi -c Release /p:WebPublishMethod=Package
dotnet publish ./OpenXmlToHtmlCli -c Release
- name: Zip
uses: thedoctor0/zip-release@main
with:
path: .\OpenXmlToHtmlCli\bin\Release\net8.0\win-x64\publish
type: 'zip'
filename: 'OpenXmlToHtmlCli.zip'
- name: NugetPush
env:
- name: Zip
run: |
Compress-Archive -Path ".\OpenXmlToHtmlCli\bin\Release\net8.0\win-x64\publish\*" -DestinationPath ".\OpenXmlToHtmlCli.zip" -Force
- name: NugetPush
env:
NUGET_TOKEN_EXISTS: ${{ secrets.NUGET_TEST_TOKEN }}
if: env.NUGET_TOKEN_EXISTS != ''
run: |
if: env.NUGET_TOKEN_EXISTS != ''
run: |
dotnet nuget push .\OpenXmlToHtml\bin\Release\*.nupkg --skip-duplicate --api-key ${{secrets.NUGET_TEST_TOKEN}} --source https://apiint.nugettest.org/v3/index.json
- name: Github Prelease
shell: bash
env:
GITHUB_TOKEN: ${{ github.TOKEN }}
if: env.GITHUB_TOKEN != ''
run: |
- name: Github Prelease
shell: bash
env:
GITHUB_TOKEN: ${{ github.TOKEN }}
if: env.GITHUB_TOKEN != ''
run: |
gh release create ${{env.CURRENT_VERSION}} ./OpenXmlToHtmlOpenApi/bin/Release/net8.0/OpenXmlToHtmlOpenApi.zip ./OpenXmlToHtmlCli.zip ./OpenXmlToHtml/bin/Release/*.*nupkg --prerelease --generate-notes

deployAzure:
if: ${{ github.ref == 'refs/heads/release' || github.ref == 'refs/heads/AzureAppPublishUsingGithubActions'}}
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Publish
run: dotnet publish ./OpenXmlToHtmlOpenApi/OpenXmlToHtmlOpenApi.csproj --configuration Release -o ./Publish
- uses: azure/webapps-deploy@v3
with:
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
package: './Publish'
2 changes: 1 addition & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
pull-requests: write

steps:
- uses: actions/stale@v9
- uses: actions/stale@v10
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'Stale issue message'
Expand Down
8 changes: 7 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,11 @@
"nupkg",
"snupkg"
],
"editor.formatOnSave": true
"editor.formatOnSave": true,
"dotnet.testDiscovery.enabled": true,
"dotnet.testProjectPath": [
"OpenXmlToHtmlTests",
"OpenXmlToHtmlOpenApiTests"
],
"testing.autoRun.mode": "rerun"
}
7 changes: 6 additions & 1 deletion OpenXmlToHtml/ExportImageHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ public ExportImageHandler(IDictionary<string, byte[]> images)
/// <returns></returns>
public XElement TransformImage(ImageInfo imageInfo)
{
if (imageInfo?.Image == null)
{
throw new ArgumentException("ImageInfo or Image cannot be null", nameof(imageInfo));
}

var cid = Guid.NewGuid().ToString();
using var memoryStream = new MemoryStream();
imageInfo.Image.CopyTo(memoryStream);
Expand All @@ -41,7 +46,7 @@ public XElement TransformImage(ImageInfo imageInfo)

var cidReference = $"cid: {cid}";

return new XElement(Xhtml.img, new XAttribute(NoNamespace.src, cidReference), imageInfo.ImgStyleAttribute, imageInfo?.AltText != null ? new XAttribute(NoNamespace.alt, imageInfo.AltText) : null);
return new XElement(Xhtml.img, new XAttribute(NoNamespace.src, cidReference), imageInfo.ImgStyleAttribute, !string.IsNullOrEmpty(imageInfo.AltText) ? new XAttribute(NoNamespace.alt, imageInfo.AltText) : null);

Copilot AI Oct 13, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] This line is too long and complex. Consider breaking it into multiple lines or extracting the conditional attribute creation into a variable for better readability.

Suggested change
return new XElement(Xhtml.img, new XAttribute(NoNamespace.src, cidReference), imageInfo.ImgStyleAttribute, !string.IsNullOrEmpty(imageInfo.AltText) ? new XAttribute(NoNamespace.alt, imageInfo.AltText) : null);
var altAttribute = !string.IsNullOrEmpty(imageInfo.AltText)
? new XAttribute(NoNamespace.alt, imageInfo.AltText)
: null;
return new XElement(
Xhtml.img,
new XAttribute(NoNamespace.src, cidReference),
imageInfo.ImgStyleAttribute,
altAttribute
);

Copilot uses AI. Check for mistakes.
}
}
}
4 changes: 2 additions & 2 deletions OpenXmlToHtml/OpenXmlToHtml.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Codeuctivity.OpenXmlPowerTools" Version="8.0.314" />
<PackageReference Include="Codeuctivity.OpenXmlPowerTools" Version="9.0.416" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="all" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="10.6.0.109712">
<PackageReference Include="SonarAnalyzer.CSharp" Version="10.15.0.120848">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
18 changes: 16 additions & 2 deletions OpenXmlToHtml/Tooling/Linux.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,20 @@

namespace Codeuctivity.OpenXmlToHtml.Tooling
{
public class Linux
/// <summary>
/// Utility class for Linux-specific operations and Azure Linux environment detection
/// </summary>
public static class Linux
{
/// <summary>
/// Command to install Chromium dependencies on Linux systems
/// </summary>
public static readonly string ChromiumInstallCommand = "export DEBIAN_FRONTEND=noninteractive && apt update && apt upgrade -y && apt install mc libgconf-2-4 libatk1.0-0 libatk-bridge2.0-0 libgdk-pixbuf2.0-0 libgtk-3-0 libgbm-dev libasound2 libnss3 -y";

/// <summary>
/// Sets up Linux dependencies required for Chromium operation
/// </summary>
/// <exception cref="InvalidOperationException">Thrown when dependency installation fails</exception>
public static void SetupDependencies()
{
var azureLinuxAppChromeDependencies = ChromiumInstallCommand;
Expand All @@ -31,10 +41,14 @@ public static void SetupDependencies()

if (process.ExitCode != 0)
{
throw new Exception($"Failed to execute '{ChromiumInstallCommand}'");
throw new InvalidOperationException($"Failed to execute '{ChromiumInstallCommand}'");
}
}

/// <summary>
/// Determines whether the current environment is running on Azure Linux
/// </summary>
/// <returns>True if running on Azure Linux, false otherwise</returns>
public static bool IsRunningOnAzureLinux()
{
var websiteSku = Environment.GetEnvironmentVariable("WEBSITE_SKU");
Expand Down
4 changes: 3 additions & 1 deletion OpenXmlToHtmlCli/OpenXmlToHtmlCli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="SonarAnalyzer.CSharp" Version="10.6.0.109712">
<PackageReference Include="SonarAnalyzer.CSharp" Version="10.15.0.120848">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>

<PackageReference Include="Microsoft.NET.ILLink.Tasks" Version="9.0.8" />
<ProjectReference Include="..\OpenXmlToHtml\OpenXmlToHtml.csproj" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion OpenXmlToHtmlCli/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace OpenXmlToHtmlCli
{
internal class Program
internal static class Program
{
private static async Task<int> Main(string[] args)
{
Expand Down
4 changes: 2 additions & 2 deletions OpenXmlToHtmlOpenApi/OpenXmlToHtmlOpenApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Codeuctivity.HtmlRenderer" Version="4.0.438" />
<PackageReference Include="Codeuctivity.HtmlRenderer" Version="4.0.458" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.23.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="8.1.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="9.0.6" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions OpenXmlToHtmlOpenApiTests/OpenXmlToHtmlOpenApiTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AngleSharp" Version="1.2.0" />
<PackageReference Include="AngleSharp" Version="1.3.0" />
<PackageReference Include="coverlet.collector" Version="6.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.13" />
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.2">
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
7 changes: 3 additions & 4 deletions OpenXmlToHtmlTests/OpenXmlToHtmlIntegrationTests.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using Codeuctivity.HtmlRenderer;
using Codeuctivity.OpenXmlToHtml;
using PdfSharp.Pdf.IO;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
using SkiaSharp;
using System.Collections.Generic;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -68,8 +67,8 @@ public async Task ShouldConvertDocumentAndExportImagesIntegrativeTest(string tes

private static bool IsValidBitmap(byte[] blob)
{
var image = Image.Load<Rgba32>(blob);
return image.Width > 1 && image.Height > 1;
using var image = SKBitmap.Decode(blob);
return image != null && image.Width > 1 && image.Height > 1;
}

[Fact]
Expand Down
10 changes: 5 additions & 5 deletions OpenXmlToHtmlTests/OpenXmlToHtmlTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Codeuctivity.HtmlRenderer" Version="4.0.438" />
<PackageReference Include="Codeuctivity.SkiaSharpCompare" Version="2.0.159" />
<PackageReference Include="Codeuctivity.HtmlRenderer" Version="4.0.458" />
<PackageReference Include="Codeuctivity.SkiaSharpCompare" Version="2.1.202" />
<PackageReference Include="coverlet.collector" Version="6.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="PdfSharp.netstandard" Version="1.3.2" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="10.6.0.109712">
<PackageReference Include="SonarAnalyzer.CSharp" Version="10.15.0.120848">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.2">
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
Loading