Skip to content

Commit 3a99c2f

Browse files
committed
[jnimarshalmethod-gen] Do not generate in already processed assemblies
Improves dotnet/android#2419 Change the behavior in case we find an existing `__<$>_jni_marshal_methods` class. Skip the whole assembly instead of just the type. Updated the warning message to report the assembly name. This can be still overriden by using `-f`. This also means the number of these warnings is significanly reduced to one per assembly, instead one per type in case we try to generate the methods for assemblies which were already processed and thus contain the marshaling classes.
1 parent 3f00d1b commit 3a99c2f

File tree

1 file changed

+3
-4
lines changed
  • tools/jnimarshalmethod-gen

1 file changed

+3
-4
lines changed

tools/jnimarshalmethod-gen/App.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ void ProcessAssemblies (List<string> assemblies)
184184
foreach (var assembly in assemblies) {
185185
try {
186186
CreateMarshalMethodAssembly (assembly);
187+
definedTypes.Clear ();
187188
} catch (Exception e) {
188189
Error ($"Unable to process assembly '{assembly}'{Environment.NewLine}{e.Message}{Environment.NewLine}{e}");
189190
Environment.Exit (1);
@@ -328,9 +329,9 @@ void CreateMarshalMethodAssembly (string path)
328329

329330
var existingMarshalMethodsType = td.GetNestedType (TypeMover.NestedName);
330331
if (existingMarshalMethodsType != null && !forceRegeneration) {
331-
Warning ($"Marshal methods type '{existingMarshalMethodsType.GetAssemblyQualifiedName ()}' already exists. Skipped generation of marshal methods. Use -f to force regeneration when desired.");
332+
Warning ($"Marshal methods type '{existingMarshalMethodsType.GetAssemblyQualifiedName ()}' already exists. Skipped generation of marshal methods in assembly '{assemblyName}'. Use -f to force regeneration when desired.");
332333

333-
continue;
334+
return;
334335
}
335336

336337
if (Verbose)
@@ -426,8 +427,6 @@ void CreateMarshalMethodAssembly (string path)
426427

427428
if (!keepTemporary)
428429
FilesToDelete.Add (dstAssembly.MainModule.FileName);
429-
430-
definedTypes.Clear ();
431430
}
432431

433432
static readonly MethodInfo Delegate_CreateDelegate = typeof (Delegate).GetMethod ("CreateDelegate", new[] {

0 commit comments

Comments
 (0)