Skip to content
Draft
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
48 changes: 24 additions & 24 deletions src/CoreGraphics/NSValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,32 +55,32 @@ public static CGSize ToCGSize (NativeHandle handle)

#if MONOMAC

// @encode(CGAffineTransform) -> "{CGAffineTransform=dddddd}" but...
// using a C string crash on macOS (while it works fine on iOS)
[DllImport ("__Internal")]
extern static IntPtr xamarin_encode_CGAffineTransform ();
// @encode(CGAffineTransform) -> "{CGAffineTransform=dddddd}" but...
// using a C string crash on macOS (while it works fine on iOS)
[DllImport ("__Internal")]
extern static IntPtr xamarin_encode_CGAffineTransform ();

// The `+valueWithCGAffineTransform:` selector comes from UIKit and is not available on macOS
/// <param name="tran">To be added.</param>
/// <summary>Creates an NSValue that wraps a CGAffineTransform object.</summary>
/// <returns>To be added.</returns>
/// <remarks>To be added.</remarks>
public unsafe static NSValue FromCGAffineTransform (CGAffineTransform tran)
{
return Create ((IntPtr) (void*) &tran, xamarin_encode_CGAffineTransform ());
}
// The `+valueWithCGAffineTransform:` selector comes from UIKit and is not available on macOS
/// <param name="tran">To be added.</param>
/// <summary>Creates an NSValue that wraps a CGAffineTransform object.</summary>
/// <returns>To be added.</returns>
/// <remarks>To be added.</remarks>
public unsafe static NSValue FromCGAffineTransform (CGAffineTransform tran)
{
return Create ((IntPtr) (void*) &tran, xamarin_encode_CGAffineTransform ());
}

// The `CGAffineTransformValue` selector comes from UIKit and is not available on macOS
public unsafe virtual CGAffineTransform CGAffineTransformValue {
get {
var result = new CGAffineTransform ();
// avoid potential buffer overflow since we use the older `getValue:` API to cover all platforms
// and we can cheat here with the actual string comparison (since we are the one doing it)
if (ObjCType == "{CGAffineTransform=dddddd}")
StoreValueAtAddress ((IntPtr) (void*) &result, (nuint) sizeof (CGAffineTransform));
return result;
}
}
// The `CGAffineTransformValue` selector comes from UIKit and is not available on macOS
public unsafe virtual CGAffineTransform CGAffineTransformValue {
get {
var result = new CGAffineTransform ();
// avoid potential buffer overflow since we use the older `getValue:` API to cover all platforms
// and we can cheat here with the actual string comparison (since we are the one doing it)
if (ObjCType == "{CGAffineTransform=dddddd}")
StoreValueAtAddress ((IntPtr) (void*) &result, (nuint) sizeof (CGAffineTransform));
return result;
}
}

#else

Expand Down
24 changes: 8 additions & 16 deletions src/CoreServices/LaunchServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,7 @@ public static class LaunchServices {
return Runtime.GetNSObject<NSUrl> (
LSCopyDefaultApplicationURLForContentType (contentTypeHandle, roles, IntPtr.Zero)
);
}
finally {
} finally {
CFString.ReleaseNative (contentTypeHandle);
}
}
Expand Down Expand Up @@ -263,8 +262,7 @@ public static NSUrl [] GetApplicationUrlsForBundleIdentifier (string bundleIdent
return NSArray.ArrayFromHandle<NSUrl> (
LSCopyApplicationURLsForBundleIdentifier (bundleIdentifierHandle, IntPtr.Zero)
);
}
finally {
} finally {
CFString.ReleaseNative (bundleIdentifierHandle);
}
}
Expand Down Expand Up @@ -355,8 +353,7 @@ public static LSResult Register (NSUrl url, bool update)
return CFArray.StringArrayFromHandle (
LSCopyAllRoleHandlersForContentType (contentTypeHandle, roles)
);
}
finally {
} finally {
CFString.ReleaseNative (contentTypeHandle);
}
}
Expand All @@ -383,8 +380,7 @@ public static LSResult Register (NSUrl url, bool update)
return Runtime.GetNSObject<NSString> (
LSCopyDefaultRoleHandlerForContentType (contentTypeHandle, roles)
);
}
finally {
} finally {
CFString.ReleaseNative (contentTypeHandle);
}
}
Expand Down Expand Up @@ -420,8 +416,7 @@ public static LSResult SetDefaultRoleHandlerForContentType (string contentType,
roles,
handlerBundleIdHandle
);
}
finally {
} finally {
CFString.ReleaseNative (contentTypeHandle);
CFString.ReleaseNative (handlerBundleIdHandle);
}
Expand All @@ -448,8 +443,7 @@ public static LSResult SetDefaultRoleHandlerForContentType (string contentType,
return CFArray.StringArrayFromHandle (
LSCopyAllHandlersForURLScheme (urlSchemeHandle)
);
}
finally {
} finally {
CFString.ReleaseNative (urlSchemeHandle);
}
}
Expand All @@ -475,8 +469,7 @@ public static LSResult SetDefaultRoleHandlerForContentType (string contentType,
return Runtime.GetNSObject<NSString> (
LSCopyDefaultHandlerForURLScheme (urlSchemeHandle)
);
}
finally {
} finally {
CFString.ReleaseNative (urlSchemeHandle);
}
}
Expand Down Expand Up @@ -507,8 +500,7 @@ public static LSResult SetDefaultHandlerForUrlScheme (string urlScheme, string h
urlSchemeHandle,
handlerBundleIdHandle
);
}
finally {
} finally {
CFString.ReleaseNative (urlSchemeHandle);
CFString.ReleaseNative (handlerBundleIdHandle);
}
Expand Down
6 changes: 3 additions & 3 deletions src/CoreVideo/CVOpenGLESTexture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ internal CVOpenGLESTexture (NativeHandle handle, bool owns)

