Skip to content

Commit d950a32

Browse files
Sergio0694Evangelinkadam-stephensonadstep
authored
Add UWP .NET 9 support for MSTest extensions (#3848)
Co-authored-by: Amaury Levé <[email protected]> Co-authored-by: unknown <[email protected]> Co-authored-by: adstep <[email protected]>
1 parent c1d2aaf commit d950a32

File tree

65 files changed

+785
-42
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+785
-42
lines changed

Directory.Build.props

+2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717

1818
<!-- The TFMs to build and test against. -->
1919
<PropertyGroup>
20+
<!-- The windows SDK version of UWP, Modern UWP and WinUI could be aligned -->
2021
<UwpMinimum>uap10.0.16299</UwpMinimum>
22+
<ModernUwpMinimum>net9.0-windows10.0.17763.0</ModernUwpMinimum>
2123
<WinUiMinimum>net6.0-windows10.0.18362.0</WinUiMinimum>
2224

2325
<MicrosoftTestingTargetFrameworks>net6.0;net7.0;net8.0;net9.0</MicrosoftTestingTargetFrameworks>

eng/verify-nupkgs.ps1

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ function Confirm-NugetPackages {
2020
Write-Verbose "Starting Confirm-NugetPackages."
2121
$expectedNumOfFiles = @{
2222
"MSTest.Sdk" = 15
23-
"MSTest.TestFramework" = 148
24-
"MSTest.TestAdapter" = 75
23+
"MSTest.TestFramework" = 150
24+
"MSTest.TestAdapter" = 77
2525
"MSTest" = 14
2626
"MSTest.Analyzers" = 56
2727
}
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<Application
2+
x:Class="BlankUwpNet9App.App"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:local="using:BlankUwpNet9App" />
+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using System;
5+
6+
using Windows.ApplicationModel;
7+
using Windows.ApplicationModel.Activation;
8+
using Windows.UI.Xaml;
9+
using Windows.UI.Xaml.Controls;
10+
using Windows.UI.Xaml.Navigation;
11+
12+
namespace BlankUwpNet9App;
13+
14+
/// <summary>
15+
/// Provides application-specific behavior to supplement the default Application class.
16+
/// </summary>
17+
public sealed partial class App : Application
18+
{
19+
/// <summary>
20+
/// Initializes the singleton application object. This is the first line of authored code
21+
/// executed, and as such is the logical equivalent of main() or WinMain().
22+
/// </summary>
23+
public App()
24+
{
25+
InitializeComponent();
26+
27+
Suspending += OnSuspending;
28+
}
29+
30+
/// <inheritdoc/>
31+
protected override void OnLaunched(LaunchActivatedEventArgs args)
32+
{
33+
var rootFrame = Window.Current.Content as Frame;
34+
35+
// Do not repeat app initialization when the Window already has content,
36+
// just ensure that the window is active.
37+
if (rootFrame == null)
38+
{
39+
// Create a Frame to act as the navigation context and navigate to the first page
40+
rootFrame = new Frame();
41+
42+
rootFrame.NavigationFailed += OnNavigationFailed;
43+
44+
if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
45+
{
46+
// TODO: Load state from previously suspended application
47+
}
48+
49+
// Place the frame in the current Window
50+
Window.Current.Content = rootFrame;
51+
}
52+
53+
Microsoft.VisualStudio.TestPlatform.TestExecutor.UnitTestClient.CreateDefaultUI();
54+
55+
// Ensure the current window is active
56+
Window.Current.Activate();
57+
58+
Microsoft.VisualStudio.TestPlatform.TestExecutor.UnitTestClient.Run(args.Arguments);
59+
}
60+
61+
/// <summary>
62+
/// Invoked when Navigation to a certain page fails.
63+
/// </summary>
64+
/// <param name="sender">The Frame which failed navigation.</param>
65+
/// <param name="e">Details about the navigation failure.</param>
66+
private void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
67+
=> throw new Exception($"Failed to load page '{e.SourcePageType.FullName}'.");
68+
69+
/// <summary>
70+
/// Invoked when application execution is being suspended. Application state is saved
71+
/// without knowing whether the application will be terminated or resumed with the contents
72+
/// of memory still intact.
73+
/// </summary>
74+
/// <param name="sender">The source of the suspend request.</param>
75+
/// <param name="e">Details about the suspend request.</param>
76+
private void OnSuspending(object sender, SuspendingEventArgs e)
77+
{
78+
SuspendingDeferral deferral = e.SuspendingOperation.GetDeferral();
79+
80+
// TODO: Save application state and stop any background activity
81+
deferral.Complete();
82+
}
83+
}
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>WinExe</OutputType>
5+
<TargetFramework>net9.0-windows10.0.26100.0</TargetFramework>
6+
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
7+
<Platforms>x86;x64;arm64</Platforms>
8+
<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
9+
<PublishProfile>win-$(Platform).pubxml</PublishProfile>
10+
<DefaultLanguage>en-US</DefaultLanguage>
11+
<PublishAot>true</PublishAot>
12+
<UseUwp>true</UseUwp>
13+
<DisableRuntimeMarshalling>true</DisableRuntimeMarshalling>
14+
<EnableMsixTooling>true</EnableMsixTooling>
15+
</PropertyGroup>
16+
17+
<ItemGroup>
18+
<ProjectCapability Include="TestContainer" />
19+
</ItemGroup>
20+
21+
<ItemGroup>
22+
<PackageReference Include="Microsoft.TestPlatform.TestHost" Version="$(VSTestVersion)" />
23+
<PackageReference Include="MSTest.TestAdapter" Version="$(MSTestVersion)" />
24+
<PackageReference Include="MSTest.TestFramework" Version="$(MSTestVersion)" />
25+
</ItemGroup>
26+
27+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.12.35521.163
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlankUwpNet9App", "BlankUwpNet9App.csproj", "{D9E66319-BE72-4384-93FC-CA0C1B79C7FC}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|arm64 = Debug|arm64
11+
Debug|x64 = Debug|x64
12+
Debug|x86 = Debug|x86
13+
Release|arm64 = Release|arm64
14+
Release|x64 = Release|x64
15+
Release|x86 = Release|x86
16+
EndGlobalSection
17+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
18+
{D9E66319-BE72-4384-93FC-CA0C1B79C7FC}.Debug|arm64.ActiveCfg = Debug|arm64
19+
{D9E66319-BE72-4384-93FC-CA0C1B79C7FC}.Debug|arm64.Build.0 = Debug|arm64
20+
{D9E66319-BE72-4384-93FC-CA0C1B79C7FC}.Debug|arm64.Deploy.0 = Debug|arm64
21+
{D9E66319-BE72-4384-93FC-CA0C1B79C7FC}.Debug|x64.ActiveCfg = Debug|x64
22+
{D9E66319-BE72-4384-93FC-CA0C1B79C7FC}.Debug|x64.Build.0 = Debug|x64
23+
{D9E66319-BE72-4384-93FC-CA0C1B79C7FC}.Debug|x64.Deploy.0 = Debug|x64
24+
{D9E66319-BE72-4384-93FC-CA0C1B79C7FC}.Debug|x86.ActiveCfg = Debug|x86
25+
{D9E66319-BE72-4384-93FC-CA0C1B79C7FC}.Debug|x86.Build.0 = Debug|x86
26+
{D9E66319-BE72-4384-93FC-CA0C1B79C7FC}.Debug|x86.Deploy.0 = Debug|x86
27+
{D9E66319-BE72-4384-93FC-CA0C1B79C7FC}.Release|arm64.ActiveCfg = Release|arm64
28+
{D9E66319-BE72-4384-93FC-CA0C1B79C7FC}.Release|arm64.Build.0 = Release|arm64
29+
{D9E66319-BE72-4384-93FC-CA0C1B79C7FC}.Release|x64.ActiveCfg = Release|x64
30+
{D9E66319-BE72-4384-93FC-CA0C1B79C7FC}.Release|x64.Build.0 = Release|x64
31+
{D9E66319-BE72-4384-93FC-CA0C1B79C7FC}.Release|x86.ActiveCfg = Release|x86
32+
{D9E66319-BE72-4384-93FC-CA0C1B79C7FC}.Release|x86.Build.0 = Release|x86
33+
EndGlobalSection
34+
GlobalSection(SolutionProperties) = preSolution
35+
HideSolutionNode = FALSE
36+
EndGlobalSection
37+
EndGlobal
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Page
2+
x:Class="BlankUwpNet9App.MainPage"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:local="using:BlankUwpNet9App"
7+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
8+
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
9+
mc:Ignorable="d">
10+
11+
<Grid>
12+
<TextBlock Text="Hello world" />
13+
</Grid>
14+
</Page>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Runtime.InteropServices.WindowsRuntime;
6+
using Windows.Foundation;
7+
using Windows.Foundation.Collections;
8+
using Windows.UI.Xaml;
9+
using Windows.UI.Xaml.Controls;
10+
using Windows.UI.Xaml.Controls.Primitives;
11+
using Windows.UI.Xaml.Data;
12+
using Windows.UI.Xaml.Input;
13+
using Windows.UI.Xaml.Media;
14+
using Windows.UI.Xaml.Navigation;
15+
16+
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
17+
18+
namespace BlankUwpNet9App;
19+
20+
/// <summary>
21+
/// An empty page that can be used on its own or navigated to within a Frame.
22+
/// </summary>
23+
public sealed partial class MainPage : Page
24+
{
25+
public MainPage()
26+
{
27+
InitializeComponent();
28+
}
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<Package
4+
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
5+
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
6+
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
7+
IgnorableNamespaces="uap mp">
8+
9+
<Identity
10+
Name="3a1115e9-2ece-44ab-944f-5b6240a08ea6"
11+
Publisher="CN=sergiopedri"
12+
Version="1.0.0.0" />
13+
14+
<mp:PhoneIdentity PhoneProductId="3a1115e9-2ece-44ab-944f-5b6240a08ea6" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
15+
16+
<Properties>
17+
<DisplayName>BlankUwpNet9App</DisplayName>
18+
<PublisherDisplayName>sergiopedri</PublisherDisplayName>
19+
<Logo>Assets\StoreLogo.png</Logo>
20+
</Properties>
21+
22+
<Dependencies>
23+
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
24+
</Dependencies>
25+
26+
<Resources>
27+
<Resource Language="x-generate"/>
28+
</Resources>
29+
30+
<Applications>
31+
<Application Id="App"
32+
Executable="$targetnametoken$.exe"
33+
EntryPoint="BlankUwpNet9App.App">
34+
<uap:VisualElements
35+
DisplayName="BlankUwpNet9App"
36+
Square150x150Logo="Assets\Square150x150Logo.png"
37+
Square44x44Logo="Assets\Square44x44Logo.png"
38+
Description="BlankUwpNet9App"
39+
BackgroundColor="transparent">
40+
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png"/>
41+
<uap:SplashScreen Image="Assets\SplashScreen.png" />
42+
</uap:VisualElements>
43+
</Application>
44+
</Applications>
45+
46+
<Capabilities>
47+
<Capability Name="internetClient" />
48+
<Capability Name="privateNetworkClientServer"/>
49+
</Capabilities>
50+
</Package>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
https://go.microsoft.com/fwlink/?LinkID=208121.
4+
-->
5+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
6+
<PropertyGroup>
7+
<PublishProtocol>FileSystem</PublishProtocol>
8+
<Platform>ARM64</Platform>
9+
<RuntimeIdentifier>win-arm64</RuntimeIdentifier>
10+
<PublishDir>bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\</PublishDir>
11+
<PublishAot>true</PublishAot>
12+
<SelfContained>true</SelfContained>
13+
</PropertyGroup>
14+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
https://go.microsoft.com/fwlink/?LinkID=208121.
4+
-->
5+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
6+
<PropertyGroup>
7+
<PublishProtocol>FileSystem</PublishProtocol>
8+
<Platform>x64</Platform>
9+
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
10+
<PublishDir>bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\</PublishDir>
11+
<PublishAot>true</PublishAot>
12+
<SelfContained>true</SelfContained>
13+
</PropertyGroup>
14+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
https://go.microsoft.com/fwlink/?LinkID=208121.
4+
-->
5+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
6+
<PropertyGroup>
7+
<PublishProtocol>FileSystem</PublishProtocol>
8+
<Platform>x86</Platform>
9+
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
10+
<PublishDir>bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\</PublishDir>
11+
<PublishAot>true</PublishAot>
12+
<SelfContained>true</SelfContained>
13+
</PropertyGroup>
14+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"profiles": {
3+
"BlankUwpNet9App": {
4+
"commandName": "MsixPackage"
5+
}
6+
}
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using Microsoft.VisualStudio.TestTools.UnitTesting;
5+
using Microsoft.VisualStudio.TestTools.UnitTesting.AppContainer;
6+
7+
using Windows.UI.Xaml.Controls;
8+
9+
namespace App1;
10+
11+
[TestClass]
12+
public class UnitTest1
13+
{
14+
[TestMethod]
15+
public void TestMethod1()
16+
{
17+
Assert.AreEqual(0, 0);
18+
}
19+
20+
// Use the UITestMethod attribute for tests that need to run on the UI thread.
21+
[UITestMethod]
22+
public void TestMethod2()
23+
{
24+
Grid grid = new();
25+
26+
Assert.AreEqual(0, grid.MinWidth);
27+
}
28+
}
Loading
Loading
Loading
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)