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] Remove NET conditions from some files. #22004

Merged
merged 3 commits into from
Jan 18, 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
16 changes: 0 additions & 16 deletions src/AppKit/Enums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1439,22 +1439,6 @@ public enum NSPasteboardReadingOptions : ulong {
AsKeyedArchive = 4,
}

#if !NET && MONOMAC // Use the one in Foundation instead, only keep this in macOS until .NET.
[Native]
public enum NSUnderlineStyle : long {
None = 0x00,
Single = 0x01,
Thick = 0x02,
Double = 0x09,
PatternSolid = 0x0000,
PatternDot = 0x0100,
PatternDash = 0x0200,
PatternDashDot = 0x0300,
PatternDashDotDot = 0x0400,
ByWord = 0x8000,
}
#endif

// Convenience enum, untyped in ObjC
[NoMacCatalyst]
public enum NSUnderlinePattern : int {
Expand Down
26 changes: 1 addition & 25 deletions src/Foundation/Compat.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Compat.cs: Stuff we won't provide in Xamarin.iOS.dll or newer XAMCORE_* profiles
// Compat.cs: Stuff we won't provide in newer XAMCORE_* profiles
//
// Authors:
// Sebastien Pouliot <[email protected]>
Expand All @@ -12,30 +12,6 @@
using ObjCRuntime;

namespace Foundation {

#if !NET
#if MONOMAC
public partial class NSError {

// removed in Xcode 11 GM
[Obsolete ("This API has been removed.")]
public static NSError GetFileProviderErrorForOutOfDateItem (FileProvider.INSFileProviderItem updatedVersion)
{
return null;
}
}
#endif

public partial class NSUserActivity {

[Obsolete ("Use the constructor that allows you to set an activity type.")]
public NSUserActivity ()
: this (String.Empty)
{
}
}
#endif // !NET

#if !XAMCORE_5_0
#if __IOS__ && !__MACCATALYST__
public partial class NSUrlConnection {
Expand Down
10 changes: 0 additions & 10 deletions src/Foundation/DictionaryContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,14 @@
using UIKit;
#endif

#if !NET
using NativeHandle = System.IntPtr;
#endif

#nullable enable

namespace Foundation {

#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
#endif
public abstract class DictionaryContainer {
#if !COREBUILD
protected DictionaryContainer ()
Expand Down Expand Up @@ -247,11 +241,7 @@ protected DictionaryContainer (NSDictionary? dictionary)
return value as NSDictionary<TKey, TValue>;
}

#if NET
protected T? GetStrongDictionary<[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] T> (NSString key)
#else
protected T? GetStrongDictionary<T> (NSString key)
#endif
where T : DictionaryContainer
{
return GetStrongDictionary (key, dict =>
Expand Down
30 changes: 0 additions & 30 deletions src/Foundation/Enum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,9 @@ public enum NSUrlCredentialPersistence : ulong {

#if MONOMAC

#if !NET
[Native]
public enum NSBundleExecutableArchitecture : long {
#else
/// <summary>The bundle's architecture.</summary>
[NoiOS][NoTV][NoMacCatalyst]
public enum NSBundleExecutableArchitecture {
#endif
I386 = 0x00000007,
PPC = 0x00000012,
X86_64 = 0x01000007,
Expand Down Expand Up @@ -252,10 +247,6 @@ public enum NSCalendarUnit : ulong {
public enum NSDataReadingOptions : ulong {
Mapped = 1 << 0,
Uncached = 1 << 1,
#if !NET
[Obsolete ("This option is unavailable.")]
Coordinated = 1 << 2,
#endif
MappedAlways = 1 << 3,
}

Expand Down Expand Up @@ -592,10 +583,6 @@ public enum NSVolumeEnumerationOptions : ulong {
[Flags]
[Native]
public enum NSDirectoryEnumerationOptions : ulong {
#if !NET
[Obsolete ("Use 'None' instead.")]
SkipsNone = 0,
#endif
None = 0,
SkipsSubdirectoryDescendants = 1 << 0,
SkipsPackageDescendants = 1 << 1,
Expand Down Expand Up @@ -808,10 +795,6 @@ public enum NSJsonReadingOptions : ulong {
Json5Allowed = 8,
[iOS (15, 0), TV (15, 0), MacCatalyst (15, 0)]
TopLevelDictionaryAssumed = 16,
#if !NET
[Obsolete ("Use 'FragmentsAllowed. instead.")]
AllowFragments = FragmentsAllowed,
#endif
}

[Flags]
Expand Down Expand Up @@ -889,7 +872,6 @@ public enum NSAttributedStringEnumeration : ulong {
LongestEffectiveRangeNotRequired = 1 << 20,
}

#if NET || !MONOMAC
// macOS has defined this in AppKit as well, but starting with .NET we're going
// to use this one only.
[Native]
Expand All @@ -905,7 +887,6 @@ public enum NSUnderlineStyle : long {
PatternDashDotDot = 0x0400,
ByWord = 0x8000,
}
#endif

// There's an AppKit.NSWritingDirection, which is deprecated.
// There's also an UIKit.UITextWritingDirection, which is deprecated too.
Expand Down Expand Up @@ -977,17 +958,6 @@ public enum NSLigatureType : long {
All,
}

#if !NET
[Flags]
[Native]
public enum NSDateComponentsWrappingBehavior : ulong {
None = 0,
WrapCalendarComponents = 1 << 0,

// Did not add the new enums here, we moved them elsewhere, and provided overloads.
}
#endif

[Flags]
[Native]
public enum NSCalendarOptions : ulong {
Expand Down
2 changes: 0 additions & 2 deletions src/Foundation/LinkerSafeAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@

namespace Foundation {

#if NET
[Obsolete ("Replace with '[assembly: System.Reflection.AssemblyMetadata (\"IsTrimmable\", \"True\")]'.")]
[EditorBrowsable (EditorBrowsableState.Never)]
#endif
[AttributeUsage (AttributeTargets.Assembly)]
public sealed class LinkerSafeAttribute : Attribute {

Expand Down
3 changes: 0 additions & 3 deletions src/Foundation/ModelAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,5 @@ public sealed class ModelAttribute : Attribute {
public ModelAttribute () { }

public string? Name { get; set; }
#if !NET
public bool AutoGeneratedName { get; set; }
#endif
}
}
72 changes: 0 additions & 72 deletions src/Foundation/MonoTouchException.cs

This file was deleted.

16 changes: 1 addition & 15 deletions src/Foundation/NSArray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@
using CoreFoundation;
using ObjCRuntime;

#if !NET
using NativeHandle = System.IntPtr;
#endif

// Disable until we get around to enable + fix any issues.
#nullable disable

Expand Down Expand Up @@ -232,7 +228,6 @@ static public NSArray FromStrings (IReadOnlyList<string> items)
}
}

#if NET
/// <summary>Create an <see cref="NSArray" /> from the specified pointers.</summary>
/// <param name="items">Array of pointers (to <see cref="NSObject" /> instances).</param>
/// <remarks>If the <paramref name="items" /> array is null, an <see cref="ArgumentNullException" /> is thrown.</remarks>
Expand All @@ -242,11 +237,10 @@ static internal NSArray FromIntPtrs (IntPtr [] items)
throw new ArgumentNullException (nameof (items));

unsafe {
fixed (IntPtr *valuesPtr = items)
fixed (IntPtr* valuesPtr = items)
return Runtime.GetNSObject<NSArray> (NSArray.FromObjects ((IntPtr) valuesPtr, items.Length))!;
}
}
#endif

static public NSArray FromIntPtrs (NativeHandle [] vals)
{
Expand Down Expand Up @@ -274,15 +268,7 @@ internal static nuint GetCount (IntPtr handle)

internal static NativeHandle GetAtIndex (NativeHandle handle, nuint i)
{
#if NET
return Messaging.NativeHandle_objc_msgSend_UIntPtr (handle, Selector.GetHandle ("objectAtIndex:"), (UIntPtr) i);
#else
#if MONOMAC
return Messaging.IntPtr_objc_msgSend_UIntPtr (handle, selObjectAtIndex_XHandle, (UIntPtr) i);
#else
return Messaging.IntPtr_objc_msgSend_UIntPtr (handle, Selector.GetHandle ("objectAtIndex:"), (UIntPtr) i);
#endif
#endif
}

[Obsolete ("Use of 'CFArray.StringArrayFromHandle' offers better performance.")]
Expand Down
20 changes: 0 additions & 20 deletions src/Foundation/NSArray_1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@

using ObjCRuntime;

#if !NET
using NativeHandle = System.IntPtr;
#endif

namespace Foundation {
#if false // https://github.com/xamarin/xamarin-macios/issues/15577
public delegate bool NSOrderedCollectionDifferenceEquivalenceTest<TValue> (TValue? first, TValue? second);
Expand Down Expand Up @@ -105,27 +101,15 @@ public TKey this [nint idx] {

#if false // https://github.com/xamarin/xamarin-macios/issues/15577

#if !NET
[TV (13,0), iOS (13,0)]
#else
[SupportedOSPlatform ("ios13.0"), SupportedOSPlatform ("tvos13.0"), SupportedOSPlatform ("macos")]
#endif
public NSOrderedCollectionDifference<TKey>? GetDifference (TKey[] other, NSOrderedCollectionDifferenceCalculationOptions options)
=> Runtime.GetNSObject <NSOrderedCollectionDifference<TKey>> (_GetDifference (NSArray.FromNSObjects (other), options));

#if !NET
[TV (13,0), iOS (13,0)]
#else
[SupportedOSPlatform ("ios13.0"), SupportedOSPlatform ("tvos13.0"), SupportedOSPlatform ("macos")]
#endif
public NSOrderedCollectionDifference<TKey>? GetDifference (TKey[] other)
=> Runtime.GetNSObject <NSOrderedCollectionDifference<TKey>> (_GetDifference (NSArray.FromNSObjects (other)));

#if !NET
[TV (13,0), iOS (13,0)]
#else
[SupportedOSPlatform ("ios13.0"), SupportedOSPlatform ("tvos13.0"), SupportedOSPlatform ("macos")]
#endif
public TKey[]? GetArrayByApplyingDifference (NSOrderedCollectionDifference difference)
=> NSArray.ArrayFromHandle<TKey> (_GetArrayByApplyingDifference (difference));
static readonly NSOrderedCollectionDifferenceEquivalenceTestProxy static_DiffEqualityGeneric = DiffEqualityHandlerGeneric;
Expand All @@ -142,11 +126,7 @@ static bool DiffEqualityHandlerGeneric (IntPtr block, IntPtr first, IntPtr secon
return false;
}

#if !NET
[TV (13,0), iOS (13,0)]
#else
[SupportedOSPlatform ("ios13.0"), SupportedOSPlatform ("tvos13.0"), SupportedOSPlatform ("macos")]
#endif
public NSOrderedCollectionDifference<TKey>? GetDifferenceFromArray (NSArray<TKey> other, NSOrderedCollectionDifferenceCalculationOptions options, NSOrderedCollectionDifferenceEquivalenceTest<TKey> equivalenceTest)
{
if (equivalenceTest is null)
Expand Down
4 changes: 1 addition & 3 deletions src/Foundation/NSAttributedString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,16 +237,14 @@ public string? Value {
return Runtime.GetNSObject<NSDictionary> (LowLevelGetAttributes (location, out effectiveRange));
}

#if NET
public IntPtr LowLevelGetAttributes (nint location, out NSRange effectiveRange)
{
unsafe {
fixed (NSRange *effectiveRangePtr = &effectiveRange) {
fixed (NSRange* effectiveRangePtr = &effectiveRange) {
return LowLevelGetAttributes (location, (IntPtr) effectiveRangePtr);
}
}
}
#endif

public NSAttributedString (string str, CTStringAttributes? attributes)
: this (str, attributes?.Dictionary)
Expand Down
Loading
Loading