Autogenerated by MFractor v3.2.13

Annotate With Attribute Usage

Professional Only

Configuration Id: com.mfractor.code_actions.csharp.annotate_with_attribute_usage

Adds an AttributeUsage annotation to a class that derives directly or indirectly from System.Attribute.

Annodate an attribute with an AttributeUsage attribute

Configurable Properties

Name Type Defaults To Description
DefaultAttributeUsage System.AttributeTargets Class When creating the attribute usage annotation, what is the default target this attribute should be used on?

Uses:

Assign Constructor Argument To Member

Professional Only

Configuration Id: com.mfractor.code_actions.csharp.assign_constructor_argument_to_member

When a constructor argument matches a member that isn't assigned by the constructor, this code action will generate an expression that assigns the argument to the member.

Assign constructor

Uses:

Create Immutable Constructor

Professional Only

Configuration Id: com.mfractor.code_actions.csharp.create_immutable_constuctor

This code action creates a constructor that assigns all of a classes readonly fields from constructor arguments

The Create Immutable Constructor code action is useful when building readonly class implementations.

When triggered, the code action collects all readonly fields in a class and builds a constructor that has a parameter that assigns to each readonly field.

Before

public class MyImmutableClass
{
    public readonly string MyString;
    public readonly int MyInt;
}

After

public class MyImmutableClass
{
    public readonly string MyString;
    public readonly int MyInt;

    public MyImmutableClass(string myString, myInt)
    {
        MyString = myString;
        MyInt = myInt;
    }
}

Uses:

Implement Base Class Constructors

Professional Only

Configuration Id: com.mfractor.code_actions.csharp.implement_base_class_constructors

When a C# class inherits from a base type that does only has parameterised constructors, this code action will generate each of the base classes parametered constructors.

For example, say a developer wanted to inherit MyCustomView from Android.Views.View to create a custom view in Xamarin.Android; the View class does not have any paramterless contructors.


public class MyCustomView : Android.Views.View // Generates a compiler error as View has no parameterless constructors. 
{
}

Using the Implement Base Class Constructors code action against the MyCustomView class would generate the following code.


public class MyClass : View
{
    public MyClass(System.IntPtr javaReference, Android.Runtime.JniHandleOwnership transfer) : base(javaReference, transfer)
    {
    }

    public MyClass(Android.Content.Context context) : base(context)
    {
    }

    public MyClass(Android.Content.Context context, Android.Util.IAttributeSet attrs) : base(context, attrs)
    {
    }

    public MyClass(Android.Content.Context context, Android.Util.IAttributeSet attrs, int defStyleAttr) : base(context, attrs, defStyleAttr)
    {
    }

    public MyClass(Android.Content.Context context, Android.Util.IAttributeSet attrs, int defStyleAttr, int defStyleRes) : base(context, attrs, defStyleAttr, defStyleRes)
    {
    }
}

Example

Implementing a base classes constructors

Uses:

Make Class Inherit From System.Attribute

Professional Only

Configuration Id: com.mfractor.code_actions.csharp.make_class_inherit_from_attribute

When a class declaration ends with Attribute (EG: MyCoolAttribute) and does not derive from any class, this code action will make the class inherit from System.Attribute.

Make class inherit from Attribute

Replace String With Resource Lookup

Professional Only

Configuration Id: com.mfractor.code_actions.resx.replace_csharp_string_with_resource_lookup

Using the localisation wizard to extract string literals into a ResX file

This code refactoring will open the localisation wizard, allowing you to walk through all strings in a C# code file and replace inline strings with resource lookups.

Uses: