Merge pull request #2 from teobugslayer/master

Merge master
This commit is contained in:
Joseph Moreno 2020-11-02 13:37:12 -05:00 committed by GitHub
commit 2efaf4369a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 26 deletions

View File

@ -1,10 +1,10 @@
This project shows how to integrate [Avalonia UI](https://avaloniaui.net) and [CoreRT](https://github.com/dotnet/corert). Both frameworks are incredible from a technical standpoint. However, they are under constant, heavy development, are not well documented, and require subtle knowledge spread across multiple sources. This project shows how to integrate [Avalonia UI](https://avaloniaui.net) and [CoreRT](https://github.com/dotnet/corert). Both frameworks are under heavy development, have sparce documentation, and require subtle knowledge spread across multiple sources.
Using this project, you will learn how to develop using both frameworks. You may also use it as a skeleton for your projects. Using this project, you will learn how to develop using both frameworks. You may also use it as a starting point for your projects.
## System requirements ## System requirements
This project was tested only under Windows, and this readme assumes you are using Windows. To build this project, you need: This project is tested only under Windows, and this readme assumes you are using Windows. To build this project, you need:
* Any supported 64-bit edition of Windows. CoreRT produces only 64-bit Windows apps. * Any supported 64-bit edition of Windows. CoreRT requires 64-bit Windows and produces only 64-bit Windows apps.
* Visual Studio. VS 20019 Community is free for personal use. Get if from [here](https://visualstudio.microsoft.com). * Visual Studio. VS 20019 Community is free for personal use. Get if from [here](https://visualstudio.microsoft.com).
When installing Visual Studio, select *.NET desktop development* and *Desktop development with C++* workloads. To generate native code, CoreRT requires the native C++ toolchain and Windows SDK. This configuration ensures you have them. When installing Visual Studio, select *.NET desktop development* and *Desktop development with C++* workloads. To generate native code, CoreRT requires the native C++ toolchain and Windows SDK. This configuration ensures you have them.
* .Net Core SDK. At the time of writing, .Net Core 5.0 is in a preview state. Download it from [here](https://dotnet.microsoft.com/download/dotnet/5.0). Note: Make sure that you download and install the *SDK*. The runtime is not enough for building apps. * .Net Core SDK. At the time of writing, .Net Core 5.0 is in a preview state. Download it from [here](https://dotnet.microsoft.com/download/dotnet/5.0). Note: Make sure that you download and install the *SDK*. The runtime is not enough for building apps.
@ -26,13 +26,13 @@ Then, build the sample:
```bash ```bash
dotnet publish -r win-x64 -c release dotnet publish -r win-x64 -c release
``` ```
**Note**: Avalonia and CoreRT are huge. Downloading them might take some time. During this period, which happens on the first build, and when CoreRT releases a new version, it will look like nothing happens. Just be patient. **Note**: Avalonia and CoreRT are huge and downloading their NuGet packages may take some time. During this period, which happens on the first build, and when CoreRT releases a new version, it will look like nothing happens. Just be patient.
We are ready - In your terminal, navigate to `src\bin\Release\net5.0\win-x64\publish`, and start AvaloniaCoreRTDemo.exe - it should work! We are ready - In your terminal, navigate to `src\bin\Release\net5.0\win-x64\publish`, and start AvaloniaCoreRTDemo.exe - it should work!
### Background information ### Background information
At the time of writing, there's an incompatibility between the current version of Avalonia (0.9.9) and CoreRT, which we need to solve. To give you context, CoreRT is an ahead-of-time compiler, and specific code patterns cannot be used with it, while JIT compilers handle them easily. One such pattern is the infinite generic type expansions, and one of Avalonia dependencies [uses it](https://github.com/dotnet/corert/issues/7920#issuecomment-568536702). The library which uses this code has released a fixed version. However, Avalonia has not been updated yet. To solve this problem, we force the new version of the sub-dependency in the project file: At the time of writing, there's an incompatibility between the current version of Avalonia (0.9.10) and CoreRT, which we need to solve. To give you context, CoreRT is an ahead-of-time compiler, and specific code patterns cannot be used with it, while JIT compilers handle them easily. One such pattern is the infinite generic type expansions, and one of Avalonia dependencies [uses it](https://github.com/dotnet/corert/issues/7920#issuecomment-568536702). The library which uses this code has released a fixed version. However, Avalonia has not been updated yet. To solve this problem, we force the new version of the sub-dependency in the project file:
```XML ```XML
<PackageReference Include="System.Reactive" Version="4.4.1" /> <PackageReference Include="System.Reactive" Version="4.4.1" />

View File

@ -3,8 +3,6 @@
<!-- if you want to check exceptions, change this to "Exe" and start your app from the console --> <!-- if you want to check exceptions, change this to "Exe" and start your app from the console -->
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<TargetFramework>net5.0</TargetFramework> <TargetFramework>net5.0</TargetFramework>
<!-- This is a hack. Avalonia 0.9.9 depends on a version of System.Reactive prior 4.4.1, which contains a critical fix for building with CoreRT -->
<!--<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>-->
<Platforms>AnyCPU;x64</Platforms> <Platforms>AnyCPU;x64</Platforms>
</PropertyGroup> </PropertyGroup>
@ -12,8 +10,8 @@
<!-- these can help when debugging weird exceptions especially when reflection is involved. See https://github.com/dotnet/corert/blob/master/Documentation/using-corert/optimizing-corert.md --> <!-- these can help when debugging weird exceptions especially when reflection is involved. See https://github.com/dotnet/corert/blob/master/Documentation/using-corert/optimizing-corert.md -->
<RootAllApplicationAssemblies>false</RootAllApplicationAssemblies> <RootAllApplicationAssemblies>false</RootAllApplicationAssemblies>
<IlcGenerateCompleteTypeMetadata>false</IlcGenerateCompleteTypeMetadata> <IlcGenerateCompleteTypeMetadata>false</IlcGenerateCompleteTypeMetadata>
<IlcGenerateStackTraceData>true</IlcGenerateStackTraceData> <IlcGenerateStackTraceData>false</IlcGenerateStackTraceData>
<IlcDisableUnhandledExceptionExperience>false</IlcDisableUnhandledExceptionExperience> <IlcDisableUnhandledExceptionExperience>true</IlcDisableUnhandledExceptionExperience>
</PropertyGroup> </PropertyGroup>
<ItemGroup Condition="$(RuntimeIdentifier.StartsWith('win'))"> <ItemGroup Condition="$(RuntimeIdentifier.StartsWith('win'))">
@ -34,15 +32,15 @@
<EmbeddedResource Include="windows.png" /> <EmbeddedResource Include="windows.png" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Avalonia" Version="0.9.9" /> <PackageReference Include="Avalonia" Version="0.9.10" />
<PackageReference Include="Avalonia.Desktop" Version="0.9.9" /> <PackageReference Include="Avalonia.Desktop" Version="0.9.10" />
<PackageReference Include="Avalonia.ReactiveUI" Version="0.9.9" /> <PackageReference Include="Avalonia.ReactiveUI" Version="0.9.10" />
<PackageReference Include="Microsoft.DotNet.ILCompiler" Version="1.0.0-alpha-*" /> <PackageReference Include="Microsoft.DotNet.ILCompiler" Version="1.0.0-alpha-*" />
<!-- This is a hack. Avalonia 0.9.7 depends on a version of System.Reactive prior 4.4.1, which contains a critical fix for building with CoreRT --> <!-- This is a hack. Avalonia 0.9.10 depends on a version of System.Reactive prior 4.4.1, which contains a critical fix for building with CoreRT -->
<PackageReference Include="System.Reactive" Version="4.4.1" /> <PackageReference Include="System.Reactive" Version="4.4.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<!-- Avalonis relies heavily on reflection. Describe types needed here. --> <!-- Avalonia relies heavily on reflection. Describe types reflected upon here. -->
<RdXmlFile Include="rd.xml" /> <RdXmlFile Include="rd.xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -2,6 +2,7 @@
<configuration> <configuration>
<packageSources> <packageSources>
<add key="AvaloniaCI" value="https://www.myget.org/F/avalonia-ci/api/v2" /> <add key="AvaloniaCI" value="https://www.myget.org/F/avalonia-ci/api/v2" />
<add key="dotnet5" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet5/nuget/v3/index.json" />
<add key="dotnet-core" value="https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json" /> <add key="dotnet-core" value="https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json" />
<add key="nuget" value="https://api.nuget.org/v3/index.json" /> <add key="nuget" value="https://api.nuget.org/v3/index.json" />
</packageSources> </packageSources>

View File

@ -18,27 +18,21 @@
<Assembly Name="Avalonia.Markup" Dynamic="Required All"></Assembly> <Assembly Name="Avalonia.Markup" Dynamic="Required All"></Assembly>
<Assembly Name="Avalonia.Markup.Xaml" Dynamic="Required All"></Assembly> <Assembly Name="Avalonia.Markup.Xaml" Dynamic="Required All"></Assembly>
<Assembly Name="Avalonia.Styling" Dynamic="Required All"></Assembly> <Assembly Name="Avalonia.Styling" Dynamic="Required All"></Assembly>
<Assembly Name="Avalonia.DesktopRuntime" Dynamic="Required All"></Assembly> <Assembly Name="Avalonia.DesktopRuntime" Dynamic="Required All"></Assembly>
<Assembly Name="Avalonia.DesignerSupport" Dynamic="Required All"></Assembly> <Assembly Name="Avalonia.DesignerSupport" Dynamic="Required All"></Assembly>
<Assembly Name="Avalonia.Diagnostics" Dynamic="Required All"></Assembly> <Assembly Name="Avalonia.Diagnostics" Dynamic="Required All"></Assembly>
<Assembly Name="Avalonia.Dialogs" Dynamic="Required All"></Assembly> <Assembly Name="Avalonia.Dialogs" Dynamic="Required All"></Assembly>
<Assembly Name="Avalonia.Input" Dynamic="Required All"></Assembly> <Assembly Name="Avalonia.Input" Dynamic="Required All"></Assembly>
<Assembly Name="Avalonia.Logging.Serilog" Dynamic="Required All"></Assembly> <Assembly Name="Avalonia.Logging.Serilog" Dynamic="Required All"></Assembly>
<Assembly Name="Avalonia.OpenGL" Dynamic="Required All"></Assembly> <Assembly Name="Avalonia.OpenGL" Dynamic="Required All"></Assembly>
<Assembly Name="Avalonia.Desktop" Dynamic="Required All"></Assembly> <Assembly Name="Avalonia.Desktop" Dynamic="Required All"></Assembly>
<Assembly Name="Avalonia.Direct2D1" Dynamic="Required All"></Assembly> <Assembly Name="Avalonia.Direct2D1" Dynamic="Required All"></Assembly>
<Assembly Name="Avalonia.ReactiveUI" Dynamic="Required All"></Assembly> <Assembly Name="Avalonia.ReactiveUI" Dynamic="Required All"></Assembly>
<Assembly Name="Avalonia.Skia" Dynamic="Required All"></Assembly> <Assembly Name="Avalonia.Skia" Dynamic="Required All"></Assembly>
<Assembly Name="Avalonia.Win32" Dynamic="Required All"></Assembly> <Assembly Name="Avalonia.Win32" Dynamic="Required All"></Assembly>
<Assembly Name="SkiaSharp" Dynamic="Required All"></Assembly>
<Assembly Name="ReactiveUI" Dynamic="Required All"></Assembly> <Assembly Name="ReactiveUI" Dynamic="Required All"></Assembly>
<Assembly Name="System.Reactive" Dynamic="Required All"></Assembly> <Assembly Name="System.Reactive" Dynamic="Required All"></Assembly>
<Assembly Name="Splat" Dynamic="Required All"></Assembly> <Assembly Name="Splat" Dynamic="Required All"></Assembly>
--> -->
</Application> </Application>
</Directives> </Directives>