Xamarin.Forms C# Code Generation

Autogenerated by MFractor v3.6.2

Design Time Binding Context Attribute

Configuration Id: com.mfractor.code_gen.forms.design_time_binding_context_attribute

Creates an implementation of the DesignTimeBindingContextAttribute class that can be used to target MFractor towards a binding context for a class where one would normally be unresolved.

Configurable Properties

Name Type Defaults To Description
AnnotationSnippet Code Snippet

Arguments:
  • namespace: The namespace that the design time binding context resides inside.
  • type: The type to use as the design time binding context.
[$namespace$.DesignTimeBindingContext(typeof($type$))] The annotation to insert onto the code behind class to target a design time binding context.
DesignTimeBindingContextAttributeFileName System.String DesignTimeBindingContextAttribute.cs What is the filename to use when creating the design time binding context?
DesignTimeBindingContextAttributeFolderPath System.String Attributes What is the project folder path to place the to use when creating the default design time binding context?

Generate Bindable Property

Configuration Id: com.mfractor.code_gen.forms.csharp.bindable_property

Generates a Xamarin.Forms bindable property implementation and a proxy property that calls the BindableProperty implementation.

Configurable Properties

Name Type Defaults To Description
Snippet Code Snippet

Arguments:
  • name: The name of the new bindable property.
  • type: The type of the new bindable property.
  • control_type: The control type that the new bindable property has been created inside.
View Code Snippet When creating the new bindable property, what is the default code snippet MFractor should use?

Generate Custom Renderer For Xamarin.Forms Control

Configuration Id: com.mfractor.code_gen.forms.generate_control_native_renderer

For a given Xamarin.Forms user control in C#, the Generate Custom Renderer For Xamarin.Forms Control code action enables you to generate a custom renderer for that control in each iOS and Android project in your solution.

Uses:

Generate ICommand Implementation

Configuration Id: com.mfractor.code_gen.forms.csharp.command_implementation

Generates a boilerplate implementation of ICommand using an inline Xamarin.Forms.Command.

Configurable Properties

Name Type Defaults To Description
Snippet Code Snippet

Arguments:
  • name: The name of the new command.
  • type: The fully qualified type of the new command
View Code Snippet What is the code snippet to use when creating the command stub? If not set, this code generator will default to generating a stub Xamarin.Forms.Command implementation
CommandType System.String Xamarin.Forms.Command The fully qualified type to use as the command implementation. For example, using Xamarin.Forms.Command would cause the new expression to be new Xamarin.Forms.Command

Generate IValueConverter Implementation

Configuration Id: com.mfractor.code_gen.forms.csharp.value_converter

Generates an implementation of a value converter.

Configurable Properties

Name Type Defaults To Description
CreateMissingValueConversionAttribute Boolean True If an implementation of the ValueConversionAttribute class cannot be resolved within the project compilation, should MFractor automatically create the implementation?
Snippet Code Snippet

Arguments:
  • name: The name of the new value converter.
  • namespace: The namespace the new converter will be placed inside.
  • value_conversion_attribute: The fully qualified type of the value conversion attribute (if available).
  • input_type: The fully qualified type that the value converter should accept as it's input type. If unavailable, defaults to System.Object.
  • output_type: The fully qualified type that the value converter should accept as it's output type. If unavailable, defaults to System.Object.
  • parameter_type: The fully qualified type that the value converter should accept as it's parameter type. If unavailable, defaults to System.Object.
View Code Snippet What is the code snippet to use when generating the value converter class file?

Uses:

Generate Platform Specific Effect

Configuration Id: com.mfractor.code_gen.forms.csharp.platform_effect

Generates a new effect, creating the effect inside the common project as well as linked Android and iOS projects.

Configurable Properties

