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

Add more type-forwarders for Xamarin.Android compatibility to mscorlib.dll #82618

Merged
merged 3 commits into from
Mar 1, 2023

Conversation

akoeplinger
Copy link
Member

@akoeplinger akoeplinger commented Feb 24, 2023

The legacy Xamarin.Android version of mscorlib.dll differed a bit compared to the .NET Framework mscorlib.dll, mostly because of additions for .NET Standard 2.1 support.

This meant that an assembly which was compiled against that mscorlib expects types there but since we didn't have type-forwarders in our mscorlib.dll shim to point them to the right assembly you'd get a TypeLoadException when running on modern .NET 6 Android.

Fixes #82193

Should also fix these MAUI issues: dotnet/maui#5142, dotnet/maui#5078, dotnet/maui#3903

…b.dll

The legacy Xamarin.Android version of mscorlib.dll differed a bit compared to the .NET Framework mscorlib.dll, mostly because of additions for .NET Standard 2.1 support.

This meant that an assembly which was compiled against that mscorlib expects types there but since we didn't have type-forwarders in our mscorlib.dll shim to point them to the right assembly you'd get a TypeLoadException when running on modern .NET 6 Android.

Fixes dotnet#82193

Should also fix dotnet/maui#5142, dotnet/maui#5078, dotnet/maui#3903
@ghost
Copy link

ghost commented Feb 24, 2023

Tagging subscribers to this area: @dotnet/area-infrastructure-libraries
See info in area-owners.md if you want to be subscribed.

Issue Details

The legacy Xamarin.Android version of mscorlib.dll differed a bit compared to the .NET Framework mscorlib.dll, mostly because of additions for .NET Standard 2.1 support.

This meant that an assembly which was compiled against that mscorlib expects types there but since we didn't have type-forwarders in our mscorlib.dll shim to point them to the right assembly you'd get a TypeLoadException when running on modern .NET 6 Android.

Fixes #82193

Should also fix these MAUI issues: dotnet/maui#5142, dotnet/maui#5078, dotnet/maui#3903

Author: akoeplinger
Assignees: akoeplinger
Labels:

area-Infrastructure-libraries

Milestone: -

@sacOO7
Copy link

sacOO7 commented Feb 24, 2023

Thanks, @akoeplinger . I support this PR 🖖

Copy link
Member

@ericstj ericstj left a comment

Choose a reason for hiding this comment

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

I'm ok with this change in principle. Needs a little work though.

src/libraries/shims/src/mscorlib.forwards.cs Show resolved Hide resolved
src/libraries/shims/src/mscorlib.forwards.cs Show resolved Hide resolved
Co-authored-by: Viktor Hofer <viktor.hofer@microsoft.com>
@filipnavara
Copy link
Member

Is this setting a precedent to workaround the historical mistake in System.Drawing facades in Mono (mono/mono#21239)?

@sacOO7
Copy link

sacOO7 commented Feb 28, 2023

Hi, when can we expect the release of this fix once this is merged?

@akoeplinger
Copy link
Member Author

@filipnavara theoretically, but my understanding is that is much less common since it was mostly an issue on iOS which isn't compatible anyway.

@akoeplinger akoeplinger merged commit d8203e7 into dotnet:main Mar 1, 2023
@akoeplinger akoeplinger deleted the mscorlib-typeforwarder branch March 1, 2023 12:13
@filipnavara
Copy link
Member

@filipnavara theoretically, but my understanding is that is much less common since it was mostly an issue on iOS which isn't compatible anyway.

It's issue for both Android and iOS. We run some debugging/profiling scenarios with net6.0-ios/android + Xamarin.Forms. The issue with the System.Drawing types basically turns this scenario into "recompile the whole world" scenario because nearly all the 3rd-party Xamarin.Forms-dependent libraries suffer from the problem.

@akoeplinger
Copy link
Member Author

@filipnavara would you mind filing an issue with the concrete types that are affected?

@filipnavara
Copy link
Member

would you mind filing an issue with the concrete types that are affected?

Sure.

@steveisok
Copy link
Member

@akoeplinger do you think we should backport this to 7?

@sacOO7
Copy link

sacOO7 commented Mar 2, 2023

@akoeplinger can we also backport this to dotnet 6?

@akoeplinger
Copy link
Member Author

We currently don't plan to do that since .NET 6 is only supported until May 2023 specifically for MAUI apps (6 months after .NET 7 release according to https://dotnet.microsoft.com/en-us/platform/support/policy/maui) so it would only apply for a very short time.

@sacOO7
Copy link

sacOO7 commented Mar 2, 2023

But still, this hotfix should apply to the apps that are using .Net 6 right?

@marek-safar marek-safar modified the milestone: 7.0.x Mar 3, 2023
akoeplinger added a commit to akoeplinger/runtime that referenced this pull request Mar 8, 2023
…b.dll (dotnet#82618)

The legacy Xamarin.Android version of mscorlib.dll differed a bit compared to the .NET Framework mscorlib.dll, mostly because of additions for .NET Standard 2.1 support.

This meant that an assembly which was compiled against that mscorlib expects types there but since we didn't have type-forwarders in our mscorlib.dll shim to point them to the right assembly you'd get a TypeLoadException when running on modern .NET 6 Android.

Fixes dotnet#82193

(cherry picked from commit d8203e7)
carlossanlop added a commit that referenced this pull request Mar 9, 2023
…ity to mscorlib.dll and System.Drawing.Common.dll (#83137)

* Add more type-forwarders for Xamarin.Android compatibility to mscorlib.dll (#82618)

The legacy Xamarin.Android version of mscorlib.dll differed a bit compared to the .NET Framework mscorlib.dll, mostly because of additions for .NET Standard 2.1 support.

This meant that an assembly which was compiled against that mscorlib expects types there but since we didn't have type-forwarders in our mscorlib.dll shim to point them to the right assembly you'd get a TypeLoadException when running on modern .NET 6 Android.

Fixes #82193

(cherry picked from commit d8203e7)

* Add type-forwarders for Xamarin.Android compatibility to System.Drawing.Common.dll (#82839)

The legacy Xamarin.Android version of System.Drawing.Common.dll contained these types, add forwarders so we don't get a TypeLoadException when using an assembly compiled against that in modern .NET Android.

Fixes #82829

(cherry picked from commit e486f38)

* Use 7.0 version of the ApiCompat suppressions

* Fix diff

---------

Co-authored-by: Carlos Sánchez López <1175054+carlossanlop@users.noreply.github.com>
@ghost ghost locked as resolved and limited conversation to collaborators Apr 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Android] Throws runtime error in mscorlib, expected class System.Runtime.CompilerServices.ValueTaskAwaiter1
7 participants