Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/egorozh/mobiletoolkit

Source generators for C# Mobile Developing
https://github.com/egorozh/mobiletoolkit

android source-generators xamarin xamarin-android xamarin-android-binding

Last synced: 13 days ago
JSON representation

Source generators for C# Mobile Developing

Awesome Lists containing this project

README

        

[![Nuget](https://img.shields.io/nuget/v/MobileToolkit.Android?label=MobileToolkit.Android)](https://www.nuget.org/packages/MobileToolkit.Android)

# .NET Mobile Toolkit

## 1. Source generator for getting android controls from xml layout

Get started:

Install the library as a NuGet package:

```powershell
Install-Package MobileToolkit.Android
# Or 'dotnet add package MobileToolkit.Android'

```
And usage:
``` csharp

[Activity]
[AndroidLayout(LayoutResource = nameof(Resource.Layout.activity_main))]
public partial class MainActivity : Activity
{
protected override void OnCreate(Bundle? savedInstanceState)
{
base.OnCreate(savedInstanceState);

SetContentView(Resource.Layout.activity_main);
}
}

```
The generated file looks like this:
``` csharp
using Android.Widget;
using Android.Views;

namespace SGM.Sample.Android
{
partial class MainActivity
{
public TextView TextView => this.FindViewById(Resource.Id.TextView);

public Button Button => this.FindViewById(Resource.Id.Button);

public EditText EditText => this.FindViewById(Resource.Id.EditText);

public View RecyclerView => this.FindViewById(Resource.Id.RecyclerView);
}
}
```

Plans:
1) Source generator for generate bindings code
2) Source generator for generate ui controls like android compose
3) Source generator for DI container
4) Source generator for generate outlets on .xib files