dotnet / dotnet/macios

Add test for MissingManifestResourceException at runtime

Open
#8,782 2 comments 0 reactions 0 assignees View on GitHub
enhancement iOS tests
Dominant language
C#
Stars
2.9k
Forks
576
Avg merge
2d 12h
Merged PRs (30d)
123

Description

Context: https://github.com/xamarin/xamarin-macios/pull/8763

This fixes the issue ^^, but it would be good to add a test for this.

### Steps to Reproduce

1. Add this to an `AppDelegate.cs`:

```csharp
[Export ("f:")]
public void F (DateTime t) { }
```

Debug the app on an iOS simulator and you will get a crash at runtime.

Verify that the console has an error such as:
```
Could not register the assembly 'brokenlocalization': ObjCRuntime.RuntimeException: The registrar found an invalid type `System.DateTime` in signature for method `brokenlocalization.AppDelegate.F`. Use `Foundation.NSDate` instead.
at Registrar.Registrar.ToSignature (System.Type type, Registrar.Registrar+ObjCMember member, System.Boolean& success, System.Boolean forProperty) [0x00380] in src/ObjCRuntime/Registrar.cs:2611
at Registrar.Registrar.ComputeSignature (System.Type declaring_type, System.Boolean is_ctor, System.Type return_type, System.Type[] parameters, System.Reflection.MethodBase mi, Registrar.Registrar+ObjCMember member, System.Boolean isCategoryInstance, System.Boolean isBlockSignature) [0x00113] in src/ObjCRuntime/Registrar.cs:2526
at Registrar.Registrar.ComputeSignature (System.Type DeclaringType, System.Reflection.MethodBase Method, Registrar.Registrar+ObjCMember member, System.Boolean isCategoryInstance, System.Boolean isBlockSignature) [0x00059] in src/ObjCRuntime/Registrar.cs:2492
at Registrar.Registrar+ObjCMethod.ComputeSignature () [0x00000] in src/ObjCRuntime/Registrar.cs:923
```

In the past, we were instead hitting:
```
System.Resources.MissingManifestResourceException:
Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "Errors.mtouch.resources" was correctly embedded or linked into assembly "Xamarin.iOS" at compile time, or that all the satellite assemblies required are loadable and fully signed.
...
at Xamarin.Bundler.Errors.get_MT4102 () [0x00000] in tools/mtouch/Errors.Designer.cs:1582
```
Introduced in https://github.com/xamarin/xamarin-macios/commit/00985a55e2ed8d5fb2f329683ccc44c90be7ce29.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.