-
Notifications
You must be signed in to change notification settings - Fork 536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[One .NET] "greenfield" projects opt into trimming #8805
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,5 +5,10 @@ | |
<RootNamespace Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">AndroidLib1</RootNamespace> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<!-- | ||
Enable trim analyzers for Android class libraries. | ||
To learn more, see: https://learn.microsoft.com/dotnet/core/deploying/trimming/prepare-libraries-for-trimming | ||
--> | ||
<IsTrimmable>true</IsTrimmable> | ||
Comment on lines
+8
to
+12
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And this would be the project template change for Android class libraries, if we think this is a good idea. |
||
</PropertyGroup> | ||
</Project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,8 +74,9 @@ | |
<AndroidLinkMode Condition=" '$(AndroidLinkMode)' == '' and '$(PublishTrimmed)' == 'true' ">SdkOnly</AndroidLinkMode> | ||
<AndroidLinkMode Condition=" '$(AndroidLinkMode)' == '' ">None</AndroidLinkMode> | ||
<!-- For compat with user code not marked trimmable, only trim opt-in by default. --> | ||
<TrimMode Condition=" '$(TrimMode)' == '' and '$(AndroidLinkMode)' == 'Full' ">link</TrimMode> | ||
<TrimMode Condition=" '$(TrimMode)' == '' and '$(AndroidLinkMode)' == 'Full' ">full</TrimMode> | ||
<TrimMode Condition="'$(TrimMode)' == ''">partial</TrimMode> | ||
<SuppressTrimAnalysisWarnings Condition=" '$(SuppressTrimAnalysisWarnings)' == '' and '$(TrimMode)' == 'full' ">false</SuppressTrimAnalysisWarnings> | ||
<SuppressTrimAnalysisWarnings Condition=" '$(SuppressTrimAnalysisWarnings)' == '' ">true</SuppressTrimAnalysisWarnings> | ||
Comment on lines
+79
to
80
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. /cc @rolfbjarne this is the only defaults I changed. So if Existing apps, that are |
||
<!-- Prefer $(RuntimeIdentifiers) plural --> | ||
<RuntimeIdentifiers Condition=" '$(RuntimeIdentifier)' == '' And '$(RuntimeIdentifiers)' == '' ">android-arm;android-arm64;android-x86;android-x64</RuntimeIdentifiers> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,10 @@ public enum AndroidLinkMode | |
SdkOnly, | ||
Full, | ||
} | ||
|
||
public enum TrimMode | ||
{ | ||
Partial, | ||
Full, | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
using System; | ||
|
||
using System.Diagnostics.CodeAnalysis; | ||
using Android.App; | ||
using Android.Content.Res; | ||
using Android.Graphics; | ||
|
@@ -25,6 +25,7 @@ public class NinePatchTests | |
}; | ||
|
||
[Test, TestCaseSource (nameof (NinePatchDrawables))] | ||
[DynamicDependency (DynamicallyAccessedMemberTypes.All, typeof (NinePatchDrawable))] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test was failing, where the only usage of Assert.IsNotNull (d as NinePatchDrawable); And so the type |
||
public void DrawableFromRes_ShouldBeTypeNinePatchDrawable (int resId, string name) | ||
{ | ||
var d = Application.Context.Resources.GetDrawable (resId); | ||
|
@@ -33,6 +34,7 @@ public void DrawableFromRes_ShouldBeTypeNinePatchDrawable (int resId, string nam | |
} | ||
|
||
[Test, TestCaseSource (nameof (NinePatchDrawables))] | ||
[DynamicDependency (DynamicallyAccessedMemberTypes.All, typeof (NinePatchDrawable))] | ||
public void DrawableFromResStream_ShouldBeTypeNinePatchDrawable (int resId, string name) | ||
{ | ||
var value = new Android.Util.TypedValue (); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
using Android.App; | ||
using System.Diagnostics.CodeAnalysis; | ||
using Android.App; | ||
using Android.Content; | ||
using Android.Util; | ||
using Android.Views; | ||
using Android.Widget; | ||
using NUnit.Framework; | ||
using Mono.Android_Test.Library; | ||
|
||
namespace Xamarin.Android.RuntimeTests | ||
{ | ||
|
@@ -12,6 +14,7 @@ public class CustomWidgetTests | |
{ | ||
// https://bugzilla.xamarin.com/show_bug.cgi?id=23880 | ||
[Test] | ||
[DynamicDependency (DynamicallyAccessedMemberTypes.All, typeof (CustomTextView))] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this case,
|
||
public void UpperCaseCustomWidget_ShouldNotThrowInflateException () | ||
{ | ||
Assert.DoesNotThrow (() => { | ||
|
@@ -21,6 +24,7 @@ public void UpperCaseCustomWidget_ShouldNotThrowInflateException () | |
} | ||
|
||
[Test] | ||
[DynamicDependency (DynamicallyAccessedMemberTypes.All, typeof (CustomTextView))] | ||
public void LowerCaseCustomWidget_ShouldNotThrowInflateException () | ||
{ | ||
Assert.DoesNotThrow (() => { | ||
|
@@ -30,6 +34,7 @@ public void LowerCaseCustomWidget_ShouldNotThrowInflateException () | |
} | ||
|
||
[Test] | ||
[DynamicDependency (DynamicallyAccessedMemberTypes.All, typeof (CustomTextView))] | ||
public void UpperAndLowerCaseCustomWidget_FromLibrary_ShouldNotThrowInflateException () | ||
{ | ||
Assert.DoesNotThrow (() => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the new project template change for apps.