Skip to content
Merged
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
35 changes: 1 addition & 34 deletions build/Uno.UI.Build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -508,40 +508,7 @@
</Target>

<Target Name="ValidatePackage" AfterTargets="BuildNuGetPackage" Condition="'$(BuildingInsideVisualStudio)'==''">
<PropertyGroup>
<PackageNamePrefix>Uno.WinUI</PackageNamePrefix>
<PackageNamePrefix Condition="'$(UNO_UWP_BUILD)'=='true'">Uno.UI</PackageNamePrefix>
<ArtifactsPlatformName>WinUI</ArtifactsPlatformName>
<ArtifactsPlatformName Condition="'$(UNO_UWP_BUILD)'=='true'">UWP</ArtifactsPlatformName>
</PropertyGroup>

<ItemGroup>
<_diffPackage Include="$(PackageNamePrefix)" Other="$(PackageNamePrefix).$(GITVERSION_SemVer).nupkg" />
<_diffPackage Include="$(PackageNamePrefix).Foldable" Other="..\..\..\NugetPackages-Artifacts-generic-$(ArtifactsPlatformName)\vslatest-generic\$(PackageNamePrefix).Foldable.$(GITVERSION_SemVer).nupkg" />
<_diffPackage Include="$(PackageNamePrefix).Lottie" Other="$(PackageNamePrefix).Lottie.$(GITVERSION_SemVer).nupkg" />
<_diffPackage Include="$(PackageNamePrefix).Maps" Other="..\..\..\NugetPackages-Artifacts-generic-$(ArtifactsPlatformName)\vslatest-generic\$(PackageNamePrefix).Maps.$(GITVERSION_SemVer).nupkg" />
<_diffPackage Include="$(PackageNamePrefix).MSAL" Other="$(PackageNamePrefix).MSAL.$(GITVERSION_SemVer).nupkg" />
<_diffPackage Include="$(PackageNamePrefix).Svg" Other="$(PackageNamePrefix).Svg.$(GITVERSION_SemVer).nupkg" />
<!-- <_diffPackage Include="$(PackageNamePrefix).RemoteControl" Other="$(PackageNamePrefix).RemoteControl.$(GITVERSION_SemVer).nupkg" /> -->
<_diffPackage Include="$(PackageNamePrefix).Skia.Gtk" Other="$(PackageNamePrefix).Skia.Gtk.$(GITVERSION_SemVer).nupkg" />
<_diffPackage Include="$(PackageNamePrefix).Runtime.Skia.Gtk" Other="..\..\..\NugetPackages-Artifacts-skia-$(ArtifactsPlatformName)\vslatest-skia\$(PackageNamePrefix).Runtime.Skia.Gtk.$(GITVERSION_SemVer).nupkg" />
<_diffPackage Include="$(PackageNamePrefix).Runtime.Skia.Linux.FrameBuffer" Other="..\..\..\NugetPackages-Artifacts-skia-$(ArtifactsPlatformName)\vslatest-skia\$(PackageNamePrefix).Runtime.Skia.Linux.FrameBuffer.$(GITVERSION_SemVer).nupkg" />
<_diffPackage Include="$(PackageNamePrefix).Skia.Linux.FrameBuffer" Other="$(PackageNamePrefix).Skia.Linux.FrameBuffer.$(GITVERSION_SemVer).nupkg" />
<_diffPackage Include="$(PackageNamePrefix).Skia.Tizen" Other="$(PackageNamePrefix).Skia.Tizen.$(GITVERSION_SemVer).nupkg" />
<_diffPackage Include="$(PackageNamePrefix).Runtime.Skia.Tizen" Other="..\..\..\NugetPackages-Artifacts-skia-$(ArtifactsPlatformName)\vslatest-skia\$(PackageNamePrefix).Runtime.Skia.Tizen.$(GITVERSION_SemVer).nupkg" />
<_diffPackage Include="$(PackageNamePrefix).Skia.Wpf" Other="$(PackageNamePrefix).Skia.Wpf.$(GITVERSION_SemVer).nupkg" />
<_diffPackage Include="$(PackageNamePrefix).Runtime.Skia.Wpf" Other="..\..\..\NugetPackages-Artifacts-skia-$(ArtifactsPlatformName)\vslatest-skia\$(PackageNamePrefix).Runtime.Skia.Wpf.$(GITVERSION_SemVer).nupkg" />
<_diffPackage Include="$(PackageNamePrefix).XamlHost" Other="$(PackageNamePrefix).XamlHost.$(GITVERSION_SemVer).nupkg" />
<_diffPackage Include="$(PackageNamePrefix).XamlHost.Skia.Wpf" Other="$(PackageNamePrefix).XamlHost.Skia.Wpf.$(GITVERSION_SemVer).nupkg" />
<_diffPackage Include="$(PackageNamePrefix).WebAssembly" Other="$(PackageNamePrefix).WebAssembly.$(GITVERSION_SemVer).nupkg" />
<_diffPackage Include="$(PackageNamePrefix).Runtime.WebAssembly" Other="..\..\..\NugetPackages-Artifacts-generic-$(ArtifactsPlatformName)\vslatest-generic\$(PackageNamePrefix).Runtime.WebAssembly.$(GITVERSION_SemVer).nupkg" />
<_diffPackage Include="Uno.Foundation.Logging" Other="Uno.Foundation.Logging.$(GITVERSION_SemVer).nupkg" />
<_diffPackage Include="Uno.Foundation.Runtime.WebAssembly" Other="..\..\..\NugetPackages-Artifacts-wasm-$(ArtifactsPlatformName)\vslatest-wasm\Uno.Foundation.Runtime.WebAssembly.$(GITVERSION_SemVer).nupkg" />
<_diffPackage Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" Other="Uno.UI.Adapter.Microsoft.Extensions.Logging.$(GITVERSION_SemVer).nupkg" />
</ItemGroup>

<Exec Command="dotnet tool install --tool-path $(MSBuildThisFileDirectory)\tools Uno.PackageDiff --version 1.1.0-dev.14" IgnoreExitCode="true" />
<Exec Command="$(MSBuildThisFileDirectory)\tools\generatepkgdiff.exe --base=%(_diffPackage.Identity) --other=%(_diffPackage.Other) --diffignore=PackageDiffIgnore.xml --outfile=$(OutputDir)\ApiDiff.%(_diffPackage.Identity).$(GITVERSION_SemVer).md" />
<!-- disable breaking changes validation on release branch -->
</Target>

<Target Name="ValidatePackageReferenceAPI" AfterTargets="BuildNuGetPackage">
Expand Down
6 changes: 5 additions & 1 deletion build/uno.winui.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<Import Project="../uno.winui.common.props" Condition="'$(WindowsAppSDKWinUI)'!='true'" />
<!--
Note that WinUI cannot be detected in properties or imports, as the nuget props
import from nuget packages cannot be controlled.
-->
<Import Project="../uno.winui.common.props" />

</Project>
4 changes: 2 additions & 2 deletions build/uno.winui.single-project.targets
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
</ItemGroup>

<Choose>
<When Condition="'$(WindowsAppSDKWinUI)'!='true'">
<When Condition="'$(_UnoIsWinAppSDKDefined)'!='true'">
<!-- IDE capabilities -->

<!-- Sync with https://github.com/dotnet/maui/blob/ffab30545ac146710a9ee61138be33e52ca4b326/src/Templates/src/templates/maui-mobile/Directory.Build.targets -->
Expand Down Expand Up @@ -148,7 +148,7 @@
</When>
</Choose>

<Target Name="_RemoveRoslynUnoSourceGenerationWinUI" BeforeTargets="CoreCompile;XamlPreCompile" Condition="'$(WindowsAppSDKWinUI)'=='true'">
<Target Name="_RemoveRoslynUnoSourceGenerationWinUI" BeforeTargets="CoreCompile;XamlPreCompile" Condition="'$(_UnoIsWinAppSDKDefined)'=='true'">
<!---
Remove uno source generators when building under WinAppSDK
-->
Expand Down
13 changes: 9 additions & 4 deletions build/uno.winui.targets
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<PropertyGroup>

<!-- Wrap WinAppSDK detection until a stable property can be used -->
<_UnoIsWinAppSDKDefined>false</_UnoIsWinAppSDKDefined>
<_UnoIsWinAppSDKDefined Condition="'$(WindowsAppSDKWinUI)'=='true' or '$(UseWinUITools)'=='true'">true</_UnoIsWinAppSDKDefined>

<_IsUnoWinUIPackage>$(MSBuildThisFile.ToLower().Equals('uno.winui.targets'))</_IsUnoWinUIPackage>
</PropertyGroup>

<Import Project="../uno.winui.common.targets" Condition="'$(WindowsAppSDKWinUI)'!='true'" />
<Import Project="../uno.winui.cross-runtime.targets" Condition="'$(WindowsAppSDKWinUI)'!='true'" />
<Import Project="../uno.winui.common.targets" Condition="'$(_UnoIsWinAppSDKDefined)'!='true'" />
<Import Project="../uno.winui.cross-runtime.targets" Condition="'$(_UnoIsWinAppSDKDefined)'!='true'" />
<Import Project="../uno.winui.single-project.targets" />
<Import Project="../uno.winui.runtime-replace.targets" Condition="'$(WindowsAppSDKWinUI)'!='true'" />
<Import Project="../uno.winui.winappsdk.targets" Condition="'$(WindowsAppSDKWinUI)'=='true'" />
<Import Project="../uno.winui.runtime-replace.targets" Condition="'$(_UnoIsWinAppSDKDefined)'!='true'" />
<Import Project="../uno.winui.winappsdk.targets" Condition="'$(_UnoIsWinAppSDKDefined)'=='true'" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<UnoUIUseRoslynSourceGenerators Condition="'$(UnoUIUseRoslynSourceGenerators)'==''">false</UnoUIUseRoslynSourceGenerators>

