> ## Documentation Index
> Fetch the complete documentation index at: https://docs.neuro-tech.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Extend the Script engine

> Publish a typed C# function from a Neuron package

Create a Script function when multiple pages, reports, or jobs need the same tested domain operation. The runtime discovers public function classes from loaded assemblies.

## Minimal scalar function

```csharp theme={null}
using Waher.Script;
using Waher.Script.Abstraction.Elements;
using Waher.Script.Functions;
using Waher.Script.Model;
using Waher.Script.Objects;

public sealed class CelsiusToKelvin : FunctionOneScalarVariable
{
    public CelsiusToKelvin(ScriptNode argument, int start, int length,
        Expression expression)
        : base(argument, start, length, expression)
    {
    }

    public override string FunctionName => nameof(CelsiusToKelvin);

    public override IElement EvaluateScalar(IElement argument,
        Variables variables)
    {
        double celsius = Expression.ToDouble(argument.AssociatedObjectValue);
        return new DoubleNumber(celsius + 273.15);
    }
}
```

Select the appropriate base class for zero, one, two, or multiple arguments and for scalar versus vector-aware evaluation. Use an asynchronous base/interface when the operation performs I/O.

## Design rules

* Validate types and ranges at the boundary.
* Keep `FunctionName` stable; changing it breaks scripts.
* Declare aliases only for intentional compatibility.
* Provide `DefaultArgumentNames` so generated help is meaningful.
* Return Script `IElement` values or supported .NET objects consistently.
* Honour cancellation and timeouts for I/O.
* Avoid hidden global state.
* Log externally visible side effects.
* Never expose secrets through exceptions or object properties.

## Inventory discovery

The runtime inventory finds the class when its assembly package loads. If the function does not appear:

1. confirm the assembly is in the package manifest;
2. check that its target framework matches the Neuron;
3. inspect module/inventory startup events;
4. verify the class is public and concrete;
5. ensure all referenced assemblies are installed.

## Test from C# and Script

Unit-test scalar conversion and invalid input directly. Then install the package in a test Neuron and evaluate:

```text theme={null}
CelsiusToKelvin(0)
```

Expected result:

```text theme={null}
273.15
```

Document the function in the package's Mintlify section and include at least one copyable example and failure case.
