Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bumped puppeteer.sharp to 11.0.3 #70

Merged
merged 14 commits into from
Aug 30, 2023
Merged
2 changes: 1 addition & 1 deletion .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
- uses: actions/setup-node@v3.7.0
- uses: actions/setup-node@v3.8.1
with:
node-version: 18
- name: Restore dependencies
Expand Down
6 changes: 4 additions & 2 deletions Codeuctivity.HtmlRenderer/Codeuctivity.HtmlRenderer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
<AssemblyName>Codeuctivity.HtmlRenderer</AssemblyName>
<RootNamespace>Codeuctivity.HtmlRenderer</RootNamespace>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
<AnalysisLevel>latest</AnalysisLevel>
<ContinuousIntegrationBuild Condition="'$(GITHUB_ACTIONS)' == 'true'">true</ContinuousIntegrationBuild>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<AssemblyOriginatorKeyFile>Codeuctivity.HtmlRenderer.snk</AssemblyOriginatorKeyFile>
Expand All @@ -39,8 +41,8 @@

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="all" />
<PackageReference Include="PuppeteerSharp" Version="10.1.2" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.55.0.65544">
<PackageReference Include="PuppeteerSharp" Version="11.0.3" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.8.0.76515">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
43 changes: 26 additions & 17 deletions Codeuctivity.HtmlRenderer/Renderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
{
if (customChromiumArgs == null)
{
LaunchOptions = SystemSpecificConfig();
LaunchOptions = Renderer.SystemSpecificConfig();
}
else
{
Expand All @@ -36,7 +36,7 @@
{
if (launchOptions == null)
{
LaunchOptions = SystemSpecificConfig();
LaunchOptions = Renderer.SystemSpecificConfig();
}
else
{
Expand All @@ -61,7 +61,7 @@
public static Task<Renderer> CreateAsync()
{
var html2Pdf = new Renderer();
return html2Pdf.InitializeAsync(new BrowserFetcher());

Check warning on line 64 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Use recommended dispose pattern to ensure that object created by 'new BrowserFetcher()' is disposed on all paths. If possible, wrap the creation within a 'using' statement or a 'using' declaration. Otherwise, use a try-finally pattern, with a dedicated local variable declared before the try region and an unconditional Dispose invocation on non-null value in the 'finally' region, say 'x?.Dispose()'. If the object is explicitly disposed within the try region or the dispose ownership is transfered to another object or method, assign 'null' to the local variable just after such an operation to prevent double dispose in 'finally'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2000)

Check warning on line 64 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Use recommended dispose pattern to ensure that object created by 'new BrowserFetcher()' is disposed on all paths. If possible, wrap the creation within a 'using' statement or a 'using' declaration. Otherwise, use a try-finally pattern, with a dedicated local variable declared before the try region and an unconditional Dispose invocation on non-null value in the 'finally' region, say 'x?.Dispose()'. If the object is explicitly disposed within the try region or the dispose ownership is transfered to another object or method, assign 'null' to the local variable just after such an operation to prevent double dispose in 'finally'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2000)

Check warning on line 64 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Use recommended dispose pattern to ensure that object created by 'new BrowserFetcher()' is disposed on all paths. If possible, wrap the creation within a 'using' statement or a 'using' declaration. Otherwise, use a try-finally pattern, with a dedicated local variable declared before the try region and an unconditional Dispose invocation on non-null value in the 'finally' region, say 'x?.Dispose()'. If the object is explicitly disposed within the try region or the dispose ownership is transfered to another object or method, assign 'null' to the local variable just after such an operation to prevent double dispose in 'finally'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2000)

Check warning on line 64 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Use recommended dispose pattern to ensure that object created by 'new BrowserFetcher()' is disposed on all paths. If possible, wrap the creation within a 'using' statement or a 'using' declaration. Otherwise, use a try-finally pattern, with a dedicated local variable declared before the try region and an unconditional Dispose invocation on non-null value in the 'finally' region, say 'x?.Dispose()'. If the object is explicitly disposed within the try region or the dispose ownership is transfered to another object or method, assign 'null' to the local variable just after such an operation to prevent double dispose in 'finally'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2000)

Check warning on line 64 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Use recommended dispose pattern to ensure that object created by 'new BrowserFetcher()' is disposed on all paths. If possible, wrap the creation within a 'using' statement or a 'using' declaration. Otherwise, use a try-finally pattern, with a dedicated local variable declared before the try region and an unconditional Dispose invocation on non-null value in the 'finally' region, say 'x?.Dispose()'. If the object is explicitly disposed within the try region or the dispose ownership is transfered to another object or method, assign 'null' to the local variable just after such an operation to prevent double dispose in 'finally'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2000)

