18 changed files with 25 additions and 230 deletions
@ -1,26 +0,0 @@ |
|||
using System; |
|||
|
|||
namespace Avalonia.Platform |
|||
{ |
|||
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] |
|||
public class ExportWindowingSubsystemAttribute : Attribute |
|||
{ |
|||
public ExportWindowingSubsystemAttribute(OperatingSystemType requiredRuntimePlatform, int priority, string name, Type initializationType, |
|||
string initializationMethod, Type? environmentChecker = null) |
|||
{ |
|||
Name = name; |
|||
InitializationType = initializationType; |
|||
InitializationMethod = initializationMethod; |
|||
EnvironmentChecker = environmentChecker; |
|||
RequiredOS = requiredRuntimePlatform; |
|||
Priority = priority; |
|||
} |
|||
|
|||
public string InitializationMethod { get; private set; } |
|||
public Type? EnvironmentChecker { get; } |
|||
public Type InitializationType { get; private set; } |
|||
public string Name { get; private set; } |
|||
public int Priority { get; private set; } |
|||
public OperatingSystemType RequiredOS { get; private set; } |
|||
} |
|||
} |
|||
@ -1,3 +0,0 @@ |
|||
Compat issues with assembly Avalonia.DesktopRuntime: |
|||
TypesMustExist : Type 'Avalonia.Shared.PlatformSupport.AssetLoader' does not exist in the implementation but it does exist in the contract. |
|||
Total Issues: 1 |
|||
@ -1,103 +0,0 @@ |
|||
using System; |
|||
using System.IO; |
|||
using System.Linq; |
|||
using System.Reflection; |
|||
using Avalonia.Controls; |
|||
using Avalonia.Platform; |
|||
using Avalonia.PlatformSupport; |
|||
|
|||
namespace Avalonia |
|||
{ |
|||
/// <summary>
|
|||
/// Initializes platform-specific services for an <see cref="Application"/>.
|
|||
/// </summary>
|
|||
public sealed class AppBuilder : AppBuilderBase<AppBuilder> |
|||
{ |
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="AppBuilder"/> class.
|
|||
/// </summary>
|
|||
public AppBuilder() |
|||
: base(new StandardRuntimePlatform(), |
|||
builder => StandardRuntimePlatformServices.Register(builder.ApplicationType.Assembly)) |
|||
{ |
|||
} |
|||
|
|||
bool CheckEnvironment(Type checkerType) |
|||
{ |
|||
if (checkerType == null) |
|||
return true; |
|||
try |
|||
{ |
|||
return ((IModuleEnvironmentChecker) Activator.CreateInstance(checkerType)).IsCompatible; |
|||
} |
|||
catch |
|||
{ |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Instructs the <see cref="AppBuilder"/> to use the best settings for the platform.
|
|||
/// </summary>
|
|||
/// <returns>An <see cref="AppBuilder"/> instance.</returns>
|
|||
public AppBuilder UseSubsystemsFromStartupDirectory() |
|||
{ |
|||
var os = RuntimePlatform.GetRuntimeInfo().OperatingSystem; |
|||
|
|||
LoadAssembliesInDirectory(); |
|||
|
|||
var windowingSubsystemAttribute = (from assembly in AppDomain.CurrentDomain.GetAssemblies() |
|||
from attribute in assembly.GetCustomAttributes<ExportWindowingSubsystemAttribute>() |
|||
where attribute.RequiredOS == os && CheckEnvironment(attribute.EnvironmentChecker) |
|||
orderby attribute.Priority ascending |
|||
select attribute).FirstOrDefault(); |
|||
if (windowingSubsystemAttribute == null) |
|||
{ |
|||
throw new InvalidOperationException("No windowing subsystem found. Are you missing assembly references?"); |
|||
} |
|||
|
|||
var renderingSubsystemAttribute = (from assembly in AppDomain.CurrentDomain.GetAssemblies() |
|||
from attribute in assembly.GetCustomAttributes<ExportRenderingSubsystemAttribute>() |
|||
where attribute.RequiredOS == os && CheckEnvironment(attribute.EnvironmentChecker) |
|||
where attribute.RequiresWindowingSubsystem == null |
|||
|| attribute.RequiresWindowingSubsystem == windowingSubsystemAttribute.Name |
|||
orderby attribute.Priority ascending |
|||
select attribute).FirstOrDefault(); |
|||
|
|||
if (renderingSubsystemAttribute == null) |
|||
{ |
|||
throw new InvalidOperationException("No rendering subsystem found. Are you missing assembly references?"); |
|||
} |
|||
|
|||
UseWindowingSubsystem(() => windowingSubsystemAttribute.InitializationType |
|||
.GetRuntimeMethod(windowingSubsystemAttribute.InitializationMethod, Type.EmptyTypes).Invoke(null, null), |
|||
windowingSubsystemAttribute.Name); |
|||
|
|||
UseRenderingSubsystem(() => renderingSubsystemAttribute.InitializationType |
|||
.GetRuntimeMethod(renderingSubsystemAttribute.InitializationMethod, Type.EmptyTypes).Invoke(null, null), |
|||
renderingSubsystemAttribute.Name); |
|||
|
|||
return this; |
|||
} |
|||
|
|||
private void LoadAssembliesInDirectory() |
|||
{ |
|||
var location = Assembly.GetEntryAssembly().Location; |
|||
if (string.IsNullOrWhiteSpace(location)) |
|||
return; |
|||
var dir = new FileInfo(location).Directory; |
|||
if (dir == null) |
|||
return; |
|||
foreach (var file in dir.EnumerateFiles("*.dll")) |
|||
{ |
|||
try |
|||
{ |
|||
Assembly.LoadFile(file.FullName); |
|||
} |
|||
catch (Exception) |
|||
{ |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -1,21 +0,0 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFrameworks>net6.0;net461;netcoreapp2.0</TargetFrameworks> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="../Avalonia.Base/Avalonia.Base.csproj" /> |
|||
<ProjectReference Include="../Avalonia.Visuals/Avalonia.Visuals.csproj" /> |
|||
<ProjectReference Include="../Avalonia.Controls/Avalonia.Controls.csproj" /> |
|||
<ProjectReference Include="../Avalonia.PlatformSupport/Avalonia.PlatformSupport.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" Version="4.3.0" Condition="'$(TargetFramework)' == 'net461'" /> |
|||
</ItemGroup> |
|||
|
|||
<Import Project="..\..\build\NetCore.props" /> |
|||
<Import Project="..\..\build\NetFX.props" /> |
|||
<Import Project="..\..\build\ApiDiff.props" /> |
|||
</Project> |
|||
@ -1,4 +0,0 @@ |
|||
using Avalonia.Native; |
|||
using Avalonia.Platform; |
|||
|
|||
[assembly: ExportWindowingSubsystem(OperatingSystemType.OSX, 1, "AvaloniaNative", typeof(AvaloniaNativePlatform), nameof(AvaloniaNativePlatform.Initialize))] |
|||
@ -0,0 +1,20 @@ |
|||
using Avalonia.Controls; |
|||
using Avalonia.PlatformSupport; |
|||
|
|||
namespace Avalonia |
|||
{ |
|||
/// <summary>
|
|||
/// Initializes platform-specific services for an <see cref="Application"/>.
|
|||
/// </summary>
|
|||
public sealed class AppBuilder : AppBuilderBase<AppBuilder> |
|||
{ |
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="AppBuilder"/> class.
|
|||
/// </summary>
|
|||
public AppBuilder() |
|||
: base(new StandardRuntimePlatform(), |
|||
builder => StandardRuntimePlatformServices.Register(builder.ApplicationType?.Assembly)) |
|||
{ |
|||
} |
|||
} |
|||
} |
|||
@ -1,27 +0,0 @@ |
|||
using System; |
|||
|
|||
namespace Avalonia.Platform |
|||
{ |
|||
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] |
|||
public class ExportRenderingSubsystemAttribute : Attribute |
|||
{ |
|||
public ExportRenderingSubsystemAttribute(OperatingSystemType requiredOS, int priority, string name, Type initializationType, string initializationMethod, |
|||
Type? environmentChecker = null) |
|||
{ |
|||
Name = name; |
|||
InitializationType = initializationType; |
|||
InitializationMethod = initializationMethod; |
|||
EnvironmentChecker = environmentChecker; |
|||
RequiredOS = requiredOS; |
|||
Priority = priority; |
|||
} |
|||
|
|||
public string InitializationMethod { get; private set; } |
|||
public Type? EnvironmentChecker { get; } |
|||
public Type InitializationType { get; private set; } |
|||
public string Name { get; private set; } |
|||
public int Priority { get; private set; } |
|||
public OperatingSystemType RequiredOS { get; private set; } |
|||
public string? RequiresWindowingSubsystem { get; set; } |
|||
} |
|||
} |
|||
@ -1,9 +1,4 @@ |
|||
using System.Runtime.CompilerServices; |
|||
using Avalonia.Platform; |
|||
using Avalonia.Direct2D1; |
|||
|
|||
[assembly: ExportRenderingSubsystem(OperatingSystemType.WinNT, 1, "Direct2D1", typeof(Direct2D1Platform), nameof(Direct2D1Platform.Initialize), |
|||
typeof(Direct2DChecker))] |
|||
|
|||
[assembly: InternalsVisibleTo("Avalonia.Direct2D1.RenderTests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c1bba1142285fe0419326fb25866ba62c47e6c2b5c1ab0c95b46413fad375471232cb81706932e1cef38781b9ebd39d5100401bacb651c6c5bbf59e571e81b3bc08d2a622004e08b1a6ece82a7e0b9857525c86d2b95fab4bc3dce148558d7f3ae61aa3a234086902aeface87d9dfdd32b9d2fe3c6dd4055b5ab4b104998bd87")] |
|||
[assembly: InternalsVisibleTo("Avalonia.Direct2D1.UnitTests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c1bba1142285fe0419326fb25866ba62c47e6c2b5c1ab0c95b46413fad375471232cb81706932e1cef38781b9ebd39d5100401bacb651c6c5bbf59e571e81b3bc08d2a622004e08b1a6ece82a7e0b9857525c86d2b95fab4bc3dce148558d7f3ae61aa3a234086902aeface87d9dfdd32b9d2fe3c6dd4055b5ab4b104998bd87")] |
|||
|
|||
@ -1,4 +0,0 @@ |
|||
using Avalonia.Platform; |
|||
using Avalonia.Win32; |
|||
|
|||
[assembly: ExportWindowingSubsystem(OperatingSystemType.WinNT, 1, "Win32", typeof(Win32Platform), nameof(Win32Platform.Initialize))] |
|||
Loading…
Reference in new issue