Skip to content

Commit

Permalink
feat: Adjust for WinUI 3.0 Preview 1 bits
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromelaban committed May 26, 2020
1 parent ec6631a commit 91b1576
Show file tree
Hide file tree
Showing 27 changed files with 216 additions and 11 deletions.
1 change: 1 addition & 0 deletions build/uno.winui.targets
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
-->
<PropertyGroup>
<UnoDefineConstants>$(UnoDefineConstants);HAS_UNO</UnoDefineConstants>
<UnoDefineConstants Condition="'$(MSBuildThisFile)'=='uno.winui.targets'">$(UnoDefineConstants);HAS_UNO_WINUI</UnoDefineConstants>
<UnoDefineConstants>$(UnoDefineConstants);UNO_HAS_FRAMEWORKELEMENT_MEASUREOVERRIDE</UnoDefineConstants>
<UnoDefineConstants>$(UnoDefineConstants);UNO_HAS_NO_IDEPENDENCYOBJECT</UnoDefineConstants>
</PropertyGroup>
Expand Down
6 changes: 6 additions & 0 deletions src/SamplesApp/SamplesApp.Shared/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Uno.Logging;

#if HAS_UNO_WINUI
using LaunchActivatedEventArgs = Microsoft.UI.Xaml.LaunchActivatedEventArgs;
#else
using LaunchActivatedEventArgs = Windows.ApplicationModel.Activation.LaunchActivatedEventArgs;
#endif

namespace SamplesApp
{
/// <summary>
Expand Down
8 changes: 8 additions & 0 deletions src/SamplesApp/UITests.Shared/ItemExclusions.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8" ?>
<Project>
<ItemGroup Condition="'$(UNO_UWP_BUILD)'!='true'">
<Page Remove="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\MapPresenter\**" />
<Compile Remove="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\MapPresenter\**" />
<None Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\MapPresenter\**" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
#pragma warning disable CS0105 // Using directive appeared previously in this namespace
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
Expand Down
4 changes: 4 additions & 0 deletions src/SamplesApp/UITests.Shared/UITests.Shared.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -5749,4 +5749,8 @@
<DependentUpon>EventsSequences.xaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)ItemExclusions.props" />
</ItemGroup>
<Import Project="ItemExclusions.props" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Windows.UI.Xaml;
using SamplesApp.Windows_UI_Xaml_Controls.WebView;
using Windows.UI.Xaml.Controls;
using Windows.Web.Http;
using System.Net.Http;

