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

[Xamarin.Android.Build.Tasks] delay ToJniName calls in ManifestDocument #7653

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 13 additions & 4 deletions src/Xamarin.Android.Build.Tasks/Utilities/ManifestDocument.cs
Expand Up @@ -336,16 +336,20 @@ public IList<string> Merge (TaskLoggingHelper log, TypeDefinitionCache cache, Li
if (PackageName == null)
PackageName = t.Namespace;

var name = JavaNativeTypeManager.ToJniName (t, cache).Replace ('/', '.');
var compatName = JavaNativeTypeManager.ToCompatJniName (t, cache).Replace ('/', '.');
if (((string) app.Attribute (attName)) == compatName) {
app.SetAttributeValue (attName, name);
string name, compatName;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of declaring w/o initializing, I think it would be better to "double declare" them, once within the following if block, and separately within the try block:

if (t.IsSubclassOf ("Android.App.Application", cache)) {
    var (name, compatName) = GetNames (t, cache);
    // …
}try {
    var (name, compatName) = GetNames (t, cache);
    // …
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put (string name, string compatName) = GetNames (t, cache) so they types are more clear.

if (t.IsSubclassOf ("Android.App.Application", cache)) {
(name, compatName) = GetNames (t, cache);
if (((string) app.Attribute (attName)) == compatName) {
app.SetAttributeValue (attName, name);
}
continue;
}

Func<TypeDefinition, string, int, XElement> generator = GetGenerator (t, cache);
if (generator == null)
continue;

(name, compatName) = GetNames (t, cache);
try {
// activity not present: create a launcher for it IFF it has attribute
if (!existingTypes.Contains (name) && !existingTypes.Contains (compatName)) {
Expand Down Expand Up @@ -481,6 +485,11 @@ SequencePoint FindSource (IEnumerable<MethodDefinition> methods)
}
}

(string name, string compatName) GetNames(TypeDefinition type, TypeDefinitionCache cache) => (
JavaNativeTypeManager.ToJniName (type, cache).Replace ('/', '.'),
JavaNativeTypeManager.ToCompatJniName (type, cache).Replace ('/', '.')
);

// FIXME: our manifest merger is hacky.
// To support complete manifest merger, we will have to implement fairly complicated one, described at
// http://tools.android.com/tech-docs/new-build-system/user-guide/manifest-merger
Expand Down