-
Notifications
You must be signed in to change notification settings - Fork 8
Adding custom functions
NeilMacMullen edited this page Mar 3, 2024
·
3 revisions
See the CustomFunctions sample
Create a partial function annotated with KustoImplementation
// ReSharper disable PartialTypeWithSinglePart
[KustoImplementation(Keyword = "fizz")]
public partial class FizzFunction
{
}
Add a dependency to SourceGeneration
<ProjectReference Include="..\SourceGeneration\SourceGeneration.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
Add a nuget ref to Kusto Language
Add one or more "Impl" methods inside the Function class
public static string Impl(long n)
{
var fizz = n % 3 == 0 ? "fizz" : string.Empty;
var buzz = n % 5 == 0 ? "buzz" : string.Empty;
return fizz + buzz;
}
IMPORTANT method names must end "Impl". If more than overide is provided, a unique prefix for each method-name is required.
Null-checking for parameters is not required; the default behaviour for the source generator is to automatically return null/string.Empty if any parameter is null.