-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Add support for multiple native function arguments of many types #1195
Merged
Commits on Jun 13, 2023
-
Add native function support for multiple arguments, non-string args, …
…and non-string returns - Native skills can now have any number of parameters. The parameters are populated from context variables of the same name. If no context variable exists for that name, it'll be populated with a default value if one was supplied via either an attribute or a default parameter value, or if there is none, the function will fail to be invoked. The first parameter may also be populated from "input" if it fails to get input by its name or default value. - Descriptions are now specified with the .NET DescriptionAttribute, and DefaultValue with the DefaultValueAttribute. The C# compiler is aware of the DefaultValueAttribute and ensures the type of the value provided matches that of the type of the parameter. Default values can now also be specified using optional parameter values. - SKFunction is now purely a marker attribute, other than for sensitivity. It's sole purpose is to subset which public members are imported as native functions when a skill is imported. It was already the case that the attribute wasn't needed when importing a function directly from a delegate; that requirement has also been lifted when importing from a MethodInfo. - SKFunctionContextParameterAttribute has been obsoleted and will be removed subsequently. DescriptionAttribute, DefaultValueAttribute, and SKName attribute are used instead. In rare situations where the method needs access to a variable that's not defined in its signature, it can use the SKParameter attribute on the method, which does have Description and DefaultValue optional properties. - SKFunctionInputAttribute has been obsoleted and will be removed subsequently. DescriptionAttribute, DefaultValueAttribute, and SKName attribute are used instead (the latter with "Input" as the name). However, the need to use SKName should be exceedingly rare. - InvokeAsync will now catch exceptions and store the exception into the context. This means native skills should handle all failures by throwing exceptions rather than by directly interacting with the context. - Updated name selection heuristic to strip off an "Async" suffix for async methods. There are now very few reasons to use [SKName] on a method. - Added support for ValueTasks as return types, just for completeness so that developers don't need to think about it. It just works. - Added ability to accept an ILogger or CancellationToken into a method; they're populated from the SKContext. With that, there are very few reasons left to pass an SKContext into a native function. - Added support for non-string arguments. All C# primitive types and many core .NET types are supported, with their corresponding TypeConverters used to parse the string context variable into the appropriate type. Custom types attributed with TypeConverterAttribute may also be used, and the associated TypeConverter will be used as is appropriate. It's the same mechanism used by UI frameworks like WinForms as well as ASP.NET MVC. - Similarly, added support for non-string return types.
Configuration menu - View commit details
-
Copy full SHA for 009ccc9 - Browse repository at this point
Copy the full SHA 009ccc9View commit details
Commits on Jun 14, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 1c010fd - Browse repository at this point
Copy the full SHA 1c010fdView commit details
Commits on Jun 15, 2023
-
Configuration menu - View commit details
-
Copy full SHA for d8bf63f - Browse repository at this point
Copy the full SHA d8bf63fView commit details
Commits on Jun 16, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 9ad839c - Browse repository at this point
Copy the full SHA 9ad839cView commit details -
name committed
Jun 16, 2023 Configuration menu - View commit details
-
Copy full SHA for 78f154c - Browse repository at this point
Copy the full SHA 78f154cView commit details -
Increase package minor version
name committedJun 16, 2023 Configuration menu - View commit details
-
Copy full SHA for 4ccf8e6 - Browse repository at this point
Copy the full SHA 4ccf8e6View commit details -
Adding InternalUtilities to SK-dotnet.sln
name committedJun 16, 2023 Configuration menu - View commit details
-
Copy full SHA for 8bf200f - Browse repository at this point
Copy the full SHA 8bf200fView commit details -
Configuration menu - View commit details
-
Copy full SHA for b8c905c - Browse repository at this point
Copy the full SHA b8c905cView commit details -
Configuration menu - View commit details
-
Copy full SHA for 3329af9 - Browse repository at this point
Copy the full SHA 3329af9View commit details
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.