Skip to content

Commit

Permalink
Bump to xamarin/xamarin-android-tools/main@099fd95 (#7709)
Browse files Browse the repository at this point in the history
Context: dotnet/maui#11605
Context: dotnet/maui#11387 (comment)
Context: http://github.com/xamarin/xamarin-android/commit/8bc7a3e84f95e70fe12790ac31ecd97957771cb2

Changes: dotnet/android-tools@9f02d77...099fd95

  * dotnet/android-tools@099fd95: Add *Task.ProjectSpecificTaskObjectKey() for RegisterTaskObject() use (dotnet/android-tools#202)
  * dotnet/android-tools@ac9ea09: Revert IBuildEngine.ProjectFileOfTaskNode use. (dotnet/android-tools#201)
  * dotnet/android-tools@47f95ab: Fix CS0121 ambiguity errors. (dotnet/android-tools#200)
  * dotnet/android-tools@76c076f: Add support for Project Specific RegisterTaskObject. (dotnet/android-tools#199)

In dotnet/maui#11605, when `$(AndroidEnableMarshalMethods)`=True
(8bc7a3e8), the build may fail if the `.sln`
contains more than one Android "App" project.  We tracked this down
to "undesired sharing" between project builds; the `obj` provided to
[`IBuildEngine4.RegisterTaskObject()`][0] can be visible across
project builds.  Consider [`<GeneratePackageManagerJava/>`][1]:

	var marshalMethodsState = BuildEngine4.GetRegisteredTaskObjectAssemblyLocal<MarshalMethodsState> (".:!MarshalMethods!:.", RegisteredTaskObjectLifetime.Build);

Further consider a `.sln` with two "App" projects, as the "App"
project build hits `<GeneratePackageManagerJava/>`, e.g. the new
`IncrementalBuildTest.BuildSolutionWithMultipleProjectsInParallel()`
unit test.  The lifetime of `RegisteredTaskObjectLifetime.Build` is
*not* tied to the the `Build` target of a given `.csproj`; rather,
it's for the *build process*.  This can result in:

 1. `dotnet build Project.sln` is run; `Project.sln` references
    `App1.csproj` and `App2.csproj`.
 2. `App1.csproj` is built.
 3. `App1.csproj` calls `<GeneratePackageManagerJava/>`.
 4. `App2.csproj` is later built as part of the process, and *also*
    calls `<GeneratePackageManagerJava/>`.

In particular note the key within `<GeneratePackageManagerJava/>`:
`".:!MarshalMethods!:."`.  This value is identical in all projects,
and means that that when `App2.csproj` is built, it will be using the
same key as was used with `App1.csproj`, and thus could be
inadvertently using data intended for `App1.csproj`!

This would result build errors:

	…\Xamarin.Android.Common.targets(1717,3): error XAGPM7009: System.InvalidOperationException: Unable to translate assembly name 'Xamarin.AndroidX.Activity' to its index
	…\Xamarin.Android.Common.targets(1717,3): error XAGPM7009:    at Xamarin.Android.Tasks.MarshalMethodsNativeAssemblyGenerator.WriteNativeMethods(LlvmIrGenerator generator, Dictionary`2 asmNameToIndex, LlvmIrVariableReference get_function_pointer_ref)
	…\Xamarin.Android.Common.targets(1717,3): error XAGPM7009:    at Xamarin.Android.Tasks.MarshalMethodsNativeAssemblyGenerator.Write(LlvmIrGenerator generator)
	…\Xamarin.Android.Common.targets(1717,3): error XAGPM7009:    at Xamarin.Android.Tasks.LLVMIR.LlvmIrComposer.Write(AndroidTargetArch arch, StreamWriter output, String fileName)
	…\Xamarin.Android.Common.targets(1717,3): error XAGPM7009:    at Xamarin.Android.Tasks.GeneratePackageManagerJava.AddEnvironment()
	…\Xamarin.Android.Common.targets(1717,3): error XAGPM7009:    at Xamarin.Android.Tasks.GeneratePackageManagerJava.RunTask()

The sharing of `RegisterTaskObject()` data across project builds is
rarely desirable.  There are a few instances where it is safe to share
the registered objects between projects, e.g. `java -version` version
information (keyed on `java` path).  However, most of the time it is
specific to the project that is being built.  Historically we have
probably got away with this because "most" users only have one project.

dotnet/android-tools@099fd95 added the methods
`AndroidTask.ProjectSpecificTaskObjectKey(object)`, 
`AndroidAsyncTask.ProjectSpecificTaskObjectKey(object)`, and
`AndroidToolTask.ProjectSpecificTaskObjectKey(object)` which returns
an `object` for use as the key to `RegisteredTaskObject()`, and the
value is a tuple which includes the input `object` *and* the
`Directory.GetCurrentDirectory()` value present when the task was
created.  (Background note: when MSBuild builds a project, it calls
`Directory.SetCurrentDirectory()` to the directory of the current
project, which is why relative file paths to work in `.csproj` files.)

Review use of the `MSBuildExtensions.RegisterTaskObjectAssemblyLocal()`
extension method and audit the key value.  If the registered value is
project specific, update the callsite to use
`ProjectSpecificTaskObjectKey(object)`, ensuring that project-specific
data is not accidentally reused in a different project.

[0]: https://learn.microsoft.com/en-us/dotnet/api/microsoft.build.framework.ibuildengine4.registertaskobject?view=msbuild-17-netcore
[1]: https://github.com/xamarin/xamarin-android/blob/c92ae5eb9fdcb3a2fd7c20f5b42dddf8b3ea781a/src/Xamarin.Android.Build.Tasks/Tasks/GeneratePackageManagerJava.cs#L407
[2]: https://github.com/xamarin/Xamarin.Build.AsyncTask/blob/8b5fc6c4d13a3dfd1d17a2007e2143b6da3447d7/Xamarin.Build.AsyncTask/AsyncTask.cs#L59
  • Loading branch information
dellis1972 authored Jan 19, 2023
1 parent b5d1d22 commit 22f10b2
Show file tree
Hide file tree
Showing 19 changed files with 63 additions and 35 deletions.
2 changes: 1 addition & 1 deletion external/xamarin-android-tools
2 changes: 1 addition & 1 deletion src/Xamarin.Android.Build.Tasks/Tasks/Aapt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public class Aapt : AndroidAsyncTask
AssemblyIdentityMap assemblyMap = new AssemblyIdentityMap ();
string resourceDirectory;

Dictionary<string, string> resource_name_case_map => _resource_name_case_map ??= MonoAndroidHelper.LoadResourceCaseMap (BuildEngine4);
Dictionary<string, string> resource_name_case_map => _resource_name_case_map ??= MonoAndroidHelper.LoadResourceCaseMap (BuildEngine4, ProjectSpecificTaskObjectKey);

bool ManifestIsUpToDate (string manifestFile)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Xamarin.Android.Build.Tasks/Tasks/Aapt2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public abstract class Aapt2 : AndroidAsyncTask {
private static readonly int DefaultMaxAapt2Daemons = 6;
protected Dictionary<string, string> _resource_name_case_map;

Dictionary<string, string> resource_name_case_map => _resource_name_case_map ??= MonoAndroidHelper.LoadResourceCaseMap (BuildEngine4);
Dictionary<string, string> resource_name_case_map => _resource_name_case_map ??= MonoAndroidHelper.LoadResourceCaseMap (BuildEngine4, ProjectSpecificTaskObjectKey);

protected virtual int ProcessorCount => Environment.ProcessorCount;

Expand Down
22 changes: 11 additions & 11 deletions src/Xamarin.Android.Build.Tasks/Tasks/AndroidComputeResPaths.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
//
//
// AndroidUpdateResDir.cs
//
//
// Author:
// Michael Hutchinson <mhutchinson@novell.com>
//
//
// Copyright (c) 2010 Novell, Inc. (http://www.novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Expand All @@ -41,18 +41,18 @@ public class AndroidComputeResPaths : AndroidTask

[Required]
public ITaskItem[] ResourceFiles { get; set; }

[Required]
public string IntermediateDir { get; set; }

public string Prefixes { get; set; }

public bool LowercaseFilenames { get; set; }

public string ProjectDir { get; set; }

public string AndroidLibraryFlatFilesDirectory { get; set; }

[Output]
public ITaskItem[] IntermediateFiles { get; set; }

Expand All @@ -63,7 +63,7 @@ public override bool RunTask ()
{
var intermediateFiles = new List<ITaskItem> (ResourceFiles.Length);
var resolvedFiles = new List<ITaskItem> (ResourceFiles.Length);

string[] prefixes = Prefixes != null ? Prefixes.Split (';') : null;
if (prefixes != null) {
for (int i = 0; i < prefixes.Length; i++) {
Expand Down Expand Up @@ -145,7 +145,7 @@ public override bool RunTask ()

IntermediateFiles = intermediateFiles.ToArray ();
ResolvedResourceFiles = resolvedFiles.ToArray ();
MonoAndroidHelper.SaveResourceCaseMap (BuildEngine4, nameCaseMap);
MonoAndroidHelper.SaveResourceCaseMap (BuildEngine4, nameCaseMap, ProjectSpecificTaskObjectKey);
return !Log.HasLoggedErrors;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ string RegisterGroupWidgets (ICollection<LayoutWidget> widgets)
{
string key = Guid.NewGuid ().ToString ();
LogDebugMessage ($"Registering {widgets?.Count} widgets for key {key}");
BuildEngine4.RegisterTaskObjectAssemblyLocal (key, widgets, RegisteredTaskObjectLifetime.Build, allowEarlyCollection: false);
BuildEngine4.RegisterTaskObjectAssemblyLocal (ProjectSpecificTaskObjectKey (key), widgets, RegisteredTaskObjectLifetime.Build, allowEarlyCollection: false);
return key;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Xamarin.Android.Build.Tasks/Tasks/ConvertCustomView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ public class ConvertCustomView : AndroidTask {
public ITaskItem [] Processed { get; set; }

Dictionary<string, string> _resource_name_case_map;
Dictionary<string, string> resource_name_case_map => _resource_name_case_map ??= MonoAndroidHelper.LoadResourceCaseMap (BuildEngine4);
Dictionary<string, string> resource_name_case_map => _resource_name_case_map ??= MonoAndroidHelper.LoadResourceCaseMap (BuildEngine4, ProjectSpecificTaskObjectKey);

public override bool RunTask ()
{
var acw_map = MonoAndroidHelper.LoadMapFile (BuildEngine4, AcwMapFile, StringComparer.Ordinal);
var acw_map = MonoAndroidHelper.LoadMapFile (BuildEngine4, Path.GetFullPath (AcwMapFile), StringComparer.Ordinal);
var customViewMap = MonoAndroidHelper.LoadCustomViewMapFile (BuildEngine4, CustomViewMapFile);
var processed = new HashSet<string> ();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class ConvertResourcesCases : AndroidTask
Dictionary<string,string> _resource_name_case_map;
Dictionary<string, HashSet<string>> customViewMap;

Dictionary<string, string> resource_name_case_map => _resource_name_case_map ??= MonoAndroidHelper.LoadResourceCaseMap (BuildEngine4);
Dictionary<string, string> resource_name_case_map => _resource_name_case_map ??= MonoAndroidHelper.LoadResourceCaseMap (BuildEngine4, ProjectSpecificTaskObjectKey);

public override bool RunTask ()
{
Expand Down Expand Up @@ -73,7 +73,7 @@ void FixupResources (ITaskItem item)
lastUpdate = File.GetLastWriteTimeUtc (AndroidConversionFlagFile);
}
Log.LogDebugMessage (" AndroidConversionFlagFile modified: {0}", lastUpdate);

var resourcedirectories = new List<string> ();
foreach (var dir in ResourceDirectories) {
if (dir == item)
Expand Down
4 changes: 2 additions & 2 deletions src/Xamarin.Android.Build.Tasks/Tasks/GenerateJavaStubs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ bool CreateJavaSources (IEnumerable<TypeDefinition> javaTypes, TypeDefinitionCac
}

if (useMarshalMethods) {
BuildEngine4.RegisterTaskObjectAssemblyLocal (MarshalMethodsRegisterTaskKey, new MarshalMethodsState (classifier.MarshalMethods), RegisteredTaskObjectLifetime.Build);
BuildEngine4.RegisterTaskObjectAssemblyLocal (ProjectSpecificTaskObjectKey (MarshalMethodsRegisterTaskKey), new MarshalMethodsState (classifier.MarshalMethods), RegisteredTaskObjectLifetime.Build);
}

return ok;
Expand Down Expand Up @@ -575,7 +575,7 @@ void WriteTypeMappings (List<TypeDefinition> types, TypeDefinitionCache cache)
if (!tmg.Generate (Debug, SkipJniAddNativeMethodRegistrationAttributeScan, types, cache, TypemapOutputDirectory, GenerateNativeAssembly, out ApplicationConfigTaskState appConfState))
throw new XamarinAndroidException (4308, Properties.Resources.XA4308);
GeneratedBinaryTypeMaps = tmg.GeneratedBinaryTypeMaps.ToArray ();
BuildEngine4.RegisterTaskObjectAssemblyLocal (ApplicationConfigTaskState.RegisterTaskObjectKey, appConfState, RegisteredTaskObjectLifetime.Build);
BuildEngine4.RegisterTaskObjectAssemblyLocal (ProjectSpecificTaskObjectKey (ApplicationConfigTaskState.RegisterTaskObjectKey), appConfState, RegisteredTaskObjectLifetime.Build);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void Generate (JniRemappingAssemblyGenerator jniRemappingGenerator, int typeRepl
}

BuildEngine4.RegisterTaskObjectAssemblyLocal (
JniRemappingNativeCodeInfoKey,
ProjectSpecificTaskObjectKey (JniRemappingNativeCodeInfoKey),
new JniRemappingNativeCodeInfo (typeReplacementsCount, jniRemappingGenerator.ReplacementMethodIndexEntryCount),
RegisteredTaskObjectLifetime.Build
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ void GenerateSourceForLayoutGroup (BindingGenerator generator, LayoutGroup group
if (!GetRequiredMetadata (item, CalculateLayoutCodeBehind.WidgetCollectionKeyMetadata, out collectionKey))
return;

ICollection<LayoutWidget> widgets = BuildEngine4.GetRegisteredTaskObjectAssemblyLocal<ICollection<LayoutWidget>> (collectionKey, RegisteredTaskObjectLifetime.Build);
ICollection<LayoutWidget> widgets = BuildEngine4.GetRegisteredTaskObjectAssemblyLocal<ICollection<LayoutWidget>> (ProjectSpecificTaskObjectKey (collectionKey), RegisteredTaskObjectLifetime.Build);
if ((widgets?.Count ?? 0) == 0) {
string inputPaths = String.Join ("; ", resourceItems.Select (i => i.ItemSpec));
LogCodedWarning ("XA4222", Properties.Resources.XA4222, inputPaths);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,8 @@ void AddEnvironment ()
}

bool haveRuntimeConfigBlob = !String.IsNullOrEmpty (RuntimeConfigBinFilePath) && File.Exists (RuntimeConfigBinFilePath);
var appConfState = BuildEngine4.GetRegisteredTaskObjectAssemblyLocal<ApplicationConfigTaskState> (ApplicationConfigTaskState.RegisterTaskObjectKey, RegisteredTaskObjectLifetime.Build);
var jniRemappingNativeCodeInfo = BuildEngine4.GetRegisteredTaskObjectAssemblyLocal<GenerateJniRemappingNativeCode.JniRemappingNativeCodeInfo> (GenerateJniRemappingNativeCode.JniRemappingNativeCodeInfoKey, RegisteredTaskObjectLifetime.Build);
var appConfState = BuildEngine4.GetRegisteredTaskObjectAssemblyLocal<ApplicationConfigTaskState> (ProjectSpecificTaskObjectKey (ApplicationConfigTaskState.RegisterTaskObjectKey), RegisteredTaskObjectLifetime.Build);
var jniRemappingNativeCodeInfo = BuildEngine4.GetRegisteredTaskObjectAssemblyLocal<GenerateJniRemappingNativeCode.JniRemappingNativeCodeInfo> (ProjectSpecificTaskObjectKey (GenerateJniRemappingNativeCode.JniRemappingNativeCodeInfoKey), RegisteredTaskObjectLifetime.Build);
var appConfigAsmGen = new ApplicationConfigNativeAssemblyGenerator (environmentVariables, systemProperties, Log) {
IsBundledApp = IsBundledApplication,
UsesMonoAOT = usesMonoAOT,
Expand Down Expand Up @@ -404,7 +404,7 @@ void AddEnvironment ()
};
appConfigAsmGen.Init ();

var marshalMethodsState = BuildEngine4.GetRegisteredTaskObjectAssemblyLocal<MarshalMethodsState> (GenerateJavaStubs.MarshalMethodsRegisterTaskKey, RegisteredTaskObjectLifetime.Build);
var marshalMethodsState = BuildEngine4.GetRegisteredTaskObjectAssemblyLocal<MarshalMethodsState> (ProjectSpecificTaskObjectKey (GenerateJavaStubs.MarshalMethodsRegisterTaskKey), RegisteredTaskObjectLifetime.Build);
MarshalMethodsNativeAssemblyGenerator marshalMethodsAsmGen;

if (enableMarshalMethods) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public override bool RunTask ()

var javaPlatformDirectory = Path.GetDirectoryName (JavaPlatformJarPath);

resource_fixup = MonoAndroidHelper.LoadMapFile (BuildEngine4, CaseMapFile, StringComparer.OrdinalIgnoreCase);
resource_fixup = MonoAndroidHelper.LoadMapFile (BuildEngine4, Path.GetFullPath (CaseMapFile), StringComparer.OrdinalIgnoreCase);

// Parse out the resources from the R.java file
CodeTypeDeclaration resources;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ bool Run(DirectoryAssemblyResolver res)

string assemblyName = Path.GetFileNameWithoutExtension (OutputFile.ItemSpec);

resource_fixup = MonoAndroidHelper.LoadMapFile (BuildEngine4, CaseMapFile, StringComparer.OrdinalIgnoreCase);
resource_fixup = MonoAndroidHelper.LoadMapFile (BuildEngine4, Path.GetFullPath (CaseMapFile), StringComparer.OrdinalIgnoreCase);
// Generate an assembly which contains all the values in the provided
// R.txt file.
var mp = new ModuleParameters ();
Expand Down
2 changes: 1 addition & 1 deletion src/Xamarin.Android.Build.Tasks/Tasks/GenerateRtxt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public override bool RunTask ()
// Parse the Resource files and then generate an R.txt file
var writer = new RtxtWriter ();

var resource_fixup = MonoAndroidHelper.LoadMapFile (BuildEngine4, CaseMapFile, StringComparer.OrdinalIgnoreCase);
var resource_fixup = MonoAndroidHelper.LoadMapFile (BuildEngine4, Path.GetFullPath (CaseMapFile), StringComparer.OrdinalIgnoreCase);

var javaPlatformDirectory = Path.GetDirectoryName (JavaPlatformJarPath);
var parser = new FileResourceParser () { Log = Log, JavaPlatformDirectory = javaPlatformDirectory, ResourceFlagFile = ResourceFlagFile};
Expand Down
2 changes: 1 addition & 1 deletion src/Xamarin.Android.Build.Tasks/Tasks/Lint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class Lint : AndroidToolTask
string text;
string type;

Dictionary<string, string> resource_name_case_map => _resource_name_case_map ??= MonoAndroidHelper.LoadResourceCaseMap (BuildEngine4);
Dictionary<string, string> resource_name_case_map => _resource_name_case_map ??= MonoAndroidHelper.LoadResourceCaseMap (BuildEngine4, ProjectSpecificTaskObjectKey);

[Required]
public string TargetDirectory { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,30 @@ public void AllProjectsHaveSameOutputDirectory()
sb.Dispose ();
}

[Test]
public void BuildSolutionWithMultipleProjectsInParallel ()
{
var testPath = Path.Combine ("temp", "BuildSolutionWithMultipleProjects");
var sb = new SolutionBuilder("BuildSolutionWithMultipleProjects.sln") {
SolutionPath = Path.Combine (Root, testPath),
MaxCpuCount = 4,
};
for (int i=1; i <= 4; i++) {
var app1 = new XamarinAndroidApplicationProject () {
ProjectName = $"App{i}",
PackageName = $"com.companyname.App{i}",
AotAssemblies = true,
IsRelease = true,
};
app1.SetProperty ("AndroidEnableMarshalMethods", "True");
sb.Projects.Add (app1);
}
sb.BuildingInsideVisualStudio = false;
Assert.IsTrue (sb.Build (), "Build of solution should have succeeded");
Assert.IsTrue (sb.ReBuild (), "ReBuild of solution should have succeeded");
sb.Dispose ();
}

[Test]
public void JavacTaskDoesNotRunOnSecondBuild ()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ public void Aapt2CompileFixesUpErrors ()
MonoAndroidHelper.SaveResourceCaseMap (engine, new Dictionary<string, string> {
{ $"layout{directorySeperator}main.axml", $"Layout{directorySeperator}Main.xml" },
{ $"values{directorySeperator}strings.xml", $"Values{directorySeperator}Strings.xml" },
});
}, (o) => { return (o, path);} );
var task = new Aapt2Compile {
BuildEngine = engine,
ToolPath = GetPathToAapt2 (),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,7 @@ public void RtxtGeneratorOutput ()
BuildEngine = engine,
RTxtFile = rTxt,
ResourceDirectory = resPath,
CaseMapFile = Path.Combine (Root, path, "case_map.txt"),
JavaPlatformJarPath = Path.Combine (AndroidSdkDirectory, "platforms", $"android-{platform}", "android.jar"),
ResourceFlagFile = Path.Combine (Root, path, "res.flag"),
AdditionalResourceDirectories = new string[] {
Expand Down Expand Up @@ -600,6 +601,7 @@ public void CompareAapt2AndManagedParserOutput ()
task.Namespace = "MonoAndroidApplication4.MonoAndroidApplication4";
task.NetResgenOutputFile = Path.Combine (Root, path, "Resource.designer.aapt2.cs");
task.ProjectDir = Path.Combine (Root, path);
task.CaseMapFile = Path.Combine (Root, path, "case_map.txt");
task.ResourceDirectory = Path.Combine (Root, path, "res") + Path.DirectorySeparatorChar;
task.Resources = new TaskItem [] {
new TaskItem (Path.Combine (Root, path, "res", "values", "strings.xml"), new Dictionary<string, string> () {
Expand Down Expand Up @@ -667,6 +669,7 @@ public void CompareAaptAndManagedParserOutputWithCustomIds ()
task.Namespace = "MonoAndroidApplication4.MonoAndroidApplication4";
task.NetResgenOutputFile = Path.Combine (Root, path, "Resource.designer.aapt.cs");
task.ProjectDir = Path.Combine (Root, path);
task.CaseMapFile = Path.Combine (Root, path, "case_map.txt");
task.ResourceDirectory = Path.Combine (Root, path, "res") + Path.DirectorySeparatorChar;
task.Resources = new TaskItem [] {
new TaskItem (Path.Combine (Root, path, "res", "values", "strings.xml"), new Dictionary<string, string> () {
Expand Down Expand Up @@ -806,6 +809,7 @@ int styleable ElevenAttributes_attr09 9
task.Namespace = "Foo.Foo";
task.NetResgenOutputFile = Path.Combine (Root, path, "Resource.designer.cs");
task.ProjectDir = Path.Combine (Root, path);
task.CaseMapFile = Path.Combine (Root, path, "case_map.txt");
task.ResourceDirectory = Path.Combine (Root, path, "res");
task.Resources = new TaskItem [] {};
task.IsApplication = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -497,11 +497,11 @@ public static string TryGetAndroidJarPath (TaskLoggingHelper log, string platfor

static readonly string ResourceCaseMapKey = $"{nameof (MonoAndroidHelper)}_ResourceCaseMap";

public static void SaveResourceCaseMap (IBuildEngine4 engine, Dictionary<string, string> map) =>
engine.RegisterTaskObjectAssemblyLocal (ResourceCaseMapKey, map, RegisteredTaskObjectLifetime.Build);
public static void SaveResourceCaseMap (IBuildEngine4 engine, Dictionary<string, string> map, Func<object, object> keyCallback) =>
engine.RegisterTaskObjectAssemblyLocal (keyCallback (ResourceCaseMapKey), map, RegisteredTaskObjectLifetime.Build);

public static Dictionary<string, string> LoadResourceCaseMap (IBuildEngine4 engine) =>
engine.GetRegisteredTaskObjectAssemblyLocal<Dictionary<string, string>> (ResourceCaseMapKey, RegisteredTaskObjectLifetime.Build) ?? new Dictionary<string, string> (0);
public static Dictionary<string, string> LoadResourceCaseMap (IBuildEngine4 engine, Func<object, object> keyCallback) =>
engine.GetRegisteredTaskObjectAssemblyLocal<Dictionary<string, string>> (keyCallback (ResourceCaseMapKey), RegisteredTaskObjectLifetime.Build) ?? new Dictionary<string, string> (0);

public static string FixUpAndroidResourcePath (string file, string resourceDirectory, string resourceDirectoryFullPath, Dictionary<string, string> resource_name_case_map)
{
Expand Down

0 comments on commit 22f10b2

Please sign in to comment.