Update source gen

This commit is contained in:
Liza 2024-09-23 20:32:54 +02:00
parent 01ad85e243
commit 4bd0b990b9
Signed by: liza
GPG Key ID: 7199F8D727D55F67
2 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,28 @@
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Questionable.Model.Questing;
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
using static Questionable.QuestPathGenerator.RoslynShortcuts;
namespace Questionable.QuestPathGenerator.RoslynElements;
internal static class PurchaseMenuExtensions
{
public static ExpressionSyntax ToExpressionSyntax(this PurchaseMenu purchaseMenu)
{
PurchaseMenu emptyMenu = new();
return ObjectCreationExpression(
IdentifierName(nameof(PurchaseMenu)))
.WithInitializer(
InitializerExpression(
SyntaxKind.ObjectInitializerExpression,
SeparatedList<ExpressionSyntax>(
SyntaxNodeList(
Assignment(nameof(PurchaseMenu.ExcelSheet), purchaseMenu.ExcelSheet,
emptyMenu.ExcelSheet)
.AsSyntaxNodeOrToken(),
Assignment(nameof(PurchaseMenu.Key), purchaseMenu.Key,
emptyMenu.Key)
.AsSyntaxNodeOrToken()))));
}
}

View File

@ -57,6 +57,7 @@ public static class RoslynShortcuts
DialogueChoice dialogueChoice => dialogueChoice.ToExpressionSyntax(), DialogueChoice dialogueChoice => dialogueChoice.ToExpressionSyntax(),
JumpDestination jumpDestination => jumpDestination.ToExpressionSyntax(), JumpDestination jumpDestination => jumpDestination.ToExpressionSyntax(),
ExcelRef excelRef => excelRef.ToExpressionSyntax(), ExcelRef excelRef => excelRef.ToExpressionSyntax(),
PurchaseMenu purchaseMenu => purchaseMenu.ToExpressionSyntax(),
ComplexCombatData complexCombatData => complexCombatData.ToExpressionSyntax(), ComplexCombatData complexCombatData => complexCombatData.ToExpressionSyntax(),
QuestWorkValue questWorkValue => questWorkValue.ToExpressionSyntax(), QuestWorkValue questWorkValue => questWorkValue.ToExpressionSyntax(),
List<QuestWorkValue> list => list.ToExpressionSyntax(), // TODO fix in AssignmentList List<QuestWorkValue> list => list.ToExpressionSyntax(), // TODO fix in AssignmentList