android: Auto generated Resource.designer.cs does not support aliased references

Steps to Reproduce

  1. Add reference to library targeted for monoandroid with alias (containing resources), example:
<ProjectReference Include="..\LibraryA\LibraryA.csproj">
  <Project>{A31DB667-7565-4C13-99CD-82064660960F}</Project>
  <Name>LibraryA</Name>
  <Aliases>LibA</Aliases>
</ProjectReference>
  1. Build main project

Example project: AliasExample.zip

Expected Behavior

Project builds properly.

Actual Behavior

Build fails with following error: Resources/Resource.designer.cs(29,12,29,20): error CS0400: The type or namespace name 'LibraryA' could not be found in the global namespace (are you missing an assembly reference?)

The generated Resource.designer.cs file contains the reference to resource in aliased library, but the reference is using global instead of proper LibA alias:

#pragma warning disable 1591
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.42000
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

[assembly: global::Android.Runtime.ResourceDesignerAttribute("AliasExample.Droid.Resource", IsApplication=true)]

namespace AliasExample.Droid
{
	
	
	[System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "1.0.0.0")]
	public partial class Resource
	{
		
		static Resource()
		{
			global::Android.Runtime.ResourceIdManager.UpdateIdValues();
		}
		
		public static void UpdateIdValues()
		{
			global::LibraryA.Resource.String.action_settings = global::AliasExample.Droid.Resource.String.action_settings;
			global::LibraryA.Resource.String.app_name = global::AliasExample.Droid.Resource.String.app_name;
...

Version Information

=== Visual Studio Community 2019 for Mac ===

Version 8.3.4 (build 8) Installation UUID: f31f4dd5-2c32-43ce-b1bd-a42b00d292f1 GTK+ 2.24.23 (Raleigh theme) Xamarin.Mac 5.16.1.24 (d16-3 / 08809f5b)

Package version: 604000208

=== Mono Framework MDK ===

Runtime: Mono 6.4.0.208 (2019-06/07c23f2ca43) (64-bit) Package version: 604000208

=== NuGet ===

Version: 5.3.0.6192

=== .NET Core SDK ===

SDK: /usr/local/share/dotnet/sdk/3.0.100/Sdks SDK Versions: 3.0.100 2.2.300 2.2.106 2.1.505 2.1.504 2.1.202 MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/6.4.0/lib/mono/msbuild/Current/bin/Sdks

=== .NET Core Runtime ===

Runtime: /usr/local/share/dotnet/dotnet Runtime Versions: 3.0.0 2.2.5 2.2.4 2.1.13 2.1.9 2.1.8 2.0.9

=== Xamarin.Profiler ===

Version: 1.6.12.26 Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Updater ===

Version: 11

=== Xamarin.Android ===

Version: 10.0.3.0 (Visual Studio Community) Commit: xamarin-android/d16-3/4d45b41 Android SDK: /Users/grko/Library/Developer/Xamarin/android-sdk-macosx Supported Android versions: 7.1 (API level 25) 8.0 (API level 26) 8.1 (API level 27)

SDK Tools Version: 26.1.1 SDK Platform Tools Version: 29.0.4 SDK Build Tools Version: 29.0.2

Build Information: Mono: mono/mono/2019-06@5608fe0abb3 Java.Interop: xamarin/java.interop/d16-3@5836f58 LibZipSharp: grendello/LibZipSharp/d16-3@71f4a94 LibZip: nih-at/libzip/rel-1-5-1@b95cf3fd ProGuard: xamarin/proguard/master@905836d SQLite: xamarin/sqlite/3.27.1@8212a2d Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-3@cb41333

=== Microsoft Mobile OpenJDK ===

Java SDK: /Users/grko/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_1.8.0.25 1.8.0-25 Android Designer EPL code available here: https://github.com/xamarin/AndroidDesigner.EPL

=== Android SDK Manager ===

Version: 1.4.0.65 Hash: c33b107 Branch: remotes/origin/d16-3 Build date: 2019-10-08 23:36:20 UTC

=== Android Device Manager ===

Version: 1.2.0.116 Hash: d2b2af0 Branch: remotes/origin/d16-3 Build date: 2019-10-08 23:36:44 UTC

=== Xamarin Inspector ===

Version: 1.4.3 Hash: db27525 Branch: 1.4-release Build date: Mon, 09 Jul 2018 21:20:18 GMT Client compatibility: 1

=== Apple Developer Tools ===

Xcode 11.1 (15405) Build 11A1027

=== Xamarin.Mac ===

Version: 6.4.0.2 (Visual Studio Community) Hash: e37549bc Branch: xcode11.1 Build date: 2019-10-07 22:43:23-0400

=== Xamarin.iOS ===

Version: 13.4.0.2 (Visual Studio Community) Hash: e37549bc Branch: xcode11.1 Build date: 2019-10-07 22:43:23-0400

=== Xamarin Designer ===

Version: 16.3.0.247 Hash: 52eac1a9e Branch: remotes/origin/d16-3 Build date: 2019-10-03 23:04:28 UTC

=== Build Information ===

Release ID: 803040008 Git revision: 8da5857bc3d33e5667cacaab3bd1ab55375ed3e3 Build date: 2019-10-14 18:26:13+00 Build branch: release-8.3 Xamarin extensions: 61c91e660a01512a3b8187c749fd3bccc75a2bf4

=== Operating System ===

Mac OS X 10.14.6 Darwin 18.7.0 Darwin Kernel Version 18.7.0 Thu Jun 20 18:42:21 PDT 2019 root:xnu-4903.270.47~4/RELEASE_X86_64 x86_64

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 1
  • Comments: 17 (9 by maintainers)

Commits related to this issue

Most upvoted comments

@brendanzagaeski #4542 is the new issue I created, if you are interested. Thanks again for your help.

@aquakul sorry for the delay. It took some time to figure out how to do what is needed using the CodeDom. I think I have a solution now, I’ll be putting up a PR today hopefully. Unfortunately the only workaround for now is to not use the Aliases feature, since the Resource.Designer.cs code generator is part of our build process. This Issue will be updated when the PR is opened.