Created attachment 1678 [details]
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
//Needed to make this DLL compile and have it's resources included
public class DummieClass
public DummieClass ()
Now in the AppDelegate
var d = new DummieClass();
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?
Mono 2.10.9 (tarball Tue Mar 20 15:31:37 EDT 2012)
Apple Developer Tools:
Xcode 4.3.1 (1176)
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.
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.
In this case I would say the risk-reward is not favorable. I recommend leaving it as is.
This bug was targeted for a past milestone, moving to the next non-hotfix active milestone.
It's now possible to preserve a type from another assembly, e.g.
> [assembly: Preserve (typeof (Common.Localization.DummieClass))]
which reduce a bit the code required in both the main and resource .dll. However it still requires a reference to exists.