The second template was pretty easy. All the date was inside the class definition :
class ClassDefinition
{
public string ClassName;
public string NamespaceName;
public Dictionary<string,MethodDefinition[]> DictNameField_Methods;
public string version = ThisAssembly.Info.Version;
}
class MethodDefinition
{
public string Name { get; set; }
public string FieldName { get; set; }
public string ReturnType;
public bool ReturnsVoid;
//name,type
public Dictionary<string,ITypeSymbol> Parameters;public string parametersDefinitionCSharp => string.Join(“,”,Parameters.Select(it => it.Value.ContainingNamespace + “.” + it.Value.Name + ” ” + it.Key).ToArray());
public string parametersCallCSharp => string.Join(“,”,Parameters.Select(it => it.Key).ToArray());public int NrParameters
{
get
{
return Parameters?.Count ?? 0;
}
}}
so the only thing that I needed is to modify the template definition
I was having one problem: I have hardcoded the names in the first stage- so I have had problems with duplicate names: . As an example,it was:
namespace {{NamespaceName}} {
[GeneratedCode(“SkinnyControllersGenerator”,”{{version}}”)]
[CompilerGenerated]
partial class WeatherForecastController{
and now it is
namespace {{NamespaceName}} {
[GeneratedCode(“SkinnyControllersGenerator”,”{{version}}”)]
[CompilerGenerated]
partial class {{ClassName}}{
Besides this,the SCRIBAN documentation is pretty self explanatory to male the second template ready
Leave a Reply