Add support for generics (#20)
* wip * . * method * TT * TT * . * . * mp
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
namespace ProxyInterfaceConsumer
|
||||
{
|
||||
[ProxyInterfaceGenerator.Proxy(typeof(ProxyInterfaceConsumer.Address))]
|
||||
// [ProxyInterfaceGenerator.Proxy(typeof(ProxyInterfaceConsumer.Address))]
|
||||
public partial interface IAddress
|
||||
{
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace ProxyInterfaceConsumer
|
||||
{
|
||||
[ProxyInterfaceGenerator.Proxy(typeof(ProxyInterfaceConsumer.PersonT<>))]
|
||||
public partial interface IPersonT<T> where T : struct
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
namespace ProxyInterfaceConsumer
|
||||
{
|
||||
[ProxyInterfaceGenerator.Proxy(typeof(ProxyInterfaceConsumer.PersonT<,>))]
|
||||
public partial interface IPersonT<T1, T2>
|
||||
where T1 : struct
|
||||
where T2 : class, new()
|
||||
{
|
||||
}
|
||||
|
||||
[ProxyInterfaceGenerator.Proxy(typeof(ProxyInterfaceConsumer.PersonTT<,>))]
|
||||
public partial interface IPersonTT<T1, T2>
|
||||
where T1 : struct
|
||||
where T2 : class, new()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,13 @@ namespace ProxyInterfaceConsumer
|
||||
|
||||
public IMyInterface MyInterface { get; set; }
|
||||
|
||||
public bool TMethod<T1, T2>(int x, T1 t1, T2 t2)
|
||||
where T1 : struct
|
||||
where T2 : class, new()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public int DefaultValue(int x = 100)
|
||||
{
|
||||
return x + 1;
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace ProxyInterfaceConsumer
|
||||
{
|
||||
public class PersonT<T> where T: struct
|
||||
{
|
||||
public T TVal { get; set; }
|
||||
|
||||
public T Call(int x, T t)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
namespace ProxyInterfaceConsumer
|
||||
{
|
||||
public class PersonT<T1, T2>
|
||||
where T1 : struct
|
||||
where T2 : class, new()
|
||||
{
|
||||
public T1 TVal1 { get; set; }
|
||||
|
||||
public T2 TVal2 { get; set; }
|
||||
|
||||
public void Call(int x, T1 t1, T2 t2)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class PersonTT<T1, T2>
|
||||
where T1 : struct
|
||||
where T2 : class, new()
|
||||
{
|
||||
public T1 TVal1 { get; set; }
|
||||
|
||||
public T2 TVal2 { get; set; }
|
||||
|
||||
public void Call(int x, T1 t1, T2 t2)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,45 +14,31 @@ namespace ProxyInterfaceConsumer
|
||||
|
||||
public static void Main()
|
||||
{
|
||||
var c = new Clazz
|
||||
{
|
||||
Name = "n"
|
||||
};
|
||||
var cp = new ClazzProxy(c);
|
||||
|
||||
var t = new Test();
|
||||
t.Cs = new List<Clazz> { c };
|
||||
|
||||
var tp = new TestProxy(t);
|
||||
tp.Cs = new List<IClazz> { cp };
|
||||
|
||||
Console.WriteLine(JsonSerializer.Serialize(t, JsonSerializerOptions));
|
||||
IPersonT<int> pT = new PersonTProxy<int>(new PersonT<int>());
|
||||
pT.TVal = 1;
|
||||
Console.WriteLine(JsonSerializer.Serialize(pT, JsonSerializerOptions));
|
||||
Console.WriteLine(new string('-', 80));
|
||||
|
||||
IPersonTT<int, Program> pTT = new PersonTTProxy<int, Program>(new PersonTT<int, Program>());
|
||||
pTT.TVal1 = 42;
|
||||
pTT.TVal2 = new Program();
|
||||
Console.WriteLine(JsonSerializer.Serialize(pTT, JsonSerializerOptions));
|
||||
Console.WriteLine(new string('-', 80));
|
||||
|
||||
IPerson p = new PersonProxy(new Person());
|
||||
p.Name = "test";
|
||||
Console.WriteLine("DefaultValue " + p.DefaultValue());
|
||||
Console.WriteLine("DefaultValue " + p.DefaultValue(42));
|
||||
|
||||
var ap = new AddressProxy(new Address { HouseNumber = 42 });
|
||||
p.Address = ap;
|
||||
var add = p.AddAddress(ap);
|
||||
Console.WriteLine("add = " + JsonSerializer.Serialize(add, JsonSerializerOptions));
|
||||
p.AddAddress(new AddressProxy(new Address { HouseNumber = 1000 }));
|
||||
//var ap = new AddressProxy(new Address { HouseNumber = 42 });
|
||||
//p.Address = ap;
|
||||
//var add = p.AddAddress(ap);
|
||||
//Console.WriteLine("add = " + JsonSerializer.Serialize(add, JsonSerializerOptions));
|
||||
//p.AddAddress(new AddressProxy(new Address { HouseNumber = 1000 }));
|
||||
|
||||
//p.MyNamedTypeSymbol = null;
|
||||
//p.Compilation = null;
|
||||
//p.Add("x");
|
||||
//p.Void();
|
||||
Console.WriteLine(JsonSerializer.Serialize(p, JsonSerializerOptions));
|
||||
|
||||
//GeneratorExecutionContext g = new GeneratorExecutionContext();
|
||||
//IGeneratorExecutionContext gc = new GeneratorExecutionContextProxy(g);
|
||||
//int y = 9;
|
||||
}
|
||||
}
|
||||
|
||||
public struct Test
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
Reference in New Issue
Block a user