Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling Parser.ParseWithContext from another project throw TargetParameterCountException #527

Closed
bdke opened this issue Jan 16, 2025 · 6 comments
Assignees

Comments

@bdke
Copy link
Contributor

bdke commented Jan 16, 2025

Info

  • OS: Windows
  • Package Version: 3.5.1
  • Net Version: 9.0.100

Reproduce Steps

Calling a method that call Parse<IN, OUT>.ParseWithContext(IList<Token<TokenType>>) from another project.

Calling that method in the same project work normally.

Error Log

   at System.Reflection.MethodBaseInvoker.ThrowTargetParameterCountException()
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
   at sly.parser.generator.visitor.EBNFSyntaxTreeVisitor`2.Visit(SyntaxNode`2 node, Object context)
   at sly.parser.generator.visitor.EBNFSyntaxTreeVisitor`2.Visit(ISyntaxNode`2 n, Object context)
   at sly.parser.generator.visitor.EBNFSyntaxTreeVisitor`2.Visit(SyntaxNode`2 node, Object context)
   at sly.parser.generator.visitor.EBNFSyntaxTreeVisitor`2.Visit(ISyntaxNode`2 n, Object context)
   at sly.parser.generator.visitor.EBNFSyntaxTreeVisitor`2.Visit(SyntaxNode`2 node, Object context)
   at sly.parser.generator.visitor.EBNFSyntaxTreeVisitor`2.Visit(ISyntaxNode`2 n, Object context)
   at sly.parser.generator.visitor.EBNFSyntaxTreeVisitor`2.Visit(ManySyntaxNode`2 node, Object context)
   at sly.parser.generator.visitor.EBNFSyntaxTreeVisitor`2.Visit(ISyntaxNode`2 n, Object context)
   at sly.parser.generator.visitor.EBNFSyntaxTreeVisitor`2.Visit(SyntaxNode`2 node, Object context)
   at sly.parser.generator.visitor.EBNFSyntaxTreeVisitor`2.Visit(ISyntaxNode`2 n, Object context)
   at sly.parser.generator.visitor.SyntaxTreeVisitor`2.VisitSyntaxTree(ISyntaxNode`2 root, Object context)
   at sly.parser.Parser`2.ParseWithContext(IList`1 tokens, Object parsingContext, String startingNonTerminal)
@b3b00
Copy link
Owner

b3b00 commented Jan 17, 2025

@bdke, First could you provide a reproducing test case.
Secondly I think that ParseWithContext needs 2 parameters :

  • a list of token as you provide
  • an object instance that will be the actual context. this might be null as default
  • and and optional third that is the starting non terminal

So my guess is that there can be an issue when the context object is null , but in this case why wouldn't you use the basic Parse(IList<Token>) method as a null context is no context at all.

But then I don't see any relation with the "calling from another project" part of your issue.

So please add a reproducing test case.

Waiting for it I will try and see what happen when calling ParseWithContext without a context.

Thanks

@b3b00
Copy link
Owner

b3b00 commented Jan 17, 2025

@bdke , I reproduce the exception when calling ParseWithContextwithout the context param. I will look at it. Still could you explain the "calling from another project" part ? How is your solution architected ? which project is ok , and which is not .....
i think this part is not the real problem

b3b00 added a commit that referenced this issue Jan 17, 2025
@b3b00 b3b00 self-assigned this Jan 17, 2025
@b3b00
Copy link
Owner

b3b00 commented Jan 17, 2025

@bdke , i've fixed the bug on branch https://github.com/b3b00/csly/tree/bugfix/issue%23527.
I 'm waiting for more context to be sure that the fix is complete. Then I will merge on dev branch and release a new nuget version

@b3b00 b3b00 closed this as completed in ad64f10 Jan 17, 2025
b3b00 added a commit that referenced this issue Jan 17, 2025
@b3b00
Copy link
Owner

b3b00 commented Jan 17, 2025

@bdke , I've published nes nuget version 3.5.2
As you do not answer to provide more context I close this issue.

@bdke
Copy link
Contributor Author

bdke commented Jan 20, 2025

sorry for the late reply, seem like i am still having the same exception
i will provide a minimum reproducible unit test in pull request

@bdke
Copy link
Contributor Author

bdke commented Jan 20, 2025

instance is null as default so it did not throw any error in IDE so i thought it was an issue
it was my fault. Thanks for your reply

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

No branches or pull requests

2 participants