diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bdc07552f..e7f5919b7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,7 +17,7 @@ on: merge_group: env: - DOTNET_VERSION: '9.0.310' # Only used by jobs that cannot access global.json (no checkout/artifact-only jobs) + DOTNET_VERSION: '10.0.401' # Only used by jobs that cannot access global.json (no checkout/artifact-only jobs) ENABLE_DIAGNOSTICS: true MSBUILD_VERBOSITY: normal #COREHOST_TRACE: 1 @@ -88,7 +88,7 @@ jobs: fail-fast: false # prevent one matrix pipeline from being cancelled if one fails, we want them all to run to completion. matrix: winui: [2, 3] - multitarget: ['uwp', 'wasdk', 'wasm', 'wpf', 'linuxgtk', 'macos', 'ios', 'android'] + multitarget: ['uwp', 'wasdk', 'wasm', 'wpf', 'win32', 'linux', 'macos', 'ios', 'android'] exclude: # WinUI 2 not supported on wasdk - winui: 2 @@ -96,6 +96,18 @@ jobs: # WinUI 3 not supported on uwp - winui: 3 multitarget: uwp + # wpf is the Uno 5 Skia WPF head, which Uno 6 replaced with win32 + - winui: 3 + multitarget: wpf + # win32 is the Uno 6 Skia desktop head, which has no Uno 5 equivalent + - winui: 2 + multitarget: win32 + include: + # On WinUI 3 the Uno.Sdk head replaces the classic Wasm head, so it rides on the + # existing wasm job as a flag rather than a fake entry in the multitarget axis. + - winui: 3 + multitarget: wasm + unoSdkHead: true # Steps represent a sequence of tasks that will be executed as part of the job steps: @@ -133,9 +145,9 @@ jobs: run: dotnet tool restore - name: Run Uno Check to Install Dependencies - if: ${{ matrix.multitarget != 'wasdk' && matrix.multitarget != 'linuxgtk' && matrix.multitarget != 'wpf' }} + if: ${{ matrix.multitarget != 'wasdk' && matrix.multitarget != 'linux' && matrix.multitarget != 'wpf' && matrix.multitarget != 'win32' && !matrix.unoSdkHead }} run: > - dotnet tool run uno-check + dotnet tool run uno-check --ci --target ${{ matrix.multitarget }} --fix @@ -146,18 +158,26 @@ jobs: --skip vswin --verbose + # The Uno.Sdk head builds desktop/browserwasm/android (iOS is filtered on + # Windows). Install the matching workloads directly instead of uno-check. + - name: Install .NET workloads (Uno.Sdk head) + if: ${{ matrix.unoSdkHead }} + run: dotnet workload install wasm-tools android ios maui + - name: Add msbuild to PATH uses: microsoft/setup-msbuild@v2 with: vs-version: '[17.9,)' # Generate full solution with all projects (sample gallery heads, components, tests) + # The Uno.Sdk head also covers Windows desktop, so it asks for win32 alongside wasm. - name: Generate solution with ${{ matrix.multitarget }} gallery, components and tests working-directory: ./ - run: powershell -version 5.1 -command "./tooling/GenerateAllSolution.ps1 -MultiTargets ${{ matrix.multitarget }} ${{ env.ENABLE_DIAGNOSTICS == 'true' && ' -UseDiagnostics' || '' }} -WinUIMajorVersion ${{ matrix.winui }}" -ErrorAction Stop + run: powershell -version 5.1 -command "./tooling/GenerateAllSolution.ps1 -MultiTargets ${{ matrix.multitarget }}${{ matrix.unoSdkHead && ',win32 -IncludeUnoSdkHead' || '' }} ${{ env.ENABLE_DIAGNOSTICS == 'true' && ' -UseDiagnostics' || '' }} -WinUIMajorVersion ${{ matrix.winui }}" -ErrorAction Stop # Build solution - name: MSBuild + if: ${{ !matrix.unoSdkHead }} run: > msbuild.exe /restore /nowarn:MSB4011 /p:Configuration=Release @@ -166,6 +186,12 @@ jobs: /v:${{ env.MSBUILD_VERBOSITY }} CommunityToolkit.AllComponents.sln + # The Uno.Sdk head is a single project covering desktop/browserwasm/android + # (iOS is filtered on Windows); build it directly with dotnet. + - name: Build Uno.Sdk head + if: ${{ matrix.unoSdkHead }} + run: dotnet build tooling/ProjectHeads/AllComponents/Uno/CommunityToolkit.App.Uno.csproj -p:Configuration=Release ${{ env.ENABLE_DIAGNOSTICS == 'true' && '/bl' || '' }} + # Run tests - name: Setup VSTest Path uses: darenm/setup-vstest@3a16d909a1f3bbc65b52f8270d475d905e7d3e44 @@ -435,7 +461,7 @@ jobs: --api-key ${{ secrets.NUGET_PACKAGE_PUSH_TOKEN }} --skip-duplicate - wasm-linux: + uno-linux: runs-on: ubuntu-latest steps: @@ -450,6 +476,12 @@ jobs: with: global-json-file: global.json + # iOS/maccatalyst aren't installable on Linux (Uno.Sdk filters those TFMs + # there). android + wasm-tools are both required: even a single-TFM build + # restores all of the head's TargetFrameworks, validating net10.0-android. + - name: Install .NET workloads + run: dotnet workload install android wasm-tools + - name: .NET Info (if diagnostics) if: ${{ env.ENABLE_DIAGNOSTICS == 'true' }} run: dotnet --info @@ -458,31 +490,26 @@ jobs: - name: Restore dotnet tools run: dotnet tool restore - - name: Enable WASM TargetFrameworks - shell: pwsh - working-directory: ./${{ env.MULTI_TARGET_DIRECTORY }} - run: ./UseTargetFrameworks.ps1 wasm - + # Generate the full solution with the Uno.Sdk gallery head, components and tests - name: Generate solution shell: pwsh working-directory: ./ - run: ./tooling/GenerateAllSolution.ps1${{ env.ENABLE_DIAGNOSTICS == 'true' && ' -UseDiagnostics' || '' }} + run: ./tooling/GenerateAllSolution.ps1 -MultiTargets wasm,linux -IncludeUnoSdkHead -WinUIMajorVersion 3${{ env.ENABLE_DIAGNOSTICS == 'true' && ' -UseDiagnostics' || '' }} - - name: Install ninja for WASM native dependencies - run: sudo apt-get install ninja-build + - name: Build Uno head (browserwasm) + shell: pwsh + working-directory: ./ + run: dotnet build tooling/ProjectHeads/AllComponents/Uno/CommunityToolkit.App.Uno.csproj -f net10.0-browserwasm -p:Configuration=Release - # Issue with Comment Links currently, see: https://github.com/mrlacey/CommentLinks/issues/38 - # See launch.json configuration file for analogous command we're emulating here to build LINK: ../../.vscode/launch.json:CommunityToolkit.App.Wasm.csproj - - name: dotnet build - working-directory: ./${{ env.HEADS_DIRECTORY }}/AllComponents/Wasm/ - run: dotnet build /r /bl -v:${{ env.MSBUILD_VERBOSITY }} - - # TODO: Do we want to run tests here? Can we do that on linux easily? + - name: Build Uno head (desktop) + shell: pwsh + working-directory: ./ + run: dotnet build tooling/ProjectHeads/AllComponents/Uno/CommunityToolkit.App.Uno.csproj -f net10.0-desktop -p:Configuration=Release - name: Artifact - Diagnostic Logs uses: actions/upload-artifact@v4 if: ${{ (env.ENABLE_DIAGNOSTICS == 'true' || env.COREHOST_TRACE != '') && always() }} with: - name: linux-logs + name: uno-linux-logs path: ./**/*.*log diff --git a/components/Animations/src/Expressions/CompositionExtensions.cs b/components/Animations/src/Expressions/CompositionExtensions.cs index 4f508553c..57f182555 100644 --- a/components/Animations/src/Expressions/CompositionExtensions.cs +++ b/components/Animations/src/Expressions/CompositionExtensions.cs @@ -186,7 +186,14 @@ public static void InsertExpressionKeyFrame(this KeyFrameAnimation keyframeAnima { expressionNode.ClearReferenceInfo(); - keyframeAnimation.InsertExpressionKeyFrame(normalizedProgressKey, expressionNode.ToExpressionString(), easing); + if (easing is null) + { + keyframeAnimation.InsertExpressionKeyFrame(normalizedProgressKey, expressionNode.ToExpressionString()); + } + else + { + keyframeAnimation.InsertExpressionKeyFrame(normalizedProgressKey, expressionNode.ToExpressionString(), easing); + } expressionNode.SetAllParameters(keyframeAnimation); } diff --git a/components/Animations/src/MultiTarget.props b/components/Animations/src/MultiTarget.props index c780abffe..aa297d836 100644 --- a/components/Animations/src/MultiTarget.props +++ b/components/Animations/src/MultiTarget.props @@ -4,6 +4,6 @@ MultiTarget is a custom property that indicates which target a project is designed to be built for / run on. Used to create project references, generate solution files, enable/disable TargetFrameworks, and build nuget packages. --> - uwp;wasdk;wpf;wasm;linuxgtk;macos;ios;android; + uwp;wasdk;wpf;win32;wasm;linux;macos;ios;android; diff --git a/components/Animations/src/Xaml/Abstract/Animation{TValue,TKeyFrame}.cs b/components/Animations/src/Xaml/Abstract/Animation{TValue,TKeyFrame}.cs index cc98af6e0..12e845e8d 100644 --- a/components/Animations/src/Xaml/Abstract/Animation{TValue,TKeyFrame}.cs +++ b/components/Animations/src/Xaml/Abstract/Animation{TValue,TKeyFrame}.cs @@ -30,11 +30,14 @@ public TValue? To /// /// Identifies the dependency property. /// + // typeof(TValue?) is only used as dependency property metadata, not for reflective construction. +#pragma warning disable IL2087 public static readonly DependencyProperty ToProperty = DependencyProperty.Register( nameof(To), typeof(TValue?), typeof(Animation), new PropertyMetadata(null)); +#pragma warning restore IL2087 /// /// Gets or sets the optional starting value for the animation. @@ -48,11 +51,14 @@ public TValue? From /// /// Identifies the dependency property. /// + // typeof(TValue?) is only used as dependency property metadata, not for reflective construction. +#pragma warning disable IL2087 public static readonly DependencyProperty FromProperty = DependencyProperty.Register( nameof(From), typeof(TValue?), typeof(Animation), new PropertyMetadata(null)); +#pragma warning restore IL2087 /// /// Gets or sets the optional keyframe collection for the current animation. diff --git a/components/Animations/src/Xaml/Abstract/KeyFrame{TValue,TKeyFrame}.cs b/components/Animations/src/Xaml/Abstract/KeyFrame{TValue,TKeyFrame}.cs index ea5627cec..fbe2fadaa 100644 --- a/components/Animations/src/Xaml/Abstract/KeyFrame{TValue,TKeyFrame}.cs +++ b/components/Animations/src/Xaml/Abstract/KeyFrame{TValue,TKeyFrame}.cs @@ -60,11 +60,14 @@ public TValue? Value /// /// Identifies the dependency property. /// + // typeof(TValue?) is only used as dependency property metadata, not for reflective construction. +#pragma warning disable IL2087 public static readonly DependencyProperty ValueProperty = DependencyProperty.Register( nameof(Value), typeof(TValue?), typeof(KeyFrame), new PropertyMetadata(null)); +#pragma warning restore IL2087 /// /// Gets or sets the optional expression for the current keyframe. diff --git a/components/Behaviors/src/Dependencies.props b/components/Behaviors/src/Dependencies.props index 9da22b46a..d69efd3e0 100644 --- a/components/Behaviors/src/Dependencies.props +++ b/components/Behaviors/src/Dependencies.props @@ -26,6 +26,6 @@ - + diff --git a/components/Behaviors/src/Headers/HeaderBehaviorBase.cs b/components/Behaviors/src/Headers/HeaderBehaviorBase.cs index 57b1c3756..e1eccdf06 100644 --- a/components/Behaviors/src/Headers/HeaderBehaviorBase.cs +++ b/components/Behaviors/src/Headers/HeaderBehaviorBase.cs @@ -184,7 +184,10 @@ private void ScrollViewer_GotFocus(object sender, RoutedEventArgs e) } else { + // Obsolete on WinUI 3/Uno, but required as a fallback where XamlRoot is unavailable (e.g. UWP). +#pragma warning disable CS0618 focusedElement = FocusManager.GetFocusedElement()!; +#pragma warning restore CS0618 } // To prevent Popups (Flyouts...) from triggering the autoscroll, we check if the focused element has a valid parent. diff --git a/components/Behaviors/src/MultiTarget.props b/components/Behaviors/src/MultiTarget.props index b11c19426..7d1e11c3c 100644 --- a/components/Behaviors/src/MultiTarget.props +++ b/components/Behaviors/src/MultiTarget.props @@ -4,6 +4,6 @@ MultiTarget is a custom property that indicates which target a project is designed to be built for / run on. Used to create project references, generate solution files, enable/disable TargetFrameworks, and build nuget packages. --> - uwp;wasdk;wpf;wasm;linuxgtk;macos;ios;android; + uwp;wasdk;wpf;win32;wasm;linux;macos;ios;android; \ No newline at end of file diff --git a/components/Collections/src/MultiTarget.props b/components/Collections/src/MultiTarget.props index b11c19426..7d1e11c3c 100644 --- a/components/Collections/src/MultiTarget.props +++ b/components/Collections/src/MultiTarget.props @@ -4,6 +4,6 @@ MultiTarget is a custom property that indicates which target a project is designed to be built for / run on. Used to create project references, generate solution files, enable/disable TargetFrameworks, and build nuget packages. --> - uwp;wasdk;wpf;wasm;linuxgtk;macos;ios;android; + uwp;wasdk;wpf;win32;wasm;linux;macos;ios;android; \ No newline at end of file diff --git a/components/ColorPicker/src/MultiTarget.props b/components/ColorPicker/src/MultiTarget.props index b11c19426..7d1e11c3c 100644 --- a/components/ColorPicker/src/MultiTarget.props +++ b/components/ColorPicker/src/MultiTarget.props @@ -4,6 +4,6 @@ MultiTarget is a custom property that indicates which target a project is designed to be built for / run on. Used to create project references, generate solution files, enable/disable TargetFrameworks, and build nuget packages. --> - uwp;wasdk;wpf;wasm;linuxgtk;macos;ios;android; + uwp;wasdk;wpf;win32;wasm;linux;macos;ios;android; \ No newline at end of file diff --git a/components/Converters/src/MultiTarget.props b/components/Converters/src/MultiTarget.props index b11c19426..7d1e11c3c 100644 --- a/components/Converters/src/MultiTarget.props +++ b/components/Converters/src/MultiTarget.props @@ -4,6 +4,6 @@ MultiTarget is a custom property that indicates which target a project is designed to be built for / run on. Used to create project references, generate solution files, enable/disable TargetFrameworks, and build nuget packages. --> - uwp;wasdk;wpf;wasm;linuxgtk;macos;ios;android; + uwp;wasdk;wpf;win32;wasm;linux;macos;ios;android; \ No newline at end of file diff --git a/components/Converters/src/TypeToObjectConverter.cs b/components/Converters/src/TypeToObjectConverter.cs index bf0b43edb..b56ff1ecd 100644 --- a/components/Converters/src/TypeToObjectConverter.cs +++ b/components/Converters/src/TypeToObjectConverter.cs @@ -25,7 +25,9 @@ public partial class TypeToObjectConverter : DependencyObject, IValueConverter /// Identifies the property. /// public static readonly DependencyProperty TypeProperty = +#pragma warning disable IL2111 // Uno 7 annotates propertyType for trimming, which flags System.Type's own annotated members DependencyProperty.Register(nameof(Type), typeof(Type), typeof(TypeToObjectConverter), new PropertyMetadata(typeof(object))); +#pragma warning restore IL2111 /// /// Gets or sets the value to be returned when the type of the provided value matches . diff --git a/components/DeveloperTools/src/FocusTracker/FocusTracker.cs b/components/DeveloperTools/src/FocusTracker/FocusTracker.cs index 39feacb29..519fc2a7b 100644 --- a/components/DeveloperTools/src/FocusTracker/FocusTracker.cs +++ b/components/DeveloperTools/src/FocusTracker/FocusTracker.cs @@ -74,7 +74,11 @@ protected override void OnApplyTemplate() private void Start() { // Get currently focused control once when we start +#if WINUI3 + if (XamlRoot != null) +#else if (Windows.Foundation.Metadata.ApiInformation.IsPropertyPresent("Windows.UI.Xaml.UIElement", "XamlRoot") && XamlRoot != null) +#endif { if (FocusManager.GetFocusedElement(XamlRoot) is FrameworkElement element) { @@ -83,7 +87,10 @@ private void Start() } else { + // Obsolete on WinUI 3/Uno, but required as a fallback where XamlRoot is unavailable (e.g. UWP). +#pragma warning disable CS0618 if (FocusManager.GetFocusedElement() is FrameworkElement element) +#pragma warning restore CS0618 { FocusOnControl(element); } diff --git a/components/DeveloperTools/src/MultiTarget.props b/components/DeveloperTools/src/MultiTarget.props index b11c19426..7d1e11c3c 100644 --- a/components/DeveloperTools/src/MultiTarget.props +++ b/components/DeveloperTools/src/MultiTarget.props @@ -4,6 +4,6 @@ MultiTarget is a custom property that indicates which target a project is designed to be built for / run on. Used to create project references, generate solution files, enable/disable TargetFrameworks, and build nuget packages. --> - uwp;wasdk;wpf;wasm;linuxgtk;macos;ios;android; + uwp;wasdk;wpf;win32;wasm;linux;macos;ios;android; \ No newline at end of file diff --git a/components/Extensions/src/Element/FrameworkElementExtensions.RelativeAncestor.cs b/components/Extensions/src/Element/FrameworkElementExtensions.RelativeAncestor.cs index 84930b7d9..167adb9f6 100644 --- a/components/Extensions/src/Element/FrameworkElementExtensions.RelativeAncestor.cs +++ b/components/Extensions/src/Element/FrameworkElementExtensions.RelativeAncestor.cs @@ -54,7 +54,9 @@ public static void SetAncestorType(FrameworkElement obj, Type value) /// Attached for retrieving a parent for the based on the provided in the . /// public static readonly DependencyProperty AncestorTypeProperty = +#pragma warning disable IL2111 // Uno 7 annotates propertyType for trimming, which flags System.Type's own annotated members DependencyProperty.RegisterAttached("AncestorType", typeof(Type), typeof(FrameworkElementExtensions), new PropertyMetadata(null, AncestorType_PropertyChanged)); +#pragma warning restore IL2111 private static void AncestorType_PropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args) { diff --git a/components/Extensions/src/MultiTarget.props b/components/Extensions/src/MultiTarget.props index b11c19426..7d1e11c3c 100644 --- a/components/Extensions/src/MultiTarget.props +++ b/components/Extensions/src/MultiTarget.props @@ -4,6 +4,6 @@ MultiTarget is a custom property that indicates which target a project is designed to be built for / run on. Used to create project references, generate solution files, enable/disable TargetFrameworks, and build nuget packages. --> - uwp;wasdk;wpf;wasm;linuxgtk;macos;ios;android; + uwp;wasdk;wpf;win32;wasm;linux;macos;ios;android; \ No newline at end of file diff --git a/components/Extensions/src/Tree/DependencyObjectExtensions.cs b/components/Extensions/src/Tree/DependencyObjectExtensions.cs index 7bc8d1b90..7a5b41b65 100644 --- a/components/Extensions/src/Tree/DependencyObjectExtensions.cs +++ b/components/Extensions/src/Tree/DependencyObjectExtensions.cs @@ -32,8 +32,8 @@ public static class DependencyObjectExtensions /// The root element. /// The descendant that was found, or . public static T? FindDescendant(this DependencyObject element) -#if HAS_UNO - where T : class, DependencyObject // Note: In Uno, DependencyObject is an interface, background: https://github.com/unoplatform/uno/issues/25 +#if HAS_UNO && WINUI2 + where T : class, DependencyObject // Note: In Uno 5 and older, DependencyObject is an interface, background: https://github.com/unoplatform/uno/issues/25 #else where T : notnull, DependencyObject #endif @@ -64,7 +64,7 @@ public static class DependencyObjectExtensions /// The predicatee to use to match the descendant nodes. /// The descendant that was found, or . public static T? FindDescendant(this DependencyObject element, Func predicate) -#if HAS_UNO +#if HAS_UNO && WINUI2 where T : class, DependencyObject #else where T : notnull, DependencyObject @@ -85,7 +85,7 @@ public static class DependencyObjectExtensions /// The predicatee to use to match the descendant nodes. /// The descendant that was found, or . public static T? FindDescendant(this DependencyObject element, TState state, Func predicate) -#if HAS_UNO +#if HAS_UNO && WINUI2 where T : class, DependencyObject #else where T : notnull, DependencyObject @@ -105,7 +105,7 @@ public static class DependencyObjectExtensions /// The predicatee to use to match the descendant nodes. /// The descendant that was found, or . private static T? FindDescendant(this DependencyObject element, ref TPredicate predicate) -#if HAS_UNO +#if HAS_UNO && WINUI2 where T : class, DependencyObject #else where T : notnull, DependencyObject @@ -158,7 +158,7 @@ public static class DependencyObjectExtensions /// The root element. /// The descendant (or self) that was found, or . public static T? FindDescendantOrSelf(this DependencyObject element) -#if HAS_UNO +#if HAS_UNO && WINUI2 where T : class, DependencyObject #else where T : notnull, DependencyObject @@ -196,7 +196,7 @@ public static class DependencyObjectExtensions /// The predicatee to use to match the descendant nodes. /// The descendant (or self) that was found, or . public static T? FindDescendantOrSelf(this DependencyObject element, Func predicate) -#if HAS_UNO +#if HAS_UNO && WINUI2 where T : class, DependencyObject #else where T : notnull, DependencyObject @@ -220,7 +220,7 @@ public static class DependencyObjectExtensions /// The predicatee to use to match the descendant nodes. /// The descendant (or self) that was found, or . public static T? FindDescendantOrSelf(this DependencyObject element, TState state, Func predicate) -#if HAS_UNO +#if HAS_UNO && WINUI2 where T : class, DependencyObject #else where T : notnull, DependencyObject @@ -284,7 +284,7 @@ public static IEnumerable FindDescendants(this DependencyObjec /// The starting element. /// The ascendant that was found, or . public static T? FindAscendant(this DependencyObject element) -#if HAS_UNO +#if HAS_UNO && WINUI2 where T : class, DependencyObject #else where T : notnull, DependencyObject @@ -316,7 +316,7 @@ public static IEnumerable FindDescendants(this DependencyObjec /// The predicatee to use to match the ascendant nodes. /// The ascendant that was found, or . public static T? FindAscendant(this DependencyObject element, Func predicate) -#if HAS_UNO +#if HAS_UNO && WINUI2 where T : class, DependencyObject #else where T : notnull, DependencyObject @@ -337,7 +337,7 @@ public static IEnumerable FindDescendants(this DependencyObjec /// The predicatee to use to match the ascendant nodes. /// The ascendant that was found, or . public static T? FindAscendant(this DependencyObject element, TState state, Func predicate) -#if HAS_UNO +#if HAS_UNO && WINUI2 where T : class, DependencyObject #else where T : notnull, DependencyObject @@ -357,7 +357,7 @@ public static IEnumerable FindDescendants(this DependencyObjec /// The predicatee to use to match the ascendant nodes. /// The ascendant that was found, or . private static T? FindAscendant(this DependencyObject element, ref TPredicate predicate) -#if HAS_UNO +#if HAS_UNO && WINUI2 where T : class, DependencyObject #else where T : notnull, DependencyObject @@ -406,7 +406,7 @@ public static IEnumerable FindDescendants(this DependencyObjec /// The starting element. /// The ascendant (or self) that was found, or . public static T? FindAscendantOrSelf(this DependencyObject element) -#if HAS_UNO +#if HAS_UNO && WINUI2 where T : class, DependencyObject #else where T : notnull, DependencyObject @@ -444,7 +444,7 @@ public static IEnumerable FindDescendants(this DependencyObjec /// The predicatee to use to match the ascendant nodes. /// The ascendant (or self) that was found, or . public static T? FindAscendantOrSelf(this DependencyObject element, Func predicate) -#if HAS_UNO +#if HAS_UNO && WINUI2 where T : class, DependencyObject #else where T : notnull, DependencyObject @@ -468,7 +468,7 @@ public static IEnumerable FindDescendants(this DependencyObjec /// The predicatee to use to match the ascendant nodes. /// The ascendant (or self) that was found, or . public static T? FindAscendantOrSelf(this DependencyObject element, TState state, Func predicate) -#if HAS_UNO +#if HAS_UNO && WINUI2 where T : class, DependencyObject #else where T : notnull, DependencyObject diff --git a/components/HeaderedControls/src/MultiTarget.props b/components/HeaderedControls/src/MultiTarget.props index b11c19426..7d1e11c3c 100644 --- a/components/HeaderedControls/src/MultiTarget.props +++ b/components/HeaderedControls/src/MultiTarget.props @@ -4,6 +4,6 @@ MultiTarget is a custom property that indicates which target a project is designed to be built for / run on. Used to create project references, generate solution files, enable/disable TargetFrameworks, and build nuget packages. --> - uwp;wasdk;wpf;wasm;linuxgtk;macos;ios;android; + uwp;wasdk;wpf;win32;wasm;linux;macos;ios;android; \ No newline at end of file diff --git a/components/Helpers/src/MultiTarget.props b/components/Helpers/src/MultiTarget.props index b11c19426..7d1e11c3c 100644 --- a/components/Helpers/src/MultiTarget.props +++ b/components/Helpers/src/MultiTarget.props @@ -4,6 +4,6 @@ MultiTarget is a custom property that indicates which target a project is designed to be built for / run on. Used to create project references, generate solution files, enable/disable TargetFrameworks, and build nuget packages. --> - uwp;wasdk;wpf;wasm;linuxgtk;macos;ios;android; + uwp;wasdk;wpf;win32;wasm;linux;macos;ios;android; \ No newline at end of file diff --git a/components/Helpers/src/ThemeListener.cs b/components/Helpers/src/ThemeListener.cs index ecd04b13f..d1337bb65 100644 --- a/components/Helpers/src/ThemeListener.cs +++ b/components/Helpers/src/ThemeListener.cs @@ -69,10 +69,14 @@ public ThemeListener(DispatcherQueue? dispatcherQueue = null) { CurrentTheme = Application.Current.RequestedTheme; +#if WINUI3 + IsHighContrast = _accessible.HighContrast; +#else if (ApiInformation.IsPropertyPresent("Windows.UI.ViewManagement.AccessibilitySettings", "HighContrast")) { IsHighContrast = _accessible.HighContrast; } +#endif DispatcherQueue = dispatcherQueue ?? DispatcherQueue.GetForCurrentThread(); diff --git a/components/LayoutTransformControl/src/MultiTarget.props b/components/LayoutTransformControl/src/MultiTarget.props index b11c19426..7d1e11c3c 100644 --- a/components/LayoutTransformControl/src/MultiTarget.props +++ b/components/LayoutTransformControl/src/MultiTarget.props @@ -4,6 +4,6 @@ MultiTarget is a custom property that indicates which target a project is designed to be built for / run on. Used to create project references, generate solution files, enable/disable TargetFrameworks, and build nuget packages. --> - uwp;wasdk;wpf;wasm;linuxgtk;macos;ios;android; + uwp;wasdk;wpf;win32;wasm;linux;macos;ios;android; \ No newline at end of file diff --git a/components/MetadataControl/src/MultiTarget.props b/components/MetadataControl/src/MultiTarget.props index b11c19426..7d1e11c3c 100644 --- a/components/MetadataControl/src/MultiTarget.props +++ b/components/MetadataControl/src/MultiTarget.props @@ -4,6 +4,6 @@ MultiTarget is a custom property that indicates which target a project is designed to be built for / run on. Used to create project references, generate solution files, enable/disable TargetFrameworks, and build nuget packages. --> - uwp;wasdk;wpf;wasm;linuxgtk;macos;ios;android; + uwp;wasdk;wpf;win32;wasm;linux;macos;ios;android; \ No newline at end of file diff --git a/components/Primitives/src/MultiTarget.props b/components/Primitives/src/MultiTarget.props index b11c19426..7d1e11c3c 100644 --- a/components/Primitives/src/MultiTarget.props +++ b/components/Primitives/src/MultiTarget.props @@ -4,6 +4,6 @@ MultiTarget is a custom property that indicates which target a project is designed to be built for / run on. Used to create project references, generate solution files, enable/disable TargetFrameworks, and build nuget packages. --> - uwp;wasdk;wpf;wasm;linuxgtk;macos;ios;android; + uwp;wasdk;wpf;win32;wasm;linux;macos;ios;android; \ No newline at end of file diff --git a/components/Primitives/src/SwitchPresenter/SwitchConverter.cs b/components/Primitives/src/SwitchPresenter/SwitchConverter.cs index 470ca28b9..9c48adee9 100644 --- a/components/Primitives/src/SwitchPresenter/SwitchConverter.cs +++ b/components/Primitives/src/SwitchPresenter/SwitchConverter.cs @@ -53,7 +53,9 @@ public Type TargetType /// Identifies the property. /// public static readonly DependencyProperty TargetTypeProperty = +#pragma warning disable IL2111 // Uno 7 annotates propertyType for trimming, which flags System.Type's own annotated members DependencyProperty.Register(nameof(TargetType), typeof(Type), typeof(SwitchConverter), new PropertyMetadata(null)); +#pragma warning restore IL2111 /// /// Initializes a new instance of the class. diff --git a/components/Primitives/src/SwitchPresenter/SwitchPresenter.cs b/components/Primitives/src/SwitchPresenter/SwitchPresenter.cs index 9ebc6b6e6..6324cf5da 100644 --- a/components/Primitives/src/SwitchPresenter/SwitchPresenter.cs +++ b/components/Primitives/src/SwitchPresenter/SwitchPresenter.cs @@ -69,7 +69,9 @@ public Type TargetType /// Identifies the property. /// public static readonly DependencyProperty TargetTypeProperty = +#pragma warning disable IL2111 // Uno 7 annotates propertyType for trimming, which flags System.Type's own annotated members DependencyProperty.Register(nameof(TargetType), typeof(Type), typeof(SwitchPresenter), new PropertyMetadata(null)); +#pragma warning restore IL2111 private static void OnValuePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { diff --git a/components/RangeSelector/src/MultiTarget.props b/components/RangeSelector/src/MultiTarget.props index b11c19426..7d1e11c3c 100644 --- a/components/RangeSelector/src/MultiTarget.props +++ b/components/RangeSelector/src/MultiTarget.props @@ -4,6 +4,6 @@ MultiTarget is a custom property that indicates which target a project is designed to be built for / run on. Used to create project references, generate solution files, enable/disable TargetFrameworks, and build nuget packages. --> - uwp;wasdk;wpf;wasm;linuxgtk;macos;ios;android; + uwp;wasdk;wpf;win32;wasm;linux;macos;ios;android; \ No newline at end of file diff --git a/components/RichSuggestBox/src/MultiTarget.props b/components/RichSuggestBox/src/MultiTarget.props index 18f6c7c98..aa297d836 100644 --- a/components/RichSuggestBox/src/MultiTarget.props +++ b/components/RichSuggestBox/src/MultiTarget.props @@ -4,6 +4,6 @@ MultiTarget is a custom property that indicates which target a project is designed to be built for / run on. Used to create project references, generate solution files, enable/disable TargetFrameworks, and build nuget packages. --> - uwp;wasdk; + uwp;wasdk;wpf;win32;wasm;linux;macos;ios;android; diff --git a/components/RichSuggestBox/src/RichSuggestBox.Helpers.cs b/components/RichSuggestBox/src/RichSuggestBox.Helpers.cs index 23e047cba..f3e3912e2 100644 --- a/components/RichSuggestBox/src/RichSuggestBox.Helpers.cs +++ b/components/RichSuggestBox/src/RichSuggestBox.Helpers.cs @@ -27,7 +27,8 @@ private static bool IsElementOnScreen(FrameworkElement element, double offsetX = // https://github.com/microsoft/microsoft-ui-xaml/issues/4228 // TODO: Remove when DisplayInformation.ScreenHeightInRawPixels alternative is available #if !WINAPPSDK - if (CoreWindow.GetForCurrentThread() == null) + var window = Window.Current; + if (CoreWindow.GetForCurrentThread() == null || window == null) { return true; } @@ -40,7 +41,7 @@ private static bool IsElementOnScreen(FrameworkElement element, double offsetX = elementBounds.Y += offsetY; // Get Window position - var windowBounds = Window.Current.Bounds; + var windowBounds = window.Bounds; // Offset Element within Window on Screen elementBounds.X += windowBounds.X; @@ -149,9 +150,9 @@ private static void ForEachLinkInDocument(ITextDocument document, Action true; #else - internal static bool IsXamlRootAvailable { get; } = Windows.Foundation.Metadata.ApiInformation.IsPropertyPresent("Microsoft.UI.Xaml.UIElement", "XamlRoot"); + internal static bool IsXamlRootAvailable { get; } = Windows.Foundation.Metadata.ApiInformation.IsPropertyPresent("Windows.UI.Xaml.UIElement", "XamlRoot"); #endif } diff --git a/components/Segmented/src/Helpers/ControlHelpers.cs b/components/Segmented/src/Helpers/ControlHelpers.cs index 28c3c8af7..2bb61e8f9 100644 --- a/components/Segmented/src/Helpers/ControlHelpers.cs +++ b/components/Segmented/src/Helpers/ControlHelpers.cs @@ -6,5 +6,9 @@ namespace CommunityToolkit.WinUI.Controls; internal static partial class ControlHelpers { +#if WINUI3 + internal static bool IsXamlRootAvailable => true; +#else internal static bool IsXamlRootAvailable { get; } = Windows.Foundation.Metadata.ApiInformation.IsPropertyPresent("Windows.UI.Xaml.UIElement", "XamlRoot"); +#endif } diff --git a/components/Segmented/src/MultiTarget.props b/components/Segmented/src/MultiTarget.props index b11c19426..7d1e11c3c 100644 --- a/components/Segmented/src/MultiTarget.props +++ b/components/Segmented/src/MultiTarget.props @@ -4,6 +4,6 @@ MultiTarget is a custom property that indicates which target a project is designed to be built for / run on. Used to create project references, generate solution files, enable/disable TargetFrameworks, and build nuget packages. --> - uwp;wasdk;wpf;wasm;linuxgtk;macos;ios;android; + uwp;wasdk;wpf;win32;wasm;linux;macos;ios;android; \ No newline at end of file diff --git a/components/Segmented/src/Segmented/Segmented.cs b/components/Segmented/src/Segmented/Segmented.cs index 6fbc6c301..ff85cb42e 100644 --- a/components/Segmented/src/Segmented/Segmented.cs +++ b/components/Segmented/src/Segmented/Segmented.cs @@ -116,7 +116,10 @@ private bool MoveFocus(int adjustment) } else { + // Obsolete on WinUI 3/Uno, but required as a fallback where XamlRoot is unavailable (e.g. UWP). +#pragma warning disable CS0618 return FocusManager.GetFocusedElement() as SegmentedItem; +#pragma warning restore CS0618 } } diff --git a/components/SettingsControls/samples/Dependencies.props b/components/SettingsControls/samples/Dependencies.props index 7b539e00b..2763dc16c 100644 --- a/components/SettingsControls/samples/Dependencies.props +++ b/components/SettingsControls/samples/Dependencies.props @@ -30,6 +30,6 @@ - + diff --git a/components/SettingsControls/src/Helpers/ControlHelper.cs b/components/SettingsControls/src/Helpers/ControlHelper.cs index 5690bcb38..90f828235 100644 --- a/components/SettingsControls/src/Helpers/ControlHelper.cs +++ b/components/SettingsControls/src/Helpers/ControlHelper.cs @@ -5,5 +5,9 @@ namespace CommunityToolkit.WinUI.Controls; internal static partial class ControlHelpers { +#if WINUI3 + internal static bool IsXamlRootAvailable => true; +#else internal static bool IsXamlRootAvailable { get; } = Windows.Foundation.Metadata.ApiInformation.IsPropertyPresent("Windows.UI.Xaml.UIElement", "XamlRoot"); +#endif } diff --git a/components/SettingsControls/src/MultiTarget.props b/components/SettingsControls/src/MultiTarget.props index b11c19426..7d1e11c3c 100644 --- a/components/SettingsControls/src/MultiTarget.props +++ b/components/SettingsControls/src/MultiTarget.props @@ -4,6 +4,6 @@ MultiTarget is a custom property that indicates which target a project is designed to be built for / run on. Used to create project references, generate solution files, enable/disable TargetFrameworks, and build nuget packages. --> - uwp;wasdk;wpf;wasm;linuxgtk;macos;ios;android; + uwp;wasdk;wpf;win32;wasm;linux;macos;ios;android; \ No newline at end of file diff --git a/components/SettingsControls/src/SettingsCard/SettingsCard.cs b/components/SettingsControls/src/SettingsCard/SettingsCard.cs index fbfc9e160..3b498128d 100644 --- a/components/SettingsControls/src/SettingsCard/SettingsCard.cs +++ b/components/SettingsControls/src/SettingsCard/SettingsCard.cs @@ -325,7 +325,10 @@ private void CheckVerticalSpacingState(VisualState s) } else { + // Obsolete on WinUI 3/Uno, but required as a fallback where XamlRoot is unavailable (e.g. UWP). +#pragma warning disable CS0618 return FocusManager.GetFocusedElement() as FrameworkElement; +#pragma warning restore CS0618 } } diff --git a/components/Sizers/src/MultiTarget.props b/components/Sizers/src/MultiTarget.props index b11c19426..7d1e11c3c 100644 --- a/components/Sizers/src/MultiTarget.props +++ b/components/Sizers/src/MultiTarget.props @@ -4,6 +4,6 @@ MultiTarget is a custom property that indicates which target a project is designed to be built for / run on. Used to create project references, generate solution files, enable/disable TargetFrameworks, and build nuget packages. --> - uwp;wasdk;wpf;wasm;linuxgtk;macos;ios;android; + uwp;wasdk;wpf;win32;wasm;linux;macos;ios;android; \ No newline at end of file diff --git a/components/TabbedCommandBar/samples/TabbedCommandBar.Samples.csproj b/components/TabbedCommandBar/samples/TabbedCommandBar.Samples.csproj index 986a36629..e570b08e1 100644 --- a/components/TabbedCommandBar/samples/TabbedCommandBar.Samples.csproj +++ b/components/TabbedCommandBar/samples/TabbedCommandBar.Samples.csproj @@ -1,4 +1,4 @@ - + TabbedCommandBar diff --git a/components/TabbedCommandBar/src/CommunityToolkit.WinUI.Controls.TabbedCommandBar.csproj b/components/TabbedCommandBar/src/CommunityToolkit.WinUI.Controls.TabbedCommandBar.csproj index f97cd6e1e..9d38932ef 100644 --- a/components/TabbedCommandBar/src/CommunityToolkit.WinUI.Controls.TabbedCommandBar.csproj +++ b/components/TabbedCommandBar/src/CommunityToolkit.WinUI.Controls.TabbedCommandBar.csproj @@ -1,4 +1,4 @@ - + TabbedCommandBar Display multiple CommandBars in the same space using tabs, like Microsoft Office's ribbon. diff --git a/components/TabbedCommandBar/src/MultiTarget.props b/components/TabbedCommandBar/src/MultiTarget.props index b11c19426..7d1e11c3c 100644 --- a/components/TabbedCommandBar/src/MultiTarget.props +++ b/components/TabbedCommandBar/src/MultiTarget.props @@ -4,6 +4,6 @@ MultiTarget is a custom property that indicates which target a project is designed to be built for / run on. Used to create project references, generate solution files, enable/disable TargetFrameworks, and build nuget packages. --> - uwp;wasdk;wpf;wasm;linuxgtk;macos;ios;android; + uwp;wasdk;wpf;win32;wasm;linux;macos;ios;android; \ No newline at end of file diff --git a/components/TokenizingTextBox/src/MultiTarget.props b/components/TokenizingTextBox/src/MultiTarget.props index b11c19426..7d1e11c3c 100644 --- a/components/TokenizingTextBox/src/MultiTarget.props +++ b/components/TokenizingTextBox/src/MultiTarget.props @@ -4,6 +4,6 @@ MultiTarget is a custom property that indicates which target a project is designed to be built for / run on. Used to create project references, generate solution files, enable/disable TargetFrameworks, and build nuget packages. --> - uwp;wasdk;wpf;wasm;linuxgtk;macos;ios;android; + uwp;wasdk;wpf;win32;wasm;linux;macos;ios;android; \ No newline at end of file diff --git a/components/TokenizingTextBox/src/TokenizingTextBox.Selection.cs b/components/TokenizingTextBox/src/TokenizingTextBox.Selection.cs index 0b20a6fee..b13a21c28 100644 --- a/components/TokenizingTextBox/src/TokenizingTextBox.Selection.cs +++ b/components/TokenizingTextBox/src/TokenizingTextBox.Selection.cs @@ -141,7 +141,10 @@ private bool MoveFocusAndSelection(MoveDirection direction) } else { + // Obsolete on WinUI 3/Uno, but required as a fallback where XamlRoot is unavailable (e.g. UWP). +#pragma warning disable CS0618 return FocusManager.GetFocusedElement() as TokenizingTextBoxItem; +#pragma warning restore CS0618 } } diff --git a/components/TokenizingTextBox/src/TokenizingTextBox.cs b/components/TokenizingTextBox/src/TokenizingTextBox.cs index db1dd0122..80d46329f 100644 --- a/components/TokenizingTextBox/src/TokenizingTextBox.cs +++ b/components/TokenizingTextBox/src/TokenizingTextBox.cs @@ -361,7 +361,10 @@ private object GetFocusedElement() } else { + // Obsolete on WinUI 3/Uno, but required as a fallback where XamlRoot is unavailable (e.g. UWP). +#pragma warning disable CS0618 return FocusManager.GetFocusedElement()!; +#pragma warning restore CS0618 } } @@ -626,5 +629,9 @@ private void GuardAgainstPlaceholderTextLayoutIssue() /// /// Checks if the XamlRoot property is available via the current API. /// +#if WINUI3 + public static bool IsXamlRootAvailable => true; +#else public static bool IsXamlRootAvailable { get; } = ApiInformation.IsPropertyPresent("Windows.UI.Xaml.UIElement", "XamlRoot"); +#endif } diff --git a/components/Triggers/src/MultiTarget.props b/components/Triggers/src/MultiTarget.props index b11c19426..7d1e11c3c 100644 --- a/components/Triggers/src/MultiTarget.props +++ b/components/Triggers/src/MultiTarget.props @@ -4,6 +4,6 @@ MultiTarget is a custom property that indicates which target a project is designed to be built for / run on. Used to create project references, generate solution files, enable/disable TargetFrameworks, and build nuget packages. --> - uwp;wasdk;wpf;wasm;linuxgtk;macos;ios;android; + uwp;wasdk;wpf;win32;wasm;linux;macos;ios;android; \ No newline at end of file diff --git a/global.json b/global.json index a99b0550b..8594f4d52 100644 --- a/global.json +++ b/global.json @@ -5,6 +5,7 @@ }, "msbuild-sdks": { - "MSBuild.Sdk.Extras":"3.0.23" + "MSBuild.Sdk.Extras":"3.0.44", + "Uno.Sdk": "7.0.0-dev.89" } } diff --git a/tooling b/tooling index f02adf9e2..8a865b0c2 160000 --- a/tooling +++ b/tooling @@ -1 +1 @@ -Subproject commit f02adf9e2d1ec1fd4865116bc786e217298985af +Subproject commit 8a865b0c25fe8d4b61c6214d4e9aceadfb05f579