Xeku.Scripts
0.0.0.7
dotnet add package Xeku.Scripts --version 0.0.0.7
NuGet\Install-Package Xeku.Scripts -Version 0.0.0.7
<PackageReference Include="Xeku.Scripts" Version="0.0.0.7" />
<PackageVersion Include="Xeku.Scripts" Version="0.0.0.7" />
<PackageReference Include="Xeku.Scripts" />
paket add Xeku.Scripts --version 0.0.0.7
#r "nuget: Xeku.Scripts, 0.0.0.7"
#:package Xeku.Scripts@0.0.0.7
#addin nuget:?package=Xeku.Scripts&version=0.0.0.7
#tool nuget:?package=Xeku.Scripts&version=0.0.0.7
Xeku.Scripts
An XAF module for dynamic C# script compilation and execution using Roslyn.
Features
- Script Types: Support for
Action,Function,Validator, andTransformerpatterns. - Dynamic Compilation: Compile C# code at runtime using Roslyn.
- IScriptService: Programmatic API for executing scripts from other modules or code.
- Asynchronous Support: Full support for
async/awaitin script logic. - Monaco Editor Integration: Professional code editor with syntax highlighting.
- ScriptContext API: Simplified interface for scripts to interact with XAF.
- Execution Logging: Track script execution history with JSON serialization for complex return values.
- Assembly Caching: Optimized performance through compiled assembly caching.
Installation
dotnet add package Xeku.Scripts
Dependencies
Xeku.Core- Core module with common servicesXeku.Editors- Monaco editor support
Usage
Script Types
| Type | Signature | Description |
|---|---|---|
| Action | void Run(ScriptContext ctx) |
Performs operations without returning a value. |
| Function | object Run(ScriptContext ctx) |
Computes and returns a value. Supports async Task<object>. |
| Validator | bool Validate(ScriptContext ctx, object target) |
Returns true if validation passes for a target object. |
| Transformer | object Transform(ScriptContext ctx, object input) |
Converts an input object into an output object. |
Basic Script Structure
public class ScriptMain
{
// Example Action Script
public void Run(ScriptContext ctx)
{
ctx.ShowMessage("Hello from Script!");
}
}
IScriptService
Register the service in your startup:
services.AddScripts();
Usage in your code:
public class MyService {
private readonly IScriptService _scriptService;
public async Task Process() {
var result = await _scriptService.ExecuteAsync("MyScript");
if (result.IsSuccess) {
// Handle success
}
}
}
ScriptContext API
| Method | Description |
|---|---|
CreateObject<T>() |
Create a new business object |
Query<T>() |
Query objects using LINQ |
GetObjectByKey<T>(key) |
Retrieve an object by its primary key |
CommitChanges() |
Save pending changes |
ShowMessage(msg) |
Queue an info message |
ShowWarning(msg) |
Queue a warning message |
ShowError(msg) |
Queue an error message |
Log(msg) |
Write to trace output |
Integration
- Add module reference in your Module.cs:
RequiredModuleTypes.Add(typeof(Xeku.Scripts.ScriptsModule));
- Register services in
Startup.cs:
public void ConfigureServices(IServiceCollection services) {
// ...
services.AddScripts();
}
AI Code Generation 🤖
This module supports automatic script code generation using Large Language Models (LLMs).
Supported LLM Providers
| Provider | Environment Variable | Description |
|---|---|---|
| OpenAI | OPENAI_API_KEY |
GPT-4, GPT-3.5, etc. |
| Google Gemini | GEMINI_API_KEY |
Gemini 1.5 Pro, Flash |
| Azure OpenAI | AZURE_OPENAI_API_KEY, AZURE_OPENAI_ENDPOINT |
Enterprise deployment |
| Ollama | OLLAMA_BASE_URL |
Local models (free) |
Configuration
# Set LLM provider (openai, gemini, azureopenai, ollama)
setx LLM_PROVIDER "gemini"
# Set API key based on provider
setx GEMINI_API_KEY "your-api-key"
Business Object Auto-Discovery
The AI generation feature automatically scans all Business Objects in your project, allowing AI to understand available classes and properties. Users simply describe their requirements in natural language, for example:
Query all orders created today, calculate total amount and display
AI will automatically generate correct code based on your project's Order class and its properties.
Business Objects
| Class | Description |
|---|---|
Script |
Stores script metadata, code, and compiled assembly |
ScriptExecutionLog |
Records execution history (read-only in UI) |
Actions
| Action | Description |
|---|---|
| Compile | Compile the script code |
| Run | Execute the script |
| Run with Context | Execute with ScriptContext parameter |
| Clear Logs | Delete all execution logs for the script |
| Generate with AI | Auto-generate script code using AI |
Architecture
graph TD
subgraph Runtime
Script[Script Business Object]
Roslyn[Roslyn Compiler]
Cache[Assembly Cache]
end
subgraph Execution
Controller[ScriptController]
Context[ScriptContext]
Log[ExecutionLog]
end
Script --> Roslyn
Roslyn --> Cache
Controller --> Script
Controller --> Context
Controller --> Log
License
Proprietary - Xeku Solutions
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- DevExpress.ExpressApp (>= 25.2.3)
- DevExpress.ExpressApp.Xpo (>= 25.2.3)
- DevExpress.Persistent.Base (>= 25.2.3)
- DevExpress.Persistent.BaseImpl.Xpo (>= 25.2.3)
- Microsoft.CodeAnalysis.CSharp (>= 4.12.0)
- Xeku.AI (>= 0.0.0.7)
- Xeku.Core (>= 0.0.0.7)
- Xeku.Editors (>= 0.0.0.7)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Xeku.Scripts:
| Package | Downloads |
|---|---|
|
Xeku.Triggers
XAF module providing trigger rules and webhook execution for CRUD operations. |
|
|
Xeku.Scripts.Blazor
Xeku Scripts Blazor module for DevExpress XAF Blazor applications. Enables Monaco editor support for script editing. |
|
|
Xeku.Scripts.WebApi
Xeku Scripts WebApi module for remote script execution via OData/REST API. |
GitHub repositories
This package is not used by any popular GitHub repositories.