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

Geolocation: Add #nullable for Essentials Geolocation code #13371

Merged
merged 7 commits into from
Feb 20, 2023
Merged

Geolocation: Add #nullable for Essentials Geolocation code #13371

merged 7 commits into from
Feb 20, 2023

Conversation

vividos
Copy link
Contributor

@vividos vividos commented Feb 15, 2023

Description of Change

This PR is a follow-up to #9572 and adds #nullable enable to the remaining Essentials' Geolocation classes.

Issues Fixed

No issue, but follow-up code changes left over from #9572.

@ghost ghost added the community ✨ Community Contribution label Feb 15, 2023
@ghost
Copy link

ghost commented Feb 15, 2023

Hey there @vividos! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.


static LocationManager LocationManager =>
static LocationManager? LocationManager =>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if LocationManager can ever be null on a sane Android environment, but there might be some weird custom ROMs; I guess the best is to throw FeatureNotSupportedException then...

Copy link
Contributor Author

@vividos vividos Feb 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jfversluis there are still my three questions...

{
if (provider == null)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as ILocationListener has the provider parameter marked with string?, provider may theoretically be null, but from reading the Android documentation, it makes no sense to be null. Therefore I just return here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jfversluis the second...

@@ -183,7 +185,7 @@ public void StopListeningForeground()
listener.ErrorHandler = null;
}

listeningManager.Delegate = null;
listeningManager.WeakDelegate = null;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure setting the WeakDelegate is the proper thing to do here, but since the Delegate now is non-nullable, it can't be set to null anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jfversluis the third...

@vividos vividos changed the title Geolocation: Add #nullable Geolocation: Add #nullable for Essentials Geolocation code Feb 15, 2023
@vividos
Copy link
Contributor Author

vividos commented Feb 15, 2023

@jfversluis Here's the rest of the changes I mentioned. I added some comments to the changes that we should discuss.

src/Essentials/src/Geolocation/Geolocation.android.cs Outdated Show resolved Hide resolved
src/Essentials/src/Geolocation/Geolocation.android.cs Outdated Show resolved Hide resolved
src/Essentials/src/Geolocation/Geolocation.android.cs Outdated Show resolved Hide resolved
src/Essentials/src/Geolocation/Geolocation.android.cs Outdated Show resolved Hide resolved
src/Essentials/src/Geolocation/Geolocation.android.cs Outdated Show resolved Hide resolved
src/Essentials/src/Geolocation/Geolocation.android.cs Outdated Show resolved Hide resolved
src/Essentials/src/Geolocation/Geolocation.android.cs Outdated Show resolved Hide resolved
src/Essentials/src/Geolocation/Geolocation.android.cs Outdated Show resolved Hide resolved
src/Essentials/src/Geolocation/Geolocation.android.cs Outdated Show resolved Hide resolved
src/Essentials/src/Geolocation/Geolocation.ios.macos.cs Outdated Show resolved Hide resolved
@vividos
Copy link
Contributor Author

vividos commented Feb 16, 2023

@mandel-macaque Thanks for the review comments! I addressed all apart from two; see my above comments. Also I have three original comments attached to the code, which we also should discuss.

@jsuarezruiz jsuarezruiz added the area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info label Feb 16, 2023
@jfversluis
Copy link
Member

jfversluis commented Feb 16, 2023

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@jfversluis
Copy link
Member

jfversluis commented Feb 16, 2023

Amazing @vividos thank you! If you're looking for something after this... We might want to enable nullable on the project level and then add #nullable disable to the files that we still need to cover and remove #nullable enable for the ones that are already done.

Besides the other feedback there is these build errors:

/Users/builder/azdo/_work/2/s/src/Essentials/src/Geolocation/Geolocation.tizen.cs(16,25): error CS8613: Nullability of reference types in return type of 'Task GeolocationImplementation.GetLastKnownLocationAsync()' doesn't match implicitly implemented member 'Task<Location?> IGeolocation.GetLastKnownLocationAsync()'. [/Users/builder/azdo/_work/2/s/src/Essentials/src/Essentials.csproj::TargetFramework=net7.0-tizen]
/Users/builder/azdo/_work/2/s/src/Essentials/src/Geolocation/Geolocation.tizen.cs(18,31): error CS8613: Nullability of reference types in return type of 'Task GeolocationImplementation.GetLocationAsync(GeolocationRequest request, CancellationToken cancellationToken)' doesn't match implicitly implemented member 'Task<Location?> IGeolocation.GetLocationAsync(GeolocationRequest request, CancellationToken cancelToken)'. [/Users/builder/azdo/_work/2/s/src/Essentials/src/Essentials.csproj::TargetFramework=net7.0-tizen]

@vividos
Copy link
Contributor Author

vividos commented Feb 16, 2023

I'll check out the Tizen build error.
All of my pull requests have the purpose to make a (distant) future migration of my Forms projects to MAUI easier 😉

@jfversluis
Copy link
Member

Hey I don't blame you! I can only be happy that you not only help yourself out, but also others in the process. So thank you for doing this!

Copy link
Member

@mandel-macaque mandel-macaque left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree on the ones left as they where, there is a missing comment to be address (probably github hide it by mistake).

src/Essentials/src/Geolocation/Geolocation.android.cs Outdated Show resolved Hide resolved
@vividos
Copy link
Contributor Author

vividos commented Feb 17, 2023

fixed the Tizen errors and still waiting opinions on my three comments from Feb. 15th.

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

Copy link
Member

@mandel-macaque mandel-macaque left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vividos I took the liberty to do a commit fixing some forgotten == null and != null.

@jfversluis
Copy link
Member

/azp run

@vividos
Copy link
Contributor Author

vividos commented Feb 17, 2023

There's still the three code comments...

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

Copy link
Member

@jfversluis jfversluis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the rest of your comments are valid, so LGTM! Thank you!

@jfversluis jfversluis merged commit 8b87c11 into dotnet:main Feb 20, 2023
@vividos
Copy link
Contributor Author

vividos commented Feb 20, 2023

Ah sorry I didn't see you comment. Sorry for the noise!

tj-devel709 pushed a commit to tj-devel709/maui that referenced this pull request Feb 21, 2023
)

* enabled nullable checks for GeolocationRequest class

* enabled nullable checks for more Geolocation source files

* enabled nullable checks for Geolocation Android and iOS implementation

* changed null checks as suggested in review

* fixed nullable errors for Tizen

* Fix some forgotte == null

* Fix some forgotte != null

---------

Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
tj-devel709 pushed a commit to tj-devel709/maui that referenced this pull request Feb 21, 2023
)

* enabled nullable checks for GeolocationRequest class

* enabled nullable checks for more Geolocation source files

* enabled nullable checks for Geolocation Android and iOS implementation

* changed null checks as suggested in review

* fixed nullable errors for Tizen

* Fix some forgotte == null

* Fix some forgotte != null

---------

Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
@github-actions github-actions bot locked and limited conversation to collaborators Dec 13, 2023
@samhouts samhouts added the fixed-in-8.0.0-preview.2.7871 Look for this fix in 8.0.0-preview.2.7871! label Aug 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info community ✨ Community Contribution fixed-in-8.0.0-preview.2.7871 Look for this fix in 8.0.0-preview.2.7871!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants