* [nnyeah] Remove NNYEAH_IN_PROCESS on IntegrationExamples.cs as it was cursed due to global caching in nuget tool install
* [nnyeah] Simplify test API
* [nnyeah] Map NSObject ctors with IntPtr to NativeHandle
- Fixes https://github.com/xamarin/xamarin-macios/issues/15120
This required a significant amount of refactoring:
- To resolve the base type of objects, we need to invoke cecil's Resolve
- Resolve requires all assemblies to be loaded in memory, whcih requires a custom resolver to find them all
- Note: This requires customer assemblies to include all non-platform dependencies to be next to the input
- This extra state prompted a refactor of Program.cs to create a tool 'AssemblyConverter' with instance variables to reduce param passing
- The ctor mapping logic is isolated to ConstructorTransforms to reduce the growth of Reworker.cs and make limited unit testing possible
- Turns out the flat removal of the platform assembly from the import list was wrong, as it caused all platform references, such as NSObject to
be resolved from System.Runtime, which is wrong. So replace in place with the new platform assembly instead.
The files of the bundle.zip are being re-zipped inside a 'bundle' folder after signing, which is wrong since everything else is expecting the files directly inside the zip file without parent folders (as we were doing before)
Remove our dependency on Visual Studio. Use the 'dotnet-t4' tool instead of
invoking the t4 tool embedded in Visual Studio.
Fixes this build error after installing VS Mac 2022:
> Cannot open assembly '/Applications/Visual Studio.app/Contents/Resources/lib/monodevelop/AddIns/MonoDevelop.TextTemplating/TextTransform.exe': No such file or directory.
The values for environment variables can be null (to remove said environment
variable).
Fixes this warning:
tests/dotnet/UnitTests/TestBaseClass.cs(294,100): warning CS8620: Argument of type 'Dictionary<string, string?>' cannot be used for parameter 'environment' of type 'Dictionary<string, string>' in 'Task<Execution> Execution.RunWithStringBuildersAsync(string filename, IList<string> arguments, Dictionary<string, string>? environment = null, StringBuilder? standardOutput = null, StringBuilder? standardError = null, TextWriter? log = null, string? workingDirectory = null, TimeSpan? timeout = null, CancellationToken? cancellationToken = null)' due to differences in the nullability of reference types.
- Due to https://github.com/microsoft/vstest/issues/3658 it is not possible to test code that exits the process on error
- Create a base class for nnyeah exceptions that we want to explicitly report (and not crash), ConversionException
- Move Main to Main2 and wrap it in a try/catch for this exception
- 'Error while attempting to map member System.IntPtr Foundation.NSObject::get_Handle() in old assembly'
- Also fix a strange directory name created by Cache.CreateTemporaryDirectory being called from async test method
A stack trace like this isn't all that helpful:
*** Terminating app due to uncaught exception 'System.Reflection.TargetException', reason: 'Object does not match target type. (System.Reflection.TargetException)
at System.Reflection.RuntimeConstructorInfo.CheckConsistency(Object target)
at System.Reflection.RuntimeConstructorInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at ObjCRuntime.Runtime.InvokeMethod(MethodBase method, Object instance, IntPtr native_parameters) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Runtime.CoreCLR.cs:line 655
at ObjCRuntime.Runtime.InvokeMethod(MonoObject* methodobj, MonoObject* instanceobj, IntPtr native_parameters) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Runtime.CoreCLR.cs:line 552
at ObjCRuntime.Runtime.bridge_runtime_invoke_method(MonoObject* method, MonoObject* instance, IntPtr parameters, IntPtr& exception_gchandle) in /Users/builder/azdo/_work/1/s/xamarin-macios/runtime/Delegates.generated.cs:line 1210
with this change we'll be told exactly which function we failed to call.
Clean up usage of modules in the app.
the var 'module' gets used all over the place. I'm going to refactor to fix up usage of imports and this will make things much easier to track.
In addition, there are a number of types that get used from module.TypeSystem.SomeType which I put into locals just to tidy up.
- Add a stupidly simple "download a nuget and test it" target
- Fix a few targets that should have had :: instead of : (I believe)
I tried to create a fancy define block to param this instead of hard coding, but I ran into the limits of my makefile example. Bike shedding an example would be appreciated, else we can go with this for now.
There will always be an API diff between:
* legacy Xamarin.*.dll assemblies and .NET Microsoft.*.dll assemblies.
* Microsoft.iOS.dll and Microsoft.MacCatalyst.dll
so don't bother with logic to detect empty diffs, just assume they will never be empty.
- change visibility of methods in Program.cs to make it unit-testable
- infrastructure to find the Microsoft platform dlls
- tests to ensure that Xamarin and Microsoft dlls are where we expect
- a (failing) test that shows that dependency is not being removed
Switch to getting mono-api-[info|html] from a newly created repository we
control and where we can easily fix issues, since mono/mono isn't getting many
fixes anymore. In the past I know I've been reluctant to look at these tools,
just because of the hassle of setting things up to debug, and then the
paperwork to get the fixes in mono/mono, and then backported to the branch
where we need them.
This repo has a few other benefits:
* The tools are built using normal projects, which means they're easy to debug
in an IDE (mono/mono's code has generated project files, which used in-tree versions
of the BCL, and it got quite complex quite fast).
* One fewer dependency on the mono archive, so we're getting closed to be able
to drop it completely when we drop support for legacy Xamarin.
* #13669 is already fixed there.
* It contains a few other misc fixes.
Fixes https://github.com/xamarin/xamarin-macios/issues/13669.