From 75809d3f4ae793e707e42f0eb8ac80d24113919e Mon Sep 17 00:00:00 2001 From: James Crutchley Date: Sat, 29 Nov 2025 23:22:52 -0800 Subject: [PATCH 01/13] Implement `[BindableProperties]` for `CameraView` Do not merge until after #2933 is merged --- .../CommunityToolkit.Maui.Camera.csproj | 4 + .../Primitives/CameraViewDefaults.shared.cs | 2 +- .../Views/CameraView.shared.cs | 168 ++++-------------- 3 files changed, 42 insertions(+), 132 deletions(-) diff --git a/src/CommunityToolkit.Maui.Camera/CommunityToolkit.Maui.Camera.csproj b/src/CommunityToolkit.Maui.Camera/CommunityToolkit.Maui.Camera.csproj index d258ea2461..807415e985 100644 --- a/src/CommunityToolkit.Maui.Camera/CommunityToolkit.Maui.Camera.csproj +++ b/src/CommunityToolkit.Maui.Camera/CommunityToolkit.Maui.Camera.csproj @@ -51,6 +51,10 @@ + + + + diff --git a/src/CommunityToolkit.Maui.Camera/Primitives/CameraViewDefaults.shared.cs b/src/CommunityToolkit.Maui.Camera/Primitives/CameraViewDefaults.shared.cs index e946945a6e..517d929ca7 100644 --- a/src/CommunityToolkit.Maui.Camera/Primitives/CameraViewDefaults.shared.cs +++ b/src/CommunityToolkit.Maui.Camera/Primitives/CameraViewDefaults.shared.cs @@ -7,7 +7,7 @@ namespace CommunityToolkit.Maui.Core; /// Default Values for [EditorBrowsable(EditorBrowsableState.Never)] -public static class CameraViewDefaults +static class CameraViewDefaults { /// /// Default value for diff --git a/src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs b/src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs index abe92387e1..c2585f72a2 100644 --- a/src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs +++ b/src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs @@ -11,82 +11,77 @@ namespace CommunityToolkit.Maui.Views; /// public partial class CameraView : View, ICameraView, IDisposable { - static readonly BindablePropertyKey isAvailablePropertyKey = - BindableProperty.CreateReadOnly(nameof(IsAvailable), typeof(bool), typeof(CameraView), CameraViewDefaults.IsAvailable); - /// - /// Backing for the property. + /// Gets or sets a value indicating whether the camera defaults is available on the current device. /// - public static readonly BindableProperty CameraFlashModeProperty = - BindableProperty.Create(nameof(CameraFlashMode), typeof(CameraFlashMode), typeof(CameraView), CameraViewDefaults.CameraFlashMode); + [BindableProperty(DefaultValue = CameraViewDefaults.IsAvailable)] + public partial bool IsAvailable { get; } /// - /// Backing for the property. + /// Gets or sets the . /// - public static readonly BindableProperty IsTorchOnProperty = - BindableProperty.Create(nameof(IsTorchOn), typeof(bool), typeof(CameraView), CameraViewDefaults.IsTorchOn); + [BindableProperty(DefaultValue = nameof(CameraViewDefaults.CameraFlashMode))] + public partial CameraFlashMode CameraFlashMode { get; set; } /// - /// Backing for the property. + /// Gets or sets a value indicating whether the torch is on. /// - public static readonly BindableProperty IsAvailableProperty = isAvailablePropertyKey.BindableProperty; - - static readonly BindablePropertyKey isCameraBusyPropertyKey = - BindableProperty.CreateReadOnly(nameof(IsCameraBusy), typeof(bool), typeof(CameraView), CameraViewDefaults.IsCameraBusy); + [BindableProperty(DefaultValue = CameraViewDefaults.IsTorchOn)] + public partial bool IsTorchOn { get; set; } /// - /// Backing for the property. + /// Gets or sets a value indicating whether the camera is busy. /// - public static readonly BindableProperty IsCameraBusyProperty = isCameraBusyPropertyKey.BindableProperty; + [BindableProperty(DefaultValue = CameraViewDefaults.IsCameraBusy)] + public partial bool IsCameraBusy { get; } /// - /// Backing for the property. + /// Gets or sets the selected camera. /// - public static readonly BindableProperty? SelectedCameraProperty = BindableProperty.Create(nameof(SelectedCamera), - typeof(CameraInfo), typeof(CameraView), null, defaultBindingMode: BindingMode.TwoWay); - + [BindableProperty(DefaultBindingMode = BindingMode.TwoWay)] + public partial CameraInfo? SelectedCamera { get; set; } + /// - /// Backing for the property. + /// Gets or sets the zoom factor for the camera. /// - public static readonly BindableProperty ZoomFactorProperty = - BindableProperty.Create(nameof(ZoomFactor), typeof(float), typeof(CameraView), CameraViewDefaults.ZoomFactor, coerceValue: CoerceZoom, defaultBindingMode: BindingMode.TwoWay); + [BindableProperty(DefaultValue = CameraViewDefaults.ZoomFactor, DefaultBindingMode = BindingMode.TwoWay, CoerceValueMethodName = nameof(CoerceZoom))] + public partial float ZoomFactor { get; set; } /// - /// Backing for the property. + /// Gets or sets the image capture resolution. /// - public static readonly BindableProperty ImageCaptureResolutionProperty = BindableProperty.Create(nameof(ImageCaptureResolution), - typeof(Size), typeof(CameraView), CameraViewDefaults.ImageCaptureResolution, defaultBindingMode: BindingMode.TwoWay); + [BindableProperty(DefaultValue = nameof(CameraViewDefaults.ImageCaptureResolution), DefaultBindingMode = BindingMode.TwoWay)] + public partial Size ImageCaptureResolution { get; set; } /// - /// Backing BindableProperty for the property. + /// Gets or sets the command to capture an image. /// - public static readonly BindableProperty CaptureImageCommandProperty = - BindableProperty.CreateReadOnly(nameof(CaptureImageCommand), typeof(Command), typeof(CameraView), null, BindingMode.OneWayToSource, defaultValueCreator: CameraViewDefaults.CreateCaptureImageCommand).BindableProperty; + [BindableProperty(DefaultValue = nameof(CameraViewDefaults.CreateCaptureImageCommand), DefaultBindingMode = BindingMode.OneWayToSource)] + public partial Command CaptureImageCommand { get; } /// - /// Backing BindableProperty for the property. + /// Gets the command to start the camera preview. /// - public static readonly BindableProperty StartCameraPreviewCommandProperty = - BindableProperty.CreateReadOnly(nameof(StartCameraPreviewCommand), typeof(Command), typeof(CameraView), null, BindingMode.OneWayToSource, defaultValueCreator: CameraViewDefaults.CreateStartCameraPreviewCommand).BindableProperty; + [BindableProperty(DefaultValue = nameof(CameraViewDefaults.CreateStartCameraPreviewCommand), DefaultBindingMode = BindingMode.OneWayToSource)] + public partial Command StartCameraPreviewCommand { get; } /// - /// Backing BindableProperty for the property. + /// Gets the command to stop the camera preview. /// - public static readonly BindableProperty StopCameraPreviewCommandProperty = - BindableProperty.CreateReadOnly(nameof(StopCameraPreviewCommand), typeof(ICommand), typeof(CameraView), null, BindingMode.OneWayToSource, defaultValueCreator: CameraViewDefaults.CreateStopCameraPreviewCommand).BindableProperty; + [BindableProperty(DefaultValue = nameof(CameraViewDefaults.CreateStopCameraPreviewCommand), DefaultBindingMode = BindingMode.OneWayToSource)] + public partial Command StopCameraPreviewCommand { get; } /// - /// Backing BindableProperty for the property. + /// Gets the command to start video recording. /// - public static readonly BindableProperty StartVideoRecordingCommandProperty = - BindableProperty.CreateReadOnly(nameof(StartVideoRecordingCommand), typeof(Command), typeof(CameraView), null, BindingMode.OneWayToSource, defaultValueCreator: CameraViewDefaults.CreateStartVideoRecordingCommand).BindableProperty; + [BindableProperty(DefaultValue = nameof(CameraViewDefaults.CreateStartVideoRecordingCommand), DefaultBindingMode = BindingMode.OneWayToSource)] + public partial Command StartVideoRecordingCommand { get; } /// - /// Backing BindableProperty for the property. + /// Gets the command to stop video recording. /// - public static readonly BindableProperty StopVideoRecordingCommandProperty = - BindableProperty.CreateReadOnly(nameof(StopVideoRecordingCommand), typeof(Command), typeof(CameraView), null, BindingMode.OneWayToSource, defaultValueCreator: CameraViewDefaults.CreateStopVideoRecordingCommand).BindableProperty; - + [BindableProperty(DefaultValue = nameof(CameraViewDefaults.CreateStopVideoRecordingCommand), DefaultBindingMode = BindingMode.OneWayToSource)] + public partial Command StopVideoRecordingCommand { get; } readonly SemaphoreSlim captureImageSemaphoreSlim = new(1, 1); readonly WeakEventManager weakEventManager = new(); @@ -114,95 +109,6 @@ public event EventHandler MediaCaptured remove => weakEventManager.RemoveEventHandler(value); } - /// - /// Gets a value indicating whether the camera feature is available on the current device. - /// - public bool IsAvailable => (bool)GetValue(IsAvailableProperty); - - /// - /// Gets a value indicating whether the camera is currently busy. - /// - public bool IsCameraBusy => (bool)GetValue(IsCameraBusyProperty); - - /// - /// Gets the Command that triggers an image capture. - /// - /// - /// has a of Command<CancellationToken> which requires a as a CommandParameter. See and for more information on passing a into as a CommandParameter - /// - public Command CaptureImageCommand => (Command)GetValue(CaptureImageCommandProperty); - - /// - /// Gets the Command that starts the camera preview. - /// - /// /// - /// has a of Command<CancellationToken> which requires a as a CommandParameter. See and for more information on passing a into as a CommandParameter - /// - public Command StartCameraPreviewCommand => (Command)GetValue(StartCameraPreviewCommandProperty); - - /// - /// Gets the Command that stops the camera preview. - /// - public ICommand StopCameraPreviewCommand => (ICommand)GetValue(StopCameraPreviewCommandProperty); - - /// - /// Gets the Command that starts video recording. - /// - /// - /// has a of Command<Stream> which requires a as a CommandParameter. - /// The parameter represents the destination where the recorded video will be saved. - /// See and for more information on passing a into as a CommandParameter. - /// - public Command StartVideoRecordingCommand => (Command)GetValue(StartVideoRecordingCommandProperty); - - /// - /// Gets the Command that stops video recording. - /// - /// - /// has a of Command<CancellationToken>, which requires a as a CommandParameter. - /// See and for more information on passing a into as a CommandParameter. - /// - public Command StopVideoRecordingCommand => (Command)GetValue(StopVideoRecordingCommandProperty); - - /// - /// Gets or sets the . - /// - public CameraFlashMode CameraFlashMode - { - get => (CameraFlashMode)GetValue(CameraFlashModeProperty); - set => SetValue(CameraFlashModeProperty, value); - } - - /// - public CameraInfo? SelectedCamera - { - get => (CameraInfo?)GetValue(SelectedCameraProperty); - set => SetValue(SelectedCameraProperty, value); - } - - /// - public float ZoomFactor - { - get => (float)GetValue(ZoomFactorProperty); - set => SetValue(ZoomFactorProperty, value); - } - - /// - public Size ImageCaptureResolution - { - get => (Size)GetValue(ImageCaptureResolutionProperty); - set => SetValue(ImageCaptureResolutionProperty, value); - } - - /// - /// Gets or sets a value indicating whether the torch (flash) is on. - /// - public bool IsTorchOn - { - get => (bool)GetValue(IsTorchOnProperty); - set => SetValue(IsTorchOnProperty, value); - } - static ICameraProvider CameraProvider => IPlatformApplication.Current?.Services.GetRequiredService() ?? throw new CameraException("Unable to retrieve CameraProvider"); [EditorBrowsable(EditorBrowsableState.Never)] From 78e90ecdd00bfbe0281022c75e976f1b810df6b5 Mon Sep 17 00:00:00 2001 From: James Crutchley Date: Sat, 29 Nov 2025 23:29:57 -0800 Subject: [PATCH 02/13] Fix comments --- .../Views/CameraView.shared.cs | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs b/src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs index c2585f72a2..e77bd3e013 100644 --- a/src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs +++ b/src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs @@ -12,73 +12,73 @@ namespace CommunityToolkit.Maui.Views; public partial class CameraView : View, ICameraView, IDisposable { /// - /// Gets or sets a value indicating whether the camera defaults is available on the current device. + /// Gets or sets a indicating whether the is available on the current device. /// [BindableProperty(DefaultValue = CameraViewDefaults.IsAvailable)] public partial bool IsAvailable { get; } /// - /// Gets or sets the . + /// Gets or sets the property. /// [BindableProperty(DefaultValue = nameof(CameraViewDefaults.CameraFlashMode))] public partial CameraFlashMode CameraFlashMode { get; set; } /// - /// Gets or sets a value indicating whether the torch is on. + /// Gets or sets the for the property. /// [BindableProperty(DefaultValue = CameraViewDefaults.IsTorchOn)] public partial bool IsTorchOn { get; set; } /// - /// Gets or sets a value indicating whether the camera is busy. + /// Gets or sets the for the property. /// [BindableProperty(DefaultValue = CameraViewDefaults.IsCameraBusy)] public partial bool IsCameraBusy { get; } /// - /// Gets or sets the selected camera. + /// Gets or sets the for the property. /// [BindableProperty(DefaultBindingMode = BindingMode.TwoWay)] public partial CameraInfo? SelectedCamera { get; set; } /// - /// Gets or sets the zoom factor for the camera. + /// Gets or sets the for the property. /// [BindableProperty(DefaultValue = CameraViewDefaults.ZoomFactor, DefaultBindingMode = BindingMode.TwoWay, CoerceValueMethodName = nameof(CoerceZoom))] public partial float ZoomFactor { get; set; } /// - /// Gets or sets the image capture resolution. + /// Gets or sets the for the property. /// [BindableProperty(DefaultValue = nameof(CameraViewDefaults.ImageCaptureResolution), DefaultBindingMode = BindingMode.TwoWay)] public partial Size ImageCaptureResolution { get; set; } /// - /// Gets or sets the command to capture an image. + /// Gets or sets the for the property. /// [BindableProperty(DefaultValue = nameof(CameraViewDefaults.CreateCaptureImageCommand), DefaultBindingMode = BindingMode.OneWayToSource)] public partial Command CaptureImageCommand { get; } /// - /// Gets the command to start the camera preview. + /// Gets the for the property. /// [BindableProperty(DefaultValue = nameof(CameraViewDefaults.CreateStartCameraPreviewCommand), DefaultBindingMode = BindingMode.OneWayToSource)] public partial Command StartCameraPreviewCommand { get; } /// - /// Gets the command to stop the camera preview. + /// Gets the for the property. /// [BindableProperty(DefaultValue = nameof(CameraViewDefaults.CreateStopCameraPreviewCommand), DefaultBindingMode = BindingMode.OneWayToSource)] public partial Command StopCameraPreviewCommand { get; } /// - /// Gets the command to start video recording. + /// Gets the for the property. /// [BindableProperty(DefaultValue = nameof(CameraViewDefaults.CreateStartVideoRecordingCommand), DefaultBindingMode = BindingMode.OneWayToSource)] public partial Command StartVideoRecordingCommand { get; } /// - /// Gets the command to stop video recording. + /// Gets the for the property. /// [BindableProperty(DefaultValue = nameof(CameraViewDefaults.CreateStopVideoRecordingCommand), DefaultBindingMode = BindingMode.OneWayToSource)] public partial Command StopVideoRecordingCommand { get; } From 3bca7804e44d4a7d66d1fb8aa7cf86daef7ca0a9 Mon Sep 17 00:00:00 2001 From: James Crutchley Date: Sat, 29 Nov 2025 23:34:39 -0800 Subject: [PATCH 03/13] Fix `DefaultValueCreatorMethodName` usage Was using `DefaultValue` Incorrectly --- .../Views/CameraView.shared.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs b/src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs index e77bd3e013..c7e8848cfc 100644 --- a/src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs +++ b/src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs @@ -1,6 +1,4 @@ using System.ComponentModel; -using System.Runtime.Versioning; -using System.Windows.Input; using CommunityToolkit.Maui.Core; using CommunityToolkit.Maui.Core.Handlers; @@ -56,19 +54,19 @@ public partial class CameraView : View, ICameraView, IDisposable /// /// Gets or sets the for the property. /// - [BindableProperty(DefaultValue = nameof(CameraViewDefaults.CreateCaptureImageCommand), DefaultBindingMode = BindingMode.OneWayToSource)] + [BindableProperty(DefaultValueCreatorMethodName = nameof(CameraViewDefaults.CreateCaptureImageCommand), DefaultBindingMode = BindingMode.OneWayToSource)] public partial Command CaptureImageCommand { get; } /// /// Gets the for the property. /// - [BindableProperty(DefaultValue = nameof(CameraViewDefaults.CreateStartCameraPreviewCommand), DefaultBindingMode = BindingMode.OneWayToSource)] + [BindableProperty(DefaultValueCreatorMethodName = nameof(CameraViewDefaults.CreateStartCameraPreviewCommand), DefaultBindingMode = BindingMode.OneWayToSource)] public partial Command StartCameraPreviewCommand { get; } /// /// Gets the for the property. /// - [BindableProperty(DefaultValue = nameof(CameraViewDefaults.CreateStopCameraPreviewCommand), DefaultBindingMode = BindingMode.OneWayToSource)] + [BindableProperty(DefaultValueCreatorMethodName = nameof(CameraViewDefaults.CreateStopCameraPreviewCommand), DefaultBindingMode = BindingMode.OneWayToSource)] public partial Command StopCameraPreviewCommand { get; } /// From 5dfa819ef681049a9da55c9e567f6610d56d97b6 Mon Sep 17 00:00:00 2001 From: James Crutchley Date: Sat, 29 Nov 2025 23:54:00 -0800 Subject: [PATCH 04/13] Fix comments --- src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs b/src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs index c7e8848cfc..0a9cde1165 100644 --- a/src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs +++ b/src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs @@ -10,7 +10,7 @@ namespace CommunityToolkit.Maui.Views; public partial class CameraView : View, ICameraView, IDisposable { /// - /// Gets or sets a indicating whether the is available on the current device. + /// Gets the indicating whether the is available on the current device. /// [BindableProperty(DefaultValue = CameraViewDefaults.IsAvailable)] public partial bool IsAvailable { get; } @@ -28,7 +28,7 @@ public partial class CameraView : View, ICameraView, IDisposable public partial bool IsTorchOn { get; set; } /// - /// Gets or sets the for the property. + /// Gets the for the property. /// [BindableProperty(DefaultValue = CameraViewDefaults.IsCameraBusy)] public partial bool IsCameraBusy { get; } @@ -52,7 +52,7 @@ public partial class CameraView : View, ICameraView, IDisposable public partial Size ImageCaptureResolution { get; set; } /// - /// Gets or sets the for the property. + /// Gets the for the property. /// [BindableProperty(DefaultValueCreatorMethodName = nameof(CameraViewDefaults.CreateCaptureImageCommand), DefaultBindingMode = BindingMode.OneWayToSource)] public partial Command CaptureImageCommand { get; } From 3288aa0b6178477c6043215481679d8aa9a2564f Mon Sep 17 00:00:00 2001 From: James Crutchley Date: Sat, 29 Nov 2025 23:58:49 -0800 Subject: [PATCH 05/13] Revert `CameraViewDefaults` Visibility --- .../Primitives/CameraViewDefaults.shared.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CommunityToolkit.Maui.Camera/Primitives/CameraViewDefaults.shared.cs b/src/CommunityToolkit.Maui.Camera/Primitives/CameraViewDefaults.shared.cs index 517d929ca7..e946945a6e 100644 --- a/src/CommunityToolkit.Maui.Camera/Primitives/CameraViewDefaults.shared.cs +++ b/src/CommunityToolkit.Maui.Camera/Primitives/CameraViewDefaults.shared.cs @@ -7,7 +7,7 @@ namespace CommunityToolkit.Maui.Core; /// Default Values for [EditorBrowsable(EditorBrowsableState.Never)] -static class CameraViewDefaults +public static class CameraViewDefaults { /// /// Default value for From 312853d457d6edb4c49b69c759e48a325c5a29eb Mon Sep 17 00:00:00 2001 From: Brandon Minnick <13558917+TheCodeTraveler@users.noreply.github.com> Date: Tue, 2 Dec 2025 13:57:06 -0500 Subject: [PATCH 06/13] Move `` to `Directory.Build.props` --- Directory.Build.props | 6 ++++++ .../CommunityToolkit.Maui.Sample.csproj | 8 -------- .../CommunityToolkit.Maui.Analyzers.UnitTests.csproj | 1 - .../CommunityToolkit.Maui.MediaElement.csproj | 3 --- ...olkit.Maui.SourceGenerators.Internal.UnitTests.csproj | 2 -- .../CommunityToolkit.Maui.UnitTests.csproj | 3 --- src/CommunityToolkit.Maui/CommunityToolkit.Maui.csproj | 9 --------- 7 files changed, 6 insertions(+), 26 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 73569d08ad..7b99375922 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -11,6 +11,12 @@ true false + + + enable all diff --git a/samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj b/samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj index 687e98aa9f..a445b78fac 100644 --- a/samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj +++ b/samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj @@ -23,14 +23,6 @@ 1.0 1 - - - true IL2026 diff --git a/src/CommunityToolkit.Maui.Analyzers.UnitTests/CommunityToolkit.Maui.Analyzers.UnitTests.csproj b/src/CommunityToolkit.Maui.Analyzers.UnitTests/CommunityToolkit.Maui.Analyzers.UnitTests.csproj index 140af48816..b0c9015058 100644 --- a/src/CommunityToolkit.Maui.Analyzers.UnitTests/CommunityToolkit.Maui.Analyzers.UnitTests.csproj +++ b/src/CommunityToolkit.Maui.Analyzers.UnitTests/CommunityToolkit.Maui.Analyzers.UnitTests.csproj @@ -2,7 +2,6 @@ $(NetVersion) - true $(BaseIntermediateOutputPath)\GF true true diff --git a/src/CommunityToolkit.Maui.MediaElement/CommunityToolkit.Maui.MediaElement.csproj b/src/CommunityToolkit.Maui.MediaElement/CommunityToolkit.Maui.MediaElement.csproj index e87ba03235..feaf734467 100644 --- a/src/CommunityToolkit.Maui.MediaElement/CommunityToolkit.Maui.MediaElement.csproj +++ b/src/CommunityToolkit.Maui.MediaElement/CommunityToolkit.Maui.MediaElement.csproj @@ -10,7 +10,6 @@ true true - 15.0 15.0 26.0 @@ -47,8 +46,6 @@ Debug;Release $(WarningsAsErrors);CS1591 True - true - $(BaseIntermediateOutputPath)\GeneratedFiles diff --git a/src/CommunityToolkit.Maui.SourceGenerators.Internal.UnitTests/CommunityToolkit.Maui.SourceGenerators.Internal.UnitTests.csproj b/src/CommunityToolkit.Maui.SourceGenerators.Internal.UnitTests/CommunityToolkit.Maui.SourceGenerators.Internal.UnitTests.csproj index ba06befedb..957775a22a 100644 --- a/src/CommunityToolkit.Maui.SourceGenerators.Internal.UnitTests/CommunityToolkit.Maui.SourceGenerators.Internal.UnitTests.csproj +++ b/src/CommunityToolkit.Maui.SourceGenerators.Internal.UnitTests/CommunityToolkit.Maui.SourceGenerators.Internal.UnitTests.csproj @@ -2,8 +2,6 @@ $(NetVersion) - true - $(BaseIntermediateOutputPath)\GF true true false diff --git a/src/CommunityToolkit.Maui.UnitTests/CommunityToolkit.Maui.UnitTests.csproj b/src/CommunityToolkit.Maui.UnitTests/CommunityToolkit.Maui.UnitTests.csproj index b91d6381fd..d623e274dc 100644 --- a/src/CommunityToolkit.Maui.UnitTests/CommunityToolkit.Maui.UnitTests.csproj +++ b/src/CommunityToolkit.Maui.UnitTests/CommunityToolkit.Maui.UnitTests.csproj @@ -2,9 +2,6 @@ $(NetVersion) - true - $(BaseIntermediateOutputPath)\GF - Exe CommunityToolkit.Maui.UnitTests diff --git a/src/CommunityToolkit.Maui/CommunityToolkit.Maui.csproj b/src/CommunityToolkit.Maui/CommunityToolkit.Maui.csproj index d681fe30d2..c299bd27e7 100644 --- a/src/CommunityToolkit.Maui/CommunityToolkit.Maui.csproj +++ b/src/CommunityToolkit.Maui/CommunityToolkit.Maui.csproj @@ -8,15 +8,6 @@ true true true - - - - true 15.0 From facf5bc591e8871882d4f9ad44b42b84bfe69d10 Mon Sep 17 00:00:00 2001 From: Brandon Minnick <13558917+TheCodeTraveler@users.noreply.github.com> Date: Tue, 2 Dec 2025 14:04:53 -0500 Subject: [PATCH 07/13] Update Directory.Build.props --- Directory.Build.props | 1 - 1 file changed, 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 7b99375922..c667671a83 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -15,7 +15,6 @@ If you see any LongPath issue on Windows, check this doc https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=cmd#enable-long-paths-in-windows-10-version-1607-and-later--> enable From 097875d32d96fb18b6fb9b2939d71da2fc125697 Mon Sep 17 00:00:00 2001 From: Brandon Minnick <13558917+TheCodeTraveler@users.noreply.github.com> Date: Tue, 2 Dec 2025 14:15:58 -0500 Subject: [PATCH 08/13] Move DefaultValueCreator Methods to `CameraView.shared.cs` --- .../Primitives/CameraViewDefaults.shared.cs | 32 +---------- .../Views/CameraView.shared.cs | 55 +++++++++++++++---- 2 files changed, 45 insertions(+), 42 deletions(-) diff --git a/src/CommunityToolkit.Maui.Camera/Primitives/CameraViewDefaults.shared.cs b/src/CommunityToolkit.Maui.Camera/Primitives/CameraViewDefaults.shared.cs index e946945a6e..ec74d93a4e 100644 --- a/src/CommunityToolkit.Maui.Camera/Primitives/CameraViewDefaults.shared.cs +++ b/src/CommunityToolkit.Maui.Camera/Primitives/CameraViewDefaults.shared.cs @@ -7,7 +7,7 @@ namespace CommunityToolkit.Maui.Core; /// Default Values for [EditorBrowsable(EditorBrowsableState.Never)] -public static class CameraViewDefaults +static class CameraViewDefaults { /// /// Default value for @@ -38,34 +38,4 @@ public static class CameraViewDefaults /// Default value for /// public static CameraFlashMode CameraFlashMode { get; } = CameraFlashMode.Off; - - internal static Command CreateCaptureImageCommand(BindableObject bindable) - { - var cameraView = (CameraView)bindable; - return new(async token => await cameraView.CaptureImage(token).ConfigureAwait(false)); - } - - internal static Command CreateStartCameraPreviewCommand(BindableObject bindable) - { - var cameraView = (CameraView)bindable; - return new(async token => await cameraView.StartCameraPreview(token).ConfigureAwait(false)); - } - - internal static ICommand CreateStopCameraPreviewCommand(BindableObject bindable) - { - var cameraView = (CameraView)bindable; - return new Command(_ => cameraView.StopCameraPreview()); - } - - internal static Command CreateStartVideoRecordingCommand(BindableObject bindable) - { - var cameraView = (CameraView)bindable; - return new Command(async stream => await cameraView.StartVideoRecording(stream).ConfigureAwait(false)); - } - - internal static Command CreateStopVideoRecordingCommand(BindableObject bindable) - { - var cameraView = (CameraView)bindable; - return new Command(async token => await cameraView.StopVideoRecording(token).ConfigureAwait(false)); - } } \ No newline at end of file diff --git a/src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs b/src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs index 0a9cde1165..8804d6c95a 100644 --- a/src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs +++ b/src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs @@ -1,4 +1,5 @@ using System.ComponentModel; +using System.Windows.Input; using CommunityToolkit.Maui.Core; using CommunityToolkit.Maui.Core.Handlers; @@ -48,37 +49,37 @@ public partial class CameraView : View, ICameraView, IDisposable /// /// Gets or sets the for the property. /// - [BindableProperty(DefaultValue = nameof(CameraViewDefaults.ImageCaptureResolution), DefaultBindingMode = BindingMode.TwoWay)] - public partial Size ImageCaptureResolution { get; set; } + [BindableProperty(DefaultValueCreatorMethodName = nameof(CreateImageCaptureResolution), DefaultBindingMode = BindingMode.TwoWay)] + public partial Microsoft.Maui.Graphics.Size ImageCaptureResolution { get; set; } /// /// Gets the for the property. /// - [BindableProperty(DefaultValueCreatorMethodName = nameof(CameraViewDefaults.CreateCaptureImageCommand), DefaultBindingMode = BindingMode.OneWayToSource)] + [BindableProperty(DefaultValueCreatorMethodName = nameof(CreateCaptureImageCommand), DefaultBindingMode = BindingMode.OneWayToSource)] public partial Command CaptureImageCommand { get; } /// /// Gets the for the property. /// - [BindableProperty(DefaultValueCreatorMethodName = nameof(CameraViewDefaults.CreateStartCameraPreviewCommand), DefaultBindingMode = BindingMode.OneWayToSource)] + [BindableProperty(DefaultValueCreatorMethodName = nameof(CreateStartCameraPreviewCommand), DefaultBindingMode = BindingMode.OneWayToSource)] public partial Command StartCameraPreviewCommand { get; } /// /// Gets the for the property. /// - [BindableProperty(DefaultValueCreatorMethodName = nameof(CameraViewDefaults.CreateStopCameraPreviewCommand), DefaultBindingMode = BindingMode.OneWayToSource)] + [BindableProperty(DefaultValueCreatorMethodName = nameof(CreateStopCameraPreviewCommand), DefaultBindingMode = BindingMode.OneWayToSource)] public partial Command StopCameraPreviewCommand { get; } /// /// Gets the for the property. /// - [BindableProperty(DefaultValue = nameof(CameraViewDefaults.CreateStartVideoRecordingCommand), DefaultBindingMode = BindingMode.OneWayToSource)] + [BindableProperty(DefaultValue = nameof(CreateStartVideoRecordingCommand), DefaultBindingMode = BindingMode.OneWayToSource)] public partial Command StartVideoRecordingCommand { get; } /// /// Gets the for the property. /// - [BindableProperty(DefaultValue = nameof(CameraViewDefaults.CreateStopVideoRecordingCommand), DefaultBindingMode = BindingMode.OneWayToSource)] + [BindableProperty(DefaultValue = nameof(CreateStopVideoRecordingCommand), DefaultBindingMode = BindingMode.OneWayToSource)] public partial Command StopVideoRecordingCommand { get; } readonly SemaphoreSlim captureImageSemaphoreSlim = new(1, 1); @@ -227,16 +228,38 @@ protected virtual void Dispose(bool disposing) } } - void ICameraView.OnMediaCaptured(Stream imageData) + static object CreateImageCaptureResolution(BindableObject bindable) => CameraViewDefaults.ImageCaptureResolution; + + static Command CreateCaptureImageCommand(BindableObject bindable) { - weakEventManager.HandleEvent(this, new MediaCapturedEventArgs(imageData), nameof(MediaCaptured)); + var cameraView = (CameraView)bindable; + return new(async token => await cameraView.CaptureImage(token).ConfigureAwait(false)); } - void ICameraView.OnMediaCapturedFailed(string failureReason) + static Command CreateStartCameraPreviewCommand(BindableObject bindable) { - weakEventManager.HandleEvent(this, new MediaCaptureFailedEventArgs(failureReason), nameof(MediaCaptureFailed)); + var cameraView = (CameraView)bindable; + return new(async token => await cameraView.StartCameraPreview(token).ConfigureAwait(false)); + } + + static CCommand CreateStopCameraPreviewCommand(BindableObject bindable) + { + var cameraView = (CameraView)bindable; + return new Command(_ => cameraView.StopCameraPreview()); + } + + static Command CreateStartVideoRecordingCommand(BindableObject bindable) + { + var cameraView = (CameraView)bindable; + return new Command(async stream => await cameraView.StartVideoRecording(stream).ConfigureAwait(false)); } + static Command CreateStopVideoRecordingCommand(BindableObject bindable) + { + var cameraView = (CameraView)bindable; + return new Command(async token => await cameraView.StopVideoRecording(token).ConfigureAwait(false)); + } + static object CoerceZoom(BindableObject bindable, object value) { var cameraView = (CameraView)bindable; @@ -258,4 +281,14 @@ static object CoerceZoom(BindableObject bindable, object value) return input; } + + void ICameraView.OnMediaCaptured(Stream imageData) + { + weakEventManager.HandleEvent(this, new MediaCapturedEventArgs(imageData), nameof(MediaCaptured)); + } + + void ICameraView.OnMediaCapturedFailed(string failureReason) + { + weakEventManager.HandleEvent(this, new MediaCaptureFailedEventArgs(failureReason), nameof(MediaCaptureFailed)); + } } \ No newline at end of file From 74c6447adbbcee3f94718a76c319114de548b56d Mon Sep 17 00:00:00 2001 From: Brandon Minnick <13558917+TheCodeTraveler@users.noreply.github.com> Date: Tue, 2 Dec 2025 14:19:08 -0500 Subject: [PATCH 09/13] Fix Commented Line --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index c667671a83..65579e1164 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -14,7 +14,7 @@ - enable From 90b91f7c4e3b839ce10aac1fe6b1a14e8a0e16e6 Mon Sep 17 00:00:00 2001 From: Brandon Minnick <13558917+TheCodeTraveler@users.noreply.github.com> Date: Tue, 2 Dec 2025 14:23:57 -0500 Subject: [PATCH 10/13] Update Formatting --- .../Views/CameraView.shared.cs | 58 +++++++++---------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs b/src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs index 8804d6c95a..fe776bb59e 100644 --- a/src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs +++ b/src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs @@ -10,6 +10,34 @@ namespace CommunityToolkit.Maui.Views; /// public partial class CameraView : View, ICameraView, IDisposable { + readonly SemaphoreSlim captureImageSemaphoreSlim = new(1, 1); + readonly WeakEventManager weakEventManager = new(); + + bool isDisposed; + + /// + /// Event that is raised when the camera capture fails. + /// + public event EventHandler MediaCaptureFailed + { + add => weakEventManager.AddEventHandler(value); + remove => weakEventManager.RemoveEventHandler(value); + } + + /// + /// Event that is raised when the camera captures an image. + /// + /// + /// The contains the captured image data. + /// + public event EventHandler MediaCaptured + { + add => weakEventManager.AddEventHandler(value); + remove => weakEventManager.RemoveEventHandler(value); + } + + static ICameraProvider CameraProvider => IPlatformApplication.Current?.Services.GetRequiredService() ?? throw new CameraException("Unable to retrieve CameraProvider"); + /// /// Gets the indicating whether the is available on the current device. /// @@ -82,34 +110,6 @@ public partial class CameraView : View, ICameraView, IDisposable [BindableProperty(DefaultValue = nameof(CreateStopVideoRecordingCommand), DefaultBindingMode = BindingMode.OneWayToSource)] public partial Command StopVideoRecordingCommand { get; } - readonly SemaphoreSlim captureImageSemaphoreSlim = new(1, 1); - readonly WeakEventManager weakEventManager = new(); - - bool isDisposed; - - /// - /// Event that is raised when the camera capture fails. - /// - public event EventHandler MediaCaptureFailed - { - add => weakEventManager.AddEventHandler(value); - remove => weakEventManager.RemoveEventHandler(value); - } - - /// - /// Event that is raised when the camera captures an image. - /// - /// - /// The contains the captured image data. - /// - public event EventHandler MediaCaptured - { - add => weakEventManager.AddEventHandler(value); - remove => weakEventManager.RemoveEventHandler(value); - } - - static ICameraProvider CameraProvider => IPlatformApplication.Current?.Services.GetRequiredService() ?? throw new CameraException("Unable to retrieve CameraProvider"); - [EditorBrowsable(EditorBrowsableState.Never)] bool ICameraView.IsAvailable { @@ -242,7 +242,7 @@ static Command CreateStartCameraPreviewCommand(BindableObject return new(async token => await cameraView.StartCameraPreview(token).ConfigureAwait(false)); } - static CCommand CreateStopCameraPreviewCommand(BindableObject bindable) + static Command CreateStopCameraPreviewCommand(BindableObject bindable) { var cameraView = (CameraView)bindable; return new Command(_ => cameraView.StopCameraPreview()); From 57d57c343678874be420bc281f9910ae67886412 Mon Sep 17 00:00:00 2001 From: Brandon Minnick <13558917+TheCodeTraveler@users.noreply.github.com> Date: Tue, 2 Dec 2025 14:38:20 -0500 Subject: [PATCH 11/13] Fix Bindable Property DefaultValueCreatorMethodName --- .../Views/CameraView.shared.cs | 81 ++++++++++--------- 1 file changed, 42 insertions(+), 39 deletions(-) diff --git a/src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs b/src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs index fe776bb59e..d70687fcac 100644 --- a/src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs +++ b/src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs @@ -6,7 +6,7 @@ namespace CommunityToolkit.Maui.Views; /// -/// A visual element that provides the ability to show a camera preview and capture images. +/// A that provides the ability to show a camera preview and capture images and record video. /// public partial class CameraView : View, ICameraView, IDisposable { @@ -37,49 +37,19 @@ public event EventHandler MediaCaptured } static ICameraProvider CameraProvider => IPlatformApplication.Current?.Services.GetRequiredService() ?? throw new CameraException("Unable to retrieve CameraProvider"); - + /// /// Gets the indicating whether the is available on the current device. /// [BindableProperty(DefaultValue = CameraViewDefaults.IsAvailable)] public partial bool IsAvailable { get; } - /// - /// Gets or sets the property. - /// - [BindableProperty(DefaultValue = nameof(CameraViewDefaults.CameraFlashMode))] - public partial CameraFlashMode CameraFlashMode { get; set; } - - /// - /// Gets or sets the for the property. - /// - [BindableProperty(DefaultValue = CameraViewDefaults.IsTorchOn)] - public partial bool IsTorchOn { get; set; } - /// /// Gets the for the property. /// [BindableProperty(DefaultValue = CameraViewDefaults.IsCameraBusy)] public partial bool IsCameraBusy { get; } - /// - /// Gets or sets the for the property. - /// - [BindableProperty(DefaultBindingMode = BindingMode.TwoWay)] - public partial CameraInfo? SelectedCamera { get; set; } - - /// - /// Gets or sets the for the property. - /// - [BindableProperty(DefaultValue = CameraViewDefaults.ZoomFactor, DefaultBindingMode = BindingMode.TwoWay, CoerceValueMethodName = nameof(CoerceZoom))] - public partial float ZoomFactor { get; set; } - - /// - /// Gets or sets the for the property. - /// - [BindableProperty(DefaultValueCreatorMethodName = nameof(CreateImageCaptureResolution), DefaultBindingMode = BindingMode.TwoWay)] - public partial Microsoft.Maui.Graphics.Size ImageCaptureResolution { get; set; } - /// /// Gets the for the property. /// @@ -101,15 +71,45 @@ public event EventHandler MediaCaptured /// /// Gets the for the property. /// - [BindableProperty(DefaultValue = nameof(CreateStartVideoRecordingCommand), DefaultBindingMode = BindingMode.OneWayToSource)] + [BindableProperty(DefaultValueCreatorMethodName = nameof(CreateStartVideoRecordingCommand), DefaultBindingMode = BindingMode.OneWayToSource)] public partial Command StartVideoRecordingCommand { get; } /// /// Gets the for the property. /// - [BindableProperty(DefaultValue = nameof(CreateStopVideoRecordingCommand), DefaultBindingMode = BindingMode.OneWayToSource)] + [BindableProperty(DefaultValueCreatorMethodName = nameof(CreateStopVideoRecordingCommand), DefaultBindingMode = BindingMode.OneWayToSource)] public partial Command StopVideoRecordingCommand { get; } + /// + /// Gets or sets the property. + /// + [BindableProperty(DefaultValueCreatorMethodName = nameof(CreateCameraFlashMode))] + public partial CameraFlashMode CameraFlashMode { get; set; } + + /// + /// Gets or sets the for the property. + /// + [BindableProperty(DefaultValue = CameraViewDefaults.IsTorchOn)] + public partial bool IsTorchOn { get; set; } + + /// + /// Gets or sets the for the property. + /// + [BindableProperty(DefaultBindingMode = BindingMode.TwoWay)] + public partial CameraInfo? SelectedCamera { get; set; } + + /// + /// Gets or sets the for the property. + /// + [BindableProperty(DefaultValue = CameraViewDefaults.ZoomFactor, DefaultBindingMode = BindingMode.TwoWay, CoerceValueMethodName = nameof(CoerceZoom))] + public partial float ZoomFactor { get; set; } + + /// + /// Gets or sets the for the property. + /// + [BindableProperty(DefaultValueCreatorMethodName = nameof(CreateImageCaptureResolution), DefaultBindingMode = BindingMode.TwoWay)] + public partial Size ImageCaptureResolution { get; set; } + [EditorBrowsable(EditorBrowsableState.Never)] bool ICameraView.IsAvailable { @@ -140,6 +140,7 @@ public async ValueTask> GetAvailableCameras(Cancellati { await CameraProvider.RefreshAvailableCameras(token); } + return CameraProvider.AvailableCameras ?? throw new CameraException("No camera available on device"); } @@ -230,6 +231,8 @@ protected virtual void Dispose(bool disposing) static object CreateImageCaptureResolution(BindableObject bindable) => CameraViewDefaults.ImageCaptureResolution; + static object CreateCameraFlashMode(BindableObject bindable) => CameraViewDefaults.CameraFlashMode; + static Command CreateCaptureImageCommand(BindableObject bindable) { var cameraView = (CameraView)bindable; @@ -245,21 +248,21 @@ static Command CreateStartCameraPreviewCommand(BindableObject static Command CreateStopCameraPreviewCommand(BindableObject bindable) { var cameraView = (CameraView)bindable; - return new Command(_ => cameraView.StopCameraPreview()); + return new(_ => cameraView.StopCameraPreview()); } static Command CreateStartVideoRecordingCommand(BindableObject bindable) { var cameraView = (CameraView)bindable; - return new Command(async stream => await cameraView.StartVideoRecording(stream).ConfigureAwait(false)); + return new(async stream => await cameraView.StartVideoRecording(stream).ConfigureAwait(false)); } static Command CreateStopVideoRecordingCommand(BindableObject bindable) { var cameraView = (CameraView)bindable; - return new Command(async token => await cameraView.StopVideoRecording(token).ConfigureAwait(false)); + return new(async token => await cameraView.StopVideoRecording(token).ConfigureAwait(false)); } - + static object CoerceZoom(BindableObject bindable, object value) { var cameraView = (CameraView)bindable; @@ -281,7 +284,7 @@ static object CoerceZoom(BindableObject bindable, object value) return input; } - + void ICameraView.OnMediaCaptured(Stream imageData) { weakEventManager.HandleEvent(this, new MediaCapturedEventArgs(imageData), nameof(MediaCaptured)); From d366aeaeb65dc6733f69536898839e44ea79876e Mon Sep 17 00:00:00 2001 From: Brandon Minnick <13558917+TheCodeTraveler@users.noreply.github.com> Date: Tue, 2 Dec 2025 14:52:30 -0500 Subject: [PATCH 12/13] Update XML Comments --- .../Interfaces/ICameraView.shared.cs | 6 +- .../Views/CameraView.shared.cs | 61 ++++++++++--------- .../Views/CameraView/CameraViewTests.cs | 2 +- 3 files changed, 35 insertions(+), 34 deletions(-) diff --git a/src/CommunityToolkit.Maui.Camera/Interfaces/ICameraView.shared.cs b/src/CommunityToolkit.Maui.Camera/Interfaces/ICameraView.shared.cs index 1b98bd1ee6..5dbfadcaf9 100644 --- a/src/CommunityToolkit.Maui.Camera/Interfaces/ICameraView.shared.cs +++ b/src/CommunityToolkit.Maui.Camera/Interfaces/ICameraView.shared.cs @@ -16,7 +16,7 @@ public interface ICameraView : IView Size ImageCaptureResolution { get; } /// - /// Gets a value indicating whether the torch is on. + /// Gets a value indicating whether the torch (flash) is on. /// bool IsTorchOn { get; } @@ -39,12 +39,12 @@ public interface ICameraView : IView float ZoomFactor { get; internal set; } /// - /// Gets whether the implementation is available. + /// Gets a value indicating whether the camera feature is available on the current device. /// bool IsAvailable { get; internal set; } /// - /// Gets whether the implementation is busy. + /// Gets a value indicating whether the camera is currently busy. /// bool IsBusy { get; internal set; } diff --git a/src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs b/src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs index d70687fcac..e9567b80d2 100644 --- a/src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs +++ b/src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs @@ -38,75 +38,76 @@ public event EventHandler MediaCaptured static ICameraProvider CameraProvider => IPlatformApplication.Current?.Services.GetRequiredService() ?? throw new CameraException("Unable to retrieve CameraProvider"); - /// - /// Gets the indicating whether the is available on the current device. - /// + /// [BindableProperty(DefaultValue = CameraViewDefaults.IsAvailable)] public partial bool IsAvailable { get; } - /// - /// Gets the for the property. - /// + /// [BindableProperty(DefaultValue = CameraViewDefaults.IsCameraBusy)] - public partial bool IsCameraBusy { get; } + public partial bool IsBusy { get; } /// - /// Gets the for the property. + /// Gets the that triggers an image capture. /// + /// + /// has a of Command<CancellationToken> which requires a as a CommandParameter. See and for more information on passing a into as a CommandParameter + /// [BindableProperty(DefaultValueCreatorMethodName = nameof(CreateCaptureImageCommand), DefaultBindingMode = BindingMode.OneWayToSource)] public partial Command CaptureImageCommand { get; } /// - /// Gets the for the property. + /// Gets the that starts the camera preview. /// + /// + /// has a of Command<CancellationToken> which requires a as a CommandParameter. See and for more information on passing a into as a CommandParameter + /// [BindableProperty(DefaultValueCreatorMethodName = nameof(CreateStartCameraPreviewCommand), DefaultBindingMode = BindingMode.OneWayToSource)] public partial Command StartCameraPreviewCommand { get; } /// - /// Gets the for the property. + /// Gets the that stops the camera preview. /// + /// + /// has a of Command<CancellationToken> which requires a as a CommandParameter. See and for more information on passing a into as a CommandParameter + /// [BindableProperty(DefaultValueCreatorMethodName = nameof(CreateStopCameraPreviewCommand), DefaultBindingMode = BindingMode.OneWayToSource)] public partial Command StopCameraPreviewCommand { get; } /// - /// Gets the for the property. + /// Gets the that starts video recording. /// + /// + /// has a of Command<Stream> which requires a as a CommandParameter. See and for more information on passing a into as a CommandParameter + /// [BindableProperty(DefaultValueCreatorMethodName = nameof(CreateStartVideoRecordingCommand), DefaultBindingMode = BindingMode.OneWayToSource)] public partial Command StartVideoRecordingCommand { get; } /// - /// Gets the for the property. + /// Gets the that stops video recording. /// + /// + /// has a of Command<CancellationToken> which requires a as a CommandParameter. See and for more information on passing a into as a CommandParameter + /// [BindableProperty(DefaultValueCreatorMethodName = nameof(CreateStopVideoRecordingCommand), DefaultBindingMode = BindingMode.OneWayToSource)] public partial Command StopVideoRecordingCommand { get; } - /// - /// Gets or sets the property. - /// + /// [BindableProperty(DefaultValueCreatorMethodName = nameof(CreateCameraFlashMode))] public partial CameraFlashMode CameraFlashMode { get; set; } - /// - /// Gets or sets the for the property. - /// + /// [BindableProperty(DefaultValue = CameraViewDefaults.IsTorchOn)] public partial bool IsTorchOn { get; set; } - /// - /// Gets or sets the for the property. - /// + /// [BindableProperty(DefaultBindingMode = BindingMode.TwoWay)] public partial CameraInfo? SelectedCamera { get; set; } - /// - /// Gets or sets the for the property. - /// + /// [BindableProperty(DefaultValue = CameraViewDefaults.ZoomFactor, DefaultBindingMode = BindingMode.TwoWay, CoerceValueMethodName = nameof(CoerceZoom))] public partial float ZoomFactor { get; set; } - - /// - /// Gets or sets the for the property. - /// + + /// [BindableProperty(DefaultValueCreatorMethodName = nameof(CreateImageCaptureResolution), DefaultBindingMode = BindingMode.TwoWay)] public partial Size ImageCaptureResolution { get; set; } @@ -120,8 +121,8 @@ bool ICameraView.IsAvailable [EditorBrowsable(EditorBrowsableState.Never)] bool ICameraView.IsBusy { - get => IsCameraBusy; - set => SetValue(isCameraBusyPropertyKey, value); + get => IsBusy; + set => SetValue(isBusyPropertyKey, value); } new CameraViewHandler Handler => (CameraViewHandler)(base.Handler ?? throw new InvalidOperationException("Unable to retrieve Handler")); diff --git a/src/CommunityToolkit.Maui.UnitTests/Views/CameraView/CameraViewTests.cs b/src/CommunityToolkit.Maui.UnitTests/Views/CameraView/CameraViewTests.cs index 4f4b43b517..a798aee895 100644 --- a/src/CommunityToolkit.Maui.UnitTests/Views/CameraView/CameraViewTests.cs +++ b/src/CommunityToolkit.Maui.UnitTests/Views/CameraView/CameraViewTests.cs @@ -21,7 +21,7 @@ public void VerifyDefaults() { Assert.Equal(CameraViewDefaults.IsAvailable, cameraView.IsAvailable); Assert.Equal(CameraViewDefaults.IsTorchOn, cameraView.IsTorchOn); - Assert.Equal(CameraViewDefaults.IsCameraBusy, cameraView.IsCameraBusy); + Assert.Equal(CameraViewDefaults.IsCameraBusy, cameraView.IsBusy); Assert.Equal(CameraViewDefaults.ZoomFactor, cameraView.ZoomFactor); Assert.Equal(CameraViewDefaults.ImageCaptureResolution, cameraView.ImageCaptureResolution); Assert.Equal(CameraViewDefaults.CameraFlashMode, cameraView.CameraFlashMode); From da34d66a3a973623811048cff878615fb0097b1d Mon Sep 17 00:00:00 2001 From: Brandon Minnick <13558917+TheCodeTraveler@users.noreply.github.com> Date: Tue, 2 Dec 2025 15:00:31 -0500 Subject: [PATCH 13/13] `dotnet format` --- Directory.Build.props | 2 +- .../Views/CameraView.shared.cs | 16 ++++++------- .../Interfaces/IMediaElement.shared.cs | 4 ++-- .../MediaElement.shared.cs | 14 +++++------ .../MediaSource/FileMediaSource.shared.cs | 4 ++-- .../MediaSource/ResourceMediaSource.shared.cs | 4 ++-- .../MediaSource/UriMediaSource.shared.cs | 4 ++-- .../Primitives/MediaElementDefaults.shared.cs | 24 +++++++++---------- .../CommonUsageTests.cs | 4 ++-- .../EdgeCaseTests.cs | 2 +- .../Services/PopupServiceTests.cs | 14 +++++------ .../Views/MediaElement/MediaElementTests.cs | 4 ++-- .../Views/Popup/PopupPage.shared.cs | 2 +- 13 files changed, 49 insertions(+), 49 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 65579e1164..377fccf275 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -11,7 +11,7 @@ true false - diff --git a/src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs b/src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs index e9567b80d2..7d31ea60a3 100644 --- a/src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs +++ b/src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs @@ -77,7 +77,7 @@ public event EventHandler MediaCaptured /// Gets the that starts video recording. /// /// - /// has a of Command<Stream> which requires a as a CommandParameter. See and for more information on passing a into as a CommandParameter + /// has a of Command<Stream> which requires a as a CommandParameter. See and for more information on passing a into as a CommandParameter /// [BindableProperty(DefaultValueCreatorMethodName = nameof(CreateStartVideoRecordingCommand), DefaultBindingMode = BindingMode.OneWayToSource)] public partial Command StartVideoRecordingCommand { get; } @@ -95,10 +95,6 @@ public event EventHandler MediaCaptured [BindableProperty(DefaultValueCreatorMethodName = nameof(CreateCameraFlashMode))] public partial CameraFlashMode CameraFlashMode { get; set; } - /// - [BindableProperty(DefaultValue = CameraViewDefaults.IsTorchOn)] - public partial bool IsTorchOn { get; set; } - /// [BindableProperty(DefaultBindingMode = BindingMode.TwoWay)] public partial CameraInfo? SelectedCamera { get; set; } @@ -106,11 +102,17 @@ public event EventHandler MediaCaptured /// [BindableProperty(DefaultValue = CameraViewDefaults.ZoomFactor, DefaultBindingMode = BindingMode.TwoWay, CoerceValueMethodName = nameof(CoerceZoom))] public partial float ZoomFactor { get; set; } - + /// [BindableProperty(DefaultValueCreatorMethodName = nameof(CreateImageCaptureResolution), DefaultBindingMode = BindingMode.TwoWay)] public partial Size ImageCaptureResolution { get; set; } + /// + [BindableProperty(DefaultValue = CameraViewDefaults.IsTorchOn)] + public partial bool IsTorchOn { get; set; } + + new CameraViewHandler Handler => (CameraViewHandler)(base.Handler ?? throw new InvalidOperationException("Unable to retrieve Handler")); + [EditorBrowsable(EditorBrowsableState.Never)] bool ICameraView.IsAvailable { @@ -125,8 +127,6 @@ bool ICameraView.IsBusy set => SetValue(isBusyPropertyKey, value); } - new CameraViewHandler Handler => (CameraViewHandler)(base.Handler ?? throw new InvalidOperationException("Unable to retrieve Handler")); - /// public void Dispose() { diff --git a/src/CommunityToolkit.Maui.MediaElement/Interfaces/IMediaElement.shared.cs b/src/CommunityToolkit.Maui.MediaElement/Interfaces/IMediaElement.shared.cs index 7a87bba749..ddd454029a 100644 --- a/src/CommunityToolkit.Maui.MediaElement/Interfaces/IMediaElement.shared.cs +++ b/src/CommunityToolkit.Maui.MediaElement/Interfaces/IMediaElement.shared.cs @@ -17,7 +17,7 @@ public interface IMediaElement : IView, IAsynchronousMediaElementHandler /// Occurs when the changes; /// event EventHandler PositionChanged; - + /// /// Gets the media aspect ratio. /// @@ -95,7 +95,7 @@ public interface IMediaElement : IView, IAsynchronousMediaElementHandler /// /// A value of 1 indicates full volume, 0 is silence. double Volume { get; set; } - + /// /// Gets or sets the title of the media. /// diff --git a/src/CommunityToolkit.Maui.MediaElement/MediaElement.shared.cs b/src/CommunityToolkit.Maui.MediaElement/MediaElement.shared.cs index bdf77170f1..a3946f62f6 100644 --- a/src/CommunityToolkit.Maui.MediaElement/MediaElement.shared.cs +++ b/src/CommunityToolkit.Maui.MediaElement/MediaElement.shared.cs @@ -98,7 +98,7 @@ internal event EventHandler StopRequested add => eventManager.AddEventHandler(value); remove => eventManager.RemoveEventHandler(value); } - + /// /// Gets the in pixels. /// @@ -110,13 +110,13 @@ internal event EventHandler StopRequested /// [BindableProperty(DefaultValue = MediaElementDefaults.MediaWidth)] public partial int MediaWidth { get; } - + /// /// Gets the current of the media playback. /// [BindableProperty(DefaultValue = MediaElementDefaults.Position)] public partial TimeSpan Position { get; } - + /// /// Gets the of the media. /// @@ -200,13 +200,13 @@ internal event EventHandler StopRequested /// [BindableProperty(DefaultValue = MediaElementDefaults.Volume, DefaultBindingMode = BindingMode.TwoWay, PropertyChangingMethodName = nameof(OnVolumeChanging))] public partial double Volume { get; set; } - + /// /// Gets or sets the of the media. /// [BindableProperty(DefaultValue = MediaElementDefaults.CurrentState, PropertyChangedMethodName = nameof(OnCurrentStatePropertyChanged))] public partial MediaElementState CurrentState { get; private set; } - + /// TaskCompletionSource IAsynchronousMediaElementHandler.SeekCompletedTCS => seekCompletedTaskCompletionSource; @@ -342,7 +342,7 @@ static void OnSourcePropertyChanged(BindableObject bindable, object oldValue, ob { var mediaElement = (MediaElement)bindable; var source = (MediaSource?)newValue; - + mediaElement.ClearTimer(); if (source is not null) @@ -381,7 +381,7 @@ static void OnVolumeChanging(BindableObject bindable, object oldValue, object ne throw new ArgumentOutOfRangeException(nameof(newValue), $"{nameof(Volume)} can not be less than 0.0 or greater than 1.0"); } } - + void IMediaElement.MediaEnded() => OnMediaEnded(); void IMediaElement.MediaFailed(MediaFailedEventArgs args) => OnMediaFailed(args); diff --git a/src/CommunityToolkit.Maui.MediaElement/MediaSource/FileMediaSource.shared.cs b/src/CommunityToolkit.Maui.MediaElement/MediaSource/FileMediaSource.shared.cs index eff2d406b1..525311ee41 100644 --- a/src/CommunityToolkit.Maui.MediaElement/MediaSource/FileMediaSource.shared.cs +++ b/src/CommunityToolkit.Maui.MediaElement/MediaSource/FileMediaSource.shared.cs @@ -21,14 +21,14 @@ public sealed partial class FileMediaSource : MediaSource /// /// A instance to convert to a string value. public static implicit operator string?(FileMediaSource? fileMediaSource) => fileMediaSource?.Path; - + /// /// Gets or sets the full path to the local file to use as a media source. /// This is a bindable property. /// [BindableProperty(PropertyChangedMethodName = nameof(OnFileMediaSourceChanged))] public partial string? Path { get; set; } - + /// public override string ToString() => $"File: {Path}"; diff --git a/src/CommunityToolkit.Maui.MediaElement/MediaSource/ResourceMediaSource.shared.cs b/src/CommunityToolkit.Maui.MediaElement/MediaSource/ResourceMediaSource.shared.cs index b2b79e7a25..067dcf5e36 100644 --- a/src/CommunityToolkit.Maui.MediaElement/MediaSource/ResourceMediaSource.shared.cs +++ b/src/CommunityToolkit.Maui.MediaElement/MediaSource/ResourceMediaSource.shared.cs @@ -21,7 +21,7 @@ public sealed partial class ResourceMediaSource : MediaSource /// /// A instance to convert to a string value. public static implicit operator string?(ResourceMediaSource? resourceMediaSource) => resourceMediaSource?.Path; - + /// /// Gets or sets the full path to the resource file to use as a media source. /// This is a bindable property. @@ -32,7 +32,7 @@ public sealed partial class ResourceMediaSource : MediaSource /// [BindableProperty(PropertyChangedMethodName = nameof(OnResourceMediaSourceMediaSourceChanged))] public partial string? Path { get; set; } - + /// public override string ToString() => $"Resource: {Path}"; diff --git a/src/CommunityToolkit.Maui.MediaElement/MediaSource/UriMediaSource.shared.cs b/src/CommunityToolkit.Maui.MediaElement/MediaSource/UriMediaSource.shared.cs index 11192b3c0e..f1e8b3a765 100644 --- a/src/CommunityToolkit.Maui.MediaElement/MediaSource/UriMediaSource.shared.cs +++ b/src/CommunityToolkit.Maui.MediaElement/MediaSource/UriMediaSource.shared.cs @@ -20,7 +20,7 @@ public sealed partial class UriMediaSource : MediaSource /// /// A instance to convert to a string value. public static implicit operator string?(UriMediaSource? uriMediaSource) => uriMediaSource?.Uri?.ToString(); - + /// /// Gets or sets the URI to use as a media source. /// This is a bindable property. @@ -29,7 +29,7 @@ public sealed partial class UriMediaSource : MediaSource [TypeConverter(typeof(UriTypeConverter))] [BindableProperty(PropertyChangedMethodName = nameof(OnUriSourceChanged), ValidateValueMethodName = nameof(UriValueValidator))] public partial Uri? Uri { get; set; } - + /// public override string ToString() => $"Uri: {Uri}"; diff --git a/src/CommunityToolkit.Maui.MediaElement/Primitives/MediaElementDefaults.shared.cs b/src/CommunityToolkit.Maui.MediaElement/Primitives/MediaElementDefaults.shared.cs index 4c02d95470..bd32fd22ac 100644 --- a/src/CommunityToolkit.Maui.MediaElement/Primitives/MediaElementDefaults.shared.cs +++ b/src/CommunityToolkit.Maui.MediaElement/Primitives/MediaElementDefaults.shared.cs @@ -5,32 +5,32 @@ static class MediaElementDefaults public const Aspect Aspect = Microsoft.Maui.Aspect.AspectFit; public const int MediaHeight = 0; - + public const int MediaWidth = 0; public const string Position = "00:00:00"; - + public const string Duration = "00:00:00"; public const bool ShouldAutoPlay = false; - + public const bool ShouldLoopPlayback = false; - + public const bool ShouldKeepScreenOn = false; - + public const bool ShouldMute = false; - + public const bool ShouldShowPlaybackControls = false; - + public const double Speed = 1.0; - + public const double Volume = 1.0; - + public const string MetadataTitle = ""; - + public const string MetadataArtist = ""; - + public const string MetadataArtworkUrl = ""; - + public const MediaElementState CurrentState = MediaElementState.None; } \ No newline at end of file diff --git a/src/CommunityToolkit.Maui.SourceGenerators.Internal.UnitTests/BindablePropertyAttributeSourceGeneratorTests/CommonUsageTests.cs b/src/CommunityToolkit.Maui.SourceGenerators.Internal.UnitTests/BindablePropertyAttributeSourceGeneratorTests/CommonUsageTests.cs index 03dad02d1f..d12688ef2f 100644 --- a/src/CommunityToolkit.Maui.SourceGenerators.Internal.UnitTests/BindablePropertyAttributeSourceGeneratorTests/CommonUsageTests.cs +++ b/src/CommunityToolkit.Maui.SourceGenerators.Internal.UnitTests/BindablePropertyAttributeSourceGeneratorTests/CommonUsageTests.cs @@ -351,7 +351,7 @@ public partial class {{defaultTestClassName}} : View await VerifySourceGeneratorAsync(source, string.Empty); } - + [Fact] public async Task GenerateBindableProperty_InternalSetter_GeneratesInternalSetter() { @@ -392,7 +392,7 @@ public partial class {{defaultTestClassName}} await VerifySourceGeneratorAsync(source, expectedGenerated); } - + [Fact] public async Task GenerateBindableProperty_PrivateProtectedSetter_GeneratesPrivateProtectedSetter() { diff --git a/src/CommunityToolkit.Maui.SourceGenerators.Internal.UnitTests/BindablePropertyAttributeSourceGeneratorTests/EdgeCaseTests.cs b/src/CommunityToolkit.Maui.SourceGenerators.Internal.UnitTests/BindablePropertyAttributeSourceGeneratorTests/EdgeCaseTests.cs index ae67355250..8de524928e 100644 --- a/src/CommunityToolkit.Maui.SourceGenerators.Internal.UnitTests/BindablePropertyAttributeSourceGeneratorTests/EdgeCaseTests.cs +++ b/src/CommunityToolkit.Maui.SourceGenerators.Internal.UnitTests/BindablePropertyAttributeSourceGeneratorTests/EdgeCaseTests.cs @@ -53,7 +53,7 @@ public partial class {{defaultTestClassName}} await VerifySourceGeneratorAsync(source, expectedGenerated); } - + [Fact] public async Task GenerateBindableProperty_PropertyIsByteEnum_GeneratesCorrectCode() { diff --git a/src/CommunityToolkit.Maui.UnitTests/Services/PopupServiceTests.cs b/src/CommunityToolkit.Maui.UnitTests/Services/PopupServiceTests.cs index dc02bcd739..d9e1b7bb06 100644 --- a/src/CommunityToolkit.Maui.UnitTests/Services/PopupServiceTests.cs +++ b/src/CommunityToolkit.Maui.UnitTests/Services/PopupServiceTests.cs @@ -540,7 +540,7 @@ sealed class ShortLivedSelfClosingPopup(ShortLivedMockPageViewModel viewModel) : class MockSelfClosingPopup : Popup, IQueryAttributable, IDisposable { readonly TaskCompletionSource popupClosedTCS = new(); - + CancellationTokenSource? cancellationTokenSource; protected MockSelfClosingPopup(MockPageViewModel viewModel, TimeSpan displayDuration, object? result = null) @@ -552,18 +552,18 @@ protected MockSelfClosingPopup(MockPageViewModel viewModel, TimeSpan displayDura Opened += HandlePopupOpened; Closed += HandlePopupClosed; } - + ~MockSelfClosingPopup() { Dispose(false); } - + public object? Result { get; } - + public TimeSpan DisplayDuration { get; } public static Color DefaultBackgroundColor { get; } = Colors.White; - + public void Dispose() { Dispose(true); @@ -600,10 +600,10 @@ protected virtual async void HandlePopupOpened(object? sender, EventArgs e) Console.WriteLine( $@"{DateTime.Now:O} Closed {BindingContext.GetType().Name} - {Application.Current?.Windows[0].Page?.Navigation.ModalStack.Count}"); - + popupClosedTCS.SetResult(); } - + protected virtual void Dispose(bool disposing) { if (disposing) diff --git a/src/CommunityToolkit.Maui.UnitTests/Views/MediaElement/MediaElementTests.cs b/src/CommunityToolkit.Maui.UnitTests/Views/MediaElement/MediaElementTests.cs index 510f339d16..284dcc637f 100644 --- a/src/CommunityToolkit.Maui.UnitTests/Views/MediaElement/MediaElementTests.cs +++ b/src/CommunityToolkit.Maui.UnitTests/Views/MediaElement/MediaElementTests.cs @@ -17,9 +17,9 @@ public void VerifyDefaults() { // Arrange MediaElement mediaElement = new(); - + // Act - + // Assert Assert.Equal(MediaElementDefaults.MediaHeight, mediaElement.MediaHeight); Assert.Equal(MediaElementDefaults.Aspect, mediaElement.Aspect); diff --git a/src/CommunityToolkit.Maui/Views/Popup/PopupPage.shared.cs b/src/CommunityToolkit.Maui/Views/Popup/PopupPage.shared.cs index 79c86cb566..f387408ebd 100644 --- a/src/CommunityToolkit.Maui/Views/Popup/PopupPage.shared.cs +++ b/src/CommunityToolkit.Maui/Views/Popup/PopupPage.shared.cs @@ -117,7 +117,7 @@ public async Task CloseAsync(PopupResult result, CancellationToken token = defau // Clean up Popup resources base.Content.GestureRecognizers.Clear(); popup.PropertyChanged -= HandlePopupPropertyChanged; - + PopupClosed?.Invoke(this, result); popup.NotifyPopupIsClosed(); }