Skip to content
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

[CoreData] Implement Xcode 16.0 beta 1-6 changes. #21113

Merged
merged 5 commits into from
Sep 5, 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
23 changes: 23 additions & 0 deletions src/CoreData/NSPersistentStoreCoordinator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#if NET
using System;
using System.Runtime.Versioning;
using System.Runtime.InteropServices;

using ObjCRuntime;

namespace CoreData {
public partial class NSPersistentStoreCoordinator {
#if !__TVOS__
[SupportedOSPlatform ("macos15.0")]
[SupportedOSPlatform ("ios18.0")]
[SupportedOSPlatform ("maccatalyst18.0")]
[UnsupportedOSPlatform ("tvos")]
public NSManagedObjectID GetManagedObjectId (string value)
{
using var str = new TransientString (value);
return GetManagedObjectId ((IntPtr) str, (nuint) value.Length);
}
#endif // !__TVOS__
}
}
#endif
8 changes: 8 additions & 0 deletions src/coredata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ interface UserInfoKeys {
[Watch (7, 0), TV (14, 0), Mac (11, 0), iOS (14, 0), MacCatalyst (17, 0)]
[Field ("NSPersistentStoreDeferredLightweightMigrationOptionKey")]
NSString DeferredLightweightMigrationOptionKey { get; }

[Watch (11, 0), TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)]
[Field ("NSPersistentStoreModelVersionChecksumKey")]
NSString ModelVersionChecksumKey { get; }
}

/// <summary>Enumerates valid keys for the user information dictionary used in <see cref="P:CoreData.NSPersistentStoreCoordinator.StoresWillChangeNotification" /> and <see cref="P:CoreData.NSPersistentStoreCoordinator.StoresDidChangeNotification" />.</summary>
Expand Down Expand Up @@ -2374,6 +2378,10 @@ partial interface NSPersistentStoreCoordinator
[Watch (7, 0), TV (14, 0), Mac (11, 0), iOS (14, 0), MacCatalyst (14, 0)]
[Export ("finishDeferredLightweightMigrationTask:")]
bool FinishDeferredLightweightMigrationTask ([NullAllowed] out NSError error);

[NoWatch, NoTV, Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)]
[Export ("managedObjectIDFromUTF8String:length:")]
NSManagedObjectID GetManagedObjectId (IntPtr utf8String, nuint length);
}

interface NSPersistentStoreCoordinatorStoreChangeEventArgs {
Expand Down
1 change: 1 addition & 0 deletions src/frameworks.sources
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ COREDATA_API_SOURCES = \

COREDATA_SOURCES = \
CoreData/NSEntityDescription.cs \
CoreData/NSPersistentStoreCoordinator.cs \
CoreData/Obsolete.cs \

# CoreFoundation
Expand Down
3 changes: 3 additions & 0 deletions tests/cecil-tests/Documentation.KnownFailures.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29627,6 +29627,8 @@ M:CoreData.NSPersistentStoreCoordinator.Execute(CoreData.NSPersistentStoreReques
M:CoreData.NSPersistentStoreCoordinator.FinishDeferredLightweightMigration(Foundation.NSError@)
M:CoreData.NSPersistentStoreCoordinator.FinishDeferredLightweightMigrationTask(Foundation.NSError@)
M:CoreData.NSPersistentStoreCoordinator.GetCurrentPersistentHistoryToken(Foundation.NSObject[])
M:CoreData.NSPersistentStoreCoordinator.GetManagedObjectId(System.IntPtr,System.UIntPtr)
M:CoreData.NSPersistentStoreCoordinator.GetManagedObjectId(System.String)
M:CoreData.NSPersistentStoreCoordinator.GetMetadata(CoreData.NSPersistentStore)
M:CoreData.NSPersistentStoreCoordinator.GetMetadata(System.String,Foundation.NSUrl,Foundation.NSDictionary,Foundation.NSError@)
M:CoreData.NSPersistentStoreCoordinator.Lock
Expand Down Expand Up @@ -60704,6 +60706,7 @@ P:CoreData.UserInfoKeys.AffectedStoresForErrorKey
P:CoreData.UserInfoKeys.DeferredLightweightMigrationOptionKey
P:CoreData.UserInfoKeys.DetailedErrorsKey
P:CoreData.UserInfoKeys.KeyForValidationErrorKey
P:CoreData.UserInfoKeys.ModelVersionChecksumKey
P:CoreData.UserInfoKeys.ObjectForValidationErrorKey
P:CoreData.UserInfoKeys.PersistentStoreSaveConflictsKey
P:CoreData.UserInfoKeys.PredicateForValidationErrorKey
Expand Down
83 changes: 83 additions & 0 deletions tests/monotouch-test/CoreData/NSPersistentStoreCoordinatorTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
//
// Unit tests for NSPersistentStoreCoordinator
//

#if !TVOS

using System;
using System.Linq;

using CoreData;
using Foundation;

using NUnit.Framework;

namespace MonoTouchFixtures.CoreData {

[TestFixture]
[Preserve (AllMembers = true)]
public class NSPersistentStoreCoordinatorTest {
#if NET
[Test]
public void GetManagedObjectId ()
{
TestRuntime.AssertXcodeVersion (16, 0);

using var managedObjectModel = new NSManagedObjectModel ();
// create an entity description
var entity = new NSEntityDescription ();
entity.Name = "Earthquake";

// create an attribute for the entity
using var date = new NSAttributeDescription ();
date.AttributeType = NSAttributeType.Date;
date.Name = "date";
date.Optional = false;

using var latitude = new NSAttributeDescription ();
latitude.AttributeType = NSAttributeType.Double;
latitude.Name = "latitude";
latitude.Optional = false;

using var location = new NSAttributeDescription ();
location.AttributeType = NSAttributeType.String;
location.Name = "location";
location.Optional = false;

using var longitude = new NSAttributeDescription ();
longitude.AttributeType = NSAttributeType.Double;
longitude.Name = "longitude";
longitude.Optional = false;

using var magnitude = new NSAttributeDescription ();
magnitude.AttributeType = NSAttributeType.Float;
magnitude.Name = "magnitude";
magnitude.Optional = false;

using var USGSWebLink = new NSAttributeDescription ();
USGSWebLink.AttributeType = NSAttributeType.String;
USGSWebLink.Name = "USGSWebLink";
USGSWebLink.Optional = false;

// assign the properties to the entity
entity.Properties = new NSPropertyDescription [] {
date,
latitude,
location,
longitude,
magnitude,
USGSWebLink
};

// add the entity to the model, and then add a configuration that
// contains the entities
managedObjectModel.Entities = new NSEntityDescription [] { entity };
managedObjectModel.SetEntities (managedObjectModel.Entities, String.Empty);

using var psc = new NSPersistentStoreCoordinator (managedObjectModel);
Assert.IsNull (psc.GetManagedObjectId ("magnitude"), "GetManagedObjectId");
}
#endif // NET
}
}
#endif // !TVOS

This file was deleted.

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

This file was deleted.

2 changes: 0 additions & 2 deletions tests/xtro-sharpie/api-annotations-dotnet/macOS-CoreData.todo

This file was deleted.

This file was deleted.

2 changes: 0 additions & 2 deletions tests/xtro-sharpie/iOS-CoreData.todo

This file was deleted.

2 changes: 0 additions & 2 deletions tests/xtro-sharpie/macOS-CoreData.todo

This file was deleted.

1 change: 0 additions & 1 deletion tests/xtro-sharpie/tvOS-CoreData.todo

This file was deleted.

1 change: 0 additions & 1 deletion tests/xtro-sharpie/watchOS-CoreData.todo

This file was deleted.