From 45b75c3c9d8437344a9d75830212b438dc6aa635 Mon Sep 17 00:00:00 2001 From: AliReZa Sabouri Date: Thu, 31 Oct 2024 00:27:01 +0100 Subject: [PATCH] fix: #219 --- src/Gridify/Syntax/Lexer.cs | 2 +- test/Gridify.Tests/IssueTests/Issue219Tests.cs | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 test/Gridify.Tests/IssueTests/Issue219Tests.cs diff --git a/src/Gridify/Syntax/Lexer.cs b/src/Gridify/Syntax/Lexer.cs index 029f42ba..831a8fe4 100644 --- a/src/Gridify/Syntax/Lexer.cs +++ b/src/Gridify/Syntax/Lexer.cs @@ -148,7 +148,7 @@ public SyntaxToken NextToken() { var start = _position; - while (char.IsLetterOrDigit(Current) || Current is '_' || Current is '.') + while (char.IsLetterOrDigit(Current) || Current is '_' || Current is '.' || Current is '-') Next(); var length = _position - start; diff --git a/test/Gridify.Tests/IssueTests/Issue219Tests.cs b/test/Gridify.Tests/IssueTests/Issue219Tests.cs new file mode 100644 index 00000000..3e109173 --- /dev/null +++ b/test/Gridify.Tests/IssueTests/Issue219Tests.cs @@ -0,0 +1,17 @@ +using System.Linq; +using FluentAssertions; +using Gridify.Syntax; +using Xunit; + +namespace Gridify.Tests.IssueTests; + +public class Issue219Tests +{ + [Fact] + private void FieldNameWithDashShouldWork() + { + var syntaxTree = SyntaxTree.Parse("property-name = value"); + syntaxTree.Diagnostics.Should().BeEmpty(); + syntaxTree.Root.GetChildren().First().Should().BeOfType(); + } +}