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

[AppKit] Improve bindings for NSPasteboard and NSPasteboardReading a bit. #20643

Merged
merged 7 commits into from
May 30, 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
21 changes: 21 additions & 0 deletions src/AppKit/NSPasteboardReading.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#if !__MACCATALYST__

using System;

using Foundation;
using ObjCRuntime;

#nullable enable

#if NET
namespace AppKit {
public partial interface INSPasteboardReading {
[BindingImpl (BindingImplOptions.Optimizable)]
public unsafe static T? CreateInstance<T> (NSObject propertyList, NSPasteboardType type) where T: NSObject, INSPasteboardReading
{
return CreateInstance<T> (propertyList, type.GetConstant ()!);
}
}
}
#endif // NET
#endif // !__MACCATALYST__
153 changes: 151 additions & 2 deletions src/appkit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11453,6 +11453,7 @@ partial interface NSPasteboard // NSPasteboard does _not_ implement NSPasteboard
[Export ("stringForType:")]
string GetStringForType (string dataType);

#if !XAMCORE_5_0
// Pasteboard data types

[Field ("NSStringPboardType")]
Expand Down Expand Up @@ -11487,6 +11488,7 @@ partial interface NSPasteboard // NSPasteboard does _not_ implement NSPasteboard
[Deprecated (PlatformName.MacOSX, 10, 14, message: "Use 'NSPasteboardTypeRuler' instead.")]
NSString NSRulerType { get; }

[Obsolete ("Use the 'NSPasteboardType' enum instead.")]
[Field ("NSFileContentsPboardType")]
NSString NSFileContentsType { get; }

Expand All @@ -11503,6 +11505,7 @@ partial interface NSPasteboard // NSPasteboard does _not_ implement NSPasteboard
NSString NSHtmlType { get; }

[Field ("NSPICTPboardType")]
[Deprecated (PlatformName.MacOSX, 10, 6 /* Yes, 10.6 */, message: "Do not use, the PICT format was discontinued a long time ago.")]
NSString NSPictType { get; }

[Field ("NSURLPboardType")]
Expand Down Expand Up @@ -11547,77 +11550,219 @@ partial interface NSPasteboard // NSPasteboard does _not_ implement NSPasteboard
[Deprecated (PlatformName.MacOSX, 10, 13, message: "Use 'NSPasteboardNameDrag' instead.")]
NSString NSDragPasteboardName { get; }

[Obsolete ("Use the 'NSPasteboardName' enum instead.")]
[Field ("NSPasteboardNameGeneral")]
NSString NSPasteboardNameGeneral { get; }

[Obsolete ("Use the 'NSPasteboardName' enum instead.")]
[Field ("NSPasteboardNameFont")]
NSString NSPasteboardNameFont { get; }

[Obsolete ("Use the 'NSPasteboardName' enum instead.")]
[Field ("NSPasteboardNameRuler")]
NSString NSPasteboardNameRuler { get; }

[Obsolete ("Use the 'NSPasteboardName' enum instead.")]
[Field ("NSPasteboardNameFind")]
NSString NSPasteboardNameFind { get; }

[Obsolete ("Use the 'NSPasteboardName' enum instead.")]
[Field ("NSPasteboardNameDrag")]
NSString NSPasteboardNameDrag { get; }

[Obsolete ("Use the 'NSPasteboardType' enum instead.")]
[Field ("NSPasteboardTypeString")]
NSString NSPasteboardTypeString { get; }

[Obsolete ("Use the 'NSPasteboardType' enum instead.")]
[Field ("NSPasteboardTypePDF")]
NSString NSPasteboardTypePDF { get; }

[Obsolete ("Use the 'NSPasteboardType' enum instead.")]
[Field ("NSPasteboardTypeTIFF")]
NSString NSPasteboardTypeTIFF { get; }

[Obsolete ("Use the 'NSPasteboardType' enum instead.")]
[Field ("NSPasteboardTypePNG")]
NSString NSPasteboardTypePNG { get; }

[Obsolete ("Use the 'NSPasteboardType' enum instead.")]
[Field ("NSPasteboardTypeRTF")]
NSString NSPasteboardTypeRTF { get; }

[Obsolete ("Use the 'NSPasteboardType' enum instead.")]
[Field ("NSPasteboardTypeRTFD")]
NSString NSPasteboardTypeRTFD { get; }

[Obsolete ("Use the 'NSPasteboardType' enum instead.")]
[Field ("NSPasteboardTypeHTML")]
NSString NSPasteboardTypeHTML { get; }

[Obsolete ("Use the 'NSPasteboardType' enum instead.")]
[Field ("NSPasteboardTypeTabularText")]
NSString NSPasteboardTypeTabularText { get; }

[Obsolete ("Use the 'NSPasteboardType' enum instead.")]
[Field ("NSPasteboardTypeFont")]
NSString NSPasteboardTypeFont { get; }

[Obsolete ("Use the 'NSPasteboardType' enum instead.")]
[Field ("NSPasteboardTypeRuler")]
NSString NSPasteboardTypeRuler { get; }

[Obsolete ("Use the 'NSPasteboardType' enum instead.")]
[Field ("NSPasteboardTypeColor")]
NSString NSPasteboardTypeColor { get; }

[Obsolete ("Use the 'NSPasteboardType' enum instead.")]
[Field ("NSPasteboardTypeSound")]
NSString NSPasteboardTypeSound { get; }

[Obsolete ("Use the 'NSPasteboardType' enum instead.")]
[Field ("NSPasteboardTypeMultipleTextSelection")]
NSString NSPasteboardTypeMultipleTextSelection { get; }

[Field ("NSPasteboardTypeFindPanelSearchOptions")]
[Deprecated (PlatformName.MacOSX, 10, 14, message: "Use 'NSPasteboardTypeTextFinderOptions' instead.")]
NSString NSPasteboardTypeFindPanelSearchOptions { get; }

[Obsolete ("Use the 'NSPasteboardType' enum instead.")]
[Field ("NSPasteboardTypeTextFinderOptions")]
NSString PasteboardTypeTextFinderOptions { get; }

[Obsolete ("Use the 'NSPasteboardType' enum instead.")]
[Field ("NSPasteboardTypeURL")]
NSString NSPasteboardTypeUrl { get; }

[Obsolete ("Use the 'NSPasteboardType' enum instead.")]
[Field ("NSPasteboardTypeFileURL")]
NSString NSPasteboardTypeFileUrl { get; }
#endif // !XAMCORE_5_0

[Export ("prepareForNewContentsWithOptions:")]
nint PrepareForNewContents (NSPasteboardContentsOptions options);
}

[NoMacCatalyst]
enum NSPasteboardName {
[Field ("NSPasteboardNameGeneral")]
General,

[Field ("NSPasteboardNameFont")]
Font,

[Field ("NSPasteboardNameRuler")]
Ruler,

[Field ("NSPasteboardNameFind")]
Find,

[Field ("NSPasteboardNameDrag")]
Drag,
}

[NoMacCatalyst]
enum NSPasteboardType {
[Field ("NSFileContentsPboardType")]
FileContents,

[Field ("NSPasteboardTypeString")]
String,

[Field ("NSPasteboardTypePDF")]
Pdf,

[Field ("NSPasteboardTypeTIFF")]
Tiff,

[Field ("NSPasteboardTypePNG")]
Png,

[Field ("NSPasteboardTypeRTF")]
Rtf,

[Field ("NSPasteboardTypeRTFD")]
Rtfd,

[Field ("NSPasteboardTypeHTML")]
Html,

[Field ("NSPasteboardTypeTabularText")]
TabularText,

[Field ("NSPasteboardTypeFont")]
Font,

[Field ("NSPasteboardTypeRuler")]
Ruler,

[Field ("NSPasteboardTypeColor")]
Color,

[Field ("NSPasteboardTypeSound")]
Sound,

[Field ("NSPasteboardTypeMultipleTextSelection")]
MultipleTextSelection,

[Field ("NSPasteboardTypeTextFinderOptions")]
TextFinderOptions,

[Field ("NSPasteboardTypeURL")]
Url,

[Field ("NSPasteboardTypeFileURL")]
FileUrl,

[Mac (13, 0)]
[Field ("NSPasteboardTypeCollaborationMetadata", "SharedWithYou")]
CollaborationMetadata,

[Field ("NSFindPanelSearchOptionsPboardType")]
FindPanelSearchOptions,

// Deprecated with replacement in all macOS versions we support, so we're not binding them:
// NSFilenamesPboardType
// NSFontPboardType
// NSColorPboardType
// NSHTMLPboardType
// NSMultipleTextSelectionPboardType
// NSPDFPboardType
// NSPICTPboardType (no replacement, just don't use)
// NSRTFDPboardType
// NSRTFDPboardType
// NSRulerPboardType
// NSStringPboardType
// NSTIFFPboardType
// NSTabularTextPboardType
// NSURLPboardType
// NSPasteboardTypeFindPanelSearchOptions
// NSFilesPromisePboardType
// NSInkTextPboardType
// NSPostScriptPboardType
// NSVCardPboardType
// NSGetFileType
// NSRTFPboardType
}

