Use the .NET version (the `*_NUGET_VERSION` variables) instead of the
Xamarin.iOS/Xamarin.Mac versions (the `IOS_PACKAGE_VERSION` /
`MAC_PACKAGE_VERSION` variables) for the buildinfo file we put in our .NET
NuGets.
This also means we can share the same logic for all .NET platforms, instead of
having to special-case macOS.
Besides this being the correct value to put in the file (the Xamarin versions
have nothing to do with the .NET versions), it also decouples legacy logic
from .NET logic, which makes it easier to remove legacy logic when that time
comes.
The current reults are hard/impossible to understand by a human. Fix the
way we report the error so that we go from:
```
(AVFoundation.AVAudioVoiceProcessingOtherAudioDuckingConfiguration ObjCRuntime.Messaging::AVAudioVoiceProcessingOtherAudioDuckingConfiguration_objc_msgSend(System.IntPtr,System.IntPtr), )
```
to
```
AVFoundation.AVAudioVoiceProcessingOtherAudioDuckingConfiguration ObjCRuntime.Messaging::AVAudioVoiceProcessingOtherAudioDuckingConfiguration_objc_msgSend(System.IntPtr,System.IntPtr) - The return type is AVFoundation.AVAudioVoiceProcessingOtherAudioDuckingConfiguration: (EnableAdvancedDucking: has a [MarshalAs] attribute)
at no match Mono.Cecil.MethodDefinition
```
fulle example here:
https://gist.github.com/mandel-macaque/30f54ac5b0e22454d57644d2b7b94eca
Add a much nicer error message and reuse code. There is not need to add
[Fail] at all in the messages.
Example of the changes:
https://gist.github.com/mandel-macaque/255597f2390804a5a1c2675959b2f35c
---------
Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
As with others, make the results more readable, in this case we just
need to re-use the already present method.
Diff in the ouputs can be found here:
https://gist.github.com/mandel-macaque/7015b2f9c7dfc857caa72f7c1ea19b0a
In this case we move to have the enumerated list.
---------
Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
Remove support for the Protocolize attribute from the generator, and remove
all usages of it in our api definitions - just use the protocol interface.
The Protocolize attribute was used to support binding stuff using the Model
class with Classic Xamarin code + and binding stuff using the protocol
interface with Unified Xamarin code, using the same source code.
Classic Xamarin has been dead for quite a few years ago now though, so there's
no need to keep his code around anymore, we can just upgrade the api
definitions to use the protocol interface directly.
Fixes https://github.com/xamarin/xamarin-macios/issues/14585.
---------
Co-authored-by: Alex Soto <alex@soto.dev>
The ToString of a named tuple does not make sense for a human, this
tests, while it does find issues with the API, it does not help the
developer to find the real reason.
This PR has 2 important fixes.
1. Add a generic constrain to the Assert.Failures. The developer that
wrote the code got lucky and always used T that are IComparable. I mean
lucky, because the OrderBy from Linq needs T to be IComparable, and I am
surprise we never got a rutime error with the test.
2. Use a record type with a reasonable ToString.
The following gist contains a diff between the output with the fix and
without it.
https://gist.github.com/mandel-macaque/ee1adab1bf0568a6e95d47e7f3b7970a
The diff is:
New code:
```
AVFoundation.AVAudioSessionRouteSharingPolicy AVFoundation.AVAudioSessionRouteSharingPolicy::LongForm: AVFoundation.AVAudioSessionRouteSharingPolicy AVFoundation.AVAudioSessionRouteSharingPolicy::LongForm is obsoleted on MacOSX but not on iOS, TVOS, MacCatalyst
```
Old code:
```
(AVFoundation.AVAudioSessionRouteSharingPolicy AVFoundation.AVAudioSessionRouteSharingPolicy::LongForm, AVFoundation.AVAudioSessionRouteSharingPolicy AVFoundation.AVAudioSessionRouteSharingPolicy::LongForm, Cecil.Tests.OSPlatformAttributes[], Cecil.Tests.OSPlatformAttributes[])
```
---------
Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
In order to make it easier to pass C-style strings to P/Invokes, we
introduced
a TransientString struct some time ago.
This works quite well, so I implemented the same for CFStrings - a
TransientCFString struct - and started using it in a few places. The
idea
would be to slowly start migrating our codebase to this new pattern.
Instead of:
var ptr = CFString.CreateNative ("somestring");
try {
CallPInvoke (ptr);
} finally {
CFString.ReleaseNative (ptr);
}
we'll do:
using var ptr = new TransientCFString ("somestring");
CallPInvoke (ptr);
The default RuntimeIdentifier for Mac Catalyst is maccatalyst-arm64 if running
on an ARM64 machine, which is what our unit tests assume. Hardcoding the
RuntimeIdentifier in the project file prevents the default from being used,
and makes the unit tests fail when running on an ARM64 machine.
Extracted a good amount of code from Main3 which should make it easier
to read. Tried to keep changes minimal.
---------
Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
The global variables cannot be loaded, this is reported by intro AND has
been tested with swift. Moved the variables to be an enum whihc makes
more sense in the API.
In theory we should define the default platform version if it's not specified
in the TFM, and this default should not change for a given .NET version:
* We release support for iOS 17.0 with .NET 8
* Apple releases iOS 18.0, we're still using .NET 8. This default continues to be iOS 17.0
* .NET 9 is shipped, and at this point we bump the default to iOS 18.0
Basically: this should be the last OS version of the platform in question when
the current major .NET version is first released to stable.
Ref: 8e6394406d/accepted/2020/net5/net5.md (os-versions)
However, this doesn't work well for Apple platforms: whenever Apple releases
new Xcode versions, our existing workloads might not be compatible with the
new Xcode. We'll of course ship updateds workload with support for the new
Xcode, but defaulting to an older target platform version would mean that
developers wouldn't get the new workload, they'd get the old one. This is
exacerbated by the fact that Apple aggressively auto-updates Xcode on
developers' machines: they might wake up one day to a broken build - the
obvious fix ("dotnet workload update") doesn't fix anything - even if we've
shipped updated workloads - because the default is to use the old one. They'd
have to manually specify the target platform version in the target platform to
get the updated workload ("net8.0-ios17.2" to use the iOS 17.2 workload
instead of "net8.0-ios", which would use the default (old/initial/17.0) .NET 8
workload) - and then update _again_ when the next Xcode comes around. At this
point the point of having a sane default value is totally out the window,
because everybody would have to specify (and continuously update) a platform
version in their project files to keep their projects building.
So we've made the decision that the default target platform version is always
the latest target platform version.
Found this while writing some unit tests for the generator. The
comparison between types uses a ReferenceEquals, that means that we
should ensure that we have a EcmaType in both sides. When running this
on unit tests, we have a RunTime vs a EcmaType comparison which results
in an error.
Pay attention to the following:
1. Changed the way we filter types so that we can use the set in several
methods.
2. Added a new compiler injected attribute to be ignored:
'Microsoft.CodeAnalysis.EmbeddedAttribute'
3. Microsoft.CodeAnalysis.EmbeddedAttribute is added/present in more
than one assembly, so do not throw when that happens, is a special case
that is injected by the compiler.
I ran the generator diff between main and this commit and the output is:
```
diff --git a/old/dotnet/IDE/obj/common/bgen/bgen.AssemblyInfo.cs b/new/dotnet/IDE/obj/common/bgen/bgen.AssemblyInfo.cs
index ef5e2e112f..5ded00c3af 100644
--- a/old/dotnet/IDE/obj/common/bgen/bgen.AssemblyInfo.cs
+++ b/new/dotnet/IDE/obj/common/bgen/bgen.AssemblyInfo.cs
@@ -13,7 +13,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("bgen")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
-[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+b60ee772c228723a5e01212471c1e8eb5c20ebb9")]
+[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+ec8a6c261a68f6aee2ad2373cf45e3f001ac4679")]
[assembly: System.Reflection.AssemblyProductAttribute("bgen")]
[assembly: System.Reflection.AssemblyTitleAttribute("bgen")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
diff --git a/old/dotnet/IDE/obj/common/bgen/bgen.sourcelink.json b/new/dotnet/IDE/obj/common/bgen/bgen.sourcelink.json
index 5c5105e606..547bfb2dc4 100644
--- a/old/dotnet/IDE/obj/common/bgen/bgen.sourcelink.json
+++ b/new/dotnet/IDE/obj/common/bgen/bgen.sourcelink.json
@@ -1 +1 @@
-{"documents":{"/Users/mandel/Xamarin/xamarin-macios/xamarin-macios/tools/comparison/tmp/src/xamarin-macios/*":"b454d454a6/*"}}
\ No newline at end of file
+{"documents":{"/Users/mandel/Xamarin/xamarin-macios/xamarin-macios/*":"b454d454a6/*"}}
\ No newline at end of file
```
API should result in no changes.
---------
Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
The packages in packages.config for mtouch don't seem be used anymore (the
localization process for mtouch doesn't use the xliff localization workflow
anymore), so just remove the file.
Adding up for review but will block its landing until the PR
https://github.com/xamarin/xamarin-macios/pull/7539 which was fixed by
@dustin-wojciechowski has been landed.
---------
Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
Also fix the signature for the Dispose method - it has to override the base
implementation, not provide a new implementation.
Contributes towards #15684.
The backslash character is pretty common on Windows (since it's a path separator),
but the argument parser will treat it as an escape character, and just skip it.
This is obviously wrong, so just replace backslashes with forward slashes, which
should work just as well on Windows, and will also be parsed correctly.
The downside is that now there's no way to escape characters, but that should be a
very rare problem (much rarer than backslash characters), and there are other
ways around the problem (set the actual target property instead of going through
the MtouchExtraArgs property for instance):
This makes it much easier to understand what's happening when there's a
failure to parse a binlog.
This happens rather frequently, these have all happened:
* Truncated binlogs because a build timed out.
* Binlog version is higher than expected.
* Bugs in the binlog reader.
* Bugs in the binlog writer.
Many, many, _many_ years ago (before my time!) Mono didn't properly handle
P/Invokes that returned structures. The arm ABI stated that certain structures
had be returned by having the function take a hidden first argument, where the
argument would be a pointer to where the returned structure should be stored
by the called function.
We worked around this in the generator by modifying functions returning
structures to functions taking a pointer to the function to return as the
first argument.
So this:
SomeStruct SomeFunction ();
would become:
void SomeFunction (SomeStruct *retval);
This workaround isn't necessary anymore, because both Mono and CoreCLR will
just do the right thing.
Except... when the the pointer to the structure must have a specific
alignment. In that case we still need the workaround, so keep it then.