NetworkInspector.BaseApp.Core 0.23.0

dotnet add package NetworkInspector.BaseApp.Core --version 0.23.0
                    
NuGet\Install-Package NetworkInspector.BaseApp.Core -Version 0.23.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NetworkInspector.BaseApp.Core" Version="0.23.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NetworkInspector.BaseApp.Core" Version="0.23.0" />
                    
Directory.Packages.props
<PackageReference Include="NetworkInspector.BaseApp.Core" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add NetworkInspector.BaseApp.Core --version 0.23.0
                    
#r "nuget: NetworkInspector.BaseApp.Core, 0.23.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package NetworkInspector.BaseApp.Core@0.23.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=NetworkInspector.BaseApp.Core&version=0.23.0
                    
Install as a Cake Addin
#tool nuget:?package=NetworkInspector.BaseApp.Core&version=0.23.0
                    
Install as a Cake Tool

NetworkInspector.BaseApp.Core

The UI-free core of a base application: who the application is, its settings folder and limits, a message list that takes any input rate, a log file per process start, typed texts in several languages, typed commands with one pipeline that contains plugin faults, a command journal with replay, background jobs, status fields, a license gate, generic plugins, profiles, shared UI state, and row sources. The core references no web or desktop framework: a tool without a UI and the tests use it directly, and the web host of NetworkInspector.BaseApp composes it.

What you get

Type What it is
ApplicationIdentity Technical name, display name, settings folder name, and semantic version; checked at start
CoreOptions, RunOverride, StartMode The options of one run, including the --set key=value values that are never saved
CoreBuilder, CoreStartResult Collects what the application declares and composes the core once
CoreComposition The composed core: identity, settings folder, messages, log file, texts; disposed once at exit
MessageHub, MessageView, MessageEntry, MessageCounts The message list: equal messages counted on one entry, a ring of messages.entries entries, O(1) views and counts
LogFile One file per process start, a writer task behind a bounded queue, rotation at log.fileSize, at most log.files files
TextSet, TextRegistry, LocalText Typed texts: English members of a class, translations that override them
BaseAppLimits The 38 limits of a base application and the hit sentence of every base limit
CommandDefinition<TParameters, TResult>, CommandRegistry, CommandCatalog Typed commands, registered once and frozen at start; one catalog with JSON schemas
ICommandRunner, CommandResult<T>, CommandError, CommandLog One pipeline for every origin, stable error codes, a ring of the recent submissions
BaseJson The strict JSON options of commands: unknown, duplicate, or missing members are refused
MessageCommands, JobCommands, CatalogCommands, JournalCommands, AppCommands, TextCommands The base command families, registered at start with owner Base
CommandJournal, ReplayResult The journal of successful changing commands and its replay through the pipeline
StatusRegistry, StatusField The named values of app.status; plugin fields are read bounded
ClosingWorkRegistry, ShutdownProgress Closing work that runs first on every exit, bounded by app.closingWait; the step the shutdown is in

Quickstart

Prerequisites: .NET 10 or later.

using NetworkInspector.BaseApp.Core;
using NetworkInspector.BaseApp.Core.Commands;

// settingsPath: the folder of this run (null: the default location of the identity).
ApplicationIdentity identity = new("Sample.App", "Sample Application", "SampleApp", "1.0.0");
CoreBuilder builder = new(new CoreOptions(identity, StartMode.NoUi, settingsPath, Profile: null, RunOverrides: [],
    AcceptLicensesHash: null));
CommandDefinition<GreetParameters, GreetResult> greet = new("sample.greet", "Greets someone.", CommandKind.Read,
    reachableBeforeAcceptance: true);
builder.Commands.Add(greet, static (parameters, _) =>
    ValueTask.FromResult(CommandResult.Ok(new GreetResult($"Hello, {parameters.Name}"))), "Sample Application");

CoreStartResult start = await builder.BuildAsync(CancellationToken.None);
if (start.Composition is null)
{
    Console.Error.WriteLine(start.Problem);
    return start.ExitCode;   // 1: invalid identity or settings folder; 2: a refused --set value
}

await using CoreComposition core = start.Composition;
CommandResult<GreetResult> answer = await core.Commands.RunAsync(greet, new GreetParameters("Ada"), CommandOrigin.Cli, new(),
    CancellationToken.None);
Console.WriteLine(answer.IsOk ? answer.Value!.Text : answer.Error.Message);   // Hello, Ada
return 0;

public sealed record GreetParameters(string Name);
public sealed record GreetResult(string Text);

The application's license inventory is embedded at build by NetworkInspector.Licensing.Build; a command not marked reachableBeforeAcceptance answers LicenseNotAccepted until the person accepted the licenses.

