Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 5 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ on:
paths:
- .editorconfig
- src/**
- tests/**
- .github/workflows/build.yml
pull_request:
types: [ opened, reopened, synchronize, ready_for_review ]
branches: [ master ]
paths:
- .editorconfig
- src/**
- tests/**
- .github/workflows/build.yml

env:
Expand All @@ -36,10 +38,10 @@ jobs:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Build solutions
run: dotnet build .\src\WinQuickLook.slnx -c Release -p:Platform=x64
run: dotnet build .\WinQuickLook.slnx -c Release -p:Platform=x64

- name: Run test cases
run: dotnet test .\src\WinQuickLook.slnx -c Release -p:Platform=x64 --no-build
run: dotnet test .\WinQuickLook.slnx -c Release -p:Platform=x64 --no-build

- name: Lint C# code
run: dotnet format .\src\WinQuickLook.slnx --verify-no-changes --verbosity detailed --no-restore
run: dotnet format .\WinQuickLook.slnx --verify-no-changes --verbosity detailed --no-restore
File renamed without changes.
26 changes: 26 additions & 0 deletions WinQuickLook.slnx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Solution>
<Configurations>
<Platform Name="arm64" />
<Platform Name="x64" />
</Configurations>
<Folder Name="/src/">
<Project Path="src\WinQuickLook.App/WinQuickLook.App.csproj">
<Platform Solution="*|arm64" Project="arm64" />
<Platform Solution="*|x64" Project="x64" />
</Project>
<Project Path="src\WinQuickLook.Core/WinQuickLook.Core.csproj">
<Platform Solution="*|arm64" Project="arm64" />
<Platform Solution="*|x64" Project="x64" />
</Project>
<Project Path="src\WinQuickLook.CsWin32/WinQuickLook.CsWin32.csproj">
<Platform Solution="*|arm64" Project="arm64" />
<Platform Solution="*|x64" Project="x64" />
</Project>
</Folder>
<Folder Name="/tests/">
<Project Path="tests\WinQuickLook.Core.Tests/WinQuickLook.Core.Tests.csproj">
<Platform Solution="*|arm64" Project="arm64" />
<Platform Solution="*|x64" Project="x64" />
</Project>
</Folder>
</Solution>
File renamed without changes.
2 changes: 1 addition & 1 deletion src/WinQuickLook.App/WinQuickLook.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<ItemGroup>
<PackageReference Include="Hardcodet.NotifyIcon.Wpf" Version="2.0.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.3" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.5" />
</ItemGroup>

<ItemGroup>
Expand Down
26 changes: 13 additions & 13 deletions src/WinQuickLook.App/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
},
"Microsoft.Extensions.DependencyInjection": {
"type": "Direct",
"requested": "[10.0.3, )",
"resolved": "10.0.3",
"contentHash": "2DLOmC0EkB2smVK8lPP1PIKEgL1arE3CMp9XSIQB/Y7ev5nnnyuM/PizKJ6QfLD08QCYoopSC9SFdbYglDomYg==",
"requested": "[10.0.5, )",
"resolved": "10.0.5",
"contentHash": "v1SVsowG6YE1YnHVGmLWz57YTRCQRx9pH5ebIESXfm5isI9gA3QaMyg/oMTzPpXYZwSAVDzYItGJKfmV+pqXkQ==",
"dependencies": {
"Microsoft.Extensions.DependencyInjection.Abstractions": "10.0.3"
"Microsoft.Extensions.DependencyInjection.Abstractions": "10.0.5"
}
},
"AvalonEdit": {
Expand All @@ -34,21 +34,21 @@
},
"Microsoft.Extensions.DependencyInjection.Abstractions": {
"type": "Transitive",
"resolved": "10.0.3",
"contentHash": "bwGMrRcAMWx2s/RDgja97p27rxSz2pEQW0+rX5cWAUWVETVJ/eyxGfjAl8vuG5a+lckWmPIE+vcuaZNVB5YDdw=="
"resolved": "10.0.5",
"contentHash": "iVMtq9eRvzyhx8949EGT0OCYJfXi737SbRVzWXE5GrOgGj5AaZ9eUuxA/BSUfmOMALKn/g8KfFaNQw0eiB3lyA=="
},
"Microsoft.Web.WebView2": {
"type": "Transitive",
"resolved": "1.0.3800.47",
"contentHash": "vluoF9sqb72AB02yYs1UXW/2/VsxOMl2idiFJNvG993sOw3bHJvjHXmd3tqevTd9s3Md/9FgEzkOXoUl2Nb/ww=="
"resolved": "1.0.3856.49",
"contentHash": "OOBKvFgK0pUKcndvTK6/jUsbrPRwce62Wt/0hkJWDsK2AcsJ2ylOS/mLa4xAcNUTOs96YIjpPN4AHMADXJcrgQ=="
},
"winquicklook.core": {
"type": "Project",
"dependencies": {
"AvalonEdit": "[6.3.1.120, )",
"Cylinder.WPF": "[1.0.0-preview.2, )",
"Markdig": "[1.1.1, )",
"Microsoft.Web.WebView2": "[1.0.3800.47, )",
"Microsoft.Web.WebView2": "[1.0.3856.49, )",
"WinQuickLook.CsWin32": "[1.0.0, )"
}
},
Expand All @@ -59,15 +59,15 @@
"net10.0-windows10.0.26100/win-arm64": {
"Microsoft.Web.WebView2": {
"type": "Transitive",
"resolved": "1.0.3800.47",
"contentHash": "vluoF9sqb72AB02yYs1UXW/2/VsxOMl2idiFJNvG993sOw3bHJvjHXmd3tqevTd9s3Md/9FgEzkOXoUl2Nb/ww=="
"resolved": "1.0.3856.49",
"contentHash": "OOBKvFgK0pUKcndvTK6/jUsbrPRwce62Wt/0hkJWDsK2AcsJ2ylOS/mLa4xAcNUTOs96YIjpPN4AHMADXJcrgQ=="
}
},
"net10.0-windows10.0.26100/win-x64": {
"Microsoft.Web.WebView2": {
"type": "Transitive",
"resolved": "1.0.3800.47",
"contentHash": "vluoF9sqb72AB02yYs1UXW/2/VsxOMl2idiFJNvG993sOw3bHJvjHXmd3tqevTd9s3Md/9FgEzkOXoUl2Nb/ww=="
"resolved": "1.0.3856.49",
"contentHash": "OOBKvFgK0pUKcndvTK6/jUsbrPRwce62Wt/0hkJWDsK2AcsJ2ylOS/mLa4xAcNUTOs96YIjpPN4AHMADXJcrgQ=="
}
}
}
Expand Down

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion src/WinQuickLook.Core/WinQuickLook.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<PackageReference Include="AvalonEdit" Version="6.3.1.120" />
<PackageReference Include="Cylinder.WPF" Version="1.0.0-preview.2" />
<PackageReference Include="Markdig" Version="1.1.1" />
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.3800.47" />
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.3856.49" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions src/WinQuickLook.Core/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
},
"Microsoft.Web.WebView2": {
"type": "Direct",
"requested": "[1.0.3800.47, )",
"resolved": "1.0.3800.47",
"contentHash": "vluoF9sqb72AB02yYs1UXW/2/VsxOMl2idiFJNvG993sOw3bHJvjHXmd3tqevTd9s3Md/9FgEzkOXoUl2Nb/ww=="
"requested": "[1.0.3856.49, )",
"resolved": "1.0.3856.49",
"contentHash": "OOBKvFgK0pUKcndvTK6/jUsbrPRwce62Wt/0hkJWDsK2AcsJ2ylOS/mLa4xAcNUTOs96YIjpPN4AHMADXJcrgQ=="
},
"winquicklook.cswin32": {
"type": "Project"
Expand Down
22 changes: 0 additions & 22 deletions src/WinQuickLook.slnx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class SizeExtensionsTests
[InlineData(2000, 3000, 800, 1200)]
[InlineData(1280, 1024, 1200, 960)]
[InlineData(1024, 1280, 960, 1200)]
public void FitTo(int width, int height, int fitWidth, int fitHeight)
public void FitTo_SizeExceedsLimit_ReturnsScaledSize(int width, int height, int fitWidth, int fitHeight)
{
var size = new Size(width, height);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
using System;
using System.IO;

using ICSharpCode.AvalonEdit;

using WinQuickLook.Handlers;

using Xunit;

namespace WinQuickLook.Tests.Handlers;

public class CodeFilePreviewHandlerTests
{
[WpfTheory]
[InlineData("test.cs")]
[InlineData("test.ts")]
[InlineData("test.tsx")]
[InlineData("test.vue")]
[InlineData("test.cjs")]
[InlineData("test.mjs")]
public void TryCreateViewer_SupportedCodeExtension_ReturnsTrue(string fileName)
{
using var temporaryFile = TemporaryFile.Create(fileName, "const value = 1;");

var handler = new CodeFilePreviewHandler();

var actual = handler.TryCreateViewer(temporaryFile.FileInfo, out _);

Assert.True(actual);
}

[WpfTheory]
[InlineData("test.txt")]
[InlineData("test")]
public void TryCreateViewer_UnsupportedCodeExtension_ReturnsFalse(string fileName)
{
using var temporaryFile = TemporaryFile.Create(fileName, "plain text");

var handler = new CodeFilePreviewHandler();

var actual = handler.TryCreateViewer(temporaryFile.FileInfo, out var handlerResult);

Assert.False(actual);
Assert.Null(handlerResult);
}

[WpfFact]
public void TryCreateViewer_SupportedCodeFile_ReturnsTextEditorWithSyntaxHighlighting()
{
using var temporaryFile = TemporaryFile.Create("test.ts", "const value = 1;");

var handler = new CodeFilePreviewHandler();

var actual = handler.TryCreateViewer(temporaryFile.FileInfo, out var handlerResult);

Assert.True(actual);
Assert.NotNull(handlerResult);

var textEditor = Assert.IsType<TextEditor>(handlerResult.Content);
Assert.NotNull(textEditor.SyntaxHighlighting);
}

private sealed class TemporaryFile : IDisposable
{
private TemporaryFile(string path)
{
Path = path;
FileInfo = new FileInfo(path);
}

public string Path { get; }

public FileInfo FileInfo { get; }

public static TemporaryFile Create(string fileName, string content)
{
var directoryPath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), Guid.NewGuid().ToString("N"));

Directory.CreateDirectory(directoryPath);

var path = System.IO.Path.Combine(directoryPath, fileName);

File.WriteAllText(path, content);

return new TemporaryFile(path);
}

public void Dispose()
{
if (Directory.Exists(System.IO.Path.GetDirectoryName(Path)))
{
Directory.Delete(System.IO.Path.GetDirectoryName(Path)!, true);
}
}
}
}
Loading
Loading