Skip to content

Commit 88de39c

Browse files
authored
OperatorNullPropagation : added code + unit-tests (#100)
1 parent 9b8ba5f commit 88de39c

File tree

8 files changed

+39
-362
lines changed

8 files changed

+39
-362
lines changed

src/System.Linq.Dynamic.Core/ClassFactory.cs

-262
This file was deleted.

src/System.Linq.Dynamic.Core/ExpressionParser.cs

+4
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,10 @@ Expression ParsePrimary()
895895
_textParser.NextToken();
896896
expr = ParseMemberAccess(null, expr);
897897
}
898+
else if (_textParser.CurrentToken.Id == TokenId.NullPropagation)
899+
{
900+
throw new NotSupportedException("An expression tree lambda may not contain a null propagating operator");
901+
}
898902
else if (_textParser.CurrentToken.Id == TokenId.OpenBracket)
899903
{
900904
expr = ParseElementAccess(expr);

src/System.Linq.Dynamic.Core/GeneratedTypesCache.cs

-39
This file was deleted.

src/System.Linq.Dynamic.Core/Tokenizer/TextParser.cs

+5
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,11 @@ public void NextToken()
214214
NextChar();
215215
tokenId = TokenId.NullCoalescing;
216216
}
217+
else if (_ch == '.')
218+
{
219+
NextChar();
220+
tokenId = TokenId.NullPropagation;
221+
}
217222
else
218223
{
219224
tokenId = TokenId.Question;

src/System.Linq.Dynamic.Core/Tokenizer/TokenId.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ internal enum TokenId
3939
DoubleGreaterThan,
4040
DoubleLessThan,
4141
NullCoalescing,
42-
Lambda
42+
Lambda,
43+
NullPropagation
4344
}
4445
}

0 commit comments

Comments
 (0)