Handlers of the application reach the jobs, the messages, and the settings of the run through the composition: subscribe builder.Composed (raised once after the composition, before any plugin starts) and keep it, as Sample.Application's SampleDemo does. CoreComposition.Paging pages a list of the application with the same bounds and cursors as the base lists (TryPage by version and position, TryPageByKey by a decreasing key).

builder.Time (default TimeProvider.System; null is refused) is the clock of the messages, the jobs, and the command log, so a test can fix it. BaseJson.Options writes every time as UTC in ISO 8601 with Z (2026-11-16T13:05:09Z) and reads any ISO offset form.

The identity's version must be a semantic version (1.4.0, 2.0.0-rc.1): plugins compare it with the host version they require. FromEntryAssembly takes the informational version of the entry assembly without its +build suffix.

Messages and the log file

Every part reports through IMessageSink.Emit(type, source, text, exception); a message of one instance goes through Emit(type, source, text, instance, exception = null) with the instance as kind:instance (counter:1; another form throws ArgumentException), so an instance that fails names both: its entry shows the badge, its details the exception. Equal messages (type, source, instance, text, exception type and message) are counted on one entry, so the same text of two instances is two entries; a repeat allocates nothing and reaches the UI and the log file only at counts 1, 2, 4, 8, …. There is no rate limit: the list is a ring of messages.entries entries in arrival order, a full ring replaces its oldest entry, and MessageCounts.Removed counts what it replaced, so every message is kept, counted as removed, or deleted by a person. Texts above messages.textSize are shortened in the list with … (shortened); the log file keeps them whole.

An entry with an exception keeps ExceptionText (type and message per level) and, only while the setting messages.stackTraces is on, StackTrace: the frames the exception text does not repeat, shortened by the same messages.textSize rule and mark, null when no level was thrown. The setting is off by default, because frames name files, folders, and user names, and the entry reaches the Messages page, Copy, and agents; the hub reads it once per new entry, so an entry keeps what it got at its arrival, and equal messages still count on one entry across a switch. The log file keeps the whole stack trace either way. A delete remembers the message, so the next equal message starts an entry with Returned set (agents read returned and stackTrace in messages.list); a clear remembers nothing. The memory holds the newest deletions up to messages.entries (off keeps all), so an agent that deletes and emits in a loop cannot grow it; a repeat never touches it.

messages.list narrows by types, source, instance, and text with its match mode (the rule: § Base commands). The type, source, and instance checks read each row in place; only a row that passes them is read whole for the text, so a narrowing that matches rarely scans the ring without allocating per row.

MessageView.TryReadFields(row, out MessageRowFields fields) reads what a filter needs of one row (id, type, source, text, instance, exception text) without building its MessageEntry: the struct refers to the strings the hub already holds, so a scan of every row allocates nothing. It returns false past the end, for a negative row, and at a row the ring overwrote since the view was taken (where Read stops too); the count and the arrival times are not part of it. The narrowed Messages page scans with it.

MessageView view = core.Messages.View();            // O(1); rows newest first
MessageEntry[] page = new MessageEntry[50];
int read = view.Read(0, page);                       // reads only the rows of the page
MessageCounts counts = core.Messages.Counts;         // O(1): per type, unseen, removed
for (long row = 0; view.TryReadFields(row, out MessageRowFields fields); row++)
{
    // fields.Text, fields.Source, fields.ExceptionText: no allocation per row
}

The log file is <settings folder>/logs/<settings folder name>-<UTC yyyyMMdd-HHmmss>-<process id>.log, one line per new message and per power-of-two repeat, with control characters escaped. A file continues in ….1.log, ….2.log at log.fileSize; at most log.files files of the application stay in the folder across starts, the oldest files of ended processes first, never a file of another running instance. log.fileEnabled switches it off. The reasons: log-file-per-process.

Texts

An application declares its texts as the public virtual members of a class; a translation derives from it and overrides what it translates. The compiler checks every use and every override.

public class SampleTexts : TextSet
{
    public virtual string CounterTitle => "Counter";
    public virtual string CounterValue(long value) => Invariant($"Counter {value}");
}

public sealed class SampleTextsGerman : SampleTexts
{
    public override string CounterTitle => "Zähler";
    // CounterValue not translated: shows the English text; Untranslated("de") lists it
}

builder.Texts.Add(new SampleTexts(), "Sample Application");
builder.Texts.AddTranslation<SampleTexts>("de", new SampleTextsGerman(), "Sample Application");
string title = core.Texts.Get<SampleTexts>("de").CounterTitle;   // "Zähler"

English (en) and German (de) are added; AddLanguage adds more. A second set or translation of the same type and language is ignored with one Error naming both owners. The reasons: typed-texts.

Commands

A command is a typed declaration plus a handler. The UI, the command line, agents, and plugins all run it through one pipeline, so every origin gets the same checks, the same error codes, and one log entry.

public sealed record CounterAddParameters(int Amount);
public sealed record CounterValue(long Value);

static readonly CommandDefinition<CounterAddParameters, CounterValue> Add =
    new("sample.counter.add", "Adds an amount to the counter.", CommandKind.Change);

builder.Commands.Add(Add, (parameters, context) =>
    ValueTask.FromResult(CommandResult.Ok(new CounterValue(counter += parameters.Amount))), "Sample Application");

// runner: the application's ICommandRunner. Any origin, typed or as JSON from an agent: {"amount":2}
CommandResult<CounterValue> result = await runner.RunAsync(Add, new CounterAddParameters(2), CommandOrigin.Ui,
    new CommandCallOptions(), cancellationToken);

BuildAsync freezes the registry. A start fails with exit 1 if a destructive command offers no dry run, a target kind is unknown, an example does not read strictly, a secret parameter is not a string, or the reset command of a target kind (§ Settings and profiles) does not exist or is not targeted at that kind. Checks run in this order, and the first failing check answers: name, origin, license gate, running application, commands.parametersSize, strict parameters, validator, target, confirm and dry run, disabled plugin. A Read command runs at once. Every other kind waits on a serial queue: the command's own queue, else its target instance (counter:1), else app. Two targets run in parallel. A command that submits to the queue it runs on is refused instead of waiting for itself.

Code When
UnknownCommand No command has the name
InvalidParameters A parameter, the target, confirm, or dryRun is wrong; Parameter names it; a value outside an enum lists the allowed values
InvalidState The state does not allow it: re-entrant submit, shutdown, tool mode for a running-application command
NotFound The target or a named object does not exist, or the target ended while the command waited
NotAllowed The origin is denied; the message names where to run it instead
LicenseNotAccepted The licenses of this start are not accepted yet
LimitExceeded A limit refused it; the message is the hit sentence with the setting key
Cancelled The caller cancelled it
Failed The handler threw, a plugin did not answer within plugins.callTimeout, or its plugin is disabled

A handler exception never reaches the answer: the caller gets <command> failed: see the Messages page, and the Messages page holds the exception. A plugin-owned handler or validator runs bounded by plugins.callTimeout; a plugin whose abandoned calls reach plugins.abandonedCalls is disabled for the run (plugin-in-process). A plugin-owned call that ends because its caller cancelled answers Cancelled (<command> was cancelled.), is logged cancelled, does not count toward the plugin's faults, and writes no Error message (the handler's cancel is caught before the plugin guard reports throws); one that the bound ended stays Failed. Parameters marked [CommandSecret] are written as *** in the command log.

The command log keeps each entry's parameters compact and cut at commands.logEntrySize: the kept part, …, and the hit sentence. CommandLogEntry.ParametersShortened (parametersShortened in commands.log) says the text was cut and ParametersBytes (parametersBytes) holds the compact size before the cut; a text of exactly the limit is kept whole. The command ran with its full parameters either way.

Base commands

BuildAsync registers these families before your commands are frozen; a command of yours with one of their names stops the start with exit 1. Each family class holds the typed definitions, so code submits them like its own commands.

Family Commands
MessageCommands messages.list (filter by types, source, instance, and text with match), messages.delete, messages.clear (dry run), messages.markSeen
JobCommands jobs.list (filter by instance, states, and text with match), jobs.read, jobs.cancel (answers at once; the job ends at its next check), jobs.remove, jobs.clearEnded (dry run); every job answer bounds status and failureReason by jobs.textLength (below)
CatalogCommands commands.search, commands.describe, commands.log (filter by origins, outcomes, target instance, and text with match)
JournalCommands journal.replay
AppCommands app.status: identity, mode, message counts, running jobs, status fields
TextCommands texts.languages, texts.coverage
LicenseCommands, PluginCommands license.read, license.text, license.accept, plugins.list
SettingsCommands settings.read, settings.set, settings.apply, settings.discard, settings.restoreDefault
ProfileCommands profiles.list, profiles.switch, profiles.create, profiles.rename, profiles.delete (dry run)
InstanceCommands instances.list, instances.rename, instances.setColor: the face of an instance (display name under InstanceName, palette color)
ActionCommands actions.list: the actions per subject kind with id, English label and tooltip, command, owner (ActionRegistry, § Actions)
UiCommands ui.state, ui.pages, ui.navigate, ui.theme.set, ui.language.set, ui.scale.set, ui.menuCollapsed.set, ui.details.resize
PopupCommands ui.popup.open, ui.popup.answer, ui.popup.cancel
DashboardCommands, WidgetCommands dashboard.read, .move, .resize, .reset (dry run), .restoreKept, .export, .import (dry run), .importUndo (Layout document); widget.create, .setState, .detach, .return, .close (dry run)

