Repository navigation
[Xamarin.Android.Build.Tasks] Use R.txt for Managed Resource Parser - #1058
Conversation
| foreach (var dir in additionalResourceDirectories) | ||
| { | ||
| rTxt = Path.Combine(dir, "..", "R.txt"); | ||
| if (File.Exists(rTxt)) |
There was a problem hiding this comment.
This feels duplicative of the above code, in that the foreach (var dir in additionalResourceDirectories) block appears to be nearly identical to the previous block. Is there any way to "flatten" these?
foreach (var dir in new[]{resourceDirectory}.Concat(additionalResourceDirectories ?? new string[0])) {
var rTxt = Path.Combine (dir, "..", "R.txt");
if (File.Exists (rTxt)) {
ProcessRtxtFile (rTxt);
continue;
}
foreach (var file in Directory.GetFiles (dir, "*.*", SearchOption.AllDirectories)) {
ProcessResourceFile (file);
}
}There was a problem hiding this comment.
One of the reasons I split this up like this is because if we find a R.txt in the resourceDirectory that will have been generated by the app. As a result it will contain EVERYTHING. There will be no need to process anything else.
If its not there then we need to process everything else.
For the additionalResourceDirectories if we find an R.txt we can use that. but it will only contain the resources ids for that directory.. not everything.
Now I do have checks to make sure we don't add duplicates.. but this needs to be quick. And the quickest way to read a file is not too. So the more we can skip over the better.
| } | ||
| for (int i = 0; i < count; i++) | ||
| c.Initializers.Add (new CodePrimitiveExpression (0)); | ||
| { |
There was a problem hiding this comment.
This brace is on the wrong line.
| int value = 0; | ||
| if (i < values.Length) | ||
| value = values[i]; | ||
| c.Initializers.Add(new CodePrimitiveExpression(value)); |
There was a problem hiding this comment.
Missing space before (, here and elsewhere.
|
|
||
| void ProcessRtxtFile (string file) | ||
| { | ||
| Console.WriteLine (file); |
There was a problem hiding this comment.
I'm assuming we don't want/need this debug spew...
| switch (items [1]) { | ||
| case "anim": | ||
| CreateIntField (animation, itemName, value); | ||
| case "anim": |
There was a problem hiding this comment.
Do we need this whitespace change? (Are your IDE settings screwing things up again? ;-)
There was a problem hiding this comment.
I was fixing the formatting.. the indentation of the case's was incorrect.
In order to speed up the processing of resources we should make use of the R.txt files which are generally included with .aar files and our components. One advantage with this is we get the actual resource id which is used by android. But it also means that when we do find an R.txt file we can skip the processing of ALL resources in that underlying `res` folder. Note this will only apply to the ManagedResourceParser.
Changes: https://github.com/xamarin/monodroid/compare/2efbdd3e...0f6725ed Fixes: https://work.azdo.io/1041849 Fixes: https://developercommunity.visualstudio.com/content/problem/858509/adb0030-monoandroidtoolsrequiresuninstallexception-2.html * xamarin/monodroid@0f6725edf: [tools/msbuild] prevent InstallPackageAssemblies from reporting two errors (#1058) * xamarin/monodroid@16fd3b845: Bump to xamarin/androidtools/master@d221090 (#1059)
Changes: https://github.com/xamarin/monodroid/compare/2c9ce23d...dab75e88 Fixes: https://work.azdo.io/1041849 Fixes: https://developercommunity.visualstudio.com/content/problem/858509/adb0030-monoandroidtoolsrequiresuninstallexception-2.html * xamarin/monodroid@dab75e880: Bump to xamarin/android-sdk-installer/d16-5@5adcbfa (#1066) * xamarin/monodroid@3293f67a9: Bump to xamarin/android-sdk-installer/d16-5@dd6e2c0 (#1063) * xamarin/monodroid@8ecaa9d30: [tools/msbuild] prevent InstallPackageAssemblies from reporting two errors (#1058) (#1064) * xamarin/monodroid@284b81933: Bump to xamarin/androidtools/d16-5@62844ab (#1062)
In order to speed up the processing of resources we should
make use of the R.txt files which are generally included with
.aar files and our components.
One advantage with this is we get the actual resource id which
is used by android. But it also means that when we do find an
R.txt file we can skip the processing of ALL resources in that
underlying
resfolder. Note this will only apply to theManagedResourceParser.