[net8.0-xcode15] Merge net8.0 into net8.0-xcode15.

This commit is contained in:
Rolf Bjarne Kvinge 2023-08-23 17:35:17 +02:00
Родитель a772b4df10 eead0fee73
Коммит 7d5e1a4e7e
53 изменённых файлов: 2195 добавлений и 268 удалений

Просмотреть файл

@ -125,7 +125,7 @@ endif
##
## Note that the prerelease identifier should be as short as possible, because otherwise
## the resulting package name can become too long for MSIs.
NUGET_HARDCODED_PRERELEASE_IDENTIFIER=net8-rc1
NUGET_HARDCODED_PRERELEASE_IDENTIFIER=net8-rc2
NUGET_HARDCODED_PRERELEASE_BRANCH=net8.0
# compute the alphanumeric version of branch names
@ -288,12 +288,6 @@ DOTNET_MIN_TVOS_SDK_VERSION=11.0
DOTNET_MIN_MACCATALYST_SDK_VERSION=13.1
DOTNET_MIN_MACOS_SDK_VERSION=10.15
# Minimum OS versions when using NativeOAT - these are at least the general min versions above (but may be higher).
DOTNET_MIN_NATIVEAOT_IOS_SDK_VERSION=12.2
DOTNET_MIN_NATIVEAOT_TVOS_SDK_VERSION=12.2
DOTNET_MIN_NATIVEAOT_MACCATALYST_SDK_VERSION=13.1
DOTNET_MIN_NATIVEAOT_MACOS_SDK_VERSION=10.15
# The min simulator version available in the Xcode we're using
MIN_IOS_SIMULATOR_VERSION=14.3
MIN_WATCHOS_SIMULATOR_VERSION=7.1

Просмотреть файл

@ -41,6 +41,8 @@
<add key="darc-pub-dotnet-runtime-de84cf9" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-runtime-d5edd29b-1/nuget/v3/index.json" />
<!-- Add a 6.0.14 feed -->
<add key="darc-pub-dotnet-runtime-2e45bc7" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-runtime-2e45bc7a/nuget/v3/index.json" />
<!-- Add a 7.0.11 feed -->
<add key="darc-pub-dotnet-runtime-0ece505" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-runtime-0ece5051/nuget/v3/index.json" />
</packageSources>
<disabledPackageSources>
<clear />

Просмотреть файл

