committed by
GitHub
88 changed files with 670 additions and 647 deletions
@ -1,7 +1,7 @@ |
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<ItemGroup> |
|||
<PackageReference Include="HarfBuzzSharp" Version="2.8.2.1-preview.108" /> |
|||
<PackageReference Condition="'$(IncludeLinuxSkia)' == 'true'" Include="HarfBuzzSharp.NativeAssets.Linux" Version="2.8.2.1-preview.108" /> |
|||
<PackageReference Condition="'$(IncludeWasmSkia)' == 'true'" Include="HarfBuzzSharp.NativeAssets.WebAssembly" Version="2.8.2.1-preview.108" /> |
|||
<PackageReference Include="HarfBuzzSharp" Version="2.8.2.3" /> |
|||
<PackageReference Condition="'$(IncludeLinuxSkia)' == 'true'" Include="HarfBuzzSharp.NativeAssets.Linux" Version="2.8.2.3" /> |
|||
<PackageReference Condition="'$(IncludeWasmSkia)' == 'true'" Include="HarfBuzzSharp.NativeAssets.WebAssembly" Version="2.8.2.3" /> |
|||
</ItemGroup> |
|||
</Project> |
|||
|
|||
@ -1,5 +1,5 @@ |
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<ItemGroup> |
|||
<PackageReference Include="SixLabors.ImageSharp" Version="2.1.1" /> |
|||
<PackageReference Include="SixLabors.ImageSharp" Version="2.1.3" /> |
|||
</ItemGroup> |
|||
</Project> |
|||
|
|||
@ -1,5 +1,5 @@ |
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<ItemGroup> |
|||
<PackageReference Include="Moq" Version="4.14.1" /> |
|||
<PackageReference Include="Moq" Version="4.18.4" /> |
|||
</ItemGroup> |
|||
</Project> |
|||
|
|||
@ -1,7 +1,7 @@ |
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<ItemGroup> |
|||
<PackageReference Include="SkiaSharp" Version="2.88.1" /> |
|||
<PackageReference Condition="'$(IncludeLinuxSkia)' == 'true'" Include="SkiaSharp.NativeAssets.Linux" Version="2.88.1" /> |
|||
<PackageReference Condition="'$(IncludeWasmSkia)' == 'true'" Include="SkiaSharp.NativeAssets.WebAssembly" Version="2.88.1" /> |
|||
<PackageReference Include="SkiaSharp" Version="2.88.3" /> |
|||
<PackageReference Condition="'$(IncludeLinuxSkia)' == 'true'" Include="SkiaSharp.NativeAssets.Linux" Version="2.88.3" /> |
|||
<PackageReference Condition="'$(IncludeWasmSkia)' == 'true'" Include="SkiaSharp.NativeAssets.WebAssembly" Version="2.88.3" /> |
|||
</ItemGroup> |
|||
</Project> |
|||
|
|||
@ -1,16 +1,79 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.IO; |
|||
using System.Linq; |
|||
using System.Reflection; |
|||
using System.Text.RegularExpressions; |
|||
using Avalonia.Markup.Xaml; |
|||
using Avalonia.Markup.Xaml.XamlIl; |
|||
|
|||
namespace Avalonia.Designer.HostApp |
|||
namespace Avalonia.Designer.HostApp; |
|||
|
|||
class DesignXamlLoader : AvaloniaXamlLoader.IRuntimeXamlLoader |
|||
{ |
|||
class DesignXamlLoader : AvaloniaXamlLoader.IRuntimeXamlLoader |
|||
public object Load(RuntimeXamlLoaderDocument document, RuntimeXamlLoaderConfiguration configuration) |
|||
{ |
|||
PreloadDepsAssemblies(configuration.LocalAssembly ?? Assembly.GetEntryAssembly()); |
|||
|
|||
return AvaloniaXamlIlRuntimeCompiler.Load(document, configuration); |
|||
} |
|||
|
|||
private void PreloadDepsAssemblies(Assembly targetAssembly) |
|||
{ |
|||
public object Load(RuntimeXamlLoaderDocument document, RuntimeXamlLoaderConfiguration configuration) |
|||
// Assemblies loaded in memory (e.g. single file) return empty string from Location.
|
|||
// In these cases, don't try probing next to the assembly.
|
|||
var assemblyLocation = targetAssembly.Location; |
|||
if (string.IsNullOrEmpty(assemblyLocation)) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
var depsJsonFile = Path.ChangeExtension(assemblyLocation, ".deps.json"); |
|||
if (!File.Exists(depsJsonFile)) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
using var stream = File.OpenRead(depsJsonFile); |
|||
|
|||
/* |
|||
We can't use any references in the Avalonia.Designer.HostApp. Including even json. |
|||
Ideally we would prefer Microsoft.Extensions.DependencyModel package, but can't use it here. |
|||
So, instead we need to fallback to some JSON parsing using pretty easy regex. |
|||
|
|||
Json part example: |
|||
"Avalonia.Xaml.Interactions/11.0.0-preview5": { |
|||
"dependencies": { |
|||
"Avalonia": "11.0.999", |
|||
"Avalonia.Xaml.Interactivity": "11.0.0-preview5" |
|||
}, |
|||
"runtime": { |
|||
"lib/net6.0/Avalonia.Xaml.Interactions.dll": { |
|||
"assemblyVersion": "11.0.0.0", |
|||
"fileVersion": "11.0.0.0" |
|||
} |
|||
} |
|||
}, |
|||
We want to extract "lib/net6.0/Avalonia.Xaml.Interactions.dll" from here. |
|||
No need to resolve real path of ref assemblies. |
|||
No need to handle special cases with .NET Framework and GAC. |
|||
*/ |
|||
var text = new StreamReader(stream).ReadToEnd(); |
|||
var matches = Regex.Matches( text, """runtime"\s*:\s*{\s*"([^"]+)""");
|
|||
|
|||
foreach (Match match in matches) |
|||
{ |
|||
return AvaloniaXamlIlRuntimeCompiler.Load(document, configuration); |
|||
if (match.Groups[1] is { Success: true } g) |
|||
{ |
|||
var assemblyName = Path.GetFileNameWithoutExtension(g.Value); |
|||
try |
|||
{ |
|||
_ = Assembly.Load(new AssemblyName(assemblyName)); |
|||
} |
|||
catch |
|||
{ |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -1,35 +0,0 @@ |
|||
using System; |
|||
using Moq; |
|||
using Avalonia.Platform; |
|||
|
|||
namespace Avalonia.Controls.UnitTests |
|||
{ |
|||
public class WindowingPlatformMock : IWindowingPlatform |
|||
{ |
|||
private readonly Func<IWindowImpl> _windowImpl; |
|||
private readonly Func<IPopupImpl> _popupImpl; |
|||
|
|||
public WindowingPlatformMock(Func<IWindowImpl> windowImpl = null, Func<IPopupImpl> popupImpl = null ) |
|||
{ |
|||
_windowImpl = windowImpl; |
|||
_popupImpl = popupImpl; |
|||
} |
|||
|
|||
public IWindowImpl CreateWindow() |
|||
{ |
|||
return _windowImpl?.Invoke() ?? Mock.Of<IWindowImpl>(x => x.RenderScaling == 1); |
|||
} |
|||
|
|||
public IWindowImpl CreateEmbeddableWindow() |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
|
|||
public ITrayIconImpl CreateTrayIcon() |
|||
{ |
|||
return null; |
|||
} |
|||
|
|||
public IPopupImpl CreatePopup() => _popupImpl?.Invoke() ?? Mock.Of<IPopupImpl>(x => x.RenderScaling == 1); |
|||
} |
|||
} |
|||
@ -1,54 +0,0 @@ |
|||
using System; |
|||
using Avalonia.Controls; |
|||
using Avalonia.Controls.Presenters; |
|||
using Avalonia.Controls.Templates; |
|||
using Avalonia.Layout; |
|||
using Avalonia.LogicalTree; |
|||
using Avalonia.Platform; |
|||
using Avalonia.Rendering; |
|||
using Avalonia.Styling; |
|||
|
|||
namespace Avalonia.UnitTests |
|||
{ |
|||
public class TestTemplatedRoot : ContentControl, ILayoutRoot, IRenderRoot, ILogicalRoot |
|||
{ |
|||
private readonly NameScope _nameScope = new NameScope(); |
|||
|
|||
public TestTemplatedRoot() |
|||
{ |
|||
LayoutManager = new LayoutManager(this); |
|||
Template = new FuncControlTemplate<TestTemplatedRoot>((x, scope) => new ContentPresenter |
|||
{ |
|||
Name = "PART_ContentPresenter", |
|||
}.RegisterInNameScope(scope)); |
|||
} |
|||
|
|||
public Size ClientSize => new Size(100, 100); |
|||
|
|||
public Size MaxClientSize => Size.Infinity; |
|||
|
|||
public double LayoutScaling => 1; |
|||
|
|||
public ILayoutManager LayoutManager { get; set; } |
|||
|
|||
public double RenderScaling => 1; |
|||
|
|||
public IRenderTarget RenderTarget => null; |
|||
|
|||
public IRenderer Renderer => null; |
|||
|
|||
public IRenderTarget CreateRenderTarget() |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
|
|||
public void Invalidate(Rect rect) |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
|
|||
public Point PointToClient(PixelPoint p) => p.ToPoint(1); |
|||
|
|||
public PixelPoint PointToScreen(Point p) => PixelPoint.FromPoint(p, 1); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue