Skip to content

Commit

Permalink
Feedback changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dellis1972 committed Jan 9, 2025
1 parent 7b29398 commit 4e8633e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Copyright (C) 2016 Xamarin. All rights reserved.
>
<MSBuild
Projects="@(ProjectReference)"
Targets="Restore;_GetProjectResourceDirectory"
Targets="_GetProjectResourceDirectory"
SkipNonexistentTargets="true"
>
<Output TaskParameter="TargetOutputs" ItemName="LibraryResourceDirectories" />
Expand Down
26 changes: 15 additions & 11 deletions src/Xamarin.Android.Build.Tasks/Tasks/GenerateResourceCaseMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,21 @@ public override bool RunTask ()
if (entry.FullName != resmap)
continue;
Log.LogDebugMessage ($"Found: {entry.FullName}");
using var ms = new MemoryStream();
entry.Extract (ms);
ms.Position = 0;
using var reader = new StreamReader (ms);
string line;
// Read each line until the end of the file
while ((line = reader.ReadLine()) != null) {
if (string.IsNullOrEmpty (line))
continue;
string [] tok = line.Split (';');
AddRename (tok [1].Replace ('/', Path.DirectorySeparatorChar), tok [0].Replace ('/', Path.DirectorySeparatorChar));
var ms = MemoryStreamPool.Shared.Rent ();
try {
entry.Extract (ms);
ms.Position = 0;
using var reader = new StreamReader (ms);
string line;
// Read each line until the end of the file
while ((line = reader.ReadLine()) != null) {
if (string.IsNullOrEmpty (line))
continue;
string [] tok = line.Split (';');
AddRename (tok [1].Replace ('/', Path.DirectorySeparatorChar), tok [0].Replace ('/', Path.DirectorySeparatorChar));
}
} finally {
MemoryStreamPool.Shared.Return (ms);
}
// no need to read the rest of the files we found the one we want
break;
Expand Down
14 changes: 9 additions & 5 deletions src/Xamarin.Android.Build.Tasks/Utilities/FileResourceParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,15 @@ public IList<R> Parse (string resourceDirectory, IEnumerable<string> additionalR
var path = Directory.GetParent (entry.FullName).Name;
if (ext == ".xml" || ext == ".axml") {
if (string.Compare (path, "raw", StringComparison.OrdinalIgnoreCase) != 0) {
using var ms = new MemoryStream ();
entry.Extract (ms);
ms.Position = 0;
using XmlReader reader = XmlReader.Create (ms);
ProcessXmlFile (reader, resources);
var ms = MemoryStreamPool.Shared.Rent ();
try {
entry.Extract (ms);
ms.Position = 0;
using XmlReader reader = XmlReader.Create (ms);
ProcessXmlFile (reader, resources);
} finally {
MemoryStreamPool.Shared.Return (ms);
}
}
}
ProcessResourceFile (entry.FullName, resources, processXml: false);
Expand Down

0 comments on commit 4e8633e

Please sign in to comment.