2 Commits
Author SHA1 Message Date
mika@stocksharp.com 6e7a7dae22 Move instrument lookups and persistence to async
Instrument lookups, configuration, credentials, CSV entities, snapshots and
the alert processing service are read and written asynchronously; the
blocking synchronous forms are obsolete wrappers.

IAsyncPersistable replaces IPersistable: every type that saves and loads its
settings has LoadAsync and SaveAsync only, and nested objects are read with
GetValueAsync, LoadEntireAsync and LoadAllAsync. The synchronous Load and Save
are the obsolete Ecng extensions. The MultiConnect sample keeps IPersistable
for two settings classes, because the settings window of the published
StockSharp.Xaml package takes it.

Copies that were made by saving and loading are made asynchronously.
IMessageAdapter, IIndicator, the risk, commission, PnL, latency, slippage and
position managers, IStorageBuffer, Strategy, DiagramElement, ICompositionModel
and its nodes get CloneAsync and no longer implement ICloneable; Clone is an
obsolete blocking wrapper. A strategy copy keeps every security and portfolio
parameter the original holds. Messages, FieldMapping, BankDetails and
WithdrawInfo are copied in memory. A CommissionRuleMessage shares its rule and
the emulator takes a copy of it. Envelope gets a constructor that takes all
three lines and CreateAsync.

ToBruteForce and ToBruteForceRandom become ToBruteForceAsync and
ToBruteForceRandomAsync and return IAsyncEnumerable; BruteForceOptimizer runs
over it and takes the next strategy through an asynchronous delegate.

Diagram elements keep their own state in SaveState, OnLoading and LoadState.
Undo restores an in-memory snapshot; a chart element holds its series and
axes in it by reference. An alert rule keeps its value in the form a message
carries it. A diagram strategy applies composition settings that were loaded
before the composition was set in SetCompositionAsync or at the start, and
saves them while they wait.

Strategies get an OnStartedAsync hook; diagram strategies resolve securities,
underlyings and strikes before the start so value processing never looks up
instruments. Paths.Serialize, SerializeInvariant, AppStartSettings.TrySave,
ICredentialsProvider.Save, ISnapshotSerializer.Serialize and the composition
registry gain async forms.

ICredentialsProvider.Delete becomes DeleteAsync, so loading, saving and
deleting the credentials wait for one another. Paths.InstalledVersion and
AppNameWithVersion are obsolete in favour of GetInstalledVersionAsync and
GetAppNameWithVersionAsync.

A file is opened for writing only after the last cancellation check, because
opening it empties it; a cancelled read reports the cancellation instead of
an empty result. A snapshot flush that failed leaves what it took due for the
next one.

The indicator templates for C#, F# and Python override LoadAsync and
SaveAsync.
2026-10-04 11:28:17 +03:00
mika@stocksharp.com 0215b8b980 Say what the core promises, in tests that can fail
Every test written during the coverage review, in one commit: 105 files, about 32,000 lines added.
No product code is touched here - what the tests found is repaired in the commit that follows.

WHERE THEY CAME FROM. Three audits read the core and its suite side by side and filed 295 findings.
Each was taken as a claim to be disproved rather than believed: of the defects claimed, most did not
survive a second reading - an unreachable trigger, a promise nobody ever made, behaviour already
covered, and in one case a property the model no longer has, so the test could not be written at all.
What survived is here.

WHAT THE TESTS ARE. Three kinds, and the difference matters.

A hole: behaviour the core has and nothing checked. Most of the new files are this - the adapters
that filter a depth, hold a candle, track a lookup, associate a security or loop a message back; the
message clone that must not share state with its original; the generators behind localized strings
and media names; the round trip of a diagram strategy and of a FIX data type.

A test that proved nothing: a name that promised one thing while the assertion checked another, an
assertion that could not fail, an expected value copied from whatever the code returned that day.
Those were rewritten in place to say what they were named for, and several of them go red doing it.

A defect: a promise the core makes and does not keep. Those tests are red, and they stay red until
the next commit repairs them - a red test is the record of the defect, and there is nowhere else the
record would be read.

HOW THEY ARE WRITTEN. From the promise, not from the implementation: the expected value is what the
caller is owed, never what the method happens to return. Every assertion carries a message saying
what was owed to whom, so a failure reads as a sentence rather than as two numbers that differ.

Claude-Session: https://claude.ai/code/session_01LjT4RKLsz3vBd8eSERZTde
2026-09-12 11:36:47 +03:00