[DllImport (Constants.CoreVideoLibrary)]
extern static void CVOpenGLESTextureGetCleanTexCoords (
/* CVOpenGLESTextureRef __nonnull */ IntPtr image,
/* GLfloat[2] */ IntPtr lowerLeft, /* GLfloat[2] */ IntPtr lowerRight, /* GLfloat[2] */ IntPtr upperRight,
/* CVOpenGLESTextureRef __nonnull */ IntPtr image,
/* GLfloat[2] */ IntPtr lowerLeft, /* GLfloat[2] */ IntPtr lowerRight, /* GLfloat[2] */ IntPtr upperRight,
/* GLfloat[2] */ IntPtr upperLeft);
// note: a GLfloat is 4 bytes even on 64bits iOS

Expand Down Expand Up @@ -75,7 +75,7 @@ public void GetCleanTexCoords (out float [] lowerLeft, out float [] lowerRight,
upperLeft = new float [2];

unsafe {
fixed (float *ll = lowerLeft, lr = lowerRight, ur = upperRight, ul = upperLeft){
fixed (float* ll = lowerLeft, lr = lowerRight, ur = upperRight, ul = upperLeft) {
CVOpenGLESTextureGetCleanTexCoords (GetCheckedHandle (), (IntPtr) ll, (IntPtr) lr, (IntPtr) ur, (IntPtr) ul);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/GameKit/GKCompat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public GKPeerPickerControllerDelegate () : base (NSObjectFlag.Empty)
}

/// <include file="../../docs/api/GameKit/GKPeerPickerControllerDelegate.xml" path="/Documentation/Docs[@DocId='M:GameKit.GKPeerPickerControllerDelegate.#ctor(Foundation.NSObjectFlag)']/*" />
protected GKPeerPickerControllerDelegate (NSObjectFlag t) : base (t)
protected GKPeerPickerControllerDelegate (NSObjectFlag t) : base (t)
{
throw new PlatformNotSupportedException (Constants.TypeUnavailable);
}
Expand Down Expand Up @@ -156,7 +156,7 @@ public GKPeerPickerController () : base (NSObjectFlag.Empty)
}

/// <include file="../../docs/api/GameKit/GKPeerPickerController.xml" path="/Documentation/Docs[@DocId='M:GameKit.GKPeerPickerController.#ctor(Foundation.NSObjectFlag)']/*" />
protected GKPeerPickerController (NSObjectFlag t) : base (t)
protected GKPeerPickerController (NSObjectFlag t) : base (t)
{
throw new PlatformNotSupportedException (Constants.TypeUnavailable);
}
Expand Down Expand Up @@ -234,7 +234,7 @@ public virtual NSObject? WeakDelegate {
}

/// <include file="../../docs/api/GameKit/GKPeerPickerController.xml" path="/Documentation/Docs[@DocId='M:GameKit.GKPeerPickerController.Dispose(System.Boolean)']/*" />
protected override void Dispose (bool disposing)
protected override void Dispose (bool disposing)
{
throw new PlatformNotSupportedException (Constants.TypeUnavailable);
}
Expand Down
2 changes: 1 addition & 1 deletion src/MediaToolbox/MTAudioProcessingTap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public MTAudioProcessingTap (MTAudioProcessingTapCallbacks callbacks, MTAudioPro
}

/// <include file="../../docs/api/MediaToolbox/MTAudioProcessingTap.xml" path="/Documentation/Docs[@DocId='M:MediaToolbox.MTAudioProcessingTap.Dispose(System.Boolean)']/*" />
protected override void Dispose (bool disposing)
protected override void Dispose (bool disposing)
{
if (Handle != IntPtr.Zero) {
lock (handles)
Expand Down
4 changes: 2 additions & 2 deletions src/ObjCRuntime/Runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,8 @@ internal static bool Initialized {
unsafe static int _NSGetExecutablePath (byte [] buf, ref int bufsize)
{
fixed (byte* bufptr = buf)
fixed (int* bufsizePtr = &bufsize)
return _NSGetExecutablePath (bufptr, bufsizePtr);
fixed (int* bufsizePtr = &bufsize)
return _NSGetExecutablePath (bufptr, bufsizePtr);
}
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/UIKit/UIAlertView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public partial class UIAlertView {
/// <param name="otherButtons">Titles of any additional buttons.</param>
/// <remarks>This constructor is provided to make it possible to fully initialize an alert view when it is created.</remarks>
public UIAlertView (string title, string message, IUIAlertViewDelegate del, string cancelButtonTitle, params string [] otherButtons)
: this (title, message, del, cancelButtonTitle, otherButtons is null || otherButtons.Length == 0 ? IntPtr.Zero : new NSString (otherButtons [0]).DangerousRetain().DangerousAutorelease().Handle, IntPtr.Zero, IntPtr.Zero)
: this (title, message, del, cancelButtonTitle, otherButtons is null || otherButtons.Length == 0 ? IntPtr.Zero : new NSString (otherButtons [0]).DangerousRetain ().DangerousAutorelease ().Handle, IntPtr.Zero, IntPtr.Zero)
{
if (otherButtons is null)
return;
Expand Down
2 changes: 1 addition & 1 deletion src/UIKit/UIImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ partial class UIImage {
extern static void UIImageWriteToSavedPhotosAlbum (/* UIImage */ IntPtr image, /* id */ IntPtr obj, /* SEL */ IntPtr selector, /*vcoid* */ IntPtr ctx);

/// <include file="../../docs/api/UIKit/UIImage.xml" path="/Documentation/Docs[@DocId='M:UIKit.UIImage.SaveToPhotosAlbum(UIKit.UIImage.SaveStatus)']/*" />
public void SaveToPhotosAlbum (SaveStatus status)
public void SaveToPhotosAlbum (SaveStatus status)
{
UIImageStatusDispatcher? dis = null;
UIApplication.EnsureUIThread ();
Expand Down
4 changes: 2 additions & 2 deletions src/webkit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7290,7 +7290,7 @@ interface WKWebExtensionAction {

[Export ("menuItems", ArgumentSemantic.Copy)]
#if IOS || MACCATALYST
UIMenuElement[] MenuItems { get; }
UIMenuElement [] MenuItems { get; }
#else
NSMenuItem [] MenuItems { get; }
#endif
Expand Down Expand Up @@ -7698,7 +7698,7 @@ WKWebExtensionPermission CurrentPermission {

[Export ("menuItemsForTab:")]
#if IOS || MACCATALYST
UIMenuElement[] GetMenuItems (IWKWebExtensionTab tab);
UIMenuElement [] GetMenuItems (IWKWebExtensionTab tab);
#else
NSMenuItem [] GetMenuItems (IWKWebExtensionTab tab);
#endif
Expand Down
17 changes: 15 additions & 2 deletions tools/autoformat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ IFS=$'\n'
done
)

# Go one directory up, to avoid any global.json in dotnet/macios
cd ..
make -C builds dotnet

if test -z "${DOTNET:-}"; then
DOTNET=dotnet
Expand Down Expand Up @@ -99,6 +98,20 @@ for file in "$SRC_DIR"/dotnet/Templates/Microsoft.*.Templates/*/*/.template.conf
mv "$file".tmp "$file"
done

make -C src csproj

FILE=$(pwd)/tmp.txt
make print-variable-value-to-file FILE="$FILE" VARIABLE=DOTNET_PLATFORMS -C tools/devops
DOTNET_PLATFORMS=$(cat "$FILE" | sed 's/.*=//' | xargs)
rm -f "$FILE"

for platform in $(echo "$DOTNET_PLATFORMS" | sed 's/ /\n/g'); do
pl=$(echo $platform | tr 'A-Z' 'a-z')
af_whitespace src/build/dotnet/$pl/csproj/core/Core.$platform.csproj
af_whitespace src/build/dotnet/$pl/csproj/api/ApiDefinition.$platform.csproj
af_whitespace src/build/dotnet/$pl/csproj/platform/Microsoft.$platform.csproj
done

# dotnet format "$SRC_DIR/[...]"
# add more projects here...

Expand Down
Loading