diff --git a/src/Ramstack.ExpressionParser/DefaultBinder.cs b/src/Ramstack.ExpressionParser/DefaultBinder.cs index 1b8dec9..dbd8b0d 100644 --- a/src/Ramstack.ExpressionParser/DefaultBinder.cs +++ b/src/Ramstack.ExpressionParser/DefaultBinder.cs @@ -16,12 +16,12 @@ namespace Ramstack.Parsing; /// public class DefaultBinder : Binder { - private static readonly Dictionary Empty = new(); + private static readonly Dictionary s_empty = new(); /// /// A predefined dictionary of safe common .NET types. /// - private static readonly Dictionary PredefinedType = new(StringComparer.OrdinalIgnoreCase) + private static readonly Dictionary s_predefinedTypes = new(StringComparer.OrdinalIgnoreCase) { { "bool", (typeof(bool), false) }, { "boolean", (typeof(bool), false) }, @@ -81,7 +81,7 @@ public class DefaultBinder : Binder /// /// A dictionary of user-registered types. /// - private Dictionary _types = Empty; + private Dictionary _types = s_empty; /// /// Registers a custom type for use in binding operations, allowing it to be resolved by name. @@ -96,9 +96,9 @@ public class DefaultBinder : Binder /// public void RegisterType(Type type, bool importAsStatic = false) { - if (!PredefinedType.ContainsKey(type.Name)) + if (!s_predefinedTypes.ContainsKey(type.Name)) { - if (ReferenceEquals(_types, Empty)) + if (ReferenceEquals(_types, s_empty)) _types = new Dictionary(StringComparer.OrdinalIgnoreCase); _types[type.Name] = (type, importAsStatic); @@ -108,7 +108,7 @@ public void RegisterType(Type type, bool importAsStatic = false) /// public override Type? BindToType(Identifier name) { - if (!PredefinedType.TryGetValue(name.Name, out var value)) + if (!s_predefinedTypes.TryGetValue(name.Name, out var value)) _types.TryGetValue(name.Name, out value); return value.type; @@ -119,7 +119,7 @@ public void RegisterType(Type type, bool importAsStatic = false) { var q = type is not null ? GetMethods(type, methodName.Name, isStatic) - : PredefinedType + : s_predefinedTypes .Concat(_types) .Where(t => t.Value.isStatic) .SelectMany(t => GetMethods(t.Value.type, methodName.Name, isStatic)); @@ -143,7 +143,7 @@ public void RegisterType(Type type, bool importAsStatic = false) : BindingFlags.Public | BindingFlags.Instance; var q = type?.GetMembers(bindingFlags) - ?? PredefinedType + ?? s_predefinedTypes .Concat(_types) .Where(t => t.Value.isStatic) .SelectMany(t => t.Value.type.GetMembers(bindingFlags)); diff --git a/src/Ramstack.ExpressionParser/ExpressionBuilder.cs b/src/Ramstack.ExpressionParser/ExpressionBuilder.cs index 9120808..9771f46 100644 --- a/src/Ramstack.ExpressionParser/ExpressionBuilder.cs +++ b/src/Ramstack.ExpressionParser/ExpressionBuilder.cs @@ -14,7 +14,7 @@ public partial class ExpressionBuilder(Binder binder) : ExprVisitor /// /// The overloads of the string.Concat method that the + operator with a string operand is bound to. /// - private static readonly MethodBase[] ConcatMethods = typeof(string) + private static readonly MethodBase[] s_concatMethods = typeof(string) .GetMethods(BindingFlags.Public | BindingFlags.Static) .Where(m => m.Name == nameof(string.Concat) @@ -117,7 +117,7 @@ protected internal override Expression VisitBinary(Expr.Binary expr) } } - var cmi = (MethodInfo?)MethodResolver.ResolveMethod(ConcatMethods, argumentTypes.ToArray())!; + var cmi = (MethodInfo?)MethodResolver.ResolveMethod(s_concatMethods, argumentTypes.ToArray())!; Debug.Assert(cmi is not null); var args = CreateInjectingArguments(cmi, arguments);