Conversation
mattleibow
commented
Oct 27, 2022
| return windowScene?.Windows.FirstOrDefault(); | ||
| try | ||
| { | ||
| using var scenes = UIApplication.SharedApplication.ConnectedScenes; |
Member
Author
There was a problem hiding this comment.
First level of attack, make sure to dispose the "other" set so that there is no managed object around to get a miss-type.
Comment on lines
+110
to
+115
| catch (InvalidCastException) | ||
| { | ||
| // HACK: Workaround for https://github.com/xamarin/xamarin-macios/issues/13704 | ||
| // This only throws if the collection is empty. | ||
| return null; | ||
| } |
Member
Author
There was a problem hiding this comment.
Second level, if we do get an exception, we know it is because the set was empty, so do empty things.
| try | ||
| { | ||
| foreach (var u in connectionOptions.UserActivities) | ||
| using var activities = connectionOptions.UserActivities; |
Member
Author
There was a problem hiding this comment.
First-point-five level, make sure we also dispose the error set because there may be another set later on.
Comment on lines
+73
to
+77
| catch (InvalidCastException) | ||
| { | ||
| // HACK: Workaround for https://github.com/xamarin/xamarin-macios/issues/13704 | ||
| // This only throws if the collection is empty. | ||
| } |
Member
Author
There was a problem hiding this comment.
Second-point-five protection, if we do somehow throw, then we know there is no user activity.
rolfbjarne
approved these changes
Oct 27, 2022
Redth
approved these changes
Oct 27, 2022
rmarinho
pushed a commit
that referenced
this pull request
Oct 27, 2022
rmarinho
pushed a commit
that referenced
this pull request
Oct 27, 2022
rmarinho
pushed a commit
that referenced
this pull request
Oct 27, 2022
rmarinho
pushed a commit
that referenced
this pull request
Oct 27, 2022
Redth
added a commit
that referenced
this pull request
Oct 27, 2022
* Squashed commit of the following: (#10942) commit 22b3033 Merge: 50866a7 95ee1a3 Author: Matthew Leibowitz <mattleibow@live.com> Date: Thu Oct 27 11:10:47 2022 +0200 Merge branch 'net7.0' into darc-net7.0-45fa6a48-68f2-4992-95f2-e40e8e14afd5 commit 50866a7 Author: Jonathan Dick <jondick@gmail.com> Date: Wed Oct 26 21:22:02 2022 -0400 Bump net6 version for SR7 commit 8edadd3 Author: Rui Marinho <me@ruimarinho.net> Date: Wed Oct 26 18:55:17 2022 +0100 Update NuGet.config commit b7c5411 Author: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Date: Wed Oct 26 17:48:49 2022 +0000 Update dependencies from https://github.com/xamarin/xamarin-macios build 20221026.24 Microsoft.tvOS.Sdk From Version 16.0.1475 -> To Version 16.0.1477 commit 4c57036 Author: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Date: Wed Oct 26 17:48:09 2022 +0000 Update dependencies from https://github.com/xamarin/xamarin-macios build 20221026.24 Microsoft.iOS.Sdk From Version 16.0.1475 -> To Version 16.0.1477 commit 89f722e Author: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Date: Wed Oct 26 16:51:31 2022 +0000 Update dependencies from https://github.com/xamarin/xamarin-macios build 20221026.21 Microsoft.tvOS.Sdk From Version 16.0.1475 -> To Version 16.0.1476 commit 9dc4a41 Author: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Date: Wed Oct 26 16:51:01 2022 +0000 Update dependencies from https://github.com/xamarin/xamarin-macios build 20221026.21 Microsoft.iOS.Sdk From Version 16.0.1475 -> To Version 16.0.1476 commit dde2135 Author: Rui Marinho <me@ruimarinho.net> Date: Wed Oct 26 17:46:35 2022 +0100 Add Nuget.config feed commit bad3509 Author: GitHub Actions Autoformatter <autoformat@example.com> Date: Wed Oct 26 16:41:26 2022 +0000 Auto-format source code commit 6d56d6c Author: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Date: Wed Oct 26 16:40:27 2022 +0000 Update dependencies from https://github.com/xamarin/xamarin-macios build 20221026.22 Microsoft.MacCatalyst.Sdk From Version 15.4.2370 -> To Version 15.4.2371 commit 2da2d4d Author: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Date: Wed Oct 26 16:40:10 2022 +0000 Update dependencies from https://github.com/xamarin/xamarin-macios build 20221026.22 Microsoft.macOS.Sdk From Version 12.3.2370 -> To Version 12.3.2371 Co-authored-by: Matthew Leibowitz <mattleibow@live.com> # Conflicts: # eng/Version.Details.xml # eng/Versions.props * Dispose empty sets and try/catch exceptions (#10955) Workaround for dotnet/macios#13704 * Update MAUI's net6 version Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Matthew Leibowitz <mattleibow@live.com> Co-authored-by: Jonathan Dick <jondick@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of Change
There seems to be a bug in the iOS/Mac Catalyst SDK where empty "collections" that are generic all use the same pointer. This causes the first reference to win and the rest throw.
This PR has a very strong error-situation-avoidance feel to it, see comments...
Issues Fixed
Workarounds for: