Skip to content

Commit

Permalink
Merge branch 'main' into dev/grendel/extended-timing
Browse files Browse the repository at this point in the history
* main:
  [Mono.Android] fix a set of the "easiest" trimmer warnings (#8731)
  Bump to dotnet/installer@0a73f814e1 9.0.100-preview.2.24122.3 (#8716)
  • Loading branch information
grendello committed Feb 26, 2024
2 parents c409721 + a82ac4e commit 3714c16
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 44 deletions.
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.2.24106.6">
<Dependency Name="Microsoft.Dotnet.Sdk.Internal" Version="9.0.100-preview.2.24122.3">
<Uri>https://github.com/dotnet/installer</Uri>
<Sha>fb7b9a4b9e578fa8c9f5fb67e22daf4b0d22668e</Sha>
<Sha>0a73f814e19c9a239371cb732c9d1257e10fb8a2</Sha>
</Dependency>
<Dependency Name="Microsoft.NET.ILLink.Tasks" Version="9.0.0-preview.2.24080.1" CoherentParentDependency="Microsoft.Dotnet.Sdk.Internal">
<Dependency Name="Microsoft.NET.ILLink.Tasks" Version="9.0.0-preview.2.24122.2" CoherentParentDependency="Microsoft.Dotnet.Sdk.Internal">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>d40c654c274fe4f4afe66328f0599130f3eb2ea6</Sha>
<Sha>dcc66a7ca25696a2326f296c3d8d3ac5a13f0524</Sha>
</Dependency>
<Dependency Name="Microsoft.NETCore.App.Ref" Version="9.0.0-preview.2.24080.1" CoherentParentDependency="Microsoft.Dotnet.Sdk.Internal">
<Dependency Name="Microsoft.NETCore.App.Ref" Version="9.0.0-preview.2.24122.2" CoherentParentDependency="Microsoft.Dotnet.Sdk.Internal">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>d40c654c274fe4f4afe66328f0599130f3eb2ea6</Sha>
<Sha>dcc66a7ca25696a2326f296c3d8d3ac5a13f0524</Sha>
</Dependency>
<Dependency Name="Microsoft.NET.Workload.Emscripten.Current.Manifest-9.0.100.Transport" Version="9.0.0-preview.2.24076.1" CoherentParentDependency="Microsoft.NETCore.App.Ref">
<Dependency Name="Microsoft.NET.Workload.Emscripten.Current.Manifest-9.0.100.Transport" Version="9.0.0-preview.2.24120.1" CoherentParentDependency="Microsoft.NETCore.App.Ref">
<Uri>https://github.com/dotnet/emsdk</Uri>
<Sha>687be2a32a302aaade82380c0eaafa5af85fb4da</Sha>
<Sha>258b51a8e5f5bea07766ab99d2aaa75582d1ceb9</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.Cecil" Version="0.11.4-alpha.24065.1" CoherentParentDependency="Microsoft.NET.ILLink.Tasks">
<Dependency Name="Microsoft.DotNet.Cecil" Version="0.11.4-alpha.24119.1" CoherentParentDependency="Microsoft.NET.ILLink.Tasks">
<Uri>https://github.com/dotnet/cecil</Uri>
<Sha>b8c2293cd1cbd9d0fe6f32d7b5befbd526b5a175</Sha>
<Sha>61250b0ed403b3f9b69a33f7d8f66f311338d6a1</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.2.24106.6</MicrosoftDotnetSdkInternalPackageVersion>
<MicrosoftNETILLinkTasksPackageVersion>9.0.0-preview.2.24080.1</MicrosoftNETILLinkTasksPackageVersion>
<MicrosoftNETCoreAppRefPackageVersion>9.0.0-preview.2.24080.1</MicrosoftNETCoreAppRefPackageVersion>
<MicrosoftDotnetSdkInternalPackageVersion>9.0.100-preview.2.24122.3</MicrosoftDotnetSdkInternalPackageVersion>
<MicrosoftNETILLinkTasksPackageVersion>9.0.0-preview.2.24122.2</MicrosoftNETILLinkTasksPackageVersion>
<MicrosoftNETCoreAppRefPackageVersion>9.0.0-preview.2.24122.2</MicrosoftNETCoreAppRefPackageVersion>
<MicrosoftDotNetApiCompatPackageVersion>7.0.0-beta.22103.1</MicrosoftDotNetApiCompatPackageVersion>
<MicrosoftDotNetBuildTasksFeedPackageVersion>7.0.0-beta.22103.1</MicrosoftDotNetBuildTasksFeedPackageVersion>
<MicrosoftNETWorkloadEmscriptenCurrentManifest90100TransportVersion>9.0.0-preview.2.24076.1</MicrosoftNETWorkloadEmscriptenCurrentManifest90100TransportVersion>
<MicrosoftNETWorkloadEmscriptenCurrentManifest90100TransportVersion>9.0.0-preview.2.24120.1</MicrosoftNETWorkloadEmscriptenCurrentManifest90100TransportVersion>
<MicrosoftNETWorkloadEmscriptenPackageVersion>$(MicrosoftNETWorkloadEmscriptenCurrentManifest90100TransportVersion)</MicrosoftNETWorkloadEmscriptenPackageVersion>
<MicrosoftTemplateEngineTasksPackageVersion>7.0.100-rc.1.22410.7</MicrosoftTemplateEngineTasksPackageVersion>
<MicrosoftDotNetCecilPackageVersion>0.11.4-alpha.24065.1</MicrosoftDotNetCecilPackageVersion>
<MicrosoftDotNetCecilPackageVersion>0.11.4-alpha.24119.1</MicrosoftDotNetCecilPackageVersion>
<SystemIOHashingPackageVersion>$(MicrosoftNETCoreAppRefPackageVersion)</SystemIOHashingPackageVersion>
</PropertyGroup>
<PropertyGroup>
Expand Down
12 changes: 11 additions & 1 deletion src/Mono.Android/Android.Graphics/Color.cs
Original file line number Diff line number Diff line change
Expand Up @@ -395,11 +395,18 @@ public static void RGBToHSV (int red, int green, int blue, float[] hsv)

public class ColorValueMarshaler : JniValueMarshaler<Color>
{
const DynamicallyAccessedMemberTypes ConstructorsAndInterfaces = DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors | DynamicallyAccessedMemberTypes.Interfaces;
const string ExpressionRequiresUnreferencedCode = "System.Linq.Expression usage may trim away required code.";

public override Type MarshalType {
get { return typeof (int); }
}

public override Color CreateGenericValue (ref JniObjectReference reference, JniObjectReferenceOptions options, Type targetType)
public override Color CreateGenericValue (
ref JniObjectReference reference,
JniObjectReferenceOptions options,
[DynamicallyAccessedMembers (ConstructorsAndInterfaces)]
Type targetType)
{
throw new NotImplementedException ();
}
Expand All @@ -414,6 +421,7 @@ public override void DestroyGenericArgumentState (Color value, ref JniValueMarsh
throw new NotImplementedException ();
}

[RequiresUnreferencedCode (ExpressionRequiresUnreferencedCode)]
public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, ParameterAttributes synchronize, Type targetType)
{
var c = typeof (Color).GetConstructor (new[]{typeof (int)})!;
Expand All @@ -424,6 +432,7 @@ public override Expression CreateParameterToManagedExpression (JniValueMarshaler
return v;
}

[RequiresUnreferencedCode (ExpressionRequiresUnreferencedCode)]
public override Expression CreateParameterFromManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, ParameterAttributes synchronize)
{
var r = Expression.Variable (MarshalType, sourceValue.Name + "_p");
Expand All @@ -433,6 +442,7 @@ public override Expression CreateParameterFromManagedExpression (JniValueMarshal
return r;
}

[RequiresUnreferencedCode (ExpressionRequiresUnreferencedCode)]
public override Expression CreateReturnValueFromManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue)
{
return CreateParameterFromManagedExpression (context, sourceValue, 0);
Expand Down
11 changes: 10 additions & 1 deletion src/Mono.Android/Android.Runtime/IJavaObjectValueMarshaler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,16 @@ namespace Android.Runtime
{
sealed class IJavaObjectValueMarshaler : JniValueMarshaler<IJavaObject> {

const DynamicallyAccessedMemberTypes ConstructorsAndInterfaces = DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors | DynamicallyAccessedMemberTypes.Interfaces;
const string ExpressionRequiresUnreferencedCode = "System.Linq.Expression usage may trim away required code.";

internal static IJavaObjectValueMarshaler Instance = new IJavaObjectValueMarshaler ();

public override IJavaObject CreateGenericValue (ref JniObjectReference reference, JniObjectReferenceOptions options, Type? targetType)
public override IJavaObject CreateGenericValue (
ref JniObjectReference reference,
JniObjectReferenceOptions options,
[DynamicallyAccessedMembers (ConstructorsAndInterfaces)]
Type? targetType)
{
throw new NotImplementedException ();
}
Expand All @@ -27,6 +34,7 @@ public override void DestroyGenericArgumentState ([AllowNull]IJavaObject value,
throw new NotImplementedException ();
}

[RequiresUnreferencedCode (ExpressionRequiresUnreferencedCode)]
public override Expression CreateReturnValueFromManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue)
{
return Expression.Call (
Expand All @@ -36,6 +44,7 @@ public override Expression CreateReturnValueFromManagedExpression (JniValueMarsh
sourceValue);
}

[RequiresUnreferencedCode (ExpressionRequiresUnreferencedCode)]
public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, ParameterAttributes synchronize, Type? targetType)
{
var r = Expression.Variable (targetType, sourceValue.Name + "_val");
Expand Down
2 changes: 2 additions & 0 deletions src/Mono.Android/System.Drawing/PointConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

using System.Collections;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.ComponentModel.Design.Serialization;
using System.Runtime.CompilerServices;
Expand Down Expand Up @@ -133,6 +134,7 @@ public override bool GetCreateInstanceSupported (ITypeDescriptorContext context)
return true;
}

[RequiresUnreferencedCode ("The Type of value cannot be statically discovered.")]
public override PropertyDescriptorCollection? GetProperties (
ITypeDescriptorContext context,
object value, Attribute[] attributes)
Expand Down
2 changes: 2 additions & 0 deletions src/Mono.Android/System.Drawing/RectangleConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

using System.ComponentModel;
using System.Collections;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Text;
using System.ComponentModel.Design.Serialization;
Expand Down Expand Up @@ -147,6 +148,7 @@ public override bool GetCreateInstanceSupported (ITypeDescriptorContext context)
return true;
}

[RequiresUnreferencedCode ("The Type of value cannot be statically discovered.")]
public override PropertyDescriptorCollection? GetProperties (
ITypeDescriptorContext context,
object value, Attribute[] attributes)
Expand Down
2 changes: 2 additions & 0 deletions src/Mono.Android/System.Drawing/SizeConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

using System.Collections;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.ComponentModel.Design.Serialization;
using System.Reflection;
Expand Down Expand Up @@ -135,6 +136,7 @@ public override bool GetCreateInstanceSupported (ITypeDescriptorContext context)
return true;
}

[RequiresUnreferencedCode ("The Type of value cannot be statically discovered.")]
public override PropertyDescriptorCollection? GetProperties (
ITypeDescriptorContext context,
object value, Attribute[] attributes)
Expand Down
2 changes: 2 additions & 0 deletions src/Mono.Android/System.Drawing/SizeFConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
using System;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.ComponentModel.Design.Serialization;
using System.Reflection;
Expand Down Expand Up @@ -118,6 +119,7 @@ public override bool GetCreateInstanceSupported (ITypeDescriptorContext context)
return true;
}

[RequiresUnreferencedCode ("The Type of value cannot be statically discovered.")]
public override PropertyDescriptorCollection? GetProperties (ITypeDescriptorContext context, object value, Attribute[] attributes)
{
if (value is SizeF)
Expand Down
11 changes: 3 additions & 8 deletions src/Mono.Android/Xamarin.Android.Net/AndroidClientHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -313,14 +313,9 @@ protected virtual Task SetupRequest (HttpRequestMessage request, HttpURLConnecti
object? GetUnderlyingHandler ()
{
var fieldName = "_nativeHandler";
FieldInfo? field = null;

for (var type = GetType (); type != null; type = type.BaseType) {
field = type.GetField (fieldName, BindingFlags.Instance | BindingFlags.NonPublic);
if (field != null)
break;
}

const BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic;
FieldInfo? field = typeof (HttpClientHandler).GetField (fieldName, flags) ??
typeof (HttpMessageHandler).GetField (fieldName, flags);
if (field == null) {
throw new InvalidOperationException ($"Field '{fieldName}' is missing from type '{GetType ()}'.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,19 +111,17 @@ public void BuildBasicApplicationReleaseProfiledAotWithoutDefaultProfile ()
}

[Test]
[TestCase ("テスト", false, false, true)]
[TestCase ("テスト", true, true, false)]
[TestCase ("テスト", true, false, true)]
[TestCase ("随机生成器", false, false, true)]
[TestCase ("随机生成器", true, true, false)]
[TestCase ("随机生成器", true, false, true)]
[TestCase ("中国", false, false, true)]
[TestCase ("中国", true, true, false)]
[TestCase ("中国", true, false, true)]
public void BuildAotApplicationWithSpecialCharactersInProject (string testName, bool isRelease, bool aot, bool expectedResult)
[TestCase ("テスト", false, false)]
[TestCase ("テスト", true, true)]
[TestCase ("テスト", true, false)]
[TestCase ("随机生成器", false, false)]
[TestCase ("随机生成器", true, true)]
[TestCase ("随机生成器", true, false)]
[TestCase ("中国", false, false)]
[TestCase ("中国", true, true)]
[TestCase ("中国", true, false)]
public void BuildAotApplicationWithSpecialCharactersInProject (string testName, bool isRelease, bool aot)
{
if (!IsWindows)
expectedResult = true;
var rootPath = Path.Combine (Root, "temp", TestName);
var proj = new XamarinAndroidApplicationProject () {
ProjectName = testName,
Expand All @@ -132,13 +130,7 @@ public void BuildAotApplicationWithSpecialCharactersInProject (string testName,
};
proj.SetAndroidSupportedAbis ("armeabi-v7a", "arm64-v8a", "x86", "x86_64");
using (var builder = CreateApkBuilder (Path.Combine (rootPath, proj.ProjectName))){
builder.ThrowOnBuildFailure = false;
Assert.AreEqual (expectedResult, builder.Build (proj), "Build should have succeeded.");
if (!expectedResult) {
var aotFailed = builder.LastBuildOutput.ContainsText ("Precompiling failed");
var aapt2Failed = builder.LastBuildOutput.ContainsText ("APT2265");
Assert.IsTrue (aotFailed || aapt2Failed, "Error APT2265 or an AOT error should have been raised.");
}
Assert.IsTrue (builder.Build (proj), "Build should have succeeded.");
}
}

Expand Down

0 comments on commit 3714c16

Please sign in to comment.