MFractor 3.3 out now!
MFractor 3.3: Introducing Code Snippets
Today Tom and I are excited to announce the release of MFractor v3.3 for Visual Studio for Mac!
This release is jammed packed with features; you can now customise the code MFractor creates using code snippets, generate interface implementations, create effects and easily localise C# and XAML.
Let's go through code snippets first.
Code Snippets
Code snippets allow you to define templated code and then tell MFractor to use it for features like view model property or command generation.
Using code snippets, it's now possible to make MFractor generate code that is specific to your project.
So, how do you use your own code snippets in MFractor? Let's learn by customising the code generated when we generate a new view model property!
Firstly, add a file named app.mfc.xml
to the top level of your project; this is a project level MFractor configuration file.
Next, create a directory in your project named Snippets
, this is where we will place our customised snippets so they can be reused between developers.
In the Snippets
folder, create a file named ViewModelProperty.txt
with the following content:
private $type$ _$name$ = $value$;
public $type$ $name$
{
get
{
return _$name$;
}
set
{
SetProperty(ref _$name$, value);
}
}
We will use this snippet to change the behaviour of the Snippet
property of the View Model Property
code generator.
In the app.mfc.xml
file, add the following xml code to apply your code snippet to the View Model Property
generator:
<?xml version="1.0" encoding="UTF-8" ?>
<mfractor>
<configure id="com.mfractor.code_gen.forms.csharp.view_model_property">
<property name="Snippet" source="file" value="Snippets/ViewModelProperty.txt"/>
</configure>
</mfractor>
Now when you generate a new property from a missing property binding, it'll create the new property using the code snippet you provided:
Awesome!
MFractor can also use code snippets defined within Visual Studio Macs code snippets editor. To learn more, check out the code snippets tutorial on our documentation.
New Features
So what else have we added?
The Extract XAML Control refactoring can take a chunk of XAML and refactor it into a standalone control that you can reuse throughout your app:
Do you need to create an implementation for an interface? Use the Generate Interface Implementation code action to quickly implement any interface:
With the localisation wizard you can now easily move C# string literals into a .resx file to quickly localise your app:
Lastly, use the Generate Effect code action to create a new platform-specific effect, right from your XAML:
In addition to all these shiny new features, you can expect a tonne of bug fixes, performance enhancements and better product stability. You can check out the full release notes here.
Interested in upgrading to MFractor Professional? Feel free to email hello@mfractor.com at any time to have a chat about how MFractor can make your Xamarin development easier.
✌️
Matt - Founder of MFractor