Skip to content

[HealthKit] Implement Xcode 16 RC changes. #21225

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

Merged
merged 5 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions src/HealthKit/HKAppleSleepingBreathingDisturbances.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System;
using System.Runtime.InteropServices;
using ObjCRuntime;
using Foundation;
using HKQuantityRef = System.IntPtr;
using NSErrorRef = System.IntPtr;

#nullable enable

namespace HealthKit {

[SupportedOSPlatform ("ios18.0")]
[SupportedOSPlatform ("maccatalyst18.0")]
[SupportedOSPlatform ("macos15.0")]
[UnsupportedOSPlatform ("tvos")]
public static class HKAppleSleepingBreathingDisturbances {

[DllImport (Constants.HealthKitLibrary)]
unsafe static extern /* NSNumber * _Nullable */ IntPtr HKAppleSleepingBreathingDisturbancesClassificationForQuantity (HKQuantityRef value);

/// <summary>Get the breathing disturbances classification for a given quantity of breathing disturbance.</summary>
/// <param name="value">The quantity of the breathing disturbance whose classification to get.</param>
/// <returns>The breathing disturbances classification for the specified breathing disturbance quantity.</returns>
public static HKAppleSleepingBreathingDisturbancesClassification? GetClassification (HKQuantity value)
{
var ptr = HKAppleSleepingBreathingDisturbancesClassificationForQuantity (value.GetHandle ());
var number = Runtime.GetNSObject<NSNumber> (ptr);
if (number is null)
return null;
return (HKAppleSleepingBreathingDisturbancesClassification) number.LongValue;
}

[DllImport (Constants.HealthKitLibrary)]
static extern HKQuantityRef HKAppleSleepingBreathingDisturbancesMinimumQuantityForClassification (nint /* HKAppleSleepingBreathingDisturbancesClassification */ classification);

/// <summary>Get the minimum quantity for a breathing disturbances classification.</summary>
/// <param name="classification">The classification to get the minimum quantity for.</param>
/// <returns>The minimum quantity for the specified breathing disturbances classification.</returns>
public static HKQuantity? GetMinimumQuantity (HKAppleSleepingBreathingDisturbancesClassification classification)
{
return Runtime.GetNSObject<HKQuantity> (HKAppleSleepingBreathingDisturbancesMinimumQuantityForClassification ((nint) (long) classification));
}
}
}
1 change: 1 addition & 0 deletions src/frameworks.sources
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,7 @@ HEALTHKIT_API_SOURCES = \

HEALTHKIT_SOURCES = \
HealthKit/EnumsCompat.cs \
HealthKit/HKAppleSleepingBreathingDisturbances.cs \
HealthKit/HKAppleWalkingSteadiness.cs \
HealthKit/HKAnchoredObjectQuery.cs \
HealthKit/HKCategoryValueSleepAnalysisAsleep.cs \
Expand Down
16 changes: 16 additions & 0 deletions src/healthkit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2696,6 +2696,10 @@ enum HKQuantityTypeIdentifier {
[iOS (18, 0), MacCatalyst (18, 0), Mac (15, 0), Watch (11, 0)]
[Field ("HKQuantityTypeIdentifierRowingSpeed")]
RowingSpeed,

[iOS (18, 0), MacCatalyst (18, 0), Mac (15, 0), Watch (11, 0)]
[Field ("HKQuantityTypeIdentifierAppleSleepingBreathingDisturbances")]
AppleSleepingBreathingDisturbances,
}

/// <summary>Contains constants that identify HealthKit correlation types.</summary>
Expand Down Expand Up @@ -3048,6 +3052,10 @@ enum HKCategoryTypeIdentifier {
[iOS (18, 0), MacCatalyst (18, 0), Mac (15, 0), Watch (11, 0)]
[Field ("HKCategoryTypeIdentifierBleedingDuringPregnancy")]
BleedingDuringPregnancy,

[iOS (18, 0), MacCatalyst (18, 0), Mac (15, 0), Watch (11, 0)]
[Field ("HKCategoryTypeIdentifierSleepApneaEvent")]
SleepApneaEvent,
}

/// <summary>Enumerates the forms of <see cref="T:HealthKit.HKCharacteristicType" />.</summary>
Expand Down Expand Up @@ -5311,4 +5319,12 @@ interface HKWorkoutEffortRelationshipQuery {
[Export ("initWithPredicate:anchor:options:resultsHandler:")]
NativeHandle Constructor ([NullAllowed] NSPredicate predicate, [NullAllowed] HKQueryAnchor anchor, HKWorkoutEffortRelationshipQueryOptions options, HKWorkoutEffortRelationshipQueryResultsHandler resultsHandler);
}

