-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
User/shasnayak/port object lifetime tests (#847)
* Adding ObjectLifetime Tests * importing props/targets to remove cswinrt.winmd in ObjectLifetimeTests project * modifying sln to deploy ObjectLifetimeTests * commenting out failing tests * removing explicit props file reference, removing TestMethod attribute from failing tests * removing nested directories * spacing Co-authored-by: Shashank Nayak <shasnayak@microsoft.com> Co-authored-by: Manodasan Wignarajah <mawign@microsoft.com>
- Loading branch information
1 parent
218bf40
commit 46e26cd
Showing
42 changed files
with
3,115 additions
and
41 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
src/Projections/Reunion/Microsoft.UI.Dispatching.DispatcherQueueSynchronizationContext.cs
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,38 @@ | ||
using System; | ||
using System.Threading; | ||
using Microsoft.System; | ||
|
||
namespace Microsoft.System | ||
{ | ||
/// <summary> | ||
/// DispatcherQueueSyncContext allows developers to await calls and get back onto the | ||
/// UI thread. Needs to be installed on the UI thread through DispatcherQueueSyncContext.SetForCurrentThread | ||
/// </summary> | ||
public class DispatcherQueueSynchronizationContext : SynchronizationContext | ||
{ | ||
private readonly DispatcherQueue m_dispatcherQueue; | ||
|
||
public DispatcherQueueSynchronizationContext(DispatcherQueue dispatcherQueue) | ||
{ | ||
m_dispatcherQueue = dispatcherQueue; | ||
} | ||
|
||
public override void Post(SendOrPostCallback d, object state) | ||
{ | ||
if (d == null) | ||
throw new ArgumentNullException(nameof(d)); | ||
|
||
m_dispatcherQueue.TryEnqueue(() => d(state)); | ||
} | ||
|
||
public override void Send(SendOrPostCallback d, object state) | ||
{ | ||
throw new NotSupportedException("Send not supported"); | ||
} | ||
|
||
public override SynchronizationContext CreateCopy() | ||
{ | ||
return new DispatcherQueueSynchronizationContext(m_dispatcherQueue); | ||
} | ||
} | ||
} |
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,59 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>netstandard2.0;net5.0</TargetFrameworks> | ||
<Platforms>x64;x86</Platforms> | ||
<AssemblyName>Microsoft.WinUI</AssemblyName> | ||
<AssemblyVersion>9.9.9.9</AssemblyVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" /> | ||
<ProjectReference Include="..\..\WinRT.Runtime\WinRT.Runtime.csproj" /> | ||
<ProjectReference Include="..\..\cswinrt\cswinrt.vcxproj" /> | ||
<ProjectReference Include="..\Windows\Windows.csproj" /> | ||
<PackageReference Include="Microsoft.ProjectReunion" Version="0.5.7" GeneratePathProperty="true"> | ||
<ExcludeAssets>build; buildtransitive; compile; runtime</ExcludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="Microsoft.ProjectReunion.Foundation" Version="0.5.7" GeneratePathProperty="true"> | ||
<ExcludeAssets>build; buildtransitive; compile; runtime</ExcludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="Microsoft.ProjectReunion.WinUI" Version="0.5.7" GeneratePathProperty="true"> | ||
<ExcludeAssets>build; buildtransitive; compile; runtime</ExcludeAssets> | ||
</PackageReference> | ||
<Manifest Include="$(ApplicationManifest)" /> | ||
</ItemGroup> | ||
|
||
<PropertyGroup> | ||
<CsWinRTFilters> | ||
-exclude Windows | ||
-include Microsoft | ||
# The current WinUI nuget incorrectly references several Windows.* types that should be | ||
# Microsoft.* types instead. Temporarily include these to enable the build | ||
-include Windows.UI.Xaml.Interop.Type | ||
-include Windows.UI.Xaml.Interop.NotifyCollectionChangedAction | ||
-include Windows.UI.Xaml.Markup.ContentPropertyAttribute | ||
-include Windows.UI.Xaml.StyleTypedPropertyAttribute | ||
-include Windows.UI.Xaml.TemplatePartAttribute | ||
-include Windows.UI.Xaml.TemplateVisualStateAttribute | ||
-include Windows.UI.Xaml.Data.BindableAttribute | ||
-include Windows.UI.Xaml.Markup.ContentPropertyAttribute | ||
-include Windows.UI.Xaml.Markup.FullXamlMetadataProviderAttribute | ||
-include Windows.UI.Xaml.Markup.MarkupExtensionReturnTypeAttribute | ||
-include Windows.UI.Xaml.Media.Animation.ConditionallyIndependentlyAnimatableAttribute | ||
-include Windows.UI.Xaml.Media.Animation.IndependentlyAnimatableAttribute | ||
-include Windows.UI.Xaml.Media.Animation.ConditionallyIndependentlyAnimatableAttribute | ||
</CsWinRTFilters> | ||
<!--PkgMicrosoft_WinUI is set in in obj\*.csproj.nuget.g.props with TargetFramework condition, doesn't support multi-targeting--> | ||
<PkgMicrosoft_ReunionWinUI>$([MSBuild]::NormalizeDirectory('$(NuGetPackageRoot)', 'microsoft.projectreunion.winui', '0.5.7'))</PkgMicrosoft_ReunionWinUI> | ||
<PkgMicrosoft_ReunionFoundation>$([MSBuild]::NormalizeDirectory('$(NuGetPackageRoot)', 'microsoft.projectreunion.foundation', '0.5.7'))</PkgMicrosoft_ReunionFoundation> | ||
<SignAssembly>true</SignAssembly> | ||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<!--Explicitly reference WinUI winmds from TFM uap10.0--> | ||
<CsWinRTInputs Include="$(PkgMicrosoft_ReunionWinUI)/**/*.winmd" /> | ||
<CsWinRTInputs Include="$(PkgMicrosoft_ReunionFoundation)/**/*.winmd" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Binary file not shown.
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 |
---|---|---|
@@ -1,40 +1,41 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>netstandard2.0;net5.0</TargetFrameworks> | ||
<Platforms>x64;x86</Platforms> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" /> | ||
<ProjectReference Include="..\..\WinRT.Runtime\WinRT.Runtime.csproj" /> | ||
<ProjectReference Include="..\..\cswinrt\cswinrt.vcxproj" /> | ||
<InternalsVisibleTo Include="UnitTest" /> | ||
</ItemGroup> | ||
|
||
<PropertyGroup> | ||
<CsWinRTFilters> | ||
-include Windows | ||
# Exclude Windows.UI, Windows.UI.Text, Windows.UI.Xaml per Microsoft.Windows.SDK.WinUI.Contracts NuGet | ||
-include Windows.UI.Popups | ||
-exclude Windows.UI.Colors | ||
-exclude Windows.UI.IColors | ||
-exclude Windows.UI.ColorHelper | ||
-exclude Windows.UI.IColorHelper | ||
#-exclude Windows.UI.Text (must include Windows.UI.Text to work around WinUI nuget issues) | ||
-exclude Windows.UI.Xaml | ||
-exclude Windows.ApplicationModel.Store.Preview | ||
# Allow Windows.UI.Text, Windows.UI.Xaml types used in other namespaces | ||
-include Windows.UI.Text.FontStretch | ||
-include Windows.UI.Text.FontStyle | ||
-include Windows.UI.Text.FontWeight | ||
-include Windows.UI.Text.UnderlineType | ||
-include Windows.UI.Xaml.Media.Animation.ConditionallyIndependentlyAnimatableAttribute | ||
</CsWinRTFilters> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<DefineConstants>TRACE;MANUAL_IUNKNOWN,UAC_VERSION_13</DefineConstants> | ||
</PropertyGroup> | ||
|
||
</Project> | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>netstandard2.0;net5.0</TargetFrameworks> | ||
<Platforms>x64;x86</Platforms> | ||
<AssemblyName>Microsoft.Windows.SDK.NET</AssemblyName> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" /> | ||
<ProjectReference Include="..\..\WinRT.Runtime\WinRT.Runtime.csproj" /> | ||
<ProjectReference Include="..\..\cswinrt\cswinrt.vcxproj" /> | ||
<InternalsVisibleTo Include="UnitTest" /> | ||
</ItemGroup> | ||
|
||
<PropertyGroup> | ||
<CsWinRTFilters> | ||
-include Windows | ||
# Exclude Windows.UI, Windows.UI.Text, Windows.UI.Xaml per Microsoft.Windows.SDK.WinUI.Contracts NuGet | ||
-include Windows.UI.Popups | ||
-exclude Windows.UI.Colors | ||
-exclude Windows.UI.IColors | ||
-exclude Windows.UI.ColorHelper | ||
-exclude Windows.UI.IColorHelper | ||
#-exclude Windows.UI.Text (must include Windows.UI.Text to work around WinUI nuget issues) | ||
-exclude Windows.UI.Xaml | ||
-exclude Windows.ApplicationModel.Store.Preview | ||
# Allow Windows.UI.Text, Windows.UI.Xaml types used in other namespaces | ||
-include Windows.UI.Text.FontStretch | ||
-include Windows.UI.Text.FontStyle | ||
-include Windows.UI.Text.FontWeight | ||
-include Windows.UI.Text.UnderlineType | ||
-include Windows.UI.Xaml.Media.Animation.ConditionallyIndependentlyAnimatableAttribute | ||
</CsWinRTFilters> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<DefineConstants>TRACE;MANUAL_IUNKNOWN,UAC_VERSION_13</DefineConstants> | ||
</PropertyGroup> | ||
|
||
</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,15 @@ | ||
<Application | ||
x:Class="ObjectLifetimeTests.Lifted.App" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="using:ObjectLifetimeTests.Lifted"> | ||
<Application.Resources> | ||
<ResourceDictionary> | ||
<ResourceDictionary.MergedDictionaries> | ||
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" /> | ||
<!-- Other merged dictionaries here --> | ||
</ResourceDictionary.MergedDictionaries> | ||
<!-- Other app resources here --> | ||
</ResourceDictionary> | ||
</Application.Resources> | ||
</Application> |
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,59 @@ | ||
using Microsoft.UI.Xaml; | ||
using Microsoft.UI.Xaml.Controls; | ||
using Microsoft.UI.Xaml.Controls.Primitives; | ||
using Microsoft.UI.Xaml.Data; | ||
using Microsoft.UI.Xaml.Input; | ||
using Microsoft.UI.Xaml.Media; | ||
using Microsoft.UI.Xaml.Navigation; | ||
using Microsoft.UI.Xaml.Shapes; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Runtime.InteropServices.WindowsRuntime; | ||
using Windows.ApplicationModel; | ||
using Windows.ApplicationModel.Activation; | ||
using Windows.Foundation; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting.AppContainer; | ||
using Windows.Foundation.Collections; | ||
|
||
// To learn more about WinUI, the WinUI project structure, | ||
// and more about our project templates, see: http://aka.ms/winui-project-info. | ||
|
||
namespace ObjectLifetimeTests.Lifted | ||
{ | ||
/// <summary> | ||
/// Provides application-specific behavior to supplement the default Application class. | ||
/// </summary> | ||
public partial class App : Application | ||
{ | ||
/// <summary> | ||
/// Initializes the singleton application object. This is the first line of authored code | ||
/// executed, and as such is the logical equivalent of main() or WinMain(). | ||
/// </summary> | ||
|
||
|
||
public App() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
|
||
/// <summary> | ||
/// Invoked when the application is launched normally by the end user. Other entry points | ||
/// will be used such as when the application is launched to open a specific file. | ||
/// </summary> | ||
/// <param name="args">Details about the launch request and process.</param> | ||
protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args) | ||
{ | ||
Microsoft.VisualStudio.TestPlatform.TestExecutor.UnitTestClient.CreateDefaultUI(); | ||
m_window = new MainWindow(); | ||
m_window.Activate(); | ||
|
||
UITestMethodAttribute.DispatcherQueue = m_window.DispatcherQueue; | ||
|
||
Microsoft.VisualStudio.TestPlatform.TestExecutor.UnitTestClient.Run(Environment.CommandLine); | ||
} | ||
|
||
public MainWindow m_window { get; set; } | ||
} | ||
} |
Oops, something went wrong.