A rapid way to generate Index overload extension method compile time with Source Generator.
- It is incomplete
- Not all scenarios are covered as of now
- No error handling and user warning
main goal was to prototype it and check feasibility.
For this Sample
namespace Try
{
public class DataStore<T>
{
public int Count { get; set; }
public void AddAt([AutoIndexer] int idx,
[AutoIndexer] int y)
{
Console.WriteLine(idx);
}
public void RemoveAt([AutoIndexer] int idx,
[AutoIndexer] double z,string k,float f)
{
Console.WriteLine(idx);
}
}
}
Source Generator generates
namespace Try;
public static class DataStoreExtn0
{
public static void AddAt<T>(this DataStore<T> @type,Index idx, Index y)=>
@type.AddAt(idx.GetOffset(@type.Count), y.GetOffset(@type.Count));
public static void RemoveAt<T>(this DataStore<T> @type,Index idx, Index z, string k, float f)=>
@type.RemoveAt(idx.GetOffset(@type.Count), z.GetOffset(@type.Count), k, f);
}