The validation verifies that the function pointer for a block callback is the
same the return value from the method's
MethodInfo.MethodHandle.GetFunctionPointer() method.
In actual code, it's equivalent to validating that the following always prints "Equal: true":
```cs
[UnmanagedCallersOnly]
public static void Invoke () {}
static void Test ()
{
delegate* unmanaged<void> fptr1 = &Invoke;
IntPtr fptr2 = GetType ().GetMethod ("Invoke").MethodHandle.GetFunctionPointer ();
Console.WriteLine ($"fptr1: 0x{((IntPtr) fptr1).ToString ("x")}");
Console.WriteLine ($"fptr2: 0x{fptr2.ToString ("x")}");
Console.WriteLine ($"Equal: ((IntPtr) fptr1) == fptr2}"); // prints "Equal: true" for me
}
```
However, this isn't documented, and some feedback indicates it's certainly not
a valid assumption for CoreCLR:
https://discord.com/channels/732297728826277939/732582981163548703/1242473425759633488
And there's also a customer running into this validation, apparently without cause:
https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2054534
So just remove it.
So instead of this:
> Cecil.Tests.Documentation+AssemblyApi: Documented API not found in the platform assembly. This probably indicates that the code to compute the doc name for a given member is incorrect.
we'll get:
> T:Foundation.SomeType: Documented API not found in the platform assembly. This probably indicates that the code to compute the doc name for a given member is incorrect.
Fixes this failure:
> 🔥 Unable to find the contents for the comment: D:\a\1\a\change-detection\results\gh-comment.md does not exist :fire
This is a partial revert of #20601, which broke the API diff.
API diff currently fails with:
** Error: Working directory isn't clean:
HEAD detached at origin/pull/20587/head
Untracked files:
(use "git add <file>..." to include in what will be committed)
tmp.txt
So clean up after ourselves in a previous step to avoid this.
iOS (and presumably tvOS) app bundles can't contain a subdirectory named "Resources".
Apple says:
> Note: An iOS app bundle cannot include a custom folder named “Resources.”
Ref: https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFBundles/BundleTypes/BundleTypes.html#//apple_ref/doc/uid/10000123i-CH101-SW1
Unfortunately Apple's toolchain won't show a helpful error message, the
eventual failure is codesign saying something like this:
bin/Release/net8.0-ios/ios-arm64/SomeApp.app: code object is not signed at all
In subcomponent: bin/Release/net8.0-ios/ios-arm64/SomeApp.app/System.Security.Cryptography.aotdata.arm64
Which is confusing, to say the least.
After debugging this myself a few times, and seeing customers running into the
same issue periodically, it's time to make the error more actionable.
I've added code to our Codesign task to detect the "Resources" subdirectory,
and show a better error message. There's also a way to disable the validation
(by setting `CodesignDisallowResourcesSubdirectoryInAppBundle=false`), just in
case we end up being overeager with the validation.
Fixes https://github.com/xamarin/xamarin-macios/issues/20135.
---------
Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
Add support for the LinkWithSwiftSystemLibraries metadata to specify whether a native library is a Swift library, in which case we'll automatically set the `LinkWithSwiftSystemLibraries` MSBuild property to `true`.
Also add a test.
A `*.framework/` native reference and a `*.framework` reference are the same
thing, so treat them the same. We accomplish this by removing any trailing
path separators (both windows style and non-windows-style for consistency)
before doing any processing.
Fixes https://github.com/xamarin/xamarin-macios/issues/15430.
Throw an exception for a condition we don't handle in the dynamic registrar:
calling a base Objective-C constructor (init method) with arguments. Our
current implementation to call the base Objective-C constructor doesn't handle
any arguments, so if the method actually takes any arguments, those will just
be random memory. In other words: a consistent exception is better than a
random invalid memory access.
We do more builds that we bump mono. Moving to a cache will reduce the
amount of network operations we need to do outside our data center. This
should reduce the time it takes to get the files as well as reduce the
number of network errors we get when accessing the mono download.
This change allows the post build pipelines to download the artefacts generated by the build pipeline that triggered them. This way we can split builds from tests.
The API diff command fials due to the fact that it creates the comment
file inside sources, by moving the file to the artifacts staging
directory we fix the problem and ensure that the comment is removed
after each build.
Ps: I also fixed all the indentation issues in the file that were
reported by yamllint.
Currently we get a message saying all the tests failed catastrophically.
Example:
https://github.com/xamarin/xamarin-macios/pull/20434#issuecomment-2100258803
This is both confusing and scary, so change the comment to say that the
build
failed instead.
---------
Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
The code incorrectly assumed that the contents of a compressed
xcframework would
always be a framework, but this is incorrect (it can be a dynamic
library (.dylib),
static library (.a) or a framework (.framework).
Fix this by:
* Change variable and parameter names to clearly indicate that the
output from
an xcframework is a native library.
* Unify code to handle metadata for native libraries from xcframeworks,
so that
the code isn't duplicated (or even worse, different) between compressed
and non-compressed
xcframeworks.
The latter point fixes a problem where we'd compute the incorrect path
to the static
library inside a compressed xcframework.
PR #20546 contains a test case that triggers this.
Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
We've recently started using more and more ARM64 bots, so these tests are
failing in those cases.
Fixes:
MonoTouchFixtures.Security.SecureTransportTest
[FAIL] SslSupportedCiphers : 3224092716
Expected: True
But was: False
at MonoTouchFixtures.Security.SecureTransportTest.SslSupportedCiphers () [0x000de] in <f08bd76ea2204d929c96e3bd36ae955a>:0
Xamarin.Mac.Tests.EveryFrameworkSmokeTests
[FAIL] ExpectedLibrariesAreLoaded : QTKitLibrary (/System/Library/Frameworks/QTKit.framework/QTKit) failed to load but this was not expected
at Xamarin.Mac.Tests.EveryFrameworkSmokeTests.ExpectedLibrariesAreLoaded () [0x000e6] in <f08bd76ea2204d929c96e3bd36ae955a>:0
Use 'Foundation' as the namespace for NSUrlSessionHandler for all platforms
(so that we have the same API across all platforms).
But only in XAMCORE_5_0, since this is a breaking change.
The enum value MethodAttributes.IsFamily is 'internal' in C#, which is not exposed
outside an assembly, so don't count such members as exposed. On the other hand, MethodAttributes.IsAssembly
is 'protected' in C#, which *is* exposed, so these members are included.
Update tests accordingly.
VB doesn't support default interface members, and will show an error for all
unimplemented interface members, even if they have a default implementation.
This is a problem for the VB templates, because they make use of protocol
interfaces, which will soon have interface members with default
implementations.
In order to get around this, change the VB templates to use the model class
instead of the protocol interfaces.
To be able to download a artifact from a build that triggered the post
build pipeline we cannot use the DownloadPipelineArtifact task with the
same values since the artifact wont be found. This change adds an if
statement to do the right thing based on the trigger so that we can have
both pipelines running correctly until we remove the tests from the
build.
---------
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
This looks like an incorrect merge conflict resolution: the property
_UnpackLibraryResourcesDependsOn was declared twice, the second time
overwriting the first.
Pick the first declaration, since it's the newest and more complete one
(70a5d0d09a).
Attempt to fix simulator runtimes disappearing by:
* Detaching all the currently loaded runtimes.
* Killing the simdiskimaged and CoreSimulatorService services.
Hopefully this will make the simdiskimaged service restart, and reload the
simulator runtimes.
PR https://github.com/xamarin/xamarin-macios/pull/19705 obsoleted
`MidiPacket.Bytes` with obsoletion message that suggests to use internal
properties. This PR changes those properties to be public so that it's
actually usable.
---------
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
We're using two different functions to atomically decrement a reference count,
the native `atomic_fetch_sub` and the managed `Interlocked.Decrement`.
Unfortunately the return value is not the same: `atomic_fetch_sub` returns the
original value before the subtraction, while `Interlocked.Decrement` returns
the subtracted value, while our code assumed the functions behaved the same.
This resulted in a memory leak, because we'd incorrectly expect `0` to be
returned from `atomic_fetch_sub` when the reference count reaches zero, and
thus not detect when the descriptor a block should be freed.
The fix is to update the expected return value from `atomic_fetch_sub` to be
`1` instead of `0`.
Fixes https://github.com/xamarin/xamarin-macios/issues/20503.