-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rework XAML compilation targets #17539
Open
MrJul
wants to merge
10
commits into
AvaloniaUI:master
Choose a base branch
from
MrJul:fix/xaml-compilation
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,017
−79
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ceecd0e
Added BuildTests projects
MrJul 21e20d5
Added VerifyXamlCompilation build target
MrJul 95f2d9e
Use TargetsTriggerByCompilation for XAML compilation
MrJul b6975c0
Add *.binlog to gitignore
MrJul 6324108
VerifyXamlCompilation target: set NuGetPackageRoot
MrJul 512457f
Ensure WpfHybrid build test uses two markup compilation passes
MrJul fdcb979
Fail build tests restore immediately if AvaloniaVersion isn't set
MrJul 1d246e0
Fix "could not extract MVID" for up-to-date builds
MrJul f539390
Run VerifyXamlCompilation on CI
MrJul ec70078
Add FSharp build test
MrJul File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,8 +45,8 @@ x64/ | |
*.vssscc | ||
.builds | ||
*.pidb | ||
*.log | ||
*.scc | ||
*.binlog | ||
|
||
# Visual C++ cache files | ||
ipch/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using System; | ||
using System.Linq; | ||
using Mono.Cecil; | ||
using Nuke.Common.Tooling; | ||
using Serilog; | ||
|
||
internal static class XamlCompilationVerifier | ||
{ | ||
public static void VerifyAssemblyCompiledXaml(string assemblyPath) | ||
{ | ||
const string avaloniaResourcesTypeName = "CompiledAvaloniaXaml.!AvaloniaResources"; | ||
const string mainViewTypeName = "BuildTests.MainView"; | ||
const string populateMethodName = "!XamlIlPopulate"; | ||
|
||
using var assembly = AssemblyDefinition.ReadAssembly(assemblyPath); | ||
|
||
if (assembly.MainModule.GetType(avaloniaResourcesTypeName) is null) | ||
{ | ||
throw new InvalidOperationException( | ||
$"Assembly {assemblyPath} is missing type {avaloniaResourcesTypeName}"); | ||
} | ||
|
||
if (assembly.MainModule.GetType(mainViewTypeName) is not { } mainViewType) | ||
{ | ||
throw new InvalidOperationException( | ||
$"Assembly {assemblyPath} is missing type {mainViewTypeName}"); | ||
} | ||
|
||
if (!mainViewType.Methods.Any(method => method.Name == populateMethodName)) | ||
{ | ||
throw new InvalidOperationException( | ||
$"Assembly {assemblyPath} is missing method {populateMethodName} on {mainViewTypeName}"); | ||
} | ||
|
||
Log.Information($"Assembly {assemblyPath} correctly has compiled XAML"); | ||
} | ||
|
||
public static void VerifyNativeAot(string programPath) | ||
{ | ||
const string expectedOutput = "Hello from AOT"; | ||
|
||
using var process = ProcessTasks.StartProcess(programPath, string.Empty); | ||
|
||
process.WaitForExit(); | ||
process.AssertZeroExitCode(); | ||
|
||
var output = process.Output.Select(o => o.Text).FirstOrDefault(); | ||
if (output != expectedOutput) | ||
{ | ||
throw new InvalidOperationException( | ||
$"{programPath} returned text \"{output}\", expected \"{expectedOutput}\""); | ||
} | ||
|
||
Log.Information($"Native program {programPath} correctly has compiled XAML"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
tests/BuildTests/BuildTests.Android/BuildTests.Android.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0-android</TargetFramework> | ||
<SupportedOSPlatformVersion>21</SupportedOSPlatformVersion> | ||
<Nullable>enable</Nullable> | ||
<ApplicationId>com.Avalonia.BuildTests</ApplicationId> | ||
<ApplicationVersion>1</ApplicationVersion> | ||
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion> | ||
<AndroidPackageFormat>apk</AndroidPackageFormat> | ||
<AndroidEnableProfiledAot>false</AndroidEnableProfiledAot> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Avalonia.Android" /> | ||
</ItemGroup> | ||
|
||
<Import Project="../IncludeBuildTestsAvaloniaItems.props" /> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using Android.App; | ||
using Android.Content.PM; | ||
using Avalonia.Android; | ||
|
||
namespace BuildTests.Android; | ||
|
||
[Activity( | ||
Label = "BuildTests.Android", | ||
MainLauncher = true, | ||
ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize | ConfigChanges.UiMode)] | ||
public class MainActivity : AvaloniaMainActivity<App>; |
5 changes: 5 additions & 0 deletions
5
tests/BuildTests/BuildTests.Android/Properties/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto"> | ||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<application android:label="BuildTests" /> | ||
</manifest> |
16 changes: 16 additions & 0 deletions
16
tests/BuildTests/BuildTests.Browser/BuildTests.Browser.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.WebAssembly"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0-browser</TargetFramework> | ||
<OutputType>Exe</OutputType> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Avalonia.Browser" /> | ||
</ItemGroup> | ||
|
||
<Import Project="../IncludeBuildTestsAvaloniaItems.props" /> | ||
|
||
</Project> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that the original issue can't be reproduced with a plain
dotnet build
, with Rider it was only happened when one tries to debug the app.