The protocol servers minted a transaction number of their own for every
client request and kept the pairing in an ITransactionIdStorage, one table
per connection. They now run each request under the number its client
gave it, so the storage, its in-memory and plain implementations and their
tests go.
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.
DeleteAsync already put a removed account back when the write failed, so that a delete reported as done could not be undone by a restart. SaveAsync had no such guard: an account whose write threw stayed granted in memory while the file knew nothing of it. The rollback is now the same on both paths.
Twelve common_*.props files sat in the repository root, mixed in with the
solutions and the READMEs. They are build configuration and now live in props/,
and every import that reaches them carries the folder: 59 imports across this
repository, Connectors and StockSharpApps, the F# analytics project included.
common_meta.props derived the repository location from its own directory, so it
now normalizes one level up. RepoGitHubPath and everything built on it -
RepoAppsPath, RepoWebPath, ConnectorsGitHubPath, ConnectorsAppsPath - evaluate
to exactly the paths they did before.
The folder is props/ and not build/, which .gitignore excludes.
A leftover of the old project format: seven projects still carried a
ProjectGuid, and nothing reads it. The solutions are the XML format and name
their projects by path, so the identifiers were not referenced anywhere - and
the SDK does not need one. Where the element was the only thing in its
PropertyGroup the empty group goes with it.
The previous attempt leaned on ToFullPathIfNeed, which does not do what its name
suggests: it expands the %Documents% variable and returns everything else
untouched. A bare "StockSharp" - what Path.Combine yields when GetFolderPath
answers with an empty string, as it does in a container with no HOME - passed
through it unchanged and stayed relative, so the paths tests went on failing.
Path.GetFullPath settles it against the current directory, which is where the
data was already going; now it is stated rather than implied. The %Documents%
expansion is kept, and its own empty result falls through to the same default
instead of throwing.
GetFolderPath answers with an empty string when the platform cannot name the
folder - a container with no HOME, which is what a CI runner usually is - and
Path.Combine then yielded a bare "StockSharp". Every path built from it inherited
that, so the data would land wherever the process happened to start rather than
in one known place.
Whatever the folder resolves to is now made absolute, which is what the rest of
the code already assumed.
Configuration already owns the StockSharp-account credentials abstraction:
ICredentialsProvider loads, saves and deletes them. What it did not have is the
third operation - who is signed in right now, and with what token - which is the
one question the credentials dialog asks the web API.
Stating it here rather than in the UI library keeps the dependency pointing the
right way. The dialog does not need to know the shape of the web API; the caller,
which already knows it, supplies the implementation. And a consumer that wants to
answer that question without a WPF reference now can.
Not in Ecng, which was the other candidate: Ecng.Net's IOAuthProvider and
IOAuthToken are generic OAuth - a token by social id, with a value and an expiry.
This is not that. It answers with an email and an access token for OUR account,
and its salt is our own login handshake, not an OAuth notion. Ecng is shared by
projects that have no StockSharp account to ask about.
Serialize<T> wrote through IFileSystem.OpenWrite, which - like File.Open - does
not create missing parent folders, so serializing to a path inside a not-yet
created directory threw DirectoryNotFoundException. The installer hit this while
saving its app cache to ...\Documents\StockSharp\Installer\ before that folder
existed (the error was logged on every run and the cache never persisted).
Create the parent directory before opening the stream.
Get(persistable:true) used SafeAdd which returned the cached session
with old requestId mappings. When a client reconnects with the same
sessionId, CreateTransactionId throws "duplicated". Replace SafeAdd
with unconditional assignment to always create a fresh session.
Non-async method with using var stream returned ValueTask without await,
causing stream to be disposed before deserialization completed
(ObjectDisposedException on SafeFileHandle).
- Accept IFileSystem, credentialsFile, and companyPath in constructor
with defaults for backward compatibility
- Replace direct File/Directory calls with IFileSystem methods
- Add comprehensive tests using MemoryFileSystem