Uh oh!
There was an error while loading. Please reload this page.
[Xamarin.Android.Build.Tasks] Add support for '<AndroidNamespaceReplacement>'. - #6643
Conversation
b1ba3b9 to
3776da5Comparejonpryor
commented
Jan 20, 2022
The |
| // ex: obj/Debug/generated/msbuild-metadata.xml | ||
| var transform_file = Path.Combine (OutputDirectory, "..", "msbuild-metadata.xml"); | ||
| var xml = new XDocument (); |
There was a problem hiding this comment.
I'm not sure you need the XDocument at all? XElement.WriteTo() also works…
jonpryor
commented
Jan 20, 2022
@jpobst: the new item group should also be documented in: https://github.com/xamarin/xamarin-android/blob/main/Documentation/guides/building-apps/build-items.md |
| xml.Add (root); | ||
| foreach (var nt in NamespaceTransforms) | ||
| xml.Root.Add (new XElement ("ns-replace", new XAttribute ("source", nt.ItemSpec), new XAttribute ("replacement", nt.GetMetadata ("replacement")))); |
There was a problem hiding this comment.
Should we emit a warning/error if %(Replacement) is blank? I'm just thinking if someone put Replace="AndroidX" on accident, they won't know what's wrong?
There was a problem hiding this comment.
%(Replacement) being blank is valid and useful. I guess the question is should we require users to provide the blank attribute Replacement=""? Perhaps we should?
There was a problem hiding this comment.
Added and documented new error.
| { | ||
| var cmd = GetCommandLineBuilder (); | ||
| if (NamespaceTransforms?.Any () == true) { |
There was a problem hiding this comment.
This is probably fine, but feels weird. Would this be just as good?
| if(NamespaceTransforms?.Any()==true){ | |
| if(NamespaceTransforms!=null&&NamespaceTransforms.Length>0){ |
There was a problem hiding this comment.
Yes, those are equivalent. I think Any and null-check operator is generally considered the modern "best practice".
There was a problem hiding this comment.
I generally avoid using System.Linq;, but there are some cases where OrderBy() is ok.
This is fine, though.
Uh oh!
There was an error while loading. Please reload this page.
d5e6aca to
476d740Compare476d740 to
3607637Compare
Context: dotnet/java-interop#727
Add an MSBuild equivalent to the
<ns-replace>metadata feature added in dotnet/java-interop#727.This takes namespace transforms like:
And places them into a generated
msbuild-metadata.xmlfile that is passed togenerator:Today, this only supports
<ns-replace>metadata, but it could be expanded in the future if we feel that allowing other metadata is desirable. (I am personally skeptical 😁.)