Skip to content

Commit 4f35eef

Browse files
[TrimmableTypeMap] Add GenerateTrimmableTypeMap MSBuild task and targets (#10924)
* [TrimmableTypeMap] Add GenerateTrimmableTypeMap MSBuild task and targets Add the MSBuild task that wires the TrimmableTypeMap scanner and generators into the build pipeline, replacing the stub _GenerateJavaStubs target. ### Task (GenerateTrimmableTypeMap) - Extends AndroidTask, TaskPrefix 'GTT' - Scans resolved assemblies for Java peer types - Generates per-assembly TypeMap .dll assemblies - Generates root _Microsoft.Android.TypeMaps.dll - Generates JCW .java source files for ACW types ### Targets - Microsoft.Android.Sdk.TypeMap.Trimmable.targets: replaces stub with real GenerateTrimmableTypeMap task call - CoreCLR.targets: adds generated assemblies as TrimmerRootAssembly, configures RuntimeHostConfigurationOption for TypeMappingEntryAssembly - NativeAOT.targets: adds to IlcReference, UnmanagedEntryPointsAssembly, and TrimmerRootAssembly Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add unit tests for GenerateTrimmableTypeMap task Tests using MockBuildEngine: - Empty assembly list succeeds with no outputs - Real Mono.Android.dll produces per-assembly + root typemap assemblies - Different TargetFrameworkVersion formats all parse correctly Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add integration tests for trimmable TypeMap build pipeline Full build integration tests: - Build with _AndroidTypeMapImplementation=trimmable succeeds on CoreCLR - Incremental build skips _GenerateJavaStubs when nothing changed Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Improve GenerateTrimmableTypeMap: extract methods, filter BCL, fail on bad version - Extract Phase 1-5 into named methods (ScanAssemblies, GenerateTypeMapAssemblies, GenerateJcwJavaSources) — no more // Phase N comments - Filter BCL assemblies: skip FrameworkAssembly=true unless HasMonoAndroidReference - Throw on unparseable TargetFrameworkVersion instead of silent fallback - Use LINQ for grouping peers by assembly and filtering paths - Deterministic output ordering via OrderBy on assembly name Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix task return types, Java output dir, remove TrimmerRootAssembly - Both GenerateTypeMapAssemblies and GenerateJcwJavaSources now return ITaskItem[] directly — no intermediate conversion in RunTask - Move Java output under typemap dir (typemap/java instead of android/src) - Remove TrimmerRootAssembly from generated assemblies — the trimmer must process TypeMapAttributes and trim entries whose trimTarget types were removed. TrimmerRootAssembly would prevent this, defeating the purpose. - NativeAOT: keep IlcReference + UnmanagedEntryPointsAssembly but remove TrimmerRootAssembly for the same reason. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add per-assembly timestamp check to skip up-to-date typemaps Compare source assembly timestamp against generated typemap .dll — skip emission when the output is newer. Root assembly only regenerated when any per-assembly typemap changed. Typical incremental build: only app assembly changed → scan all (for cross-assembly resolution) but only emit _MyApp.TypeMap.dll + root. Mono.Android scan is unavoidable (xref resolution) but its typemap emission is skipped. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add thorough incrementality tests for GenerateTrimmableTypeMap - SecondRun_SkipsUpToDateAssemblies: run twice with same inputs, verify typemap file timestamp unchanged and 'up to date' logged - SourceTouched_RegeneratesOnlyChangedAssembly: touch source assembly, verify typemap is regenerated with newer timestamp - InvalidTargetFrameworkVersion_Throws: verify ArgumentException - Extracted CreateTask helper to reduce test boilerplate - ParsesTargetFrameworkVersion converted to [TestCase] parameterized test Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Document future scan optimization path in task Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Move TypeMappingEntryAssembly config to shared targets Both CoreCLR and NativeAOT need to know the TypeMap entry assembly. RuntimeHostConfigurationOption works for both (runtimeconfig.json for CoreCLR, ILC feature switch for NativeAOT). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Make scanner/generator types public, fix invalid TFV test Make types consumed by the MSBuild task public (they're build-time only, not shipped in apps): JavaPeerInfo, MarshalMethodInfo, JniParameterInfo, JavaConstructorInfo, ActivationCtorInfo, ActivationCtorStyle, JavaPeerScanner, TypeMapAssemblyGenerator, RootTypeMapAssemblyGenerator, JcwJavaSourceGenerator. Fix Execute_InvalidTargetFrameworkVersion test: AndroidTask catches exceptions and logs them as errors, so Assert.Throws doesn't work. Check task.Execute() returns false and errors are logged instead. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Skip writing unchanged JCW Java files for faster incremental builds Generate Java content to StringWriter first, compare with existing file. Only write to disk if content changed. This avoids unnecessary javac recompilation on incremental builds where types haven't changed. Benchmark showed JCW file writing was the biggest bottleneck (~511ms p50 for 315 files). With this change, incremental builds that don't change any types skip all disk writes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Revert "Skip writing unchanged JCW Java files for faster incremental builds" This reverts commit ac4227b. * Move UsingTask to Trimmable.targets — only needed in trimmable path Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Sign TrimmableTypeMap assembly with product.snk The Xamarin.Android.Build.Tasks project is strong-name signed and references Microsoft.Android.Sdk.TrimmableTypeMap, which was not signed. This caused CS8002 on all CI platforms. Add SignAssembly + AssemblyOriginatorKeyFile to both the library and its unit test project, and add the public key to the InternalsVisibleTo entry. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Address review: FileWrites, ->Count(), #nullable enable - Add @(FileWrites) for generated typemap assemblies and Java files to prevent IncrementalClean from deleting them. - Use ->Count() instead of != '' for item group empty checks in CoreCLR and NativeAOT targets. - Add #nullable enable to GenerateTrimmableTypeMap.cs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix malformed <Touch> element in Trimmable.targets Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add test: no peers found with non-empty assembly input Exercises the early-return path in RunTask() when the scanner finds no [Register] types in the provided assemblies. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix FindMonoAndroidDll to use TestEnvironment.MonoAndroidFrameworkDirectory Remove hardcoded Microsoft.Android.Ref.35 path that would break when the API level changes. MonoAndroidFrameworkDirectory already resolves the correct version dynamically via XABuildConfig. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Address review: use MonoAndroidHelper, leave outputs null, drop LINQ - Leave GeneratedAssemblies/GeneratedJavaFiles null when no peers found instead of assigning empty arrays (review: jonathanpeppers) - Use MonoAndroidHelper.IsMonoAndroidAssembly() instead of custom FrameworkAssembly/HasMonoAndroidReference logic (review: jonathanpeppers) - Replace LINQ Select+ToArray with simple loop in GenerateJcwJavaSources to avoid unnecessary ITaskItem cloning (review: jonathanpeppers) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix UsingTask to use $(_XamarinAndroidBuildTasksAssembly) The bare filename 'Xamarin.Android.Build.Tasks.dll' doesn't resolve at runtime. All other shipped UsingTask elements use the $(_XamarinAndroidBuildTasksAssembly) property which contains the full path to the task assembly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix CI: package TrimmableTypeMap DLL and add metadata to test TaskItems Two fixes for CI test failures: 1. Integration tests (BuildWithTrimmableTypeMap*): Add Microsoft.Android.Sdk.TrimmableTypeMap.dll/pdb to _MSBuildFiles in create-installers.targets so the dependency is packaged into the SDK tools directory. Without this, GenerateTrimmableTypeMap task fails at runtime with a missing assembly error. 2. Unit tests (Execute*): FindMonoAndroidDll now returns ITaskItem with HasMonoAndroidReference=True metadata. The review change in 64725e6 switched GetJavaInteropAssemblyPaths to use MonoAndroidHelper.IsMonoAndroidAssembly which requires metadata on TaskItems. Bare TaskItem(path) was rejected, causing 0 assemblies to be scanned. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Make JavaFieldInfo record public for MSBuild task consumption JavaFieldInfo is exposed through the public JavaPeerInfo.JavaFields property but was not itself marked public, causing CS0050 accessibility errors when building Xamarin.Android.Build.Tasks which references the assembly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix integration tests: target _GenerateJavaStubs only Full Build,SignAndroidPackage cannot succeed yet because manifest generation (GenerateMainAndroidManifest) is not implemented for the trimmable typemap path. Scope tests to _GenerateJavaStubs target which validates the typemap + JCW generation that is implemented. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix CI: ensure stamp directory exists for trimmable _GenerateJavaStubs When _GenerateJavaStubs is invoked directly (e.g., via /t:_GenerateJavaStubs in tests), the Build target does not run, so _CleanIntermediateIfNeeded never creates the stamp directory. The Touch task then fails because the stamp/ directory doesn't exist. Fix by: 1. Adding _CleanIntermediateIfNeeded to DependsOnTargets so the stamp directory and properties cache are created (needed for incremental builds). 2. Adding a defensive MakeDir before Touch as a safety net. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix CI: use full Build for trimmable typemap integration tests Running _GenerateJavaStubs directly fails because _ResolveAssemblies needs the compiled project DLL and Resource.Designer.dll which only exist after a full Build. Instead, run the full Build,SignAndroidPackage target with ThrowOnBuildFailure=false (the build fails downstream at manifest generation, which is not yet implemented for the trimmable path) and verify _GenerateJavaStubs ran by checking typemap outputs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent e0d2614 commit 4f35eef

15 files changed

+546
-19
lines changed

build-tools/installers/create-installers.targets

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@
153153
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)Microsoft.Android.Sdk.Bindings.Gradle.targets" />
154154
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)Xamarin.Android.Build.Tasks.dll" />
155155
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)Xamarin.Android.Build.Tasks.pdb" />
156+
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)Microsoft.Android.Sdk.TrimmableTypeMap.dll" />
157+
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)Microsoft.Android.Sdk.TrimmableTypeMap.pdb" />
156158
<_MSBuildFiles Include="@(_LocalizationLanguages->'$(MicrosoftAndroidSdkOutDir)%(Identity)\Microsoft.Android.Build.BaseTasks.resources.dll')" />
157159
<_MSBuildFiles Include="@(_LocalizationLanguages->'$(MicrosoftAndroidSdkOutDir)%(Identity)\Xamarin.Android.Build.Tasks.resources.dll')" />
158160
<_MSBuildFiles Include="@(_LocalizationLanguages->'$(MicrosoftAndroidSdkOutDir)%(Identity)\Xamarin.Android.Tools.AndroidSdk.resources.dll')" />

src/Microsoft.Android.Sdk.TrimmableTypeMap/Generator/JcwJavaSourceGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ namespace Microsoft.Android.Sdk.TrimmableTypeMap;
3939
/// }
4040
/// </code>
4141
/// </remarks>
42-
sealed class JcwJavaSourceGenerator
42+
public sealed class JcwJavaSourceGenerator
4343
{
4444
/// <summary>
4545
/// Generates .java source files for all ACW types and writes them to the output directory.

src/Microsoft.Android.Sdk.TrimmableTypeMap/Generator/RootTypeMapAssemblyGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace Microsoft.Android.Sdk.TrimmableTypeMap;
1919
/// [assembly: TypeMapAssemblyTarget&lt;Java.Lang.Object&gt;("_MyApp.TypeMap")]
2020
/// </code>
2121
/// </remarks>
22-
sealed class RootTypeMapAssemblyGenerator
22+
public sealed class RootTypeMapAssemblyGenerator
2323
{
2424
const string DefaultAssemblyName = "_Microsoft.Android.TypeMaps";
2525

src/Microsoft.Android.Sdk.TrimmableTypeMap/Generator/TypeMapAssemblyGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Microsoft.Android.Sdk.TrimmableTypeMap;
88
/// High-level API: builds the model from peers, then emits the PE assembly.
99
/// Composes <see cref="ModelBuilder"/> + <see cref="TypeMapAssemblyEmitter"/>.
1010
/// </summary>
11-
sealed class TypeMapAssemblyGenerator
11+
public sealed class TypeMapAssemblyGenerator
1212
{
1313
readonly Version _systemRuntimeVersion;
1414

src/Microsoft.Android.Sdk.TrimmableTypeMap/Microsoft.Android.Sdk.TrimmableTypeMap.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66
<Nullable>enable</Nullable>
77
<WarningsAsErrors>Nullable</WarningsAsErrors>
88
<RootNamespace>Microsoft.Android.Sdk.TrimmableTypeMap</RootNamespace>
9+
<SignAssembly>true</SignAssembly>
10+
<AssemblyOriginatorKeyFile>..\..\product.snk</AssemblyOriginatorKeyFile>
911
</PropertyGroup>
1012

1113
<ItemGroup>
1214
<PackageReference Include="System.IO.Hashing" Version="$(SystemIOHashingPackageVersion)" />
1315
<PackageReference Include="System.Reflection.Metadata" Version="$(SystemReflectionMetadataPackageVersion)" />
14-
<InternalsVisibleTo Include="Microsoft.Android.Sdk.TrimmableTypeMap.Tests" />
16+
<InternalsVisibleTo Include="Microsoft.Android.Sdk.TrimmableTypeMap.Tests" Key="0024000004800000940000000602000000240000525341310004000011000000438ac2a5acfbf16cbd2b2b47a62762f273df9cb2795ceccdf77d10bf508e69e7a362ea7a45455bbf3ac955e1f2e2814f144e5d817efc4c6502cc012df310783348304e3ae38573c6d658c234025821fda87a0be8a0d504df564e2c93b2b878925f42503e9d54dfef9f9586d9e6f38a305769587b1de01f6c0410328b2c9733db" />
1517
</ItemGroup>
1618

1719
<ItemGroup>

src/Microsoft.Android.Sdk.TrimmableTypeMap/Scanner/JavaPeerInfo.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Microsoft.Android.Sdk.TrimmableTypeMap;
88
/// Contains all data needed by downstream generators (TypeMap IL, UCO wrappers, JCW Java sources).
99
/// Generators consume this data model — they never touch PEReader/MetadataReader.
1010
/// </summary>
11-
sealed record JavaPeerInfo
11+
public sealed record JavaPeerInfo
1212
{
1313
/// <summary>
1414
/// JNI type name, e.g., "android/app/Activity".
@@ -124,7 +124,7 @@ sealed record JavaPeerInfo
124124
/// Contains all data needed to generate a UCO wrapper, a JCW native declaration,
125125
/// and a RegisterNatives call.
126126
/// </summary>
127-
sealed record MarshalMethodInfo
127+
public sealed record MarshalMethodInfo
128128
{
129129
/// <summary>
130130
/// JNI method name, e.g., "onCreate".
@@ -208,7 +208,7 @@ sealed record MarshalMethodInfo
208208
/// <summary>
209209
/// Describes a JNI parameter for UCO method generation.
210210
/// </summary>
211-
sealed record JniParameterInfo
211+
public sealed record JniParameterInfo
212212
{
213213
/// <summary>
214214
/// JNI type descriptor, e.g., "Landroid/os/Bundle;", "I", "Z".
@@ -224,7 +224,7 @@ sealed record JniParameterInfo
224224
/// <summary>
225225
/// Describes a Java constructor to emit in the JCW .java source file.
226226
/// </summary>
227-
sealed record JavaConstructorInfo
227+
public sealed record JavaConstructorInfo
228228
{
229229
/// <summary>
230230
/// JNI constructor signature, e.g., "(Landroid/content/Context;)V".
@@ -247,7 +247,7 @@ sealed record JavaConstructorInfo
247247
/// Describes a Java field from an [ExportField] attribute.
248248
/// The field is initialized by calling the annotated method.
249249
/// </summary>
250-
sealed record JavaFieldInfo
250+
public sealed record JavaFieldInfo
251251
{
252252
/// <summary>
253253
/// Java field name, e.g., "STATIC_INSTANCE".
@@ -278,7 +278,7 @@ sealed record JavaFieldInfo
278278
/// <summary>
279279
/// Describes how to call the activation constructor for a Java peer type.
280280
/// </summary>
281-
sealed record ActivationCtorInfo
281+
public sealed record ActivationCtorInfo
282282
{
283283
/// <summary>
284284
/// The type that declares the activation constructor.
@@ -297,7 +297,7 @@ sealed record ActivationCtorInfo
297297
public required ActivationCtorStyle Style { get; init; }
298298
}
299299

300-
enum ActivationCtorStyle
300+
public enum ActivationCtorStyle
301301
{
302302
/// <summary>
303303
/// Xamarin.Android style: (IntPtr handle, JniHandleOwnership transfer)

src/Microsoft.Android.Sdk.TrimmableTypeMap/Scanner/JavaPeerScanner.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace Microsoft.Android.Sdk.TrimmableTypeMap;
1414
/// Phase 1: Build per-assembly indices (fast, O(1) lookups)
1515
/// Phase 2: Analyze types using cached indices
1616
/// </summary>
17-
sealed class JavaPeerScanner : IDisposable
17+
public sealed class JavaPeerScanner : IDisposable
1818
{
1919
readonly Dictionary<string, AssemblyIndex> assemblyCache = new (StringComparer.Ordinal);
2020
readonly Dictionary<(string typeName, string assemblyName), ActivationCtorInfo> activationCtorCache = new ();
Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
1-
<!-- Trimmable typemap targets for CoreCLR runtime (stub).
2-
The actual implementation will be added in a follow-up. -->
1+
<!-- Trimmable typemap targets for CoreCLR runtime.
2+
Adds generated typemap assemblies to the linker inputs. -->
33
<Project>
44

5+
<!-- After typemap generation, add generated assemblies to resolved assemblies for the linker.
6+
NOT as TrimmerRootAssembly — the trimmer must process TypeMapAttributes and trim entries
7+
whose trimTarget types were removed. -->
8+
<Target Name="_AddTrimmableTypeMapAssembliesToLinker"
9+
AfterTargets="_GenerateJavaStubs"
10+
Condition=" '@(_GeneratedTypeMapAssemblies->Count())' != '0' ">
11+
<ItemGroup>
12+
<_ResolvedAssemblies Include="@(_GeneratedTypeMapAssemblies)" />
13+
</ItemGroup>
14+
</Target>
15+
516
</Project>
Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
1-
<!-- Trimmable typemap targets for NativeAOT runtime (stub).
2-
The actual implementation will be added in a follow-up. -->
1+
<!-- Trimmable typemap targets for NativeAOT runtime.
2+
Adds generated typemap assemblies to ILC inputs. -->
33
<Project>
4+
5+
<!-- After typemap generation, add generated assemblies to ILC inputs.
6+
NOT as TrimmerRootAssembly — ILC must process TypeMapAttributes and trim entries
7+
whose trimTarget types were removed. -->
8+
<Target Name="_AddTrimmableTypeMapAssembliesToIlc"
9+
AfterTargets="_GenerateJavaStubs"
10+
Condition=" '@(_GeneratedTypeMapAssemblies->Count())' != '0' ">
11+
<ItemGroup>
12+
<IlcReference Include="@(_GeneratedTypeMapAssemblies)" />
13+
<UnmanagedEntryPointsAssembly Include="@(_GeneratedTypeMapAssemblies)" />
14+
</ItemGroup>
15+
</Target>
16+
417
</Project>

src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.TypeMap.Trimmable.targets

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,27 @@
11
<!-- Trimmable typemap: managed type mapping instead of native binary typemaps.
2-
This is a stub — the actual implementation will be added in a follow-up. -->
2+
Generates per-assembly TypeMap .dll assemblies, a root _Microsoft.Android.TypeMaps.dll,
3+
and JCW .java source files with registerNatives. -->
34
<Project>
45

6+
<UsingTask TaskName="Xamarin.Android.Tasks.GenerateTrimmableTypeMap" AssemblyFile="$(_XamarinAndroidBuildTasksAssembly)" />
7+
58
<Import Project="$(MSBuildThisFileDirectory)Microsoft.Android.Sdk.TypeMap.Trimmable.CoreCLR.targets"
69
Condition=" '$(_AndroidRuntime)' == 'CoreCLR' " />
710
<Import Project="$(MSBuildThisFileDirectory)Microsoft.Android.Sdk.TypeMap.Trimmable.NativeAOT.targets"
811
Condition=" '$(_AndroidRuntime)' == 'NativeAOT' " />
912

13+
<PropertyGroup>
14+
<_TypeMapAssemblyName>_Microsoft.Android.TypeMaps</_TypeMapAssemblyName>
15+
<_TypeMapOutputDirectory>$(IntermediateOutputPath)typemap\</_TypeMapOutputDirectory>
16+
<_TypeMapJavaOutputDirectory>$(IntermediateOutputPath)typemap\java</_TypeMapJavaOutputDirectory>
17+
</PropertyGroup>
18+
19+
<!-- Tell the runtime which assembly contains the TypeMap attributes -->
20+
<ItemGroup>
21+
<RuntimeHostConfigurationOption Include="System.Runtime.InteropServices.TypeMappingEntryAssembly"
22+
Value="$(_TypeMapAssemblyName)" />
23+
</ItemGroup>
24+
1025
<Target Name="_ValidateTrimmableTypeMapRuntime"
1126
BeforeTargets="Build"
1227
Condition=" '$(_AndroidRuntime)' != 'CoreCLR' And '$(_AndroidRuntime)' != 'NativeAOT' ">
@@ -18,10 +33,25 @@
1833
from the Cecil-based GenerateJavaStubs task. Extracting them into a shared target
1934
requires decoupling from NativeCodeGenState first. See #10807. -->
2035
<Target Name="_GenerateJavaStubs"
21-
DependsOnTargets="_SetLatestTargetFrameworkVersion;_PrepareAssemblies;_GetGenerateJavaStubsInputs"
36+
DependsOnTargets="_SetLatestTargetFrameworkVersion;_CleanIntermediateIfNeeded;_PrepareAssemblies;_GetGenerateJavaStubsInputs"
2237
Inputs="@(_GenerateJavaStubsInputs)"
2338
Outputs="$(_AndroidStampDirectory)_GenerateJavaStubs.stamp">
24-
<Message Text="Trimmable typemap: skipping legacy _GenerateJavaStubs" Importance="High" />
39+
40+
<GenerateTrimmableTypeMap
41+
ResolvedAssemblies="@(_ResolvedAssemblies)"
42+
OutputDirectory="$(_TypeMapOutputDirectory)"
43+
JavaSourceOutputDirectory="$(_TypeMapJavaOutputDirectory)"
44+
TargetFrameworkVersion="$(TargetFrameworkVersion)">
45+
<Output TaskParameter="GeneratedAssemblies" ItemName="_GeneratedTypeMapAssemblies" />
46+
<Output TaskParameter="GeneratedJavaFiles" ItemName="_GeneratedJavaFiles" />
47+
</GenerateTrimmableTypeMap>
48+
49+
<ItemGroup>
50+
<FileWrites Include="@(_GeneratedTypeMapAssemblies)" />
51+
<FileWrites Include="@(_GeneratedJavaFiles)" />
52+
</ItemGroup>
53+
54+
<MakeDir Directories="$(_AndroidStampDirectory)" Condition=" !Exists('$(_AndroidStampDirectory)') " />
2555
<Touch Files="$(_AndroidStampDirectory)_GenerateJavaStubs.stamp" AlwaysCreate="True" />
2656
</Target>
2757

0 commit comments

Comments
 (0)