namespace Uno.UI.Samples.Content.UITests.WebView
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
var replacedNuget = @"
<PackageReference Include=""Microsoft.WinUI"">
<Version>3.0.0-alpha.200210.0</Version>
<Version>3.0.0-preview1.200515.3</Version>
</PackageReference>
<PackageReference Include=""Microsoft.NETCore.UniversalWindowsPlatform"">";
Expand All @@ -177,6 +177,8 @@
{
s = s
.Replace("Include=\"Uno.UI", "Include=\"Uno.WinUI")
.Replace("e.PreviousExecutionState", "e.UWPLaunchActivatedEventArgs.PreviousExecutionState")
.Replace("e.PrelaunchActivated", "e.UWPLaunchActivatedEventArgs.PrelaunchActivated")
.Replace("Windows.UI.Xaml", "Microsoft.UI.Xaml");
var replacedLogging = @"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,10 @@ private static void GenerateDependencyObjectImplementation(IndentedStringBuilder
builder.AppendLineInvariant(@"private DependencyObjectStore __storeBackingField;");
builder.AppendLineInvariant(@"public Windows.UI.Core.CoreDispatcher Dispatcher => Windows.UI.Core.CoreDispatcher.Main;");

builder.AppendLineInvariant(@"#if HAS_UNO_WINUI");
builder.AppendLineInvariant(@"public global::Microsoft.System.DispatcherQueue DispatcherQueue => global::Microsoft.System.DispatcherQueue.GetForCurrentThread();");
builder.AppendLineInvariant(@"#endif");

using (builder.BlockInvariant($"private DependencyObjectStore __Store"))
{
using (builder.BlockInvariant($"get"))
Expand Down
4 changes: 2 additions & 2 deletions src/Uno.UI.Tests.Performance/Uno.UI.Tests.Performance.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<DefineConstants>TRACE;DEBUG;HAS_UMBRELLA_BINDING;IS_UNIT_TESTS;HAS_GEOCOORDINATE_WATCHER;HAS_GEOCOORDINATE;HAS_COMPILED_REGEX;HAS_ISTORAGEFILE;HAS_SEMAPHORE;HAS_FILE_IO;IS_UNO;HAS_CRIPPLEDREFLECTION;NET46</DefineConstants>
<DefineConstants>$(DefineConstants);TRACE;DEBUG;HAS_UMBRELLA_BINDING;IS_UNIT_TESTS;HAS_GEOCOORDINATE_WATCHER;HAS_GEOCOORDINATE;HAS_COMPILED_REGEX;HAS_ISTORAGEFILE;HAS_SEMAPHORE;HAS_FILE_IO;IS_UNO;HAS_CRIPPLEDREFLECTION;NET46</DefineConstants>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<DefineConstants>TRACE;HAS_UMBRELLA_BINDING;IS_UNIT_TESTS;HAS_GEOCOORDINATE_WATCHER;HAS_GEOCOORDINATE;HAS_COMPILED_REGEX;HAS_ISTORAGEFILE;HAS_SEMAPHORE;HAS_FILE_IO;IS_UNO;HAS_CRIPPLEDREFLECTION</DefineConstants>
<DefineConstants>$(DefineConstants);TRACE;HAS_UMBRELLA_BINDING;IS_UNIT_TESTS;HAS_GEOCOORDINATE_WATCHER;HAS_GEOCOORDINATE;HAS_COMPILED_REGEX;HAS_ISTORAGEFILE;HAS_SEMAPHORE;HAS_FILE_IO;IS_UNO;HAS_CRIPPLEDREFLECTION</DefineConstants>
</PropertyGroup>

<ItemGroup>
Expand Down
6 changes: 5 additions & 1 deletion src/Uno.UI.Tests/App/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
#if HAS_UNO_WINUI
using LaunchActivatedEventArgs = Microsoft.UI.Xaml.LaunchActivatedEventArgs;
#else
using LaunchActivatedEventArgs = Windows.ApplicationModel.Activation.LaunchActivatedEventArgs;
#endif

namespace UnitTestsApp
{
Expand Down
4 changes: 2 additions & 2 deletions src/Uno.UI.Tests/Uno.UI.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<DefineConstants>TRACE;DEBUG;HAS_UMBRELLA_BINDING;IS_UNIT_TESTS;HAS_GEOCOORDINATE_WATCHER;HAS_GEOCOORDINATE;HAS_COMPILED_REGEX;HAS_ISTORAGEFILE;HAS_SEMAPHORE;HAS_FILE_IO;IS_UNO;HAS_CRIPPLEDREFLECTION;NET46</DefineConstants>
<DefineConstants>$(DefineConstants);TRACE;DEBUG;HAS_UMBRELLA_BINDING;IS_UNIT_TESTS;HAS_GEOCOORDINATE_WATCHER;HAS_GEOCOORDINATE;HAS_COMPILED_REGEX;HAS_ISTORAGEFILE;HAS_SEMAPHORE;HAS_FILE_IO;IS_UNO;HAS_CRIPPLEDREFLECTION;NET46</DefineConstants>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<DefineConstants>TRACE;HAS_UMBRELLA_BINDING;IS_UNIT_TESTS;HAS_GEOCOORDINATE_WATCHER;HAS_GEOCOORDINATE;HAS_COMPILED_REGEX;HAS_ISTORAGEFILE;HAS_SEMAPHORE;HAS_FILE_IO;IS_UNO;HAS_CRIPPLEDREFLECTION</DefineConstants>
<DefineConstants>$(DefineConstants);TRACE;HAS_UMBRELLA_BINDING;IS_UNIT_TESTS;HAS_GEOCOORDINATE_WATCHER;HAS_GEOCOORDINATE;HAS_COMPILED_REGEX;HAS_ISTORAGEFILE;HAS_SEMAPHORE;HAS_FILE_IO;IS_UNO;HAS_CRIPPLEDREFLECTION</DefineConstants>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Microsoft.UI.Xaml.Controls
{
public class NumberBoxValueChangedEventArgs
public partial class NumberBoxValueChangedEventArgs
{
internal NumberBoxValueChangedEventArgs(double oldValue, double newValue)
{
Expand Down
6 changes: 6 additions & 0 deletions src/Uno.UI/UI/Xaml/Application.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
using Windows.Foundation.Metadata;
using Windows.UI.Xaml.Controls.Primitives;

#if HAS_UNO_WINUI
using LaunchActivatedEventArgs = Microsoft.UI.Xaml.LaunchActivatedEventArgs;
#else
using LaunchActivatedEventArgs = Windows.ApplicationModel.Activation.LaunchActivatedEventArgs;
#endif

namespace Windows.UI.Xaml
{
public partial class Application
Expand Down
6 changes: 6 additions & 0 deletions src/Uno.UI/UI/Xaml/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
using Windows.ApplicationModel.Core;
using Windows.ApplicationModel;

#if HAS_UNO_WINUI
using LaunchActivatedEventArgs = Microsoft.UI.Xaml.LaunchActivatedEventArgs;
#else
using LaunchActivatedEventArgs = Windows.ApplicationModel.Activation.LaunchActivatedEventArgs;
#endif

namespace Windows.UI.Xaml
{
public partial class Application
Expand Down
6 changes: 6 additions & 0 deletions src/Uno.UI/UI/Xaml/Application.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
using Uno.Extensions;
using Microsoft.Extensions.Logging;

#if HAS_UNO_WINUI
using LaunchActivatedEventArgs = Microsoft.UI.Xaml.LaunchActivatedEventArgs;
#else
using LaunchActivatedEventArgs = Windows.ApplicationModel.Activation.LaunchActivatedEventArgs;
#endif

namespace Windows.UI.Xaml
{
[Register("UnoAppDelegate")]
Expand Down
6 changes: 6 additions & 0 deletions src/Uno.UI/UI/Xaml/Application.macOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
using System.Linq;
using Microsoft.Extensions.Logging;

#if HAS_UNO_WINUI
using LaunchActivatedEventArgs = Microsoft.UI.Xaml.LaunchActivatedEventArgs;
#else
using LaunchActivatedEventArgs = Windows.ApplicationModel.Activation.LaunchActivatedEventArgs;
#endif

namespace Windows.UI.Xaml
{
[Register("UnoAppDelegate")]
Expand Down
6 changes: 6 additions & 0 deletions src/Uno.UI/UI/Xaml/Application.wasm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
using System.Collections.Specialized;
using Uno.Helpers;

#if HAS_UNO_WINUI
using LaunchActivatedEventArgs = Microsoft.UI.Xaml.LaunchActivatedEventArgs;
#else
using LaunchActivatedEventArgs = Windows.ApplicationModel.Activation.LaunchActivatedEventArgs;
#endif

namespace Windows.UI.Xaml
{
public partial class Application
Expand Down
7 changes: 7 additions & 0 deletions src/Uno.UI/UI/Xaml/Controls/Control/Control.cs
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,7 @@ public Brush BorderBrush

#endregion

#if !HAS_UNO_WINUI
#region FocusState DependencyProperty

public FocusState FocusState
Expand Down Expand Up @@ -640,6 +641,12 @@ public bool IsTabStop
)
);
#endregion
#else
private protected override void OnIsTabStopChanged(bool oldValue, bool newValue)
{
OnIsFocusableChanged();
}
#endif

internal protected override void OnDataContextChanged(DependencyPropertyChangedEventArgs e)
{
Expand Down
5 changes: 5 additions & 0 deletions src/Uno.UI/UI/Xaml/Controls/WebView/WebView.wasm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ public async Task<string> InvokeScriptAsync(CancellationToken ct, string script,
{
throw new NotSupportedException();
}

public async Task<string> InvokeScriptAsync(string script, string[] arguments)
{
throw new NotSupportedException();
}
}
}

3 changes: 3 additions & 0 deletions src/Uno.UI/UI/Xaml/DependencyObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ public partial interface DependencyObject
{
CoreDispatcher Dispatcher { get; }

#if HAS_UNO_WINUI
public global::Microsoft.System.DispatcherQueue DispatcherQueue { get; }
#endif
object GetValue(DependencyProperty dp);

void SetValue(DependencyProperty dp, object value);
Expand Down
25 changes: 25 additions & 0 deletions src/Uno.UI/UI/Xaml/LaunchActivatedEventArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#nullable enable

#if HAS_UNO_WINUI
using Windows.ApplicationModel.Activation;

namespace Microsoft.UI.Xaml
{
public sealed partial class LaunchActivatedEventArgs
{
internal LaunchActivatedEventArgs() : this(ActivationKind.Launch, null)
{
}

internal LaunchActivatedEventArgs(ActivationKind kind, string? arguments)
{
Arguments = arguments;
UWPLaunchActivatedEventArgs = new Windows.ApplicationModel.Activation.LaunchActivatedEventArgs(kind, arguments);
}

public string? Arguments { get; }

public Windows.ApplicationModel.Activation.LaunchActivatedEventArgs UWPLaunchActivatedEventArgs { get; }
}
}
#endif
44 changes: 44 additions & 0 deletions src/Uno.UI/UI/Xaml/UIElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -572,5 +572,49 @@ public IList<KeyboardAccelerator> KeyboardAccelerators
propertyType: typeof(IList<KeyboardAccelerator>),
ownerType: typeof(UIElement),
typeMetadata: new PropertyMetadata(null));

#if HAS_UNO_WINUI
#region FocusState DependencyProperty

public FocusState FocusState
{
get { return (FocusState)GetValue(FocusStateProperty); }
internal set { SetValue(FocusStateProperty, value); }
}

public static DependencyProperty FocusStateProperty =
DependencyProperty.Register(
"FocusState",
typeof(FocusState),
typeof(UIElement),
new PropertyMetadata(
(FocusState)FocusState.Unfocused
)
);

#endregion

#region IsTabStop DependencyProperty

public bool IsTabStop
{
get { return (bool)GetValue(IsTabStopProperty); }
set { SetValue(IsTabStopProperty, value); }
}

public static DependencyProperty IsTabStopProperty =
DependencyProperty.Register(
"IsTabStop",
typeof(bool),
typeof(UIElement),
new PropertyMetadata(
(bool)true,
(s, e) => ((Control)s)?.OnIsTabStopChanged((bool)e.OldValue, (bool)e.NewValue)
)
);
#endregion

private protected virtual void OnIsTabStopChanged(bool oldValue, bool newValue) { }
#endif
}
}
28 changes: 28 additions & 0 deletions src/Uno.UI/UI/Xaml/WindowActivatedEventArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#if HAS_UNO_WINUI
using System;
using Windows.Foundation;
using Windows.Foundation.Metadata;
using Windows.UI.Core;

namespace Microsoft.UI.Xaml
{
public sealed partial class WindowActivatedEventArgs
{
internal WindowActivatedEventArgs(CoreWindowActivationState windowActivationState)
{
WindowActivationState = windowActivationState;
}

public bool Handled
{
get;
set;
}

public CoreWindowActivationState WindowActivationState
{
get;
}
}
}
#endif
27 changes: 27 additions & 0 deletions src/Uno.UI/UI/Xaml/WindowSizeChangedEventArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#if HAS_UNO_WINUI
using System;
using Windows.Foundation;
using Windows.Foundation.Metadata;

namespace Microsoft.UI.Xaml
{
public sealed partial class WindowSizeChangedEventArgs
{
public WindowSizeChangedEventArgs(Size newSize)
{
Size = newSize;
}

public bool Handled
{
get;
set;
}

public Size Size
{
get;
}
}
}
#endif
4 changes: 4 additions & 0 deletions src/Uno.UI/Uno.UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,10 @@
</ProjectReference>
</ItemGroup>

<ItemGroup>
<UpToDateCheckInput Remove="UI\Xaml\LaunchActivatedEventArgs.cs" />
</ItemGroup>

<ItemGroup>
<None Update="BaseActivity.Callbacks.Implementation.Android.tt">
<Generator>TextTemplatingFileGenerator</Generator>
Expand Down
Loading

0 comments on commit 91b1576

Please sign in to comment.