Skip to content
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

[Mono.Android.Export] decorate types to improve trimming warnings #9300

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
6 changes: 6 additions & 0 deletions src/Mono.Android.Export/CallbackCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ abstract class CallbackCodeGenerator<TDelegateSpec>
public abstract void GenerateNativeCallbackDelegate ();
}

[RequiresDynamicCode (MonoAndroidExport.DynamicFeatures)]
[RequiresUnreferencedCode (MonoAndroidExport.DynamicFeatures)]
class DynamicInvokeTypeInfo
{
// NewArray<T>(T[])
Expand Down Expand Up @@ -517,6 +519,8 @@ public static Type GetNativeType (Type type)
}
}

[RequiresDynamicCode (MonoAndroidExport.DynamicFeatures)]
[RequiresUnreferencedCode (MonoAndroidExport.DynamicFeatures)]
static class DynamicCallbackFactory
{
static DynamicCallbackFactory ()
Expand All @@ -530,6 +534,8 @@ static DynamicCallbackFactory ()
public static CodeClass CodeClass { get; private set; }
}

[RequiresDynamicCode (MonoAndroidExport.DynamicFeatures)]
[RequiresUnreferencedCode (MonoAndroidExport.DynamicFeatures)]
class DynamicCallbackCodeGenerator : CallbackCodeGenerator<Type>
{
public static Delegate Create (MethodInfo method)
Expand Down
2 changes: 1 addition & 1 deletion src/Mono.Android.Export/Mono.Android.Export.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
<Import Project="..\..\Configuration.props" />
<Import Project="$(XamarinAndroidSourcePath)\build-tools\trim-analyzers\trim-analyzers.props" />

<PropertyGroup>
<TargetFrameworks>$(DotNetTargetFramework)</TargetFrameworks>
Expand All @@ -10,7 +11,6 @@
<NoStdLib>true</NoStdLib>
<ImplicitlyExpandDesignTimeFacades>false</ImplicitlyExpandDesignTimeFacades>
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
<EnableSingleFileAnalyzer>true</EnableSingleFileAnalyzer>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputPath>$(_MonoAndroidNETDefaultOutDir)</OutputPath>

Expand Down
2 changes: 0 additions & 2 deletions src/Mono.Android.Export/Mono.CodeGeneration/CodeAdd.cs

This file was deleted.

2 changes: 2 additions & 0 deletions src/Mono.Android.Export/Mono.CodeGeneration/CodeAnd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@

#if !MONOTOUCH
using System;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Reflection.Emit;

namespace Mono.CodeGeneration
{
[RequiresUnreferencedCode (MonoAndroidExport.DynamicFeatures)]
internal class CodeAnd: CodeConditionExpression
{
CodeExpression exp1;
Expand Down
2 changes: 2 additions & 0 deletions src/Mono.Android.Export/Mono.CodeGeneration/CodeArgument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

#if !MONOTOUCH
using System;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Reflection.Emit;

namespace Mono.CodeGeneration
{
[RequiresUnreferencedCode (MonoAndroidExport.DynamicFeatures)]
internal class CodeArgument: CodeExpression
{
int argument;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@

#if !MONOTOUCH
using System;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Reflection.Emit;

namespace Mono.CodeGeneration
{
[RequiresUnreferencedCode (MonoAndroidExport.DynamicFeatures)]
internal class CodeArgumentReference: CodeValueReference
{
Type type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@

#if !MONOTOUCH
using System;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Reflection.Emit;

namespace Mono.CodeGeneration
{
[RequiresUnreferencedCode (MonoAndroidExport.DynamicFeatures)]
internal abstract class CodeArithmeticOperation: CodeExpression
{
protected CodeExpression exp1;
Expand Down Expand Up @@ -67,6 +69,7 @@ public override Type GetResultType ()
}
}

[RequiresUnreferencedCode (MonoAndroidExport.DynamicFeatures)]
internal class CodeAdd: CodeArithmeticOperation
{
public CodeAdd (CodeExpression exp1, CodeExpression exp2)
Expand Down Expand Up @@ -97,6 +100,7 @@ public override void Generate (ILGenerator gen)
}
}

[RequiresUnreferencedCode (MonoAndroidExport.DynamicFeatures)]
internal class CodeMul: CodeArithmeticOperation
{
public CodeMul (CodeExpression exp1, CodeExpression exp2)
Expand All @@ -111,7 +115,8 @@ public override void Generate (ILGenerator gen)
gen.Emit (OpCodes.Mul);
}
}


[RequiresUnreferencedCode (MonoAndroidExport.DynamicFeatures)]
internal class CodeDiv: CodeArithmeticOperation
{
public CodeDiv (CodeExpression exp1, CodeExpression exp2)
Expand All @@ -127,6 +132,7 @@ public override void Generate (ILGenerator gen)
}
}

[RequiresUnreferencedCode (MonoAndroidExport.DynamicFeatures)]
internal class CodeSub: CodeArithmeticOperation
{
public CodeSub (CodeExpression exp1, CodeExpression exp2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@

#if !MONOTOUCH
using System;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Reflection.Emit;

namespace Mono.CodeGeneration
{
[RequiresUnreferencedCode (MonoAndroidExport.DynamicFeatures)]
internal class CodeArrayItem: CodeValueReference
{
CodeExpression array;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@

#if !MONOTOUCH
using System;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Reflection.Emit;

namespace Mono.CodeGeneration
{
[RequiresUnreferencedCode (MonoAndroidExport.DynamicFeatures)]
internal class CodeArrayLength: CodeExpression
{
CodeExpression array;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@

#if !MONOTOUCH
using System;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Reflection.Emit;

namespace Mono.CodeGeneration
{
[RequiresUnreferencedCode (MonoAndroidExport.DynamicFeatures)]
internal class CodeAssignment: CodeExpression
{
new CodeValueReference var;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@

#if !MONOTOUCH
using System;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Reflection.Emit;

namespace Mono.CodeGeneration
{
[RequiresUnreferencedCode (MonoAndroidExport.DynamicFeatures)]
internal abstract class CodeBinaryComparison: CodeConditionExpression
{
protected CodeExpression exp1;
Expand Down Expand Up @@ -63,6 +65,7 @@ public override Type GetResultType ()
}
}

[RequiresUnreferencedCode (MonoAndroidExport.DynamicFeatures)]
internal class CodeGreaterThan: CodeBinaryComparison
{
public CodeGreaterThan (CodeExpression exp1, CodeExpression exp2)
Expand All @@ -88,6 +91,7 @@ public override void GenerateForBranch (ILGenerator gen, Label label, bool branc
}
}

[RequiresUnreferencedCode (MonoAndroidExport.DynamicFeatures)]
internal class CodeGreaterEqualThan: CodeBinaryComparison
{
public CodeGreaterEqualThan (CodeExpression exp1, CodeExpression exp2)
Expand Down Expand Up @@ -115,6 +119,7 @@ public override void GenerateForBranch (ILGenerator gen, Label label, bool branc
}
}

[RequiresUnreferencedCode (MonoAndroidExport.DynamicFeatures)]
internal class CodeLessThan: CodeBinaryComparison
{
public CodeLessThan (CodeExpression exp1, CodeExpression exp2)
Expand All @@ -140,6 +145,7 @@ public override void GenerateForBranch (ILGenerator gen, Label label, bool branc
}
}

[RequiresUnreferencedCode (MonoAndroidExport.DynamicFeatures)]
internal class CodeLessEqualThan: CodeBinaryComparison
{
public CodeLessEqualThan (CodeExpression exp1, CodeExpression exp2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

#if !MONOTOUCH
using System;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Reflection.Emit;

namespace Mono.CodeGeneration
{
[RequiresUnreferencedCode (MonoAndroidExport.DynamicFeatures)]
internal abstract class CodeBinaryOperation: CodeConditionExpression
{
protected CodeExpression exp1;
Expand Down
3 changes: 3 additions & 0 deletions src/Mono.Android.Export/Mono.CodeGeneration/CodeBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@
#if !MONOTOUCH
using System;
using System.Collections;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Reflection.Emit;

namespace Mono.CodeGeneration
{
[RequiresUnreferencedCode (MonoAndroidExport.DynamicFeatures)]
internal class CodeBlock: CodeItem
{
ArrayList statements = new ArrayList ();
Expand Down Expand Up @@ -75,6 +77,7 @@ public override void PrintCode (CodeWriter cp)
}
}

[RequiresUnreferencedCode (MonoAndroidExport.DynamicFeatures)]
internal class CodePop: CodeStatement
{
public override void Generate (ILGenerator gen)
Expand Down
2 changes: 2 additions & 0 deletions src/Mono.Android.Export/Mono.CodeGeneration/CodeBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@
using System;
using System.IO;
using System.Collections;
using System.Diagnostics.CodeAnalysis;
using System.Reflection.Emit;
using System.Reflection;

namespace Mono.CodeGeneration
{
[RequiresUnreferencedCode (MonoAndroidExport.DynamicFeatures)]
internal class CodeBuilder
{
CodeBlock mainBlock;
Expand Down
2 changes: 2 additions & 0 deletions src/Mono.Android.Export/Mono.CodeGeneration/CodeCast.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@

#if !MONOTOUCH
using System;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Reflection.Emit;
using Mono.CodeGeneration;

namespace Mono.CodeGeneration
{
[RequiresUnreferencedCode (MonoAndroidExport.DynamicFeatures)]
internal class CodeCast: CodeExpression
{
Type type;
Expand Down
3 changes: 3 additions & 0 deletions src/Mono.Android.Export/Mono.CodeGeneration/CodeClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@
using System;
using System.IO;
using System.Collections;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Reflection.Emit;

namespace Mono.CodeGeneration
{
[RequiresDynamicCode (MonoAndroidExport.DynamicFeatures)]
[RequiresUnreferencedCode (MonoAndroidExport.DynamicFeatures)]
internal class CodeClass
{
TypeBuilder typeBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@
using System;
using System.IO;
using System.Collections;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Reflection.Emit;

namespace Mono.CodeGeneration
{
[RequiresDynamicCode (MonoAndroidExport.DynamicFeatures)]
[RequiresUnreferencedCode (MonoAndroidExport.DynamicFeatures)]
internal class CodeCustomAttribute
{
public static CodeCustomAttribute Create (Type attributeType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@

#if !MONOTOUCH
using System;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Reflection.Emit;

namespace Mono.CodeGeneration
{
[RequiresUnreferencedCode (MonoAndroidExport.DynamicFeatures)]
internal class CodeDecrement: CodeValueReference
{
CodeValueReference exp;
Expand Down Expand Up @@ -60,6 +62,7 @@ public override Type GetResultType ()
}
}

[RequiresUnreferencedCode (MonoAndroidExport.DynamicFeatures)]
internal class CodeSubstractOne: CodeExpression
{
CodeExpression exp;
Expand Down
2 changes: 2 additions & 0 deletions src/Mono.Android.Export/Mono.CodeGeneration/CodeEquals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@

#if !MONOTOUCH
using System;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Reflection.Emit;

namespace Mono.CodeGeneration
{
[RequiresUnreferencedCode (MonoAndroidExport.DynamicFeatures)]
internal class CodeEquals: CodeConditionExpression
{
CodeExpression exp1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@

#if !MONOTOUCH
using System;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Reflection.Emit;

namespace Mono.CodeGeneration
{
[RequiresUnreferencedCode (MonoAndroidExport.DynamicFeatures)]
internal abstract class CodeExpression: CodeItem
{
internal CodeVariableReference var;
Expand Down Expand Up @@ -185,6 +187,7 @@ public bool IsNumber
}
}

[RequiresUnreferencedCode (MonoAndroidExport.DynamicFeatures)]
internal abstract class CodeConditionExpression: CodeExpression
{
public virtual void GenerateForBranch (ILGenerator gen, Label label, bool jumpCase)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@

#if !MONOTOUCH
using System;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Reflection.Emit;

namespace Mono.CodeGeneration
{
[RequiresUnreferencedCode (MonoAndroidExport.DynamicFeatures)]
internal class CodeFieldReference: CodeValueReference
{
CodeExpression target;
Expand Down
Loading
Loading