We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
NSUrl?
Uri?
null
URL
@objc(Foo) public class Foo : NSObject { @objc public var imageUrl: URL? @objc public init(url: URL?) { self.imageUrl = url super.init() } }
[BaseType (typeof(NSObject))] [DisableDefaultCtor] interface Foo { // @property (copy, nonatomic) NSURL * _Nullable imageUrl; [NullAllowed, Export ("imageUrl", ArgumentSemantic.Copy)] NSUrl ImageUrl { get; set; } // -(instancetype _Nonnull)initWithUrl:(NSURL * _Nullable)url __attribute__((objc_designated_initializer)); [Export ("initWithUrl:")] [DesignatedInitializer] IntPtr Constructor ([NullAllowed] NSUrl url); }
URI?
var foo = new Foo(null); Uri? imageUri = foo.ImageUrl;
imageUri should be null since it is nullable
imageUri
Crash:
System.NullReferenceException: Object reference not set to an instance of an object. at Foundation.NSUrl.op_Implicit(NSUrl url)
I have to fake out the compiler to get it to work, otherwise the implicit conversion kicks in
Uri? uri; if (foo.ImageUrl == null) { uri = null; } else { uri = foo.ImageUrl; }
I'm running this on a Mac through dotnet CLI and VSCode since its a MAUI app
The text was updated successfully, but these errors were encountered:
Looks like our implicit operator should return null here.
Sorry, something went wrong.
I can reproduce this with:
global::System.Uri uri = null; NSUrl sUrl = uri;
Fix crash with NSUrl implicit conversion and null
0982f78
- Fixes: dotnet#14786
Fix crash with NSUrl implicit conversion and null (#14860)
6a16226
- Fixes: #14786
chamons
Successfully merging a pull request may close this issue.
Steps to Reproduce
URL
property:URI?
implicitlyExpected Behavior
imageUri
should benull
since it is nullableActual Behavior
Crash:
I have to fake out the compiler to get it to work, otherwise the implicit conversion kicks in
Environment
I'm running this on a Mac through dotnet CLI and VSCode since its a MAUI app
Build Logs
Example Project (If Possible)
The text was updated successfully, but these errors were encountered: