public GeneratedSource GenerateErrorSourceCode(Exception exception, ClassDeclarationSyntax classDeclaration)
        {
            var context = $"[{typeof(T).Name} - {classDeclaration.Identifier.Text}]";

            var templateString = ResourceReader.GetResource("ErrorModel.cstemplate");

            templateString = templateString.Replace("//Error", $"#error {context} {exception.Message} | Logfile: {Options.LogPath}");

            return(new GeneratedSource(templateString, classDeclaration.Identifier.Text));
        }
示例#2
0
        private GeneratedSource GenearteProxy(ClassDeclarationSyntax proxy, SourceGeneratorContext <ActorProxySourceGenerator> context)
        {
            try
            {
                var proxyModel = GetModel(proxy, context.GeneratorExecutionContext.Compilation);

                var templateString = ResourceReader.GetResource("ActorProxy.scriban");

                var result = TemplateGenerator.Execute(templateString, proxyModel);

                context.TryLogSourceCode(proxy, result);

                return(new GeneratedSource(result, proxyModel.ClassName));
            }
            catch (Exception ex)
            {
                context.TryLogException(proxy, ex);
                return(context.GenerateErrorSourceCode(ex, proxy));
            }
        }