[HealthKit] Adopt XAMCORE_4_0 changes in .NET. (#13968)

This commit is contained in:
Rolf Bjarne Kvinge 2022-01-31 16:57:26 +01:00 коммит произвёл GitHub
Родитель 05bbc6e66a
Коммит d8c2e5e040
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 17 добавлений и 108 удалений

Просмотреть файл

@ -442,7 +442,7 @@ namespace HealthKit
public enum HKInsulinDeliveryReason : long {
Basal = 1,
Bolus,
#if !XAMCORE_4_0
#if !NET
[Obsolete ("Use 'Basal' instead.")]
Asal = Basal,
[Obsolete ("Use 'Bolus' instead.")]
@ -455,7 +455,7 @@ namespace HealthKit
public enum HKBloodGlucoseMealTime : long {
Preprandial = 1,
Postprandial,
#if !XAMCORE_4_0
#if !NET
[Obsolete ("Use 'Preprandial' instead.")]
Reprandial = Preprandial,
[Obsolete ("Use 'Postprandial' instead.")]

Просмотреть файл

@ -1,4 +1,4 @@
#if !XAMCORE_4_0
#if !NET
using System;
using Foundation;
@ -6,17 +6,8 @@ using ObjCRuntime;
using System.Runtime.Versioning;
namespace HealthKit {
#if !NET
[Obsolete ("Use the 'HKQuantityTypeIdentifier' enum instead.")]
[Introduced (PlatformName.iOS, 8,0, PlatformArchitecture.All)]
#else
// not 'UnsupportedOSPlatform for iOS since many members are introduced in
// different versions of iOS
[UnsupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("maccatalyst")]
[UnsupportedOSPlatform ("tvos")]
[Obsolete ("Use the 'HKQuantityTypeIdentifier' enum instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#endif
public unsafe static partial class HKQuantityTypeIdentifierKey {
public static NSString ActiveEnergyBurned {
get {
@ -24,19 +15,15 @@ namespace HealthKit {
}
}
#if !NET
[Introduced (PlatformName.iOS, 9,3, PlatformArchitecture.All)]
[Introduced (PlatformName.WatchOS, 2,2, PlatformArchitecture.All)]
#endif
public static NSString AppleExerciseTime {
get {
return HKQuantityTypeIdentifierExtensions.GetConstant (HKQuantityTypeIdentifier.AppleExerciseTime);
}
}
#if !NET
[Introduced (PlatformName.iOS, 9,0, PlatformArchitecture.All)]
#endif
public static NSString BasalBodyTemperature {
get {
return HKQuantityTypeIdentifierExtensions.GetConstant (HKQuantityTypeIdentifier.BasalBodyTemperature);
@ -319,9 +306,7 @@ namespace HealthKit {
}
}
#if !NET
[Introduced (PlatformName.iOS, 9,0, PlatformArchitecture.All)]
#endif
public static NSString DietaryWater {
get {
return HKQuantityTypeIdentifierExtensions.GetConstant (HKQuantityTypeIdentifier.DietaryWater);
@ -340,22 +325,16 @@ namespace HealthKit {
}
}
#if !NET
[Introduced (PlatformName.WatchOS, 4,2, PlatformArchitecture.All)]
[Introduced (PlatformName.iOS, 11,2, PlatformArchitecture.All)]
#else
[SupportedOSPlatform ("ios11.2")]
#endif
public static NSString DistanceDownhillSnowSports {
get {
return HKQuantityTypeIdentifierExtensions.GetConstant (HKQuantityTypeIdentifier.DistanceDownhillSnowSports);
}
}
#if !NET
[Introduced (PlatformName.iOS, 10,0, PlatformArchitecture.All)]
[Introduced (PlatformName.WatchOS, 3,0, PlatformArchitecture.All)]
#endif
public static NSString DistanceSwimming {
get {
return HKQuantityTypeIdentifierExtensions.GetConstant (HKQuantityTypeIdentifier.DistanceSwimming);
@ -368,10 +347,8 @@ namespace HealthKit {
}
}
#if !NET
[Introduced (PlatformName.iOS, 10,0, PlatformArchitecture.All)]
[Introduced (PlatformName.WatchOS, 3,0, PlatformArchitecture.All)]
#endif
public static NSString DistanceWheelchair {
get {
return HKQuantityTypeIdentifierExtensions.GetConstant (HKQuantityTypeIdentifier.DistanceWheelchair);
@ -408,12 +385,8 @@ namespace HealthKit {
}
}
#if !NET
[Introduced (PlatformName.iOS, 11,0, PlatformArchitecture.All)]
[Introduced (PlatformName.WatchOS, 4,0, PlatformArchitecture.All)]
#else
[SupportedOSPlatform ("ios11.0")]
#endif
public static NSString HeartRateVariabilitySdnn {
get {
return HKQuantityTypeIdentifierExtensions.GetConstant (HKQuantityTypeIdentifier.HeartRateVariabilitySdnn);
@ -432,12 +405,8 @@ namespace HealthKit {
}
}
#if !NET
[Introduced (PlatformName.iOS, 11,0, PlatformArchitecture.All)]
[Introduced (PlatformName.WatchOS, 4,0, PlatformArchitecture.All)]
#else
[SupportedOSPlatform ("ios11.0")]
#endif
public static NSString InsulinDelivery {
get {
return HKQuantityTypeIdentifierExtensions.GetConstant (HKQuantityTypeIdentifier.InsulinDelivery);
@ -480,10 +449,8 @@ namespace HealthKit {
}
}
#if !NET
[Introduced (PlatformName.iOS, 10,0, PlatformArchitecture.All)]
[Introduced (PlatformName.WatchOS, 3,0, PlatformArchitecture.All)]
#endif
public static NSString PushCount {
get {
return HKQuantityTypeIdentifierExtensions.GetConstant (HKQuantityTypeIdentifier.PushCount);
@ -496,12 +463,8 @@ namespace HealthKit {
}
}
#if !NET
[Introduced (PlatformName.iOS, 11,0, PlatformArchitecture.All)]
[Introduced (PlatformName.WatchOS, 4,0, PlatformArchitecture.All)]
#else
[SupportedOSPlatform ("ios11.0")]
#endif
public static NSString RestingHeartRate {
get {
return HKQuantityTypeIdentifierExtensions.GetConstant (HKQuantityTypeIdentifier.RestingHeartRate);
@ -514,55 +477,39 @@ namespace HealthKit {
}
}
#if !NET
[Introduced (PlatformName.iOS, 10,0, PlatformArchitecture.All)]
[Introduced (PlatformName.WatchOS, 3,0, PlatformArchitecture.All)]
#endif
public static NSString SwimmingStrokeCount {
get {
return HKQuantityTypeIdentifierExtensions.GetConstant (HKQuantityTypeIdentifier.SwimmingStrokeCount);
}
}
#if !NET
[Introduced (PlatformName.iOS, 9,0, PlatformArchitecture.All)]
#endif
public static NSString UVExposure {
get {
return HKQuantityTypeIdentifierExtensions.GetConstant (HKQuantityTypeIdentifier.UVExposure);
}
}
#if !NET
[Introduced (PlatformName.WatchOS, 4,0, PlatformArchitecture.All)]
[Introduced (PlatformName.iOS, 11,0, PlatformArchitecture.All)]
#else
[SupportedOSPlatform ("ios11.0")]
#endif
public static NSString VO2Max {
get {
return HKQuantityTypeIdentifierExtensions.GetConstant (HKQuantityTypeIdentifier.VO2Max);
}
}
#if !NET
[Introduced (PlatformName.WatchOS, 4,0, PlatformArchitecture.All)]
[Introduced (PlatformName.iOS, 11,0, PlatformArchitecture.All)]
#else
[SupportedOSPlatform ("ios11.0")]
#endif
public static NSString WaistCircumference {
get {
return HKQuantityTypeIdentifierExtensions.GetConstant (HKQuantityTypeIdentifier.WaistCircumference);
}
}
#if !NET
[Introduced (PlatformName.iOS, 11,0, PlatformArchitecture.All)]
[Introduced (PlatformName.WatchOS, 4,0, PlatformArchitecture.All)]
#else
[SupportedOSPlatform ("ios11.0")]
#endif
public static NSString WalkingHeartRateAverage {
get {
return HKQuantityTypeIdentifierExtensions.GetConstant (HKQuantityTypeIdentifier.WalkingHeartRateAverage);
@ -570,75 +517,53 @@ namespace HealthKit {
}
} /* class HKQuantityTypeIdentifierKey */
#if !NET
[Obsolete ("Use the 'HKCategoryTypeIdentifier' enum instead.")]
[Introduced (PlatformName.iOS, 8,0, PlatformArchitecture.All)]
#else
[UnsupportedOSPlatform ("ios")]
[UnsupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("tvos")]
[UnsupportedOSPlatform ("maccatalyst")]
[Obsolete ("Starting with ios8.0 use the 'HKCategoryTypeIdentifier' enum instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#endif
public unsafe static partial class HKCategoryTypeIdentifierKey {
#if !NET
[Introduced (PlatformName.iOS, 9,0, PlatformArchitecture.All)]
#endif
public static NSString AppleStandHour {
get {
return HKCategoryTypeIdentifierExtensions.GetConstant (HKCategoryTypeIdentifier.AppleStandHour);
}
}
#if !NET
[Introduced (PlatformName.iOS, 9,0, PlatformArchitecture.All)]
#endif
public static NSString CervicalMucusQuality {
get {
return HKCategoryTypeIdentifierExtensions.GetConstant (HKCategoryTypeIdentifier.CervicalMucusQuality);
}
}
#if !NET
[Introduced (PlatformName.iOS, 9,0, PlatformArchitecture.All)]
#endif
public static NSString IntermenstrualBleeding {
get {
return HKCategoryTypeIdentifierExtensions.GetConstant (HKCategoryTypeIdentifier.IntermenstrualBleeding);
}
}
#if !NET
[Introduced (PlatformName.iOS, 9,0, PlatformArchitecture.All)]
#endif
public static NSString MenstrualFlow {
get {
return HKCategoryTypeIdentifierExtensions.GetConstant (HKCategoryTypeIdentifier.MenstrualFlow);
}
}
#if !NET
[Introduced (PlatformName.iOS, 10,0, PlatformArchitecture.All)]
[Introduced (PlatformName.WatchOS, 3,0, PlatformArchitecture.All)]
#endif
public static NSString MindfulSession {
get {
return HKCategoryTypeIdentifierExtensions.GetConstant (HKCategoryTypeIdentifier.MindfulSession);
}
}
#if !NET
[Introduced (PlatformName.iOS, 9,0, PlatformArchitecture.All)]
#endif
public static NSString OvulationTestResult {
get {
return HKCategoryTypeIdentifierExtensions.GetConstant (HKCategoryTypeIdentifier.OvulationTestResult);
}
}
#if !NET
[Introduced (PlatformName.iOS, 9,0, PlatformArchitecture.All)]
#endif
public static NSString SexualActivity {
get {
return HKCategoryTypeIdentifierExtensions.GetConstant (HKCategoryTypeIdentifier.SexualActivity);
@ -652,16 +577,8 @@ namespace HealthKit {
}
} /* class HKCategoryTypeIdentifierKey */
#if !NET
[Obsolete ("Use the 'HKCharacteristicTypeIdentifier' enum instead.")]
[Introduced (PlatformName.iOS, 8,0, PlatformArchitecture.All)]
#else
[UnsupportedOSPlatform ("ios")]
[UnsupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("tvos")]
[UnsupportedOSPlatform ("maccatalyst")]
[Obsolete ("Use the 'HKCharacteristicTypeIdentifier' enum instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#endif
public unsafe static partial class HKCharacteristicTypeIdentifierKey {
public static NSString BiologicalSex {
get {
@ -681,19 +598,15 @@ namespace HealthKit {
}
}
#if !NET
[Introduced (PlatformName.iOS, 9,0, PlatformArchitecture.All)]
#endif
public static NSString FitzpatrickSkinType {
get {
return HKCharacteristicTypeIdentifierExtensions.GetConstant (HKCharacteristicTypeIdentifier.FitzpatrickSkinType);
}
}
#if !NET
[Introduced (PlatformName.iOS, 10,0, PlatformArchitecture.All)]
[Introduced (PlatformName.WatchOS, 3,0, PlatformArchitecture.All)]
#endif
public static NSString WheelchairUse {
get {
return HKCharacteristicTypeIdentifierExtensions.GetConstant (HKCharacteristicTypeIdentifier.WheelchairUse);
@ -701,16 +614,8 @@ namespace HealthKit {
}
} /* class HKCharacteristicTypeIdentifierKey */
#if !NET
[Obsolete ("Use the 'HKCorrelationType' enum instead.")]
[Introduced (PlatformName.iOS, 8,0, PlatformArchitecture.All)]
#else
[UnsupportedOSPlatform ("ios")]
[UnsupportedOSPlatform ("tvos")]
[UnsupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("maccatalyst")]
[Obsolete ("Use the 'HKCorrelationType' enum instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#endif
public unsafe static partial class HKCorrelationTypeKey {
public static NSString IdentifierBloodPressure {
get {
@ -726,4 +631,4 @@ namespace HealthKit {
} /* class HKCorrelationTypeKey */
}
#endif // !XAMCORE_4_0
#endif // !NET

Просмотреть файл

@ -1015,7 +1015,7 @@ namespace HealthKit {
[Watch (2,0)]
[iOS (8,0)]
#if XAMCORE_4_0
#if NET
[Abstract] // as per docs
#endif
[DisableDefaultCtor] // - (instancetype)init NS_UNAVAILABLE;
@ -1045,7 +1045,7 @@ namespace HealthKit {
[Watch (2,0)]
[iOS (8,0)]
#if XAMCORE_4_0
#if NET
[Abstract]
#endif
[DisableDefaultCtor] // - (instancetype)init NS_UNAVAILABLE;
@ -1055,7 +1055,7 @@ namespace HealthKit {
[Export ("identifier")]
NSString Identifier { get; }
#if XAMCORE_4_0 || WATCH
#if NET || WATCH
[Internal]
#else
[Obsolete ("Use 'HKQuantityType.Create (HKQuantityTypeIdentifier)'.")]
@ -1065,7 +1065,7 @@ namespace HealthKit {
[return: NullAllowed]
HKQuantityType GetQuantityType (NSString hkTypeIdentifier);
#if XAMCORE_4_0 || WATCH
#if NET || WATCH
[Internal]
#else
[Obsolete ("Use 'HKCategoryType.Create (HKCategoryTypeIdentifier)'.")]
@ -1075,7 +1075,7 @@ namespace HealthKit {
[return: NullAllowed]
HKCategoryType GetCategoryType (NSString hkCategoryTypeIdentifier);
#if XAMCORE_4_0 || WATCH
#if NET || WATCH
[Internal]
#else
[Obsolete ("Use 'HKCharacteristicType.Create (HKCharacteristicTypeIdentifier)'.")]
@ -1085,7 +1085,7 @@ namespace HealthKit {
[return: NullAllowed]
HKCharacteristicType GetCharacteristicType (NSString hkCharacteristicTypeIdentifier);
#if XAMCORE_4_0 || WATCH
#if NET || WATCH
[Internal]
#else
[Obsolete ("Use 'HKCorrelationType.Create (HKCorrelationTypeIdentifier)'.")]
@ -1103,7 +1103,7 @@ namespace HealthKit {
HKDocumentType _GetDocumentType (NSString hkDocumentTypeIdentifier);
[Static, Export ("workoutType")]
#if XAMCORE_4_0
#if NET
HKWorkoutType WorkoutType { get; }
#else
HKWorkoutType GetWorkoutType ();
@ -1230,7 +1230,7 @@ namespace HealthKit {
[Watch (2,0)]
[iOS (8,0)]
[BaseType (typeof (HKQuery))]
#if XAMCORE_4_0
#if NET
[Abstract]
#endif
[DisableDefaultCtor] // NSInvalidArgumentException Reason: The -init method is not available on HKObserverQuery
@ -1469,7 +1469,7 @@ namespace HealthKit {
[Watch (2,0)]
[iOS (8,0)]
[BaseType (typeof (HKObject))]
#if XAMCORE_4_0
#if NET
[Abstract]
#endif
[DisableDefaultCtor] // NSInvalidArgumentException Reason: The -init method is not available on HKSample

Просмотреть файл

@ -27,7 +27,11 @@ namespace MonoTouchFixtures.HealthKit {
{
TestRuntime.AssertXcodeVersion (6, 0);
#if NET
using (var t = HKObjectType.WorkoutType) {
#else
using (var t = HKObjectType.GetWorkoutType ()) {
#endif
Assert.That (t.Handle, Is.Not.EqualTo (IntPtr.Zero), "Handle");
}
}