-
-
Notifications
You must be signed in to change notification settings - Fork 394
Open
Labels
Description
Description
When using the DetectIdentifiers method of the Interpreter, generic type (e.g. Tuple<>) is incorrectly detected as an unknown identifier, despite being properly referenced and Eval() works.
var target = new Interpreter();
target.Reference(typeof(Tuple<>));
target.Reference(typeof(Tuple<,>));
target.Reference(typeof(Tuple<,,>));
var expression = "new Tuple<int>(1).Item1";
var result = target.Eval(expression);
Console.WriteLine(result); // 1
var detectedIdentifiers = target.DetectIdentifiers(expression);
Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(detectedIdentifiers.UnknownIdentifiers)); // ["Tuple"]
I think we can add a KnownGenericTypes, and update DetectIdentifiers
else if (_settings.KnownGenericTypes.TryGetValue(identifier, out ReferenceType knownType))
knownTypes.Add(knownType);
, but I'm not sure if there's an better fix. Could you take a look when you have time?