@ -3749,3 +3749,28 @@ This exception will have an inner exception which gives the reason for the failu
### MT8036: Failed to convert the value at index {index} from {type} to {type}.
This exception will have an inner exception which gives the reason for the failure.
<a name="MX8056" />
### MX8056: Failed to marshal the Objective-C object {handle} (type: {objc_type}). Could not find an existing managed instance for this object, nor was it possible to create a new managed instance of generic type {managed_type}.
This occurs when the Xamarin.iOS runtime finds an Objective-C object without a
corresponding managed wrapper object, and when trying to create that managed
wrapper, it turns out it's not possible. This error is specific to the managed
static registrar.
There are a few reasons this may happen:
* A managed wrapper existed at some point, but was collected by the GC. If the
native object is still alive, and later resurfaces to managed code, the
Xamarin.iOS runtime will try to re-create a managed wrapper instance. In
most cases the problem here is that the managed wrapper shouldn't have been
collected by the GC in the first place.
Possible causes include:
* Manually calling Dispose too early on the managed wrapper.
* Incorrect bindings for third-party libraries.
* Reference-counting bugs in third-party libraries.
* This indicates a bug in Xamarin.iOS. Please file a new issue on [github](https://github.com/xamarin/xamarin-macios/issues/new).

Просмотреть файл

@ -1,9 +1,51 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0-maccatalyst</TargetFramework>
<RuntimeIdentifier>maccatalyst-x64</RuntimeIdentifier>
<!-- The default runtime is maccatalyst-x64, except in Release config, in which case the default is maccatalyst-x64;maccatalyst-arm64.
When specifying both architectures, use the plural <RuntimeIdentifiers> instead of the singular <RuntimeIdentifer>.
The App Store will NOT accept apps with ONLY maccatalyst-arm64 indicated;
either BOTH runtimes must be indicated or ONLY macatalyst-x64. -->
<!-- ex. <RuntimeIdentifiers>maccatalyst-x64;maccatalyst-arm64</RuntimeIdentifiers> -->
<RootNamespace Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">MacCatalystApp1</RootNamespace>
<OutputType>Exe</OutputType>
<SupportedOSPlatformVersion>minOSVersion</SupportedOSPlatformVersion>
</PropertyGroup>
<!-- Notes about the values set below:
1. For macOS it's possible to sign both the app bundle (EnableCodesigning=true) and the package (*.pkg) (EnablePackageSigning=true),
and these are signed separately and with different certificates.
CodesignKey: this is the signing key used for the app bundle
PackageSigningKey: this is the signing key used for the package
2. Publishing to the App Store requires signing both the app bundle and the package.
Must be 'Apple Distribution: ...' for the app bundle. Note that apps signed like this will not execute locally.
They have to be published to the App Store and then downloaded (Apple will resign the app with a different signing identity that allows for local execution).
Must be '3rd Party Mac Developer Installer: ...' for the pkg
3. Publishing outside of the App Store (i.e. only notarizing) requires:
Must be 'Developer ID Application: ...' for the app bundle
Must be 'Developer ID Installer: ...' for the pkg
4. During development, use the 'Apple Development: ...' signing key (typically to verify that the app works when is signed and entitlements are enforced).
5. Depending on the entitlements the app needs, a specific provisioning profile (CodesignProvision) might be needed.
6. UseHardenedRuntime must be set to true when app sandbox is enabled in Info.plist.
-->
<!--
For Debug: (Note: Replace placeholder information before building)
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<CodesignKey>Apple Development: YOURNAME (*******)</CodesignKey>
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
<CodesignProvision>YOUR PROFILE NAME</CodesignProvision>
</PropertyGroup>
-->
<!--
For Release: (Note: Replace placeholder information before building)
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<EnableCodeSigning>True</EnableCodeSigning>
<ProvisionType>Manual</ProvisionType>
<CreatePackage>true</CreatePackage>
<EnablePackageSigning>true</EnablePackageSigning>
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
<CodesignKey>Apple Development: YOURNAME (*******)</CodesignKey>
<CodesignProvision>YOUR PROFILE NAME</CodesignProvision>
<PackageSigningKey>3rd Party Mac Developer Installer: YOURNAME (*******)</PackageSigningKey>
<UseHardenedRuntime>true</UseHardenedRuntime>
</PropertyGroup>-->
</Project>

Просмотреть файл

@ -24,16 +24,10 @@ var doc = new XmlDocument ();
doc.Load (plistPath);
var nodes = doc.SelectNodes ($"/plist/dict/key[text()='KnownVersions']/following-sibling::dict[1]/key[text()='{platform}']/following-sibling::array[1]/string");
var allLines = File.ReadAllLines ("../Make.config");
var minSdkVersionName = $"DOTNET_MIN_{platform.ToUpper ()}_SDK_VERSION";
var minSdkVersionString = allLines.Single (v => v.StartsWith (minSdkVersionName + "=", StringComparison.Ordinal)).Substring (minSdkVersionName.Length + 1);
var minSdkVersionString = File.ReadAllLines ("../Make.config").Single (v => v.StartsWith (minSdkVersionName + "=", StringComparison.Ordinal)).Substring (minSdkVersionName.Length + 1);
var minSdkVersion = Version.Parse (minSdkVersionString);
var minNativeAotSdkVersionName = $"DOTNET_MIN_NATIVEAOT_{platform.ToUpper ()}_SDK_VERSION";
var minNativeAotSdkVersionString = allLines.Single (v => v.StartsWith (minNativeAotSdkVersionName + "=", StringComparison.Ordinal)).Substring (minNativeAotSdkVersionName.Length + 1);
var minNativeAotSdkVersion = Version.Parse (minNativeAotSdkVersionString);
using (TextWriter writer = new StreamWriter (outputPath)) {
writer.WriteLine ($"<!-- This file contains a generated list of the {platform} platform versions that are supported for this SDK -->");
writer.WriteLine ($"<!-- Generation script: https://github.com/xamarin/xamarin-macios/blob/main/dotnet/generate-target-platforms.csharp -->");
@ -42,14 +36,9 @@ using (TextWriter writer = new StreamWriter (outputPath)) {
foreach (XmlNode n in nodes) {
var version = n.InnerText;
var parsedVersion = Version.Parse (version);
if (parsedVersion < minSdkVersion)
if (Version.Parse (version) < minSdkVersion)
continue;
if (parsedVersion < minNativeAotSdkVersion) {
writer.WriteLine ($"\t\t<{platform}SdkSupportedTargetPlatformVersion Include=\"{n.InnerText}\" Condition=\"!('$(PublishAot)' == 'true' And '$(_IsPublishing)' == 'true')\" />");
} else {
writer.WriteLine ($"\t\t<{platform}SdkSupportedTargetPlatformVersion Include=\"{n.InnerText}\" />");
}
writer.WriteLine ($"\t\t<{platform}SdkSupportedTargetPlatformVersion Include=\"{n.InnerText}\" />");
}
writer.WriteLine ("\t</ItemGroup>");
@ -57,8 +46,7 @@ using (TextWriter writer = new StreamWriter (outputPath)) {
writer.WriteLine ($"\t\t<SdkSupportedTargetPlatformVersion Condition=\"'$(TargetPlatformIdentifier)' == '{platform}'\" Include=\"@({platform}SdkSupportedTargetPlatformVersion)\" />");
writer.WriteLine ("\t</ItemGroup>");
writer.WriteLine ("\t<PropertyGroup>");
writer.WriteLine ($"\t\t<{platform}MinSupportedOSPlatformVersion Condition=\"!('$(PublishAot)' == 'true' And '$(_IsPublishing)' == 'true')\">{minSdkVersionString}</{platform}MinSupportedOSPlatformVersion>");
writer.WriteLine ($"\t\t<{platform}MinSupportedOSPlatformVersion Condition=\"'$(PublishAot)' == 'true' And '$(_IsPublishing)' == 'true'\">{minNativeAotSdkVersionString}</{platform}MinSupportedOSPlatformVersion>");
writer.WriteLine ($"\t\t<{platform}MinSupportedOSPlatformVersion>{minSdkVersionString}</{platform}MinSupportedOSPlatformVersion>");
writer.WriteLine ("\t</PropertyGroup>");
writer.WriteLine ("</Project>");
}

Просмотреть файл

@ -10,18 +10,6 @@
<EnableDefaultwatchOSItems Condition=" '$(_PlatformName)' == 'watchOS' And '$(EnableDefaultwatchOSItems)' == '' ">$(EnableDefaultItems)</EnableDefaultwatchOSItems>
<EnableDefaultmacOSItems Condition=" '$(_PlatformName)' == 'macOS' And '$(EnableDefaultmacOSItems)' == '' ">$(EnableDefaultItems)</EnableDefaultmacOSItems>
<EnableDefaultMacCatalystItems Condition=" '$(_PlatformName)' == 'MacCatalyst' And '$(EnableDefaultMacCatalystItems)' == '' ">$(EnableDefaultItems)</EnableDefaultMacCatalystItems>
<!--
PublishAot should only take effect when doing 'dotnet publish', not when doing 'dotnet build'. We distinguish these cases using the '_IsPublishing' property,
but it's rather annoying to always have to check both PublishAot and _IsPublishing to see if we're using NativeAOT, so introduce a third property that's
only set to true if both PublishAot=true and _IsPublishing=true
-->
<_UseNativeAot Condition="'$(PublishAot)' == 'true' And '$(_IsPublishing)' == 'true'">true</_UseNativeAot>
<UseMonoRuntime Condition=" '$(UseMonoRuntime)' == '' And '$(_PlatformName)' == 'macOS'">false</UseMonoRuntime>
<UseMonoRuntime Condition=" '$(UseMonoRuntime)' == '' And '$(_UseNativeAot)' == 'true'">false</UseMonoRuntime>
<UseMonoRuntime Condition=" '$(UseMonoRuntime)' == ''">true</UseMonoRuntime>
</PropertyGroup>
<ItemGroup>

Просмотреть файл

@ -8,8 +8,15 @@
<Import Project="Xamarin.Shared.Sdk.TargetFrameworkInference.props" />
<!-- Imports the .user.env file if exists and the build is from VS -->
<Import Project="$(MSBuildProjectFullPath).user.env" Condition="Exists('$(MSBuildProjectFullPath).user.env') And '$(BuildingInsideVisualStudio)' == 'true'" />
<PropertyGroup>
<!-- e.g: C:\Users\user1\app1\app1\obj\ -->
<_MobilePropsDir>$([System.IO.Path]::Combine($(MSBuildProjectDirectory), $(BaseIntermediateOutputPath)))</_MobilePropsDir>
<!-- e.g: C:\Users\user1\app1\app1\obj\app1.mobile.props -->
<_MobilePropsPath>$(_MobilePropsDir)$(MSBuildProjectName).mobile.props</_MobilePropsPath>
</PropertyGroup>
<!-- Imports the .mobile.props file if exists and the build is from VS -->
<Import Project="$(_MobilePropsPath)" Condition="Exists('$(_MobilePropsPath)') And '$(BuildingInsideVisualStudio)' == 'true'" />
<PropertyGroup>
<!-- Set to true when using the Microsoft.<platform>.Sdk NuGet. This is used by pre-existing/shared targets to tweak behavior depending on build system -->
@ -20,7 +27,27 @@
<_XamarinSdkRootDirectoryOnMac>$(_XamarinSdkRootDirectory)</_XamarinSdkRootDirectoryOnMac>
<_XamarinTaskAssembly Condition="'$(_PlatformName)' != 'macOS'">$(_XamarinSdkRootDirectory)\tools\msbuild\iOS\Xamarin.iOS.Tasks.dll</_XamarinTaskAssembly>
<_XamarinTaskAssembly Condition="'$(_PlatformName)' == 'macOS'">$(_XamarinSdkRootDirectory)\tools\msbuild\macOS\Xamarin.Mac.Tasks.dll</_XamarinTaskAssembly>
<SuppressTrimAnalysisWarnings Condition=" '$(SuppressTrimAnalysisWarnings)' == '' ">true</SuppressTrimAnalysisWarnings>
<!--
PublishAot should only take effect when doing 'dotnet publish', not when doing 'dotnet build'. We distinguish these cases using the '_IsPublishing' property,
but it's rather annoying to always have to check both PublishAot and _IsPublishing to see if we're using NativeAOT, so introduce a third property that's
only set to true if both PublishAot=true and _IsPublishing=true
-->
<_UseNativeAot Condition="'$(PublishAot)' == 'true' And '$(_IsPublishing)' == 'true'">true</_UseNativeAot>
<UseMonoRuntime Condition=" '$(UseMonoRuntime)' == '' And '$(_PlatformName)' == 'macOS'">false</UseMonoRuntime>
<UseMonoRuntime Condition=" '$(UseMonoRuntime)' == '' And '$(_UseNativeAot)' == 'true'">false</UseMonoRuntime>
<UseMonoRuntime Condition=" '$(UseMonoRuntime)' == ''">true</UseMonoRuntime>
<!--
With NativeAOT we want to suppress trim warnings coming from ILLink and enable them only for ILC.
For this reason, in case of NativeAOT, we set SuppressTrimAnalysisWarnings to true by default and store the overwriten default in
_OriginalSuppressTrimAnalysisWarnings property, which is later used to properly configure warning suppression for ILC.
-->
<_OriginalSuppressTrimAnalysisWarnings>$(SuppressTrimAnalysisWarnings)</_OriginalSuppressTrimAnalysisWarnings>
<SuppressTrimAnalysisWarnings Condition="'$(_UseNativeAot)' == 'true'">true</SuppressTrimAnalysisWarnings>
<SuppressTrimAnalysisWarnings Condition="'$(SuppressTrimAnalysisWarnings)' == ''">true</SuppressTrimAnalysisWarnings>
<AfterMicrosoftNETSdkTargets>$(AfterMicrosoftNETSdkTargets);$(MSBuildThisFileDirectory)Microsoft.$(_PlatformName).Sdk.targets</AfterMicrosoftNETSdkTargets>
<!-- _XamarinSdkRoot is used by the existing MSBuild targets files -->

Просмотреть файл

@ -508,18 +508,12 @@
<!-- Set NativeAOT value -->
<_IsNativeAOTFeature Condition="'$(_XamarinRuntime)' == 'NativeAOT'">true</_IsNativeAOTFeature>
<_IsNativeAOTFeature Condition="'$(_XamarinRuntime)' != 'NativeAOT'">false</_IsNativeAOTFeature>
<!-- Set the features for ILLink -->
<_ExtraTrimmerArgs>$(_ExtraTrimmerArgs) --feature ObjCRuntime.Runtime.Arch.IsSimulator $(_IsSimulatorFeature)</_ExtraTrimmerArgs>
<_ExtraTrimmerArgs>$(_ExtraTrimmerArgs) --feature ObjCRuntime.Runtime.IsManagedStaticRegistrar $(_IsManagedStaticRegistrarFeature)</_ExtraTrimmerArgs>
<_ExtraTrimmerArgs>$(_ExtraTrimmerArgs) --feature ObjCRuntime.Runtime.IsNativeAOT $(_IsNativeAOTFeature)</_ExtraTrimmerArgs>
</PropertyGroup>
<ItemGroup>
<!-- Set the features for ILC -->
<IlcArg Include="--feature:ObjCRuntime.Runtime.Arch.IsSimulator=$(_IsSimulatorFeature)" />
<IlcArg Include="--feature:ObjCRuntime.Runtime.IsManagedStaticRegistrar=$(_IsManagedStaticRegistrarFeature)" />
<IlcArg Include="--feature:ObjCRuntime.Runtime.IsNativeAOT=$(_IsNativeAOTFeature)" />
<RuntimeHostConfigurationOption Include="ObjCRuntime.Runtime.Arch.IsSimulator" Value="$(_IsSimulatorFeature)" Trim="true" />
<RuntimeHostConfigurationOption Include="ObjCRuntime.Runtime.IsManagedStaticRegistrar" Value="$(_IsManagedStaticRegistrarFeature)" Trim="true" />
<RuntimeHostConfigurationOption Include="ObjCRuntime.Runtime.IsNativeAOT" Value="$(_IsNativeAOTFeature)" Trim="true" />
</ItemGroup>
</Target>
@ -655,6 +649,9 @@
<!-- Enable serialization discovery. Ref: https://github.com/xamarin/xamarin-macios/issues/15676 -->
<_ExtraTrimmerArgs>$(_ExtraTrimmerArgs) --enable-serialization-discovery</_ExtraTrimmerArgs>
<!-- If we're using NativeAOT, tell ILLink to not remove dependency attributes (DynamicDependencyAttribute), because NativeAOT's trimmer also needs to see them. -->
<_ExtraTrimmerArgs Condition="'$(_UseNativeAot)' == 'true'">$(_ExtraTrimmerArgs) --keep-dep-attributes</_ExtraTrimmerArgs>
<!-- We always want the linker to process debug symbols, even when building in Release mode, because the AOT compiler uses the managed debug symbols to output DWARF debugging symbols -->
<TrimmerRemoveSymbols Condition="'$(TrimmerRemoveSymbols)' == ''">false</TrimmerRemoveSymbols>
@ -847,9 +844,8 @@
<_StrippedAssemblyDirectory>$(DeviceSpecificIntermediateOutputPath)\stripped</_StrippedAssemblyDirectory>
</PropertyGroup>
<ItemGroup>
<_AssembliesToBeStripped Include="@(ResolvedFileToPublish)" Condition="'%(Extension)' == '.dll'">
<OutputPath Condition="'%(ResolvedFileToPublish.DestinationSubPath)' != ''">$(_StrippedAssemblyDirectory)\%(ResolvedFileToPublish.DestinationSubPath)</OutputPath>
<OutputPath Condition="'%(ResolvedFileToPublish.DestinationSubPath)' == ''">$(_StrippedAssemblyDirectory)\%(Filename)%(Extension)</OutputPath>
<_AssembliesToBeStripped Include="@(ResolvedFileToPublish)" Condition="'%(Extension)' == '.dll' And '%(ResolvedFileToPublish.Culture)' == ''">
<OutputPath>$(_StrippedAssemblyDirectory)\%(ResolvedFileToPublish.OriginalRelativePath)</OutputPath>
</_AssembliesToBeStripped>
<!-- Use forward slashes in OutputPath, otherwise ILStrip will create filenames that resemble the part of
@ -1229,6 +1225,9 @@
<PropertyGroup>
<!-- Ask ILC to produce a static library -->
<NativeLib>static</NativeLib>
<!-- Always enable trim warnings by default with NativeAOT -->
<SuppressTrimAnalysisWarnings Condition="'$(_OriginalSuppressTrimAnalysisWarnings)' != 'true'">false</SuppressTrimAnalysisWarnings>
</PropertyGroup>
<ItemGroup>
@ -1645,8 +1644,7 @@
</PropertyGroup>
<PropertyGroup Condition="'$(TrimMode)' == ''">
<!-- Linking is always on for all assemblies when using NativeAOT - this is because we need to modify all assemblies in the linker for them to be compatible with NativeAOT -->
<_DefaultLinkMode Condition="'$(_UseNativeAot)' == 'true' And '$(_PlatformName)' == 'macOS'">Full</_DefaultLinkMode>
<_DefaultLinkMode Condition="'$(_UseNativeAot)' == 'true' And '$(_PlatformName)' != 'macOS'">SdkOnly</_DefaultLinkMode>
<_DefaultLinkMode Condition="'$(_UseNativeAot)' == 'true'">Full</_DefaultLinkMode>
<_DefaultLinkMode Condition="'$(_UseNativeAot)' != 'true' And '$(_PlatformName)' == 'macOS'">None</_DefaultLinkMode> <!-- Linking is off by default for macOS apps -->
<_DefaultLinkMode Condition="'$(_UseNativeAot)' != 'true' And '$(_PlatformName)' == 'MacCatalyst' And '$(Configuration)' == 'Release'">SdkOnly</_DefaultLinkMode> <!-- Default linking is on for release builds for Mac Catalyst apps -->
@ -1898,7 +1896,7 @@
<ResolvedFileToPublish Remove="@(_CompressedAppleBindingResourcePackage)" />
<!-- Rewrite the relative path so that everything ends up in the app bundle -->
<ResolvedFileToPublish RelativePath="$(_RelativeAppBundlePath)\%(RelativePath)" />
<ResolvedFileToPublish RelativePath="$(_RelativeAppBundlePath)\%(RelativePath)" OriginalRelativePath="%(RelativePath)" />
</ItemGroup>
<!-- This task is executed on Windows as well, for hotrestart builds -->
@ -2313,7 +2311,7 @@ global using nfloat = global::System.Runtime.InteropServices.NFloat%3B
<Import Project="$(_TargetsDirectory)Xamarin.Mac.ObjCBinding.$(_ProjectLanguage).targets" Condition="'$(_ProjectType)' == 'macOSBindingProject' " />
<Import Project="$(_TargetsDirectory)Xamarin.MacCatalyst.$(_ProjectLanguage).targets" Condition="'$(_ProjectType)' == 'MacCatalystExecutableProject' Or '$(_ProjectType)' == 'MacCatalystClassLibrary' " />
<Import Project="$(_TargetsDirectory)Xamarin.MacCatalyst.AppExtension.$(_ProjectLanguage).targets" Condition="'$(_ProjectType)' == 'MacCatalystSAppExtensionProject' " />
<Import Project="$(_TargetsDirectory)Xamarin.MacCatalyst.AppExtension.$(_ProjectLanguage).targets" Condition="'$(_ProjectType)' == 'MacCatalystAppExtensionProject' " />
<Import Project="$(_TargetsDirectory)Xamarin.MacCatalyst.ObjCBinding.$(_ProjectLanguage).targets" Condition="'$(_ProjectType)' == 'MacCatalystBindingProject' " />
</Project>

Просмотреть файл

@ -1,47 +1,47 @@
<Dependencies>
<ProductDependencies>
<Dependency Name="Microsoft.Dotnet.Sdk.Internal" Version="8.0.100-rc.1.23378.5">
<Dependency Name="Microsoft.Dotnet.Sdk.Internal" Version="8.0.100-rc.2.23422.3">
<Uri>https://github.com/dotnet/installer</Uri>
<Sha>eee48b8da517110dcdcd100c1a36bb084abd4482</Sha>
<Sha>287aaf0581126c529df97b7155c9fe70f0f8acce</Sha>
</Dependency>
<Dependency Name="Microsoft.NET.ILLink.Tasks" Version="8.0.0-rc.1.23376.5" CoherentParentDependency="Microsoft.Dotnet.Sdk.Internal">
<Dependency Name="Microsoft.NET.ILLink.Tasks" Version="8.0.0-rc.2.23418.14" CoherentParentDependency="Microsoft.Dotnet.Sdk.Internal">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>ea97babd7ccfd2f6e9553093d315f26b51e4c7ac</Sha>
<Sha>90b92bb265a412592c4c152983d7b30c92236dbe</Sha>
</Dependency>
<!-- Set TRACKING_DOTNET_RUNTIME_SEPARATELY to something in Make.config if removing the CoherentParentDependency on Microsoft.Dotnet.Sdk.Internal -->
<Dependency Name="Microsoft.NETCore.App.Ref" Version="8.0.0-rc.1.23376.5" CoherentParentDependency="Microsoft.Dotnet.Sdk.Internal">
<Dependency Name="Microsoft.NETCore.App.Ref" Version="8.0.0-rc.2.23418.14" CoherentParentDependency="Microsoft.Dotnet.Sdk.Internal">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>ea97babd7ccfd2f6e9553093d315f26b51e4c7ac</Sha>
<Sha>90b92bb265a412592c4c152983d7b30c92236dbe</Sha>
</Dependency>
<!-- This is required for our test apps to build; in some cases Microsoft.AspNetCore.App is pulled in, and when building test apps the build needs to be able to resolve that -->
<Dependency Name="Microsoft.AspNetCore.App.Ref" Version="8.0.0-rc.1.23376.5" CoherentParentDependency="Microsoft.Dotnet.Sdk.Internal">
<Dependency Name="Microsoft.AspNetCore.App.Ref" Version="8.0.0-rc.2.23421.27" CoherentParentDependency="Microsoft.Dotnet.Sdk.Internal">
<Uri>https://github.com/dotnet/aspnetcore</Uri>
<Sha>40dc1466a4543921e5e124ae6f92a813cae40e83</Sha>
<Sha>fe448a7958355091ea97ca19e7c93f517c4df8fa</Sha>
</Dependency>
<Dependency Name="Microsoft.NET.Workload.Emscripten.Current.Manifest-8.0.100.Transport" Version="8.0.0-rc.1.23368.3" CoherentParentDependency="Microsoft.NETCore.App.Ref">
<Dependency Name="Microsoft.NET.Workload.Emscripten.Current.Manifest-8.0.100.Transport" Version="8.0.0-rc.1.23415.5" CoherentParentDependency="Microsoft.NETCore.App.Ref">
<Uri>https://github.com/dotnet/emsdk</Uri>
<Sha>1f68fcee45ca75a2cb780edaff1e695af4d4f787</Sha>
<Sha>66dbaefff04250dc72849f0172e0c53bcfb3ab38</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.Cecil" Version="0.11.4-alpha.23360.2" CoherentParentDependency="Microsoft.NETCore.App.Ref">
<Dependency Name="Microsoft.DotNet.Cecil" Version="0.11.4-alpha.23407.2" CoherentParentDependency="Microsoft.NETCore.App.Ref">
<Uri>https://github.com/dotnet/cecil</Uri>
<Sha>1a6a83a8f50e1119f1007b1e3c211d3289ba6901</Sha>
<Sha>2f4ef297939628143389ddeea569874ded0b1c1b</Sha>
</Dependency>
<!-- This is a subscription of the .NET 7 versions of our packages -->
<Dependency Name="Microsoft.MacCatalyst.Sdk" Version="16.4.7097">
<Dependency Name="Microsoft.MacCatalyst.Sdk" Version="16.4.7098">
<Uri>https://github.com/xamarin/xamarin-macios</Uri>
<Sha>3dbe4c545c5c55850113f91fdcdc9797569f853c</Sha>
<Sha>3501f0c638bba4bd8c91017df96fa9d1a0010a73</Sha>
</Dependency>
<Dependency Name="Microsoft.macOS.Sdk" Version="13.3.7097">
<Dependency Name="Microsoft.macOS.Sdk" Version="13.3.7098">
<Uri>https://github.com/xamarin/xamarin-macios</Uri>
<Sha>3dbe4c545c5c55850113f91fdcdc9797569f853c</Sha>
<Sha>3501f0c638bba4bd8c91017df96fa9d1a0010a73</Sha>
</Dependency>
<Dependency Name="Microsoft.iOS.Sdk" Version="16.4.7097">
<Dependency Name="Microsoft.iOS.Sdk" Version="16.4.7098">
<Uri>https://github.com/xamarin/xamarin-macios</Uri>
<Sha>3dbe4c545c5c55850113f91fdcdc9797569f853c</Sha>
<Sha>3501f0c638bba4bd8c91017df96fa9d1a0010a73</Sha>
</Dependency>
<Dependency Name="Microsoft.tvOS.Sdk" Version="16.4.7097">
<Dependency Name="Microsoft.tvOS.Sdk" Version="16.4.7098">
<Uri>https://github.com/xamarin/xamarin-macios</Uri>
<Sha>3dbe4c545c5c55850113f91fdcdc9797569f853c</Sha>
<Sha>3501f0c638bba4bd8c91017df96fa9d1a0010a73</Sha>
</Dependency>
<Dependency Name="Microsoft.NET.Runtime.MonoTargets.Sdk" Version="7.0.7">
<Uri>https://github.com/dotnet/runtime</Uri>

Просмотреть файл

@ -2,22 +2,22 @@
<!--Package versions-->
<PropertyGroup>
<!-- Versions updated by maestro -->
<MicrosoftDotnetSdkInternalPackageVersion>8.0.100-rc.1.23378.5</MicrosoftDotnetSdkInternalPackageVersion>
<MicrosoftNETILLinkTasksPackageVersion>8.0.0-rc.1.23376.5</MicrosoftNETILLinkTasksPackageVersion>
<MicrosoftDotnetSdkInternalPackageVersion>8.0.100-rc.2.23422.3</MicrosoftDotnetSdkInternalPackageVersion>
<MicrosoftNETILLinkTasksPackageVersion>8.0.0-rc.2.23418.14</MicrosoftNETILLinkTasksPackageVersion>
<MicrosoftDotNetBuildTasksFeedPackageVersion>6.0.0-beta.21212.6</MicrosoftDotNetBuildTasksFeedPackageVersion>
<MicrosoftNETCoreAppRefPackageVersion>8.0.0-rc.1.23376.5</MicrosoftNETCoreAppRefPackageVersion>
<MicrosoftNETWorkloadEmscriptenCurrentManifest80100TransportVersion>8.0.0-rc.1.23368.3</MicrosoftNETWorkloadEmscriptenCurrentManifest80100TransportVersion>
<MicrosoftNETCoreAppRefPackageVersion>8.0.0-rc.2.23418.14</MicrosoftNETCoreAppRefPackageVersion>
<MicrosoftNETWorkloadEmscriptenCurrentManifest80100TransportVersion>8.0.0-rc.1.23415.5</MicrosoftNETWorkloadEmscriptenCurrentManifest80100TransportVersion>
<MicrosoftNETRuntimeMonoTargetsSdkPackageVersion>7.0.7</MicrosoftNETRuntimeMonoTargetsSdkPackageVersion>
<MicrosoftTemplateEngineTasksVersion>7.0.100-alpha.1.21601.1</MicrosoftTemplateEngineTasksVersion>
<MicrosoftDotNetCecilPackageVersion>0.11.4-alpha.23360.2</MicrosoftDotNetCecilPackageVersion>
<MicrosoftDotNetCecilPackageVersion>0.11.4-alpha.23407.2</MicrosoftDotNetCecilPackageVersion>
<MicrosoftDotNetXHarnessiOSSharedPackageVersion>8.0.0-prerelease.23407.2</MicrosoftDotNetXHarnessiOSSharedPackageVersion>
<!-- Manually updated versions -->
<Emscriptennet7WorkloadVersion>$(MicrosoftNETWorkloadEmscriptenCurrentManifest80100TransportVersion)</Emscriptennet7WorkloadVersion>
<EmscriptenWorkloadVersion>$(MicrosoftNETWorkloadEmscriptenCurrentManifest80100TransportVersion)</EmscriptenWorkloadVersion>
<!-- This is a subscription of the .NET 7 versions of our packages -->
<MicrosoftMacCatalystSdkPackageVersion>16.4.7097</MicrosoftMacCatalystSdkPackageVersion>
<MicrosoftmacOSSdkPackageVersion>13.3.7097</MicrosoftmacOSSdkPackageVersion>
<MicrosoftiOSSdkPackageVersion>16.4.7097</MicrosoftiOSSdkPackageVersion>
<MicrosofttvOSSdkPackageVersion>16.4.7097</MicrosofttvOSSdkPackageVersion>
<MicrosoftMacCatalystSdkPackageVersion>16.4.7098</MicrosoftMacCatalystSdkPackageVersion>
<MicrosoftmacOSSdkPackageVersion>13.3.7098</MicrosoftmacOSSdkPackageVersion>
<MicrosoftiOSSdkPackageVersion>16.4.7098</MicrosoftiOSSdkPackageVersion>
<MicrosofttvOSSdkPackageVersion>16.4.7098</MicrosofttvOSSdkPackageVersion>
</PropertyGroup>
</Project>

Просмотреть файл

@ -1,5 +1,5 @@
{
"sdk": {
"version": "8.0.100-rc.1.23378.5"
"version": "8.0.100-rc.2.23422.3"
}
}

Просмотреть файл

@ -97,7 +97,7 @@ namespace Xamarin.MacDev.Tasks {
}
// 'sortedItems' is sorted by length of path, longest first.
bool NeedsCodesign (ITaskItem [] sortedItems, int index)
bool NeedsCodesign (ITaskItem [] sortedItems, int index, string stampFileContents)
{
var item = sortedItems [index];
var stampFile = GetCodesignStampFile (item);
@ -140,6 +140,11 @@ namespace Xamarin.MacDev.Tasks {
}
}
if (File.ReadAllText (stampFile) != stampFileContents) {
Log.LogMessage (MessageImportance.Low, "The expected content in the stamp file '{0}' for the item '{1}' is not up-to-date, so the item must be codesigned.", stampFile, item.ItemSpec);
return true;
}
Log.LogMessage (MessageImportance.Low, "The stamp file '{0}' for the item '{1}' is up-to-date, so the item does not need to be codesigned.", stampFile, item.ItemSpec);
return false;
}
@ -258,10 +263,11 @@ namespace Xamarin.MacDev.Tasks {
return args;
}
void Codesign (ITaskItem item)
void Codesign (SignInfo info)
{
var item = info.Item;
var fileName = GetFullPathToTool ();
var arguments = GenerateCommandLineArguments (item);
var arguments = info.GetCommandLineArguments (this);
var environment = new Dictionary<string, string> () {
{ "CODESIGN_ALLOCATE", GetCodesignAllocate (item) },
};
@ -283,14 +289,15 @@ namespace Xamarin.MacDev.Tasks {
if (string.IsNullOrEmpty (stampFile)) {
Log.LogMessage (MessageImportance.Low, "No stamp file '{0}' available for the item '{1}'", stampFile, item.ItemSpec);
} else if (IsUpToDate (item.ItemSpec, stampFile)) {
Log.LogMessage (MessageImportance.Low, "The stamp file '{0}' is already up-to-date for the item '{1}'", stampFile, item.ItemSpec);
Log.LogMessage (MessageImportance.Low, "The stamp file '{0}' is already up-to-date for the item '{1}', updating it anyway", stampFile, item.ItemSpec);
File.WriteAllText (stampFile, info.GetStampFileContents (this));
} else if (File.Exists (stampFile)) {
Log.LogMessage (MessageImportance.Low, "The stamp file '{0}' is not up-to-date for the item '{1}', and it will be touched", stampFile, item.ItemSpec);
File.SetLastWriteTimeUtc (stampFile, DateTime.UtcNow);
Log.LogMessage (MessageImportance.Low, "The stamp file '{0}' is not up-to-date for the item '{1}', and it will be updated", stampFile, item.ItemSpec);
File.WriteAllText (stampFile, info.GetStampFileContents (this));
} else {
Log.LogMessage (MessageImportance.Low, "The stamp file '{0}' is not up-to-date for the item '{1}', and it will be created", stampFile, item.ItemSpec);
Log.LogMessage (MessageImportance.Low, "The stamp file '{0}' does not exit for the item '{1}', and it will be created", stampFile, item.ItemSpec);
Directory.CreateDirectory (Path.GetDirectoryName (stampFile));
File.WriteAllText (stampFile, string.Empty);
File.WriteAllText (stampFile, info.GetStampFileContents (this));
}
var additionalFilesToTouch = item.GetMetadata ("CodesignAdditionalFilesToTouch").Split (new char [] { ';' }, StringSplitOptions.RemoveEmptyEntries);
@ -379,13 +386,13 @@ namespace Xamarin.MacDev.Tasks {
resourcesToSign = resourcesToSign.OrderBy (v => v.ItemSpec.Length).Reverse ().ToArray ();
// remove items that are up-to-date
var itemsToSign = new List<SignInfo> ();
for (var i = 0; i < resourcesToSign.Length; i++) {
var item = resourcesToSign [i];
if (!NeedsCodesign (resourcesToSign, i)) {
resourcesToSign [i] = null;
}
var info = new SignInfo { Item = item };
if (NeedsCodesign (resourcesToSign, i, info.GetStampFileContents (this)))
itemsToSign.Add (info);
}
resourcesToSign = resourcesToSign.Where (v => v is not null).ToArray ();
// Then we need to split the input into buckets, where everything in a bucket can be signed in parallel
// (i.e. no item in a bucket depends on any other item in the bucket being signed first).
@ -393,15 +400,16 @@ namespace Xamarin.MacDev.Tasks {
// we have to sign the first bucket first, and so on.
// Since we've sorted by path length, we know that if we find a directory, we won't find any containing
// files from that directory later.
var buckets = new List<List<ITaskItem>> ();
for (var i = 0; i < resourcesToSign.Length; i++) {
var res = resourcesToSign [i];
var buckets = new List<List<SignInfo>> ();
for (var i = 0; i < itemsToSign.Count; i++) {
var info = itemsToSign [i];
var res = info.Item;
// All files can go into the first bucket.
if (File.Exists (res.ItemSpec)) {
if (buckets.Count == 0)
buckets.Add (new List<ITaskItem> ());
buckets.Add (new List<SignInfo> ());
var bucket = buckets [0];
bucket.Add (res);
bucket.Add (info);
continue;
}
@ -417,11 +425,11 @@ namespace Xamarin.MacDev.Tasks {
var added = false;
for (var b = buckets.Count - 1; b >= 0; b--) {
var bucket = buckets [b];
var anyContainingFile = bucket.Any (v => v.ItemSpec.StartsWith (dir, StringComparison.OrdinalIgnoreCase));
var anyContainingFile = bucket.Any (v => v.Item.ItemSpec.StartsWith (dir, StringComparison.OrdinalIgnoreCase));
if (anyContainingFile) {
if (b + 1 >= buckets.Count)
buckets.Add (new List<ITaskItem> ());
buckets [b + 1].Add (res);
buckets.Add (new List<SignInfo> ());
buckets [b + 1].Add (info);
added = true;
break;
}
@ -429,9 +437,9 @@ namespace Xamarin.MacDev.Tasks {
if (!added) {
// This directory doesn't contain any other signed files, so we can add it to the first bucket.
if (buckets.Count == 0)
buckets.Add (new List<ITaskItem> ());
buckets.Add (new List<SignInfo> ());
var bucket = buckets [0];
bucket.Add (res);
bucket.Add (info);
}
continue;
}
@ -445,7 +453,7 @@ namespace Xamarin.MacDev.Tasks {
var bucket = buckets [b];
Log.LogWarning ($" Bucket #{b + 1} contains {bucket.Count} items:");
foreach (var item in bucket) {
Log.LogWarning ($" {item.ItemSpec}");
Log.LogWarning ($" {item.Item.ItemSpec}");
}
}
#endif
@ -455,7 +463,7 @@ namespace Xamarin.MacDev.Tasks {
Parallel.ForEach (bucket, new ParallelOptions { MaxDegreeOfParallelism = Math.Max (Environment.ProcessorCount / 2, 1) }, (item) => {
Codesign (item);
var files = GetCodesignedFiles (item);
var files = GetCodesignedFiles (item.Item);
lock (codesignedFiles)
codesignedFiles.AddRange (files);
});
@ -529,5 +537,22 @@ namespace Xamarin.MacDev.Tasks {
return codesignedFiles;
}
class SignInfo {
public ITaskItem Item;
IList<string> arguments;
public IList<string> GetCommandLineArguments (CodesignTaskBase task)
{
if (arguments is null)
arguments = task.GenerateCommandLineArguments (Item);
return arguments;
}
public string GetStampFileContents (CodesignTaskBase task)
{
return string.Join (" ", GetCommandLineArguments (task));
}
}
}
}

Просмотреть файл

@ -75,7 +75,7 @@ namespace Xamarin.MacDev.Tasks {
bundle.CopyMetadataTo (item);
// Compute the stamp file to use
item.SetMetadataIfNotSet ("CodesignStampFile", Path.Combine (bundlePath, CodeSignatureRelativePath, "_CodeSignature", "CodeResources"));
item.SetMetadataIfNotSet ("CodesignStampFile", Path.Combine (CodesignStampPath, Path.GetFileName (bundle.ItemSpec), ".stampfile"));
// Get any additional stamp files we must touch when the item is signed.
var additionalStampFiles = new List<string> ();

Просмотреть файл

@ -34,7 +34,10 @@ namespace Xamarin.MacDev.Tasks {
{
var result = new List<ITaskItem> ();
foreach (var file in File) {
var document = XDocument.Load (file.ItemSpec);
// XDocument.Load(string) takes a string to a URI, not a file path, so with certain characters that becomes a problem.
// Just File.OpenRead instead and use the XDocument.Load(Stream) overload instead.
using var stream = global::System.IO.File.OpenRead (file.ItemSpec);
var document = XDocument.Load (stream);
var items = document.Root
.Elements (ItemGroupElementName)

Просмотреть файл

@ -69,6 +69,16 @@ namespace Foundation {
}
#endif
#if NET
// This interface will be made public when the managed static registrar is used.
internal interface INSObjectFactory {
// The method will be implemented via custom linker step if the managed static registrar is used
// for NSObject subclasses which have an (NativeHandle) or (IntPtr) constructor.
[MethodImpl(MethodImplOptions.NoInlining)]
virtual static NSObject _Xamarin_ConstructNSObject (NativeHandle handle) => null;
}
#endif
#if NET && !COREBUILD
[ObjectiveCTrackedType]
[SupportedOSPlatform ("ios")]
@ -81,6 +91,9 @@ namespace Foundation {
#if !COREBUILD
, IEquatable<NSObject>
, IDisposable
#endif
#if NET
, INSObjectFactory
#endif
{
#if !COREBUILD

Просмотреть файл

@ -6,7 +6,6 @@
//
// Copyright 2023 Microsoft Corp
#if NET
#nullable enable
@ -34,6 +33,10 @@ namespace ObjCRuntime {
// This method will be called once per assembly, and the implementation has to
// add all the interface -> wrapper type mappings to the dictionary.
void RegisterWrapperTypes (Dictionary<RuntimeTypeHandle, RuntimeTypeHandle> type);
// Create an instance of a managed NSObject subclass for an existing Objective-C object.
INativeObject? ConstructNSObject (RuntimeTypeHandle typeHandle, NativeHandle nativeHandle);
// Create an instance of a managed NSObject subclass for an existing Objective-C object.
INativeObject? ConstructINativeObject (RuntimeTypeHandle typeHandle, NativeHandle nativeHandle, bool owns);
}
}

Просмотреть файл

@ -1,6 +1,7 @@
#nullable enable
using System;
using System.Runtime.CompilerServices;
using Foundation;
#if !NET
@ -15,6 +16,14 @@ namespace ObjCRuntime {
get;
}
#endif
#if NET
// The method will be implemented via custom linker step if the managed static registrar is used
// for classes which have an (NativeHandle, bool) or (IntPtr, bool) constructor.
// This method will be made public when the managed static registrar is used.
[MethodImpl(MethodImplOptions.NoInlining)]
internal static virtual INativeObject? _Xamarin_ConstructINativeObject (NativeHandle handle, bool owns) => null;
#endif
}
#if !COREBUILD

Просмотреть файл

@ -194,6 +194,12 @@ namespace ObjCRuntime {
return entry.Registrar.LookupUnmanagedFunction (symbol, id);
}
[MethodImpl(MethodImplOptions.NoInlining)]
static bool RuntimeTypeHandleEquals (ref RuntimeTypeHandle typeHandle, RuntimeTypeHandle otherTypeHandle)
{
return typeHandle.Equals (otherTypeHandle);
}
internal static Type LookupRegisteredType (Assembly assembly, uint id)
{
var entry = GetMapEntry (assembly);
@ -208,6 +214,22 @@ namespace ObjCRuntime {
return entry.Registrar.LookupTypeId (type.TypeHandle);
}
internal static T? ConstructNSObject<T> (Type type, NativeHandle nativeHandle)
where T : class, INativeObject
{
if (!TryGetMapEntry (type.Assembly.GetName ().Name!, out var entry))
return null;
return (T?) entry.Registrar.ConstructNSObject (type.TypeHandle, nativeHandle);
}
internal static T? ConstructINativeObject<T> (Type type, NativeHandle nativeHandle, bool owns)
where T : class, INativeObject
{
if (!TryGetMapEntry (type.Assembly.GetName ().Name!, out var entry))
return null;
return (T?) entry.Registrar.ConstructINativeObject (type.TypeHandle, nativeHandle, owns);
}
// helper functions for converting between native and managed objects
static NativeHandle ManagedArrayToNSArray (object array, bool retain)
{

Просмотреть файл

@ -1283,38 +1283,65 @@ namespace ObjCRuntime {
}
msg.Append (").");
if (sel != IntPtr.Zero || method_handle.Value != IntPtr.Zero) {
msg.AppendLine ();
msg.AppendLine ("Additional information:");
if (sel != IntPtr.Zero)
msg.Append ("\tSelector: ").Append (Selector.GetName (sel)).AppendLine ();
if (method_handle.Value != IntPtr.Zero) {
try {
var method = MethodBase.GetMethodFromHandle (method_handle);
msg.Append ($"\tMethod: ");
if (method is not null) {
// there's no good built-in function to format a MethodInfo :/
msg.Append (method.DeclaringType?.FullName ?? string.Empty);
msg.Append (".");
msg.Append (method.Name);
msg.Append ("(");
var parameters = method.GetParameters ();
for (var i = 0; i < parameters.Length; i++) {
if (i > 0)
msg.Append (", ");
msg.Append (parameters [i].ParameterType.FullName);
}
msg.Append (")");
} else {
msg.Append ($"Unable to resolve RuntimeMethodHandle 0x{method_handle.Value.ToString ("x")}");
AppendAdditionalInformation (msg, sel, method_handle);
}
throw ErrorHelper.CreateError (8027, msg.ToString ());
}
#if NET
static void CannotCreateManagedInstanceOfGenericType (IntPtr ptr, IntPtr klass, Type type, MissingCtorResolution resolution, IntPtr sel, RuntimeMethodHandle method_handle)
{
if (resolution == MissingCtorResolution.Ignore)
return;
if (klass == IntPtr.Zero)
klass = Class.GetClassForObject (ptr);
var msg = new StringBuilder ();
msg.AppendFormat (Xamarin.Bundler.Errors.MX8056 /* Failed to marshal the Objective-C object 0x{0} (type: {1}). Could not find an existing managed instance for this object, nor was it possible to create a new managed instance of generic type {2}. */, ptr.ToString ("x"), new Class (klass).Name, type.FullName);
if (sel != IntPtr.Zero || method_handle.Value != IntPtr.Zero) {
AppendAdditionalInformation (msg, sel, method_handle);
}
throw ErrorHelper.CreateError (8056, msg.ToString ());
}
#endif
static void AppendAdditionalInformation (StringBuilder msg, IntPtr sel, RuntimeMethodHandle method_handle)
{
msg.AppendLine ();
msg.AppendLine ("Additional information:");
if (sel != IntPtr.Zero)
msg.Append ("\tSelector: ").Append (Selector.GetName (sel)).AppendLine ();
if (method_handle.Value != IntPtr.Zero) {
try {
var method = MethodBase.GetMethodFromHandle (method_handle);
msg.Append ($"\tMethod: ");
if (method is not null) {
// there's no good built-in function to format a MethodInfo :/
msg.Append (method.DeclaringType?.FullName ?? string.Empty);
msg.Append (".");
msg.Append (method.Name);
msg.Append ("(");
var parameters = method.GetParameters ();
for (var i = 0; i < parameters.Length; i++) {
if (i > 0)
msg.Append (", ");
msg.Append (parameters [i].ParameterType.FullName);
}
msg.AppendLine ();
} catch (Exception ex) {
msg.Append ($"\tMethod: Unable to resolve RuntimeMethodHandle 0x{method_handle.Value.ToString ("x")}: {ex.Message}");
msg.Append (")");
} else {
msg.Append ($"Unable to resolve RuntimeMethodHandle 0x{method_handle.Value.ToString ("x")}");
}
msg.AppendLine ();
} catch (Exception ex) {
msg.Append ($"\tMethod: Unable to resolve RuntimeMethodHandle 0x{method_handle.Value.ToString ("x")}: {ex.Message}");
}
}
throw ErrorHelper.CreateError (8027, msg.ToString ());
}
static NSObject? ConstructNSObject (IntPtr ptr, IntPtr klass, MissingCtorResolution missingCtorResolution)
@ -1333,19 +1360,61 @@ namespace ObjCRuntime {
return ConstructNSObject<T> (ptr, typeof (T), MissingCtorResolution.ThrowConstructor1NotFound);
}
// The generic argument T is only used to cast the return value.
// The 'selector' and 'method' arguments are only used in error messages.
static T? ConstructNSObject<T> (IntPtr ptr, Type type, MissingCtorResolution missingCtorResolution) where T : class, INativeObject
static T? ConstructNSObject<T> (IntPtr ptr, Type type, MissingCtorResolution missingCtorResolution) where T : NSObject
{
return ConstructNSObject<T> (ptr, type, missingCtorResolution, IntPtr.Zero, default (RuntimeMethodHandle));
}
// The generic argument T is only used to cast the return value.
// The 'selector' and 'method' arguments are only used in error messages.
#if NET
static T? ConstructNSObject<T> (IntPtr ptr, Type type, MissingCtorResolution missingCtorResolution, IntPtr sel, RuntimeMethodHandle method_handle) where T : NSObject, INSObjectFactory
#else
static T? ConstructNSObject<T> (IntPtr ptr, Type type, MissingCtorResolution missingCtorResolution, IntPtr sel, RuntimeMethodHandle method_handle) where T : class, INativeObject
#endif
{
if (type is null)
throw new ArgumentNullException (nameof (type));
#if NET
if (Runtime.IsManagedStaticRegistrar) {
T? instance = default;
var nativeHandle = new NativeHandle (ptr);
// We want to create an instance of `type` and if we have the chance to use the factory method
// on the generic type, we will prefer it to using the lookup table.
if (typeof (T) == type
&& typeof (T) != typeof (NSObject)
&& !(typeof (T).IsInterface || typeof (T).IsAbstract)) {
instance = ConstructNSObjectViaFactoryMethod (nativeHandle);
}
// Generic types can only be instantiated through the factory method and if that failed, we can't
// fall back to the lookup tables and we need to stop here.
if (type.IsGenericType && instance is null) {
CannotCreateManagedInstanceOfGenericType (ptr, IntPtr.Zero, type, missingCtorResolution, sel, method_handle);
return null;
}
// If we couldn't create an instance of T through the factory method, we'll use the lookup table
// based on the RuntimeTypeHandle.
//
// This isn't possible for generic types - we don't know the type arguments at compile time
// (otherwise we would be able to create an instance of T through the factory method).
// For non-generic types, we can call the NativeHandle constructor based on the RuntimeTypeHandle.
if (instance is null) {
instance = RegistrarHelper.ConstructNSObject<T> (type, nativeHandle);
}
if (instance is null) {
// If we couldn't create an instance using the lookup table either, it means `type` doesn't contain
// a suitable constructor.
MissingCtor (ptr, IntPtr.Zero, type, missingCtorResolution, sel, method_handle);
}
return instance;
}
#endif
var ctor = GetIntPtrConstructor (type);
@ -1366,6 +1435,17 @@ namespace ObjCRuntime {
#endif
return (T) ctor.Invoke (ctorArguments);
#if NET
// It isn't possible to call T._Xamarin_ConstructNSObject (...) directly from the parent function. For some
// types, the app crashes with a SIGSEGV:
//
// error: * Assertion at /Users/runner/work/1/s/src/mono/mono/mini/mini-generic-sharing.c:2283, condition `m_class_get_vtable (info->klass)' not met
//
// When the same call is made from a separate function, it works fine.
static T? ConstructNSObjectViaFactoryMethod (NativeHandle handle)
=> T._Xamarin_ConstructNSObject (handle) as T;
#endif
}
// The generic argument T is only used to cast the return value.
@ -1377,6 +1457,56 @@ namespace ObjCRuntime {
if (type.IsByRef)
type = type.GetElementType ()!;
#if NET
if (Runtime.IsManagedStaticRegistrar) {
var nativeHandle = new NativeHandle (ptr);
T? instance = null;
// We want to create an instance of `type` and if we have the chance to use the factory method
// on the generic type, we will prefer it to using the lookup table.
if (typeof (T) == type
&& typeof (T) != typeof (INativeObject)
&& typeof (T) != typeof (NSObject)
&& !(typeof (T).IsInterface || typeof (T).IsAbstract)) {
instance = ConstructINativeObjectViaFactoryMethod (nativeHandle, owns);
}
// Generic types can only be instantiated through the factory method and if that failed, we can't
// fall back to the lookup tables and we need to stop here.
if (type.IsGenericType && instance is null) {
CannotCreateManagedInstanceOfGenericType (ptr, IntPtr.Zero, type, missingCtorResolution, sel, method_handle);
return null;
}
// If we couldn't create an instance of T through the factory method, we'll use the lookup table
// based on the RuntimeTypeHandle.
//
// This isn't possible for generic types - we don't know the type arguments at compile time
// (otherwise we would be able to create an instance of T through the factory method).
// For non-generic types, we can call the NativeHandle constructor based on the RuntimeTypeHandle.
// If type is an NSObject, we prefer the NSObject lookup table
if (instance is null && type != typeof (NSObject) && type.IsSubclassOf (typeof (NSObject))) {
instance = (T?)(INativeObject?) RegistrarHelper.ConstructNSObject<T> (type, nativeHandle);
if (instance is not null && owns) {
Runtime.TryReleaseINativeObject (instance);
}
}
if (instance is null && type != typeof (INativeObject)) {
instance = RegistrarHelper.ConstructINativeObject<T> (type, nativeHandle, owns);
}
if (instance is null) {
// If we couldn't create an instance using the lookup table either, it means `type` doesn't contain
// a suitable constructor.
MissingCtor (ptr, IntPtr.Zero, type, missingCtorResolution, sel, method_handle);
}
return instance;
}
#endif
var ctor = GetIntPtr_BoolConstructor (type);
if (ctor is null) {
@ -1397,6 +1527,17 @@ namespace ObjCRuntime {
ctorArguments [1] = owns;
return (T?) ctor.Invoke (ctorArguments);
#if NET
// It isn't possible to call T._Xamarin_ConstructINativeObject (...) directly from the parent function. For some
// types, the app crashes with a SIGSEGV:
//
// error: * Assertion at /Users/runner/work/1/s/src/mono/mono/mini/mini-generic-sharing.c:2283, condition `m_class_get_vtable (info->klass)' not met
//
// When the same call is made from a separate function, it works fine.
static T? ConstructINativeObjectViaFactoryMethod (NativeHandle nativeHandle, bool owns)
=> T._Xamarin_ConstructINativeObject (nativeHandle, owns) as T;
#endif
}
static IntPtr CreateNSObject (IntPtr type_gchandle, IntPtr handle, NSObject.Flags flags)
@ -1776,7 +1917,7 @@ namespace ObjCRuntime {
// native objects and NSObject instances.
throw ErrorHelper.CreateError (8004, $"Cannot create an instance of {implementation.FullName} for the native object 0x{ptr:x} (of type '{Class.class_getName (Class.GetClassForObject (ptr))}'), because another instance already exists for this native object (of type {o.GetType ().FullName}).");
}
return ConstructNSObject<INativeObject> (ptr, implementation, MissingCtorResolution.ThrowConstructor1NotFound, sel, method_handle);
return ConstructNSObject<NSObject> (ptr, implementation!, MissingCtorResolution.ThrowConstructor1NotFound, sel, method_handle);
}
return ConstructINativeObject<INativeObject> (ptr, owns, implementation, MissingCtorResolution.ThrowConstructor2NotFound, sel, method_handle);
@ -1833,10 +1974,22 @@ namespace ObjCRuntime {
// native objects and NSObject instances.
throw ErrorHelper.CreateError (8004, $"Cannot create an instance of {implementation.FullName} for the native object 0x{ptr:x} (of type '{Class.class_getName (Class.GetClassForObject (ptr))}'), because another instance already exists for this native object (of type {o.GetType ().FullName}).");
}
var rv = (T?) ConstructNSObject<T> (ptr, implementation, MissingCtorResolution.ThrowConstructor1NotFound);
#if NET
if (!Runtime.IsManagedStaticRegistrar) {
// For other registrars other than managed-static the generic parameter of ConstructNSObject is used
// only to cast the return value so we can safely pass NSObject here to satisfy the constraints of the
// generic parameter.
var rv = (T?)(INativeObject?) ConstructNSObject<NSObject> (ptr, implementation, MissingCtorResolution.ThrowConstructor1NotFound, sel, method_handle);
if (owns)
TryReleaseINativeObject (rv);
return rv;
}
#else
var rv = ConstructNSObject<T> (ptr, implementation, MissingCtorResolution.ThrowConstructor1NotFound, sel, method_handle);
if (owns)
TryReleaseINativeObject (rv);
return rv;
#endif
}
return ConstructINativeObject<T> (ptr, owns, implementation, MissingCtorResolution.ThrowConstructor2NotFound, sel, method_handle);

Просмотреть файл

@ -0,0 +1,858 @@
using System.Collections.Generic;
partial class Frameworks {
// GENERATED FILE - DO NOT EDIT
internal readonly HashSet<string> iosframeworks = new HashSet<string> {
"Accelerate",
"Accessibility",
"Accounts",
"AddressBook",
"AddressBookUI",
"AdServices",
"AdSupport",
"AppClip",
"AppTrackingTransparency",
"ARKit",
"AssetsLibrary",
"AudioToolbox",
"AudioUnit",
"AuthenticationServices",
"AutomaticAssessmentConfiguration",
"AVFoundation",
"AVKit",
"AVRouting",
"BackgroundAssets",
"BackgroundTasks",
"BusinessChat",
"CallKit",
"CarPlay",
"CFNetwork",
"Chip",
"ClassKit",
"CloudKit",
"Compression",
"Contacts",
"ContactsUI",
"CoreAnimation",
"CoreAudioKit",
"CoreBluetooth",
"CoreData",
"CoreFoundation",
"CoreGraphics",
"CoreHaptics",
"CoreImage",
"CoreLocation",
"CoreLocationUI",
"CoreMedia",
"CoreMIDI",
"CoreML",
"CoreMotion",
"CoreNFC",
"CoreSpotlight",
"CoreTelephony",
"CoreText",
"CoreVideo",
"DeviceCheck",
"EventKit",
"EventKitUI",
"ExternalAccessory",
"FileProvider",
"FileProviderUI",
"Foundation",
"GameController",
"GameKit",
"GameplayKit",
"GLKit",
"HealthKit",
"HealthKitUI",
"HomeKit",
"iAd",
"IdentityLookup",
"IdentityLookupUI",
"ImageIO",
"Intents",
"IntentsUI",
"IOSurface",
"JavaScriptCore",
"LinkPresentation",
"LocalAuthentication",
"MapKit",
"MediaAccessibility",
"MediaPlayer",
"MediaSetup",
"MediaToolbox",
"Messages",
"MessageUI",
"Metal",
"MetalKit",
"MetalPerformanceShaders",
"MetalPerformanceShadersGraph",
"MetricKit",
"MLCompute",
"MobileCoreServices",
"ModelIO",
"MultipeerConnectivity",
"NaturalLanguage",
"NearbyInteraction",
"Network",
"NetworkExtension",
"NewsstandKit",
"NotificationCenter",
"OpenGLES",
"OSLog",
"PassKit",
"PdfKit",
"PencilKit",
"Phase",
"Photos",
"PhotosUI",
"PushKit",
"PushToTalk",
"QuickLook",
"QuickLookThumbnailing",
"ReplayKit",
"SafariServices",
"SceneKit",
"ScreenTime",
"Security",
"SensorKit",
"SharedWithYou",
"SharedWithYouCore",
"ShazamKit",
"Social",
"SoundAnalysis",
"Speech",
"SpriteKit",
"StoreKit",
"SystemConfiguration",
"ThreadNetwork",
"Twitter",
"UIKit",
"UniformTypeIdentifiers",
"UserNotifications",
"UserNotificationsUI",
"VideoSubscriberAccount",
"VideoToolbox",
"Vision",
"VisionKit",
"WatchConnectivity",
"WatchKit",
"WebKit",
"XKit",
};
// GENERATED FILE - DO NOT EDIT
internal readonly HashSet<string> macosframeworks = new HashSet<string> {
"Accelerate",
"Accessibility",
"Accounts",
"AdServices",
"AdSupport",
"AppKit",
"AppTrackingTransparency",
"AudioToolbox",
"AudioUnit",
"AuthenticationServices",
"AutomaticAssessmentConfiguration",
"AVFoundation",
"AVKit",
"AVRouting",
"BackgroundAssets",
"BusinessChat",
"CallKit",
"CFNetwork",
"Chip",
"ClassKit",
"CloudKit",
"Compression",
"Contacts",
"ContactsUI",
"CoreAnimation",
"CoreAudioKit",
"CoreBluetooth",
"CoreData",
"CoreFoundation",
"CoreGraphics",
"CoreImage",
"CoreLocation",
"CoreMedia",
"CoreMidi",
"CoreML",
"CoreMotion",
"CoreServices",
"CoreSpotlight",
"CoreText",
"CoreVideo",
"CoreWlan",
"DeviceCheck",
"EventKit",
"ExecutionPolicy",
"ExtensionKit",
"ExternalAccessory",
"FileProvider",
"FileProviderUI",
"FinderSync",
"Foundation",
"GameController",
"GameKit",
"GameplayKit",
"GLKit",
"HealthKit",
"ImageCaptureCore",
"ImageIO",
"ImageKit",
"Intents",
"IntentsUI",
"IOSurface",
"iTunesLibrary",
"JavaScriptCore",
"LinkPresentation",
"LocalAuthentication",
"LocalAuthenticationEmbeddedUI",
"MailKit",
"MapKit",
"MediaAccessibility",
"MediaLibrary",
"MediaPlayer",
"MediaToolbox",
"Metal",
"MetalKit",
"MetalPerformanceShaders",
"MetalPerformanceShadersGraph",
"MetricKit",
"MLCompute",
"MobileCoreServices",
"ModelIO",
"MultipeerConnectivity",
"NaturalLanguage",
"NearbyInteraction",
"Network",
"NetworkExtension",
"NotificationCenter",
"OpenGL",
"OSLog",
"PassKit",
"PdfKit",
"PencilKit",
"Phase",
"Photos",
"PhotosUI",
"PrintCore",
"PushKit",
"QTKit",
"QuartzComposer",
"QuickLook",
"QuickLookThumbnailing",
"QuickLookUI",
"ReplayKit",
"SafariServices",
"SceneKit",
"ScreenCaptureKit",
"ScreenTime",
"ScriptingBridge",
"SearchKit",
"Security",
"ServiceManagement",
"SharedWithYou",
"SharedWithYouCore",
"ShazamKit",
"Social",
"SoundAnalysis",
"Speech",
"SpriteKit",
"StoreKit",
"SystemConfiguration",
"ThreadNetwork",
"UniformTypeIdentifiers",
"UserNotifications",
"UserNotificationsUI",
"VideoSubscriberAccount",
"VideoToolbox",
"Vision",
"WebKit",
"XKit",
};
// GENERATED FILE - DO NOT EDIT
internal readonly HashSet<string> watchosframeworks = new HashSet<string> {
"Accelerate",
"Accessibility",
"AuthenticationServices",
"AVFoundation",
"CallKit",
"Chip",
"ClockKit",
"CloudKit",
"Compression",
"Contacts",
"CoreBluetooth",
"CoreData",
"CoreFoundation",
"CoreGraphics",
"CoreLocation",
"CoreMedia",
"CoreML",
"CoreMotion",
"CoreText",
"CoreVideo",
"DeviceCheck",
"EventKit",
"Foundation",
"GameKit",
"HealthKit",
"HomeKit",
"ImageIO",
"Intents",
"LocalAuthentication",
"MapKit",
"MediaPlayer",
"MobileCoreServices",
"NaturalLanguage",
"NearbyInteraction",
"Network",
"OSLog",
"PassKit",
"PushKit",
"SceneKit",
"Security",
"ShazamKit",
"SoundAnalysis",
"SpriteKit",
"StoreKit",
"UIKit",
"UniformTypeIdentifiers",
"UserNotifications",
"WatchConnectivity",
"WatchKit",
"XKit",
};
// GENERATED FILE - DO NOT EDIT
internal readonly HashSet<string> tvosframeworks = new HashSet<string> {
"Accelerate",
"Accessibility",
"AdSupport",
"AppTrackingTransparency",
"AudioToolbox",
"AudioUnit",
"AuthenticationServices",
"AVFoundation",
"AVKit",
"BackgroundTasks",
"CFNetwork",
"Chip",
"CloudKit",
"Compression",
"CoreAnimation",
"CoreBluetooth",
"CoreData",
"CoreFoundation",
"CoreGraphics",
"CoreHaptics",
"CoreImage",
"CoreLocation",
"CoreMedia",
"CoreML",
"CoreSpotlight",
"CoreText",
"CoreVideo",
"DeviceCheck",
"ExternalAccessory",
"Foundation",
"GameController",
"GameKit",
"GameplayKit",
"GLKit",
"HomeKit",
"ImageIO",
"Intents",
"IOSurface",
"JavaScriptCore",
"LinkPresentation",
"MapKit",
"MediaAccessibility",
"MediaPlayer",
"MediaToolbox",
"Metal",
"MetalKit",
"MetalPerformanceShaders",
"MetalPerformanceShadersGraph",
"MLCompute",
"MobileCoreServices",
"ModelIO",
"MultipeerConnectivity",
"NaturalLanguage",
"Network",
"OpenGLES",
"OSLog",
"Photos",
"PhotosUI",
"ReplayKit",
"SceneKit",
"Security",
"SharedWithYou",
"SharedWithYouCore",
"ShazamKit",
"SoundAnalysis",
"SpriteKit",
"StoreKit",
"SystemConfiguration",
"TVMLKit",
"TVServices",
"TVUIKit",
"UIKit",
"UniformTypeIdentifiers",
"UserNotifications",
"VideoSubscriberAccount",
"VideoToolbox",
"Vision",
"XKit",
};
// GENERATED FILE - DO NOT EDIT
internal readonly HashSet<string> maccatalystframeworks = new HashSet<string> {
"Accelerate",
"Accessibility",
"Accounts",
"AddressBook",
"AdServices",
"AdSupport",
"AppClip",
"AppKit",
"AppTrackingTransparency",
"AudioToolbox",
"AudioUnit",
"AuthenticationServices",
"AutomaticAssessmentConfiguration",
"AVFoundation",
"AVKit",
"AVRouting",
"BackgroundAssets",
"BackgroundTasks",
"BusinessChat",
"CallKit",
"CFNetwork",
"ClassKit",
"CloudKit",
"Compression",
"Contacts",
"ContactsUI",
"CoreAnimation",
"CoreAudioKit",
"CoreBluetooth",
"CoreData",
"CoreFoundation",
"CoreGraphics",
"CoreHaptics",
"CoreImage",
"CoreLocation",
"CoreLocationUI",
"CoreMedia",
"CoreMIDI",
"CoreML",
"CoreMotion",
"CoreNFC",
"CoreSpotlight",
"CoreTelephony",
"CoreText",
"CoreVideo",
"CoreWlan",
"DeviceCheck",
"EventKit",
"EventKitUI",
"ExecutionPolicy",
"ExternalAccessory",
"FileProvider",
"Foundation",
"GameController",
"GameKit",
"GameplayKit",
"HealthKit",
"HealthKitUI",
"HomeKit",
"IdentityLookup",
"IdentityLookupUI",
"ImageIO",
"Intents",
"IntentsUI",
"IOSurface",
"JavaScriptCore",
"LinkPresentation",
"LocalAuthentication",
"MapKit",
"MediaAccessibility",
"MediaPlayer",
"MediaToolbox",
"Messages",
"MessageUI",
"Metal",
"MetalKit",
"MetalPerformanceShaders",
"MetalPerformanceShadersGraph",
"MetricKit",
"MLCompute",
"MobileCoreServices",
"ModelIO",
"MultipeerConnectivity",
"NaturalLanguage",
"NearbyInteraction",
"Network",
"NetworkExtension",
"OSLog",
"PassKit",
"PdfKit",
"PencilKit",
"Phase",
"Photos",
"PhotosUI",
"PushKit",
"QuickLook",
"QuickLookThumbnailing",
"ReplayKit",
"SafariServices",
"SceneKit",
"ScreenTime",
"Security",
"SensorKit",
"ServiceManagement",
"SharedWithYou",
"SharedWithYouCore",
"ShazamKit",
"Social",
"SoundAnalysis",
"Speech",
"SpriteKit",
"StoreKit",
"SystemConfiguration",
"ThreadNetwork",
"UIKit",
"UniformTypeIdentifiers",
"UserNotifications",
"UserNotificationsUI",
"VideoToolbox",
"Vision",
"VisionKit",
"WebKit",
"XKit",
};
bool? _Accelerate;
bool? _Accessibility;
bool? _Accounts;
bool? _AddressBook;
bool? _AddressBookUI;
bool? _AdServices;
bool? _AdSupport;
bool? _AppClip;
bool? _AppKit;
bool? _AppTrackingTransparency;
bool? _ARKit;
bool? _AssetsLibrary;
bool? _AudioToolbox;
bool? _AudioUnit;
bool? _AuthenticationServices;
bool? _AutomaticAssessmentConfiguration;
bool? _AVFoundation;
bool? _AVKit;
bool? _AVRouting;
bool? _BackgroundAssets;
bool? _BackgroundTasks;
bool? _BusinessChat;
bool? _CallKit;
bool? _CarPlay;
bool? _CFNetwork;
bool? _Chip;
bool? _ClassKit;
bool? _ClockKit;
bool? _CloudKit;
bool? _Compression;
bool? _Contacts;
bool? _ContactsUI;
bool? _CoreAnimation;
bool? _CoreAudioKit;
bool? _CoreBluetooth;
bool? _CoreData;
bool? _CoreFoundation;
bool? _CoreGraphics;
bool? _CoreHaptics;
bool? _CoreImage;
bool? _CoreLocation;
bool? _CoreLocationUI;
bool? _CoreMedia;
bool? _CoreMidi;
bool? _CoreMIDI;
bool? _CoreML;
bool? _CoreMotion;
bool? _CoreNFC;
bool? _CoreServices;
bool? _CoreSpotlight;
bool? _CoreTelephony;
bool? _CoreText;
bool? _CoreVideo;
bool? _CoreWlan;
bool? _DeviceCheck;
bool? _EventKit;
bool? _EventKitUI;
bool? _ExecutionPolicy;
bool? _ExtensionKit;
bool? _ExternalAccessory;
bool? _FileProvider;
bool? _FileProviderUI;
bool? _FinderSync;
bool? _Foundation;
bool? _GameController;
bool? _GameKit;
bool? _GameplayKit;
bool? _GLKit;
bool? _HealthKit;
bool? _HealthKitUI;
bool? _HomeKit;
bool? _iAd;
bool? _IdentityLookup;
bool? _IdentityLookupUI;
bool? _ImageCaptureCore;
bool? _ImageIO;
bool? _ImageKit;
bool? _Intents;
bool? _IntentsUI;
bool? _IOSurface;
bool? _iTunesLibrary;
bool? _JavaScriptCore;
bool? _LinkPresentation;
bool? _LocalAuthentication;
bool? _LocalAuthenticationEmbeddedUI;
bool? _MailKit;
bool? _MapKit;
bool? _MediaAccessibility;
bool? _MediaLibrary;
bool? _MediaPlayer;
bool? _MediaSetup;
bool? _MediaToolbox;
bool? _Messages;
bool? _MessageUI;
bool? _Metal;
bool? _MetalKit;
bool? _MetalPerformanceShaders;
bool? _MetalPerformanceShadersGraph;
bool? _MetricKit;
bool? _MLCompute;
bool? _MobileCoreServices;
bool? _ModelIO;
bool? _MultipeerConnectivity;
bool? _NaturalLanguage;
bool? _NearbyInteraction;
bool? _Network;
bool? _NetworkExtension;
bool? _NewsstandKit;
bool? _NotificationCenter;
bool? _OpenGL;
bool? _OpenGLES;
bool? _OSLog;
bool? _PassKit;
bool? _PdfKit;
bool? _PencilKit;
bool? _Phase;
bool? _Photos;
bool? _PhotosUI;
bool? _PrintCore;
bool? _PushKit;
bool? _PushToTalk;
bool? _QTKit;
bool? _QuartzComposer;
bool? _QuickLook;
bool? _QuickLookThumbnailing;
bool? _QuickLookUI;
bool? _ReplayKit;
bool? _SafariServices;
bool? _SceneKit;
bool? _ScreenCaptureKit;
bool? _ScreenTime;
bool? _ScriptingBridge;
bool? _SearchKit;
bool? _Security;
bool? _SensorKit;
bool? _ServiceManagement;
bool? _SharedWithYou;
bool? _SharedWithYouCore;
bool? _ShazamKit;
bool? _Social;
bool? _SoundAnalysis;
bool? _Speech;
bool? _SpriteKit;
bool? _StoreKit;
bool? _SystemConfiguration;
bool? _ThreadNetwork;
bool? _TVMLKit;
bool? _TVServices;
bool? _TVUIKit;
bool? _Twitter;
bool? _UIKit;
bool? _UniformTypeIdentifiers;
bool? _UserNotifications;
bool? _UserNotificationsUI;
bool? _VideoSubscriberAccount;
bool? _VideoToolbox;
bool? _Vision;
bool? _VisionKit;
bool? _WatchConnectivity;
bool? _WatchKit;
bool? _WebKit;
bool? _XKit;
public bool HaveAccelerate { get { if (!_Accelerate.HasValue) _Accelerate = GetValue ("Accelerate"); return _Accelerate.Value; } }
public bool HaveAccessibility { get { if (!_Accessibility.HasValue) _Accessibility = GetValue ("Accessibility"); return _Accessibility.Value; } }
public bool HaveAccounts { get { if (!_Accounts.HasValue) _Accounts = GetValue ("Accounts"); return _Accounts.Value; } }
public bool HaveAddressBook { get { if (!_AddressBook.HasValue) _AddressBook = GetValue ("AddressBook"); return _AddressBook.Value; } }
public bool HaveAddressBookUI { get { if (!_AddressBookUI.HasValue) _AddressBookUI = GetValue ("AddressBookUI"); return _AddressBookUI.Value; } }
public bool HaveAdServices { get { if (!_AdServices.HasValue) _AdServices = GetValue ("AdServices"); return _AdServices.Value; } }
public bool HaveAdSupport { get { if (!_AdSupport.HasValue) _AdSupport = GetValue ("AdSupport"); return _AdSupport.Value; } }
public bool HaveAppClip { get { if (!_AppClip.HasValue) _AppClip = GetValue ("AppClip"); return _AppClip.Value; } }
public bool HaveAppKit { get { if (!_AppKit.HasValue) _AppKit = GetValue ("AppKit"); return _AppKit.Value; } }
public bool HaveAppTrackingTransparency { get { if (!_AppTrackingTransparency.HasValue) _AppTrackingTransparency = GetValue ("AppTrackingTransparency"); return _AppTrackingTransparency.Value; } }
public bool HaveARKit { get { if (!_ARKit.HasValue) _ARKit = GetValue ("ARKit"); return _ARKit.Value; } }
public bool HaveAssetsLibrary { get { if (!_AssetsLibrary.HasValue) _AssetsLibrary = GetValue ("AssetsLibrary"); return _AssetsLibrary.Value; } }
public bool HaveAudioToolbox { get { if (!_AudioToolbox.HasValue) _AudioToolbox = GetValue ("AudioToolbox"); return _AudioToolbox.Value; } }
public bool HaveAudioUnit { get { if (!_AudioUnit.HasValue) _AudioUnit = GetValue ("AudioUnit"); return _AudioUnit.Value; } }
public bool HaveAuthenticationServices { get { if (!_AuthenticationServices.HasValue) _AuthenticationServices = GetValue ("AuthenticationServices"); return _AuthenticationServices.Value; } }
public bool HaveAutomaticAssessmentConfiguration { get { if (!_AutomaticAssessmentConfiguration.HasValue) _AutomaticAssessmentConfiguration = GetValue ("AutomaticAssessmentConfiguration"); return _AutomaticAssessmentConfiguration.Value; } }
public bool HaveAVFoundation { get { if (!_AVFoundation.HasValue) _AVFoundation = GetValue ("AVFoundation"); return _AVFoundation.Value; } }
public bool HaveAVKit { get { if (!_AVKit.HasValue) _AVKit = GetValue ("AVKit"); return _AVKit.Value; } }
public bool HaveAVRouting { get { if (!_AVRouting.HasValue) _AVRouting = GetValue ("AVRouting"); return _AVRouting.Value; } }
public bool HaveBackgroundAssets { get { if (!_BackgroundAssets.HasValue) _BackgroundAssets = GetValue ("BackgroundAssets"); return _BackgroundAssets.Value; } }
public bool HaveBackgroundTasks { get { if (!_BackgroundTasks.HasValue) _BackgroundTasks = GetValue ("BackgroundTasks"); return _BackgroundTasks.Value; } }
public bool HaveBusinessChat { get { if (!_BusinessChat.HasValue) _BusinessChat = GetValue ("BusinessChat"); return _BusinessChat.Value; } }
public bool HaveCallKit { get { if (!_CallKit.HasValue) _CallKit = GetValue ("CallKit"); return _CallKit.Value; } }
public bool HaveCarPlay { get { if (!_CarPlay.HasValue) _CarPlay = GetValue ("CarPlay"); return _CarPlay.Value; } }
public bool HaveCFNetwork { get { if (!_CFNetwork.HasValue) _CFNetwork = GetValue ("CFNetwork"); return _CFNetwork.Value; } }
public bool HaveChip { get { if (!_Chip.HasValue) _Chip = GetValue ("Chip"); return _Chip.Value; } }
public bool HaveClassKit { get { if (!_ClassKit.HasValue) _ClassKit = GetValue ("ClassKit"); return _ClassKit.Value; } }
public bool HaveClockKit { get { if (!_ClockKit.HasValue) _ClockKit = GetValue ("ClockKit"); return _ClockKit.Value; } }
public bool HaveCloudKit { get { if (!_CloudKit.HasValue) _CloudKit = GetValue ("CloudKit"); return _CloudKit.Value; } }
public bool HaveCompression { get { if (!_Compression.HasValue) _Compression = GetValue ("Compression"); return _Compression.Value; } }
public bool HaveContacts { get { if (!_Contacts.HasValue) _Contacts = GetValue ("Contacts"); return _Contacts.Value; } }
public bool HaveContactsUI { get { if (!_ContactsUI.HasValue) _ContactsUI = GetValue ("ContactsUI"); return _ContactsUI.Value; } }
public bool HaveCoreAnimation { get { if (!_CoreAnimation.HasValue) _CoreAnimation = GetValue ("CoreAnimation"); return _CoreAnimation.Value; } }
public bool HaveCoreAudioKit { get { if (!_CoreAudioKit.HasValue) _CoreAudioKit = GetValue ("CoreAudioKit"); return _CoreAudioKit.Value; } }
public bool HaveCoreBluetooth { get { if (!_CoreBluetooth.HasValue) _CoreBluetooth = GetValue ("CoreBluetooth"); return _CoreBluetooth.Value; } }
public bool HaveCoreData { get { if (!_CoreData.HasValue) _CoreData = GetValue ("CoreData"); return _CoreData.Value; } }
public bool HaveCoreFoundation { get { if (!_CoreFoundation.HasValue) _CoreFoundation = GetValue ("CoreFoundation"); return _CoreFoundation.Value; } }
public bool HaveCoreGraphics { get { if (!_CoreGraphics.HasValue) _CoreGraphics = GetValue ("CoreGraphics"); return _CoreGraphics.Value; } }
public bool HaveCoreHaptics { get { if (!_CoreHaptics.HasValue) _CoreHaptics = GetValue ("CoreHaptics"); return _CoreHaptics.Value; } }
public bool HaveCoreImage { get { if (!_CoreImage.HasValue) _CoreImage = GetValue ("CoreImage"); return _CoreImage.Value; } }
public bool HaveCoreLocation { get { if (!_CoreLocation.HasValue) _CoreLocation = GetValue ("CoreLocation"); return _CoreLocation.Value; } }
public bool HaveCoreLocationUI { get { if (!_CoreLocationUI.HasValue) _CoreLocationUI = GetValue ("CoreLocationUI"); return _CoreLocationUI.Value; } }
public bool HaveCoreMedia { get { if (!_CoreMedia.HasValue) _CoreMedia = GetValue ("CoreMedia"); return _CoreMedia.Value; } }
public bool HaveCoreMidi { get { if (!_CoreMidi.HasValue) _CoreMidi = GetValue ("CoreMidi"); return _CoreMidi.Value; } }
public bool HaveCoreMIDI { get { if (!_CoreMIDI.HasValue) _CoreMIDI = GetValue ("CoreMIDI"); return _CoreMIDI.Value; } }
public bool HaveCoreML { get { if (!_CoreML.HasValue) _CoreML = GetValue ("CoreML"); return _CoreML.Value; } }
public bool HaveCoreMotion { get { if (!_CoreMotion.HasValue) _CoreMotion = GetValue ("CoreMotion"); return _CoreMotion.Value; } }
public bool HaveCoreNFC { get { if (!_CoreNFC.HasValue) _CoreNFC = GetValue ("CoreNFC"); return _CoreNFC.Value; } }
public bool HaveCoreServices { get { if (!_CoreServices.HasValue) _CoreServices = GetValue ("CoreServices"); return _CoreServices.Value; } }
public bool HaveCoreSpotlight { get { if (!_CoreSpotlight.HasValue) _CoreSpotlight = GetValue ("CoreSpotlight"); return _CoreSpotlight.Value; } }
public bool HaveCoreTelephony { get { if (!_CoreTelephony.HasValue) _CoreTelephony = GetValue ("CoreTelephony"); return _CoreTelephony.Value; } }
public bool HaveCoreText { get { if (!_CoreText.HasValue) _CoreText = GetValue ("CoreText"); return _CoreText.Value; } }
public bool HaveCoreVideo { get { if (!_CoreVideo.HasValue) _CoreVideo = GetValue ("CoreVideo"); return _CoreVideo.Value; } }
public bool HaveCoreWlan { get { if (!_CoreWlan.HasValue) _CoreWlan = GetValue ("CoreWlan"); return _CoreWlan.Value; } }
public bool HaveDeviceCheck { get { if (!_DeviceCheck.HasValue) _DeviceCheck = GetValue ("DeviceCheck"); return _DeviceCheck.Value; } }
public bool HaveEventKit { get { if (!_EventKit.HasValue) _EventKit = GetValue ("EventKit"); return _EventKit.Value; } }
public bool HaveEventKitUI { get { if (!_EventKitUI.HasValue) _EventKitUI = GetValue ("EventKitUI"); return _EventKitUI.Value; } }
public bool HaveExecutionPolicy { get { if (!_ExecutionPolicy.HasValue) _ExecutionPolicy = GetValue ("ExecutionPolicy"); return _ExecutionPolicy.Value; } }
public bool HaveExtensionKit { get { if (!_ExtensionKit.HasValue) _ExtensionKit = GetValue ("ExtensionKit"); return _ExtensionKit.Value; } }
public bool HaveExternalAccessory { get { if (!_ExternalAccessory.HasValue) _ExternalAccessory = GetValue ("ExternalAccessory"); return _ExternalAccessory.Value; } }
public bool HaveFileProvider { get { if (!_FileProvider.HasValue) _FileProvider = GetValue ("FileProvider"); return _FileProvider.Value; } }
public bool HaveFileProviderUI { get { if (!_FileProviderUI.HasValue) _FileProviderUI = GetValue ("FileProviderUI"); return _FileProviderUI.Value; } }
public bool HaveFinderSync { get { if (!_FinderSync.HasValue) _FinderSync = GetValue ("FinderSync"); return _FinderSync.Value; } }
public bool HaveFoundation { get { if (!_Foundation.HasValue) _Foundation = GetValue ("Foundation"); return _Foundation.Value; } }
public bool HaveGameController { get { if (!_GameController.HasValue) _GameController = GetValue ("GameController"); return _GameController.Value; } }
public bool HaveGameKit { get { if (!_GameKit.HasValue) _GameKit = GetValue ("GameKit"); return _GameKit.Value; } }
public bool HaveGameplayKit { get { if (!_GameplayKit.HasValue) _GameplayKit = GetValue ("GameplayKit"); return _GameplayKit.Value; } }
public bool HaveGLKit { get { if (!_GLKit.HasValue) _GLKit = GetValue ("GLKit"); return _GLKit.Value; } }
public bool HaveHealthKit { get { if (!_HealthKit.HasValue) _HealthKit = GetValue ("HealthKit"); return _HealthKit.Value; } }
public bool HaveHealthKitUI { get { if (!_HealthKitUI.HasValue) _HealthKitUI = GetValue ("HealthKitUI"); return _HealthKitUI.Value; } }
public bool HaveHomeKit { get { if (!_HomeKit.HasValue) _HomeKit = GetValue ("HomeKit"); return _HomeKit.Value; } }
public bool HaveiAd { get { if (!_iAd.HasValue) _iAd = GetValue ("iAd"); return _iAd.Value; } }
public bool HaveIdentityLookup { get { if (!_IdentityLookup.HasValue) _IdentityLookup = GetValue ("IdentityLookup"); return _IdentityLookup.Value; } }
public bool HaveIdentityLookupUI { get { if (!_IdentityLookupUI.HasValue) _IdentityLookupUI = GetValue ("IdentityLookupUI"); return _IdentityLookupUI.Value; } }
public bool HaveImageCaptureCore { get { if (!_ImageCaptureCore.HasValue) _ImageCaptureCore = GetValue ("ImageCaptureCore"); return _ImageCaptureCore.Value; } }
public bool HaveImageIO { get { if (!_ImageIO.HasValue) _ImageIO = GetValue ("ImageIO"); return _ImageIO.Value; } }
public bool HaveImageKit { get { if (!_ImageKit.HasValue) _ImageKit = GetValue ("ImageKit"); return _ImageKit.Value; } }
public bool HaveIntents { get { if (!_Intents.HasValue) _Intents = GetValue ("Intents"); return _Intents.Value; } }
public bool HaveIntentsUI { get { if (!_IntentsUI.HasValue) _IntentsUI = GetValue ("IntentsUI"); return _IntentsUI.Value; } }
public bool HaveIOSurface { get { if (!_IOSurface.HasValue) _IOSurface = GetValue ("IOSurface"); return _IOSurface.Value; } }
public bool HaveiTunesLibrary { get { if (!_iTunesLibrary.HasValue) _iTunesLibrary = GetValue ("iTunesLibrary"); return _iTunesLibrary.Value; } }
public bool HaveJavaScriptCore { get { if (!_JavaScriptCore.HasValue) _JavaScriptCore = GetValue ("JavaScriptCore"); return _JavaScriptCore.Value; } }
public bool HaveLinkPresentation { get { if (!_LinkPresentation.HasValue) _LinkPresentation = GetValue ("LinkPresentation"); return _LinkPresentation.Value; } }
public bool HaveLocalAuthentication { get { if (!_LocalAuthentication.HasValue) _LocalAuthentication = GetValue ("LocalAuthentication"); return _LocalAuthentication.Value; } }
public bool HaveLocalAuthenticationEmbeddedUI { get { if (!_LocalAuthenticationEmbeddedUI.HasValue) _LocalAuthenticationEmbeddedUI = GetValue ("LocalAuthenticationEmbeddedUI"); return _LocalAuthenticationEmbeddedUI.Value; } }
public bool HaveMailKit { get { if (!_MailKit.HasValue) _MailKit = GetValue ("MailKit"); return _MailKit.Value; } }
public bool HaveMapKit { get { if (!_MapKit.HasValue) _MapKit = GetValue ("MapKit"); return _MapKit.Value; } }
public bool HaveMediaAccessibility { get { if (!_MediaAccessibility.HasValue) _MediaAccessibility = GetValue ("MediaAccessibility"); return _MediaAccessibility.Value; } }
public bool HaveMediaLibrary { get { if (!_MediaLibrary.HasValue) _MediaLibrary = GetValue ("MediaLibrary"); return _MediaLibrary.Value; } }
public bool HaveMediaPlayer { get { if (!_MediaPlayer.HasValue) _MediaPlayer = GetValue ("MediaPlayer"); return _MediaPlayer.Value; } }
public bool HaveMediaSetup { get { if (!_MediaSetup.HasValue) _MediaSetup = GetValue ("MediaSetup"); return _MediaSetup.Value; } }
public bool HaveMediaToolbox { get { if (!_MediaToolbox.HasValue) _MediaToolbox = GetValue ("MediaToolbox"); return _MediaToolbox.Value; } }
public bool HaveMessages { get { if (!_Messages.HasValue) _Messages = GetValue ("Messages"); return _Messages.Value; } }
public bool HaveMessageUI { get { if (!_MessageUI.HasValue) _MessageUI = GetValue ("MessageUI"); return _MessageUI.Value; } }
public bool HaveMetal { get { if (!_Metal.HasValue) _Metal = GetValue ("Metal"); return _Metal.Value; } }
public bool HaveMetalKit { get { if (!_MetalKit.HasValue) _MetalKit = GetValue ("MetalKit"); return _MetalKit.Value; } }
public bool HaveMetalPerformanceShaders { get { if (!_MetalPerformanceShaders.HasValue) _MetalPerformanceShaders = GetValue ("MetalPerformanceShaders"); return _MetalPerformanceShaders.Value; } }
public bool HaveMetalPerformanceShadersGraph { get { if (!_MetalPerformanceShadersGraph.HasValue) _MetalPerformanceShadersGraph = GetValue ("MetalPerformanceShadersGraph"); return _MetalPerformanceShadersGraph.Value; } }
public bool HaveMetricKit { get { if (!_MetricKit.HasValue) _MetricKit = GetValue ("MetricKit"); return _MetricKit.Value; } }
public bool HaveMLCompute { get { if (!_MLCompute.HasValue) _MLCompute = GetValue ("MLCompute"); return _MLCompute.Value; } }
public bool HaveMobileCoreServices { get { if (!_MobileCoreServices.HasValue) _MobileCoreServices = GetValue ("MobileCoreServices"); return _MobileCoreServices.Value; } }
public bool HaveModelIO { get { if (!_ModelIO.HasValue) _ModelIO = GetValue ("ModelIO"); return _ModelIO.Value; } }
public bool HaveMultipeerConnectivity { get { if (!_MultipeerConnectivity.HasValue) _MultipeerConnectivity = GetValue ("MultipeerConnectivity"); return _MultipeerConnectivity.Value; } }
public bool HaveNaturalLanguage { get { if (!_NaturalLanguage.HasValue) _NaturalLanguage = GetValue ("NaturalLanguage"); return _NaturalLanguage.Value; } }
public bool HaveNearbyInteraction { get { if (!_NearbyInteraction.HasValue) _NearbyInteraction = GetValue ("NearbyInteraction"); return _NearbyInteraction.Value; } }
public bool HaveNetwork { get { if (!_Network.HasValue) _Network = GetValue ("Network"); return _Network.Value; } }
public bool HaveNetworkExtension { get { if (!_NetworkExtension.HasValue) _NetworkExtension = GetValue ("NetworkExtension"); return _NetworkExtension.Value; } }
public bool HaveNewsstandKit { get { if (!_NewsstandKit.HasValue) _NewsstandKit = GetValue ("NewsstandKit"); return _NewsstandKit.Value; } }
public bool HaveNotificationCenter { get { if (!_NotificationCenter.HasValue) _NotificationCenter = GetValue ("NotificationCenter"); return _NotificationCenter.Value; } }
public bool HaveOpenGL { get { if (!_OpenGL.HasValue) _OpenGL = GetValue ("OpenGL"); return _OpenGL.Value; } }
public bool HaveOpenGLES { get { if (!_OpenGLES.HasValue) _OpenGLES = GetValue ("OpenGLES"); return _OpenGLES.Value; } }
public bool HaveOSLog { get { if (!_OSLog.HasValue) _OSLog = GetValue ("OSLog"); return _OSLog.Value; } }
public bool HavePassKit { get { if (!_PassKit.HasValue) _PassKit = GetValue ("PassKit"); return _PassKit.Value; } }
public bool HavePdfKit { get { if (!_PdfKit.HasValue) _PdfKit = GetValue ("PdfKit"); return _PdfKit.Value; } }
public bool HavePencilKit { get { if (!_PencilKit.HasValue) _PencilKit = GetValue ("PencilKit"); return _PencilKit.Value; } }
public bool HavePhase { get { if (!_Phase.HasValue) _Phase = GetValue ("Phase"); return _Phase.Value; } }
public bool HavePhotos { get { if (!_Photos.HasValue) _Photos = GetValue ("Photos"); return _Photos.Value; } }
public bool HavePhotosUI { get { if (!_PhotosUI.HasValue) _PhotosUI = GetValue ("PhotosUI"); return _PhotosUI.Value; } }
public bool HavePrintCore { get { if (!_PrintCore.HasValue) _PrintCore = GetValue ("PrintCore"); return _PrintCore.Value; } }
public bool HavePushKit { get { if (!_PushKit.HasValue) _PushKit = GetValue ("PushKit"); return _PushKit.Value; } }
public bool HavePushToTalk { get { if (!_PushToTalk.HasValue) _PushToTalk = GetValue ("PushToTalk"); return _PushToTalk.Value; } }
public bool HaveQTKit { get { if (!_QTKit.HasValue) _QTKit = GetValue ("QTKit"); return _QTKit.Value; } }
public bool HaveQuartzComposer { get { if (!_QuartzComposer.HasValue) _QuartzComposer = GetValue ("QuartzComposer"); return _QuartzComposer.Value; } }
public bool HaveQuickLook { get { if (!_QuickLook.HasValue) _QuickLook = GetValue ("QuickLook"); return _QuickLook.Value; } }
public bool HaveQuickLookThumbnailing { get { if (!_QuickLookThumbnailing.HasValue) _QuickLookThumbnailing = GetValue ("QuickLookThumbnailing"); return _QuickLookThumbnailing.Value; } }
public bool HaveQuickLookUI { get { if (!_QuickLookUI.HasValue) _QuickLookUI = GetValue ("QuickLookUI"); return _QuickLookUI.Value; } }
public bool HaveReplayKit { get { if (!_ReplayKit.HasValue) _ReplayKit = GetValue ("ReplayKit"); return _ReplayKit.Value; } }
public bool HaveSafariServices { get { if (!_SafariServices.HasValue) _SafariServices = GetValue ("SafariServices"); return _SafariServices.Value; } }
public bool HaveSceneKit { get { if (!_SceneKit.HasValue) _SceneKit = GetValue ("SceneKit"); return _SceneKit.Value; } }
public bool HaveScreenCaptureKit { get { if (!_ScreenCaptureKit.HasValue) _ScreenCaptureKit = GetValue ("ScreenCaptureKit"); return _ScreenCaptureKit.Value; } }
public bool HaveScreenTime { get { if (!_ScreenTime.HasValue) _ScreenTime = GetValue ("ScreenTime"); return _ScreenTime.Value; } }
public bool HaveScriptingBridge { get { if (!_ScriptingBridge.HasValue) _ScriptingBridge = GetValue ("ScriptingBridge"); return _ScriptingBridge.Value; } }
public bool HaveSearchKit { get { if (!_SearchKit.HasValue) _SearchKit = GetValue ("SearchKit"); return _SearchKit.Value; } }
public bool HaveSecurity { get { if (!_Security.HasValue) _Security = GetValue ("Security"); return _Security.Value; } }
public bool HaveSensorKit { get { if (!_SensorKit.HasValue) _SensorKit = GetValue ("SensorKit"); return _SensorKit.Value; } }
public bool HaveServiceManagement { get { if (!_ServiceManagement.HasValue) _ServiceManagement = GetValue ("ServiceManagement"); return _ServiceManagement.Value; } }
public bool HaveSharedWithYou { get { if (!_SharedWithYou.HasValue) _SharedWithYou = GetValue ("SharedWithYou"); return _SharedWithYou.Value; } }
public bool HaveSharedWithYouCore { get { if (!_SharedWithYouCore.HasValue) _SharedWithYouCore = GetValue ("SharedWithYouCore"); return _SharedWithYouCore.Value; } }
public bool HaveShazamKit { get { if (!_ShazamKit.HasValue) _ShazamKit = GetValue ("ShazamKit"); return _ShazamKit.Value; } }
public bool HaveSocial { get { if (!_Social.HasValue) _Social = GetValue ("Social"); return _Social.Value; } }
public bool HaveSoundAnalysis { get { if (!_SoundAnalysis.HasValue) _SoundAnalysis = GetValue ("SoundAnalysis"); return _SoundAnalysis.Value; } }
public bool HaveSpeech { get { if (!_Speech.HasValue) _Speech = GetValue ("Speech"); return _Speech.Value; } }
public bool HaveSpriteKit { get { if (!_SpriteKit.HasValue) _SpriteKit = GetValue ("SpriteKit"); return _SpriteKit.Value; } }
public bool HaveStoreKit { get { if (!_StoreKit.HasValue) _StoreKit = GetValue ("StoreKit"); return _StoreKit.Value; } }
public bool HaveSystemConfiguration { get { if (!_SystemConfiguration.HasValue) _SystemConfiguration = GetValue ("SystemConfiguration"); return _SystemConfiguration.Value; } }
public bool HaveThreadNetwork { get { if (!_ThreadNetwork.HasValue) _ThreadNetwork = GetValue ("ThreadNetwork"); return _ThreadNetwork.Value; } }
public bool HaveTVMLKit { get { if (!_TVMLKit.HasValue) _TVMLKit = GetValue ("TVMLKit"); return _TVMLKit.Value; } }
public bool HaveTVServices { get { if (!_TVServices.HasValue) _TVServices = GetValue ("TVServices"); return _TVServices.Value; } }
public bool HaveTVUIKit { get { if (!_TVUIKit.HasValue) _TVUIKit = GetValue ("TVUIKit"); return _TVUIKit.Value; } }
public bool HaveTwitter { get { if (!_Twitter.HasValue) _Twitter = GetValue ("Twitter"); return _Twitter.Value; } }
public bool HaveUIKit { get { if (!_UIKit.HasValue) _UIKit = GetValue ("UIKit"); return _UIKit.Value; } }
public bool HaveUniformTypeIdentifiers { get { if (!_UniformTypeIdentifiers.HasValue) _UniformTypeIdentifiers = GetValue ("UniformTypeIdentifiers"); return _UniformTypeIdentifiers.Value; } }
public bool HaveUserNotifications { get { if (!_UserNotifications.HasValue) _UserNotifications = GetValue ("UserNotifications"); return _UserNotifications.Value; } }
public bool HaveUserNotificationsUI { get { if (!_UserNotificationsUI.HasValue) _UserNotificationsUI = GetValue ("UserNotificationsUI"); return _UserNotificationsUI.Value; } }
public bool HaveVideoSubscriberAccount { get { if (!_VideoSubscriberAccount.HasValue) _VideoSubscriberAccount = GetValue ("VideoSubscriberAccount"); return _VideoSubscriberAccount.Value; } }
public bool HaveVideoToolbox { get { if (!_VideoToolbox.HasValue) _VideoToolbox = GetValue ("VideoToolbox"); return _VideoToolbox.Value; } }
public bool HaveVision { get { if (!_Vision.HasValue) _Vision = GetValue ("Vision"); return _Vision.Value; } }
public bool HaveVisionKit { get { if (!_VisionKit.HasValue) _VisionKit = GetValue ("VisionKit"); return _VisionKit.Value; } }
public bool HaveWatchConnectivity { get { if (!_WatchConnectivity.HasValue) _WatchConnectivity = GetValue ("WatchConnectivity"); return _WatchConnectivity.Value; } }
public bool HaveWatchKit { get { if (!_WatchKit.HasValue) _WatchKit = GetValue ("WatchKit"); return _WatchKit.Value; } }
public bool HaveWebKit { get { if (!_WebKit.HasValue) _WebKit = GetValue ("WebKit"); return _WebKit.Value; } }
public bool HaveXKit { get { if (!_XKit.HasValue) _XKit = GetValue ("XKit"); return _XKit.Value; } }
}

Просмотреть файл

@ -52,9 +52,12 @@ try {
for (int i = 0; i < names.Length; i++) {
var name = names [i];
var frameworks = allframeworks [i];
sb.Append ($"\tinternal readonly HashSet<string> {name} = new HashSet<string> {{\"");
sb.Append (string.Join ("\", \"", frameworks));
sb.AppendLine ("\"};");
sb.AppendLine ($"\t// GENERATED FILE - DO NOT EDIT");
sb.AppendLine ($"\tinternal readonly HashSet<string> {name} = new HashSet<string> {{");
foreach (var fw in frameworks.OrderBy (v => v)) {
sb.AppendLine ($"\t\t\"{fw}\",");
}
sb.AppendLine ("\t};");
}
var allArray = all.ToArray ();

Просмотреть файл

@ -225,11 +225,15 @@ namespace Xamarin.Tests {
public static string EvaluateVariable (string variable)
{
var result = Environment.GetEnvironmentVariable (variable);
if (!string.IsNullOrEmpty (result))
return result;
var output = new StringBuilder ();
var rv = ExecutionHelper.Execute ("/usr/bin/make", new string [] { "-C", Path.Combine (SourceRoot, "tools", "devops"), "print-abspath-variable", $"VARIABLE={variable}" }, environmentVariables: null, stdout: output, stderr: output, timeout: TimeSpan.FromSeconds (5));
if (rv != 0)
throw new Exception ($"Failed to evaluate variable '{variable}'. Exit code: {rv}. Output:\n{output}");
var result = output.ToString ().Split (new char [] { '\n' }, StringSplitOptions.RemoveEmptyEntries).Where (v => v.StartsWith (variable + "=", StringComparison.Ordinal)).SingleOrDefault ();
result = output.ToString ().Split (new char [] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries).Where (v => v.StartsWith (variable + "=", StringComparison.Ordinal)).SingleOrDefault ();
if (result is null)
throw new Exception ($"Could not find the variable '{variable}' to evaluate.");
return result.Substring (variable.Length + 1);

Просмотреть файл

@ -28,14 +28,14 @@ namespace Xamarin.Tests {
}
}
public static ExecutionResult AssertPack (string project, Dictionary<string, string>? properties = null)
public static ExecutionResult AssertPack (string project, Dictionary<string, string>? properties = null, bool? msbuildParallelism = null)
{
return Execute ("pack", project, properties, true);
return Execute ("pack", project, properties, true, msbuildParallelism: msbuildParallelism);
}
public static ExecutionResult AssertPackFailure (string project, Dictionary<string, string>? properties = null)
public static ExecutionResult AssertPackFailure (string project, Dictionary<string, string>? properties = null, bool? msbuildParallelism = null)
{
var rv = Execute ("pack", project, properties, false);
var rv = Execute ("pack", project, properties, false, msbuildParallelism: msbuildParallelism);
Assert.AreNotEqual (0, rv.ExitCode, "Unexpected success");
return rv;
}
@ -113,7 +113,7 @@ namespace Xamarin.Tests {
return new ExecutionResult (output, output, rv.ExitCode);
}
public static ExecutionResult Execute (string verb, string project, Dictionary<string, string>? properties, bool assert_success = true, string? target = null)
public static ExecutionResult Execute (string verb, string project, Dictionary<string, string>? properties, bool assert_success = true, string? target = null, bool? msbuildParallelism = null)
{
if (!File.Exists (project))
throw new FileNotFoundException ($"The project file '{project}' does not exist.");
@ -181,6 +181,14 @@ namespace Xamarin.Tests {
args.Add ("/p:LangVersion=latest");
// End workaround
if (msbuildParallelism.HasValue) {
if (msbuildParallelism.Value) {
args.Add ("-maxcpucount"); // this means "use as many processes as there are cpus"
} else {
args.Add ("-maxcpucount:1");
}
}
var env = new Dictionary<string, string?> ();
env ["MSBuildSDKsPath"] = null;
env ["MSBUILD_EXE_PATH"] = null;

Просмотреть файл

@ -196,7 +196,7 @@ namespace Xamarin.Tests {
public void ParseMessages ()
{
messages.Clear ();
ParseMessages (messages, output.ToString ().Split ('\n'), MessageToolName);
ParseMessages (messages, output.ToString ().Split ('\n', '\r'), MessageToolName);
}
static bool TrySplitCode (string code, out string prefix, out int number)

Просмотреть файл

@ -10,6 +10,7 @@ namespace Xamarin.Tests {
public void NativeLink (ApplePlatform platform, string runtimeIdentifiers)
{
Configuration.IgnoreIfIgnoredPlatform (platform);
Configuration.AssertRuntimeIdentifiersAvailable (platform, runtimeIdentifiers);
var project_path = GenerateProject (platform, name: nameof (NativeLink), runtimeIdentifiers: runtimeIdentifiers, out var appPath);
var properties = new Dictionary<string, string> (verbosity);

Просмотреть файл

@ -26,7 +26,7 @@ namespace Xamarin.Tests {
properties ["OutputPath"] = outputPath + Path.DirectorySeparatorChar;
properties ["IntermediateOutputPath"] = intermediateOutputPath + Path.DirectorySeparatorChar;
var rv = DotNet.AssertPackFailure (project_path, properties);
var rv = DotNet.AssertPackFailure (project_path, properties, msbuildParallelism: false);
var errors = BinLog.GetBuildLogErrors (rv.BinLogPath).ToArray ();
Assert.AreEqual (1, errors.Length, "Error count");
Assert.AreEqual ($"Creating a NuGet package is not supported for projects that have ObjcBindingNativeLibrary items. Migrate to use NativeReference items instead.", errors [0].Message, "Error message");
@ -57,7 +57,7 @@ namespace Xamarin.Tests {
properties ["IntermediateOutputPath"] = intermediateOutputPath + Path.DirectorySeparatorChar;
properties ["NoBindingEmbedding"] = noBindingEmbedding ? "true" : "false";
DotNet.AssertPack (project_path, properties);
DotNet.AssertPack (project_path, properties, msbuildParallelism: false);
var nupkg = Path.Combine (outputPath, project + ".1.0.0.nupkg");
Assert.That (nupkg, Does.Exist, "nupkg existence");
@ -121,7 +121,7 @@ namespace Xamarin.Tests {
properties ["IntermediateOutputPath"] = intermediateOutputPath + Path.DirectorySeparatorChar;
properties ["NoBindingEmbedding"] = noBindingEmbedding ? "true" : "false";
DotNet.AssertPack (project_path, properties);
DotNet.AssertPack (project_path, properties, msbuildParallelism: false);
var nupkg = Path.Combine (outputPath, assemblyName + ".1.0.0.nupkg");
Assert.That (nupkg, Does.Exist, "nupkg existence");

Просмотреть файл

@ -116,9 +116,9 @@ namespace Xamarin.Tests {
[TestCase (ApplePlatform.iOS, "ios-arm64;ios-arm")]
[TestCase (ApplePlatform.TVOS, "tvos-arm64")]
[TestCase (ApplePlatform.MacCatalyst, "maccatalyst-arm64")]
[TestCase (ApplePlatform.MacCatalyst, "maccatalyst-arm64;maccatalyst-x64")]
// [TestCase (ApplePlatform.MacCatalyst, "maccatalyst-arm64;maccatalyst-x64")] // Ignored due to https://github.com/dotnet/runtime/issues/90584
[TestCase (ApplePlatform.MacOSX, "osx-x64")]
[TestCase (ApplePlatform.MacOSX, "osx-arm64;osx-x64")]
// [TestCase (ApplePlatform.MacOSX, "osx-arm64;osx-x64")] // Ignored due to https://github.com/dotnet/runtime/issues/90584
public void PublishTest (ApplePlatform platform, string runtimeIdentifiers)
{
var project = "MySimpleApp";

Просмотреть файл

@ -529,10 +529,10 @@ namespace Xamarin.Tests {
}
[Test]
[TestCase (ApplePlatform.iOS, "win10-x86", null)]
[TestCase (ApplePlatform.TVOS, "win10-x64", null)]
[TestCase (ApplePlatform.MacOSX, "win10-arm64", null)]
[TestCase (ApplePlatform.MacCatalyst, "win10-arm64", "Unable to find package Microsoft.NETCore.App.Runtime.Mono.win-arm64. No packages exist with this id in source[(]s[)]:.*")]
[TestCase (ApplePlatform.iOS, "win10-x86", "The specified RuntimeIdentifier 'win10-x86' is not recognized.")]
[TestCase (ApplePlatform.TVOS, "win10-x64", "The specified RuntimeIdentifier 'win10-x64' is not recognized.")]
[TestCase (ApplePlatform.MacOSX, "win10-arm64", "The specified RuntimeIdentifier 'win10-arm64' is not recognized.")]
[TestCase (ApplePlatform.MacCatalyst, "win10-arm64", "The specified RuntimeIdentifier 'win10-arm64' is not recognized.")]
public void InvalidRuntimeIdentifier_Restore (ApplePlatform platform, string runtimeIdentifier, string? failureMessagePattern)
{
var project = "MySimpleApp";
@ -914,6 +914,11 @@ namespace Xamarin.Tests {
[OneTimeSetUp]
public void KillEverything ()
{
if (Environment.OSVersion.Platform == PlatformID.Win32NT) {
Console.WriteLine ($"Skipped killing everything, because there's nothing to kill on Windows.");
return;
}
ExecutionHelper.Execute ("launchctl", new [] { "remove", "com.apple.CoreSimulator.CoreSimulatorService" }, timeout: TimeSpan.FromSeconds (10));
var to_kill = new string [] { "iPhone Simulator", "iOS Simulator", "Simulator", "Simulator (Watch)", "com.apple.CoreSimulator.CoreSimulatorService", "ibtoold" };

Просмотреть файл

@ -11,6 +11,7 @@ namespace Xamarin.Tests {
var configuration = "Debug";
var runtimeIdentifiers = GetDefaultRuntimeIdentifier (platform);
Configuration.IgnoreIfIgnoredPlatform (platform);
Configuration.AssertRuntimeIdentifiersAvailable (platform, runtimeIdentifiers);
var projectPath = GetProjectPath (project, platform: platform);
Clean (projectPath);

Просмотреть файл

@ -283,7 +283,7 @@ namespace GeneratorTests {
foreach (var ca in attributes)
lines.Add (RenderSupportedOSPlatformAttribute (ca));
lines.Sort ();
return string.Join ("\n", lines);
return string.Join ("\n", lines).Replace ("\r", string.Empty);
}
static string RenderSupportedOSPlatformAttribute (CustomAttribute ca)
@ -311,7 +311,7 @@ namespace GeneratorTests {
var preserves = allSupportedAttributes.Count ();
var renderedAttributes = "\t" + string.Join ("\n\t", renderedSupportedAttributes.OrderBy (v => v)) + "\n";
#if NET
const string expectedAttributes =
string expectedAttributes =
@" Bug35176.IFooInterface: [SupportedOSPlatform(""ios14.3"")]
Bug35176.IFooInterface: [SupportedOSPlatform(""maccatalyst14.3"")]
Bug35176.IFooInterface: [SupportedOSPlatform(""macos11.2"")]
@ -332,7 +332,7 @@ namespace GeneratorTests {
UIKit.UIView Bug35176.FooInterface_Extensions::GetBarView(Bug35176.IFooInterface): [SupportedOSPlatform(""macos11.2"")]
";
#else
const string expectedAttributes =
string expectedAttributes =
@" Bug35176.IFooInterface: [Introduced(ObjCRuntime.PlatformName.iOS, 14, 3, ObjCRuntime.PlatformArchitecture.None, null)]
Bug35176.IFooInterface: [Introduced(ObjCRuntime.PlatformName.MacCatalyst, 14, 3, ObjCRuntime.PlatformArchitecture.None, null)]
Bug35176.IFooInterface: [Introduced(ObjCRuntime.PlatformName.MacOSX, 11, 2, ObjCRuntime.PlatformArchitecture.None, null)]
@ -352,6 +352,9 @@ namespace GeneratorTests {
";
#endif
expectedAttributes = expectedAttributes.Replace ("\r", string.Empty);
renderedAttributes = renderedAttributes.Replace ("\r", string.Empty);
if (renderedAttributes != expectedAttributes) {
Console.WriteLine ($"Expected:");
Console.WriteLine (expectedAttributes);
@ -1101,6 +1104,9 @@ namespace GeneratorTests {
someMethod [i] = type.Methods.Single (v => v.Name == "SomeMethod" + (i + 1).ToString ());
renderedSomeMethod [i] = string.Join ("\n", someMethod [i].CustomAttributes.Select (ca => RenderSupportedOSPlatformAttribute (ca)).OrderBy (v => v));
expectedAttributes [i] = expectedAttributes [i].Replace ("\r", string.Empty);
renderedSomeMethod [i] = renderedSomeMethod [i].Replace ("\r", string.Empty);
if (expectedAttributes [i] == renderedSomeMethod [i])
continue;
@ -1180,6 +1186,8 @@ namespace GeneratorTests {
[SupportedOSPlatform(""macos"")]
[UnsupportedOSPlatform(""ios"")]
[UnsupportedOSPlatform(""tvos"")]";
expectedPropertyAttributes = expectedPropertyAttributes.Replace ("\r", string.Empty);
Assert.AreEqual (expectedPropertyAttributes, RenderSupportedOSPlatformAttributes (property), "Property attributes");
Assert.AreEqual (string.Empty, RenderSupportedOSPlatformAttributes (getter), "Getter Attributes");
}
@ -1208,6 +1216,9 @@ namespace GeneratorTests {
[SupportedOSPlatform(""macos11.0"")]
[UnsupportedOSPlatform(""tvos"")]";
expectedPropertyAttributes = expectedPropertyAttributes.Replace ("\r", string.Empty);
expectedSetterAttributes = expectedSetterAttributes.Replace ("\r", string.Empty);
Assert.AreEqual (expectedPropertyAttributes, RenderSupportedOSPlatformAttributes (property), "Property attributes");
Assert.AreEqual (string.Empty, RenderSupportedOSPlatformAttributes (getter), "Getter Attributes");
Assert.AreEqual (expectedSetterAttributes, RenderSupportedOSPlatformAttributes (setter), "Setter Attributes");
@ -1353,7 +1364,8 @@ namespace GeneratorTests {
var member = type.Methods.SingleOrDefault (v => v.Name == expectedMember.Method);
Assert.IsNotNull (member, $"Method not found: {expectedMember.Method} in {type.FullName}");
var renderedAttributes = RenderSupportedOSPlatformAttributes (member);
if (renderedAttributes != expectedMember.Attributes) {
var expectedAttributes = expectedMember.Attributes.Replace ("\r", string.Empty);
if (renderedAttributes != expectedAttributes) {
var msg =
$"Property: {type.FullName}::{member.Name}\n" +
$"\tExpected attributes:\n" +
@ -1376,7 +1388,8 @@ namespace GeneratorTests {
var member = type.Properties.SingleOrDefault (v => v.Name == expectedMember.Property);
Assert.IsNotNull (member, $"Property not found: {expectedMember.Property} in {type.FullName}");
var renderedAttributes = RenderSupportedOSPlatformAttributes (member);
if (renderedAttributes != expectedMember.Attributes) {
var expectedAttributes = expectedMember.Attributes.Replace ("\r", string.Empty);
if (renderedAttributes != expectedAttributes) {
var msg =
$"Property: {type.FullName}::{member.Name}\n" +
$"\tExpected attributes:\n" +

Просмотреть файл

@ -55,10 +55,14 @@ namespace Xamarin.Tests {
public BGenTool ()
{
EnvironmentVariables = new Dictionary<string, string> {
{ "MD_MTOUCH_SDK_ROOT", Configuration.SdkRootXI },
{ "XamarinMacFrameworkRoot", Configuration.SdkRootXM },
};
if (Environment.OSVersion.Platform == PlatformID.Win32NT) {
EnvironmentVariables = new Dictionary<string, string> ();
} else {
EnvironmentVariables = new Dictionary<string, string> {
{ "MD_MTOUCH_SDK_ROOT", Configuration.SdkRootXI },
{ "XamarinMacFrameworkRoot", Configuration.SdkRootXM },
};
}
}
public void AddTestApiDefinition (string filename)

Просмотреть файл

@ -77,7 +77,6 @@ namespace Xamarin.MacDev.Tasks {
};
var p1MetadataNativeLibraries = new Dictionary<string, string> (p1Metadata);
p1MetadataNativeLibraries ["CodesignSigningKey"] = "-";
p1MetadataNativeLibraries ["CodesignStampFile"] = "_CodeSignature/CodeResources";
p1MetadataNativeLibraries.Remove ("CodesignEntitlements");
var p2Metadata = new Dictionary<string, string> {
@ -93,7 +92,6 @@ namespace Xamarin.MacDev.Tasks {
{ "CodesignUseSecureTimestamp", "p2.appex-use-secure-timestamp" },
};
var p2MetadataNativeLibraries = new Dictionary<string, string> (p2Metadata);
p2MetadataNativeLibraries ["CodesignStampFile"] = "_CodeSignature/CodeResources";
p2MetadataNativeLibraries.Remove ("CodesignEntitlements");
var p3Metadata = new Dictionary<string, string> {
@ -109,7 +107,6 @@ namespace Xamarin.MacDev.Tasks {
{ "CodesignUseSecureTimestamp", "p3.appex-use-secure-timestamp" },
};
var p3MetadataNativeLibraries = new Dictionary<string, string> (p3Metadata);
p3MetadataNativeLibraries ["CodesignStampFile"] = "_CodeSignature/CodeResources";
p3MetadataNativeLibraries.Remove ("CodesignEntitlements");
var w1Metadata = new Dictionary<string, string> {
@ -141,7 +138,6 @@ namespace Xamarin.MacDev.Tasks {
};
var wp1MetadataNativeLibraries = new Dictionary<string, string> (wp1Metadata);
wp1MetadataNativeLibraries ["CodesignSigningKey"] = "-";
wp1MetadataNativeLibraries ["CodesignStampFile"] = "_CodeSignature/CodeResources";
wp1MetadataNativeLibraries.Remove ("CodesignEntitlements");
var wp2Metadata = new Dictionary<string, string> {
@ -157,7 +153,6 @@ namespace Xamarin.MacDev.Tasks {
{ "CodesignUseSecureTimestamp", "wp2.appex-use-secure-timestamp" },
};
var wp2MetadataNativeLibraries = new Dictionary<string, string> (wp2Metadata);
wp2MetadataNativeLibraries ["CodesignStampFile"] = "_CodeSignature/CodeResources";
wp2MetadataNativeLibraries.Remove ("CodesignEntitlements");
var wp3Metadata = new Dictionary<string, string> {
@ -173,7 +168,6 @@ namespace Xamarin.MacDev.Tasks {
{ "CodesignUseSecureTimestamp", "wp3.appex-use-secure-timestamp" },
};
var wp3MetadataNativeLibraries = new Dictionary<string, string> (wp3Metadata);
wp3MetadataNativeLibraries ["CodesignStampFile"] = "_CodeSignature/CodeResources";
wp3MetadataNativeLibraries.Remove ("CodesignEntitlements");
var createDumpMetadata = new Dictionary<string, string> {
@ -240,7 +234,7 @@ namespace Xamarin.MacDev.Tasks {
"Bundle.app/PlugIns/P1.appex",
Platforms.None,
p1Metadata.
Set ("CodesignStampFile", $"Bundle.app/PlugIns/P1.appex/PlugIns/P2.appex/{codeSignatureSubdirectory}_CodeSignature/CodeResources")
Set ("CodesignStampFile", $"codesign-stamp-path/P1.appex/.stampfile")
),
new CodesignInfo ("Bundle.app/PlugIns/P1.appex/P1a.dylib", Platforms.Mobile, p1MetadataNativeLibraries.Set ("CodesignStampFile", "codesign-stamp-path/Bundle.app/PlugIns/P1.appex/P1a.dylib")),
new CodesignInfo ("Bundle.app/PlugIns/P1.appex/Contents/P1b.dylib", Platforms.All, p1MetadataNativeLibraries.Set ("CodesignStampFile", "codesign-stamp-path/Bundle.app/PlugIns/P1.appex/Contents/P1b.dylib")),
@ -254,7 +248,7 @@ namespace Xamarin.MacDev.Tasks {
"Bundle.app/PlugIns/P1.appex/plugins/P2.appex",
Platforms.All,
p2Metadata.
Set ("CodesignStampFile", $"Bundle.app/PlugIns/P1.appex/PlugIns/P2.appex/{codeSignatureSubdirectory}_CodeSignature/CodeResources").
Set ("CodesignStampFile", $"codesign-stamp-path/P2.appex/.stampfile").
Set ("CodesignAdditionalFilesToTouch", "P2.appex.dSYM/Contents/Info.plist")
),
new CodesignInfo ("Bundle.app/PlugIns/P1.appex/plugins/P2.appex/P2a.dylib", Platforms.Mobile, p2MetadataNativeLibraries.Set ("CodesignStampFile", "codesign-stamp-path/Bundle.app/PlugIns/P1.appex/plugins/P2.appex/P2a.dylib")),
@ -269,7 +263,7 @@ namespace Xamarin.MacDev.Tasks {
"Bundle.app/PlugIns/P1.appex/plugins/P2.appex/PlugIns/P3.appex",
Platforms.All,
p3Metadata.
Set ("CodesignStampFile", $"Bundle.app/PlugIns/P1.appex/PlugIns/P2.appex/PlugIns/P3.appex/{codeSignatureSubdirectory}_CodeSignature/CodeResources").
Set ("CodesignStampFile", $"codesign-stamp-path/P3.appex/.stampfile").
Set ("CodesignAdditionalFilesToTouch", "P3.appex.dSYM/Contents/Info.plist;p3-strip-stamp-file")
),
new CodesignInfo ("Bundle.app/PlugIns/P1.appex/plugins/P2.appex/PlugIns/P3.appex/P3a.dylib", Platforms.Mobile, p3MetadataNativeLibraries.Set ("CodesignStampFile", "codesign-stamp-path/Bundle.app/PlugIns/P1.appex/plugins/P2.appex/PlugIns/P3.appex/P3a.dylib")),
@ -284,7 +278,7 @@ namespace Xamarin.MacDev.Tasks {
"Bundle.app/Watch/W1.app",
Platforms.All,
w1Metadata.
Set ("CodesignStampFile", $"Bundle.app/Watch/W1.app/{codeSignatureSubdirectory}_CodeSignature/CodeResources").
Set ("CodesignStampFile", $"codesign-stamp-path/W1.app/.stampfile").
Set ("CodesignAdditionalFilesToTouch", "W1.app.dSYM/Contents/Info.plist")
),
new CodesignInfo ("Bundle.app/Watch/W1.app/Contents/b.dylib", Platforms.All, w1MetadataNativeLibraries.Set ("CodesignStampFile", "codesign-stamp-path/Bundle.app/Watch/W1.app/Contents/b.dylib")),
@ -298,7 +292,7 @@ namespace Xamarin.MacDev.Tasks {
"Bundle.app/Watch/W1.app/PlugIns/WP1.appex",
Platforms.All,
wp1Metadata.
Set ("CodesignStampFile", $"Bundle.app/Watch/W1.app/PlugIns/WP1.appex/{codeSignatureSubdirectory}_CodeSignature/CodeResources").
Set ("CodesignStampFile", $"codesign-stamp-path/WP1.appex/.stampfile").
Set ("CodesignAdditionalFilesToTouch", "WP1.appex.dSYM/Contents/Info.plist")
),
new CodesignInfo ("Bundle.app/Watch/W1.app/PlugIns/WP1.appex/W1a.dylib", Platforms.Mobile, wp1MetadataNativeLibraries.Set ("CodesignStampFile", "codesign-stamp-path/Bundle.app/Watch/W1.app/PlugIns/WP1.appex/W1a.dylib")),
@ -313,7 +307,7 @@ namespace Xamarin.MacDev.Tasks {
"Bundle.app/Watch/W1.app/PlugIns/WP1.appex/PlugIns/WP2.appex",
Platforms.All,
wp2Metadata.
Set ("CodesignStampFile", $"Bundle.app/Watch/W1.app/PlugIns/WP1.appex/PlugIns/WP2.appex/{codeSignatureSubdirectory}_CodeSignature/CodeResources").
Set ("CodesignStampFile", $"codesign-stamp-path/WP2.appex/.stampfile").
Set ("CodesignAdditionalFilesToTouch", "WP2.appex.dSYM/Contents/Info.plist")
),
new CodesignInfo ("Bundle.app/Watch/W1.app/PlugIns/WP1.appex/PlugIns/WP2.appex/W2a.dylib", Platforms.Mobile, wp2MetadataNativeLibraries.Set ("CodesignStampFile", "codesign-stamp-path/Bundle.app/Watch/W1.app/PlugIns/WP1.appex/PlugIns/WP2.appex/W2a.dylib")),
@ -328,7 +322,7 @@ namespace Xamarin.MacDev.Tasks {
"Bundle.app/Watch/W1.app/PlugIns/WP1.appex/PlugIns/WP2.appex/PlugIns/WP3.appex",
Platforms.All,
wp3Metadata.
Set ("CodesignStampFile", $"Bundle.app/Watch/W1.app/PlugIns/WP1.appex/PlugIns/WP2.appex/PlugIns/WP3.appex/{codeSignatureSubdirectory}_CodeSignature/CodeResources").
Set ("CodesignStampFile", $"codesign-stamp-path/WP3.appex/.stampfile").
Set ("CodesignAdditionalFilesToTouch", "WP3.appex.dSYM/Contents/Info.plist;wp3-strip-stamp-file")
),
new CodesignInfo ("Bundle.app/Watch/W1.app/PlugIns/WP1.appex/PlugIns/WP2.appex/PlugIns/WP3.appex/W3a.dylib", Platforms.Mobile, wp3MetadataNativeLibraries.Set ("CodesignStampFile", "codesign-stamp-path/Bundle.app/Watch/W1.app/PlugIns/WP1.appex/PlugIns/WP2.appex/PlugIns/WP3.appex/W3a.dylib")),
@ -408,7 +402,7 @@ namespace Xamarin.MacDev.Tasks {
};
var infos = new CodesignInfo [] {
new CodesignInfo ("Bundle.app", Platforms.All, bundleAppMetadata.Set ("CodesignStampFile", $"Bundle.app/{codeSignatureSubdirectory}_CodeSignature/CodeResources")),
new CodesignInfo ("Bundle.app", Platforms.All, bundleAppMetadata.Set ("CodesignStampFile", $"codesign-stamp-path/Bundle.app/.stampfile")),
new CodesignInfo ("Bundle.app/Contents/MonoBundle/createdump", Platforms.All, createDumpMetadata.Set ("CodesignStampFile", "codesign-stamp-path/Bundle.app/Contents/MonoBundle/createdump")),
};
@ -486,7 +480,7 @@ namespace Xamarin.MacDev.Tasks {
};
var infos = new CodesignInfo [] {
new CodesignInfo ("Bundle.app", Platforms.All, bundleAppMetadata.Set ("CodesignStampFile", $"Bundle.app/{codeSignatureSubdirectory}_CodeSignature/CodeResources")),
new CodesignInfo ("Bundle.app", Platforms.All, bundleAppMetadata.Set ("CodesignStampFile", $"codesign-stamp-path/Bundle.app/.stampfile")),
new CodesignInfo ("Bundle.app/Contents/MonoBundle/createdump", Platforms.All, createDumpMetadata1.Set ("CodesignStampFile", "codesign-stamp-path/Bundle.app/Contents/MonoBundle/createdump")),
};

Просмотреть файл

@ -168,7 +168,7 @@ namespace Xharness {
// the Make.config will use the wrong version. The CI set the version in the environment variable {platform}_WORKLOAD_VERSION via a script.
var workloadVersion = Environment.GetEnvironmentVariable ($"{platform.ToUpperInvariant ()}_WORKLOAD_VERSION");
mlaunchPath = Path.Combine (mlaunchPath, $"Microsoft.{platform}.Sdk",
string.IsNullOrEmpty (workloadVersion) ? config [$"{platform.ToUpperInvariant ()}_NUGET_VERSION_NO_METADATA"] : workloadVersion);
string.IsNullOrEmpty (workloadVersion) ? GetVariable ($"{platform.ToUpperInvariant ()}_NUGET_VERSION_NO_METADATA") : workloadVersion);
mlaunchPath = Path.Combine (mlaunchPath, "tools", "bin", "mlaunch");
return mlaunchPath;
} else if (INCLUDE_XAMARIN_LEGACY && INCLUDE_IOS) {
@ -178,6 +178,21 @@ namespace Xharness {
}
}
bool IsVariableSet (string variable)
{
return !string.IsNullOrEmpty (GetVariable (variable));
}
string GetVariable (string variable, string @default = null)
{
var result = Environment.GetEnvironmentVariable (variable);
if (string.IsNullOrEmpty (result))
config.TryGetValue (variable, out result);
if (string.IsNullOrEmpty (result))
result = @default;
return result;
}
public List<iOSTestProject> IOSTestProjects { get; }
public List<MacTestProject> MacTestProjects { get; } = new List<MacTestProject> ();
@ -207,7 +222,7 @@ namespace Xharness {
public bool INCLUDE_XAMARIN_LEGACY { get; }
public string SYSTEM_MONO { get; set; }
public string DOTNET_DIR { get; set; }
public string DotNetTfm { get; set; }
public string DOTNET_TFM { get; set; }
// Run
@ -265,35 +280,32 @@ namespace Xharness {
LaunchTimeout = InCI ? 3 : 120;
var config = ParseConfigFiles ();
config = ParseConfigFiles ();
var src_root = Path.GetDirectoryName (Path.GetFullPath (RootDirectory));
MONO_PATH = Path.GetFullPath (Path.Combine (src_root, "external", "mono"));
TVOS_MONO_PATH = MONO_PATH;
INCLUDE_IOS = config.ContainsKey ("INCLUDE_IOS") && !string.IsNullOrEmpty (config ["INCLUDE_IOS"]);
INCLUDE_TVOS = config.ContainsKey ("INCLUDE_TVOS") && !string.IsNullOrEmpty (config ["INCLUDE_TVOS"]);
JENKINS_RESULTS_DIRECTORY = config ["JENKINS_RESULTS_DIRECTORY"];
INCLUDE_WATCH = config.ContainsKey ("INCLUDE_WATCH") && !string.IsNullOrEmpty (config ["INCLUDE_WATCH"]);
INCLUDE_MAC = config.ContainsKey ("INCLUDE_MAC") && !string.IsNullOrEmpty (config ["INCLUDE_MAC"]);
INCLUDE_MACCATALYST = config.ContainsKey ("INCLUDE_MACCATALYST") && !string.IsNullOrEmpty (config ["INCLUDE_MACCATALYST"]);
MAC_DESTDIR = config ["MAC_DESTDIR"];
IOS_DESTDIR = config ["IOS_DESTDIR"];
MONO_IOS_SDK_DESTDIR = config ["MONO_IOS_SDK_DESTDIR"];
MONO_MAC_SDK_DESTDIR = config ["MONO_MAC_SDK_DESTDIR"];
ENABLE_DOTNET = config.ContainsKey ("ENABLE_DOTNET") && !string.IsNullOrEmpty (config ["ENABLE_DOTNET"]);
SYSTEM_MONO = config ["SYSTEM_MONO"];
DOTNET_DIR = config ["DOTNET_DIR"];
INCLUDE_XAMARIN_LEGACY = config.ContainsKey ("INCLUDE_XAMARIN_LEGACY") && !string.IsNullOrEmpty (config ["INCLUDE_XAMARIN_LEGACY"]);
DotNetTfm = config ["DOTNET_TFM"];
INCLUDE_IOS = IsVariableSet (nameof (INCLUDE_IOS));
INCLUDE_TVOS = IsVariableSet (nameof (INCLUDE_TVOS));
JENKINS_RESULTS_DIRECTORY = GetVariable (nameof (JENKINS_RESULTS_DIRECTORY));
INCLUDE_WATCH = IsVariableSet (nameof (INCLUDE_WATCH));
INCLUDE_MAC = IsVariableSet (nameof (INCLUDE_MAC));
INCLUDE_MACCATALYST = IsVariableSet (nameof (INCLUDE_MACCATALYST));
MAC_DESTDIR = GetVariable (nameof (MAC_DESTDIR));
IOS_DESTDIR = GetVariable (nameof (IOS_DESTDIR));
MONO_IOS_SDK_DESTDIR = GetVariable (nameof (MONO_IOS_SDK_DESTDIR));
MONO_MAC_SDK_DESTDIR = GetVariable (nameof (MONO_MAC_SDK_DESTDIR));
ENABLE_DOTNET = IsVariableSet (nameof (ENABLE_DOTNET));
SYSTEM_MONO = GetVariable (nameof (SYSTEM_MONO));
DOTNET_DIR = GetVariable (nameof (DOTNET_DIR));
INCLUDE_XAMARIN_LEGACY = IsVariableSet (nameof (INCLUDE_XAMARIN_LEGACY));
DOTNET_TFM = GetVariable (nameof (DOTNET_TFM));
if (string.IsNullOrEmpty (SdkRoot))
SdkRoot = config ["XCODE_DEVELOPER_ROOT"] ?? configuration.SdkRoot;
this.config = config;
SdkRoot = GetVariable ("XCODE_DEVELOPER_ROOT", configuration.SdkRoot);
processManager = new MlaunchProcessManager (XcodeRoot, MlaunchPath);
AppBundleLocator = new AppBundleLocator (processManager, () => HarnessLog, XIBuildPath, "/usr/local/share/dotnet/dotnet", config ["DOTNET"]);
AppBundleLocator = new AppBundleLocator (processManager, () => HarnessLog, XIBuildPath, "/usr/local/share/dotnet/dotnet", GetVariable ("DOTNET"));
TunnelBore = new TunnelBore (processManager);
}

Просмотреть файл

@ -47,6 +47,7 @@ namespace Xharness {
bool INCLUDE_XAMARIN_LEGACY { get; }
string SYSTEM_MONO { get; set; }
string DOTNET_DIR { get; set; }
string DOTNET_TFM { get; }
string XcodeRoot { get; }
string LogDirectory { get; }
double Timeout { get; }
@ -64,7 +65,6 @@ namespace Xharness {
bool UseGroupedApps { get; }
string VSDropsUri { get; }
bool DisableWatchOSOnWrench { get; }
string DotNetTfm { get; }
#endregion

Просмотреть файл

@ -65,7 +65,7 @@ namespace Xharness.Targets {
public const string FSharpGuid = "{F2A71F9B-5D33-465A-A702-920D77279786}";
public const string CSharpGuid = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}";
public string DotNetTfm => Harness.DotNetTfm;
public string DotNetTfm => Harness.DOTNET_TFM;
public string LanguageGuid { get { return IsFSharp ? FSharpGuid : CSharpGuid; } }

Просмотреть файл

@ -711,7 +711,7 @@ namespace Xamarin.Bundler {
}
}
public static void ExtractResource (ModuleDefinition module, string name, string path, bool remove)
public static bool ExtractResource (ModuleDefinition module, string name, string path, bool remove)
{
for (int i = 0; i < module.Resources.Count; i++) {
EmbeddedResource embedded = module.Resources [i] as EmbeddedResource;
@ -730,8 +730,10 @@ namespace Xamarin.Bundler {
if (remove)
module.Resources.RemoveAt (i);
break;
return true;
}
return false;
}
// Returns true if the source file was copied to the target or false if it was already up to date.

Просмотреть файл

@ -280,18 +280,24 @@ namespace Xamarin.Bundler {
if (!string.IsNullOrEmpty (linkWith.LibraryName)) {
switch (Path.GetExtension (linkWith.LibraryName).ToLowerInvariant ()) {
case ".framework":
case ".framework": {
AssertiOSVersionSupportsUserFrameworks (linkWith.LibraryName);
Frameworks.Add (ExtractFramework (assembly, metadata));
// TryExtractFramework prints a error/warning if something goes wrong, so no need for us to have an error handling path.
if (TryExtractFramework (assembly, metadata, out var framework))
Frameworks.Add (framework);
break;
}
case ".xcframework":
// this is resolved, at msbuild time, into a framework
// but we must ignore it here (can't be the `default` case)
break;
default:
LinkWith.Add (ExtractNativeLibrary (assembly, metadata));
default: {
// TryExtractFramework prints a error/warning if something goes wrong, so no need for us to have an error handling path.
if (TryExtractNativeLibrary (assembly, metadata, out var framework))
LinkWith.Add (framework);
break;
}
}
}
}
}
@ -352,12 +358,17 @@ namespace Xamarin.Bundler {
#endif
}
string ExtractNativeLibrary (AssemblyDefinition assembly, NativeReferenceMetadata metadata)
bool TryExtractNativeLibrary (AssemblyDefinition assembly, NativeReferenceMetadata metadata, out string library)
{
string path = Path.Combine (App.Cache.Location, metadata.LibraryName);
library = null;
if (!Application.IsUptodate (FullPath, path)) {
Application.ExtractResource (assembly.MainModule, metadata.LibraryName, path, false);
if (!Application.ExtractResource (assembly.MainModule, metadata.LibraryName, path, false)) {
ErrorHelper.Warning (1308, Errors.MX1308 /* Could not extract the native library '{0}' from the assembly '{1}', because it doesn't contain the resource '{2}'. */, metadata.LibraryName, FullPath, metadata.LibraryName);
return false;
}
Driver.Log (3, "Extracted third-party binding '{0}' from '{1}' to '{2}'", metadata.LibraryName, FullPath, path);
LogNativeReference (metadata);
} else {
@ -367,16 +378,24 @@ namespace Xamarin.Bundler {
if (!File.Exists (path))
ErrorHelper.Warning (1302, Errors.MT1302, metadata.LibraryName, path);
return path;
library = path;
return true;
}
string ExtractFramework (AssemblyDefinition assembly, NativeReferenceMetadata metadata)
bool TryExtractFramework (AssemblyDefinition assembly, NativeReferenceMetadata metadata, out string framework)
{
string path = Path.Combine (App.Cache.Location, metadata.LibraryName);
var zipPath = path + ".zip";
framework = null;
if (!Application.IsUptodate (FullPath, zipPath)) {
Application.ExtractResource (assembly.MainModule, metadata.LibraryName, zipPath, false);
if (!Application.ExtractResource (assembly.MainModule, metadata.LibraryName, zipPath, false)) {
ErrorHelper.Warning (1307, Errors.MX1307 /* Could not extract the native framework '{0}' from the assembly '{1}', because it doesn't contain the resource '{2}'. */, metadata.LibraryName, FullPath, metadata.LibraryName);
return false;
}
Driver.Log (3, "Extracted third-party framework '{0}' from '{1}' to '{2}'", metadata.LibraryName, FullPath, zipPath);
LogNativeReference (metadata);
} else {
@ -401,7 +420,8 @@ namespace Xamarin.Bundler {
throw ErrorHelper.CreateError (1303, Errors.MT1303, metadata.LibraryName, zipPath);
}
return path;
framework = path;
return true;
}
static void LogNativeReference (NativeReferenceMetadata metadata)

Просмотреть файл

@ -839,6 +839,9 @@ namespace Registrar {
}
protected override IEnumerable<TypeReference> CollectTypes (AssemblyDefinition assembly)
=> GetAllTypes (assembly);
internal static IEnumerable<TypeReference> GetAllTypes (AssemblyDefinition assembly)
{
var queue = new Queue<TypeDefinition> ();
@ -3307,12 +3310,7 @@ namespace Registrar {
ErrorHelper.ThrowIfErrors (exceptions);
}
bool HasIntPtrBoolCtor (TypeDefinition type, List<Exception> exceptions)
{
return HasIntPtrBoolCtor (type, exceptions, out var _);
}
bool HasIntPtrBoolCtor (TypeDefinition type, List<Exception> exceptions, [NotNullWhen (true)] out MethodDefinition? ctor)
bool TryGetIntPtrBoolCtor (TypeDefinition type, List<Exception> exceptions, [NotNullWhen (true)] out MethodDefinition? ctor)
{
ctor = null;
if (!type.HasMethods)
@ -4552,7 +4550,7 @@ namespace Registrar {
}
// verify that the type has a ctor with two parameters
if (!HasIntPtrBoolCtor (nativeObjType, exceptions, out ctor))
if (!TryGetIntPtrBoolCtor (nativeObjType, exceptions, out ctor))
throw ErrorHelper.CreateError (4103, Errors.MT4103, nativeObjType.FullName, descriptiveMethodName);
return nativeObjType;

Просмотреть файл

@ -212,7 +212,9 @@ Describe 'New-BuildConfiguration' {
""BuildId"": ""BUILD_BUILDID"",
""DOTNET_PLATFORMS"": ""iOS tvOS"",
""INCLUDE_DOTNET_IOS"": null,
""IOS_NUGET_VERSION_NO_METADATA"": null,
""INCLUDE_DOTNET_TVOS"": ""true"",
""TVOS_NUGET_VERSION_NO_METADATA"": null,
""Commit"": ""BUILD_SOURCEVERSION"",
""Tags"": [
""ciBuild"",
@ -238,7 +240,9 @@ Describe 'New-BuildConfiguration' {
""BuildId"": ""BUILD_BUILDID"",
""DOTNET_PLATFORMS"": ""iOS tvOS"",
""INCLUDE_DOTNET_IOS"": null,
""IOS_NUGET_VERSION_NO_METADATA"": null,
""INCLUDE_DOTNET_TVOS"": ""true"",
""TVOS_NUGET_VERSION_NO_METADATA"": null,
""Commit"": ""BUILD_SOURCEVERSION"",
""Tags"": [
""ciBuild"",

Просмотреть файл

@ -259,6 +259,10 @@ class BuildConfiguration {
$variableName = "INCLUDE_DOTNET_$($platform.ToUpper())"
$variableValue = $config.$variableName
Write-Host "##vso[task.setvariable variable=$variableName;isOutput=true]$variableValue"
$variableName = "$($platform.ToUpper())_NUGET_VERSION_NO_METADATA"
$variableValue = $config.$variableName
Write-Host "##vso[task.setvariable variable=$variableName;isOutput=true]$variableValue"
}
return $config
@ -281,6 +285,10 @@ class BuildConfiguration {
$variableName = "INCLUDE_DOTNET_$($platform.ToUpper())"
$variableValue = [Environment]::GetEnvironmentVariable("CONFIGURE_PLATFORMS_$variableName")
$configuration | Add-Member -NotePropertyName $variableName -NotePropertyValue $variableValue
$variableName = "$($platform.ToUpper())_NUGET_VERSION_NO_METADATA"
$variableValue = [Environment]::GetEnvironmentVariable("CONFIGURE_PLATFORMS_$variableName")
$configuration | Add-Member -NotePropertyName $variableName -NotePropertyValue $variableValue
}
# calculate the commit to later share it with the cascade pipelines

Просмотреть файл

@ -30,8 +30,6 @@ INCLUDE_WATCH=$(cat "$FILE")
make -C "$BUILD_SOURCESDIRECTORY/xamarin-macios/tools/devops" print-variable-value-to-file FILE="$FILE" VARIABLE=INCLUDE_MAC
INCLUDE_MAC=$(cat "$FILE")
rm -f "$FILE"
# print it out, so turn off echoing since that confuses Azure DevOps
set +x
@ -42,6 +40,11 @@ for platform in $DOTNET_PLATFORMS; do
PLATFORM_UPPER=$(echo "$platform" | tr '[:lower:]' '[:upper:]')
echo "##vso[task.setvariable variable=INCLUDE_DOTNET_$PLATFORM_UPPER;isOutput=true]1"
DISABLED_DOTNET_PLATFORMS=${DISABLED_DOTNET_PLATFORMS/ $platform / }
VARIABLE="${PLATFORM_UPPER}_NUGET_VERSION_NO_METADATA"
make -C "$BUILD_SOURCESDIRECTORY/xamarin-macios/tools/devops" print-variable-value-to-file FILE="$FILE" VARIABLE="$VARIABLE"
VALUE=$(cat "$FILE")
echo "##vso[task.setvariable variable=$VARIABLE;isOutput=true]$VALUE"
done
for platform in $DISABLED_DOTNET_PLATFORMS; do
PLATFORM_UPPER=$(echo "$platform" | tr '[:lower:]' '[:upper:]')
@ -61,3 +64,5 @@ else
echo "##vso[task.setvariable variable=INCLUDE_LEGACY_MAC;isOutput=true]"
fi
set -x
rm -f "$FILE"

Просмотреть файл

@ -0,0 +1,38 @@
# Dump the environment to see what we're working with.
& "$Env:SYSTEM_DEFAULTWORKINGDIRECTORY\xamarin-macios\tools\devops\automation\scripts\show_env.ps1"
# Set a few variables
$Env:DOTNET = "$Env:BUILD_SOURCESDIRECTORY\xamarin-macios\tests\dotnet\Windows\bin\dotnet\dotnet.exe"
$Env:DOTNET_DIR = "$Env:BUILD_SOURCESDIRECTORY\xamarin-macios\tests\dotnet\Windows\bin\dotnet\"
$Env:TESTS_USE_SYSTEM = "1"
# Compute the <platform>_NUGET_VERSION_NO_METADATA variables and set them in the environment
$configurationDotNetPlatforms = $Env:CONFIGURATION_DOTNET_PLATFORMS
$dotnetPlatforms = $configurationDotNetPlatforms.Split(' ', [StringSplitOptions]::RemoveEmptyEntries)
foreach ($platform in $dotnetPlatforms) {
$manifestPath = "$Env:BUILD_SOURCESDIRECTORY\artifacts\AssetManifests\$($platform)\AssetManifest.xml"
$productVersion = Select-Xml -Path "$manifestPath" -XPath "/Build/Package[@Id='Microsoft.$($platform).Sdk']/@Version" | ForEach-Object { $_.Node.Value }
$variableName = "$($platform.ToUpper())_NUGET_VERSION_NO_METADATA"
[Environment]::SetEnvironmentVariable($variableName, $productVersion)
Write-Host "$variableName = $productVersion"
}
# Tell the tests how they can execute the C# compiler
$csc = Get-ChildItem "$Env:BUILD_SOURCESDIRECTORY\xamarin-macios\tests\dotnet\Windows\bin\dotnet" -Include csc.dll -Recurse -File | %{$_.FullName}
$Env:DOTNET_CSC_COMMAND = "$Env:DOTNET exec $csc".Replace("\", "/")
Write-Host "DOTNET_CSC_COMMAND: $Env:DOTNET_CSC_COMMAND"
# Tell the tests where the BCL is
$Env:DOTNET_BCL_DIR = Get-ChildItem "$Env:BUILD_SOURCESDIRECTORY\xamarin-macios\tests\dotnet\Windows\bin\dotnet\packs\Microsoft.NETCore.App.Ref" -Include System.dll -Recurse -File | %{$_.DirectoryName}
Write-Host "DOTNET_BCL_DIR: $Env:DOTNET_BCL_DIR"
# Finally we can run the tests
& $Env:BUILD_SOURCESDIRECTORY\xamarin-macios\tests\dotnet\Windows\bin\dotnet\dotnet.exe `
test `
"$Env:BUILD_SOURCESDIRECTORY/xamarin-macios/tests/bgen/bgen-tests.csproj" `
"--results-directory:$Env:BUILD_SOURCESDIRECTORY/xamarin-macios/jenkins-results/windows/bgen-tests/" `
"--logger:console;verbosity=detailed" `
"--logger:trx;LogFileName=$Env:BUILD_SOURCESDIRECTORY/xamarin-macios/jenkins-results/windows/bgen-tests/results.trx" `
"--logger:html;LogFileName=$Env:BUILD_SOURCESDIRECTORY/xamarin-macios/jenkins-results/windows/bgen-tests/results.html" `
"--settings" "$Env:BUILD_SOURCESDIRECTORY/xamarin-macios/tests/dotnet/Windows/config.runsettings" `
"-bl:$Env:BUILD_SOURCESDIRECTORY/xamarin-macios/jenkins-results/windows/bgen-tests/results.binlog"

Просмотреть файл

@ -178,7 +178,9 @@ steps:
rm -Rf $(System.DefaultWorkingDirectory)/diagnostic-sim-output/output
mkdir -p $(System.DefaultWorkingDirectory)/diagnostic-sim-output/output
printf "\n" | xcrun simctl diagnose -b -X --output=$(System.DefaultWorkingDirectory)/diagnostic-sim-output/output
if ! printf "\n" | xcrun simctl diagnose -b -X --output=$(System.DefaultWorkingDirectory)/diagnostic-sim-output/output; then
echo "simctl diagnose failed with exit code $?"
fi
displayName: 'Collect diagnostic info from simulators'
condition: eq(variables['system.debug'], true)

Просмотреть файл

@ -174,6 +174,19 @@ steps:
"-bl:$(Build.SourcesDirectory)/xamarin-macios/tests/dotnet/Windows/run-dotnet-tests.binlog"
displayName: 'Run .NET tests'
- pwsh: |
Import-Module $Env:SYSTEM_DEFAULTWORKINGDIRECTORY\xamarin-macios\tools\devops\automation\scripts\MaciosCI.psd1
$configFile = "$(Build.SourcesDirectory)\artifacts\build-configuration\configuration.json"
$config = Import-BuildConfiguration -ConfigFile $configFile
$config | Write-Host
name: configuration
continueOnError: true
displayName: 'Parse build configuration'
timeoutInMinutes: 1
- pwsh: $(System.DefaultWorkingDirectory)/xamarin-macios/tools/devops/automation/scripts/run-generator-tests-on-windows.ps1
displayName: 'Run generator tests'
# Archive files for the Html Report so that the report can be easily uploaded as artifacts of the build.
- task: ArchiveFiles@1
displayName: 'Archive HtmlReport'

Просмотреть файл

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Mono.Cecil;
@ -309,6 +310,12 @@ namespace Xamarin.Linker {
}
}
public TypeReference System_Diagnostics_CodeAnalysis_DynamicallyAccessedMemberTypes {
get {
return GetTypeReference (CorlibAssembly, "System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes", out var _);
}
}
public TypeReference System_Reflection_MethodBase {
get {
return GetTypeReference (CorlibAssembly, "System.Reflection.MethodBase", out var _);
@ -389,6 +396,12 @@ namespace Xamarin.Linker {
}
}
public TypeReference Foundation_INSObjectFactory {
get {
return GetTypeReference (PlatformAssembly, "Foundation.INSObjectFactory", out var _);
}
}
public TypeReference ObjCRuntime_INativeObject {
get {
return GetTypeReference (PlatformAssembly, "ObjCRuntime.INativeObject", out var _);
@ -466,17 +479,34 @@ namespace Xamarin.Linker {
return GetMethodReference (CorlibAssembly,
System_Diagnostics_CodeAnalysis_DynamicDependencyAttribute,
".ctor",
".ctor(String,Type)",
isStatic: false,
System_String,
System_Type);
}
}
public MethodReference DynamicDependencyAttribute_ctor__DynamicallyAccessedMemberTypes_Type {
get {
return GetMethodReference (CorlibAssembly,
System_Diagnostics_CodeAnalysis_DynamicDependencyAttribute,
".ctor",
".ctor(DynamicallyAccessedMemberTypes,Type)",
isStatic: false,
System_Diagnostics_CodeAnalysis_DynamicallyAccessedMemberTypes,
System_Type);
}
}
public MethodReference RuntimeTypeHandle_Equals {
get {
if (configuration.Application.XamarinRuntime == XamarinRuntime.MonoVM) {
return RegistrarHelper_RuntimeTypeHandleEquals;
}
return GetMethodReference (CorlibAssembly, System_RuntimeTypeHandle, "Equals", isStatic: false, System_RuntimeTypeHandle);
}
}
public MethodReference MethodBase_Invoke {
get {
return GetMethodReference (CorlibAssembly, System_Reflection_MethodBase, "Invoke", (v) =>
@ -727,6 +757,20 @@ namespace Xamarin.Linker {
}
}
public MethodReference RegistrarHelper_RuntimeTypeHandleEquals {
get {
return GetMethodReference (PlatformAssembly,
ObjCRuntime_RegistrarHelper,
"RuntimeTypeHandleEquals",
(v) => v.IsStatic
&& v.HasParameters
&& v.Parameters.Count == 2
&& v.Parameters [0].ParameterType is ByReferenceType brt1 && brt1.ElementType.Is ("System", "RuntimeTypeHandle")
&& v.Parameters [1].ParameterType.Is ("System", "RuntimeTypeHandle")
&& !v.HasGenericParameters);
}
}
public MethodReference IManagedRegistrar_LookupUnmanagedFunction {
get {
return GetMethodReference (PlatformAssembly,
@ -755,6 +799,49 @@ namespace Xamarin.Linker {
}
}
public MethodReference IManagedRegistrar_ConstructNSObject {
get {
return GetMethodReference (PlatformAssembly,
ObjCRuntime_IManagedRegistrar, "ConstructNSObject",
isStatic: false,
System_RuntimeTypeHandle,
ObjCRuntime_NativeHandle);
}
}
public MethodReference INSObjectFactory__Xamarin_ConstructNSObject {
get {
return GetMethodReference (PlatformAssembly,
Foundation_INSObjectFactory, "_Xamarin_ConstructNSObject",
nameof (INSObjectFactory__Xamarin_ConstructNSObject),
isStatic: true,
ObjCRuntime_NativeHandle);
}
}
public MethodReference IManagedRegistrar_ConstructINativeObject {
get {
return GetMethodReference (PlatformAssembly,
ObjCRuntime_IManagedRegistrar, "ConstructINativeObject",
nameof (IManagedRegistrar_ConstructINativeObject),
isStatic: false,
System_RuntimeTypeHandle,
ObjCRuntime_NativeHandle,
System_Boolean);
}
}
public MethodReference INativeObject__Xamarin_ConstructINativeObject {
get {
return GetMethodReference (PlatformAssembly,
ObjCRuntime_INativeObject, "_Xamarin_ConstructINativeObject",
nameof (INativeObject__Xamarin_ConstructINativeObject),
isStatic: true,
ObjCRuntime_NativeHandle,
System_Boolean);
}
}
public MethodReference IManagedRegistrar_RegisterWrapperTypes {
get {
return GetMethodReference (PlatformAssembly, ObjCRuntime_IManagedRegistrar, "RegisterWrapperTypes", (v) =>
@ -1094,6 +1181,15 @@ namespace Xamarin.Linker {
}
}
public MethodReference Runtime_TryReleaseINativeObject {
get {
return GetMethodReference (PlatformAssembly,
ObjCRuntime_Runtime, "TryReleaseINativeObject",
isStatic: true,
ObjCRuntime_INativeObject);
}
}
public MethodReference UnmanagedCallersOnlyAttribute_Constructor {
get {
return GetMethodReference (CorlibAssembly, "System.Runtime.InteropServices.UnmanagedCallersOnlyAttribute", ".ctor", (v) => v.IsDefaultConstructor ());
@ -1147,5 +1243,22 @@ namespace Xamarin.Linker {
method_map.Clear ();
field_map.Clear ();
}
public CustomAttribute CreateDynamicDependencyAttribute (string memberSignature, TypeDefinition type)
{
var attribute = new CustomAttribute (DynamicDependencyAttribute_ctor__String_Type);
attribute.ConstructorArguments.Add (new CustomAttributeArgument (System_String, memberSignature));
attribute.ConstructorArguments.Add (new CustomAttributeArgument (System_Type, type));
return attribute;
}
public CustomAttribute CreateDynamicDependencyAttribute (DynamicallyAccessedMemberTypes memberTypes, TypeDefinition type)
{
var attribute = new CustomAttribute (DynamicDependencyAttribute_ctor__DynamicallyAccessedMemberTypes_Type);
// typed as 'int' because that's how the linker expects it: https://github.com/dotnet/runtime/blob/3c5ad6c677b4a3d12bc6a776d654558cca2c36a9/src/tools/illink/src/linker/Linker/DynamicDependency.cs#L97
attribute.ConstructorArguments.Add (new CustomAttributeArgument (System_Diagnostics_CodeAnalysis_DynamicallyAccessedMemberTypes, (int) memberTypes));
attribute.ConstructorArguments.Add (new CustomAttributeArgument (System_Type, type));
return attribute;
}
}
}

Просмотреть файл

@ -3,18 +3,31 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
using Mono.Linker;
using Mono.Linker.Steps;
using Mono.Cecil;
using Mono.Cecil.Cil;
using Xamarin.Bundler;
using Xamarin.Linker;
using Xamarin.Utils;
#nullable enable
namespace Mono.Tuner {
public abstract class ApplyPreserveAttributeBase : BaseSubStep {
public abstract class ApplyPreserveAttributeBase : ConfigurationAwareSubStep {
AppBundleRewriter? abr;
protected override string Name { get => "Apply Preserve Attribute"; }
protected override int ErrorCode { get => 2450; }
// set 'removeAttribute' to true if you want the preserved attribute to be removed from the final assembly
protected abstract bool IsPreservedAttribute (ICustomAttributeProvider provider, CustomAttribute attribute, out bool removeAttribute);
@ -30,28 +43,36 @@ namespace Mono.Tuner {
}
}
public override void Initialize (LinkContext context)
{
base.Initialize (context);
if (Configuration.Application.XamarinRuntime == XamarinRuntime.NativeAOT)
abr = Configuration.AppBundleRewriter;
}
public override bool IsActiveFor (AssemblyDefinition assembly)
{
return Annotations.GetAction (assembly) == AssemblyAction.Link;
}
public override void ProcessType (TypeDefinition type)
protected override void Process (TypeDefinition type)
{
TryApplyPreserveAttribute (type);
}
public override void ProcessField (FieldDefinition field)
protected override void Process (FieldDefinition field)
{
foreach (var attribute in GetPreserveAttributes (field))
Mark (field, attribute);
}
public override void ProcessMethod (MethodDefinition method)
protected override void Process (MethodDefinition method)
{
MarkMethodIfPreserved (method);
}
public override void ProcessProperty (PropertyDefinition property)
protected override void Process (PropertyDefinition property)
{
foreach (var attribute in GetPreserveAttributes (property)) {
MarkMethod (property.GetMethod, attribute);
@ -59,7 +80,7 @@ namespace Mono.Tuner {
}
}
public override void ProcessEvent (EventDefinition @event)
protected override void Process (EventDefinition @event)
{
foreach (var attribute in GetPreserveAttributes (@event)) {
MarkMethod (@event.AddMethod, attribute);
@ -103,6 +124,7 @@ namespace Mono.Tuner {
}
Annotations.AddPreservedMethod (method.DeclaringType, method);
AddConditionalDynamicDependencyAttribute (method.DeclaringType, method);
}
static bool IsConditionalAttribute (CustomAttribute? attribute)
@ -120,6 +142,7 @@ namespace Mono.Tuner {
void PreserveUnconditional (IMetadataTokenProvider provider)
{
Annotations.Mark (provider);
AddDynamicDependencyAttribute (provider);
var member = provider as IMemberDefinition;
if (member is null || member.DeclaringType is null)
@ -131,14 +154,7 @@ namespace Mono.Tuner {
void TryApplyPreserveAttribute (TypeDefinition type)
{
foreach (var attribute in GetPreserveAttributes (type)) {
Annotations.Mark (type);
if (!attribute.HasFields)
continue;
foreach (var named_argument in attribute.Fields)
if (named_argument.Name == "AllMembers" && (bool) named_argument.Argument.Value)
Annotations.SetPreserve (type, TypePreserve.All);
PreserveType (type, attribute);
}
}
@ -165,5 +181,82 @@ namespace Mono.Tuner {
return attrs;
}
protected void PreserveType (TypeDefinition type, CustomAttribute preserveAttribute)
{
var allMembers = false;
if (preserveAttribute.HasFields) {
foreach (var named_argument in preserveAttribute.Fields)
if (named_argument.Name == "AllMembers" && (bool) named_argument.Argument.Value)
allMembers = true;
}
PreserveType (type, allMembers);
}
protected void PreserveType (TypeDefinition type, bool allMembers)
{
Annotations.Mark (type);
if (allMembers)
Annotations.SetPreserve (type, TypePreserve.All);
AddDynamicDependencyAttribute (type, allMembers);
}
MethodDefinition GetOrCreateModuleConstructor (ModuleDefinition @module)
{
var moduleType = @module.GetModuleType ();
var moduleConstructor = moduleType.GetTypeConstructor ();
if (moduleConstructor is null) {
moduleConstructor = moduleType.AddMethod (".cctor", MethodAttributes.Private | MethodAttributes.HideBySig | MethodAttributes.RTSpecialName | MethodAttributes.SpecialName | MethodAttributes.Static, abr!.System_Void);
moduleConstructor.CreateBody (out var il);
il.Emit (OpCodes.Ret);
}
return moduleConstructor;
}
void AddDynamicDependencyAttribute (TypeDefinition type, bool allMembers)
{
if (abr is null)
return;
abr.ClearCurrentAssembly ();
abr.SetCurrentAssembly (type.Module.Assembly);
var moduleConstructor = GetOrCreateModuleConstructor (type.GetModule ());
var attrib = abr.CreateDynamicDependencyAttribute (allMembers ? DynamicallyAccessedMemberTypes.All : DynamicallyAccessedMemberTypes.None, type);
moduleConstructor.CustomAttributes.Add (attrib);
abr.ClearCurrentAssembly ();
}
void AddConditionalDynamicDependencyAttribute (TypeDefinition onType, MethodDefinition forMethod)
{
if (abr is null)
return;
// I haven't found a way to express a conditional Preserve attribute using DynamicDependencyAttribute :/
ErrorHelper.Warning (2112, Errors.MX2112 /* Unable to apply the conditional [Preserve] attribute on the member {0} */, forMethod.FullName);
}
void AddDynamicDependencyAttribute (IMetadataTokenProvider provider)
{
if (abr is null)
return;
var member = provider as IMemberDefinition;
if (member is null)
throw ErrorHelper.CreateError (99, $"Unable to add dynamic dependency attribute to {provider.GetType ().FullName}");
var module = member.GetModule ();
abr.ClearCurrentAssembly ();
abr.SetCurrentAssembly (module.Assembly);
var moduleConstructor = GetOrCreateModuleConstructor (module);
var signature = DocumentationComments.GetSignature (member);
var attrib = abr.CreateDynamicDependencyAttribute (signature, member.DeclaringType);
moduleConstructor.CustomAttributes.Add (attrib);
abr.ClearCurrentAssembly ();
}
}
}

Просмотреть файл

@ -1,8 +1,11 @@
using System.Collections.Generic;
using System.Linq;
using Mono.Cecil;
using Mono.Cecil.Cil;
using Xamarin.Bundler;
#nullable enable
namespace Xamarin.Linker {
@ -127,5 +130,25 @@ namespace Xamarin.Linker {
il.Emit (OpCodes.Ret);
return defaultCtor;
}
public static ModuleDefinition GetModule (this IMetadataTokenProvider provider)
{
if (provider is TypeDefinition td)
return td.Module;
if (provider is IMemberDefinition md)
return md.DeclaringType.Module;
throw ErrorHelper.CreateError (99, $"Unable to get the module of {provider.GetType ().FullName}");
}
public static TypeDefinition GetModuleType (this ModuleDefinition @module)
{
var moduleType = @module.Types.SingleOrDefault (v => v.Name == "<Module>");
if (moduleType is null)
throw ErrorHelper.CreateError (99, $"No <Module> type found in {@module.Name}");
return moduleType;
}
}
}

Просмотреть файл

@ -0,0 +1,80 @@
using System;
using System.Collections.Generic;
using System.Text;
using Mono.Cecil;
using Xamarin.Bundler;
#nullable enable
namespace Xamarin.Utils {
// signature format: https://github.com/dotnet/csharpstandard/blob/standard-v6/standard/documentation-comments.md#d42-id-string-format
public static class DocumentationComments {
public static string GetSignature (IMetadataTokenProvider member)
{
if (member is FieldDefinition fd)
return GetSignature (fd);
if (member is MethodDefinition md)
return GetSignature (md);
if (member is TypeDefinition td)
return GetSignature (td);
throw ErrorHelper.CreateError (99, $"Unable to get the doc signature for {member.GetType ().FullName}");
}
public static string GetSignature (TypeDefinition type)
{
if (type.IsNested)
return type.Name;
return type.FullName;
}
public static string GetSignature (FieldDefinition field)
{
return field.Name.Replace ('.', '#');
}
public static string GetSignature (MethodDefinition method)
{
var sb = new StringBuilder ();
sb.Append (method.Name.Replace ('.', '#'));
sb.Append ('(');
for (var i = 0; i < method.Parameters.Count; i++) {
if (i > 0)
sb.Append (',');
var parameterType = method.Parameters [i].ParameterType;
WriteTypeSignature (sb, parameterType);
}
sb.Append (')');
return sb.ToString ();
}
static void WriteTypeSignature (StringBuilder sb, TypeReference type)
{
if (type is ByReferenceType brt) {
WriteTypeSignature (sb, brt.GetElementType ());
sb.Append ('@');
return;
}
if (type is ArrayType at) {
WriteTypeSignature (sb, at.GetElementType ());
sb.Append ("[]");
return;
}
if (type is PointerType pt) {
WriteTypeSignature (sb, pt.GetElementType ());
sb.Append ('*');
return;
}
sb.Append (type.FullName.Replace ('/', '.'));
}
}
}

Просмотреть файл

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
@ -123,6 +124,8 @@ namespace Xamarin.Linker {
GenerateLookupType (info, registrarType, types);
GenerateLookupTypeId (info, registrarType, types);
GenerateRegisterWrapperTypes (registrarType);
GenerateConstructNSObject (registrarType);
GenerateConstructINativeObject (registrarType);
// Make sure the linker doesn't sweep away anything we just generated.
Annotations.Mark (registrarType);
@ -201,6 +204,13 @@ namespace Xamarin.Linker {
return types;
}
IEnumerable<TypeDefinition> GetRelevantTypes (Func<TypeDefinition, bool> isRelevant)
=> StaticRegistrar.GetAllTypes (abr.CurrentAssembly)
.Cast<TypeDefinition> ()
.Where (type => !IsTrimmed (type))
.Where (type => type.Module.Assembly == abr.CurrentAssembly)
.Where (isRelevant);
bool IsTrimmed (MemberReference type)
{
return StaticRegistrar.IsTrimmed (type, Annotations);
@ -281,6 +291,245 @@ namespace Xamarin.Linker {
il.Emit (OpCodes.Ret);
}
void GenerateConstructNSObject (TypeDefinition registrarType)
{
var createInstanceMethod = registrarType.AddMethod ("ConstructNSObject", MethodAttributes.Private | MethodAttributes.Final | MethodAttributes.Virtual | MethodAttributes.NewSlot | MethodAttributes.HideBySig, abr.ObjCRuntime_INativeObject);
var typeHandleParameter = createInstanceMethod.AddParameter ("typeHandle", abr.System_RuntimeTypeHandle);
var nativeHandleParameter = createInstanceMethod.AddParameter ("nativeHandle", abr.ObjCRuntime_NativeHandle);
createInstanceMethod.Overrides.Add (abr.IManagedRegistrar_ConstructNSObject);
var body = createInstanceMethod.CreateBody (out var il);
// We generate something like this:
// if (RuntimeTypeHandle.Equals (typeHandle, typeof (TypeA).TypeHandle))
// return new TypeA (nativeHandle);
// if (RuntimeTypeHandle.Equals (typeHandle, typeof (TypeB).TypeHandle))
// return new TypeB (nativeHandle);
// return null;
var types = GetRelevantTypes (type => type.IsNSObject (DerivedLinkContext) && !type.IsAbstract && !type.IsInterface);
foreach (var type in types) {
var ctorRef = FindNSObjectConstructor (type);
if (ctorRef is null) {
Driver.Log (9, $"Cannot include {type.FullName} in ConstructNSObject because it doesn't have a suitable constructor");
continue;
}
var ctor = abr.CurrentAssembly.MainModule.ImportReference (ctorRef);
if (IsTrimmed (ctor))
Annotations.Mark (ctor.Resolve ());
// We can only add a type to the table if it's not an open type.
if (!ManagedRegistrarStep.IsOpenType (type)) {
EnsureVisible (createInstanceMethod, ctor);
il.Emit (OpCodes.Ldarga_S, typeHandleParameter);
il.Emit (OpCodes.Ldtoken, type);
il.Emit (OpCodes.Call, abr.RuntimeTypeHandle_Equals);
var falseTarget = il.Create (OpCodes.Nop);
il.Emit (OpCodes.Brfalse_S, falseTarget);
il.Emit (OpCodes.Ldarg, nativeHandleParameter);
if (ctor.Parameters [0].ParameterType.Is ("System", "IntPtr"))
il.Emit (OpCodes.Call, abr.NativeObject_op_Implicit_IntPtr);
il.Emit (OpCodes.Newobj, ctor);
il.Emit (OpCodes.Ret);
il.Append (falseTarget);
}
// In addition to the big lookup method, implement the static factory method on the type:
ImplementConstructNSObjectFactoryMethod (type, ctor);
}
// return default (NSObject);
il.Emit (OpCodes.Ldnull);
il.Emit (OpCodes.Ret);
}
void GenerateConstructINativeObject (TypeDefinition registrarType)
{
var createInstanceMethod = registrarType.AddMethod ("ConstructINativeObject", MethodAttributes.Private | MethodAttributes.Final | MethodAttributes.Virtual | MethodAttributes.NewSlot | MethodAttributes.HideBySig, abr.ObjCRuntime_INativeObject);
var typeHandleParameter = createInstanceMethod.AddParameter ("typeHandle", abr.System_RuntimeTypeHandle);
var nativeHandleParameter = createInstanceMethod.AddParameter ("nativeHandle", abr.ObjCRuntime_NativeHandle);
var ownsParameter = createInstanceMethod.AddParameter ("owns", abr.System_Boolean);
createInstanceMethod.Overrides.Add (abr.IManagedRegistrar_ConstructINativeObject);
var body = createInstanceMethod.CreateBody (out var il);
// We generate something like this:
// if (RuntimeTypeHandle.Equals (typeHandle, typeof (TypeA).TypeHandle))
// return new TypeA (nativeHandle, owns);
// if (RuntimeTypeHandle.Equals (typeHandle, typeof (TypeB).TypeHandle))
// return new TypeB (nativeHandle, owns);
// return null;
var types = GetRelevantTypes (type => type.IsNativeObject () && !type.IsAbstract && !type.IsInterface);
foreach (var type in types) {
var ctorRef = FindINativeObjectConstructor (type);
if (ctorRef is not null) {
var ctor = abr.CurrentAssembly.MainModule.ImportReference (ctorRef);
// we need to preserve the constructor because it might not be used anywhere else
if (IsTrimmed (ctor))
Annotations.Mark (ctor.Resolve ());
if (!ManagedRegistrarStep.IsOpenType (type)) {
EnsureVisible (createInstanceMethod, ctor);
il.Emit (OpCodes.Ldarga_S, typeHandleParameter);
il.Emit (OpCodes.Ldtoken, type);
il.Emit (OpCodes.Call, abr.RuntimeTypeHandle_Equals);
var falseTarget = il.Create (OpCodes.Nop);
il.Emit (OpCodes.Brfalse_S, falseTarget);
il.Emit (OpCodes.Ldarg, nativeHandleParameter);
if (ctor.Parameters [0].ParameterType.Is ("System", "IntPtr"))
il.Emit (OpCodes.Call, abr.NativeObject_op_Implicit_IntPtr);
il.Emit (OpCodes.Ldarg, ownsParameter);
il.Emit (OpCodes.Newobj, ctor);
il.Emit (OpCodes.Ret);
il.Append (falseTarget);
}
}
// In addition to the big lookup method, implement the static factory method on the type:
ImplementConstructINativeObjectFactoryMethod (type, ctorRef);
}
// return default (NSObject)
il.Emit (OpCodes.Ldnull);
il.Emit (OpCodes.Ret);
}
void ImplementConstructNSObjectFactoryMethod (TypeDefinition type, MethodReference ctor)
{
// skip creating the factory for NSObject itself
if (type.Is ("Foundation", "NSObject"))
return;
var createInstanceMethod = type.AddMethod ("_Xamarin_ConstructNSObject", MethodAttributes.Public | MethodAttributes.Static | MethodAttributes.NewSlot | MethodAttributes.HideBySig, abr.Foundation_NSObject);
var nativeHandleParameter = createInstanceMethod.AddParameter ("nativeHandle", abr.ObjCRuntime_NativeHandle);
abr.Foundation_INSObjectFactory.Resolve ().IsPublic = true;
createInstanceMethod.Overrides.Add (abr.INSObjectFactory__Xamarin_ConstructNSObject);
var body = createInstanceMethod.CreateBody (out var il);
if (type.HasGenericParameters) {
ctor = type.CreateMethodReferenceOnGenericType (ctor, type.GenericParameters.ToArray ());
}
// return new TypeA (nativeHandle); // for NativeHandle ctor
// return new TypeA ((IntPtr) nativeHandle); // for IntPtr ctor
il.Emit (OpCodes.Ldarg, nativeHandleParameter);
if (ctor.Parameters [0].ParameterType.Is ("System", "IntPtr"))
il.Emit (OpCodes.Call, abr.NativeObject_op_Implicit_IntPtr);
il.Emit (OpCodes.Newobj, ctor);
il.Emit (OpCodes.Ret);
Annotations.Mark (createInstanceMethod);
}
void ImplementConstructINativeObjectFactoryMethod (TypeDefinition type, MethodReference? ctor)
{
// skip creating the factory for NSObject itself
if (type.Is ("Foundation", "NSObject"))
return;
// If the type is a subclass of NSObject, we prefer the NSObject "IntPtr" constructor
var nsobjectConstructor = type.IsNSObject (DerivedLinkContext) ? FindNSObjectConstructor (type) : null;
if (nsobjectConstructor is null && ctor is null)
return;
var createInstanceMethod = type.AddMethod ("_Xamarin_ConstructINativeObject", MethodAttributes.Public | MethodAttributes.Static | MethodAttributes.NewSlot | MethodAttributes.HideBySig, abr.ObjCRuntime_INativeObject);
var nativeHandleParameter = createInstanceMethod.AddParameter ("nativeHandle", abr.ObjCRuntime_NativeHandle);
var ownsParameter = createInstanceMethod.AddParameter ("owns", abr.System_Boolean);
abr.INativeObject__Xamarin_ConstructINativeObject.Resolve ().IsPublic = true;
createInstanceMethod.Overrides.Add (abr.INativeObject__Xamarin_ConstructINativeObject);
var body = createInstanceMethod.CreateBody (out var il);
if (nsobjectConstructor is not null) {
// var instance = new TypeA (nativeHandle);
// // alternatively with a cast: new TypeA ((IntPtr) nativeHandle);
// if (instance is not null && owns)
// Runtime.TryReleaseINativeObject (instance);
// return instance;
if (type.HasGenericParameters) {
nsobjectConstructor = type.CreateMethodReferenceOnGenericType (nsobjectConstructor, type.GenericParameters.ToArray ());
}
il.Emit (OpCodes.Ldarg, nativeHandleParameter);
if (nsobjectConstructor.Parameters [0].ParameterType.Is ("System", "IntPtr"))
il.Emit (OpCodes.Call, abr.NativeObject_op_Implicit_IntPtr);
il.Emit (OpCodes.Newobj, nsobjectConstructor);
var falseTarget = il.Create (OpCodes.Nop);
il.Emit (OpCodes.Dup);
il.Emit (OpCodes.Ldnull);
il.Emit (OpCodes.Cgt_Un);
il.Emit (OpCodes.Ldarg, ownsParameter);
il.Emit (OpCodes.And);
il.Emit (OpCodes.Brfalse_S, falseTarget);
il.Emit (OpCodes.Dup);
il.Emit (OpCodes.Call, abr.Runtime_TryReleaseINativeObject);
il.Append (falseTarget);
il.Emit (OpCodes.Ret);
} else if (ctor is not null) {
// return new TypeA (nativeHandle, owns); // for NativeHandle ctor
// return new TypeA ((IntPtr) nativeHandle, owns); // IntPtr ctor
if (type.HasGenericParameters) {
ctor = type.CreateMethodReferenceOnGenericType (ctor, type.GenericParameters.ToArray ());
}
il.Emit (OpCodes.Ldarg, nativeHandleParameter);
if (ctor.Parameters [0].ParameterType.Is ("System", "IntPtr"))
il.Emit (OpCodes.Call, abr.NativeObject_op_Implicit_IntPtr);
il.Emit (OpCodes.Ldarg, ownsParameter);
il.Emit (OpCodes.Newobj, ctor);
il.Emit (OpCodes.Ret);
} else {
throw new UnreachableException ();
}
Annotations.Mark (createInstanceMethod);
}
static MethodReference? FindNSObjectConstructor (TypeDefinition type)
{
return FindConstructorWithOneParameter ("ObjCRuntime", "NativeHandle")
?? FindConstructorWithOneParameter ("System", "IntPtr");
MethodReference? FindConstructorWithOneParameter (string ns, string cls)
=> type.Methods.SingleOrDefault (method =>
method.IsConstructor
&& !method.IsStatic
&& method.HasParameters
&& method.Parameters.Count == 1
&& method.Parameters [0].ParameterType.Is (ns, cls));
}
static MethodReference? FindINativeObjectConstructor (TypeDefinition type)
{
return FindConstructorWithTwoParameters ("ObjCRuntime", "NativeHandle", "System", "Boolean")
?? FindConstructorWithTwoParameters ("System", "IntPtr", "System", "Boolean");
MethodReference? FindConstructorWithTwoParameters (string ns1, string cls1, string ns2, string cls2)
=> type.Methods.SingleOrDefault (method =>
method.IsConstructor
&& !method.IsStatic
&& method.HasParameters
&& method.Parameters.Count == 2
&& method.Parameters [0].ParameterType.Is (ns1, cls1)
&& method.Parameters [1].ParameterType.Is (ns2, cls2));
}
void GenerateRegisterWrapperTypes (TypeDefinition type)
{
var method = type.AddMethod ("RegisterWrapperTypes", MethodAttributes.Private | MethodAttributes.Final | MethodAttributes.Virtual | MethodAttributes.NewSlot | MethodAttributes.HideBySig, abr.System_Void);
@ -473,13 +722,32 @@ namespace Xamarin.Linker {
return $"{method?.ReturnType?.FullName ?? "(null)"} {method?.DeclaringType?.FullName ?? "(null)"}::{method?.Name ?? "(null)"} ({string.Join (", ", method?.Parameters?.Select (v => v?.ParameterType?.FullName + " " + v?.Name) ?? Array.Empty<string> ())})";
}
void EnsureVisible (MethodDefinition caller, TypeDefinition type)
static void EnsureVisible (MethodDefinition caller, MethodReference methodRef)
{
var method = methodRef.Resolve ();
var type = method.DeclaringType.Resolve ();
if (type.IsNested) {
type.IsNestedPublic = true;
if (!method.IsPublic) {
method.IsFamilyOrAssembly = true;
}
EnsureVisible (caller, type);
} else if (!method.IsPublic) {
method.IsFamilyOrAssembly = true;
}
}
static void EnsureVisible (MethodDefinition caller, TypeReference typeRef)
{
var type = typeRef.Resolve ();
if (type.IsNested) {
if (!type.IsNestedPublic) {
type.IsNestedAssembly = true;
}
EnsureVisible (caller, type.DeclaringType);
} else {
type.IsPublic = true;
} else if (!type.IsPublic) {
type.IsNotPublic = true;
}
}

Просмотреть файл

@ -158,9 +158,14 @@ namespace Xamarin.Linker {
assembly.MainModule.Types.Add (additionalType);
// Make sure the linker saves any changes in the assembly.
if (modified) {
DerivedLinkContext.Annotations.SetCustomAnnotation ("ManagedRegistrarStep", assembly, current_trampoline_lists);
DerivedLinkContext.Annotations.SetCustomAnnotation ("ManagedRegistrarStep", assembly, current_trampoline_lists);
if (modified)
abr.SaveCurrentAssembly ();
if (App.XamarinRuntime == XamarinRuntime.MonoVM) {
var md = abr.RegistrarHelper_RuntimeTypeHandleEquals.Resolve ();
md.IsPublic = true;
Annotations.Mark (md);
}
abr.ClearCurrentAssembly ();
@ -292,7 +297,7 @@ namespace Xamarin.Linker {
infos.Add (new TrampolineInfo (callback, method, name));
// If the target method is marked, then we must mark the trampoline as well.
method.CustomAttributes.Add (CreateDynamicDependencyAttribute (callbackType, callback.Name));
method.CustomAttributes.Add (abr.CreateDynamicDependencyAttribute (callback.Name, callbackType));
callback.AddParameter ("pobj", abr.System_IntPtr);
@ -1058,7 +1063,7 @@ namespace Xamarin.Linker {
return false;
}
bool IsOpenType (TypeReference tr)
internal static bool IsOpenType (TypeReference tr)
{
if (tr is GenericParameter)
return true;
@ -1080,13 +1085,13 @@ namespace Xamarin.Linker {
return IsOpenType (tr.Resolve ());
}
void EnsureVisible (MethodDefinition caller, FieldDefinition field)
static void EnsureVisible (MethodDefinition caller, FieldDefinition field)
{
field.IsPublic = true;
EnsureVisible (caller, field.DeclaringType);
}
void EnsureVisible (MethodDefinition caller, TypeDefinition type)
static void EnsureVisible (MethodDefinition caller, TypeDefinition type)
{
if (type.IsNested) {
type.IsNestedPublic = true;
@ -1096,7 +1101,7 @@ namespace Xamarin.Linker {
}
}
void EnsureVisible (MethodDefinition caller, MethodReference method)
static void EnsureVisible (MethodDefinition caller, MethodReference method)
{
var md = method.Resolve ();
md.IsPublic = true;
@ -1121,14 +1126,6 @@ namespace Xamarin.Linker {
return unmanagedCallersAttribute;
}
CustomAttribute CreateDynamicDependencyAttribute (TypeDefinition type, string member)
{
var attribute = new CustomAttribute (abr.DynamicDependencyAttribute_ctor__String_Type);
attribute.ConstructorArguments.Add (new CustomAttributeArgument (abr.System_String, member));
attribute.ConstructorArguments.Add (new CustomAttributeArgument (abr.System_Type, type));
return attribute;
}
void GenerateConversionToManaged (MethodDefinition method, ILProcessor il, TypeReference inputType, TypeReference outputType, string descriptiveMethodName, int parameter, out TypeReference nativeCallerType)
{
// This is a mirror of the native method xamarin_generate_conversion_to_managed (for the dynamic registrar).

Просмотреть файл

@ -27,8 +27,9 @@ namespace Xamarin.Linker.Steps {
}
#if NET
public override void ProcessAssembly (AssemblyDefinition assembly)
protected override void Process (AssemblyDefinition assembly)
{
base.Process (assembly);
ProcessAssemblyAttributes (assembly);
}
#else
@ -62,6 +63,10 @@ namespace Xamarin.Linker.Steps {
// (a) we're potentially processing a different assembly and `is_active` represent the current one
// (b) it will try to fetch the [Preserve] attribute on the type (and it's not there) as `base` would
var type = tr.Resolve ();
#if NET
PreserveType (type, attribute);
#else
Annotations.Mark (type);
if (attribute.HasFields) {
foreach (var named_argument in attribute.Fields) {
@ -69,6 +74,7 @@ namespace Xamarin.Linker.Steps {
Annotations.SetPreserve (type, TypePreserve.All);
}
}
#endif
// In .NET6, ApplyPreserveAttribute no longer runs on all assemblies.
// [assembly: Preserve (typeof (SomeAttribute))] no longer gives SomeAttribute "Preserve" semantics.

36
tools/mtouch/Errors.designer.cs сгенерированный
Просмотреть файл

@ -3811,6 +3811,24 @@ namespace Xamarin.Bundler {
}
}
/// <summary>
/// Looks up a localized string similar to Could not extract the native framework &apos;{0}&apos; from the assembly &apos;{1}&apos;, because it doesn&apos;t contain the resource &apos;{2}&apos;..
/// </summary>
public static string MX1307 {
get {
return ResourceManager.GetString("MX1307", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Could not extract the native library &apos;{0}&apos; from the assembly &apos;{1}&apos;, because it doesn&apos;t contain the resource &apos;{2}&apos;..
/// </summary>
public static string MX1308 {
get {
return ResourceManager.GetString("MX1308", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to One or more reference(s) to type &apos;{0}&apos; already exists inside &apos;{1}&apos; before linking
/// .
@ -3985,6 +4003,15 @@ namespace Xamarin.Bundler {
}
}
/// <summary>
/// Looks up a localized string similar to Unable to apply the conditional [Preserve] attribute on the member {0}..
/// </summary>
public static string MX2112 {
get {
return ResourceManager.GetString("MX2112", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Could not {0} the assembly &apos;{1}&apos;
/// .
@ -4301,5 +4328,14 @@ namespace Xamarin.Bundler {
return ResourceManager.GetString("MX8055", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Failed to marshal the Objective-C object 0x{0} (type: {1}). Could not find an existing managed instance for this object, nor was it possible to create a new managed instance of generic type {2}..
/// </summary>
public static string MX8056 {
get {
return ResourceManager.GetString("MX8056", resourceCulture);
}
}
}
}

Просмотреть файл

@ -1023,6 +1023,14 @@
<value>Could not decompress the file '{0}'. Please review the build log for more information from the native 'unzip' command.</value>
</data>
<data name="MX1307" xml:space="preserve">
<value>Could not extract the native framework '{0}' from the assembly '{1}', because it doesn't contain the resource '{2}'.</value>
</data>
<data name="MX1308" xml:space="preserve">
<value>Could not extract the native library '{0}' from the assembly '{1}', because it doesn't contain the resource '{2}'.</value>
</data>
<data name="MM1401" xml:space="preserve">
<value>The required 'Xamarin.Mac.dll' assembly is missing from the references
</value>
@ -1338,6 +1346,11 @@
</value>
</data>
<data name="MX2112" xml:space="preserve">
<!-- This is a warning -->
<value>Unable to apply the conditional [Preserve] attribute on the member {0}.</value>
</data>
<!-- 2200 -> 2299 is used by/reserved for ExceptionalSubStep subclasses in the linker -->
<!-- 220x: PreserveSmartEnumConversionsSubStep -->
<!-- 221x: RemoveBitcodeIncompatibleCodeStep -->
@ -1371,6 +1384,15 @@
<!-- 234x: ExtractBindingLibrariesStep -->
<!-- 235x: LoadNonSkippedAssembliesStep -->
<!-- 236x: RegistrarStep -->
<!-- 237x: ComputeAOTArguments -->
<!-- 238x: RegistrarRemovalTrackingStep -->
<!-- 239x: CoreTypeMapStep -->
<!-- 240x: BackingFieldDelayHandler -->
<!-- 241x: BackingFieldReintroductionSubStep -->
<!-- 242x: MarkIProtocolHandler -->
<!-- 243x: ManagedRegistrarStep -->
<!-- 244x: ManagedRegistrarLookupTablesStep -->
<!-- 245x: ApplyPreserveAttribute -->
<data name="MX3001" xml:space="preserve">
<value>Could not {0} the assembly '{1}'
@ -2258,4 +2280,8 @@
<data name="MX8055" xml:space="preserve">
<value>Could not find the type 'ObjCRuntime.__Registrar__' in the assembly '{0}'.</value>
</data>
<data name="MX8056" xml:space="preserve">
<value>Failed to marshal the Objective-C object 0x{0} (type: {1}). Could not find an existing managed instance for this object, nor was it possible to create a new managed instance of generic type {2}.</value>
</data>
</root>