[Watch (11, 0), TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)]
[Native]
public enum HKAppleSleepingBreathingDisturbancesClassification : long {
NotElevated,
Elevated,
}

}
6 changes: 6 additions & 0 deletions tests/cecil-tests/Documentation.KnownFailures.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10853,6 +10853,8 @@ F:HealthKit.HKActivityMoveMode.AppleMoveTime
F:HealthKit.HKAnchoredObjectQuery.NoAnchor
F:HealthKit.HKAppleEcgAlgorithmVersion.Version1
F:HealthKit.HKAppleEcgAlgorithmVersion.Version2
F:HealthKit.HKAppleSleepingBreathingDisturbancesClassification.Elevated
F:HealthKit.HKAppleSleepingBreathingDisturbancesClassification.NotElevated
F:HealthKit.HKAppleWalkingSteadinessClassification.Low
F:HealthKit.HKAppleWalkingSteadinessClassification.Ok
F:HealthKit.HKAppleWalkingSteadinessClassification.VeryLow
Expand Down Expand Up @@ -10951,6 +10953,7 @@ F:HealthKit.HKCategoryTypeIdentifier.ShortnessOfBreath
F:HealthKit.HKCategoryTypeIdentifier.SinusCongestion
F:HealthKit.HKCategoryTypeIdentifier.SkippedHeartbeat
F:HealthKit.HKCategoryTypeIdentifier.SleepAnalysis
F:HealthKit.HKCategoryTypeIdentifier.SleepApneaEvent
F:HealthKit.HKCategoryTypeIdentifier.SleepChanges
F:HealthKit.HKCategoryTypeIdentifier.SoreThroat
F:HealthKit.HKCategoryTypeIdentifier.ToothbrushingEvent
Expand Down Expand Up @@ -11161,6 +11164,7 @@ F:HealthKit.HKQuantityAggregationStyle.DiscreteTemporallyWeighted
F:HealthKit.HKQuantityTypeIdentifier.ActiveEnergyBurned
F:HealthKit.HKQuantityTypeIdentifier.AppleExerciseTime
F:HealthKit.HKQuantityTypeIdentifier.AppleMoveTime
F:HealthKit.HKQuantityTypeIdentifier.AppleSleepingBreathingDisturbances
F:HealthKit.HKQuantityTypeIdentifier.AppleSleepingWristTemperature
F:HealthKit.HKQuantityTypeIdentifier.AppleStandTime
F:HealthKit.HKQuantityTypeIdentifier.AppleWalkingSteadiness
Expand Down Expand Up @@ -83756,6 +83760,8 @@ T:GLKit.GLKViewDrawEventArgs
T:HealthKit.HKActivityMoveMode
T:HealthKit.HKAnchoredObjectUpdateHandler
T:HealthKit.HKAppleEcgAlgorithmVersion
T:HealthKit.HKAppleSleepingBreathingDisturbances
T:HealthKit.HKAppleSleepingBreathingDisturbancesClassification
T:HealthKit.HKAppleWalkingSteadiness
T:HealthKit.HKAppleWalkingSteadinessClassification
T:HealthKit.HKAttachmentStoreCompletionHandler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ public void EnumValues_22351 ()

case HKCategoryTypeIdentifier.BleedingAfterPregnancy:
case HKCategoryTypeIdentifier.BleedingDuringPregnancy:
case HKCategoryTypeIdentifier.SleepApneaEvent:
if (!TestRuntime.CheckXcodeVersion (16, 0))
continue;
break;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#if HAS_HEALTHKIT

using System;

using Foundation;
using HealthKit;

using NUnit.Framework;

namespace MonoTouchFixtures.HealthKit {

[TestFixture]
[Preserve (AllMembers = true)]
public class HKAppleSleepingBreathingDisturbancesTest {
[Test]
public void RoundtripTest ()
{
TestRuntime.AssertXcodeVersion (16, 0);

var minimum = HKAppleSleepingBreathingDisturbances.GetMinimumQuantity (HKAppleSleepingBreathingDisturbancesClassification.Elevated);
var classification = HKAppleSleepingBreathingDisturbances.GetClassification (minimum);
Assert.AreEqual (HKAppleSleepingBreathingDisturbancesClassification.Elevated, classification, "Classification");
}
}
}

#endif // HAS_HEALTHKIT
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public void EnumValues_22351 ()
if (!TestRuntime.CheckXcodeVersion (15, 0))
continue;
break;
case HKQuantityTypeIdentifier.AppleSleepingBreathingDisturbances:
case HKQuantityTypeIdentifier.CrossCountrySkiingSpeed:
case HKQuantityTypeIdentifier.DistanceCrossCountrySkiing:
case HKQuantityTypeIdentifier.DistancePaddleSports:
Expand Down

This file was deleted.

5 changes: 0 additions & 5 deletions tests/xtro-sharpie/api-annotations-dotnet/iOS-HealthKit.todo

This file was deleted.

This file was deleted.