Skip to content

Code Quality: Added a test project to ensure AoT compatibility of external packages & class libraries #17129

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="9.0.5" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="9.0.5" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="9.0.5" />
<PackageVersion Include="Microsoft.TestPlatform.TestHost" Version="17.13.0" />
<PackageVersion Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.3916" />
<PackageVersion Include="Microsoft.Xaml.Behaviors.WinUI.Managed" Version="3.0.0" />
<PackageVersion Include="OwlCore.Storage" Version="0.12.2" />
Expand Down
6 changes: 6 additions & 0 deletions Files.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@
</Project>
</Folder>
<Folder Name="/tests/">
<Project Path="tests/Files.App.UnitTests/Files.App.UnitTests.csproj" Id="dcd7e0a5-b198-4359-ab3b-1ca130997337">
<Platform Solution="*|arm64" Project="ARM64" />
<Platform Solution="*|x64" Project="x64" />
<Platform Solution="*|x86" Project="x86" />
<Deploy />
</Project>
<Project Path="tests/Files.App.UITests/Files.App.UITests.csproj">
<Platform Solution="*|arm64" Project="arm64" />
<Platform Solution="*|x64" Project="x64" />
Expand Down
15 changes: 15 additions & 0 deletions tests/Files.App.UnitTests/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Application
x:Class="Files.App.UnitTests.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Files.App.UnitTests">

<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>

</Application>
30 changes: 30 additions & 0 deletions tests/Files.App.UnitTests/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (c) Files Community
// Licensed under the MIT License.

using Microsoft.UI.Xaml;
using Microsoft.VisualStudio.TestTools.UnitTesting.AppContainer;

namespace Files.App.UnitTests
{
public partial class App : Application
{
private Window? _window;

public App()
{
InitializeComponent();
}

protected override void OnLaunched(LaunchActivatedEventArgs args)
{
Microsoft.VisualStudio.TestPlatform.TestExecutor.UnitTestClient.CreateDefaultUI();

_window = new MainWindow();
_window.Activate();

UITestMethodAttribute.DispatcherQueue = _window.DispatcherQueue;

Microsoft.VisualStudio.TestPlatform.TestExecutor.UnitTestClient.Run(System.Environment.CommandLine);
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/Files.App.UnitTests/Assets/StoreLogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions tests/Files.App.UnitTests/Files.App.UnitTests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>$(WindowsTargetFramework)</TargetFramework>
<TargetPlatformMinVersion>$(MinimalWindowsVersion)</TargetPlatformMinVersion>
<OutputType>WinExe</OutputType>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Platforms>x86;x64;ARM64</Platforms>
<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
<PublishProfile>win-$(Platform).pubxml</PublishProfile>
<UseWinUI>true</UseWinUI>
<EnableMsixTooling>true</EnableMsixTooling>
<Nullable>enable</Nullable>
<PublishAot>true</PublishAot>
<PublishTrimmed>true</PublishTrimmed>
<IlcGenerateMstatFile>true</IlcGenerateMstatFile>
<IlcGenerateDgmlFile>true</IlcGenerateDgmlFile>
<HasPackageAndPublishMenu Condition="'$(DisableHasPackageAndPublishMenuAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">true</HasPackageAndPublishMenu>
</PropertyGroup>

<ItemGroup>
<Manifest Include="$(ApplicationManifest)" />
<Content Include="Assets\*.png" />
<ProjectCapability Include="TestContainer" />
<ProjectCapability Condition="'$(DisableMsixProjectCapabilityAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'" Include="Msix" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.TestPlatform.TestHost" />
<PackageReference Include="MSTest.TestAdapter" />
<PackageReference Include="MSTest.TestFramework" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" />
<PackageReference Include="Microsoft.WindowsAppSDK" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Files.App.CsWin32\Files.App.CsWin32.csproj" />
<ProjectReference Include="..\..\src\Files.App.Storage\Files.App.Storage.csproj" />
<ProjectReference Include="..\..\src\Files.Shared\Files.Shared.csproj" />
</ItemGroup>

</Project>
14 changes: 14 additions & 0 deletions tests/Files.App.UnitTests/MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Window
x:Class="Files.App.UnitTests.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:Files.App.UnitTests"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="Files.App.UnitTests"
mc:Ignorable="d">
<Window.SystemBackdrop>
<MicaBackdrop />
</Window.SystemBackdrop>

</Window>
17 changes: 17 additions & 0 deletions tests/Files.App.UnitTests/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (c) Files Community
// Licensed under the MIT License.

using Microsoft.UI.Xaml;

namespace Files.App.UnitTests
{
public sealed partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();

ExtendsContentIntoTitleBar = true;
}
}
}
47 changes: 47 additions & 0 deletions tests/Files.App.UnitTests/Package.appxmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap rescap">

<Identity
Name="f20f07f5-b301-4f12-92af-febb4e36abaf"
Publisher="CN=Files Community"
Version="1.0.2.0" />

<Properties>
<DisplayName>Files Unit Test WinUI app</DisplayName>
<PublisherDisplayName>Files Community</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>

<Dependencies>
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.19041.0" MaxVersionTested="10.0.22621.0" />
</Dependencies>

<Resources>
<Resource Language="x-generate"/>
</Resources>

<Applications>
<Application Id="App"
Executable="$targetnametoken$.exe"
EntryPoint="$targetentrypoint$">
<uap:VisualElements
DisplayName="Files.App.UnitTests"
Description="Files.App.UnitTests"
BackgroundColor="transparent"
Square150x150Logo="Assets\Square150x150Logo.png"
Square44x44Logo="Assets\Square44x44Logo.png">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" />
<uap:SplashScreen Image="Assets\SplashScreen.png" />
</uap:VisualElements>
</Application>
</Applications>

<Capabilities>
<rescap:Capability Name="runFullTrust" />
</Capabilities>

</Package>
26 changes: 26 additions & 0 deletions tests/Files.App.UnitTests/UnitTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (c) Files Community
// Licensed under the MIT License.

using Microsoft.UI.Xaml.Controls;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.VisualStudio.TestTools.UnitTesting.AppContainer;

namespace App1
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
Assert.AreEqual(0, 0);
}

[UITestMethod]
public void TestMethod2()
{
var grid = new Grid();
Assert.AreEqual(0, grid.MinWidth);
}
}
}
17 changes: 17 additions & 0 deletions tests/Files.App.UnitTests/app.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="Files.App.UnitTests.app"/>

<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
</application>
</compatibility>

<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
</windowsSettings>
</application>

</assembly>
Loading