From 85270acf1179c630b318613b1e9a2dbb8c715f0a Mon Sep 17 00:00:00 2001 From: Alejandro Sanchez <135753845+alesanchez-windifferent@users.noreply.github.com> Date: Fri, 15 Nov 2024 04:48:20 -0400 Subject: [PATCH 1/2] feat: DetectIdentifier obtain complete variable name (#323) * Add logic to enable detection of complete variable name (ex. contact.first_name) * - Create Enum - Change signature --------- Co-authored-by: Alejandro Javier Sanchez Roa --- src/DynamicExpresso.Core/Detector.cs | 34 ++++++++++---- src/DynamicExpresso.Core/DetectorOptions.cs | 11 +++++ src/DynamicExpresso.Core/Interpreter.cs | 46 +++++++++++++++---- .../DetectIdentifiersTest.cs | 17 ++++++- 4 files changed, 89 insertions(+), 19 deletions(-) create mode 100644 src/DynamicExpresso.Core/DetectorOptions.cs diff --git a/src/DynamicExpresso.Core/Detector.cs b/src/DynamicExpresso.Core/Detector.cs index 77a8191c..e325397f 100644 --- a/src/DynamicExpresso.Core/Detector.cs +++ b/src/DynamicExpresso.Core/Detector.cs @@ -11,21 +11,33 @@ internal class Detector { private readonly ParserSettings _settings; - private static readonly Regex IdentifiersDetectionRegex = new Regex(@"(?@?[\p{L}\p{Nl}_][\p{L}\p{Nl}\p{Nd}\p{Mn}\p{Mc}\p{Pc}\p{Cf}_]*)", RegexOptions.Compiled); + private static readonly Regex RootIdentifierDetectionRegex = + new Regex(@"(?@?[\p{L}\p{Nl}_][\p{L}\p{Nl}\p{Nd}\p{Mn}\p{Mc}\p{Pc}\p{Cf}_]*)", RegexOptions.Compiled); - private static readonly string Id = IdentifiersDetectionRegex.ToString(); + private static readonly Regex ChildIdentifierDetectionRegex = new Regex( + @"(?@?[\p{L}\p{Nl}_][\p{L}\p{Nl}\p{Nd}\p{Mn}\p{Mc}\p{Pc}\p{Cf}_]*(\.[\p{L}\p{Nl}_][\p{L}\p{Nl}\p{Nd}\p{Mn}\p{Mc}\p{Pc}\p{Cf}_]*)*)", + RegexOptions.Compiled); + + + private static readonly string Id = RootIdentifierDetectionRegex.ToString(); private static readonly string Type = Id.Replace("", ""); - private static readonly Regex LambdaDetectionRegex = new Regex($@"(\((((?({Type}\s+)?{Id}))(\s*,\s*)?)+\)|(?{Id}))\s*=>", RegexOptions.Compiled); - private static readonly Regex StringDetectionRegex = new Regex(@"(?({Type}\s+)?{Id}))(\s*,\s*)?)+\)|(?{Id}))\s*=>", + RegexOptions.Compiled); + + private static readonly Regex StringDetectionRegex = + new Regex(@"(? in that case, we ignore the detected type - if (lambdaParameters.TryGetValue(identifier, out Identifier already) && already.Expression.Type != type) + if (lambdaParameters.TryGetValue(identifier, out Identifier already) && + already.Expression.Type != type) type = typeof(object); var defaultValue = type.IsValueType ? Activator.CreateInstance(type) : null; @@ -67,8 +80,11 @@ public IdentifiersInfo DetectIdentifiers(string expression) } } + var identifierRegex = option == DetectorOptions.IncludeChildren + ? ChildIdentifierDetectionRegex + : RootIdentifierDetectionRegex; - foreach (Match match in IdentifiersDetectionRegex.Matches(expression)) + foreach (Match match in identifierRegex.Matches(expression)) { var idGroup = match.Groups["id"]; var identifier = idGroup.Value; @@ -76,7 +92,7 @@ public IdentifiersInfo DetectIdentifiers(string expression) if (IsReservedKeyword(identifier)) continue; - if (idGroup.Index > 0) + if (option == DetectorOptions.None && idGroup.Index > 0) { var previousChar = expression[idGroup.Index - 1]; diff --git a/src/DynamicExpresso.Core/DetectorOptions.cs b/src/DynamicExpresso.Core/DetectorOptions.cs new file mode 100644 index 00000000..41a17b51 --- /dev/null +++ b/src/DynamicExpresso.Core/DetectorOptions.cs @@ -0,0 +1,11 @@ +namespace DynamicExpresso +{ + /// + /// Option to set the detector variable level + /// + public enum DetectorOptions + { + None = 0, + IncludeChildren = 1 + } +} diff --git a/src/DynamicExpresso.Core/Interpreter.cs b/src/DynamicExpresso.Core/Interpreter.cs index d84107fa..74c81ce6 100644 --- a/src/DynamicExpresso.Core/Interpreter.cs +++ b/src/DynamicExpresso.Core/Interpreter.cs @@ -19,6 +19,7 @@ public class Interpreter private readonly ISet _visitors = new HashSet(); #region Constructors + /// /// Creates a new Interpreter using InterpreterOptions.Default. /// @@ -70,9 +71,11 @@ internal Interpreter(ParserSettings settings) { _settings = settings; } + #endregion #region Properties + public bool CaseInsensitive { get @@ -114,6 +117,7 @@ public AssignmentOperators AssignmentOperators { get { return _settings.AssignmentOperators; } } + #endregion #region Options @@ -141,9 +145,11 @@ public Interpreter EnableAssignment(AssignmentOperators assignmentOperators) return this; } + #endregion #region Visitors + public ISet Visitors { get { return _visitors; } @@ -161,9 +167,11 @@ public Interpreter EnableReflection() return this; } + #endregion #region Register identifiers + /// /// Allow the specified function delegate to be called from a parsed expression. /// Overloads can be added (ie. multiple delegates can be registered with the same name). @@ -177,7 +185,8 @@ public Interpreter SetFunction(string name, Delegate value) if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullException(nameof(name)); - if (_settings.Identifiers.TryGetValue(name, out var identifier) && identifier is FunctionIdentifier fIdentifier) + if (_settings.Identifiers.TryGetValue(name, out var identifier) && + identifier is FunctionIdentifier fIdentifier) { fIdentifier.AddOverload(value); } @@ -319,9 +328,11 @@ public Interpreter UnsetIdentifier(string name) _settings.Identifiers.Remove(name); return this; } + #endregion #region Register referenced types + /// /// Allow the specified type to be used inside an expression. The type will be available using its name. /// If the type contains method extensions methods they will be available inside expressions. @@ -385,9 +396,11 @@ public Interpreter Reference(ReferenceType type) return this; } + #endregion #region Parse + /// /// Parse a text expression and returns a Lambda class that can be used to invoke it. /// @@ -443,13 +456,15 @@ public TDelegate ParseAsDelegate(string expressionText, params string /// Names of the parameters. If not specified the parameters names defined inside the delegate are used. /// /// - public Expression ParseAsExpression(string expressionText, params string[] parametersNames) + public Expression ParseAsExpression(string expressionText, + params string[] parametersNames) { var lambda = ParseAs(expressionText, parametersNames); return lambda.LambdaExpression(); } - internal LambdaExpression ParseAsExpression(Type delegateType, string expressionText, params string[] parametersNames) + internal LambdaExpression ParseAsExpression(Type delegateType, string expressionText, + params string[] parametersNames) { var delegateInfo = ReflectionExtensions.GetDelegateInfo(delegateType, parametersNames); @@ -466,7 +481,7 @@ internal LambdaExpression ParseAsExpression(Type delegateType, string expression public Lambda ParseAs(string expressionText, params string[] parametersNames) { - return ParseAs(typeof(TDelegate), expressionText, parametersNames); + return ParseAs(typeof(TDelegate), expressionText, parametersNames); } internal Lambda ParseAs(Type delegateType, string expressionText, params string[] parametersNames) @@ -475,9 +490,11 @@ internal Lambda ParseAs(Type delegateType, string expressionText, params string[ return ParseAsLambda(expressionText, delegateInfo.ReturnType, delegateInfo.Parameters); } + #endregion #region Eval + /// /// Parse and invoke the specified expression. /// @@ -511,15 +528,25 @@ public object Eval(string expressionText, Type expressionType, params Parameter[ { return Parse(expressionText, expressionType, parameters).Invoke(parameters); } + #endregion #region Detection + public IdentifiersInfo DetectIdentifiers(string expression) { var detector = new Detector(_settings); - return detector.DetectIdentifiers(expression); + return detector.DetectIdentifiers(expression, DetectorOptions.None); } + + public IdentifiersInfo DetectIdentifiers(string expression, DetectorOptions options) + { + var detector = new Detector(_settings); + + return detector.DetectIdentifiers(expression, options); + } + #endregion #region Private methods @@ -527,10 +554,10 @@ public IdentifiersInfo DetectIdentifiers(string expression) private Lambda ParseAsLambda(string expressionText, Type expressionType, Parameter[] parameters) { var arguments = new ParserArguments( - expressionText, - _settings, - expressionType, - parameters); + expressionText, + _settings, + expressionType, + parameters); var expression = Parser.Parse(arguments); @@ -559,6 +586,7 @@ private void AssertDetectIdentifiers(Lambda lambda) throw new Exception("Detected unknown identifiers doesn't match actual parameters"); } #endif + #endregion } } diff --git a/test/DynamicExpresso.UnitTest/DetectIdentifiersTest.cs b/test/DynamicExpresso.UnitTest/DetectIdentifiersTest.cs index 99d91f21..e74d5203 100644 --- a/test/DynamicExpresso.UnitTest/DetectIdentifiersTest.cs +++ b/test/DynamicExpresso.UnitTest/DetectIdentifiersTest.cs @@ -43,6 +43,19 @@ public void Detect_unknown_identifiers() detectedIdentifiers.UnknownIdentifiers.ToArray()); } + [Test] + public void Detect_unknown_identifiers_with_complete_variable_name() + { + var target = new Interpreter(); + + var detectedIdentifiers = target.DetectIdentifiers("Contact.Personal.Year_of_birth = 1987", + DetectorOptions.IncludeChildren); + + CollectionAssert.AreEqual( + new[] { "Contact.Personal.Year_of_birth" }, + detectedIdentifiers.UnknownIdentifiers.ToArray()); + } + [Test] public void Should_detect_various_format_of_identifiers() { @@ -267,7 +280,9 @@ public void Detect_identifiers_inside_lambda_expression_duplicate_param_name() { var target = new Interpreter(InterpreterOptions.Default | InterpreterOptions.LambdaExpressions); - var detectedIdentifiers = target.DetectIdentifiers("(x, int y, z, int a) => x.Select(z => z + y).Select((string a, string b) => b)"); + var detectedIdentifiers = + target.DetectIdentifiers( + "(x, int y, z, int a) => x.Select(z => z + y).Select((string a, string b) => b)"); Assert.IsEmpty(detectedIdentifiers.UnknownIdentifiers); Assert.AreEqual(2, detectedIdentifiers.Types.Count()); From 94366a5e6a1b7d0c8407b00c9d36acb01f19d95b Mon Sep 17 00:00:00 2001 From: Constantin Piber <59023762+cpiber@users.noreply.github.com> Date: Fri, 15 Nov 2024 13:40:01 +0100 Subject: [PATCH 2/2] fix: Introduce localized strings for new errors (#329) --- .../DynamicExpresso.Core.csproj | 15 + .../AssignmentOperatorDisabledException.cs | 3 +- .../Exceptions/DuplicateParameterException.cs | 3 +- .../Exceptions/NoApplicableMethodException.cs | 3 +- .../ReflectionNotAllowedException.cs | 3 +- .../Exceptions/UnknownIdentifierException.cs | 3 +- src/DynamicExpresso.Core/Interpreter.cs | 5 +- src/DynamicExpresso.Core/Lambda.cs | 3 +- .../Parsing/InterpreterExpression.cs | 3 +- src/DynamicExpresso.Core/Parsing/Parser.cs | 12 +- src/DynamicExpresso.Core/ReferenceType.cs | 3 +- .../Resources/ErrorMessages.Designer.cs | 493 +++++++----------- .../Resources/ErrorMessages.de.resx | 36 ++ .../Resources/ErrorMessages.resx | 92 +++- 14 files changed, 324 insertions(+), 353 deletions(-) diff --git a/src/DynamicExpresso.Core/DynamicExpresso.Core.csproj b/src/DynamicExpresso.Core/DynamicExpresso.Core.csproj index 29140fcd..4382d88c 100644 --- a/src/DynamicExpresso.Core/DynamicExpresso.Core.csproj +++ b/src/DynamicExpresso.Core/DynamicExpresso.Core.csproj @@ -24,4 +24,19 @@ + + + ResXFileCodeGenerator + ErrorMessages.Designer.cs + + + + + + True + True + ErrorMessages.resx + + + diff --git a/src/DynamicExpresso.Core/Exceptions/AssignmentOperatorDisabledException.cs b/src/DynamicExpresso.Core/Exceptions/AssignmentOperatorDisabledException.cs index e13fdbe1..f069690f 100644 --- a/src/DynamicExpresso.Core/Exceptions/AssignmentOperatorDisabledException.cs +++ b/src/DynamicExpresso.Core/Exceptions/AssignmentOperatorDisabledException.cs @@ -1,5 +1,6 @@ using System; using System.Runtime.Serialization; +using DynamicExpresso.Resources; namespace DynamicExpresso.Exceptions { @@ -7,7 +8,7 @@ namespace DynamicExpresso.Exceptions public class AssignmentOperatorDisabledException : ParseException { public AssignmentOperatorDisabledException(string operatorString, int position) - : base(string.Format("Assignment operator '{0}' not allowed", operatorString), position) + : base(string.Format(ErrorMessages.AssignmentOperatorNotAllowed, operatorString), position) { OperatorString = operatorString; } diff --git a/src/DynamicExpresso.Core/Exceptions/DuplicateParameterException.cs b/src/DynamicExpresso.Core/Exceptions/DuplicateParameterException.cs index 765545a1..d5a49d22 100644 --- a/src/DynamicExpresso.Core/Exceptions/DuplicateParameterException.cs +++ b/src/DynamicExpresso.Core/Exceptions/DuplicateParameterException.cs @@ -1,5 +1,6 @@ using System; using System.Runtime.Serialization; +using DynamicExpresso.Resources; namespace DynamicExpresso.Exceptions { @@ -7,7 +8,7 @@ namespace DynamicExpresso.Exceptions public class DuplicateParameterException : DynamicExpressoException { public DuplicateParameterException(string identifier) - : base(string.Format("The parameter '{0}' was defined more than once", identifier)) + : base(string.Format(ErrorMessages.DuplicateParameter, identifier)) { Identifier = identifier; } diff --git a/src/DynamicExpresso.Core/Exceptions/NoApplicableMethodException.cs b/src/DynamicExpresso.Core/Exceptions/NoApplicableMethodException.cs index 29255427..4298d695 100644 --- a/src/DynamicExpresso.Core/Exceptions/NoApplicableMethodException.cs +++ b/src/DynamicExpresso.Core/Exceptions/NoApplicableMethodException.cs @@ -1,5 +1,6 @@ using System; using System.Runtime.Serialization; +using DynamicExpresso.Resources; namespace DynamicExpresso.Exceptions { @@ -7,7 +8,7 @@ namespace DynamicExpresso.Exceptions public class NoApplicableMethodException : ParseException { public NoApplicableMethodException(string methodName, string methodTypeName, int position) - : base(string.Format("No applicable method '{0}' exists in type '{1}'", methodName, methodTypeName), position) + : base(string.Format(ErrorMessages.InvalidMethodCall2, methodName, methodTypeName), position) { MethodTypeName = methodTypeName; MethodName = methodName; diff --git a/src/DynamicExpresso.Core/Exceptions/ReflectionNotAllowedException.cs b/src/DynamicExpresso.Core/Exceptions/ReflectionNotAllowedException.cs index a8b55081..9604c3ee 100644 --- a/src/DynamicExpresso.Core/Exceptions/ReflectionNotAllowedException.cs +++ b/src/DynamicExpresso.Core/Exceptions/ReflectionNotAllowedException.cs @@ -1,5 +1,6 @@ using System; using System.Runtime.Serialization; +using DynamicExpresso.Resources; namespace DynamicExpresso.Exceptions { @@ -7,7 +8,7 @@ namespace DynamicExpresso.Exceptions public class ReflectionNotAllowedException : ParseException { public ReflectionNotAllowedException() - : base("Reflection expression not allowed. To enable reflection use Interpreter.EnableReflection().", 0) + : base(ErrorMessages.ReflectionNotAllowed, 0) { } diff --git a/src/DynamicExpresso.Core/Exceptions/UnknownIdentifierException.cs b/src/DynamicExpresso.Core/Exceptions/UnknownIdentifierException.cs index dab591fe..6591e4c5 100644 --- a/src/DynamicExpresso.Core/Exceptions/UnknownIdentifierException.cs +++ b/src/DynamicExpresso.Core/Exceptions/UnknownIdentifierException.cs @@ -1,5 +1,6 @@ using System; using System.Runtime.Serialization; +using DynamicExpresso.Resources; namespace DynamicExpresso.Exceptions { @@ -7,7 +8,7 @@ namespace DynamicExpresso.Exceptions public class UnknownIdentifierException : ParseException { public UnknownIdentifierException(string identifier, int position) - : base(string.Format("Unknown identifier '{0}'", identifier), position) + : base(string.Format(ErrorMessages.UnknownIdentifier, identifier), position) { Identifier = identifier; } diff --git a/src/DynamicExpresso.Core/Interpreter.cs b/src/DynamicExpresso.Core/Interpreter.cs index 74c81ce6..4a8b05ec 100644 --- a/src/DynamicExpresso.Core/Interpreter.cs +++ b/src/DynamicExpresso.Core/Interpreter.cs @@ -6,6 +6,7 @@ using System.Linq; using System.Linq.Expressions; using DynamicExpresso.Exceptions; +using DynamicExpresso.Resources; namespace DynamicExpresso { @@ -134,7 +135,7 @@ public Interpreter SetDefaultNumberType(DefaultNumberType defaultNumberType) } /// - /// Allows to enable/disable assignment operators. + /// Allows to enable/disable assignment operators. /// For security when expression are generated by the users is more safe to disable assignment operators. /// /// @@ -278,7 +279,7 @@ public Interpreter SetIdentifier(Identifier identifier) throw new ArgumentNullException(nameof(identifier)); if (LanguageConstants.ReservedKeywords.Contains(identifier.Name)) - throw new InvalidOperationException($"{identifier.Name} is a reserved word"); + throw new InvalidOperationException(string.Format(ErrorMessages.ReservedWord, identifier.Name)); _settings.Identifiers[identifier.Name] = identifier; diff --git a/src/DynamicExpresso.Core/Lambda.cs b/src/DynamicExpresso.Core/Lambda.cs index 707f51d7..23b8f91e 100644 --- a/src/DynamicExpresso.Core/Lambda.cs +++ b/src/DynamicExpresso.Core/Lambda.cs @@ -5,6 +5,7 @@ using System.Reflection; using System.Runtime.ExceptionServices; using DynamicExpresso.Reflection; +using DynamicExpresso.Resources; namespace DynamicExpresso { @@ -87,7 +88,7 @@ public object Invoke(params object[] args) if (args != null) { if (declaredParameters.Length != args.Length) - throw new InvalidOperationException("Arguments count mismatch."); + throw new InvalidOperationException(ErrorMessages.ArgumentCountMismatch); for (var i = 0; i < args.Length; i++) { diff --git a/src/DynamicExpresso.Core/Parsing/InterpreterExpression.cs b/src/DynamicExpresso.Core/Parsing/InterpreterExpression.cs index 75d5dfb2..1dc98a9d 100644 --- a/src/DynamicExpresso.Core/Parsing/InterpreterExpression.cs +++ b/src/DynamicExpresso.Core/Parsing/InterpreterExpression.cs @@ -4,6 +4,7 @@ using System.Linq.Expressions; using DynamicExpresso.Exceptions; using DynamicExpresso.Reflection; +using DynamicExpresso.Resources; namespace DynamicExpresso.Parsing { @@ -35,7 +36,7 @@ public InterpreterExpression(ParserArguments parserArguments, string expressionT { if (settings.Identifiers.ContainsKey(myParameter.Name)) { - throw new ParseException($"A local or parameter named '{myParameter.Name}' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter", myParameter.Position); + throw new ParseException(string.Format(ErrorMessages.DuplicateLocalParameterDeclaration, myParameter.Name), myParameter.Position); } } diff --git a/src/DynamicExpresso.Core/Parsing/Parser.cs b/src/DynamicExpresso.Core/Parsing/Parser.cs index 5118524c..eb61acdf 100644 --- a/src/DynamicExpresso.Core/Parsing/Parser.cs +++ b/src/DynamicExpresso.Core/Parsing/Parser.cs @@ -175,7 +175,7 @@ private ParameterWithPosition[] ParseLambdaParameterList() } if (!hasOpenParen && parameters.Length > 1) - throw new ParseException("Multiple lambda parameters detected, but with no surrounding parenthesis", _parsePosition); + throw new ParseException(ErrorMessages.MultipleLambdaParametersWithoutBrace, _parsePosition); return parameters; } @@ -508,7 +508,7 @@ public bool IsShiftOperator(out ExpressionType shiftType) // << could be a token, but is not for symmetry else if (_token.id == TokenId.LessThan && _parseChar == '<') { - NextToken(); // consume next < + NextToken(); // consume next < shiftType = ExpressionType.LeftShift; return true; } @@ -1397,7 +1397,7 @@ private Type ParseKnownType() private bool TryParseKnownType(string name, out Type type) { - // if the type is unknown, we need to restart parsing + // if the type is unknown, we need to restart parsing var originalPos = _token.pos; // the name might reference a generic type, with an aliased name (e.g. List = MyList instead of List`1) @@ -1433,7 +1433,7 @@ private Type ParseKnownGenericType(string name, Type type) return null; if (rank != type.GetGenericArguments().Length) - throw new ArgumentException($"The number of generic arguments provided doesn't equal the arity of the generic type definition."); + throw new ArgumentException(ErrorMessages.GenericArgumentCountMismatch); // there are actual type arguments: instantiate the proper generic type if (typeArguments.All(_ => _ != null)) @@ -1959,7 +1959,7 @@ private Expression GenerateGreaterThan(Expression left, Expression right) return GenerateBinary(ExpressionType.GreaterThan, left, right); } - + private Expression GenerateGreaterThanEqual(Expression left, Expression right) { @@ -2533,7 +2533,7 @@ private void NextToken() if (_parsePosition == _expressionTextLength) { if (_token.id == TokenId.End) - throw new InvalidOperationException("NextToken called when already at the end of the expression"); + throw new InvalidOperationException(ErrorMessages.NextTokenAtEnd); t = TokenId.End; break; diff --git a/src/DynamicExpresso.Core/ReferenceType.cs b/src/DynamicExpresso.Core/ReferenceType.cs index 5019b757..f1664214 100644 --- a/src/DynamicExpresso.Core/ReferenceType.cs +++ b/src/DynamicExpresso.Core/ReferenceType.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Reflection; using DynamicExpresso.Reflection; +using DynamicExpresso.Resources; namespace DynamicExpresso { @@ -30,7 +31,7 @@ public ReferenceType(string name, Type type) var genericType = type.GetGenericTypeDefinition(); var genericTypeName = genericType.Name.Substring(0, genericType.Name.IndexOf('`')); genericTypeName += $"<{new string(',', genericType.GetGenericArguments().Length - 1)}>"; - throw new ArgumentException($"Generic type must be referenced via its generic definition: {genericTypeName}"); + throw new ArgumentException(string.Format(ErrorMessages.GenericTypeReference, genericTypeName)); } Type = type; diff --git a/src/DynamicExpresso.Core/Resources/ErrorMessages.Designer.cs b/src/DynamicExpresso.Core/Resources/ErrorMessages.Designer.cs index 7e0643d1..d85515ba 100644 --- a/src/DynamicExpresso.Core/Resources/ErrorMessages.Designer.cs +++ b/src/DynamicExpresso.Core/Resources/ErrorMessages.Designer.cs @@ -1,7 +1,6 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -12,552 +11,428 @@ namespace DynamicExpresso.Resources { using System; - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class ErrorMessages { - private static global::System.Resources.ResourceManager resourceMan; + private static System.Resources.ResourceManager resourceMan; - private static global::System.Globalization.CultureInfo resourceCulture; + private static System.Globalization.CultureInfo resourceCulture; - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal ErrorMessages() { } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DynamicExpresso.Resources.ErrorMessages", typeof(ErrorMessages).Assembly); + + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + internal static System.Resources.ResourceManager ResourceManager { + get { + if (object.Equals(null, resourceMan)) { + System.Resources.ResourceManager temp = new System.Resources.ResourceManager("DynamicExpresso.Resources.ErrorMessages", typeof(ErrorMessages).Assembly); resourceMan = temp; } return resourceMan; } } - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + internal static System.Globalization.CultureInfo Culture { get { return resourceCulture; } set { resourceCulture = value; } - } - - /// - /// Looks up a localized string similar to Ambiguous invocation of indexer in type '{0}'. - /// - internal static string AmbiguousIndexerInvocation { + } + + internal static string AmbiguousIndexerInvocation { get { return ResourceManager.GetString("AmbiguousIndexerInvocation", resourceCulture); } } - /// - /// Looks up a localized string similar to Ambiguous invocation of method '{0}' in type '{1}'. - /// internal static string AmbiguousMethodInvocation { get { return ResourceManager.GetString("AmbiguousMethodInvocation", resourceCulture); } } - - /// - /// Looks up a localized string similar to Ambiguous invocation of user defined operator '{0}' in type '{1}'. - /// - internal static string AmbiguousUnaryOperatorInvocation - { - get - { - return ResourceManager.GetString("AmbiguousUnaryOperatorInvocation", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Ambiguous invocation of user defined operator '{0}' in types '{1}' and '{2}'. - /// - internal static string AmbiguousBinaryOperatorInvocation - { - get - { - return ResourceManager.GetString("AmbiguousBinaryOperatorInvocation", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Ambiguous invocation of delegate (multiple overloads found). - /// - internal static string AmbiguousDelegateInvocation - { - get - { - return ResourceManager.GetString("AmbiguousDelegateInvocation", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Argument list incompatible with delegate expression. - /// + internal static string ArgsIncompatibleWithDelegate { get { return ResourceManager.GetString("ArgsIncompatibleWithDelegate", resourceCulture); } } - /// - /// Looks up a localized string similar to Argument list incompatible with lambda expression. - /// internal static string ArgsIncompatibleWithLambda { get { return ResourceManager.GetString("ArgsIncompatibleWithLambda", resourceCulture); } } - /// - /// Looks up a localized string similar to Both of the types '{0}' and '{1}' convert to the other. - /// internal static string BothTypesConvertToOther { get { return ResourceManager.GetString("BothTypesConvertToOther", resourceCulture); } } - /// - /// Looks up a localized string similar to A value of type '{0}' cannot be converted to type '{1}'. - /// internal static string CannotConvertValue { get { return ResourceManager.GetString("CannotConvertValue", resourceCulture); } } - /// - /// Looks up a localized string similar to ']' or ',' expected. - /// internal static string CloseBracketOrCommaExpected { get { return ResourceManager.GetString("CloseBracketOrCommaExpected", resourceCulture); } } - /// - /// Looks up a localized string similar to ')' or ',' expected. - /// internal static string CloseParenOrCommaExpected { get { return ResourceManager.GetString("CloseParenOrCommaExpected", resourceCulture); } } - /// - /// Looks up a localized string similar to ')' or operator expected. - /// internal static string CloseParenOrOperatorExpected { get { return ResourceManager.GetString("CloseParenOrOperatorExpected", resourceCulture); } } - - /// - /// Looks up a localized string similar to '=' expected. - /// - internal static string EqualExpected - { - get - { - return ResourceManager.GetString("EqualExpected", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to ':' expected. - /// + internal static string ColonExpected { get { return ResourceManager.GetString("ColonExpected", resourceCulture); } } - /// - /// Looks up a localized string similar to Digit expected. - /// internal static string DigitExpected { get { return ResourceManager.GetString("DigitExpected", resourceCulture); } } - /// - /// Looks up a localized string similar to '.' or '(' expected. - /// internal static string DotOrOpenParenExpected { get { return ResourceManager.GetString("DotOrOpenParenExpected", resourceCulture); } } - /// - /// Looks up a localized string similar to Expression expected. - /// internal static string ExpressionExpected { get { return ResourceManager.GetString("ExpressionExpected", resourceCulture); } } - /// - /// Looks up a localized string similar to Expression must be writable. - /// internal static string ExpressionMustBeWritable { get { return ResourceManager.GetString("ExpressionMustBeWritable", resourceCulture); } } - /// - /// Looks up a localized string similar to The first expression must be of type 'Boolean'. - /// internal static string FirstExprMustBeBool { get { return ResourceManager.GetString("FirstExprMustBeBool", resourceCulture); } } - /// - /// Looks up a localized string similar to {0} (at index {1}).. - /// internal static string Format { get { return ResourceManager.GetString("Format", resourceCulture); } } - /// - /// Looks up a localized string similar to Identifier expected. - /// internal static string IdentifierExpected { get { return ResourceManager.GetString("IdentifierExpected", resourceCulture); } } - /// - /// Looks up a localized string similar to Operator '{0}' incompatible with operand type '{1}'. - /// internal static string IncompatibleOperand { get { return ResourceManager.GetString("IncompatibleOperand", resourceCulture); } } - /// - /// Looks up a localized string similar to Operator '{0}' incompatible with operand types '{1}' and '{2}'. - /// internal static string IncompatibleOperands { get { return ResourceManager.GetString("IncompatibleOperands", resourceCulture); } } - /// - /// Looks up a localized string similar to Incorrect number of indexes. - /// internal static string IncorrectNumberOfIndexes { get { return ResourceManager.GetString("IncorrectNumberOfIndexes", resourceCulture); } } - /// - /// Looks up a localized string similar to Syntax error '{0}'. - /// internal static string InvalidCharacter { get { return ResourceManager.GetString("InvalidCharacter", resourceCulture); } } - /// - /// Looks up a localized string similar to Character literal must contain exactly one character. - /// internal static string InvalidCharacterLiteral { get { return ResourceManager.GetString("InvalidCharacterLiteral", resourceCulture); } } - /// - /// Looks up a localized string similar to Invalid character escape sequence. - /// internal static string InvalidEscapeSequence { get { return ResourceManager.GetString("InvalidEscapeSequence", resourceCulture); } } - /// - /// Looks up a localized string similar to Array index must be an integer expression. - /// internal static string InvalidIndex { get { return ResourceManager.GetString("InvalidIndex", resourceCulture); } } - /// - /// Looks up a localized string similar to Invalid integer literal '{0}'. - /// internal static string InvalidIntegerLiteral { get { return ResourceManager.GetString("InvalidIntegerLiteral", resourceCulture); } } - /// - /// Looks up a localized string similar to No applicable method exists in type '{0}'. - /// internal static string InvalidMethodCall { get { return ResourceManager.GetString("InvalidMethodCall", resourceCulture); } } - - /// - /// Looks up a localized string similar to Params array type is not an array, element not found - /// - internal static string ParamsArrayTypeNotAnArray - { - get - { - return ResourceManager.GetString("ParamsArrayTypeNotAnArray", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The type arguments for method '{0}' cannot be inferred from the usage. - /// - internal static string MethodTypeParametersCantBeInferred - { - get - { - return ResourceManager.GetString("MethodTypeParametersCantBeInferred", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invalid real literal '{0}'. - /// - internal static string InvalidRealLiteral { + + internal static string InvalidRealLiteral { get { return ResourceManager.GetString("InvalidRealLiteral", resourceCulture); } } - /// - /// Looks up a localized string similar to Neither of the types '{0}' and '{1}' converts to the other. - /// internal static string NeitherTypeConvertsToOther { get { return ResourceManager.GetString("NeitherTypeConvertsToOther", resourceCulture); } } - /// - /// Looks up a localized string similar to No applicable constructor exists in type '{0}'. - /// internal static string NoApplicableConstructor { get { return ResourceManager.GetString("NoApplicableConstructor", resourceCulture); } - } - - /// - /// Looks up a localized string similar to Ambiguous invocation of constructor in type '{0}'. - /// - internal static string AmbiguousConstructorInvocation - { - get - { - return ResourceManager.GetString("AmbiguousConstructorInvocation", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to No applicable indexer exists in type '{0}'. - /// - internal static string NoApplicableIndexer { + } + + internal static string NoApplicableIndexer { get { return ResourceManager.GetString("NoApplicableIndexer", resourceCulture); } } - /// - /// Looks up a localized string similar to '(' expected. - /// internal static string OpenParenExpected { get { return ResourceManager.GetString("OpenParenExpected", resourceCulture); } } - - /// - /// Looks up a localized string similar to '{' expected. - /// - internal static string OpenCurlyBracketExpected - { - get - { - return ResourceManager.GetString("OpenCurlyBracketExpected", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to '}' expected. - /// - internal static string CloseCurlyBracketExpected - { - get - { - return ResourceManager.GetString("CloseCurlyBracketExpected", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to '>' expected. - /// - internal static string CloseTypeArgumentListExpected - { - get - { - return ResourceManager.GetString("CloseTypeArgumentListExpected", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Syntax error. - /// + internal static string SyntaxError { get { return ResourceManager.GetString("SyntaxError", resourceCulture); } } - /// - /// Looks up a localized string similar to Type '{0}' has no nullable form. - /// internal static string TypeHasNoNullableForm { get { return ResourceManager.GetString("TypeHasNoNullableForm", resourceCulture); } } - /// - /// Looks up a localized string similar to Type identifier expected. - /// internal static string TypeIdentifierExpected { get { return ResourceManager.GetString("TypeIdentifierExpected", resourceCulture); } } - /// - /// Looks up a localized string similar to The 'typeof' keyword requires a type as an argument. - /// internal static string TypeofRequiresAType { get { return ResourceManager.GetString("TypeofRequiresAType", resourceCulture); } } - /// - /// Looks up a localized string similar to The 'typeof' keyword requires 1 argument. - /// internal static string TypeofRequiresOneArg { get { return ResourceManager.GetString("TypeofRequiresOneArg", resourceCulture); } } - /// - /// Looks up a localized string similar to No property or field '{0}' exists in type '{1}'. - /// internal static string UnknownPropertyOrField { get { return ResourceManager.GetString("UnknownPropertyOrField", resourceCulture); } } - /// - /// Looks up a localized string similar to Unterminated string literal. - /// internal static string UnterminatedStringLiteral { get { return ResourceManager.GetString("UnterminatedStringLiteral", resourceCulture); } } - - /// - /// Looks up a localized string similar to Unterminated string literal. - /// + internal static string InvalidOperation { get { return ResourceManager.GetString("InvalidOperation", resourceCulture); } } - - /// - /// Looks up a localized string similar to Multidimensional arrays are not supported. - /// - internal static string UnsupportedMultidimensionalArrays - { - get - { - return ResourceManager.GetString("UnsupportedMultidimensionalArrays", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invalid initializer member declarator. - /// - internal static string InvalidInitializerMemberDeclarator { - get { - return ResourceManager.GetString("InvalidInitializerMemberDeclarator", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Cannot initialize type '{0}' with a collection initializer because it does not implement '{1}'. - /// - internal static string CollectionInitializationNotSupported { - get { - return ResourceManager.GetString("CollectionInitializationNotSupported", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The best overloaded Add method '{0}.Add' for the collection initializer has some invalid arguments. - /// - internal static string UnableToFindAppropriateAddMethod { - get { - return ResourceManager.GetString("UnableToFindAppropriateAddMethod", resourceCulture); - } - } - - } + + internal static string AmbiguousBinaryOperatorInvocation { + get { + return ResourceManager.GetString("AmbiguousBinaryOperatorInvocation", resourceCulture); + } + } + + internal static string AmbiguousUnaryOperatorInvocation { + get { + return ResourceManager.GetString("AmbiguousUnaryOperatorInvocation", resourceCulture); + } + } + + internal static string AmbiguousDelegateInvocation { + get { + return ResourceManager.GetString("AmbiguousDelegateInvocation", resourceCulture); + } + } + + internal static string CloseCurlyBracketExpected { + get { + return ResourceManager.GetString("CloseCurlyBracketExpected", resourceCulture); + } + } + + internal static string OpenCurlyBracketExpected { + get { + return ResourceManager.GetString("OpenCurlyBracketExpected", resourceCulture); + } + } + + internal static string EqualExpected { + get { + return ResourceManager.GetString("EqualExpected", resourceCulture); + } + } + + internal static string CloseTypeArgumentListExpected { + get { + return ResourceManager.GetString("CloseTypeArgumentListExpected", resourceCulture); + } + } + + internal static string MethodTypeParametersCantBeInferred { + get { + return ResourceManager.GetString("MethodTypeParametersCantBeInferred", resourceCulture); + } + } + + internal static string ParamsArrayTypeNotAnArray { + get { + return ResourceManager.GetString("ParamsArrayTypeNotAnArray", resourceCulture); + } + } + + internal static string AmbiguousConstructorInvocation { + get { + return ResourceManager.GetString("AmbiguousConstructorInvocation", resourceCulture); + } + } + + internal static string UnsupportedMultidimensionalArrays { + get { + return ResourceManager.GetString("UnsupportedMultidimensionalArrays", resourceCulture); + } + } + + internal static string InvalidInitializerMemberDeclarator { + get { + return ResourceManager.GetString("InvalidInitializerMemberDeclarator", resourceCulture); + } + } + + internal static string CollectionInitializationNotSupported { + get { + return ResourceManager.GetString("CollectionInitializationNotSupported", resourceCulture); + } + } + + internal static string UnableToFindAppropriateAddMethod { + get { + return ResourceManager.GetString("UnableToFindAppropriateAddMethod", resourceCulture); + } + } + + internal static string ReservedWord { + get { + return ResourceManager.GetString("ReservedWord", resourceCulture); + } + } + + internal static string ArgumentCountMismatch { + get { + return ResourceManager.GetString("ArgumentCountMismatch", resourceCulture); + } + } + + internal static string GenericTypeReference { + get { + return ResourceManager.GetString("GenericTypeReference", resourceCulture); + } + } + + internal static string AssignmentOperatorNotAllowed { + get { + return ResourceManager.GetString("AssignmentOperatorNotAllowed", resourceCulture); + } + } + + internal static string DuplicateParameter { + get { + return ResourceManager.GetString("DuplicateParameter", resourceCulture); + } + } + + internal static string InvalidMethodCall2 { + get { + return ResourceManager.GetString("InvalidMethodCall2", resourceCulture); + } + } + + internal static string ReflectionNotAllowed { + get { + return ResourceManager.GetString("ReflectionNotAllowed", resourceCulture); + } + } + + internal static string UnknownIdentifier { + get { + return ResourceManager.GetString("UnknownIdentifier", resourceCulture); + } + } + + internal static string DuplicateLocalParameterDeclaration { + get { + return ResourceManager.GetString("DuplicateLocalParameterDeclaration", resourceCulture); + } + } + + internal static string MultipleLambdaParametersWithoutBrace { + get { + return ResourceManager.GetString("MultipleLambdaParametersWithoutBrace", resourceCulture); + } + } + + internal static string GenericArgumentCountMismatch { + get { + return ResourceManager.GetString("GenericArgumentCountMismatch", resourceCulture); + } + } + + internal static string NextTokenAtEnd { + get { + return ResourceManager.GetString("NextTokenAtEnd", resourceCulture); + } + } + } } diff --git a/src/DynamicExpresso.Core/Resources/ErrorMessages.de.resx b/src/DynamicExpresso.Core/Resources/ErrorMessages.de.resx index cc3a5d1f..65e6b453 100644 --- a/src/DynamicExpresso.Core/Resources/ErrorMessages.de.resx +++ b/src/DynamicExpresso.Core/Resources/ErrorMessages.de.resx @@ -177,4 +177,40 @@ Nicht-beendetes Zeichenfolgenliteral + + {0} ist ein reserviertes Wort + + + Argumentzahl unpassend + + + Generische Typen müssen mittels generischer Definition referenziert werden: {0} + + + Zuweisungsoperator '{0}' ist nicht erlaubt + + + Der Parameter '{0}' wurde mehrmals definiert + + + Keine zutreffende Methode '{0}' gefunden im Typ '{1}' + + + Spiegelungsausdrücke sind nicht erlaubt. Aktivieren Sie Spiegelung mittels Interpreter.EnableReflection(). + + + Unbekannter Bezeichner '{0}' + + + Eine locale Variable oder Parameter '{0}' kann nicht in dieser Zugriffsebene deklariert werden, da dieser Name bereits in einer höheren Zugriffsebene verwendet wird, um eine lokale Variable oder Parameter zu definieren + + + Mehrere Lambda-Funktionsparameter erkannt, aber keine umgebenden Klammern gegeben + + + Die Anzahl an Typargumenten für den generischen Typ stimmt nicht mit der Stelligkeit der Definition überein + + + NextToken wurde am Ende des Ausdrucks aufgerufen + diff --git a/src/DynamicExpresso.Core/Resources/ErrorMessages.resx b/src/DynamicExpresso.Core/Resources/ErrorMessages.resx index 9a3ea951..f5ed85fc 100644 --- a/src/DynamicExpresso.Core/Resources/ErrorMessages.resx +++ b/src/DynamicExpresso.Core/Resources/ErrorMessages.resx @@ -1,17 +1,17 @@  - @@ -276,4 +276,40 @@ The best overloaded Add method '{0}.Add' for the collection initializer has some invalid arguments - \ No newline at end of file + + {0} is a reserved word + + + Arguments count mismatch + + + Generic type must be referenced via its generic definition: {0} + + + Assignment operator '{0}' not allowed + + + The parameter '{0}' was defined more than once + + + No applicable method '{0}' exists in type '{1}' + + + Reflection expression not allowed. To enable reflection use Interpreter.EnableReflection(). + + + Unknown identifier '{0}' + + + A local or parameter named '{0}' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter + + + Multiple lambda parameters detected, but with no surrounding parenthesis + + + The number of generic arguments provided doesn't equal the arity of the generic type definition + + + NextToken called when already at the end of the expression + +