Name Type Defaults To Description
iOSEffectsFolder System.String Effects What is the folder that iOS platform-specific effects should be placed into?
AndroidEffectsFolder System.String Effects What is the folder that Android platform-specific effects should be placed into?
GtkEffectsFolder System.String Effects What is the folder that GTK platform-specific effects should be placed into?
EffectsFolder System.String Effects What is the folder that the effects declaration be placed into?
ResolutionGroupName System.String Effects What is the name of the resolution group?
iOSEffectSnippet Code Snippet

Arguments:
  • name: The name of the new effect.
  • group_name: The resolution group name of the new effect.
  • namespace: The iOS projects default namespace.
  • platform: If you wish to shared the platform-specific effect template, this is the name of the effects platform.
View Code Snippet What is the code snippet for the iOS platform-specific effect?
AndroidEffectSnippet Code Snippet

Arguments:
  • name: The name of the new effect.
  • group_name: The resolution group name of the new effect.
  • namespace: The Android projects default namespace.
  • platform: If you wish to shared the platform-specific effect template, this is the name of the effects platform.
View Code Snippet What is the code snippet for the Android platform-specific effect?
GtkEffectSnippet Code Snippet

Arguments:
  • name: The name of the new effect.
  • group_name: The resolution group name of the new effect.
  • namespace: The GTK projects default namespace.
  • platform: If you wish to shared the platform-specific effect template, this is the name of the effects platform.
View Code Snippet What is the code snippet for the GTK platform-specific effect?
EffectSnippet Code Snippet

Arguments:
  • name: The name of the new effect.
  • group_name: The resolution group name of the new effect.
  • namespace: The common projects default namespace.
View Code Snippet What is the code snippet for the effect?

Generate Value Conversion Attribute

Configuration Id: com.mfractor.code_gen.forms.csharp.value_conversion_attribute

Generates an implementation of the ValueConversionAttribute; the attribute used to hint type-flow in a value converter for design time tools like MFractor.

Configurable Properties

Name Type Defaults To Description
Snippet Code Snippet

Arguments:
  • namespace: The namespace that the new value conversion attribute should be placed within.
View Code Snippet What is the default code snippet to use when creating the value conversion attribute implementation?

Uses:

Generate View With XAML and Code-Behind Class

Configuration Id: com.mfractor.code_gen.forms.xaml_view_with_code_behind

Creates a new view/control using a XAML to define the UI and a code-behind class to encapsulate backing logic.

Configurable Properties

Name Type Defaults To Description
ViewsFolder System.String null What is the folder that new XAML views be placed into?
CodeBehindSnippet Code Snippet

Arguments:
  • name: The name of the new class.
  • namespace: The namespace that the new class resides inside.
  • type: The base type of the new class.
View Code Snippet What is the default implementation of the new XAML control's code behind class?

Uses:

Generates Xamarin.Forms Cascading Style Sheet

Configuration Id: com.mfractor.code_gen.forms.generate_style_sheet

Generates a new Xamarin.Forms cascading style sheet that can be used to style XAML

Configurable Properties

Name Type Defaults To Description
Snippet Code Snippet

Arguments:
  • control: The name of the control that this style sheet is for. EG: stackLayout, entry, view etc
$control$ {
margin:10;
}
The default cascading style sheet to use.
StyleFolder System.String Styles What is the folder to place new style sheets into?
DefaultControl System.String view What is the default control to use when generating new style sheets?

String Localisation Generator

Configuration Id: com.mfractor.code_gen.forms.replace_with_localisation_lookup

The string localisation generator converts literal string value inside a XAML document to a localised value lookup. This replaces the text with a localistaion lookup extension and generates a resx entry for the old value.

Configurable Properties

Name Type Defaults To Description
TranslateExtensionSymbol System.String .i18n.TranslateExtension What is the full sybol name (namespace + class name) of the translate markup extension? Prepend the symbol name with a dot to make it relative to the projects default namespace. For example, using .Localisation.TranslateExtension when the default namespace is MyApp would cause the full symbol name to become MyApp.Localisation.TranslateExtension.
TranslationXamlNamespace System.String i18n When importing a XAML namespace reference to the translation extension, what is the default namespace name that should be used?
XamlLocalisationExpression Code Snippet

Arguments:
  • namespace: The xml namespace for the translate extension symbol when used in XAML.
  • translate_extension: The name of the translation extension that's used to lookup a localised value for a given key.
  • key: The key that's used to lookup a localised value in this applications resources.
  • resx_name: The name of the RESX file to look into for the given key, excluding the .resx file extension.
{$namespace$:$translate_extension$ $key$} When importing a XAML namespace reference to the translation extension, what is the default namespace name that should be used?

Uses:

View Model Property Generator

Configuration Id: com.mfractor.code_gen.forms.csharp.view_model_property

Generates a property declaration for a Xamarin.Forms ViewModel. By default, this code generator routes to the standard PropertyGenerator. However, specifying a code snippet will cause the code generator to use that instead.

Configurable Properties

Name Type Defaults To Description
Snippet Code Snippet

Arguments:
  • type: The fully qualified type of the new property.
  • name: The name of the new property.
public $type$ $name$
{
get;
set;
}
What is the code snippet to use when creating the property declaration?
ValueSnippet Code Snippet

Arguments:
  • type: The fully qualified type of the new property.
  • name: The name of the new property.
  • value: The value to assign to the new property.
public $type$ $name$
{
get;
set;
} = $value$;
What is the code snippet to use when creating a property declaration with a default value?
DefaultEnumerableType System.String System.Collections.Generic.List When the new view model property is an IEnumerable, what is the default type that should be used instead of IEnumerable? To use the provided IEnumerable type, set this to an empty string.

XAML Localisation Infrastructure Generation

Configuration Id: com.mfractor.code_gen.forms.xaml_localisation_infrastructure

Builds the necessary infrustructure needed for XAML localisation using the best practice outlined in Localizing Xamarin.Forms Apps with RESX Resource Files.

This code generator will create the following:

MyApp.Core

  • i18n/TranslateExtension.cs:
  • i18n/ILocalise.cs: The interface that provides the current culture on each platform.

MyApp.iOS - Localise.cs: The iOS implementation of ILocalise to provide iOS's current culture.

MyApp.Android - Localise.cs: The Android implementation of ILocalise to provide iOS's current culture.

Configurable Properties

Name Type Defaults To Description
LocalisationFolder System.String i18n What is the folder that the translation extension and localiser class should be placed into?
LocaliserName System.String ILocale What is the name of the class that provides the culture information for translation extension?
ILocaliserSnippet Code Snippet

Arguments:
  • namespace: The projects namespace
  • name: The name of the new localiser interface. Defaults to ILocale
View Code Snippet The code snippet to use for the ILocalise interface that each platform project should implement.
TranslateExtensionSnippet Code Snippet

Arguments:
  • namespace: The projects namespace
  • name: The name of the translation extension class. This will be derived from the string localisation generations TranslateExtensionSymbol property.
  • resource: The fully qualified type of the resource file that the translate extension should use when looking for localisation values. This will be provided by the apps default resource file config.
  • localiser: The name of the localisation interface that provides the current culture.
View Code Snippet The code snippet to use for the translation extension.
AndroidLocaliserClassName System.String Locale_Android What is the name of the Android localiser class?
AndroidLocaliseSnippet Code Snippet

Arguments:
  • namespace: The projects namespace
  • i18n_namespace: The namespace that the translate extension and ILocale interface live within
  • localiser: The name of the localisation interface that provides the current culture.
View Code Snippet The code snippet to use for the Android implementation of the localization interface to provide the current culture.
IOSLocaliserClassName System.String Locale_iOS What is the name of the iOS localiser class?
IOSLocaliseSnippet Code Snippet

Arguments:
  • namespace: The projects namespace
  • i18n_namespace: The namespace that the translate extension and ILocale interface live within
  • localiser: The name of the localisation interface that provides the current culture.
View Code Snippet The code snippet to use for the iOS implementation of the localization interface to provide the current culture.

Uses: