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

feat(mono-rt2): allow default parameters for dynfunc #2918

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

DaniGP17
Copy link
Contributor

@DaniGP17 DaniGP17 commented Nov 9, 2024

Goal of this PR

This allows parameters to have default values ​​for DynFuncs

Example

[EventHandler("testing_event", Binding.Local)]
void TestEvent(int a, string b = "default value")
{
    Debug.WriteLine("Test func a="+a+", b="+b);
}

How is this PR achieving the goal

Declaring at the beginning a local variable to store the size of the argument array. Within the for, if the index of the current parameter is greater than the size of the array arguments, it will use the optional parameter. To do this I have seen the implementation that was made at https://github.com/citizenfx/msgpack-cs/blob/master/MsgPack/MsgPackFunc.cs#L138

This PR applies to the following area(s)

ScRT: C#

Successfully tested on

Game builds: ..

Platforms: Windows

Checklist

  • Code compiles and has been tested successfully.
  • Code explains itself well and/or is documented.
  • My commit message explains what the changes do and what they are for.
  • No extra compilation warnings are added by these changes.

Fixes issues

@github-actions github-actions bot added ScRT: C# Issues/PRs related to either C# scripting runtimes invalid Requires changes before it's considered valid and can be (re)triaged labels Nov 9, 2024
@DaniGP17 DaniGP17 closed this Nov 9, 2024
@github-actions github-actions bot added triage Needs a preliminary assessment to determine the urgency and required action and removed invalid Requires changes before it's considered valid and can be (re)triaged labels Nov 9, 2024
@DaniGP17 DaniGP17 reopened this Nov 9, 2024
@github-actions github-actions bot added invalid Requires changes before it's considered valid and can be (re)triaged and removed triage Needs a preliminary assessment to determine the urgency and required action labels Nov 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid Requires changes before it's considered valid and can be (re)triaged ScRT: C# Issues/PRs related to either C# scripting runtimes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant