Skip to content

C# Components

The C# helpers that Siphonophore.Stolon compiles into every plugin. These pages cover what each type is for, when to use it, how to wire it, and what can surprise you. The XML docs in the source are the reference for members and signatures, so your editor shows them as you type.

What the Package Is

Stolon is a NuGet package of shared helpers for the Jellyfin plugins in this family. Every type lives in one namespace, Siphonophore.Stolon.

The package has no runtime assembly. It holds these files, and its targets file wires them into the plugin.

Path in the package What it holds What the plugin build does with it
src/*.cs The C# helpers Compiles them into the plugin DLL
assets/stolon.css and assets/stolon.js The bundled web components Embeds them as <RootNamespace>.Configuration.stolon.css and .js
assets/stolon.d.ts The typings of the JavaScript Copies them to the plugin's obj/ folder for the editor and never embeds them
templates/*.html The HTML templates, such as status.html Embeds each as <RootNamespace>.Templates.<name>.html
build/Siphonophore.Stolon.targets and build/Siphonophore.Stolon.Translations.targets The build wiring Runs in every build of the plugin
tasks/net10.0/Siphonophore.Stolon.Tasks.dll The translations task Runs inside MSBuild to check and build the translations, and never reaches the plugin
jellyfin/ Jellyfin's strings, one file per language for the web client and the server, with their source and license Takes the declared Jellyfin strings from it, and checks the local strings against it
LICENSE The GNU General Public License v3.0 Nothing
README.md The package readme Nothing

Add one reference and nothing else ships. See Using Stolon for the steps.

  • All public types are compiled into the plugin, used or not.
  • The package declares no dependencies of its own. The plugin must reference Jellyfin.Controller and Jellyfin.Model, which bring the MediaBrowser.*, ASP.NET Core, and Data Protection types the sources compile against. Without them the build fails in the Stolon sources.
  • The sources are compiled with the plugin's own analyzer settings, so a warning in a source file fails the plugin's build.
  • ActivityLogger.Current, PluginBase.Instance, the TemplateLoader cache, and the StableSecretProtection provider cache are static state inside the plugin's own copy of the code. Two plugins never share them.
  • The package version is the Jellyfin version Stolon targets, then a release count, such as 12.4.0. See Releasing.

In these pages, "plugin" means the consuming Jellyfin plugin, "task" means a Jellyfin scheduled task, and "entry" means one row of Jellyfin's activity log. The page and anchor for each type are listed below. For the web half of Stolon, see Web Components.

Types

Type What it is for Page
ActivityLogger Writes entries to Jellyfin's activity log without ever throwing. Activity Log
ActivityOutcome Defines one kind of summary entry. Activity Log
ActivitySummary Sums events into one activity entry per outcome. Activity Log
ActivityTally Holds the counts an outcome's overview is built from. Activity Log
ActivityText Shared wording for counts, plurals, lists, and sentences. Activity Log
AtomicFile Replaces a file through a temp file so a reader never sees half of it. Files and Paths
BackoffPolicy A stateless exponential pause for a repeatedly failing record. HTTP and Resilience
BackoffState The failure count and pause deadline a caller stores per record. HTTP and Resilience
StolonHttp Outbound HTTP that returns a status and body and does not throw. HTTP and Resilience
StolonNotifier Sends one message to Discord, a webhook, Jellyfin, and web push, and previews each. Notifications
StolonPageScript The web push and casing helpers for a page that loads no bundle. Pages and Templates
StolonRetryHandler A handler that retries a read for a gateway error or a slow answer. HTTP and Resilience
StolonRetryOptions The attempts, waits, and timeout of a retry handler. HTTP and Resilience
StolonTranslations The plugin's strings in a language, with fallback, formatting, the endpoint answer, and the language of a request. Translations
ByteSize Binary byte counts as long constants. Streams and Throttling
CappedReadStream A read through stream that throws past a limit. Streams and Throttling
CircuitBreaker Stops calls to a named service after repeated failures, for a cooldown. HTTP and Resilience
ConcurrentTaskRunner Runs a worker over items with bounded parallelism and progress. Plugin and Tasks
DatabaseSchema Versions a SQLite database with a minimum reader and a backup. Data and Storage
FaviconResolver Finds the web client's favicon on disk. Pages and Templates
FileNameSanitizer Makes a string a safe cross-platform file name. Files and Paths
FormatUtilities Formats byte counts and makes text safe for a log. Text and Formatting
HashUtilities Short SHA-256 fingerprints and the full SHA-256 hex of a string. Text and Formatting
HostedPage Serves a user page at a root path of the server, for anyone, signed in users, or administrators. Pages and Templates
HostedPageAccess Who may open a hosted page. Pages and Templates
HostedPageContent What a hosted page serves, a template or an embedded fragment. Pages and Templates
HttpResult The status and body that StolonHttp returns. HTTP and Resilience
HttpRetry Names the statuses worth asking again and reads Retry-After. HTTP and Resilience
INotifyHeldStore The plugin's store for Jellyfin messages that wait for a device. Notifications
ItemTitles Names a library item as Jellyfin does. Text and Formatting
IWebPushStore The plugin's store for the VAPID keys and web push subscriptions. Notifications
JsonFileStore A thread-safe atomic JSON file for one value. Data and Storage
NotifyChannel The kind of place a destination is. Notifications
NotifyDestination One place messages go, with its secrets encrypted at rest. Notifications
NotifyField One name and value a message carries. Notifications
NotifyHeldMessage A Jellyfin message held until a device is online. Notifications
NotifyHeldWatcher Shows held messages once a device comes online. Notifications
NotifyMessage One update, written once for every channel. Notifications
NotifyPreview What a destination would get, without sending. Notifications
NotifyResult What sending to one destination did. Notifications
NotifyTemplate Placeholders, custom bodies, headers, and escaping for notifications. Notifications
PagedQuery The skip, take, search, and filter a list endpoint receives. Data and Storage
PagedResult One page of results with the count and page metadata. Data and Storage
PagedResultExtensions ToPagedResult for an already filtered collection. Data and Storage
PathContainment Whether a folder is, or is inside, one of some folders. Files and Paths
PluginBase The plugin base class with locked configuration and shared pages. Plugin and Tasks
PluginScheduledTask A scheduled task base with defaults and trigger helpers. Plugin and Tasks
ProgressReportingStream A write through stream that reports a download's progress in whole percent steps. Streams and Throttling
PublicPage Hardening headers and the favicon for standalone pages. Pages and Templates
RateUtilities Converts Mbps and older units to bytes per second. Streams and Throttling
RedirectRefusingHandler A handler that refuses a redirect and names the address it pointed to. HTTP and Resilience
RetryPolicy Exponential backoff retry for transient exceptions. HTTP and Resilience
SchemaAction What opening a database did or what the caller must do next. Data and Storage
SecretCompare Constant time secret comparison and random tokens. Security and Secrets
SecretProtector Encrypts plugin secrets at rest with Data Protection. Security and Secrets
ServiceCollectionExtensions DI registration for the activity logger, the secret protector, and the notifier. Plugin and Tasks
SpeedBucket A bytes per second rate that several streams share. Streams and Throttling
SsrfGuard Refuses private, loopback, link local, and other unsafe targets. HTTP and Resilience
StableSecretProtection Builds the provider and protector with launch-independent keys. Security and Secrets
StatusPage Renders the themed standalone status card. Pages and Templates
StreamLimits Reads a stream into memory with a size limit. Streams and Throttling
StreamUtilities Copies a stream, alone or under a shared speed limit. Streams and Throttling
StringNormalizationUtility Puts a list of strings in a canonical form. Text and Formatting
StringUtilities Escapes text for a JavaScript string literal. Text and Formatting
TaskTriggers Builds default trigger entries for a scheduled task. Plugin and Tasks
TemplateLoader Loads and fills embedded HTML templates. Pages and Templates
TextCase Title case and sentence case for English text, keeping the casing list's words. Translations
ThrottledReadStream A read through stream held to the rate of a SpeedBucket. Streams and Throttling
UrlUtilities Reads text as an absolute http or https URL. Security and Secrets
UtcTime Formats and parses stored times as UTC. Text and Formatting
WebPushEncryption Encrypts a web push as RFC 8291 sets out. Notifications
WebPushKeys The VAPID key pair that signs every web push. Notifications
WebPushSubscription One browser signed up for a user's web push. Notifications
WebPushWorker The service worker script that shows a web push. Notifications

Pages

Page Covers
Plugin and Tasks The plugin base, scheduled tasks, bounded parallel work, and DI registration.
HTTP and Resilience Outbound HTTP, the SSRF guard, retries, the circuit breaker, and backoff.
Security and Secrets Secrets at rest, constant time comparison, and URL checks.
Files and Paths File names, atomic writes, and folder containment.
Streams and Throttling Speed limits, shared rates, and size caps.
Text and Formatting Log and JavaScript escaping, titles, string lists, and hashes.
Data and Storage SQLite versioning, JSON state files, and paged results.
Pages and Templates Standalone status pages, templates, favicons, and the standalone page script.
Activity Log Single and summed entries in Jellyfin's activity log.
Translations The plugin's strings in each language, for C# text and for its pages.
Notifications Discord, webhooks, Jellyfin messages, and web push from one message.

Wiring Checklist

  1. Reference the package, and reference Jellyfin.Controller and Jellyfin.Model too.
  2. Derive the plugin class from PluginBase, and yield GetSharedPages("<prefix>") from GetPages.
  3. Choose one stable plugin name for secrets, use the assembly name, and never change it.
  4. In the service registrator, call AddPluginSecretProtector(name) and AddActivityLogger() as needed. See ServiceCollectionExtensions.
  5. Derive tasks from PluginScheduledTask.
  6. Own the dispose of any ActivitySummary you create, so waiting events are written on shutdown.
  7. For standalone pages, serve StatusPage.Render output with PublicPage.ApplyHardeningHeaders and a sibling favicon.ico route. For a user page, declare a HostedPage and serve it from a controller action.
  8. For translations, add Localization/en-us.json and the JellyfinString items, and an endpoint that returns StolonTranslations.Serve. See Translations.
  9. For notifications, call AddBaseNotifier() and register the plugin's stores. See Notifications.