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
11 changes: 6 additions & 5 deletions src/SingleProject/Resizetizer/src/SkiaSharpSvgTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,19 @@ public override SKSize GetOriginalSize() =>

public override void DrawUnscaled(SKCanvas canvas, float scale)
{
var size = GetOriginalSize();
if (size.IsEmpty)
{
throw new InvalidOperationException($"Cannot draw SVG file '{Filename}'. The SVG has no size. Ensure the SVG includes a viewBox attribute or both width and height attributes with valid dimensions.");
}
if (scale >= 1)
{
// draw using default scaling
canvas.DrawPicture(svg.Picture, Paint);
}
else
{
var size = GetOriginalSize();
if (size.IsEmpty)
{
throw new InvalidOperationException($"Cannot draw SVG file '{Filename}'. The SVG has no size. Ensure the SVG includes a viewBox attribute or both width and height attributes with valid dimensions.");
}

// vector scaling has rounding issues, so first draw as intended
var info = new SKImageInfo((int)size.Width, (int)size.Height);
using var surface = SKSurface.Create(info);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,24 @@ public void ImageProcessingErrorCode(string image)
Assert.Equal("MAUIR0001", errorCode);
}

[Fact]
public void EmptySvgAppIconSucceeds_Issue35293()
{
var items = new[]
{
new TaskItem("images/appicon_empty.svg", new Dictionary<string, string>
{
["IsAppIcon"] = bool.TrueString,
["Link"] = "appicon",
}),
};

var task = GetNewTask(items);
var success = task.Execute();

Assert.True(success, LogErrorEvents.FirstOrDefault()?.Message);
}

[Fact]
public void GenerationSkippedOnIncrementalBuild()
{
Expand Down Expand Up @@ -1029,6 +1047,7 @@ public void NonExistantFilesAreDeleted()

// AssertFileSize(DestinationFilename, exWidth, exHeight);
//}

}

public class ExecuteForiOS : ExecuteForPlatformApp
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading