forked from microsoft/semantic-kernel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
94 lines (74 loc) · 3.73 KB
/
Program.cs
File metadata and controls
94 lines (74 loc) · 3.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// Copyright (c) Microsoft. All rights reserved.
using System.Diagnostics.CodeAnalysis;
using SemanticKernel.AotTests.UnitTests.Core.Functions;
using SemanticKernel.AotTests.UnitTests.Core.Plugins;
using SemanticKernel.AotTests.UnitTests.Search;
namespace SemanticKernel.AotTests;
/// <summary>
/// This application is created in accordance with the instructions in the blog post at https://devblogs.microsoft.com/dotnet/creating-aot-compatible-libraries to ensure that
/// all Native-AOT-related warnings missed by the Roslyn analyzers are caught by the AOT compiler used in this application.
/// </summary>
internal sealed class Program
{
private static async Task<int> Main(string[] args)
{
bool success = await RunUnitTestsAsync(s_unitTests);
return success ? 1 : 0;
}
[UnconditionalSuppressMessage("AOT", "IL3050:Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.", Justification = "Test application intentionally tests dynamic code paths. VectorStoreTextSearch LINQ filtering requires reflection for dynamic expression building from runtime filter specifications.")]
private static readonly Func<Task>[] s_unitTests =
[
// Tests for functions
KernelFunctionFromMethodTests.CreateUsingOverloadWithFunctionDetails,
KernelFunctionFromMethodTests.CreateUsingOverloadWithOptions,
KernelFunctionFromMethodTests.CreateMetadataUsingOverloadWithFunctionDetails,
KernelFunctionFromMethodTests.CreateMetadataUsingOverloadWithOptions,
KernelFunctionFactoryTests.CreateFromLambda,
KernelFunctionFactoryTests.CreateFromMethod,
KernelFunctionFactoryTests.CreateFromStringPrompt,
KernelFunctionFactoryTests.CreateFromPromptTemplate,
KernelExtensions_KernelFunctionTests.CreateFromLambda,
KernelExtensions_KernelFunctionTests.CreateFromMethod,
KernelExtensions_KernelFunctionTests.CreateFromStringPrompt,
KernelExtensions_KernelFunctionTests.CreateFromPromptTemplate,
KernelExtensions_InvokePromptTests.InvokePrompt,
KernelExtensions_InvokePromptTests.InvokePromptStreaming,
KernelFunctionMetadataFactoryTests.CreateFromType,
// Tests for plugins
KernelPluginFactoryTests.CreateFromGenericParameterType,
KernelPluginFactoryTests.CreateFromObject,
KernelExtensions_KernelPluginTests.CreateFromType,
KernelExtensions_KernelPluginTests.CreateFromObject,
KernelExtensions_KernelPluginTests.ImportFromType,
KernelExtensions_KernelPluginTests.ImportFromObject,
KernelPluginExtensionsTests.AddFromType,
KernelPluginExtensionsTests.AddFromObject,
KernelBuilderPluginsExtensionsTests.AddFromType,
KernelBuilderPluginsExtensionsTests.AddFromObject,
// Tests for text search
VectorStoreTextSearchTests.GetTextSearchResultsAsync,
VectorStoreTextSearchTests.AddVectorStoreTextSearch,
TextSearchExtensionsTests.CreateWithSearch,
TextSearchExtensionsTests.CreateWithGetTextSearchResults,
TextSearchExtensionsTests.CreateWithGetSearchResults,
];
private static async Task<bool> RunUnitTestsAsync(IEnumerable<Func<Task>> functionsToRun)
{
bool failed = false;
foreach (var function in functionsToRun)
{
Console.Write($"Running - {function.Method.DeclaringType?.Name}.{function.Method.Name}");
try
{
await function.Invoke();
Console.WriteLine(" - Success");
}
catch (Exception ex)
{
failed = true;
Console.WriteLine($" - Fail: {ex.Message}");
}
}
return failed;
}
}