<ShouldRunGenerator>true</ShouldRunGenerator>
<ShouldRunGenerator Condition="'$(WindowsAppSDKWinUI)'=='true' or $(TargetFramework.StartsWith('uap10.0'))">false</ShouldRunGenerator>
<ShouldRunGenerator Condition="'$(_UnoIsWinAppSDKDefined)'=='true' or $(TargetFramework.StartsWith('uap10.0'))">false</ShouldRunGenerator>

<!--
MSBuild below 17.0 implies C# 7.3 or below, which does not support lambda parameters shadowing (https://github.com/dotnet/csharplang/blob/main/meetings/2019/LDM-2019-01-16.md).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,85 @@ private async Task<RawBitmap> TakeScreenshot(FrameworkElement SUT)
}
#endif

[TestMethod]
public async Task When_SelectedItem_TwoWay_Binding_Clear()
{
var root = new Grid();

var comboBox = new ComboBox();

root.Children.Add(comboBox);

comboBox.SetBinding(ComboBox.ItemsSourceProperty, new Binding { Path = new("Items") });
comboBox.SetBinding(ComboBox.SelectedItemProperty, new Binding { Path = new("Item"), Mode = BindingMode.TwoWay });

WindowHelper.WindowContent = root;

var dc = new TwoWayBindingClearViewModel();
root.DataContext = dc;

await WindowHelper.WaitForIdle();

dc.Dispose();
root.DataContext = null;

Assert.AreEqual(1, dc.ItemGetCount);
Assert.AreEqual(1, dc.ItemSetCount);
}

public sealed class TwoWayBindingClearViewModel : IDisposable
{
public enum Themes
{
Invalid,
Day,
Night
}

public TwoWayBindingClearViewModel()
{
_item = Items[0];
}

public Themes[] Items { get; } = new Themes[] { Themes.Day, Themes.Night };
private Themes _item;
private bool _isDisposed;
public Themes Item
{
get
{
ItemGetCount++;

if (_isDisposed)
{
return Themes.Invalid;
}

return _item;
}
set
{
ItemSetCount++;

if (_isDisposed)
{
_item = Themes.Invalid;
return;
}

_item = value;
}
}

public int ItemGetCount { get; private set; }
public int ItemSetCount { get; private set; }

public void Dispose()
{
_isDisposed = true;
}
}

public class TwoWayBindingItem : System.ComponentModel.INotifyPropertyChanged
{
private int _selectedNumber;
Expand Down Expand Up @@ -928,6 +1007,8 @@ protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
}

}


#if __IOS__
#region "Helper classes for the iOS Modal Page (UIModalPresentationStyle.pageSheet)"
public partial class MultiFrame : Grid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ public async Task When_Animate()
await target.GetValue(ct, 3);
await Task.Yield();

target.History.Should().BeEquivalentTo(v1, v2, v3);
// v3 is repeated because the target property is not a DependencyProperty
// and no deduplication happens in the binding engine.
target.History.Should().BeEquivalentTo(v1, v2, v3, v3);
sut.State.Should().Be(Timeline.TimelineState.Filling);
}

Expand Down Expand Up @@ -147,7 +149,9 @@ public async Task When_PauseResume()
await target.GetValue(ct, 3);
await Task.Yield();

target.History.Should().BeEquivalentTo(v1, v2, v3);
// v3 is repeated because the target property is not a DependencyProperty
// and no deduplication happens in the binding engine.
target.History.Should().BeEquivalentTo(v1, v2, v3, v3);
sut.State.Should().Be(Timeline.TimelineState.Filling);
}

Expand Down Expand Up @@ -178,7 +182,9 @@ public async Task When_RepeatCount()
await target.GetValue(ct, 9);
await Task.Yield();

target.History.Should().BeEquivalentTo(v1, v2, v3, v1, v2, v3, v1, v2, v3);
// v3 is repeated because the target property is not a DependencyProperty
// and no deduplication happens in the binding engine.
target.History.Should().BeEquivalentTo(v1, v2, v3, v1, v2, v3, v1, v2, v3, v3);
sut.State.Should().Be(Timeline.TimelineState.Filling);
}

Expand Down
Loading