Xamarin-macios: NSGraphicsContext.CurrentContext should be able to be set to null

Created on 9 Oct 2020  路  2Comments  路  Source: xamarin/xamarin-macios

The property currently throws if you try to set it to null. However this is an expected scenario when using it off the main thread.

The Apple declaration makes it clear:

@property(class, nullable, strong) NSGraphicsContext *currentContext;

Steps to Reproduce

  1. Set NSGraphicsContext.CurrentContext = null

Expected Behavior

The CurrentContext is set to null.

Actual Behavior

ArgumentNullExcpetion is thrown.

Environment

=== Visual Studio Enterprise 2019 for Mac ===

Version 8.7.8 (build 4)
Installation UUID: 985b3334-0c0b-427c-b061-67c799e36934
    GTK+ 2.24.23 (Raleigh theme)
    Xamarin.Mac 6.18.0.23 (d16-6 / 088c73638)

    Package version: 612000093

=== Mono Framework MDK ===

Runtime:
    Mono 6.12.0.93 (2020-02/620cf538206) (64-bit)
    Package version: 612000093

=== Roslyn (Language Service) ===

3.7.0-6.20427.1+18ede13943b0bfae1b44ef078b2f3923159bcd32

=== NuGet ===

Version: 5.7.0.6702

=== Xamarin Designer ===

Version: 16.7.0.495
Hash: 03d50a221
Branch: remotes/origin/d16-7-vsmac
Build date: 2020-08-28 13:12:52 UTC

=== .NET Core SDK ===

SDK: /usr/local/share/dotnet/sdk/5.0.100-preview.7.20317.11/Sdks
SDK Versions:
    5.0.100-preview.7.20317.11
    5.0.100-preview.6.20265.2
    3.1.402
    3.1.300
    3.1.200
    3.1.102
    3.1.101
    3.1.100
    3.0.100
    3.0.100-preview5-011568
    3.0.100-preview-009812
    2.2.203
    2.2.103
    2.1.302
    2.1.300-preview2-008530
    2.0.3
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/msbuild/Current/bin/Sdks

=== .NET Core Runtime ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
    5.0.0-preview.7.20317.2
    5.0.0-preview.6.20264.1
    3.1.8
    3.1.4
    3.1.2
    3.1.1
    3.1.0
    3.0.0
    3.0.0-preview5-27626-15
    3.0.0-preview-27122-01
    2.2.4
    2.2.1
    2.1.22
    2.1.21
    2.1.20
    2.1.18
    2.1.17
    2.1.16
    2.1.15
    2.1.13
    2.1.2
    2.1.0-preview2-26406-04
    2.0.3

=== Xamarin.Profiler ===

Version: 1.6.15.68
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Updater ===

Version: 11

=== Xamarin.Android ===

Version: 11.0.2.0 (Visual Studio Enterprise)
Commit: xamarin-android/d16-7/025fde9
Android SDK: /Users/fak/Library/Developer/Xamarin/android-sdk-macosx
    Supported Android versions:
        7.0 (API level 24)
        7.1 (API level 25)

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 30.0.4
SDK Build Tools Version: 29.0.2

Build Information: 
Mono: 83105ba
Java.Interop: xamarin/java.interop/d16-7@1f3388a
ProGuard: Guardsquare/proguard/proguard6.2.2@ebe9000
SQLite: xamarin/sqlite/3.32.1@1a3276b
Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-7@017078f

=== Microsoft OpenJDK for Mobile ===

Java SDK: /Users/fak/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_1.8.0.25
1.8.0-25
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Android SDK Manager ===

Version: 16.7.0.13
Hash: 8380518
Branch: remotes/origin/d16-7~2
Build date: 2020-09-16 05:12:24 UTC

=== Android Device Manager ===

Version: 16.7.0.24
Hash: bb090a3
Branch: remotes/origin/d16-7
Build date: 2020-09-16 05:12:46 UTC

=== Apple Developer Tools ===

Xcode 12.0 (17218)
Build 12A7208

=== Xamarin.Mac ===

Version: 6.20.2.2 (Visual Studio Enterprise)
Hash: 817b6f72a
Branch: d16-7
Build date: 2020-07-18 18:44:59-0400

=== Xamarin.iOS ===

Version: 14.0.0.0 (Visual Studio Enterprise)
Hash: 7ec3751a1
Branch: xcode12
Build date: 2020-09-16 11:33:15-0400

=== Build Information ===

Release ID: 807080004
Git revision: 9ea7bef96d65cdc3f4288014a799026ccb1993bc
Build date: 2020-09-16 17:22:54-04
Build branch: release-8.7
Xamarin extensions: 9ea7bef96d65cdc3f4288014a799026ccb1993bc

=== Operating System ===

Mac OS X 10.15.6
Darwin 19.6.0 Darwin Kernel Version 19.6.0
    Sun Jul  5 00:43:10 PDT 2020
    root:xnu-6153.141.1~9/RELEASE_X86_64 x86_64

=== Enabled user installed extensions ===

Build Light 0.5
AddinMaker 1.5.0
MSBuild Editor 2.2.0

bug macOS

All 2 comments

Thanks for the report. I'll get it fixed up.

Do you need a manual binding work around?

Thanks for the quick response @chamons . I had a workaround already, but I look forward to this coming out!

Was this page helpful?
0 / 5 - 0 ratings