This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
Bug 4453 - Localization in common project fail unless some class is referenced
: Localization in common project fail unless some class is referenced
Status: ASSIGNED
Product: iOS
Classification: Xamarin
Component: Runtime
: 5.2
: PC Mac OS
: --- normal
: 7.2.0 (iOS 7.1)
Assigned To: Sebastien Pouliot
:
:
:
:
  Show dependency treegraph
 
Reported: 2012-04-15 17:31 EDT by Ian
Modified: 2013-11-19 16:44 EST (History)
3 users (show)

See Also:
Tags:
Test Case URL:
External Submit: ---


Attachments
Common.Localization (33.19 KB, image/jpeg)
2012-04-15 17:31 EDT, Ian
Details

Description Ian 2012-04-15 17:31:07 EDT
Created attachment 1678 [details]
Common.Localization

I have a common project with the localization info for all my apps,
Common.Localization.csproj. In order for the localization, like fr.lproj to
appear in the resulting build, I have to create a dummie class in the common
project, wrap it with a [Preserve] attribute AND reference it in the app.

If there is no dummie class made, there is no common.localization.dll made and
the localization files are not sent to the .app

Here's how I make it work:

Create a dummie class in common.localization.csproj

using System;
using MonoTouch.Foundation;

//Needed to make this DLL compile and have it's resources included
namespace Common.Localization
{
    [Preserve]
    public class DummieClass
    {
        [Preserve]
        public DummieClass ()
        {
        }
    }
}


Now in the AppDelegate

var d = new DummieClass();
d=null;


Then it works.

I am hoping this is a bug as I'd rather not have write dummie references in all
my apps just to get the localization copied over to the app. It's be ok if I
just have a dummie class with [Preserve], but to have to reference it too?


Photo attached.

Version info:
MonoDevelop 2.8.8.4
Runtime:
    Mono 2.10.9 (tarball Tue Mar 20 15:31:37 EDT 2012)
    GTK 2.24.10
    GTK# (2.12.0.0)
Apple Developer Tools:
     Xcode 4.3.1 (1176)
     Build 4E1019
Monotouch: 5.2.10
Comment 2 Sebastien Pouliot 2012-04-16 09:18:19 EDT
That's likely a linker issue, i.e. removing an assembly without any code left
inside it. I'll check this, thanks for the bug report.
Comment 3 Sebastien Pouliot 2012-04-16 14:38:06 EDT
So this is not a linker issue (the same thing occurs, on device, without
linking). Once compiled there's no reference to the assembly and it is
(presently) ignored (i.e. not copied) even if it contains resources.

Your workaround ensure a reference is compiled in (so it's not excluded for
being extraneous) and the [Preserve] ensure the code is not linked out (which
could remove the reference when linked).

> It's be ok if I just have a dummie class with [Preserve],

We might be able to remove this requirement. E.g. if there's no code but some
resources are present then we could copy the assembly in the bundle. 

That needs some testing so we do not end up with SDK assemblies (that include
resources) requiring extra space in applications (for unused resources).

> but to have to reference it too?

Sadly that requirement is harder to remove. 

Without a reference mtouch would not even know about the resource assembly (as
it would not be on its command line) and the tool cannot just bring every .dll
it finds (some solutions have a lot of extraneous assemblies that are not meant
to be shipped with the app).

Now we could have another way to "mark" them but it would not be any simpler
than the (existing) "add reference". Also there is IMO a reference between them
- as the main app will refer to the resource-only assembly.
Comment 4 Ian 2012-04-16 15:29:44 EDT
In this case I would say the risk-reward is not favorable. I recommend leaving
it as is.
Comment 7 PJ 2013-11-19 16:44:52 EST
This bug was targeted for a past milestone, moving to the next non-hotfix
active milestone.

Note You need to log in before you can comment on or make changes to this bug.