[NoMacCatalyst]
enum NSPasteboardTypeTextFinderOptionKey {
[Field ("NSTextFinderCaseInsensitiveKey")]
CaseInsensitiveKey,

[Field ("NSTextFinderMatchingTypeKey")]
MatchingTypeKey,
}

[NoMacCatalyst]
enum NSPasteboardTypeFindPanelSearchOptionKey {
[Field ("NSFindPanelCaseInsensitiveSearch")]
CaseInsensitiveSearch,

[Field ("NSFindPanelSubstringMatch")]
SubstringMatch,
}

[NoiOS]
[NoTV]
[NoMacCatalyst]
Expand Down Expand Up @@ -11725,9 +11870,13 @@ interface NSPasteboardReading {
[Export ("readingOptionsForType:pasteboard:")]
NSPasteboardReadingOptions GetReadingOptionsForType (string type, NSPasteboard pasteboard);

#if !NET
// This binding is just broken, it's an ObjC ctor (init*) bound as a normal method.
[Abstract]
#if NET
[Export ("initWithPasteboardPropertyList:ofType:")]
NativeHandle Constructor (NSObject propertyList, NSString type);

#else
// This binding is just broken, it's an ObjC ctor (init*) bound as a normal method.
[Export ("xamarinselector:removed:")]
[Obsolete ("It will never be called.")]
NSObject InitWithPasteboardPropertyList (NSObject propertyList, string type);
Expand Down
1 change: 1 addition & 0 deletions src/frameworks.sources
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ APPKIT_SOURCES = \
AppKit/NSDraggingSession.cs \
AppKit/NSDraggingItem.cs \
AppKit/NSPasteboard.cs \
AppKit/NSPasteboardReading.cs \
AppKit/NSSharingServiceDelegate.cs \
AppKit/NSDocument.cs \
AppKit/NSEnumsExtensions.cs \
Expand Down
56 changes: 34 additions & 22 deletions tests/cecil-tests/Documentation.KnownFailures.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2234,10 +2234,38 @@ F:AppKit.NSPageControllerTransitionStyle.StackHistory
F:AppKit.NSPageLayoutResult.Cancelled
F:AppKit.NSPageLayoutResult.Changed
F:AppKit.NSPasteboardContentsOptions.CurrentHostOnly
F:AppKit.NSPasteboardName.Drag
F:AppKit.NSPasteboardName.Find
F:AppKit.NSPasteboardName.Font
F:AppKit.NSPasteboardName.General
F:AppKit.NSPasteboardName.Ruler
F:AppKit.NSPasteboardReadingOptions.AsData
F:AppKit.NSPasteboardReadingOptions.AsKeyedArchive
F:AppKit.NSPasteboardReadingOptions.AsPropertyList
F:AppKit.NSPasteboardReadingOptions.AsString
F:AppKit.NSPasteboardType.CollaborationMetadata
F:AppKit.NSPasteboardType.Color
F:AppKit.NSPasteboardType.FileContents
F:AppKit.NSPasteboardType.FileUrl
F:AppKit.NSPasteboardType.FindPanelSearchOptions
F:AppKit.NSPasteboardType.Font
F:AppKit.NSPasteboardType.Html
F:AppKit.NSPasteboardType.MultipleTextSelection
F:AppKit.NSPasteboardType.Pdf
F:AppKit.NSPasteboardType.Png
F:AppKit.NSPasteboardType.Rtf
F:AppKit.NSPasteboardType.Rtfd
F:AppKit.NSPasteboardType.Ruler
F:AppKit.NSPasteboardType.Sound
F:AppKit.NSPasteboardType.String
F:AppKit.NSPasteboardType.TabularText
F:AppKit.NSPasteboardType.TextFinderOptions
F:AppKit.NSPasteboardType.Tiff
F:AppKit.NSPasteboardType.Url
F:AppKit.NSPasteboardTypeFindPanelSearchOptionKey.CaseInsensitiveSearch
F:AppKit.NSPasteboardTypeFindPanelSearchOptionKey.SubstringMatch
F:AppKit.NSPasteboardTypeTextFinderOptionKey.CaseInsensitiveKey
F:AppKit.NSPasteboardTypeTextFinderOptionKey.MatchingTypeKey
F:AppKit.NSPasteboardWritingOptions.WritingPromised
F:AppKit.NSPathStyle.NavigationBar
F:AppKit.NSPathStyle.PopUp
Expand Down Expand Up @@ -21053,6 +21081,8 @@ M:AppKit.INSHapticFeedbackPerformer.PerformFeedback(AppKit.NSHapticFeedbackPatte
M:AppKit.INSMenuItemValidation.ValidateMenuItem(AppKit.NSMenuItem)
M:AppKit.INSMenuValidation.ValidateMenuItem(AppKit.NSMenuItem)
M:AppKit.INSPasteboardItemDataProvider.ProvideDataForType(AppKit.NSPasteboard,AppKit.NSPasteboardItem,System.String)
M:AppKit.INSPasteboardReading.CreateInstance``1(Foundation.NSObject,AppKit.NSPasteboardType)
M:AppKit.INSPasteboardReading.CreateInstance``1(Foundation.NSObject,Foundation.NSString)
M:AppKit.INSPasteboardTypeOwner.ProvideData(AppKit.NSPasteboard,System.String)
M:AppKit.INSPasteboardWriting.GetPasteboardPropertyListForType(System.String)
M:AppKit.INSPasteboardWriting.GetWritableTypesForPasteboard(AppKit.NSPasteboard)
Expand Down Expand Up @@ -47431,7 +47461,6 @@ P:AppKit.NSParagraphStyle.TextLists
P:AppKit.NSParagraphStyle.UsesDefaultHyphenation
P:AppKit.NSPasteboard.NSColorType
P:AppKit.NSPasteboard.NSDragPasteboardName
P:AppKit.NSPasteboard.NSFileContentsType
P:AppKit.NSPasteboard.NSFilenamesType
P:AppKit.NSPasteboard.NSFilesPromiseType
P:AppKit.NSPasteboard.NSFindPasteboardName
Expand All @@ -47440,27 +47469,7 @@ P:AppKit.NSPasteboard.NSFontType
P:AppKit.NSPasteboard.NSGeneralPasteboardName
P:AppKit.NSPasteboard.NSHtmlType
P:AppKit.NSPasteboard.NSMultipleTextSelectionType
P:AppKit.NSPasteboard.NSPasteboardNameDrag
P:AppKit.NSPasteboard.NSPasteboardNameFind
P:AppKit.NSPasteboard.NSPasteboardNameFont
P:AppKit.NSPasteboard.NSPasteboardNameGeneral
P:AppKit.NSPasteboard.NSPasteboardNameRuler
P:AppKit.NSPasteboard.NSPasteboardTypeColor
P:AppKit.NSPasteboard.NSPasteboardTypeFileUrl
P:AppKit.NSPasteboard.NSPasteboardTypeFindPanelSearchOptions
P:AppKit.NSPasteboard.NSPasteboardTypeFont
P:AppKit.NSPasteboard.NSPasteboardTypeHTML
P:AppKit.NSPasteboard.NSPasteboardTypeMultipleTextSelection
P:AppKit.NSPasteboard.NSPasteboardTypePDF
P:AppKit.NSPasteboard.NSPasteboardTypePNG
P:AppKit.NSPasteboard.NSPasteboardTypeRTF
P:AppKit.NSPasteboard.NSPasteboardTypeRTFD
P:AppKit.NSPasteboard.NSPasteboardTypeRuler
P:AppKit.NSPasteboard.NSPasteboardTypeSound
P:AppKit.NSPasteboard.NSPasteboardTypeString
P:AppKit.NSPasteboard.NSPasteboardTypeTabularText
P:AppKit.NSPasteboard.NSPasteboardTypeTIFF
P:AppKit.NSPasteboard.NSPasteboardTypeUrl
P:AppKit.NSPasteboard.NSPdfType
P:AppKit.NSPasteboard.NSPictType
P:AppKit.NSPasteboard.NSPostScriptType
Expand All @@ -47473,7 +47482,6 @@ P:AppKit.NSPasteboard.NSTabularTextType
P:AppKit.NSPasteboard.NSTiffType
P:AppKit.NSPasteboard.NSUrlType
P:AppKit.NSPasteboard.NSVCardType
P:AppKit.NSPasteboard.PasteboardTypeTextFinderOptions
P:AppKit.NSPasteboardItem.CollaborationMetadata
P:AppKit.NSPathCell.Delegate
P:AppKit.NSPathCellDisplayPanelEventArgs.OpenPanel
Expand Down Expand Up @@ -68306,7 +68314,11 @@ T:AppKit.NSPageLayoutResult
T:AppKit.NSParagraphStyle
T:AppKit.NSPasteboardContentsOptions
T:AppKit.NSPasteboardItemDataProvider
T:AppKit.NSPasteboardName
T:AppKit.NSPasteboardReadingOptions
T:AppKit.NSPasteboardType
T:AppKit.NSPasteboardTypeFindPanelSearchOptionKey
T:AppKit.NSPasteboardTypeTextFinderOptionKey
T:AppKit.NSPasteboardWritingOptions
T:AppKit.NSPathCellDelegate
T:AppKit.NSPathCellDisplayPanelEventArgs
Expand Down
Loading
Loading