Check warning on line 64 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Use recommended dispose pattern to ensure that object created by 'new BrowserFetcher()' is disposed on all paths. If possible, wrap the creation within a 'using' statement or a 'using' declaration. Otherwise, use a try-finally pattern, with a dedicated local variable declared before the try region and an unconditional Dispose invocation on non-null value in the 'finally' region, say 'x?.Dispose()'. If the object is explicitly disposed within the try region or the dispose ownership is transfered to another object or method, assign 'null' to the local variable just after such an operation to prevent double dispose in 'finally'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2000)

Check warning on line 64 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Use recommended dispose pattern to ensure that object created by 'new BrowserFetcher()' is disposed on all paths. If possible, wrap the creation within a 'using' statement or a 'using' declaration. Otherwise, use a try-finally pattern, with a dedicated local variable declared before the try region and an unconditional Dispose invocation on non-null value in the 'finally' region, say 'x?.Dispose()'. If the object is explicitly disposed within the try region or the dispose ownership is transfered to another object or method, assign 'null' to the local variable just after such an operation to prevent double dispose in 'finally'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2000)

Check warning on line 64 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Use recommended dispose pattern to ensure that object created by 'new BrowserFetcher()' is disposed on all paths. If possible, wrap the creation within a 'using' statement or a 'using' declaration. Otherwise, use a try-finally pattern, with a dedicated local variable declared before the try region and an unconditional Dispose invocation on non-null value in the 'finally' region, say 'x?.Dispose()'. If the object is explicitly disposed within the try region or the dispose ownership is transfered to another object or method, assign 'null' to the local variable just after such an operation to prevent double dispose in 'finally'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2000)

Check warning on line 64 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Use recommended dispose pattern to ensure that object created by 'new BrowserFetcher()' is disposed on all paths. If possible, wrap the creation within a 'using' statement or a 'using' declaration. Otherwise, use a try-finally pattern, with a dedicated local variable declared before the try region and an unconditional Dispose invocation on non-null value in the 'finally' region, say 'x?.Dispose()'. If the object is explicitly disposed within the try region or the dispose ownership is transfered to another object or method, assign 'null' to the local variable just after such an operation to prevent double dispose in 'finally'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2000)

Check warning on line 64 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Use recommended dispose pattern to ensure that object created by 'new BrowserFetcher()' is disposed on all paths. If possible, wrap the creation within a 'using' statement or a 'using' declaration. Otherwise, use a try-finally pattern, with a dedicated local variable declared before the try region and an unconditional Dispose invocation on non-null value in the 'finally' region, say 'x?.Dispose()'. If the object is explicitly disposed within the try region or the dispose ownership is transfered to another object or method, assign 'null' to the local variable just after such an operation to prevent double dispose in 'finally'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2000)

Check warning on line 64 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / deployTest

Use recommended dispose pattern to ensure that object created by 'new BrowserFetcher()' is disposed on all paths. If possible, wrap the creation within a 'using' statement or a 'using' declaration. Otherwise, use a try-finally pattern, with a dedicated local variable declared before the try region and an unconditional Dispose invocation on non-null value in the 'finally' region, say 'x?.Dispose()'. If the object is explicitly disposed within the try region or the dispose ownership is transfered to another object or method, assign 'null' to the local variable just after such an operation to prevent double dispose in 'finally'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2000)

Check warning on line 64 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / deployTest

Use recommended dispose pattern to ensure that object created by 'new BrowserFetcher()' is disposed on all paths. If possible, wrap the creation within a 'using' statement or a 'using' declaration. Otherwise, use a try-finally pattern, with a dedicated local variable declared before the try region and an unconditional Dispose invocation on non-null value in the 'finally' region, say 'x?.Dispose()'. If the object is explicitly disposed within the try region or the dispose ownership is transfered to another object or method, assign 'null' to the local variable just after such an operation to prevent double dispose in 'finally'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2000)

Check warning on line 64 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Use recommended dispose pattern to ensure that object created by 'new BrowserFetcher()' is disposed on all paths. If possible, wrap the creation within a 'using' statement or a 'using' declaration. Otherwise, use a try-finally pattern, with a dedicated local variable declared before the try region and an unconditional Dispose invocation on non-null value in the 'finally' region, say 'x?.Dispose()'. If the object is explicitly disposed within the try region or the dispose ownership is transfered to another object or method, assign 'null' to the local variable just after such an operation to prevent double dispose in 'finally'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2000)

Check warning on line 64 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Use recommended dispose pattern to ensure that object created by 'new BrowserFetcher()' is disposed on all paths. If possible, wrap the creation within a 'using' statement or a 'using' declaration. Otherwise, use a try-finally pattern, with a dedicated local variable declared before the try region and an unconditional Dispose invocation on non-null value in the 'finally' region, say 'x?.Dispose()'. If the object is explicitly disposed within the try region or the dispose ownership is transfered to another object or method, assign 'null' to the local variable just after such an operation to prevent double dispose in 'finally'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2000)
}

/// <summary>
Expand Down Expand Up @@ -89,15 +89,26 @@

private async Task<Renderer> InitializeAsync(BrowserFetcher browserFetcher)
{
BrowserFetcher = browserFetcher;
BrowserFetcher.DownloadProgressChanged += DownloadProgressChanged;
var revisionInfo = await BrowserFetcher.DownloadAsync(BrowserFetcher.DefaultChromiumRevision ?? string.Empty).ConfigureAwait(false);
LaunchOptions.ExecutablePath = revisionInfo.ExecutablePath;
Browser = await Puppeteer.LaunchAsync(LaunchOptions).ConfigureAwait(false);
// for macsome reason the download progress is not called on macos
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
using var browserFetcher1 = new BrowserFetcher();
await browserFetcher1.DownloadAsync();

Check warning on line 96 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 96 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 96 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 96 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 96 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 96 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 96 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 96 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 96 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 96 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 96 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / deployTest

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 96 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / deployTest

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 96 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 96 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)
Browser = await Puppeteer.LaunchAsync(new LaunchOptions { Headless = true });

Check warning on line 97 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 97 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 97 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 97 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 97 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 97 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 97 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 97 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 97 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 97 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 97 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / deployTest

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 97 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / deployTest

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 97 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 97 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)
}
else
{
BrowserFetcher = browserFetcher;
BrowserFetcher.DownloadProgressChanged += DownloadProgressChanged;
var revisionInfo = await BrowserFetcher.DownloadAsync(PuppeteerSharp.BrowserData.Chrome.DefaultBuildId).ConfigureAwait(false);
LaunchOptions.ExecutablePath = revisionInfo.GetExecutablePath();
Browser = await Puppeteer.LaunchAsync(LaunchOptions).ConfigureAwait(false);
}

return this;
}

private LaunchOptions SystemSpecificConfig()
private static LaunchOptions SystemSpecificConfig()
{
if (IsRunningOnWslOrAzure() || IsRunningOnAzureLinux())
{
Expand All @@ -115,7 +126,7 @@
return false;
}

return RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && websiteSku.IndexOf("Linux", StringComparison.OrdinalIgnoreCase) >= 0;

Check warning on line 129 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Use 'string.Contains' instead of 'string.IndexOf' to improve readability (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2249)

Check warning on line 129 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Use 'string.Contains' instead of 'string.IndexOf' to improve readability (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2249)

Check warning on line 129 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Use 'string.Contains' instead of 'string.IndexOf' to improve readability (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2249)

Check warning on line 129 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Use 'string.Contains' instead of 'string.IndexOf' to improve readability (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2249)

Check warning on line 129 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Use 'string.Contains' instead of 'string.IndexOf' to improve readability (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2249)

Check warning on line 129 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / deployTest

Use 'string.Contains' instead of 'string.IndexOf' to improve readability (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2249)

Check warning on line 129 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Use 'string.Contains' instead of 'string.IndexOf' to improve readability (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2249)
}

private static bool IsRunningOnWslOrAzure()
Expand All @@ -126,8 +137,8 @@
}

var version = File.ReadAllText("/proc/version");
var IsWsl = version.IndexOf("Microsoft", StringComparison.OrdinalIgnoreCase) >= 0;
var IsAzure = version.IndexOf("azure", StringComparison.OrdinalIgnoreCase) >= 0;
var IsWsl = version?.IndexOf("Microsoft", StringComparison.OrdinalIgnoreCase) >= 0;
var IsAzure = version?.IndexOf("azure", StringComparison.OrdinalIgnoreCase) >= 0;

return IsWsl || IsAzure;
}
Expand Down Expand Up @@ -157,10 +168,10 @@
}