Every job answer (JobItem, built in one place for list, read, cancel, and remove) carries a status text and a failure reason of at most jobs.textLength characters (BaseAppLimits.JobsTextLength, default 2,000, 100 to 1,000,000, or off): a longer text is its first characters, never half of a surrogate pair, and statusShortened or failureReasonShortened holds the English mark shortened · 2 000 of 1 000 000 characters kept · jobs.textLength (null when the text is whole). The text of jobs.list matches only that answered part. The job itself keeps its text and is neither stopped nor slowed; the bound lives at the readers.

Text members that may carry foreign text (a message source, a job name, a logged parameter) are marked [UntrustedText]; every serialized object of such a type then carries "untrusted": [ … ] naming them, on every surface, so agents can tell data from instructions.

The seven long lists (messages.list, jobs.list, commands.log, plugins.list, license.read, instances.list, actions.list) answer one page: entries, cursor (null on the last page), and cut (the sentence naming agent.pageRows or agent.pageDataSize when a bound ended the page). They take pageSize and cursor (PageParameters, or the members of MessageListParameters, JobListParameters, CommandLogParameters, InstanceListParameters, and ActionListParameters; a cursor of instances.list or actions.list belongs to its kind, one of the first three to its narrowing). Cursors are sealed with a per-process key: a changed character, a cursor of another list or another narrowing, or one from before a change of a version-paged list is refused with InvalidParameters naming cursor. The message list and the command log are paged by id, so new entries never invalidate their cursors.

The three narrowed reads share one rule: every filter that is set must hold, a list filter (types, states, origins, outcomes) matches any of its values, an empty list or text narrows nothing, and text is matched ignoring case in the texts the list shows (messages: text, source, exception; jobs: name, kind, status, failure reason; commands: name, target, parameters, error code). match says how: contains (when omitted), startsWith, and endsWith compare the text as plain characters; pattern reads it as a regular expression matched in linear time (RegexOptions.NonBacktracking), which refuses backreferences, lookarounds, and atomic groups. TextMatcher (with TextMatchMode) holds the rule for the reads and the pages: a literal text holds at most 1,000 characters (TextMatcher.MaxTextLength, a display rule of the filter box), a pattern at most ui.filterPatternSize (default 1,024 characters, 16 to 65,536, or off). A longer text, an invalid pattern, or an unsupported construct answers InvalidParameters naming text with its sentence (for the limit its hit sentence); a match other than the four names answers InvalidParameters naming match. A cursor belongs to its mode as to its other filters.

Actions

CoreBuilder.Actions (ActionRegistry) holds the actions per subject kind: ActionDefinition (id, label, icon, tooltip, subject kind or none, command, parameters from the Subject, check answering ActionState) and the subject kinds (the base's message, job, command, plugin, widget, every target kind, and the kinds of the application and plugins). The application adds with AddAction and AddSubjectKind (owner: its display name); a plugin with the same members of BasePluginBuilder, published at its commit after its commands, all or nothing.

builder.Actions.AddAction(new ActionDefinition("sample.counter.reset", label, "refresh-cw", tooltip, "counter", "sample.counter.reset",
    static subject => JsonSerializer.Serialize(new CounterResetParameters(subject.Value), BaseJson.Options)));

BuildAsync freezes the registry after the commands and refuses the start (exit 1) for a kind declared twice or an id defined twice (both owners named), Subject kind {kind} is not declared., or a command that does not exist. actions.list reads the registry; the web package builds context menus from it. The full rules: NetworkInspector.BaseApp README § Actions.

Journal and replay

With commands.journalEnabled on (off by default: the journal holds what the person did), every changing command that ends ok is written as one JSON line, secrets masked, to <settings folder>/journal/journal-<UTC yyyyMMdd-HHmmss>-<process id>.jsonl:

{"time":"2026-11-17T10:00:00+00:00","origin":"ui","target":null,"name":"sample.counter.add","confirm":false,"parameters":{"amount":1}}

Reads and dry runs are not written; a replay writes the lines it ran (origin replay), never journal.replay itself, and runs only the lines it counted, so replaying the current journal ends. A command counts when the journal was on as it started, so the settings.apply that turns the journal on is not in it. A file continues in ….1.jsonl at commands.journalFileSize; this process keeps at most commands.journalFiles files. journal.replay with a fully qualified path runs the lines in order through every check of the pipeline with origin Replay and answers 2 of 2 commands replayed, or where it stopped: 1 of 3 commands replayed, stopped at line 2: …. A line longer than commands.journalLineSize stops the replay without being read whole. A replay started by an agent stops at a command that agents may not run, so a file cannot widen what its starter is allowed to do.

Licenses

The application embeds its license inventory (NetworkInspector.Licenses.json, written by NetworkInspector.Licensing.Build). The gate hashes it together with the admitted plugins; until the person accepts that hash, only the commands marked reachable before acceptance answer (license.read, license.text, license.accept, plugins.list, commands.search, commands.describe, app.status, texts.languages), and no plugin code runs.

CommandResult<LicenseReadResult> read =
    await core.Commands.RunAsync(LicenseCommands.Read, new NoParameters(), CommandOrigin.Ui, options, ct);
await core.Commands.RunAsync(LicenseCommands.Accept, new LicenseAcceptParameters(read.Value!.Hash), CommandOrigin.Ui,
    options, ct);
await core.StartPluginsWhenAcceptedAsync(ct);   // waits for the gate, then loads the plugins

The acceptance is remembered in <settings folder>/licenses/accepted-<hash>.txt (content sha256 <hash>); a new plugin or an update changes the hash and asks again. Another process of the same installation that accepts opens this gate too. Without an embedded inventory, or one above licenses.inventorySize, the gate is Broken and nothing can be accepted. There is no implicit acceptance: agents and --accept-licenses name the hash they read.

Settings and profiles

An application declares its settings once per scope kind; the core adds the base settings (limits, log.fileEnabled, commands.journalEnabled, messages.stackTraces, access.* in the application scope; ui.theme, ui.scale, ui.language, ui.menuCollapsed, widgets.confirmClose in the profile scope):

builder.Commands.AddTargetKind("counter", LocalText.Fixed("Counter"), "Sample");   // a kind with its UI name
builder.Settings.AddScopeKind("counter", "Sample");                  // every live counter instance gets its own settings
builder.Settings.Add(SettingScopeId.Application, "Sample", static registrar =>
{
    registrar.RegisterGroup("sample", "Sample", "The sample.");
    _ = registrar.RegisterSetting(Setting.String("sample.greeting", "Greeting", "sample", "Hello", "The greeting."));
});

core.Settings holds one pending model for every window and agent: TrySetPending (refused with one sentence that names the key, the value, and the rule, for example ui.scale: '145' is refused: the choices are 90 %, 100 %, …, 200 %.), Apply (lists the keys in effect now and those waiting for a reset or a restart; saves only these keys), Discard, TryRestoreDefault, Read (rows with state, default, pending value, owner, limit facts, and for a closed set Choices, the values to send, with ChoiceLabels, their English names: dark/light as Dark/Light, the language codes of ui.language as their native names, any other enumeration as its names, and Activation, when a change takes effect as the setting declares it: Immediate, Reset, or Restart; JSON immediate, reset, restart), EditedCount(scope) (the values of a scope that wait for Apply, the same count in every window), and View. The application and profile scopes are saved; an instance scope lives in memory and ends with its instance, or lives in a manager the application handed over with AddInstanceManager(scope, manager) (never saved or disposed by the base; see the settings guide). Path lists (plugins.paths, access.agentReadFolders, access.agentWriteFolders) accept absolute paths without duplicates only, from every client; ui.scale takes one of its choices 90 % to 200 % in steps of 10, by name (120 %) or by number (120), checked the same way for --set, and ui.scale.set refuses anything else before it is pending (ui.scale: '125' is not allowed. Use 90 to 200 in steps of 10.). Agents (REST, MCP, a replay) cannot set an access.* key: those settings bound what agents may do; the window and the command line can.

A target kind may declare the command that resets one instance: builder.Commands.AddTargetKind("box", LocalText.Fixed("Box"), "Sample", resetCommand: "sample.box.reset"). The command must be targeted at the kind (checked at the start). After it answers ok for an instance (not as a dry run), from any surface, the base puts the instance's values that wait for a reset into effect: their rows leave the state WaitingForReset, values that wait for a restart keep waiting, and Changed is raised. The reset command reads the applied value from its scope and knows nothing else of settings: the settings library applies a value at once and only records how it takes effect. core.Targets.TryGetReset(kind, out command) answers the declared command; for a kind without one it answers false, and its waiting values keep waiting.

Agent file access is open by default. With access.restrictAgentFiles on, a path an agent gives (origin REST, MCP, command line, or a replay) must lie in access.agentReadFolders (reading) or access.agentWriteFolders (writing); the window and plugins are never restricted. core.Files (AgentFileAccess, also BasePluginBuilder.Files) checks a path: TryCheckRead(path, context.Origin, "paths", out error) answers NotAllowed with {path} is outside the folders of access.agentReadFolders.; links and junctions are resolved before the check, and .. and a shared name prefix (allowedX) never pass. files.list lists one folder (folders first, then files matching filter, paged with a cursor); a folder above ui.fileListEntries answers LimitExceeded with the hit sentence, never a cut list.

Popups (core.Popups): ui.popup.open, ui.popup.answer, and ui.popup.cancel change the one shared stack; each entry carries its page (OpenPopup.Page): the page parameter (a visible page), else the open page for origin ui and the start page for every other origin (TryOpen takes the origin of the running command); removing a page cancels its popups. An answer is read strictly, checked, and closes the popup, and then the type's answer command runs on its own loop with the answerer's origin (a refused run is one Error). BasePopups.Confirm and BasePopups.FileBrowser (its answer passes FileBrowserRules with the answerer's origin); OptionFormType<TResult> turns setting declarations into a form whose answers get the sentences of the Settings page (field key a.b.c is the result property c).

core.Profiles switches the active profile for everybody at once (profiles.switch; pending values of the old profile are discarded and named), creates (empty or as a copy), renames, and deletes profiles; the active and the last profile cannot be deleted, and a name must be a valid folder name on every system. The active profile is remembered in <settings folder>/active-profile.txt (UTF-8 without a byte order mark, created with default by the first start); --profile <name> opens another one for one run. A --set key that no setting holds stops the start with exit 2 (Unknown setting … Did you mean …?), except a key a plugin may declare, which waits for the plugin load and then gives one Warning.

UI state, pages, popups, widgets

Every window and agent shares one UI state: named parts of core.UiState (the open page, the popup stack, the dashboard, the details shares, and parts the application adds with builder.UiState.AddPart). Only a command handler changes a part, so every change appears in the command log and reaches every window; a view watches a part with UiState.Watch(part, onChange) and gets the newest value at most ten times a second.

builder.Pages.TryAdd(new PageDeclaration("counter", LocalText.Fixed("Counter"), "hash", MenuPlace.Application, 0,
    ReachableBeforeAcceptance: false, typeof(CounterPageParameters), "Sample"), out _);
builder.Pages.StartPage = "counter";
builder.Popups.TryAdd(new PopupType<RenameParameters, RenameResult>("sample.rename", LocalText.Fixed("Rename"), "Sample",
    ["OK", "Cancel"]), out _);
builder.Widgets.TryAdd(new PersistentWidgetType<CounterState>("sample.counter", LocalText.Fixed("Counter"), 10, new(), "Sample",
    stateVersion: 1), out _);
builder.Widgets.TryAdd(new WidgetType<ClockState>("sample.clock", LocalText.Fixed("Clock"), 8, new(), "Sample"), out _);

Pages have typed parameters (ui.navigate reads them strictly). The base has seven pages (BasePages.All); About holds the licenses, takes AboutPageParameters(Part), and cannot be hidden. BasePages.LicensesId (licenses) is no page but an alias: ui.navigate to licenses opens about with {"part":"licenses"} and answers with that page, refuses parameters of its own (Page 'licenses' takes no parameters.), and Hide("licenses") is refused like Hide("about") (The page about cannot be hidden: it must stay reachable.); an added page cannot take the id. The Settings page takes SettingsPageParameters(Tab, Search, Group); ui.navigate refuses a tab that no scope has now with InvalidParameters naming tab (There is no settings tab "nope"., the text cut to 64 characters and …), and leaves an unknown group to the page. Popups have typed parameters, buttons, and answer values; ui.popupsOpen bounds the stack. Widgets have a typed state; ui.widgets bounds the dashboard and a widget id is never given twice. The base part ui.detailsShares (DetailsShares) holds, per page id, the share of the page height the details panel of that page takes; ui.details.resize ({"page":"messages","share":0.4}) sets it for every window, a share outside DetailsShareRules.Min to Max (0.15 to 0.85) or an unknown page is refused with InvalidParameters, and a page without a stored share uses DetailsShareRules.Default (0.5, half of the page height). A window mode saves the open page, the dashboard, the details shares, and the application parts to <settings folder>/ui-state.json a second after a change and at exit, and restores them at the next start: a damaged file gives the defaults and is kept as ui-state.json.damaged; a bad details share gives its page the default with one Warning; a widget of a plugin that is missing this run is kept for later. Only a persistent widget type (PersistentWidgetType<TState>) stores its widgets' state, with its stateVersion ({"widget":1,"type":"sample.counter",…,"state":{"value":7},"stateVersion":2}); a plain WidgetType<TState> stores none, and its widgets start with the default state. A state stored without stateVersion (a file of an earlier build) is version 1, so the format version stays 1. At the restore a version newer than the type's is refused (The state of widget 2 (sample.counter) has version 3; this type reads up to 2. Its default state is used.); otherwise the type's Restore step checks, converts, or refuses the stored text (… was refused: {reason}. …), and without one the current version is read strictly and an older one refused. A refusal, an unreadable stateVersion, or a restore step that throws gives that widget its default state at its place with one Warning; the other widgets are unchanged. A widget whose type registers later (a plugin's) keeps the stored text and its version until the plugins have loaded; then the base runs dashboard.restoreKept, which restores all such widgets the same way in one change of the dashboard. A widget of a plugin that is missing this run keeps its text and version in the file. core.CloseImpact.ReadAsync() lists what closing would end (running jobs, and what plugins report).

Layout document

The dashboard leaves the application as one JSON document and comes back checked (LayoutDocument). dashboard.export answers it as text ({"document":…,"bytes":…,"aboveImportLimit":false}) or, with {"path":"C:\\layouts\\team.layout.json"}, writes it to a fully qualified file through a temporary file and a move, so a failed write leaves no partial file (The layout cannot be written to {path}: {reason}). The document, indented, members in this order:

{
  "format": "base-app.layout", "formatVersion": 1,
  "application": { "name": "Sample.Application", "version": "0.23.0" },
  "widgets": [
    { "type": "sample.counter", "plugin": null, "share": 1.2, "color": 3, "stateVersion": 2, "state": { "value": 7 } },
    { "type": "sample.clock", "plugin": null, "share": 1 }
  ]
}

plugin is the unique name of the plugin that published the type (null for the application's types); color appears only when set; stateVersion and state only for a persistent type, after its Export step, which leaves out what must not leave the machine (a throwing step refuses the export). Nothing else: no widget id, placement (a detached widget exports like a docked one), path, user, machine, or token. A widget whose type is not loaded is exported without its state. An export larger than ui.layoutImportSize says so (aboveImportLimit).

dashboard.import takes {"path":…} or {"text":…} (exactly one) and checks the document as untrusted input, in this order, each refusal one sentence that changes nothing: the size against ui.layoutImportSize (default 1 MiB, the hit sentence with the measured size), UTF-8, JSON of at most 64 levels, format, formatVersion (This layout has format version 2; this application reads version 1.), a closed member set for the document, application, and each widget (an unknown or repeated member is refused), the application name (This layout belongs to Other.App.), and the widget count against ui.widgets. Each widget is then read as tolerantly as the stored layout, one Warning each, naming the widget by its position in the document: an entry without a valid type is left out; a bad share or colour gets its default; a persistent state goes through the type's restore step (a refusal gives the default state); a type that is not loaded is kept, hidden, until its plugin loads (Widget type other.missing of plugin Colleague.Plugin is not loaded; it is kept and shows when the plugin is loaded.). The import replaces the whole dashboard in one step with new widget ids and docks every widget; widget popups and status lines of the widgets that went are dropped, and the Warnings go to the Messages page. The answer names goes, comes, hidden, and warnings; a dry run answers the same and changes nothing. An agent's path must lie in access.agentReadFolders (import) or access.agentWriteFolders (export) while access.restrictAgentFiles is on.

dashboard.importUndo brings back the layout the last import replaced, with its widget ids, until the next change of the dashboard ({"undone":true}); after a later change, a second Undo, or a restart it answers {"undone":false,"note":"There is no import to undo."}.

Rows

GrowingStore<T> holds up to 2^48 values: one thread appends (Append, AppendRange), any number of threads read below Count (Read, the indexer) without a lock and never see a value before it is written. GrowingStoreRowSource<T> turns a store into the rows of a virtual list: it notices growth once per interval (Changed with count and generation) and can replace the store (a new generation). FixedRowHeights and MeasuredRowHeights map a scroll position (ListPosition: the top row and its offset) to the scroll bar and back; measured heights are exact up to 100,000 rows.

GrowingStore<Frame> frames = new();
using GrowingStoreRowSource<Frame> rows = new(frames, TimeSpan.FromMilliseconds(100), core.Messages);
rows.Changed += (_, change) => view.Grow(change.Count, change.Generation);
frames.Append(frame);   // the writer thread

Plugin kinds

An application defines its plugin kinds and the plugins it ships before the build:

public interface ISamplePlugin : IPluginModule<SamplePluginBuilder>;

public sealed class SamplePluginBuilder(PluginIdentity plugin, CoreBuilderAccess core) : BasePluginBuilder(plugin, core);

builder.PluginKinds.Add<ISamplePlugin, SamplePluginBuilder>("sample",
    static (plugin, core) => new SamplePluginBuilder(plugin, core));
builder.PluginKinds.AddBuiltIn<CounterPlugin>();
builder.PluginKinds.AddApplicationFolder("plugins/sample");   // relative to the application's folder, loaded before plugins.paths

An application folder must stay inside AppContext.BaseDirectory (rooted paths, .., and duplicates are refused when it is added); each row of plugins.list carries its origin: builtIn, application, or setting (plugin guide § 15).

Keep the kind interface in an assembly of the application (a contract assembly): the loader accepts a kind only from there, so a plugin file cannot invent one. A plugin adds commands, texts, status fields, settings (AddSettings, in a group of its own), pages, popup types, widget types, close-impact lines, and closing work through its builder; they are published only when every configure call of the plugin succeeded. After the load the plugins start in load order with a context (log, data folder <settings folder>/plugins-data/<name>/, application and live profile settings, SettingsApplied, Stopping); a start that fails or passes plugins.startTimeout disables that plugin, and its row's reason names the failed start and keeps the start error (plugin <name> failed to start: StartAsync failed: InvalidOperationException: missing setting x).

The builder records every contribution with a name and an English description, read when the plugin stages it (a LocalText title becomes its English text; the plugin's own text sets count before its commit). PluginRow.Items and the items of plugins.list list them in record order as ContributionItem(Kind, Name, Description), and Contributions counts the same items per kind. The kinds and what they record:

Kind Name Description
command the command name its description
texts the text set (with the language of a translation) English texts of …, de texts of …
status the field name where it shows and its value type
closeimpact closeimpact<n> what the lines are for
closingwork the name of the piece Work that runs first when the application ends
page, popup, widget, subjectkind id or kind the English title or UI name
settings each group of the registration 1 setting, <n> settings
action the English label the English tooltip

The web package's builder adds menuentry, menusubmenu, statusitem, and welcome; a builder of your own records further kinds with RecordContribution(kind, name, description) and reads a title with EnglishText(text, fallback). Names and descriptions are plugin text, kept as written and marked untrusted for agents.

Plugin faults

Every call into plugin code after the start is contained: a command handler or validator, a status field reader, and a SettingsApplied handler run on a pool thread bounded by plugins.callTimeout (a settings handler never holds the apply). A throwing call answers Failed and gives one Error per contributor; a hung call answers <command> did not answer within <n> s: <plugin> may be stuck and its queue goes on; a hung status field shows a problem while the other fields answer. A plugin whose hung calls reach plugins.abandonedCalls is disabled for the run: its commands answer plugin <plugin> is disabled: <reason> and plugins.list shows it failed with its fault count. Faults that end a process (an exception on the plugin's own thread, async void, stack overflow, out of memory) cannot be contained in process (plugin-in-process).

Closing work

Work that must run however the application ends (flush a file, save a value, tell a device goodbye) is closing work. The application registers it on CoreBuilder.Closing, a plugin with AddClosingWork(name, work) on its builder:

builder.Closing.Add("sample.flush", async cancel => await log.FlushAsync(cancel), "Sample Application");
pluginBuilder.AddClosingWork("sampleplugin.save", cancel => SaveAsync(cancel));

It runs first in the shutdown, while the jobs, the settings, the UI state, and the commands are still usable: one piece after another, the application's in registration order, then the plugins' in load order (a disabled plugin's are left out). A name is 1 to 64 characters without control characters and unique per owner (else ArgumentException). Each piece runs on a pool thread with its own token, which is cancelled at the limit app.closingWait (5 s, 1 s to 10 min, or off); a piece that has not ended by then is left and named in one Warning with the hit sentence, a piece that throws is named in one Error, and the shutdown goes on. A host calls CoreComposition.RunClosingWorkAsync when its run ends, before it stops serving; DisposeAsync runs it first when no host did, so a core without a host gets the same order. CoreComposition.Shutdown names the step the shutdown is in (running the closing work sample.flush, waiting for jobs: Demo (job 3), saving the UI state, …).

Limits

Every bound on untrusted input, memory, disk, or time is a limit of BaseAppLimits.All and an application setting: the person changes it on the Settings page, with the command settings.set, or for one run with --set key=value. A hit is reported with one sentence that names the measured value, the limit, the key, and those three ways (BaseAppLimits.HitMessage). The register with every key, default, and range: docs/limits/base-app.md (generated by NetworkInspector.BaseApp.LimitRegisterTool with LimitRegister.Render, which renders the register of an application's own limits too).

Build and test

dotnet build NetworkInspector.BaseApp.Core/NetworkInspector.BaseApp.Core.csproj -c Release
dotnet test --project NetworkInspector.BaseApp.Core.Tests/NetworkInspector.BaseApp.Core.Tests.csproj -c Release

Documentation

Architecture § BaseApp.Core · Base app guide · Texts guide · Limits register · Changelog

License

MIT; see LICENSE.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on NetworkInspector.BaseApp.Core:

Package Downloads
NetworkInspector.BaseApp

Web host, Blazor shell, REST, MCP, and command line for local tools built on the NetworkInspector base.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.23.0 0 11/26/2026