From 649fa077f26c50c5ff2bd9889ba7a190cb9b2ff9 Mon Sep 17 00:00:00 2001 From: Alexander Raszka Date: Sat, 13 Jan 2024 13:00:10 +0100 Subject: [PATCH 1/3] Add more test cases for MtTransformer --- .../CurlyBraceCountMismatchException.cs | 16 ++++ .../InterpolationRecursionException.cs | 16 ++++ src/ManiaTemplates/Lib/MtTransformer.cs | 76 +++++++++++++--- .../Lib/MtTransformerTest.cs | 87 ++++++++++++++++++- .../Lib/TestDynamicObject.cs | 7 ++ 5 files changed, 190 insertions(+), 12 deletions(-) create mode 100644 src/ManiaTemplates/Exceptions/CurlyBraceCountMismatchException.cs create mode 100644 src/ManiaTemplates/Exceptions/InterpolationRecursionException.cs create mode 100644 tests/ManiaTemplates.Tests/Lib/TestDynamicObject.cs diff --git a/src/ManiaTemplates/Exceptions/CurlyBraceCountMismatchException.cs b/src/ManiaTemplates/Exceptions/CurlyBraceCountMismatchException.cs new file mode 100644 index 0000000..74998af --- /dev/null +++ b/src/ManiaTemplates/Exceptions/CurlyBraceCountMismatchException.cs @@ -0,0 +1,16 @@ +namespace ManiaTemplates.Exceptions; + +public class CurlyBraceCountMismatchException : Exception +{ + public CurlyBraceCountMismatchException() + { + } + + public CurlyBraceCountMismatchException(string message) : base(message) + { + } + + public CurlyBraceCountMismatchException(string message, Exception inner) : base(message, inner) + { + } +} \ No newline at end of file diff --git a/src/ManiaTemplates/Exceptions/InterpolationRecursionException.cs b/src/ManiaTemplates/Exceptions/InterpolationRecursionException.cs new file mode 100644 index 0000000..9ef3bb0 --- /dev/null +++ b/src/ManiaTemplates/Exceptions/InterpolationRecursionException.cs @@ -0,0 +1,16 @@ +namespace ManiaTemplates.Exceptions; + +public class InterpolationRecursionException : Exception +{ + public InterpolationRecursionException() + { + } + + public InterpolationRecursionException(string message) : base(message) + { + } + + public InterpolationRecursionException(string message, Exception inner) : base(message, inner) + { + } +} \ No newline at end of file diff --git a/src/ManiaTemplates/Lib/MtTransformer.cs b/src/ManiaTemplates/Lib/MtTransformer.cs index 26e326d..f56f57d 100644 --- a/src/ManiaTemplates/Lib/MtTransformer.cs +++ b/src/ManiaTemplates/Lib/MtTransformer.cs @@ -29,6 +29,7 @@ public class MtTransformer private static readonly Regex TemplateFeatureControlRegex = new(@"#>\s*<#\+"); private static readonly Regex TemplateInterpolationRegex = new(@"\{\{\s*(.+?)\s*\}\}"); + private static readonly Regex TemplateInterpolationRecursionRegex = new(@"\{\{\s*(.+?)\s*\}\}"); private static readonly Regex JoinScriptBlocksRegex = new(@"(?s)-->.+?.+?