Skip to content

Commit

Permalink
Merge branch 'main' into dev/grendel/blazor-hang
Browse files Browse the repository at this point in the history
* main:
  [runtime] Remove the last vestiges of desktop builds (#8810)
  [ci] Don't auto-retry APK test suites. (#8811)
  [Microsoft.Android.Templates] Update EN l10n template strings (#8808)
  Bump to xamarin/Java.Interop/main@651de42 (#8809)
  [Mono.Android] is now "trimming safe" (#8778)
  [Mono.Android] Fix missing enum issues that cause BG8800 warnings. (#8707)
  Bump external/Java.Interop from `3436a30` to `5bca8ad` (#8803)
  Bump to xamarin/monodroid@77124dc1 (#8804)
  Bump to dotnet/installer@e911f5c82c 9.0.100-preview.3.24161.2 (#8802)
  Bump to xamarin/Java.Interop/main@3436a30 (#8799)
  • Loading branch information
grendello committed Mar 15, 2024
2 parents 8887397 + 6fde0f6 commit dc6254d
Show file tree
Hide file tree
Showing 33 changed files with 610 additions and 446 deletions.
2 changes: 1 addition & 1 deletion .external
Original file line number Diff line number Diff line change
@@ -1 +1 @@
xamarin/monodroid:main@e13723e701307f9f6966d4b309c3eba10a741694
xamarin/monodroid:main@77124dc16985a92077e62b0cfeaeb007c4d4fd2a
9 changes: 9 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,13 @@
<PackageReference Update="Irony" Version="1.1.0" />
</ItemGroup>

<!-- Automatically add NRT attribute support for netstandard2.0 projects using NRT -->
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' AND ('$(Nullable)' == 'enable' OR '$(Nullable)' == 'annotations') ">
<Compile Include="$(MSBuildThisFileDirectory)external\Java.Interop\src\utils\NullableAttributes.cs" Visible="false" />
</ItemGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' AND ('$(Nullable)' == 'enable' OR '$(Nullable)' == 'annotations') ">
<DefineConstants>$(DefineConstants);INTERNAL_NULLABLE_ATTRIBUTES</DefineConstants>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ parameters:
artifactSource: ""
artifactFolder: ""
condition: succeeded()
retryCountOnTaskFailure: 1

steps:
- template: /build-tools/automation/yaml-templates/run-dotnet-preview.yaml
Expand All @@ -25,7 +24,6 @@ steps:
-v:n -c ${{ parameters.configuration }} ${{ parameters.extraBuildArgs }}
condition: ${{ parameters.condition }}
continueOnError: true
retryCountOnTaskFailure: ${{ parameters.retryCountOnTaskFailure }}

- script: >
DEST="$(Build.StagingDirectory)/Test${{ parameters.configuration }}/${{ parameters.artifactFolder }}/" &&
Expand Down
55 changes: 55 additions & 0 deletions build-tools/trim-analyzers/trim-analyzers.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<!-- Import this to enable trim warnings of all kinds -->
<Project>
<PropertyGroup>
<!-- Sets assembly metadata, enable analyzers -->
<IsTrimmable>true</IsTrimmable>
<EnableSingleFileAnalyzer>true</EnableSingleFileAnalyzer>
<EnableAotAnalyzer>true</EnableAotAnalyzer>
<!-- In app projects, tells ILLink to emit warnings as errors -->
<ILLinkTreatWarningsAsErrors>true</ILLinkTreatWarningsAsErrors>
<!--
Trim warnings, codes listed here:
* https://github.com/dotnet/runtime/blob/7403a062960d092c73ce3f07d3ff323ffdf7de43/src/tools/illink/src/linker/Resources/Strings.resx
* https://github.com/dotnet/docs/tree/9cb45cf9cd34f3b7259a023c3d92a124a87090d5/docs/core/deploying/trimming/trim-warnings
-->
<WarningsAsErrors>
$(WarningsAsErrors);
IL2000;IL2001;IL2002;IL2003;IL2004;
IL2005;IL2006;IL2007;IL2008;IL2009;
IL2010;IL2011;IL2012;IL2013;IL2014;
IL2015;IL2016;IL2017;IL2018;IL2019;
IL2020;IL2021;IL2022;IL2023;IL2024;
IL2025;IL2026;IL2027;IL2028;IL2029;
IL2030;IL2031;IL2032;IL2033;IL2034;
IL2035;IL2036;IL2037;IL2038;IL2039;
IL2040;IL2041;IL2042;IL2043;IL2044;
IL2045;IL2046;IL2047;IL2048;IL2049;
IL2050;IL2051;IL2052;IL2053;IL2054;
IL2055;IL2056;IL2057;IL2058;IL2059;
IL2060;IL2061;IL2062;IL2063;IL2064;
IL2065;IL2066;IL2067;IL2068;IL2069;
IL2070;IL2071;IL2072;IL2073;IL2074;
IL2075;IL2076;IL2077;IL2078;IL2079;
IL2080;IL2081;IL2082;IL2083;IL2084;
IL2085;IL2086;IL2087;IL2088;IL2089;
IL2090;IL2091;IL2092;IL2093;IL2094;
IL2095;IL2096;IL2097;IL2098;IL2099;
IL2100;IL2101;IL2102;IL2103;IL2104;
IL2105;IL2106;IL2107;IL2108;IL2109;
IL2110;IL2111;IL2112;IL2113;IL2114;
IL2115;IL2116;IL2117;IL2118;IL2119;
IL2120;IL2121;IL2122;IL2123;IL2124;
IL2125;IL2126;IL2127;IL2128;IL2129;
</WarningsAsErrors>
<!-- In NativeAOT app projects, tells Ilc to emit warnings as errors -->
<IlcTreatWarningsAsErrors>true</IlcTreatWarningsAsErrors>
<!--
NativeAOT warnings, codes listed here:
* https://github.com/dotnet/docs/tree/9cb45cf9cd34f3b7259a023c3d92a124a87090d5/docs/core/deploying/native-aot/warnings
-->
<WarningsAsErrors>
$(WarningsAsErrors);
IL3050;IL3051;IL3052;IL3053;IL3054;IL3055;IL3056;
</WarningsAsErrors>
</PropertyGroup>
</Project>
20 changes: 10 additions & 10 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<Dependencies>
<ProductDependencies>
<Dependency Name="Microsoft.Dotnet.Sdk.Internal" Version="9.0.100-preview.3.24153.2">
<Dependency Name="Microsoft.Dotnet.Sdk.Internal" Version="9.0.100-preview.3.24161.2">
<Uri>https://github.com/dotnet/installer</Uri>
<Sha>893b762b6e36d558df7ae6fccdfd8034f83a1c2e</Sha>
<Sha>e911f5c82cc02aea96e227596e16c830d54cf03a</Sha>
</Dependency>
<Dependency Name="Microsoft.NET.ILLink.Tasks" Version="9.0.0-preview.3.24129.2" CoherentParentDependency="Microsoft.Dotnet.Sdk.Internal">
<Dependency Name="Microsoft.NET.ILLink.Tasks" Version="9.0.0-preview.3.24160.3" CoherentParentDependency="Microsoft.Dotnet.Sdk.Internal">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>5e603d595e63ddc5cdce9777a40608279abdcc37</Sha>
<Sha>3eb8c7f1086b79b28a27b57a935f97be3b7fcccb</Sha>
</Dependency>
<Dependency Name="Microsoft.NETCore.App.Ref" Version="9.0.0-preview.3.24129.2" CoherentParentDependency="Microsoft.Dotnet.Sdk.Internal">
<Dependency Name="Microsoft.NETCore.App.Ref" Version="9.0.0-preview.3.24160.3" CoherentParentDependency="Microsoft.Dotnet.Sdk.Internal">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>5e603d595e63ddc5cdce9777a40608279abdcc37</Sha>
<Sha>3eb8c7f1086b79b28a27b57a935f97be3b7fcccb</Sha>
</Dependency>
<Dependency Name="Microsoft.NET.Workload.Emscripten.Current.Manifest-9.0.100.Transport" Version="9.0.0-preview.3.24126.1" CoherentParentDependency="Microsoft.NETCore.App.Ref">
<Dependency Name="Microsoft.NET.Workload.Emscripten.Current.Manifest-9.0.100.Transport" Version="9.0.0-preview.3.24156.3" CoherentParentDependency="Microsoft.NETCore.App.Ref">
<Uri>https://github.com/dotnet/emsdk</Uri>
<Sha>0f3e462442af5fe65271e3185d5b645ad40a6041</Sha>
<Sha>a5f4de78fca42544771977f8e8e04c4aa83e1d02</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.Cecil" Version="0.11.4-alpha.24120.1" CoherentParentDependency="Microsoft.NET.ILLink.Tasks">
<Dependency Name="Microsoft.DotNet.Cecil" Version="0.11.4-alpha.24158.1" CoherentParentDependency="Microsoft.NET.ILLink.Tasks">
<Uri>https://github.com/dotnet/cecil</Uri>
<Sha>0d0bc8e0f47fdae9834e1eac678f364c50946133</Sha>
<Sha>ba53c75483aa4980a332fa48e61076f80adfec40</Sha>
</Dependency>
</ProductDependencies>
<ToolsetDependencies>
Expand Down
10 changes: 5 additions & 5 deletions eng/Versions.props
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<Project>
<!--Package versions-->
<PropertyGroup>
<MicrosoftDotnetSdkInternalPackageVersion>9.0.100-preview.3.24153.2</MicrosoftDotnetSdkInternalPackageVersion>
<MicrosoftNETILLinkTasksPackageVersion>9.0.0-preview.3.24129.2</MicrosoftNETILLinkTasksPackageVersion>
<MicrosoftNETCoreAppRefPackageVersion>9.0.0-preview.3.24129.2</MicrosoftNETCoreAppRefPackageVersion>
<MicrosoftDotnetSdkInternalPackageVersion>9.0.100-preview.3.24161.2</MicrosoftDotnetSdkInternalPackageVersion>
<MicrosoftNETILLinkTasksPackageVersion>9.0.0-preview.3.24160.3</MicrosoftNETILLinkTasksPackageVersion>
<MicrosoftNETCoreAppRefPackageVersion>9.0.0-preview.3.24160.3</MicrosoftNETCoreAppRefPackageVersion>
<MicrosoftDotNetApiCompatPackageVersion>7.0.0-beta.22103.1</MicrosoftDotNetApiCompatPackageVersion>
<MicrosoftDotNetBuildTasksFeedPackageVersion>7.0.0-beta.22103.1</MicrosoftDotNetBuildTasksFeedPackageVersion>
<MicrosoftNETWorkloadEmscriptenCurrentManifest90100TransportVersion>9.0.0-preview.3.24126.1</MicrosoftNETWorkloadEmscriptenCurrentManifest90100TransportVersion>
<MicrosoftNETWorkloadEmscriptenCurrentManifest90100TransportVersion>9.0.0-preview.3.24156.3</MicrosoftNETWorkloadEmscriptenCurrentManifest90100TransportVersion>
<MicrosoftNETWorkloadEmscriptenPackageVersion>$(MicrosoftNETWorkloadEmscriptenCurrentManifest90100TransportVersion)</MicrosoftNETWorkloadEmscriptenPackageVersion>
<MicrosoftTemplateEngineTasksPackageVersion>7.0.100-rc.1.22410.7</MicrosoftTemplateEngineTasksPackageVersion>
<MicrosoftDotNetCecilPackageVersion>0.11.4-alpha.24120.1</MicrosoftDotNetCecilPackageVersion>
<MicrosoftDotNetCecilPackageVersion>0.11.4-alpha.24158.1</MicrosoftDotNetCecilPackageVersion>
<SystemIOHashingPackageVersion>$(MicrosoftNETCoreAppRefPackageVersion)</SystemIOHashingPackageVersion>
</PropertyGroup>
<PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion external/Java.Interop
44 changes: 44 additions & 0 deletions src/Mono.Android/Android.Hardware/HardwareBuffer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using Android.Runtime;
using Java.Interop;

namespace Android.Hardware;

public partial class HardwareBuffer
{
// These are manually bound because we do not have a way to bind the `long` enum values.
// generator treats them as int, like:
// __args [4] = new JniArgumentValue ((int) usage);

// Metadata.xml XPath method reference: path="/api/package[@name='android.hardware']/class[@name='HardwareBuffer']/method[@name='create' and count(parameter)=5 and parameter[1][@type='int'] and parameter[2][@type='int'] and parameter[3][@type='int'] and parameter[4][@type='int'] and parameter[5][@type='long']]"
[global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android26.0")]
[Register ("create", "(IIIIJ)Landroid/hardware/HardwareBuffer;", "", ApiSince = 26)]
public static unsafe Android.Hardware.HardwareBuffer Create (int width, int height, [global::Android.Runtime.GeneratedEnum] Android.Hardware.HardwareBufferFormat format, int layers, Android.Hardware.HardwareBufferUsage usage)
{
const string __id = "create.(IIIIJ)Landroid/hardware/HardwareBuffer;";
try {
JniArgumentValue* __args = stackalloc JniArgumentValue [5];
__args [0] = new JniArgumentValue (width);
__args [1] = new JniArgumentValue (height);
__args [2] = new JniArgumentValue ((int) format);
__args [3] = new JniArgumentValue (layers);
__args [4] = new JniArgumentValue ((long) usage);
var __rm = _members.StaticMethods.InvokeObjectMethod (__id, __args);
return global::Java.Lang.Object.GetObject<Android.Hardware.HardwareBuffer> (__rm.Handle, JniHandleOwnership.TransferLocalRef)!;
} finally {
}
}

[global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android26.0")]
public unsafe Android.Hardware.HardwareBufferUsage Usage {
// Metadata.xml XPath method reference: path="/api/package[@name='android.hardware']/class[@name='HardwareBuffer']/method[@name='getUsage' and count(parameter)=0]"
[Register ("getUsage", "()J", "", ApiSince = 26)]
get {
const string __id = "getUsage.()J";
try {
var __rm = _members.InstanceMethods.InvokeAbstractInt64Method (__id, this, null);
return (Android.Hardware.HardwareBufferUsage) __rm!;
} finally {
}
}
}
}
64 changes: 64 additions & 0 deletions src/Mono.Android/Android.Hardware/HardwareBufferUsage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
namespace Android.Hardware;

[System.Flags]
[global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android26.0")]
public enum HardwareBufferUsage : long
{
None = 0,

// Metadata.xml XPath field reference: path="/api/package[@name='android.hardware']/class[@name='HardwareBuffer']/field[@name='USAGE_COMPOSER_OVERLAY']"
[global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android33.0")]
UsageComposerOverlay = 2048,

// Metadata.xml XPath field reference: path="/api/package[@name='android.hardware']/class[@name='HardwareBuffer']/field[@name='USAGE_CPU_READ_OFTEN']"
[global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android26.0")]
UsageCpuReadOften = 3,

// Metadata.xml XPath field reference: path="/api/package[@name='android.hardware']/class[@name='HardwareBuffer']/field[@name='USAGE_CPU_READ_RARELY']"
[global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android26.0")]
UsageCpuReadRarely = 2,

// Metadata.xml XPath field reference: path="/api/package[@name='android.hardware']/class[@name='HardwareBuffer']/field[@name='USAGE_CPU_WRITE_OFTEN']"
[global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android26.0")]
UsageCpuWriteOften = 48,

// Metadata.xml XPath field reference: path="/api/package[@name='android.hardware']/class[@name='HardwareBuffer']/field[@name='USAGE_CPU_WRITE_RARELY']"
[global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android26.0")]
UsageCpuWriteRarely = 32,

// Metadata.xml XPath field reference: path="/api/package[@name='android.hardware']/class[@name='HardwareBuffer']/field[@name='USAGE_FRONT_BUFFER']"
[global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android33.0")]
UsageFrontBuffer = 4294967296,

// Metadata.xml XPath field reference: path="/api/package[@name='android.hardware']/class[@name='HardwareBuffer']/field[@name='USAGE_GPU_COLOR_OUTPUT']"
[global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android26.0")]
UsageGpuColorOutput = 512,

// Metadata.xml XPath field reference: path="/api/package[@name='android.hardware']/class[@name='HardwareBuffer']/field[@name='USAGE_GPU_CUBE_MAP']"
[global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android28.0")]
UsageGpuCubeMap = 33554432,

// Metadata.xml XPath field reference: path="/api/package[@name='android.hardware']/class[@name='HardwareBuffer']/field[@name='USAGE_GPU_DATA_BUFFER']"
[global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android26.0")]
UsageGpuDataBuffer = 16777216,

// Metadata.xml XPath field reference: path="/api/package[@name='android.hardware']/class[@name='HardwareBuffer']/field[@name='USAGE_GPU_MIPMAP_COMPLETE']"
[global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android28.0")]
UsageGpuMipmapComplete = 67108864,

// Metadata.xml XPath field reference: path="/api/package[@name='android.hardware']/class[@name='HardwareBuffer']/field[@name='USAGE_GPU_SAMPLED_IMAGE']"
[global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android26.0")]
UsageGpuSampledImage = 256,

// Metadata.xml XPath field reference: path="/api/package[@name='android.hardware']/class[@name='HardwareBuffer']/field[@name='USAGE_PROTECTED_CONTENT']"
[global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android26.0")]
UsageProtectedContent = 16384,

// Metadata.xml XPath field reference: path="/api/package[@name='android.hardware']/class[@name='HardwareBuffer']/field[@name='USAGE_SENSOR_DIRECT_DATA']"
[global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android26.0")]
UsageSensorDirectData = 8388608,

// Metadata.xml XPath field reference: path="/api/package[@name='android.hardware']/class[@name='HardwareBuffer']/field[@name='USAGE_VIDEO_ENCODE']"
[global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android26.0")]
UsageVideoEncode = 65536
}
11 changes: 10 additions & 1 deletion src/Mono.Android/Android.OS/AsyncTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,16 @@ namespace Android.OS {

[global::System.Runtime.Versioning.ObsoletedOSPlatform ("android30.0")]
[Register ("android/os/AsyncTask", DoNotGenerateAcw=true)]
public abstract class AsyncTask<TParams, TProgress, TResult> : AsyncTask {
public abstract class AsyncTask<
[DynamicallyAccessedMembers (Constructors)]
TParams,
[DynamicallyAccessedMembers (Constructors)]
TProgress,
[DynamicallyAccessedMembers (Constructors)]
TResult
> : AsyncTask {

const DynamicallyAccessedMemberTypes Constructors = DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors;

static IntPtr java_class_handle;
internal static IntPtr class_ref {
Expand Down
20 changes: 17 additions & 3 deletions src/Mono.Android/Android.Runtime/AndroidEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public static class AndroidEnvironment {
static IX509TrustManager? sslTrustManager;
static KeyStore? certStore;
static object lock_ = new object ();
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
static Type? httpMessageHandlerType;

static void SetupTrustManager ()
Expand Down Expand Up @@ -335,11 +336,18 @@ static IWebProxy GetDefaultProxy ()
[DynamicDependency (DynamicallyAccessedMemberTypes.PublicParameterlessConstructor, typeof (Xamarin.Android.Net.AndroidMessageHandler))]
static object GetHttpMessageHandler ()
{
// FIXME: https://github.com/xamarin/xamarin-android/issues/8797
// Note that this is a problem for custom $(AndroidHttpClientHandlerType) or $XA_HTTP_CLIENT_HANDLER_TYPE
[UnconditionalSuppressMessage ("Trimming", "IL2057", Justification = "DynamicDependency should preserve AndroidMessageHandler.")]
[return: DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
static Type TypeGetType (string typeName) =>
Type.GetType (typeName, throwOnError: false);

if (httpMessageHandlerType is null) {
var handlerTypeName = Environment.GetEnvironmentVariable ("XA_HTTP_CLIENT_HANDLER_TYPE")?.Trim ();
Type? handlerType = null;
if (!String.IsNullOrEmpty (handlerTypeName))
handlerType = Type.GetType (handlerTypeName, throwOnError: false);
handlerType = TypeGetType (handlerTypeName);

// We don't do any type checking or casting here to avoid dependency on System.Net.Http in Mono.Android.dll
if (handlerType is null || !IsAcceptableHttpMessageHandlerType (handlerType)) {
Expand Down Expand Up @@ -369,13 +377,19 @@ static bool IsAcceptableHttpMessageHandlerType (Type handlerType)
return true;
}

static bool Extends (Type handlerType, string baseTypeName) {
static bool Extends (
Type handlerType,
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
string baseTypeName)
{
var baseType = Type.GetType (baseTypeName, throwOnError: false);
return baseType?.IsAssignableFrom (handlerType) ?? false;
}

static Type GetFallbackHttpMessageHandlerType (string typeName = "Xamarin.Android.Net.AndroidMessageHandler, Mono.Android")
[return: DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
static Type GetFallbackHttpMessageHandlerType ()
{
const string typeName = "Xamarin.Android.Net.AndroidMessageHandler, Mono.Android";
var handlerType = Type.GetType (typeName, throwOnError: false)
?? throw new InvalidOperationException ($"The {typeName} was not found. The type was probably linked away.");

Expand Down
Loading

0 comments on commit dc6254d

Please sign in to comment.