var absolutePath = Path.GetFullPath(sourceHtmlFilePath);
await using var page = (await Browser.NewPageAsync().ConfigureAwait(false));
await using var page = await Browser.NewPageAsync().ConfigureAwait(false);

Check warning on line 171 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 171 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 171 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 171 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 171 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 171 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / deployTest

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 171 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)
await page.GoToAsync($"file://{absolutePath}").ConfigureAwait(false);
// Wait for fonts to be loaded. Omitting this might result in no text rendered in PDF.
await page.EvaluateExpressionHandleAsync("document.fonts.ready");
await page.EvaluateExpressionHandleAsync("document.fonts.ready").ConfigureAwait(false);
await page.PdfAsync(destinationPdfFilePath, pdfOptions).ConfigureAwait(false);
}

Expand Down Expand Up @@ -188,10 +199,10 @@
}

var absolutePath = Path.GetFullPath(sourceHtmlFilePath);
await using var page = (await Browser.NewPageAsync().ConfigureAwait(false));
await using var page = await Browser.NewPageAsync().ConfigureAwait(false);

Check warning on line 202 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 202 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 202 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 202 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 202 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 202 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / deployTest

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 202 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)
await page.GoToAsync($"file://{absolutePath}").ConfigureAwait(false);
// Wait for fonts to be loaded. Omitting this might result in no text the screenshot.
await page.EvaluateExpressionHandleAsync("document.fonts.ready");
await page.EvaluateExpressionHandleAsync("document.fonts.ready").ConfigureAwait(false);
await page.ScreenshotAsync(destinationPngFilePath, screenshotOptions).ConfigureAwait(false);
}

Expand All @@ -211,10 +222,10 @@
/// <param name="screenshotOptions"></param>
public async Task<byte[]> ConvertHtmlStringToPngData(string sourceHtmlData, ScreenshotOptions screenshotOptions)
{
await using var page = await Browser.NewPageAsync().ConfigureAwait(false);

Check warning on line 225 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 225 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 225 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 225 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 225 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 225 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / deployTest

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 225 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)
await page.SetContentAsync(sourceHtmlData).ConfigureAwait(false);
// Wait for fonts to be loaded. Omitting this might result in no text the screenshot.
await page.EvaluateExpressionHandleAsync("document.fonts.ready");
await page.EvaluateExpressionHandleAsync("document.fonts.ready").ConfigureAwait(false);
return await page.ScreenshotDataAsync(screenshotOptions).ConfigureAwait(false);
}

Expand Down Expand Up @@ -243,9 +254,7 @@
await DisposeAsyncCore().ConfigureAwait(false);

Dispose(disposing: false);
#pragma warning disable CA1816 // Dispose methods should call SuppressFinalize
GC.SuppressFinalize(this);
#pragma warning restore CA1816 // Dispose methods should call SuppressFinalize
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0</TargetFrameworks>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
<AnalysisLevel>latest</AnalysisLevel>
<RootNamespace>Codeuctivity.HtmlRendererCli</RootNamespace>
<DebugSymbols>true</DebugSymbols>
<DebugType>embedded</DebugType>
Expand Down
22 changes: 10 additions & 12 deletions Codeuctivity.HtmlRendererCli/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@

namespace Codeuctivity.HtmlRendererCli
{
public class Program
public static class Program
{
public static readonly Assembly Reference = typeof(Renderer).Assembly;
public static readonly Version Version = Reference.GetName().Version;
private static int _lastProgressValue;

public static async Task<int> Main(string[] args)
{
if (args.Length != 2)
if (args?.Length != 2)
{
Console.WriteLine("Usage: PuppeteerSharp.RendererCli <sourceHtmlFilePath> <destinatioPdfFilePath>");

Check warning on line 20 in Codeuctivity.HtmlRendererCli/Program.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Method 'Task<int> Program.Main(string[] args)' passes a literal string as parameter 'value' of a call to 'void Console.WriteLine(string? value)'. Retrieve the following string(s) from a resource table instead: "Usage: PuppeteerSharp.RendererCli <sourceHtmlFilePath> <destinatioPdfFilePath>". (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1303)

Check warning on line 20 in Codeuctivity.HtmlRendererCli/Program.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Method 'Task<int> Program.Main(string[] args)' passes a literal string as parameter 'value' of a call to 'void Console.WriteLine(string? value)'. Retrieve the following string(s) from a resource table instead: "Usage: PuppeteerSharp.RendererCli <sourceHtmlFilePath> <destinatioPdfFilePath>". (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1303)

Check warning on line 20 in Codeuctivity.HtmlRendererCli/Program.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Method 'Task<int> Program.Main(string[] args)' passes a literal string as parameter 'value' of a call to 'void Console.WriteLine(string? value)'. Retrieve the following string(s) from a resource table instead: "Usage: PuppeteerSharp.RendererCli <sourceHtmlFilePath> <destinatioPdfFilePath>". (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1303)

Check warning on line 20 in Codeuctivity.HtmlRendererCli/Program.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Method 'Task<int> Program.Main(string[] args)' passes a literal string as parameter 'value' of a call to 'void Console.WriteLine(string? value)'. Retrieve the following string(s) from a resource table instead: "Usage: PuppeteerSharp.RendererCli <sourceHtmlFilePath> <destinatioPdfFilePath>". (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1303)

Check warning on line 20 in Codeuctivity.HtmlRendererCli/Program.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Method 'Task<int> Program.Main(string[] args)' passes a literal string as parameter 'value' of a call to 'void Console.WriteLine(string? value)'. Retrieve the following string(s) from a resource table instead: "Usage: PuppeteerSharp.RendererCli <sourceHtmlFilePath> <destinatioPdfFilePath>". (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1303)

Check warning on line 20 in Codeuctivity.HtmlRendererCli/Program.cs

View workflow job for this annotation

GitHub Actions / deployTest

Method 'Task<int> Program.Main(string[] args)' passes a literal string as parameter 'value' of a call to 'void Console.WriteLine(string? value)'. Retrieve the following string(s) from a resource table instead: "Usage: PuppeteerSharp.RendererCli <sourceHtmlFilePath> <destinatioPdfFilePath>". (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1303)

Check warning on line 20 in Codeuctivity.HtmlRendererCli/Program.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Method 'Task<int> Program.Main(string[] args)' passes a literal string as parameter 'value' of a call to 'void Console.WriteLine(string? value)'. Retrieve the following string(s) from a resource table instead: "Usage: PuppeteerSharp.RendererCli <sourceHtmlFilePath> <destinatioPdfFilePath>". (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1303)
return 1;
}

var inputPathDocx = args[0];
var inputPathDocX = args[0];
var outputPathHtml = args[1];

if (!File.Exists(inputPathDocx))
if (!File.Exists(inputPathDocX))
{
Console.WriteLine($"Could not find source {inputPathDocx}.");
Console.WriteLine($"Could not find source {inputPathDocX}.");
return 1;
}

Expand All @@ -36,14 +36,12 @@
return 1;
}

Console.WriteLine($"Converting {inputPathDocx} to {outputPathHtml} using PuppeteerSharp.Renderer {Version}");
BrowserFetcherOptions options = new BrowserFetcherOptions();
options.Path = Path.GetTempPath();
var browserFetcher = new BrowserFetcher(options);
Console.WriteLine($"Fetching chromium from web, to {browserFetcher.DownloadsFolder} .... ");
Console.WriteLine($"Converting {inputPathDocX} to {outputPathHtml} using PuppeteerSharp.Renderer {Version}");
using var browserFetcher = new BrowserFetcher();
Console.WriteLine($"Fetching chromium from web, to {browserFetcher.CacheDir} .... ");
browserFetcher.DownloadProgressChanged += BrowserFetcher_DownloadProgressChanged;
await using var chromiumRenderer = await Renderer.CreateAsync(browserFetcher, string.Empty);
await chromiumRenderer.ConvertHtmlToPdf(inputPathDocx, outputPathHtml);
await using var chromiumRenderer = await Renderer.CreateAsync(browserFetcher);

Check warning on line 43 in Codeuctivity.HtmlRendererCli/Program.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 43 in Codeuctivity.HtmlRendererCli/Program.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 43 in Codeuctivity.HtmlRendererCli/Program.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 43 in Codeuctivity.HtmlRendererCli/Program.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 43 in Codeuctivity.HtmlRendererCli/Program.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 43 in Codeuctivity.HtmlRendererCli/Program.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 43 in Codeuctivity.HtmlRendererCli/Program.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 43 in Codeuctivity.HtmlRendererCli/Program.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 43 in Codeuctivity.HtmlRendererCli/Program.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 43 in Codeuctivity.HtmlRendererCli/Program.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 43 in Codeuctivity.HtmlRendererCli/Program.cs

View workflow job for this annotation

GitHub Actions / deployTest

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 43 in Codeuctivity.HtmlRendererCli/Program.cs

View workflow job for this annotation

GitHub Actions / deployTest

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 43 in Codeuctivity.HtmlRendererCli/Program.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 43 in Codeuctivity.HtmlRendererCli/Program.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)
await chromiumRenderer.ConvertHtmlToPdf(inputPathDocX, outputPathHtml);

Check warning on line 44 in Codeuctivity.HtmlRendererCli/Program.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 44 in Codeuctivity.HtmlRendererCli/Program.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 44 in Codeuctivity.HtmlRendererCli/Program.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 44 in Codeuctivity.HtmlRendererCli/Program.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 44 in Codeuctivity.HtmlRendererCli/Program.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 44 in Codeuctivity.HtmlRendererCli/Program.cs

View workflow job for this annotation

GitHub Actions / deployTest

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 44 in Codeuctivity.HtmlRendererCli/Program.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)
return 0;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.55.0.65544">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.8.0.76515">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="xunit" Version="2.5.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

