-
Notifications
You must be signed in to change notification settings - Fork 3
Feature/function variables #75
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
Conversation
Add custom functions, similiary to variables. Add predefined Add new feature - Functions Add predefined system functions.
Add missing test scenarios.
Add functions to demo. Edit documentation.
Suppress warning for nuget and change version for nuget package
Addressing comments from PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
src/TeaPie/Functions/Function.cs
Outdated
| } | ||
|
|
||
| return _func((T1)Convert.ChangeType(args[0], typeof(T1)), (T2)Convert.ChangeType(args[1], typeof(T2))); | ||
| return _func((TParameter1)Convert.ChangeType(args[0], typeof(TParameter1)), (TParameter2)Convert.ChangeType(args[1], typeof(TParameter2))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too long line.
src/TeaPie/Functions/Function.cs
Outdated
| } | ||
|
|
||
| internal class Function<T1, T2, T>(string name, Func<T1, T2, T> func) : Function(name) | ||
| internal class Function<TParameter1, TParameter2, TResult>(string name, Func<TParameter1, TParameter2, TResult> func) : Function(name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too long line.
TL;DR
Resolves #71
This PR introduces a system for built-in and user-defined functions to TeaPie, allowing dynamic value generation in scripts and
.httpfiles.Highlights
🔧 Function system
New infrastructure for defining, registering, validating, and executing functions
Built-in functions:
$now→ current timestamp$guid→ new GUID$rand→ random double$randomInt→ random integerResolver for parsing/executing functions in
.httpfiles (with argument parsing via System.CommandLine)Functions are injectable across the application
📖 Documentation
🧪 Demo & Tests
$carReturnDate)Files of interest
src/TeaPie/Functions/*src/TeaPie/Functions/FunctionsResolver.csdocs/docs/functions.mddemo/Tests/003-Car-Rentals/*,demo/.teapie/Definitions/CarRent.csx,demo/server/CarRentalServer.json