C# Analysis Service SDK
The DxWorks.ScriptBee.Analysis.Sdk NuGet package is the C# implementation of the Analysis Service SDK. It lets you build a fully-featured Analysis Service in .NET without writing any HTTP boilerplate.
Installation
dotnet add package DxWorks.ScriptBee.Analysis.SdkOr directly in your .csproj:
<PackageReference Include="DxWorks.ScriptBee.Analysis.Sdk" Version="1.0.0" />What the SDK provides
| Layer | What's included |
|---|---|
| Endpoints | All REST routes pre-wired with correct HTTP verbs, paths, and status codes |
| Contracts | Web* request/response records matching the public REST API |
| Validators | FluentValidation rules for all request models |
| Abstractions | Use-case interfaces your service must implement |
| Utilities | FileBundler for packaging file streams for loader plugins |
| Registration | AddAnalysisEndpoints() extension to mount everything in one call |
Implementing the use cases
Implement each interface from the DxWorks.ScriptBee.Analysis.Sdk namespace. The SDK resolves them from the DI container at runtime.
| Interface | Responsibility |
|---|---|
IRunAnalysisUseCase | Execute a script against the loaded context |
IGetContextUseCase | Return current context slices |
IGetContextGraphUseCase | Return context as a graph (nodes + edges) |
ILoadContextUseCase | Load files into context via a loader plugin |
ILinkContextUseCase | Link loaded context via a linker plugin |
IClearContextUseCase | Clear all loaded context |
IGenerateClassesUseCase | Stream generated model class files |
IGetInstalledPluginsUseCase | List installed plugins |
IInstallPluginUseCase | Install a plugin by id |
IUninstallPluginUseCase | Uninstall a plugin by id |
Supporting SDK interfaces
The SDK also exposes a small set of helper interfaces for context, scripts, model files, and results. These are injected into the service layer and provide the low-level persistence and retrieval operations that the higher-level use cases rely on.
IModelFileLoader
public interface IModelFileLoader
{
Task<Stream> LoadModelFileStreamAsync(FileId fileId, CancellationToken cancellationToken);
}Loads a model file stream identified by a FileId so the service can read or process the raw model file.
IScriptLoader
public interface IScriptLoader
{
Task<OneOf<Script, ScriptDoesNotExistsError>> Get(
ScriptId scriptId,
CancellationToken cancellationToken
);
Task<OneOf<string, ScriptDoesNotExistsError>> GetScriptContent(
ProjectId projectId,
string path,
CancellationToken cancellationToken
);
}Retrieves a script definition by ScriptId, and optionally resolves the script source text from a project path.
IAnalysisState
public interface IAnalysisState
{
Task<AnalysisInfo> CreateAsync(AnalysisInfo analysisInfo, CancellationToken cancellationToken);
Task UpdateAsync(AnalysisInfo analysisInfo, CancellationToken cancellationToken);
}Creates or updates persisted analysis metadata so the service can track the current analysis state.
IScriptResultsStore
The current interface name is IScriptResultsStore. Older release notes and documentation may refer to this as IScriptResults.
public interface IScriptResultsStore
{
Task UploadFileAsync<TMetadata>(
FileId fileId,
Stream fileStream,
TMetadata? metadata = null,
CancellationToken cancellationToken = default
)
where TMetadata : class;
}Uploads a script result file and optional metadata for persistence under the provided FileId.
Example
public sealed class Neo4jRunAnalysisService : IRunAnalysisUseCase
{
private readonly INeo4jSession _session;
public Neo4jRunAnalysisService(INeo4jSession session)
{
_session = session;
}
public async Task<WebRunAnalysisResponse> RunAsync(
WebRunAnalysisCommand command,
CancellationToken cancellationToken)
{
// store results in Neo4j, return response
return new WebRunAnalysisResponse(...);
}
}Registration
In your Program.cs, register each implementation and call the SDK extension method:
builder.Services.AddScoped<IRunAnalysisUseCase, Neo4jRunAnalysisService>();
builder.Services.AddScoped<IGetContextUseCase, Neo4jGetContextService>();
// ... all other use cases
var app = builder.Build();
app.AddAnalysisEndpoints();
app.Run();AddAnalysisEndpoints() registers all FluentValidation validators and maps every endpoint to IEndpointRouteBuilder automatically.
Versioning & Changelog
The SDK follows Semantic Versioning. Releases are tagged analysis-sdk@<version> in the monorepo and published automatically to NuGet.
See CHANGELOG.md for the full release history.