Skip to content

DetectIdentifier obtain complete variable name#323

Merged
davideicardi merged 2 commits intodynamicexpresso:masterfrom
alesanchez-windifferent:feat/detect-identifiers-complete-variable-name
Nov 15, 2024
Merged

DetectIdentifier obtain complete variable name#323
davideicardi merged 2 commits intodynamicexpresso:masterfrom
alesanchez-windifferent:feat/detect-identifiers-complete-variable-name

Conversation

@alesanchez-windifferent
Copy link
Copy Markdown
Contributor

Add logic to enable detection of complete variable name (ex. contact.firstname)

Comment thread src/DynamicExpresso.Core/Detector.cs Outdated
@davideicardi
Copy link
Copy Markdown
Member

Thank you for the PR. I only proposed a change in the signature.

- Change signature
@davideicardi davideicardi merged commit 85270ac into dynamicexpresso:master Nov 15, 2024
@metoule
Copy link
Copy Markdown
Contributor

metoule commented Mar 27, 2025

@alesanchez-windifferent can you please explain what you were trying to accomplish with this PR? The implementation seems wrong, and led to #351. For example, with your implementation:

var target = new Interpreter();
target.SetVariable("test", "Toto");

var detectedIdentifiers = target.DetectIdentifiers("test.Length", DetectorOptions.IncludeChildren);
Assert.That(detectedIdentifiers.UnknownIdentifiers, Is.Empty);

Failure:

detectedIdentifiers.UnknownIdentifiers:
  Expected: <empty>
  But was:  < "test.Length" >

test is a valid variable, and Length is a valid property of string, so the Unknown identifiers should be empty.

With DetectorOptions.IncludeChildren, you check whether the entire string test.Length is an identifier, or a lambda parameter, or a known type, but I don't see in which case it can ever true?

@davideicardi
Copy link
Copy Markdown
Member

@metoule I thought that with the PR the idea was to also check for any missing sub-properties or sub-functions. But I realize only now that the implementation is not correct. My mistake for not checking more carefully. Sorry.

Can we ollback the code, leaving DetectorOptions for the future, and marking IncludeChildren option as obsolete?

@alesanchez-windifferent If you explain your use case maybe we can find another solution.

@blahetal
Copy link
Copy Markdown

blahetal commented Apr 2, 2025

Having a full blown implementation which would check sub/properties and functions of all detected identifiers would be great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants