the guide points to DocumentationGenerator/Program.cs in order to generate a simple documentation I wanted to generate the ts file the nt file has all the capabilities just wanted to invoke from c# like visual studio but from code
so I have done that code but it doesn't render the result after NTypeWriter.Render(template, codeModel) method :
code :
public async Task<string> WriteEndpointServices()
{
AnalyzerManager manager = new AnalyzerManager();
IProjectAnalyzer analyzer = manager.GetProject(@"..\..\CodeGenerator\CodeGenerator\CodeGenerator.csproj");
AdhocWorkspace workspace = analyzer.GetWorkspace(false);
var project = workspace.CurrentSolution.Projects.Where(x => x.Name == "CodeGenerator").First();
// 2) Add xml documentation
project = AddXmlDocumentation(project, typeof(ICodeModel));
project = AddXmlDocumentation(project, typeof(ActionFunctions));
project = AddXmlDocumentation(project, typeof(Scriban.Functions.StringFunctions));
project = AddXmlDocumentation(project, typeof(Scriban.Functions.BuiltinFunctions));
project = AddXmlDocumentation(project, typeof(Scriban.Functions.ArrayFunctions));
project = AddXmlDocumentation(project, typeof(Scriban.Functions.RegexFunctions));
// 3) Compile
var compilation = await project.GetCompilationAsync();
// 4) Create CodeModel
var codeModelConfiguration = new CodeModelConfiguration() { OmitSymbolsFromReferencedAssemblies = false };
var codeModel = new CodeModel(compilation, codeModelConfiguration);
// 5) Load template
string template = System.IO.File.ReadAllText(@"FastEndointsServiceTemplate.nt");
// 6) Add custom functions
var ntypewriterConfig = new Configuration();
// 7) Render
var result = await NTypeWriter.Render(template, codeModel);
if (!result.HasErrors)
{
var renderedItem = result.Items.First();
var path = Path.Combine(@"..\..\..\", renderedItem.Name);
System.IO.File.WriteAllText(path, renderedItem.Content);
}
else
{
foreach (var msg in result.Messages)
{
Console.WriteLine(msg.Message);
}
}
return "";
}
error:
**{<input>(23,29) Value cannot be null. (Parameter 'input')}**
I don't know what input mean here ? isn't the typewriter should read the project by its own and output the result?
Hello I wanted to invoke my typewriter generator but from C# instead of visual studio which begins like that (.nt) file :
and output the ts files like that:
I cannot use source generators for my case as I want to invoke on runtime so I followed the guide of build your own cli here: https://github.com/NeVeSpl/NTypewriter/blob/master/Documentation/NTypewriter.md#Build-your-own-CLI
the guide points to DocumentationGenerator/Program.cs in order to generate a simple documentation I wanted to generate the ts file the nt file has all the capabilities just wanted to invoke from c# like visual studio but from code so I have done that code but it doesn't render the result after NTypeWriter.Render(template, codeModel) method : code :
error:
I don't know what input mean here ? isn't the typewriter should read the project by its own and output the result?