-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for non-string arguments
TypeDescriptors are used to both implicitly support a large number of types implicitly and also to support an extensibility mechanism. It's the same mechanism used by UI frameworks like WinForms as well as ASP.NET MVC.
- Loading branch information
1 parent
69c1ffe
commit b1dec86
Showing
35 changed files
with
496 additions
and
264 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<Project> | ||
<ItemGroup> | ||
<Compile Include="$(RepoRoot)/dotnet/src/InternalUtilities/src/**/*.cs" Link="%(RecursiveDir)%(Filename)%(Extension)" /> | ||
</ItemGroup> | ||
</Project> |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
|
||
using System; | ||
using Xunit; | ||
|
||
namespace SemanticKernel.UnitTests; | ||
|
||
internal static class AssertExtensions | ||
{ | ||
/// <summary>Asserts that an exception is an <see cref="ArgumentOutOfRangeException"/> with the specified values.</summary> | ||
public static void AssertIsArgumentOutOfRange(Exception? e, string expectedParamName, string expectedActualValue) | ||
{ | ||
ArgumentOutOfRangeException aoore = Assert.IsType<ArgumentOutOfRangeException>(e); | ||
Assert.Equal(expectedActualValue, aoore.ActualValue); | ||
Assert.Equal(expectedParamName, aoore.ParamName); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
|
||
using Microsoft.SemanticKernel.Orchestration; | ||
using Microsoft.SemanticKernel.SkillDefinition; | ||
using Microsoft.SemanticKernel; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
|
||
namespace SemanticKernel.UnitTests; | ||
|
||
/// <summary>Test helpers for working with native functions.</summary> | ||
internal static class FunctionHelpers | ||
{ | ||
/// <summary> | ||
/// Invokes a function on a skill instance via the kernel. | ||
/// </summary> | ||
public static Task<SKContext> CallViaKernel( | ||
object skillInstance, | ||
string methodName, | ||
params (string Name, string Value)[] variables) | ||
{ | ||
var kernel = Kernel.Builder.Build(); | ||
|
||
IDictionary<string, ISKFunction> funcs = kernel.ImportSkill(skillInstance); | ||
|
||
SKContext context = kernel.CreateNewContext(); | ||
foreach ((string Name, string Value) pair in variables) | ||
{ | ||
context.Variables.Set(pair.Name, pair.Value); | ||
} | ||
|
||
return funcs[methodName].InvokeAsync(context); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
dotnet/src/InternalUtilities/test/TestInternalUtilities.props
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<Project> | ||
<ItemGroup> | ||
<Compile Include="$(RepoRoot)/dotnet/src/InternalUtilities/test/**/*.cs" Link="%(RecursiveDir)%(Filename)%(Extension)" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.