Add ProxyInterfaceConsumerViaNuGet project

This commit is contained in:
Stef Heyenrath
2021-07-25 17:29:26 +02:00
parent 762f962e1d
commit a38d8c8ef0
13 changed files with 153 additions and 30 deletions
@@ -0,0 +1,6 @@
namespace ProxyInterfaceConsumer
{
public interface IMyInterface
{
}
}
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using Microsoft.CodeAnalysis;
namespace ProxyInterfaceConsumer
{
@@ -20,6 +19,8 @@ namespace ProxyInterfaceConsumer
public E E { get; set; }
public IMyInterface MyInterface { get; set; }
public int Add(string s)
{
return 600;
@@ -32,12 +33,7 @@ namespace ProxyInterfaceConsumer
public void Void()
{
//
}
public Compilation Compilation { get; set; }
public INamedTypeSymbol MyNamedTypeSymbol { get; set; }
}
public enum E
@@ -1,11 +1,17 @@
using System;
using System.Collections.Generic;
using System.Text.Json;
using AutoMapper;
namespace ProxyInterfaceConsumer
{
public class Program
{
private static JsonSerializerOptions JsonSerializerOptions = new ()
{
WriteIndented = true
};
public static void Main()
{
var c = new Clazz
@@ -20,7 +26,7 @@ namespace ProxyInterfaceConsumer
var tp = new TestProxy(t);
tp.Cs = new List<IClazz> { cp };
Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(t));
Console.WriteLine(JsonSerializer.Serialize(t, JsonSerializerOptions));
Console.WriteLine(new string('-', 80));
@@ -35,7 +41,7 @@ namespace ProxyInterfaceConsumer
//p.Compilation = null;
//p.Add("x");
//p.Void();
Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(p));
Console.WriteLine(JsonSerializer.Serialize(p, JsonSerializerOptions));
}
}
@@ -7,13 +7,12 @@
<ItemGroup>
<PackageReference Include="AutoMapper" Version="10.1.1" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.2">
<!--<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="3.10.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.10.0" />
<!--<PackageReference Include="TinyMapper" Version="3.0.3" />-->
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.10.0" />-->
</ItemGroup>
<ItemGroup>
@@ -0,0 +1,7 @@
namespace ProxyInterfaceConsumer
{
public class Address
{
public int HouseNumber { get; set; }
}
}
@@ -0,0 +1,7 @@
namespace ProxyInterfaceConsumer
{
[ProxyInterfaceGenerator.Proxy(typeof(ProxyInterfaceConsumer.Address))]
public partial interface IAddress
{
}
}
@@ -0,0 +1,6 @@
namespace ProxyInterfaceConsumer
{
public interface IMyInterface
{
}
}
@@ -0,0 +1,7 @@
namespace ProxyInterfaceConsumer
{
[ProxyInterfaceGenerator.Proxy(typeof(ProxyInterfaceConsumer.Person))]
public partial interface IPerson
{
}
}
@@ -0,0 +1,44 @@
using System.Collections.Generic;
namespace ProxyInterfaceConsumer
{
public class Person
{
private int PrivateId { get; }
public int Id { get; }
public long? NullableLong { get; }
public string Name { get; set; }
public Address Address { get; set; }
public List<Address> AddressesLIst { get; set; }
public Dictionary<string, Address> AddressesDict { get; set; } = new Dictionary<string, Address>();
public E E { get; set; }
public IMyInterface MyInterface { get; set; }
public int Add(string s)
{
return 600;
}
public void AddAddress(Address a)
{
AddressesDict.Add($"{AddressesDict.Count}", a);
}
public void Void()
{
}
}
public enum E
{
V1,
V2
}
}
@@ -0,0 +1,25 @@
using System;
using System.Text.Json;
namespace ProxyInterfaceConsumer
{
class Program
{
private static JsonSerializerOptions JsonSerializerOptions = new ()
{
WriteIndented = true
};
static void Main(string[] args)
{
IPerson p = new PersonProxy(new Person());
p.Name = "test";
var ap = new AddressProxy(new Address { HouseNumber = 42 });
p.Address = ap;
p.AddAddress(ap);
p.AddAddress(new AddressProxy(new Address { HouseNumber = 1000 }));
Console.WriteLine(JsonSerializer.Serialize(p, JsonSerializerOptions));
}
}
}
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<AssemblyName>ProxyInterfaceConsumer</AssemblyName>
<RootNamespace>ProxyInterfaceConsumer</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ProxyInterfaceGenerator" Version="0.0.2" />
</ItemGroup>
</Project>