namespace Codeuctivity.HtmlRendererCliTests
{
internal class FactRunableOnWindowsAttribute : FactAttribute
internal class FactRunnableOnWindowsAttribute : FactAttribute
{
public FactRunableOnWindowsAttribute()
public FactRunnableOnWindowsAttribute()
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
Expand Down
10 changes: 5 additions & 5 deletions Codeuctivity.HtmlRendererCliTests/RendererCliTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public void VersionShouldBeProcessed()
[Fact]
public async Task ConversionShouldWork()
{
var testFileName = "BasicTextFormated.html";
var testFileName = "BasicTextFormatted.html";
var sourceHtmlFilePath = $"../../../TestInput/{testFileName}";
var actualFilePath = Path.Combine(Path.GetTempPath(), $"Actual{testFileName}.pdf");

Expand All @@ -28,10 +28,10 @@ public async Task ConversionShouldWork()
Assert.True(File.Exists(actualFilePath));
}

[FactRunableOnWindows]
[FactRunnableOnWindows]
public void PublishedSelfContainedBinaryShouldWork()
{
var testFileName = "BasicTextFormated.html";
var testFileName = "BasicTextFormatted.html";
var sourceHtmlFilePath = Path.GetFullPath($"../../../TestInput/{testFileName}");
var actualFilePath = Path.Combine(Path.GetTempPath(), $"Actual{testFileName}.pdf");

Expand All @@ -40,13 +40,13 @@ public void PublishedSelfContainedBinaryShouldWork()
File.Delete(actualFilePath);
}

var acutualWindowsBinary = DotnetPublishFolderProfileWindows("Codeuctivity.HtmlRendererCli");
var actualWindowsBinary = DotnetPublishFolderProfileWindows("Codeuctivity.HtmlRendererCli");

using var process = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = acutualWindowsBinary,
FileName = actualWindowsBinary,
Arguments = $" {sourceHtmlFilePath} {actualFilePath}",
RedirectStandardOutput = true,
RedirectStandardError = true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0;net6.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<LangVersion>9.0</LangVersion>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
</PropertyGroup>
<PropertyGroup>
<TargetFrameworks>net7.0;net6.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<LangVersion>9.0</LangVersion>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
</PropertyGroup>

<ItemGroup>
<Compile Remove="SourceTestFiles\**" />
<EmbeddedResource Remove="SourceTestFiles\**" />
<None Remove="SourceTestFiles\**" />
</ItemGroup>
<ItemGroup>
<Compile Remove="SourceTestFiles\**" />
<EmbeddedResource Remove="SourceTestFiles\**" />
<None Remove="SourceTestFiles\**" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Codeuctivity.ImageSharpCompare" Version="2.0.155" />
<PackageReference Include="Codeuctivity.PdfjsSharp" Version="1.2.95" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.55.0.65544">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Codeuctivity.ImageSharpCompare" Version="2.0.182" />
<PackageReference Include="Codeuctivity.PdfjsSharp" Version="1.2.95" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.8.0.76515">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="xunit" Version="2.5.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Codeuctivity.HtmlRenderer\Codeuctivity.HtmlRenderer.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Codeuctivity.HtmlRenderer\Codeuctivity.HtmlRenderer.csproj" />
</ItemGroup>
</Project>
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ private static void CopyToTestOutput(string testOutputFile)
}

if (!Directory.Exists(TestOutputFirectory))
{
Directory.CreateDirectory(TestOutputFirectory);
}

File.Copy(testOutputFile, Path.Combine(TestOutputFirectory, Path.GetFileName(testOutputFile)), true);
}
Expand Down
Loading
Loading