mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 02:36:19 +02:00
Self-contained .NET (#22217)
* dotnet sc
* MD preview - C# app
- working self-contained
* Gcode preview - C# app
* DevFiles preview - C# app
* Fix passing path with spaces as cmd arg and monacocpp proj file
* Pdf preview - C# app
* Svg preview - C# app
* Fix comment
* Gcode thumbnail - C# app
TODO:
- installer
- why IThumbnailProvider and IIntializeWithFile doesn't work?
* Pdf thumbnail - C# app
TODO:
- installer
- why IThumbnailProvider and IIntializeWithFile doesn't work?
* Pdf thumbnail - C# app
TODO:
- installer
- why IThumbnailProvider and IIntializeWithFile doesn't work?
* Fix GcodeThumbnailProviderCpp.vcxproj
* Svg thumbnail - C# app
TODO:
- installer
- why IThumbnailProvider and IIntializeWithFile doesn't work?
* Fix Svg tests
* Thumbnail providers - installer
* Self-contained Hosts and FileLocksmith
* Fix hardcoded <RuntimeIdentifier>
* Remove unneeded files
* Try to fix Nuget in PR CI
* Prefix new dlls with PowerToys.
Sign new dlls and exes
* Add new .exe files to ProcessList
* ci: debug by listing all env vars
* ci: try setting variable in the right ci file
* Bring back hardcoded RuntimeIdentifier
* ci: Add comment and remove debug action
* Remove unneeded lib
* [WIP] Platform conditional dotnet files & hardlinks
* Cleanup
* Update expect.txt
* Test fix - ARM installer
* Fix uninstall bug
* Update docs
* Fix failing test
* Add dll details
* Minor cleanup
* Improve resizing
* Add some logs
* Test fix - release build
* Remove InvokeOnControlThread
* Test fix: logger initialization
* Fix arm64 installer
Co-authored-by: Jaime Bernardo <jaime@janeasystems.com>
Co-authored-by: Dustin L. Howett <dustin@howett.net>
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
|
||||
<circle cx="50" cy="50" r="50">
|
||||
</circle>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 119 B |
@@ -0,0 +1,12 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
|
||||
<meta http-equiv="Content-Type" content="text/html" charset="utf-8">
|
||||
</head>
|
||||
<body>
|
||||
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
|
||||
<circle cx="50" cy="50" r="50">
|
||||
</circle>
|
||||
</svg>
|
||||
</body>
|
||||
</html>
|
||||
@@ -27,7 +27,7 @@ namespace SvgThumbnailProviderUnitTests
|
||||
svgBuilder.AppendLine("\t</circle>");
|
||||
svgBuilder.AppendLine("</svg>");
|
||||
|
||||
SvgThumbnailProvider svgThumbnailProvider = new SvgThumbnailProvider();
|
||||
SvgThumbnailProvider svgThumbnailProvider = new SvgThumbnailProvider(null);
|
||||
Bitmap thumbnail = svgThumbnailProvider.GetThumbnail(svgBuilder.ToString(), 256);
|
||||
|
||||
Assert.IsNotNull(thumbnail);
|
||||
@@ -45,7 +45,7 @@ namespace SvgThumbnailProviderUnitTests
|
||||
svgBuilder.AppendLine("\t</circle>");
|
||||
svgBuilder.AppendLine("</svg>");
|
||||
|
||||
SvgThumbnailProvider svgThumbnailProvider = new SvgThumbnailProvider();
|
||||
SvgThumbnailProvider svgThumbnailProvider = new SvgThumbnailProvider(null);
|
||||
Bitmap thumbnail = svgThumbnailProvider.GetThumbnail(svgBuilder.ToString(), 256);
|
||||
Assert.IsTrue(thumbnail != null);
|
||||
}
|
||||
@@ -56,7 +56,7 @@ namespace SvgThumbnailProviderUnitTests
|
||||
var svgBuilder = new StringBuilder();
|
||||
svgBuilder.AppendLine("<p>foo</p>");
|
||||
|
||||
SvgThumbnailProvider svgThumbnailProvider = new SvgThumbnailProvider();
|
||||
SvgThumbnailProvider svgThumbnailProvider = new SvgThumbnailProvider(null);
|
||||
Bitmap thumbnail = svgThumbnailProvider.GetThumbnail(svgBuilder.ToString(), 256);
|
||||
Assert.IsTrue(thumbnail == null);
|
||||
}
|
||||
@@ -64,7 +64,7 @@ namespace SvgThumbnailProviderUnitTests
|
||||
[TestMethod]
|
||||
public void CheckNoSvgEmptyStringShouldReturnNullBitmap()
|
||||
{
|
||||
SvgThumbnailProvider svgThumbnailProvider = new SvgThumbnailProvider();
|
||||
SvgThumbnailProvider svgThumbnailProvider = new SvgThumbnailProvider(null);
|
||||
Bitmap thumbnail = svgThumbnailProvider.GetThumbnail(string.Empty, 256);
|
||||
Assert.IsTrue(thumbnail == null);
|
||||
}
|
||||
@@ -72,7 +72,7 @@ namespace SvgThumbnailProviderUnitTests
|
||||
[TestMethod]
|
||||
public void CheckNoSvgNullStringShouldReturnNullBitmap()
|
||||
{
|
||||
SvgThumbnailProvider svgThumbnailProvider = new SvgThumbnailProvider();
|
||||
SvgThumbnailProvider svgThumbnailProvider = new SvgThumbnailProvider(null);
|
||||
Bitmap thumbnail = svgThumbnailProvider.GetThumbnail(null, 256);
|
||||
Assert.IsTrue(thumbnail == null);
|
||||
}
|
||||
@@ -81,7 +81,7 @@ namespace SvgThumbnailProviderUnitTests
|
||||
public void CheckZeroSizedThumbnailShouldReturnNullBitmap()
|
||||
{
|
||||
string content = "<svg></svg>";
|
||||
SvgThumbnailProvider svgThumbnailProvider = new SvgThumbnailProvider();
|
||||
SvgThumbnailProvider svgThumbnailProvider = new SvgThumbnailProvider(null);
|
||||
Bitmap thumbnail = svgThumbnailProvider.GetThumbnail(content, 0);
|
||||
Assert.IsTrue(thumbnail == null);
|
||||
}
|
||||
@@ -103,7 +103,7 @@ namespace SvgThumbnailProviderUnitTests
|
||||
svgBuilder.AppendLine("</body>");
|
||||
svgBuilder.AppendLine("</html>");
|
||||
|
||||
SvgThumbnailProvider svgThumbnailProvider = new SvgThumbnailProvider();
|
||||
SvgThumbnailProvider svgThumbnailProvider = new SvgThumbnailProvider(null);
|
||||
Bitmap thumbnail = svgThumbnailProvider.GetThumbnail(svgBuilder.ToString(), 256);
|
||||
Assert.IsTrue(thumbnail != null);
|
||||
}
|
||||
@@ -111,77 +111,25 @@ namespace SvgThumbnailProviderUnitTests
|
||||
[TestMethod]
|
||||
public void GetThumbnailValidStreamSVG()
|
||||
{
|
||||
var svgBuilder = new StringBuilder();
|
||||
svgBuilder.AppendLine("<svg viewBox=\"0 0 100 100\" xmlns=\"http://www.w3.org/2000/svg\">");
|
||||
svgBuilder.AppendLine("<circle cx=\"50\" cy=\"50\" r=\"50\">");
|
||||
svgBuilder.AppendLine("</circle>");
|
||||
svgBuilder.AppendLine("</svg>");
|
||||
var filePath = "HelperFiles/file1.svg";
|
||||
|
||||
SvgThumbnailProvider provider = new SvgThumbnailProvider();
|
||||
SvgThumbnailProvider svgThumbnailProvider = new SvgThumbnailProvider(filePath);
|
||||
|
||||
provider.Initialize(GetMockStream(svgBuilder.ToString()), 0);
|
||||
Bitmap bitmap = svgThumbnailProvider.GetThumbnail(256);
|
||||
|
||||
IntPtr bitmap;
|
||||
WTS_ALPHATYPE alphaType;
|
||||
provider.GetThumbnail(256, out bitmap, out alphaType);
|
||||
|
||||
Assert.IsTrue(bitmap != IntPtr.Zero);
|
||||
Assert.IsTrue(alphaType == WTS_ALPHATYPE.WTSAT_RGB);
|
||||
Assert.IsTrue(bitmap != null);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetThumbnailValidStreamHTML()
|
||||
{
|
||||
var svgBuilder = new StringBuilder();
|
||||
svgBuilder.AppendLine("<html>");
|
||||
svgBuilder.AppendLine("<head>");
|
||||
svgBuilder.AppendLine("<meta http-equiv=\"X-UA-Compatible\" content=\"IE=Edge\">");
|
||||
svgBuilder.AppendLine("<meta http-equiv=\"Content-Type\" content=\"text/html\" charset=\"utf-8\">");
|
||||
svgBuilder.AppendLine("</head>");
|
||||
svgBuilder.AppendLine("<body>");
|
||||
svgBuilder.AppendLine("<svg viewBox=\"0 0 100 100\" xmlns=\"http://www.w3.org/2000/svg\">");
|
||||
svgBuilder.AppendLine("<circle cx=\"50\" cy=\"50\" r=\"50\">");
|
||||
svgBuilder.AppendLine("</circle>");
|
||||
svgBuilder.AppendLine("</svg>");
|
||||
svgBuilder.AppendLine("</body>");
|
||||
svgBuilder.AppendLine("</html>");
|
||||
var filePath = "HelperFiles/file2.svg";
|
||||
|
||||
SvgThumbnailProvider provider = new SvgThumbnailProvider();
|
||||
SvgThumbnailProvider svgThumbnailProvider = new SvgThumbnailProvider(filePath);
|
||||
|
||||
provider.Initialize(GetMockStream(svgBuilder.ToString()), 0);
|
||||
Bitmap bitmap = svgThumbnailProvider.GetThumbnail(256);
|
||||
|
||||
IntPtr bitmap;
|
||||
WTS_ALPHATYPE alphaType;
|
||||
provider.GetThumbnail(256, out bitmap, out alphaType);
|
||||
|
||||
Assert.IsTrue(bitmap != IntPtr.Zero);
|
||||
Assert.IsTrue(alphaType == WTS_ALPHATYPE.WTSAT_RGB);
|
||||
}
|
||||
|
||||
private static IStream GetMockStream(string streamData)
|
||||
{
|
||||
var mockStream = new Mock<IStream>();
|
||||
var streamBytes = Encoding.UTF8.GetBytes(streamData);
|
||||
|
||||
var streamMock = new Mock<IStream>();
|
||||
var firstCall = true;
|
||||
streamMock
|
||||
.Setup(x => x.Read(It.IsAny<byte[]>(), It.IsAny<int>(), It.IsAny<IntPtr>()))
|
||||
.Callback<byte[], int, IntPtr>((buffer, countToRead, bytesReadPtr) =>
|
||||
{
|
||||
if (firstCall)
|
||||
{
|
||||
Array.Copy(streamBytes, 0, buffer, 0, streamBytes.Length);
|
||||
Marshal.WriteInt32(bytesReadPtr, streamBytes.Length);
|
||||
firstCall = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Marshal.WriteInt32(bytesReadPtr, 0);
|
||||
}
|
||||
});
|
||||
|
||||
return streamMock.Object;
|
||||
Assert.IsTrue(bitmap != null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,11 @@
|
||||
|
||||
<Import Project="..\..\..\Version.props" />
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="HelperFiles\file1.svg" />
|
||||
<None Remove="HelperFiles\file2.svg" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.0" />
|
||||
<PackageReference Include="Moq" Version="4.16.1" />
|
||||
@@ -35,4 +40,12 @@
|
||||
<Compile Include="..\STATestClassAttribute.cs" Link="STATestClassAttribute.cs" />
|
||||
<Compile Include="..\STATestMethodAttribute.cs" Link="STATestMethodAttribute.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="HelperFiles\file1.svg">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="HelperFiles\file2.svg">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user