Skip to content

Commit

Permalink
Merge branch 'main' into dev/grendel/blobs-in-lib
Browse files Browse the repository at this point in the history
* main:
  [tests] fix duplicate sources in `NuGet.config` (#8772)
  Bump to xamarin/monodroid@e13723e701 (#8771)
  Bump to xamarin/xamarin-android-tools/main@37d79c9 (#8752)
  Bump to dotnet/installer@d070660282 9.0.100-preview.3.24126.2 (#8763)
  Bump to xamarin/java.interop/main@14a9470 (#8766)
  $(AndroidPackVersionSuffix)=preview.3; net9 is 34.99.0.preview.3 (#8765)
  [Mono.Android] Do not dispose request content stream in AndroidMessageHandler (#8764)
  Bump com.android.tools:r8 from 8.2.42 to 8.2.47 (#8761)
  [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 Mar 1, 2024
2 parents b3559e6 + e873731 commit 46f08c8
Show file tree
Hide file tree
Showing 18 changed files with 112 additions and 81 deletions.
2 changes: 1 addition & 1 deletion .external
Original file line number Diff line number Diff line change
@@ -1 +1 @@
xamarin/monodroid:main@905441a990d7daf720bdd4fc2f333fed5be28274
xamarin/monodroid:main@e13723e701307f9f6966d4b309c3eba10a741694
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* Bump first digit of the patch version for feature releases (and reset the first two digits to 0)
-->
<AndroidPackVersion>34.99.0</AndroidPackVersion>
<AndroidPackVersionSuffix>preview.2</AndroidPackVersionSuffix>
<AndroidPackVersionSuffix>preview.3</AndroidPackVersionSuffix>
</PropertyGroup>

<!-- Common <PackageReference/> versions -->
Expand Down
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.3.24126.2">
<Uri>https://github.com/dotnet/installer</Uri>
<Sha>fb7b9a4b9e578fa8c9f5fb67e22daf4b0d22668e</Sha>
<Sha>d070660282eb5f78497310f77093638744112e03</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.24123.1" CoherentParentDependency="Microsoft.Dotnet.Sdk.Internal">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>d40c654c274fe4f4afe66328f0599130f3eb2ea6</Sha>
<Sha>99b76018b6e4edc4ce185dd5f3c5697c6941d88e</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.24123.1" CoherentParentDependency="Microsoft.Dotnet.Sdk.Internal">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>d40c654c274fe4f4afe66328f0599130f3eb2ea6</Sha>
<Sha>99b76018b6e4edc4ce185dd5f3c5697c6941d88e</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.24121.1" CoherentParentDependency="Microsoft.NETCore.App.Ref">
<Uri>https://github.com/dotnet/emsdk</Uri>
<Sha>687be2a32a302aaade82380c0eaafa5af85fb4da</Sha>
<Sha>2d3f1fe4807a21879cedba9d3fde8cd329fb17f2</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.3.24126.2</MicrosoftDotnetSdkInternalPackageVersion>
<MicrosoftNETILLinkTasksPackageVersion>9.0.0-preview.2.24123.1</MicrosoftNETILLinkTasksPackageVersion>
<MicrosoftNETCoreAppRefPackageVersion>9.0.0-preview.2.24123.1</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.24121.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
2 changes: 1 addition & 1 deletion external/Java.Interop
2 changes: 1 addition & 1 deletion external/xamarin-android-tools
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
47 changes: 23 additions & 24 deletions src/Mono.Android/Xamarin.Android.Net/AndroidMessageHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -536,30 +536,29 @@ protected virtual async Task WriteRequestContentToOutput (HttpRequestMessage req
if (request.Content is null)
return;

using (var stream = await request.Content.ReadAsStreamAsync ().ConfigureAwait (false)) {
await stream.CopyToAsync(httpConnection.OutputStream!, 4096, cancellationToken).ConfigureAwait(false);

//
// Rewind the stream to beginning in case the HttpContent implementation
// will be accessed again (e.g. after redirect) and it keeps its stream
// open behind the scenes instead of recreating it on the next call to
// ReadAsStreamAsync. If we don't rewind it, the ReadAsStreamAsync
// call above will throw an exception as we'd be attempting to read an
// already "closed" stream (that is one whose Position is set to its
// end).
//
// This is not a perfect solution since the HttpContent may do weird
// things in its implementation, but it's better than copying the
// content into a buffer since we have no way of knowing how the data is
// read or generated and also we don't want to keep potentially large
// amounts of data in memory (which would happen if we read the content
// into a byte[] buffer and kept it cached for re-use on redirect).
//
// See https://bugzilla.xamarin.com/show_bug.cgi?id=55477
//
if (stream.CanSeek)
stream.Seek (0, SeekOrigin.Begin);
}
var stream = await request.Content.ReadAsStreamAsync ().ConfigureAwait (false);
await stream.CopyToAsync(httpConnection.OutputStream!, 4096, cancellationToken).ConfigureAwait(false);

//
// Rewind the stream to beginning in case the HttpContent implementation
// will be accessed again (e.g. after redirect) and it keeps its stream
// open behind the scenes instead of recreating it on the next call to
// ReadAsStreamAsync. If we don't rewind it, the ReadAsStreamAsync
// call above will throw an exception as we'd be attempting to read an
// already "closed" stream (that is one whose Position is set to its
// end).
//
// This is not a perfect solution since the HttpContent may do weird
// things in its implementation, but it's better than copying the
// content into a buffer since we have no way of knowing how the data is
// read or generated and also we don't want to keep potentially large
// amounts of data in memory (which would happen if we read the content
// into a byte[] buffer and kept it cached for re-use on redirect).
//
// See https://bugzilla.xamarin.com/show_bug.cgi?id=55477
//
if (stream.CanSeek)
stream.Seek (0, SeekOrigin.Begin);
}

internal Task WriteRequestContentToOutputInternal (HttpRequestMessage request, HttpURLConnection httpConnection, CancellationToken cancellationToken)
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
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,6 @@ public void CopyNuGetConfig (string relativeDirectory)

/// <summary>
/// Updates a NuGet.config based on sources in ExtraNuGetConfigSources
/// If target framework is not the latest or default, sources are added for previous releases
/// </summary>
protected void AddNuGetConfigSources (string nugetConfigPath)
{
Expand All @@ -415,14 +414,8 @@ protected void AddNuGetConfigSources (string nugetConfigPath)
ExtraNuGetConfigSources = new List<string> ();
}

if (TargetFramework?.IndexOf ("net8.0", StringComparison.OrdinalIgnoreCase) != -1
|| TargetFrameworks?.IndexOf ("net8.0", StringComparison.OrdinalIgnoreCase) != -1) {
ExtraNuGetConfigSources.Add ("https://api.nuget.org/v3/index.json");
ExtraNuGetConfigSources.Add ("https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json");
}

int sourceIndex = 0;
foreach (var source in ExtraNuGetConfigSources) {
foreach (var source in ExtraNuGetConfigSources.Distinct ()) {
var sourceElement = new XElement ("add");
sourceElement.SetAttributeValue ("key", $"testsource{++sourceIndex}");
sourceElement.SetAttributeValue ("value", source);
Expand Down
2 changes: 1 addition & 1 deletion src/r8/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ repositories {
}

dependencies {
implementation 'com.android.tools:r8:8.2.42'
implementation 'com.android.tools:r8:8.2.47'
}

jar {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,31 @@ async Task<bool> DoDecompression (string urlPath, string encoding, string jsonFi
return true;
}

[Test]
public async Task DoesNotDisposeContentStream()
{
using var listener = new HttpListener ();
listener.Prefixes.Add ("http://+:47663/");
listener.Start ();
listener.BeginGetContext (ar => {
var ctx = listener.EndGetContext (ar);
ctx.Response.StatusCode = 204;
ctx.Response.ContentLength64 = 0;
ctx.Response.Close ();
}, null);

var jsonContent = new StringContent ("hello");
var request = new HttpRequestMessage (HttpMethod.Post, "http://localhost:47663/") { Content = jsonContent };

var response = await new HttpClient (new AndroidMessageHandler ()).SendAsync (request);
Assert.True (response.IsSuccessStatusCode);

var contentValue = await jsonContent.ReadAsStringAsync ();
Assert.AreEqual ("hello", contentValue);

listener.Close ();
}

[Test]
public async Task ServerCertificateCustomValidationCallback_ApproveRequest ()
{
Expand Down

0 comments on commit 46f08c8

Please sign in to comment.