Skip to content

Integrate common ISensor interface (net10.0) #30135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: net10.0
Choose a base branch
from

Conversation

framinosona
Copy link

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Description of Change

Extends sensor interfaces such as IAccelerometer, IBarometer, ICompass, IGyroscope, IMagnetometer, and IOrientationSensor with a common ISensor interface to unify capabilities. Eliminates redundant IsSupported and IsMonitoring properties and Start/Stop methods from individual sensor interfaces. Updates IAppActions, IHapticFeedback, IPhoneDialer, and IVibration to extend from IDeviceCapabilities for uniformity. Improves code maintainability by reducing duplicate functionality.

Relates to codebase cleanup and standardization.

(net9 PR : #30121)

Updates sensor and device interfaces by integrating common capabilities into base interfaces,
namely ISensor and IDeviceCapabilities. Simplifies code maintenance and enhances consistency across devices.
@Copilot Copilot AI review requested due to automatic review settings June 23, 2025 14:05
@framinosona framinosona requested a review from a team as a code owner June 23, 2025 14:05
@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Jun 23, 2025
Copy link
Contributor

Hey there @@framinosona! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a new ISensor base interface and a shared IDeviceCapabilities interface, then updates all existing sensor and capability APIs to inherit from these to remove duplicate members.

  • Introduces ISensor with IsMonitoring, Start, and Stop
  • Introduces IDeviceCapabilities with IsSupported
  • Updates all sensor interfaces and other device‐capability APIs (e.g., vibration, haptics, phone dialer, app actions) to derive from these new bases

Reviewed Changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/Essentials/src/Sensors/ISensors.shared.cs Adds new ISensor interface
src/Essentials/src/Sensors/IDeviceCapabilities.shared.cs Adds new IDeviceCapabilities interface
src/Essentials/src/Vibration/Vibration.shared.cs Updates IVibration to extend IDeviceCapabilities
src/Essentials/src/HapticFeedback/HapticFeedback.shared.cs Updates IHapticFeedback to extend IDeviceCapabilities
src/Essentials/src/PhoneDialer/PhoneDialer.shared.cs Updates IPhoneDialer to extend IDeviceCapabilities
src/Essentials/src/AppActions/AppActions.shared.cs Updates IAppActions to extend IDeviceCapabilities
src/Essentials/src/Sensors/* Updates all sensor interfaces to extend ISensor
src/Essentials/src/PublicAPI/*/PublicAPI.Unshipped.txt Exposes new interfaces in public API listings
Comments suppressed due to low confidence (2)

src/Essentials/src/Sensors/ISensors.shared.cs:12

  • Add automated unit tests for the new ISensor and IDeviceCapabilities interfaces under TestCases.Shared.Tests and ensure corresponding UI tests in TestCases.HostApp with unique AutomationIds.
	public interface ISensor : IDeviceCapabilities

src/Essentials/src/Sensors/ISensors.shared.cs:1

  • Update the public XML documentation in the /docs/ folder to describe the new ISensor and IDeviceCapabilities interfaces, ensuring consistency between docs and code.
#nullable enable

@jfversluis
Copy link
Member

/azp run MAUI-public

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@jfversluis jfversluis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

84 errors that look similar to this

C:\a_work\1\s\src\Essentials\src\PublicAPI\net\PublicAPI.Shipped.txt(673,1): error RS0017: Symbol 'Microsoft.Maui.Devices.Sensors.IMagnetometer.Stop() -> void' is part of the declared API, but is either not public or could not be found (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md) [C:\a_work\1\s\src\Essentials\src\Essentials.csproj::TargetFramework=net10.0]
C:\a_work\1\s\src\Essentials\src\PublicAPI\net\PublicAPI.Shipped.txt(675,1): error RS0017: Symbol 'Microsoft.Maui.Devices.Sensors.IOrientationSensor.IsMonitoring.get -> bool' is part of the declared API, but is either not public or could not be found (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md) [C:\a_work\1\s\src\Essentials\src\Essentials.csproj::TargetFramework=net10.0]
C:\a_work\1\s\src\Essentials\src\PublicAPI\net\PublicAPI.Shipped.txt(676,1): error RS0017: Symbol 'Microsoft.Maui.Devices.Sensors.IOrientationSensor.IsSupported.get -> bool' is part of the declared API, but is either not public or could not be found (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md) [C:\a_work\1\s\src\Essentials\src\Essentials.csproj::TargetFramework=net10.0]
C:\a_work\1\s\src\Essentials\src\PublicAPI\net\PublicAPI.Shipped.txt(678,1): error RS0017: Symbol 'Microsoft.Maui.Devices.Sensors.IOrientationSensor.Start(Microsoft.Maui.Devices.Sensors.SensorSpeed sensorSpeed) -> void' is part of the declared API, but is either not public or could not be found (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md) [C:\a_work\1\s\src\Essentials\src\Essentials.csproj::TargetFramework=net10.0]
C:\a_work\1\s\src\Essentials\src\PublicAPI\net\PublicAPI.Shipped.txt(679,1): error RS0017: Symbol 'Microsoft.Maui.Devices.Sensors.IOrientationSensor.Stop() -> void' is part of the declared API, but is either not public or could not be found (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md) [C:\a_work\1\s\src\Essentials\src\Essentials.csproj::TargetFramework=net10.0]

@framinosona
Copy link
Author

@jfversluis Of course ... When I add them to Unshipped, I need to remove them in the Shipped ... I just pushed. It should fix it :)

@framinosona framinosona requested a review from jfversluis June 24, 2025 18:41
@framinosona
Copy link
Author

/azp run MAUI-public

Copy link

Commenter does not have sufficient privileges for PR 30135 in repo dotnet/maui

@framinosona
Copy link
Author

Ohhh hold on, just discovered there is REMOVED tag ! Will use that instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community ✨ Community Contribution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants