Skip to content

Conversation

metoule
Copy link
Contributor

@metoule metoule commented Apr 3, 2025

For value types parameters, the parameter's default value returned by the reflection API is null, which is not a valid value for value types.

This PR detects the situation, and instantiates the value type to the default value.

public class Functions
{
	public Guid ReturnsGuid(Guid guid = default)
	{
		return guid;
	}
}

var interpreter = new Interpreter();
interpreter.SetVariable("b", new Functions());

Assert.That(interpreter.Eval<Guid>("b.ReturnsGuid()"), Is.EqualTo(Guid.Empty));

Fixes #354

@metoule metoule requested a review from davideicardi as a code owner April 3, 2025 06:54
@metoule metoule merged commit 7010c2c into dynamicexpresso:master Apr 4, 2025
2 checks passed
@metoule metoule deleted the fix_354 branch April 4, 2025 13:50
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.

Calling functions with some struct parameters set to "default" by default throws an exception: "Arguments do not match."
2 participants