You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[jcw-gen] use Assembly Name instead of FullName for typemaps (#227)
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=61073
The Java-to-Managed typemaps list types such as:
android/app/Activity
Android.App.Activity, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065
Let’s assume you have an Android project with the following
assembly-level attribute:
[assembly:AssemblyVersion("1.0.0.*")]
Then on *every* build, the typemap is invalidated because your version
number has been incremented.
The fix here is to use the assembly’s short name via `GetName ().Name`
or Mono.Cecil’s equivalent `AssemblyDefinition.Name.Name`. So the above
typemap would only be `Android.App.Activity, Mono.Android`. These
changes needed to happen in both `JavaNativeTypeManager` and
`TypeNameMapGenerator`.
The final fix is to find *every* instance of
`TypeDefinitionRocks.GetAssemblyQualifiedName` and use
`TypeDefinitionRocks.GetPartialAssemblyQualifiedName` in its place.
The latter also had the issue of needing to replace the `/` character
with `+`, so both methods return valid nested type names.
Copy file name to clipboardExpand all lines: src/Java.Interop.Tools.JavaCallableWrappers/Java.Interop.Tools.JavaCallableWrappers/JavaCallableWrapperGenerator.cs
Copy file name to clipboardExpand all lines: src/Java.Interop.Tools.JavaCallableWrappers/Java.Interop.Tools.JavaCallableWrappers/TypeNameMapGenerator.cs
+2-2
Original file line number
Diff line number
Diff line change
@@ -141,7 +141,7 @@ public void WriteJavaToManaged (Stream output)
141
141
vartypeMap=GetTypeMapping(
142
142
t =>t.IsInterface||t.HasGenericParameters,
143
143
JavaNativeTypeManager.ToJniName,
144
-
t =>t.GetAssemblyQualifiedName());
144
+
t =>t.GetPartialAssemblyQualifiedName());
145
145
146
146
WriteBinaryMapping(output,typeMap);
147
147
}
@@ -234,7 +234,7 @@ public void WriteManagedToJava (Stream output)
Copy file name to clipboardExpand all lines: src/Java.Interop.Tools.JavaCallableWrappers/Test/Java.Interop.Tools.JavaCallableWrappers/JavaCallableWrapperGeneratorTests.cs
+19-19
Original file line number
Diff line number
Diff line change
@@ -93,7 +93,7 @@ public void GenerateIndirectApplication (
0 commit comments