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

[Foundation] Update to xcode9 beta 1 #2235

Closed
wants to merge 51 commits into from
Closed

[Foundation] Update to xcode9 beta 1 #2235

wants to merge 51 commits into from

Conversation

timrisi
Copy link
Contributor

@timrisi timrisi commented Jun 20, 2017

No description provided.

@monojenkins
Copy link
Collaborator

Build failure

@@ -722,7 +722,8 @@ public enum NSJsonReadingOptions : nuint_compat_int {
[Flags]
[Native]
public enum NSJsonWritingOptions : nuint_compat_int {
PrettyPrinted = 1
PrettyPrinted = 1,
SortedKeys = (1 << 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a comma on the last entry, it's valid in c# and makes diffs smaller

All = 0,
Team = 1,
Group = 2,
OwnProcess = 3
Copy link
Contributor

Choose a reason for hiding this comment

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

Same (and others)

}

[Native]
public enum NSLinguisticTaggerUnit : nint {
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing availability attributes

[Field ("NSMetadataItemKeywordsKey")]
NSString ItemKeywordsKey { get; }

// extern NSString *const _Nonnull NSMetadataItemTitleKey __attribute__((availability(tvos, unavailable))) __attribute__((availability(watchos, unavailable))) __attribute__((availability(ios, unavailable))) __attribute__((availability(macos, introduced=10.9)));
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove all comments from sharpie

// extern NSString *const _Nonnull NSMetadataItemISOSpeedKey __attribute__((availability(tvos, unavailable))) __attribute__((availability(watchos, unavailable))) __attribute__((availability(ios, unavailable))) __attribute__((availability(macos, introduced=10.9)));
[NoWatch, NoTV, NoiOS, Mac (10, 9)]
[Field ("NSMetadataItemISOSpeedKey")]
NSString ItemISOSpeedKey { get; }
Copy link
Contributor

Choose a reason for hiding this comment

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

Iso not ISO - only 2 letters acronyms are uppercase in .net

[Export ("finished")]
bool Finished { [Bind ("isFinished")] get; }[Watch (4, 0), TV (11, 0), Mac (10, 13), iOS (11, 0)]
[NullAllowed, Export ("estimatedTimeRemaining", ArgumentSemantic.Copy)]
NSNumber EstimatedTimeRemaining { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

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

Look at using bindas attribute
Ask @dalexsoto if you have questions


[Watch (4, 0), TV (11, 0), Mac (10, 13), iOS (11, 0)]
[NullAllowed, Export ("throughput", ArgumentSemantic.Copy)]
NSNumber Throughput { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

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

Same


[Watch (4, 0), TV (11, 0), Mac (10, 13), iOS (11, 0)]
[NullAllowed, Export ("fileTotalCount", ArgumentSemantic.Copy)]
NSNumber FileTotalCount { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

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

Same


[Watch (4, 0), TV (11, 0), Mac (10, 13), iOS (11, 0)]
[NullAllowed, Export ("fileCompletedCount", ArgumentSemantic.Copy)]
NSNumber FileCompletedCount { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

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

Same


[NoWatch, NoTV, Mac (10,13), iOS (11,0)]
[BaseType (typeof(NSObject))]
interface NSFileProviderMessenger
Copy link
Contributor

@spouliot spouliot Jun 21, 2017

Choose a reason for hiding this comment

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

There's probably no default init if there's a designated initializer

}

delegate void LinguisticTaggerEnumerateTagsBlock (string tag, NSRange tokenRange, bool stop);
Copy link
Member

Choose a reason for hiding this comment

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

Block sounds strange in C#, maybe use Callback, or something even more different, like LinguisticTagEnumerator.

[BaseType (typeof(NSObject))]
interface NSItemProviderWriting
{
//TODO: Where to implement this?
Copy link
Member

Choose a reason for hiding this comment

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

Please file a bug about this so that we don't forget (and add the bug # in the comment).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's a card for it on the trello board (https://trello.com/c/snhPxWy2/21-static-properties-inside-protocols), do you want a separate bug as well? Not 100% sure if it's a bug or if there's a way to do it that I'm not aware of

src/generator.cs Outdated
@@ -3850,6 +3850,8 @@ void GenerateTypeLowering (MethodInfo mi, bool null_allowed_override, EnumMode e
by_ref_processing.AppendLine();
if (mai.Type.GetElementType () == TypeManager.System_String){
by_ref_processing.AppendFormat("{0} = {0}Value != IntPtr.Zero ? NSString.FromHandle ({0}Value) : null;", pi.Name.GetSafeParamName ());
} else if ((pi.ParameterType.GetElementType ().IsArray)) {
Copy link
Member

Choose a reason for hiding this comment

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

There are redundant parenthesis around the property access.

@rolfbjarne
Copy link
Member

@timrisi You duplicated some work Miguel already did in PR #2190 😒 IMHO the best would be to remove everything he implemented from your PR, since yours still contains a lot of new API.

@timrisi
Copy link
Contributor Author

timrisi commented Jun 21, 2017

I can pull those parts out, though I'd have to wait for his to be merged and pull the commit(s) into this PR since there's other places that use the protocol I'd be pulling out.

@rolfbjarne
Copy link
Member

It can take a while to get that PR in, since we need to sort out how to bind constructors in protocols (https://bugzilla.xamarin.com/show_bug.cgi?id=57650) first.

It still looks like there are useful bits here even if you remove all related code to that PR though.

@timrisi
Copy link
Contributor Author

timrisi commented Jun 22, 2017

I'll pull out the NSItemProvider(Reading|Writing) stuff for now and create a trello card so it doesn't get forgotten when we figure out how to implement it all (will need updates after miguel's PR goes in)

@monojenkins
Copy link
Collaborator

Build failure

@monojenkins
Copy link
Collaborator

Build failure

[NoWatch, NoTV, NoiOS, Mac (10, 9)]
[Field ("NSMetadataItemTitleKey")]
NSString ItemTitleKey { get; }

Copy link
Contributor

Choose a reason for hiding this comment

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

For each one of these properties that were added, you need to update Foundation/NSMetadataItem.cs which is the strongly typed version of this, and it entails figuring out the data type that is being looked up there.

For example, the documentation for this key is that the value is an NSString, so you would need to add to that class something like:

public NSString Title => return Runtime.GetNSObject<NSString> (GetHandle (NSMetadataQuery.ItemTitleKey))

And this needs to be done for each of these new keys.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do

@timrisi
Copy link
Contributor Author

timrisi commented Jun 27, 2017

Heads up there's more I coming here. Some of the bindings for lost in the shuffle swapping back and forth with doing or fixes on other frameworks (stashed, so it doesn't have to be rebound. I'm fixing up merge conflicts to commit)

@monojenkins
Copy link
Collaborator

Build failure

1 similar comment
@monojenkins
Copy link
Collaborator

Build failure

@@ -1258,4 +1259,51 @@ public enum NSMeasurementFormatterUnitOptions : nuint {
TemperatureWithoutUnit = (1 << 2)
}

[Watch(2, 0), TV(9, 0), Mac(10, 8), iOS(6, 0)]
[Native]
public enum NSXPCConnectionOptions : nuint
Copy link
Member

Choose a reason for hiding this comment

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

XPC -> Xpc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Realized this one after I pushed. I have all the Xpcs changed locally for when I push again

[Native]
public enum NSXPCConnectionOptions : nuint
{
NSXPCConnectionPrivileged = (1 << 12)
Copy link
Member

Choose a reason for hiding this comment

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

Same

Copy link
Contributor

Choose a reason for hiding this comment

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

in this case the enum member name should not be prefixed with NSXPCConnection anyway


[Watch (4, 0), TV (11, 0), Mac (10, 13), iOS (11, 0)]
[NullAllowed, Export ("fileURL", ArgumentSemantic.Copy)]
NSUrl FileURL { get; set; }
Copy link
Member

Choose a reason for hiding this comment

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

URL -> Url.

void SetClasses (NSSet<Class> classes, Selector sel, nuint arg, bool ofReply);

[Export ("classesForSelector:argumentIndex:ofReply:")]
NSSet<Class> ClassesForSelector (Selector sel, nuint arg, bool ofReply);
Copy link
Member

Choose a reason for hiding this comment

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

GetClasses


[Export ("interfaceForSelector:argumentIndex:ofReply:")]
[return: NullAllowed]
NSXpcInterface InterfaceForSelector (Selector sel, nuint arg, bool ofReply);
Copy link
Member

Choose a reason for hiding this comment

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

GetInterface

Copy link
Contributor

@spouliot spouliot left a comment

Choose a reason for hiding this comment

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

We need to add tests for those Xpc API to ensure the proving stuff works correctly. we should not expose (post beta) them unless they are confirmed to work properly.

[Native]
public enum NSXPCConnectionOptions : nuint
{
NSXPCConnectionPrivileged = (1 << 12)
Copy link
Contributor

Choose a reason for hiding this comment

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

in this case the enum member name should not be prefixed with NSXPCConnection anyway

[Watch (4, 0), TV (11, 0), Mac (10, 13), iOS (11, 0)]
[Native]
public enum NSItemProviderFileOptions : nint {
NSItemProviderFileOptionOpenInPlace = 1,
Copy link
Contributor

Choose a reason for hiding this comment

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

remove NSItemProviderFileOption prefix on name


[Watch (4,0), TV (11,0), Mac (10,13), iOS (11,0)]
[Export ("writeToURL:error:")]
bool WriteToUrl (NSUrl url, [NullAllowed] out NSError error);
Copy link
Contributor

Choose a reason for hiding this comment

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

Write the rest is implied by the parameters

[Static]
[Export ("arrayWithContentsOfURL:error:")]
[return: NullAllowed]
NSObject[] FromUrl (NSUrl url, [NullAllowed] out NSError error);
Copy link
Contributor

Choose a reason for hiding this comment

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

that's an odd case. In general returning an [] make sense, but this is a static method in NSArray so it should return an NSArray not another type.

@@ -1715,7 +1725,11 @@ interface NSDateFormatter {

[iOS (8,0), Mac (10,10)]
[Export ("setLocalizedDateFormatFromTemplate:")]
void SetLocalizedDateFormatFromTemplate (string dateFormatTemplate);
void SetLocalizedDateFormatFromTemplate (string dateFormatTemplate);
Copy link
Contributor

Choose a reason for hiding this comment

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

SetLocalizedDateFormat, the rest is implied


[NoWatch, NoTV, Mac (10, 13), iOS (11, 0)]
[Export ("observedPresentedItemUbiquityAttributes", ArgumentSemantic.Strong)]
NSSet<NSString> ObservedUbiquityAttributes { get; }
Copy link
Contributor

Choose a reason for hiding this comment

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

same


[NoWatch, NoTV, Mac (10,13), iOS (11,0)]
[Async, Export ("getFileProviderMessageInterfacesForItemAtURL:completionHandler:")]
void GetFileProviderMessageInterfaces (NSUrl url, FileProviderMessageInterfacesCompletionHandler completionHandler);
Copy link
Contributor

Choose a reason for hiding this comment

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

Does FileProviderMessageInterfacesCompletionHandler exists in ObjC ? (it's not prefixed by NS)

When we have a single parameter or a two parameters with a NSError then we can (when it's not confusing) use Action<T[,V]>. That makes it easier to share delegates in code and reduce metadata (app size).

The reason why we can't do it for longer delegates is because the arguments become unclear. That's not the case here since the method name is clear about what will be given and the NSError itself is self-documenting.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gotcha. It had been pointed out one one of the other (longer) handlers that we needed the delegate because of the multiple parameters and I made all of 2 parameters (with one as an NSError) into delegates, so there's probably others I can change back as well.

I'll go through ll the delegates and convert any that match back to Action<T, V>

@@ -12435,6 +13368,7 @@ interface NSAffineTransform : NSSecureCoding, NSCopying {
CGAffineTransform TransformStruct { get; set; }
}

[Availability (Deprecated = Platform.Mac_10_13 | Platform.iOS_11_0 | Platform.Watch_2_0 | Platform.TV_11_0, Message = "Use NSXpcConnection instead")]
Copy link
Contributor

Choose a reason for hiding this comment

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

missing . at end of message

@@ -12538,6 +13472,7 @@ interface NSConnection {
NSConnectionDelegate Delegate { get; set; }
}

[Availability (Deprecated = Platform.Mac_10_13 | Platform.iOS_11_0 | Platform.Watch_2_0 | Platform.TV_11_0, Message = "Use NSXpcConnection instead")]
Copy link
Contributor

Choose a reason for hiding this comment

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

same

@@ -12561,6 +13496,7 @@ interface NSConnectionDelegate {
bool AllowNewConnection (NSConnection newConnection, NSConnection parentConnection);
}

[Availability (Deprecated = Platform.Mac_10_13 | Platform.iOS_11_0 | Platform.Watch_2_0 | Platform.TV_11_0, Message = "Use NSXpcConnection instead")]
Copy link
Contributor

Choose a reason for hiding this comment

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

same

@monojenkins
Copy link
Collaborator

Build failure

@monojenkins
Copy link
Collaborator

Build failure

@monojenkins
Copy link
Collaborator

Build failure

@monojenkins
Copy link
Collaborator

Build failure

@timrisi
Copy link
Contributor Author

timrisi commented Jul 26, 2017

I removed the BindAs attributes and manually bound strongly-typed versions of the properties, so I'm removing the don't-merge tag

@timrisi timrisi removed the do-not-merge Do not merge this pull request label Jul 26, 2017
@monojenkins
Copy link
Collaborator

Build success

Timothy Risi and others added 12 commits July 31, 2017 12:35
This fix is needed by PDFKit because it is a remapped framework[0],
the current code generates incorrect FieldAttribute on smart enums
because it uses `fa.LibraryName` as first option and this causes
remmaped frameworks have incorrect LibraryName generated for example
if a Field uses `+CoreImage` as `LibraryName` the following incorrect
code is generated:

```
	[Field ("First", "+CoreImage")]
	internal unsafe static IntPtr First {
		get {
			fixed (IntPtr *storage = &values [0])
				return Dlfcn.CachePointer (Libraries.+CoreImage.Handle, "First", storage);
		}
	}
```

[0]: https://github.com/xamarin/xamarin-macios/blob/f5956d6cc1eb5dfa7bab16628cf282d40237f64e/src/generator.cs#L5985
Apple removed (mistake?) some API in beta 1. Filed as rdar 33590997

Internal tracking in
https://trello.com/c/J8BDDUV9/86-33590997-coreanimation-quartzcore-api-removals
@@ -40,7 +40,7 @@ IOS_PRODUCT=Xamarin.iOS
IOS_PACKAGE_NAME=Xamarin.iOS
IOS_PACKAGE_NAME_LOWER=$(shell echo $(IOS_PACKAGE_NAME) | tr "[:upper:]" "[:lower:]")
# NEVER customize IOS_PACKAGE_VERSION itself, other parts (mtouch, web updater) are using the IOS_PACKAGE_VERSION_* variables
IOS_PACKAGE_VERSION=10.99.1.$(IOS_COMMIT_DISTANCE)
IOS_PACKAGE_VERSION=10.99.2.$(IOS_COMMIT_DISTANCE)
Copy link
Member

Choose a reason for hiding this comment

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

This looks wrong, I think you need to merge in the xcode9 branch.

@spouliot
Copy link
Contributor

spouliot commented Aug 1, 2017

@timrisi there should not be any need to merge in most cases as the PR gets tested on top of the HEAD of the branch.

@timrisi
Copy link
Contributor Author

timrisi commented Aug 1, 2017

In this case, I was merging so I could get the PhotosUI commit since it fixes crashes in the introspection tests to make it a lot easier to run the tests locally. Not sure what exactly I did here, this is the first time I've accidentally pulled in other commits when I tried to merge.

@monojenkins
Copy link
Collaborator

Build failure

@spouliot
Copy link
Contributor

spouliot commented Aug 9, 2017

@timrisi the PR failed the tests (but was not investigated), it's also not mergeable (fixing this does not require a merge) and it's not clear which beta version is supported.
Please review the failure(s) and update the PR to cover up to beta 5.

@timrisi
Copy link
Contributor Author

timrisi commented Aug 9, 2017

Replaced with an updated (and rebased) PR: #2468

@timrisi timrisi closed this Aug 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants