-
Notifications
You must be signed in to change notification settings - Fork 547
[opengl] Add nullability to (generated and manual) bindings #15174
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this is only whitespace changes, so not really needed?
NVM, just saw a portion of the PR
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@rolfbjarne Changes addressed! |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general LGTM but I'm concerned that some of these changes are non-trivial, and we have literally no coverage/expected usage of some of this code.
Who is using MonoMacGameView.cs these days?
On one hand, that makes it lower risk (as few people will be impacted), but on the other hand we have likely zero sample coverage and it could stay broken awhile.
I think this is fine, but just something for us to consider.
|
Unrelated Test Failures: https://github.com/xamarin/maccore/issues/2558 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chamons I have the same though, the AssertContext was removed, which changes a behaviour in which we are throwing an exception, yet if you look closely what @tj-devel709 did was the following:
- Remove the method.
- Add the logic of the method to the property.
The change makes sense, since we are using now the property to access the OpenGL context, yet it has an undesired runtime effect. Our users used to be able to get a null variable out of the properties, now they are getting an exception. My fear here is that a user would be doing something like this:
if (view. OpenGLContext == null) {
// call the init code
}The above code, with the changes, will not work because it is throwing an exception. Now, issue here is that the Assert method is not very helpful with regards of nullability and hence the change from @tj-devel709 I propose something in between:
- Revert the property change to not throw and return null
- Add a private property that does the new logic, and call it _OpenGLContext
With the above, you have what @tj-devel709 was looking for and what @chamons wants (no runtime changes).
|
Or you could could it |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| get { | ||
| if (pixelFormat is null) | ||
| throw new InvalidOperationException ("Operation requires a PixelFormat that cannot be null."); | ||
| return pixelFormat; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This property has AFAIK the same issue as the OpenGL one we talked about. You are throwing an exception on a property that did not used to and returned a null variable correctly. We are changing the behaviour and we should not.
src/OpenGL/MonoMacGameView.cs
Outdated
| get => openGLContext; | ||
| } | ||
|
|
||
| public NSOpenGLContext ActualOpenGLContext { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be public, you are adding a public property that is not needed since we have the OpenGLContext. This is an implementation detail that we are leaking to the users.
| public NSOpenGLContext ActualOpenGLContext { | |
| private NSOpenGLContext ActualOpenGLContext { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call!
💻 [PR Build] Tests on macOS Mac Catalina (10.15) passed 💻✅ All tests on macOS Mac Catalina (10.15) passed. Pipeline on Agent |
✅ API diff for current PR / commitLegacy Xamarin (No breaking changes).NET (No breaking changes)✅ API diff vs stableLegacy Xamarin (No breaking changes).NET (No breaking changes)ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
❌ [PR Build] Tests on macOS M1 - Mac Big Sur (11.5) failed ❌Failed tests are:
Pipeline on Agent |
|
Unrelated Test Failure: https://github.com/xamarin/maccore/issues/2558 |
This PR aims to bring nullability changes to OpenGL.
Following the steps here:
nullable enableto all manual files that are not "API_SOURCES" in src/frameworks.sources and making the required nullability changesthrow new ArgumentNullException ("object"));toObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (object));for size saving optimization as well to mark that this framework contains nullability changes== nullor!= nulltois nullandis not null