-
Notifications
You must be signed in to change notification settings - Fork 552
[trimming] preserve custom views and $(AndroidHttpClientHandlerType)
#8944
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
src/Xamarin.Android.Build.Tasks/Tasks/GenerateILLinkXml.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using System.Xml.Linq; | ||
using Microsoft.Android.Build.Tasks; | ||
using Microsoft.Build.Framework; | ||
|
||
namespace Xamarin.Android.Tasks; | ||
|
||
public class GenerateILLinkXml : AndroidTask | ||
{ | ||
public override string TaskPrefix => "GILX"; | ||
|
||
[Required] | ||
public string AndroidHttpClientHandlerType { get; set; } | ||
|
||
[Required] | ||
public string CustomViewMapFile { get; set; } | ||
|
||
[Required] | ||
public string OutputFile { get; set; } | ||
|
||
public override bool RunTask () | ||
{ | ||
string assemblyName, typeName; | ||
|
||
var index = AndroidHttpClientHandlerType.IndexOf (','); | ||
if (index != -1) { | ||
typeName = AndroidHttpClientHandlerType.Substring (0, index).Trim (); | ||
assemblyName = AndroidHttpClientHandlerType.Substring (index + 1).Trim (); | ||
} else { | ||
typeName = AndroidHttpClientHandlerType; | ||
assemblyName = "Mono.Android"; | ||
} | ||
|
||
// public parameterless constructors | ||
// example: https://github.com/dotnet/runtime/blob/039d2ecb46687e89337d6d629c295687cfe226be/src/mono/System.Private.CoreLib/src/ILLink/ILLink.Descriptors.xml | ||
var ctor = new XElement ("method", new XAttribute("signature", "System.Void .ctor()")); | ||
|
||
XElement linker; | ||
var doc = new XDocument ( | ||
linker = new XElement ("linker", | ||
new XElement ("assembly", | ||
new XAttribute ("fullname", assemblyName), | ||
new XElement ("type", new XAttribute ("fullname", typeName), ctor) | ||
) | ||
) | ||
); | ||
|
||
var customViewMap = MonoAndroidHelper.LoadCustomViewMapFile (BuildEngine4, CustomViewMapFile); | ||
foreach (var pair in customViewMap) { | ||
index = pair.Key.IndexOf (','); | ||
if (index == -1) | ||
continue; | ||
|
||
typeName = pair.Key.Substring (0, index).Trim (); | ||
assemblyName = pair.Key.Substring (index + 1).Trim (); | ||
|
||
linker.Add (new XElement ("assembly", | ||
new XAttribute ("fullname", assemblyName), | ||
new XElement ("type", new XAttribute ("fullname", typeName), ctor) | ||
)); | ||
} | ||
|
||
if (doc.SaveIfChanged (OutputFile)) { | ||
Log.LogDebugMessage ($"Saving {OutputFile}"); | ||
} else { | ||
Log.LogDebugMessage ($"{OutputFile} is unchanged. Skipping."); | ||
} | ||
|
||
return !Log.HasLoggedErrors; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code doesn't work yet, as the file contains:
I need the full type name like
Mono.Android_Test.Library.CustomTextView, Mono.Android_Test.Library
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the acw_map.txt file might allow you to map that info back. You will probably need a new file though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to piece together the information with existing files:
customview-map.txt
has an entry with a type name and file name likeupper_lower_custom.xml
<ConvertResourcesCases/>
has$(MonoAndroidResDirIntermediate);@(_LibraryResourceDirectories)
@(_LibraryResourceDirectories)
hasOriginalFile = D:\src\xamarin-android\tests\Mono.Android-Tests\Mono.Android-Test.Library\bin\Release\net9.0-android\Mono.Android-Test.Library.NET.aar
Mono.Android-Test.Library.NET.aar
is created based onAndroidResource
files inMono.Android-Test.Library.NET.dll
So, it doesn't seem like we even have data to map back to the assembly name. I'll keep thinking about this one.