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] Fix all availability attributes in this framework. #22261

Merged
merged 1 commit into from
Mar 3, 2025
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
2 changes: 0 additions & 2 deletions src/AppKit/AppKitThreadAccessException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
#nullable enable

namespace AppKit {
#if NET
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("maccatalyst")]
#endif
public class AppKitThreadAccessException : Exception {
public AppKitThreadAccessException () : base ("AppKit Consistency error: you are calling a method that can only be invoked from the UI thread.")
{
Expand Down
2 changes: 0 additions & 2 deletions src/AppKit/Defs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@
#nullable enable

namespace AppKit {
#if NET
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("maccatalyst")]
#endif
[StructLayout (LayoutKind.Sequential)]
public struct NSEdgeInsets {
public nfloat Top;
Expand Down
8 changes: 0 additions & 8 deletions src/AppKit/NSAccessibility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,9 @@
namespace AppKit {
public partial interface INSAccessibility { }

#if NET
[SupportedOSPlatform ("macos")]
#endif
public partial class NSAccessibility {
#if !COREBUILD
#if NET
[SupportedOSPlatform ("macos")]
#endif
[DllImport (Constants.AppKitLibrary)]
static extern CGRect NSAccessibilityFrameInView (NativeHandle parentView, CGRect frame);

Expand All @@ -42,9 +37,6 @@ public static CGRect GetFrameInView (NSView parentView, CGRect frame)
return NSAccessibilityFrameInView (parentView.GetHandle (), frame);
}

#if NET
[SupportedOSPlatform ("macos")]
#endif
[DllImport (Constants.AppKitLibrary)]
static extern CGPoint NSAccessibilityPointInView (NativeHandle parentView, CGPoint point);

Expand Down
4 changes: 0 additions & 4 deletions src/AppKit/NSBezierPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,6 @@ public unsafe void AppendPathWithGlyphs (uint [] glyphs, NSFont font)
}
#endif

#if NET
[SupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("maccatalyst")]
#endif
public unsafe void Append (uint [] glyphs, NSFont font)
{
if (glyphs is null)
Expand Down
20 changes: 0 additions & 20 deletions src/AppKit/NSButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ public partial class NSButton {
set { base.Cell = value; }
}

#if NET
[SupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("maccatalyst")]
#endif
public static NSButton CreateButton (string title, NSImage image, Action action)
{
var dispatcher = new NSActionDispatcher (action);
Expand All @@ -63,10 +59,6 @@ public static NSButton CreateButton (string title, NSImage image, Action action)
return control;
}

#if NET
[SupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("maccatalyst")]
#endif
public static NSButton CreateButton (string title, Action action)
{
var dispatcher = new NSActionDispatcher (action);
Expand All @@ -75,10 +67,6 @@ public static NSButton CreateButton (string title, Action action)
return control;
}

#if NET
[SupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("maccatalyst")]
#endif
public static NSButton CreateButton (NSImage image, Action action)
{
var dispatcher = new NSActionDispatcher (action);
Expand All @@ -87,10 +75,6 @@ public static NSButton CreateButton (NSImage image, Action action)
return control;
}

#if NET
[SupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("maccatalyst")]
#endif
public static NSButton CreateCheckbox (string title, Action action)
{
var dispatcher = new NSActionDispatcher (action);
Expand All @@ -99,10 +83,6 @@ public static NSButton CreateCheckbox (string title, Action action)
return control;
}

#if NET
[SupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("maccatalyst")]
#endif
public static NSButton CreateRadioButton (string title, Action action)
{
var dispatcher = new NSActionDispatcher (action);
Expand Down
38 changes: 0 additions & 38 deletions src/AppKit/NSFont.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ public partial class NSFont {
return new NSFont (font.Handle);
}

#if NET
[SupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("maccatalyst")]
#endif
public unsafe CGRect [] GetBoundingRects (CGGlyph [] glyphs)
{
if (glyphs is null)
Expand All @@ -41,10 +37,6 @@ public unsafe CGRect [] GetBoundingRects (CGGlyph [] glyphs)
return bounds;
}

#if NET
[SupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("maccatalyst")]
#endif
public unsafe CGSize [] GetAdvancements (CGGlyph [] glyphs)
{
if (glyphs is null)
Expand Down Expand Up @@ -151,41 +143,29 @@ public unsafe CGSize [] GetAdvancements (CGGlyph [] glyphs)
return ptr == IntPtr.Zero ? null : new NSFont (ptr);
}

#if NET
[SupportedOSPlatform ("macos")]
[ObsoletedOSPlatform ("macos10.13")]
[UnsupportedOSPlatform ("maccatalyst")]
#else
[Deprecated (PlatformName.MacOSX, 10, 13)]
#endif
public virtual NSFont? PrinterFont {
get {
var ptr = _PrinterFont;
return ptr == IntPtr.Zero ? null : new NSFont (ptr);
}
}

#if NET
[SupportedOSPlatform ("macos")]
[ObsoletedOSPlatform ("macos10.13")]
[UnsupportedOSPlatform ("maccatalyst")]
#else
[Deprecated (PlatformName.MacOSX, 10, 13)]
#endif
public virtual NSFont? ScreenFont {
get {
var ptr = _ScreenFont;
return ptr == IntPtr.Zero ? null : new NSFont (ptr);
}
}

#if NET
[SupportedOSPlatform ("macos")]
[ObsoletedOSPlatform ("macos10.13")]
[UnsupportedOSPlatform ("maccatalyst")]
#else
[Deprecated (PlatformName.MacOSX, 10, 13)]
#endif
public virtual NSFont? ScreenFontWithRenderingMode (NSFontRenderingMode renderingMode)
{
var ptr = _ScreenFontWithRenderingMode (renderingMode);
Expand All @@ -198,42 +178,24 @@ public virtual NSFont? ScreenFont {
return ptr == IntPtr.Zero ? null : new NSFont (ptr);
}

#if NET
[SupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("maccatalyst")]
#endif
public static NSFont? SystemFontOfSize (nfloat fontSize, nfloat weight)
{
var ptr = _SystemFontOfSize (fontSize, weight);
return ptr == IntPtr.Zero ? null : new NSFont (ptr);
}

#if NET
[SupportedOSPlatform ("macos13.0")]
[UnsupportedOSPlatform ("maccatalyst")]
#else
[Mac (13, 0)]
#endif
public static NSFont? SystemFontOfSize (nfloat fontSize, nfloat weight, nfloat width)
{
var ptr = _SystemFontOfSize (fontSize, weight, width);
return ptr == IntPtr.Zero ? null : new NSFont (ptr);
}

#if NET
[SupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("maccatalyst")]
#endif
public static NSFont? MonospacedDigitSystemFontOfSize (nfloat fontSize, nfloat weight)
{
var ptr = _MonospacedDigitSystemFontOfSize (fontSize, weight);
return ptr == IntPtr.Zero ? null : new NSFont (ptr);
}

#if NET
[SupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("maccatalyst")]
#endif
public static NSFont? MonospacedSystemFont (nfloat fontSize, nfloat weight)
{
var ptr = _MonospacedSystemFont (fontSize, weight);
Expand Down
6 changes: 0 additions & 6 deletions src/AppKit/NSGestureRecognizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@ public NSGestureRecognizer (Selector sel, Token token) : this (token, sel)
MarkDirty ();
}

#if NET
[SupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("maccatalyst")]
#endif
[Register ("__NSGestureRecognizerToken")]
[Preserve (Conditional = true)]
public class Token : NSObject {
Expand All @@ -49,10 +47,8 @@ public Token ()
}
}

#if NET
[SupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("maccatalyst")]
#endif
[Register ("__NSGestureRecognizerParameterlessToken")]
[Preserve (Conditional = true)]
public class ParameterlessDispatch : Token {
Expand All @@ -71,10 +67,8 @@ public void Activated ()
}
}

#if NET
[SupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("maccatalyst")]
#endif
[Register ("__NSGestureRecognizerParametrizedToken")]
[Preserve (Conditional = true)]
public class ParametrizedDispatch : Token {
Expand Down
18 changes: 0 additions & 18 deletions src/AppKit/NSGraphics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@
#nullable enable

namespace AppKit {
#if NET
[SupportedOSPlatform ("macos")]
#endif
public static class NSGraphics {
public static readonly float White = 1;
public static readonly float Black = 0;
Expand Down Expand Up @@ -179,21 +177,13 @@ public static void FrameRect (CGRect rect, nfloat frameWidth, NSCompositingOpera
NSFrameRectWithWidthUsingOperation (rect, frameWidth, (nuint) (ulong) operation);
}

#if NET
[SupportedOSPlatform ("macos")]
[ObsoletedOSPlatform ("macos14.0", "Use 'NSCursor.DisappearingItemCursor' instead.")]
#else
[Deprecated (PlatformName.MacOSX, 14, 0, message: "Use 'NSCursor.DisappearingItemCursor' instead.")]
#endif
[DllImport (Constants.AppKitLibrary, EntryPoint = "NSShowAnimationEffect")]
extern static void NSShowAnimationEffect (nuint animationEffect, CGPoint centerLocation, CGSize size, NativeHandle animationDelegate, NativeHandle didEndSelector, IntPtr contextInfo);

#if NET
[SupportedOSPlatform ("macos")]
[ObsoletedOSPlatform ("macos14.0", "Use 'NSCursor.DisappearingItemCursor' instead.")]
#else
[Deprecated (PlatformName.MacOSX, 14, 0, message: "Use 'NSCursor.DisappearingItemCursor' instead.")]
#endif
public static void ShowAnimationEffect (NSAnimationEffect animationEffect, CGPoint centerLocation, CGSize size, NSObject animationDelegate, Selector didEndSelector, IntPtr contextInfo)
{
NSShowAnimationEffect ((nuint) (ulong) animationEffect, centerLocation, size, animationDelegate.GetHandle (), didEndSelector.Handle, contextInfo);
Expand Down Expand Up @@ -250,21 +240,13 @@ public static CGRect DrawTiledRects (CGRect aRect, CGRect clipRect, NSRectEdge [
[DllImport (Constants.AppKitLibrary, EntryPoint = "NSDrawWindowBackground")]
public extern static void DrawWindowBackground (CGRect aRect);

#if NET
[SupportedOSPlatform ("macos")]
[ObsoletedOSPlatform ("macos10.11", "Not usually necessary, 'NSAnimationContext.RunAnimation' can be used instead and not suffer from performance issues.")]
#else
[Deprecated (PlatformName.MacOSX, 10, 11, message: "Not usually necessary, 'NSAnimationContext.RunAnimation' can be used instead and not suffer from performance issues.")]
#endif
[DllImport (Constants.AppKitLibrary, EntryPoint = "NSDisableScreenUpdates")]
public extern static void DisableScreenUpdates ();

#if NET
[SupportedOSPlatform ("macos")]
[ObsoletedOSPlatform ("macos10.11", "Not usually necessary, 'NSAnimationContext.RunAnimation' can be used instead and not suffer from performance issues.")]
#else
[Deprecated (PlatformName.MacOSX, 10, 11, message: "Not usually necessary, 'NSAnimationContext.RunAnimation' can be used instead and not suffer from performance issues.")]
#endif
[DllImport (Constants.AppKitLibrary, EntryPoint = "NSEnableScreenUpdates")]
public extern static void EnableScreenUpdates ();

Expand Down
4 changes: 0 additions & 4 deletions src/AppKit/NSSegmentedControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ public partial class NSSegmentedControl {
set { base.Cell = value; }
}

#if NET
[SupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("maccatalyst")]
#endif
public static NSSegmentedControl FromLabels (string [] labels, NSSegmentSwitchTracking trackingMode, Action action)
{
var dispatcher = new NSActionDispatcher (action);
Expand All @@ -35,10 +33,8 @@ public static NSSegmentedControl FromLabels (string [] labels, NSSegmentSwitchTr
return control;
}

#if NET
[SupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("maccatalyst")]
#endif
public static NSSegmentedControl FromImages (NSImage [] images, NSSegmentSwitchTracking trackingMode, Action action)
{
var dispatcher = new NSActionDispatcher (action);
Expand Down
4 changes: 0 additions & 4 deletions src/AppKit/NSSlider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,8 @@ namespace AppKit {
public partial class NSSlider {
NSActionDispatcher? dispatcher;

#if NET
[SupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("maccatalyst")]
#endif
public static NSSlider FromTarget (Action action)
{
var dispatcher = new NSActionDispatcher (action);
Expand All @@ -51,10 +49,8 @@ public static NSSlider FromTarget (Action action)
return control;
}

#if NET
[SupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("maccatalyst")]
#endif
public static NSSlider FromValue (double value, double minValue, double maxValue, Action action)
{
var dispatcher = new NSActionDispatcher (action);
Expand Down
2 changes: 1 addition & 1 deletion src/AppKit/NSStringAttributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ int SetUnderlineStyle (NSString attr, NSUnderlineStyle style,
{
var value = (int) style | (int) pattern;
if (byWord) {
value |= (int) NSAttributedString.UnderlineByWordMaskAttributeName;
value |= (int) NSUnderlineStyle.ByWord;
}

SetNumberValue (attr, value);
Expand Down
8 changes: 3 additions & 5 deletions src/AppKit/NSStringDrawing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@

namespace AppKit {

#if NET
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("tvos")]
#endif
[UnsupportedOSPlatform ("ios")]
[UnsupportedOSPlatform ("tvos")]
[UnsupportedOSPlatform ("maccatalyst")]
// Manual bindings, easier than make the generator support extension methods on non-NSObject-derived types (string in this case).
public unsafe static partial class NSStringDrawing {
public static void DrawAtPoint (this string This, CGPoint point, NSDictionary? attributes)
Expand Down
Loading