Skip to content

Commit

Permalink
Move TryGetValue changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dellis1972 committed Jul 17, 2018
1 parent 6394c4c commit 9253468
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/Xamarin.Android.Build.Tasks/Utilities/AndroidResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ private static void TryFixResourceAlias (XElement elem, string resourceBasePath,

private static bool TryFixFragment (XAttribute attr, Dictionary<string, string> acwMap)
{
string mappedValue;
// Looks for any:
// <fragment class="My.DotNet.Class"
// <fragment android:name="My.DotNet.Class" ...
Expand All @@ -187,17 +188,17 @@ private static bool TryFixFragment (XAttribute attr, Dictionary<string, string>
return false;

if (attr.Name == "class" || attr.Name == android + "name") {
if (acwMap.ContainsKey (attr.Value)) {
attr.Value = acwMap[attr.Value];
if (acwMap.TryGetValue (attr.Value, out mappedValue)) {
attr.Value = mappedValue;

return true;
}
else if (attr.Value?.Contains (',') ?? false) {
// attr.Value could be an assembly-qualified name that isn't in acw-map.txt;
// see e5b1c92c, https://github.com/xamarin/xamarin-android/issues/1296#issuecomment-365091948
var n = attr.Value.Substring (0, attr.Value.IndexOf (','));
if (acwMap.ContainsKey (n)) {
attr.Value = acwMap [n];
if (acwMap.TryGetValue (n, out mappedValue)) {
attr.Value = mappedValue;
return true;
}
}
Expand Down Expand Up @@ -225,8 +226,9 @@ private static bool TryFixCustomView (XElement elem, Dictionary<string, string>
// Looks for any <My.DotNet.Class ...
// and tries to change it to the ACW name
string name = elem.Name.ToString ();
if (acwMap.ContainsKey (name)) {
elem.Name = acwMap[name];
string mappedValue;
if (acwMap.TryGetValue (name, out mappedValue)) {
elem.Name = mappedValue;
return true;
}
if (logMessage == null)
Expand Down

0 comments on commit 9253468

Please sign in to comment.