Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Enable DefaultValueAttributeSupport in partial trim mode. #9525

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions build-tools/automation/azure-pipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,16 @@ extends:
artifactSource: bin/Test$(XA.Build.Configuration)/$(DotNetTargetFramework)-android/Mono.Android.NET_Tests-Signed.aab
artifactFolder: $(DotNetTargetFramework)-NoAot

- template: /build-tools/automation/yaml-templates/apk-instrumentation.yaml@self
parameters:
configuration: $(XA.Build.Configuration)
testName: Mono.Android.NET_Tests-TrimModePartial
project: tests/Mono.Android-Tests/Runtime-Microsoft.Android.Sdk/Mono.Android.NET-Tests.csproj
testResultsFiles: TestResult-Mono.Android.NET_Tests-$(XA.Build.Configuration)TrimModePartial.xml
extraBuildArgs: -p:TestsFlavor=TrimModePartial -p:TrimMode=partial
artifactSource: bin/Test$(XA.Build.Configuration)/$(DotNetTargetFramework)-android/Mono.Android.NET_Tests-Signed.aab
artifactFolder: $(DotNetTargetFramework)-TrimModePartial

- template: /build-tools/automation/yaml-templates/apk-instrumentation.yaml@self
parameters:
configuration: $(XA.Build.Configuration)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@
<UseNativeHttpHandler Condition="'$(UseNativeHttpHandler)' == ''">true</UseNativeHttpHandler>
<BuiltInComInteropSupport Condition="'$(BuiltInComInteropSupport)' == ''">false</BuiltInComInteropSupport>
<JsonSerializerIsReflectionEnabledByDefault Condition="'$(JsonSerializerIsReflectionEnabledByDefault)' == '' and '$(TrimMode)' == 'partial'">true</JsonSerializerIsReflectionEnabledByDefault>
<!-- Set to disable throwing behavior, see: https://github.com/dotnet/runtime/issues/109724 -->
<_DefaultValueAttributeSupport Condition="'$(_DefaultValueAttributeSupport)' == '' and '$(TrimMode)' == 'partial'">true</_DefaultValueAttributeSupport>
<MetricsSupport Condition="'$(MetricsSupport)' == ''">false</MetricsSupport>
<AndroidAvoidEmitForPerformance Condition="'$(AndroidAvoidEmitForPerformance)' == ''">$(AvoidEmitForPerformance)</AndroidAvoidEmitForPerformance>
<AndroidAvoidEmitForPerformance Condition="'$(AndroidAvoidEmitForPerformance)' == ''">true</AndroidAvoidEmitForPerformance>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<Compile Include="$(MSBuildThisFileDirectory)System.Text\EncodingTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System.Text.Json\JsonSerializerTest.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System.Threading\InterlockedTest.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System.Xml\XmlSerializer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Java.Interop\JavaObjectExtensionsTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Xamarin.Android.Net\AndroidClientHandlerTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Xamarin.Android.Net\AndroidMessageHandlerTests.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
<AndroidLinkTool Condition=" '$(AndroidLinkTool)' == '' ">r8</AndroidLinkTool>
<TrimMode Condition=" '$(TrimMode)' == '' ">full</TrimMode>
<!-- Trimmer switches required for tests -->
<JsonSerializerIsReflectionEnabledByDefault>true</JsonSerializerIsReflectionEnabledByDefault>
<JsonSerializerIsReflectionEnabledByDefault Condition="'$(TrimMode)' == 'full'">true</JsonSerializerIsReflectionEnabledByDefault>
<_DefaultValueAttributeSupport Condition="'$(TrimMode)' == 'full'">true</_DefaultValueAttributeSupport>
</PropertyGroup>

<ItemGroup>
Expand Down
23 changes: 23 additions & 0 deletions tests/Mono.Android-Tests/System.Xml/XmlSerializer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System.Xml.Serialization;
using System.ComponentModel;

using NUnit.Framework;

namespace System.XmlTests {
public class C {
[DefaultValue(typeof(C), "c")]
public Type? T { get; }
}

[TestFixture]
public class XmlSerializerTest {

[Test]
public void TrimmingDefaultValueAttribute ()
{
// Context: https://github.com/dotnet/runtime/issues/109724
var s = new XmlSerializer(typeof(C));
_ = new C().T; // Prevent C.T from being removed by trimming
}
}
}
Loading