Edit

Share via


LinkerSafeAttribute Class

Definition

Assembly-level attributed used to inform MonoTouch's linker that this assembly can be safely linked, regardless of the system linker settings.

[System.AttributeUsage(System.AttributeTargets.Assembly)]
public sealed class LinkerSafeAttribute : Attribute
type LinkerSafeAttribute = class
    inherit Attribute
Inheritance
LinkerSafeAttribute
Attributes

Remarks

Use this attribute in your assembly if it is safe to perform linking on it, regardless of the user default setting to "Link only Framework Assemblies.

The use case for this attribute are third-party libraries that are safe to be linked because they have either safe to be linked because they do not depend on members or methods to be compiled in to work, or if they do, they used the PreserveAttribute to preserve those classes.

The default configuration for MonoTouch projects is to link only the SDK assemblies, and not link user code or third party assemblies. But many third party assemblies might want to reduce their on-disk footprint by informing the linker that they are linkable. Use this attribute in those cases.

You do not actually need to take a dependency on the Xamarin assemblies, for example, if you are a third-party developer that is creating a component or nuget package that is safe to be linked, you can just include the LinkerSafe attribute source code in your application, and the Xamarin linker will recognize it.

To use, merely add the following snippet to your source code in your assembly:

[assembly:LinkerSafe]

To use in an assembly, without taking a dependency in Xamarin's assemblies:

class LinkerSafeAttribute : System.Attribute {
    public LinkerSafeAttribute () {}
}

[assembly:LinkerSafe]

Constructors

LinkerSafeAttribute()

Default attribute constructor.

Applies to