diff --git a/.github/workflows/mirror.yml b/.github/workflows/mirror.yml
index d23b363..71a86a5 100644
--- a/.github/workflows/mirror.yml
+++ b/.github/workflows/mirror.yml
@@ -4,14 +4,22 @@ name: Mirror
#
# The mirror is never worked in: every commit of it is a snapshot made by scripts/mirror.ps1, here or on a machine.
# This workflow takes the list of components from the .orchestra file of the last snapshot, clones each at its
-# default branch, makes a new snapshot when anything changed, pushes it, and starts the docs workflow (a push made
-# with the token of a workflow starts no other workflow by itself).
+# default branch, makes a new snapshot when anything changed and pushes it. A push with the token of an app starts the
+# workflows of the mirror as any push does: the docs workflow builds the site.
#
# It lives in the core like everything the mirror holds, but runs only where the repository variable
# STELLAR_MIRROR is 'true' (Settings -> Secrets and variables -> Actions -> Variables): in the mirror.
# Public components work with the token of the workflow. A component it cannot clone (a private repository) is kept
# as the mirror has it; the secret STELLAR_MIRROR_TOKEN (a fine-grained token with read access to their contents)
# lets the workflow refresh private ones too.
+#
+# The rulesets of the mirror let nobody write its branch, and the token of a workflow can neither pass a ruleset nor
+# change a file of .github/workflows/, which a snapshot does whenever the core did. So the snapshot is pushed with the
+# token of a GitHub App of the organization. Set once:
+# - the app: repository permissions Contents and Workflows, read and write; installed on the mirror only;
+# - the mirror, Settings -> Secrets and variables -> Actions: the variable STELLAR_MIRROR_APP_ID (its client ID) and
+# the secret STELLAR_MIRROR_APP_KEY (its private key);
+# - the mirror, Settings -> Rules -> the ruleset of the branch: the app in the bypass list.
# The first snapshot comes from a machine: scripts/mirror.ps1 -Push. After that this workflow is the only writer:
# on a machine, mirror.ps1 without -Push shows the next snapshot, Run workflow here publishes it.
@@ -22,7 +30,6 @@ on:
permissions:
contents: write
- actions: write
concurrency:
group: mirror
@@ -40,12 +47,21 @@ jobs:
# Its own credentials would add a second Authorization header to every request to github.com
persist-credentials: false
+ # Writes the mirror: a token of this job only, for this repository and these two permissions
+ - name: Token of the mirror app
+ id: app
+ uses: actions/create-github-app-token@v3
+ with:
+ client-id: ${{ vars.STELLAR_MIRROR_APP_ID }}
+ private-key: ${{ secrets.STELLAR_MIRROR_APP_KEY }}
+ permission-contents: write
+ permission-workflows: write
+
- name: Clone the components
id: workspace
shell: pwsh
env:
COMPONENTS_TOKEN: ${{ secrets.STELLAR_MIRROR_TOKEN || github.token }}
- MIRROR_TOKEN: ${{ github.token }}
run: |
if (-not (Test-Path .orchestra)) {
throw 'No .orchestra here: make the first snapshot on a machine with scripts/mirror.ps1 -Push'
@@ -66,8 +82,6 @@ jobs:
}
$mirrorRepository = 'https://github.com/${{ github.repository }}'
- # The mirror itself is written with the token of this workflow
- Set-Credentials $mirrorRepository $env:MIRROR_TOKEN
$workspace = Join-Path $env:RUNNER_TEMP 'orchestra'
$components = @((Get-Content .orchestra -Raw | ConvertFrom-Json).Components)
@@ -97,7 +111,15 @@ jobs:
- name: Snapshot and push
id: snapshot
shell: pwsh
+ env:
+ MIRROR_TOKEN: ${{ steps.app.outputs.token }}
run: |
+ # The same form of credentials as for the components: in a header, for both spellings of the repository
+ $basic = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("x-access-token:$env:MIRROR_TOKEN"))
+ foreach ($url in 'https://github.com/${{ github.repository }}', 'https://github.com/${{ github.repository }}.git') {
+ git config --global --replace-all "http.$url.extraheader" "AUTHORIZATION: basic $basic"
+ }
+
$workspace = '${{ steps.workspace.outputs.path }}'
$keep = @('${{ steps.workspace.outputs.keep }}' -split ',' | Where-Object { $_ })
@@ -150,8 +172,3 @@ jobs:
if ($version.Contains('-')) { $flags += '--prerelease' }
gh release create '${{ steps.snapshot.outputs.tag }}' --repo '${{ github.repository }}' --verify-tag --title "StellarEngine $version" --notes-file $notesFile @flags
if ($LASTEXITCODE -ne 0) { throw 'gh release create failed' }
-
- - name: Build the site
- env:
- GH_TOKEN: ${{ github.token }}
- run: gh workflow run docs.yml --repo '${{ github.repository }}' --ref master
diff --git a/.github/workflows/restrict-master-prs.yml b/.github/workflows/restrict-master-prs.yml
index b07b852..665d43f 100644
--- a/.github/workflows/restrict-master-prs.yml
+++ b/.github/workflows/restrict-master-prs.yml
@@ -4,6 +4,11 @@ on:
pull_request_target:
types: [opened, reopened]
+permissions:
+ contents: read
+ pull-requests: write
+ issues: write
+
jobs:
restrict:
uses: QuantumDevTeam/.github/.github/workflows/restrict-master-prs.yml@master
diff --git a/Core/src/Managed/Stellar.Core/EntryPoint.cs b/Core/src/Managed/Stellar.Core/EntryPoint.cs
index 8196dae..b24b15b 100644
--- a/Core/src/Managed/Stellar.Core/EntryPoint.cs
+++ b/Core/src/Managed/Stellar.Core/EntryPoint.cs
@@ -2,7 +2,7 @@
using Stellar.Core.Global;
using Stellar.Kernel.Configuration;
using Stellar.Kernel.EntryPoint;
-using Stellar.Kernel.Failures;
+using Stellar.Kernel.FailureSystem;
using Stellar.Kernel.Lifecycle;
using Stellar.Kernel.LoggingSystem;
using Stellar.Kernel.Services;
diff --git a/Core/src/Managed/Stellar.Core/EntryPoints/RunContext.cs b/Core/src/Managed/Stellar.Core/EntryPoints/RunContext.cs
index 5666aef..926b167 100644
--- a/Core/src/Managed/Stellar.Core/EntryPoints/RunContext.cs
+++ b/Core/src/Managed/Stellar.Core/EntryPoints/RunContext.cs
@@ -1,5 +1,5 @@
using Stellar.Kernel.EntryPoint;
-using Stellar.Kernel.Failures;
+using Stellar.Kernel.FailureSystem;
using Stellar.Kernel.Lifecycle;
using Stellar.Kernel.LoggingSystem;
using Stellar.Kernel.Quantization;
diff --git a/Core/src/Managed/Stellar.Core/Failures/FailureSystem.cs b/Core/src/Managed/Stellar.Core/Failures/FailureSystem.cs
index 786dd0a..8f5643a 100644
--- a/Core/src/Managed/Stellar.Core/Failures/FailureSystem.cs
+++ b/Core/src/Managed/Stellar.Core/Failures/FailureSystem.cs
@@ -3,7 +3,7 @@
using Stellar.Core.Quantization;
using Stellar.Kernel.Data.Catalog;
using Stellar.Kernel.EntryPoint;
-using Stellar.Kernel.Failures;
+using Stellar.Kernel.FailureSystem;
using Stellar.Kernel.Lifecycle;
using Stellar.Kernel.LoggingSystem;
diff --git a/Core/src/Managed/Stellar.Core/Global/CoreEngine.cs b/Core/src/Managed/Stellar.Core/Global/CoreEngine.cs
index 6e2f04a..03f28ce 100644
--- a/Core/src/Managed/Stellar.Core/Global/CoreEngine.cs
+++ b/Core/src/Managed/Stellar.Core/Global/CoreEngine.cs
@@ -5,7 +5,7 @@
using Stellar.Core.Services;
using Stellar.Kernel.Data.Collections;
using Stellar.Kernel.Data.Registry;
-using Stellar.Kernel.Failures;
+using Stellar.Kernel.FailureSystem;
using Stellar.Kernel.Lifecycle;
using Stellar.Kernel.LoggingSystem;
using Stellar.Kernel.Quantization;
@@ -106,6 +106,7 @@ public static CoreEngine For(IEngineInstance engine)
/// Whether it had one.
public static bool Release(IEngineInstance engine)
{
+ // ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
if (engine is null || !Engines.TryGetValue(engine, out var core)) return false;
Engines.Remove(engine);
diff --git a/Core/src/Managed/Stellar.Core/Global/Engine.cs b/Core/src/Managed/Stellar.Core/Global/Engine.cs
index 3fba677..8910f3b 100644
--- a/Core/src/Managed/Stellar.Core/Global/Engine.cs
+++ b/Core/src/Managed/Stellar.Core/Global/Engine.cs
@@ -1,6 +1,6 @@
using Stellar.Kernel.Data.Collections;
using Stellar.Kernel.Data.Registry;
-using Stellar.Kernel.Failures;
+using Stellar.Kernel.FailureSystem;
using Stellar.Kernel.LoggingSystem;
using Stellar.Kernel.Quantization;
using Stellar.Kernel.Services;
diff --git a/Core/tests/Managed/Stellar.Core.Tests/FailureTests.cs b/Core/tests/Managed/Stellar.Core.Tests/FailureTests.cs
index 31dace3..9e5c475 100644
--- a/Core/tests/Managed/Stellar.Core.Tests/FailureTests.cs
+++ b/Core/tests/Managed/Stellar.Core.Tests/FailureTests.cs
@@ -3,7 +3,7 @@
using Stellar.Core.Global;
using Stellar.Kernel.Configuration;
using Stellar.Kernel.EntryPoint;
-using Stellar.Kernel.Failures;
+using Stellar.Kernel.FailureSystem;
using Stellar.Kernel.FileSystem;
using Stellar.Kernel.Lifecycle;
using Stellar.Kernel.LoggingSystem;
@@ -32,7 +32,11 @@ private sealed class RecordingLogger : ILogger
public void LogWithoutFormat(string message) => Lines.Add((LogLevel.Info, message));
- public void Dispose()
+ public void Start()
+ {
+ }
+
+ public void Stop()
{
}
}
diff --git a/Docs/Architecture/Sdk.md b/Docs/Architecture/Sdk.md
index dfc7081..537af99 100644
--- a/Docs/Architecture/Sdk.md
+++ b/Docs/Architecture/Sdk.md
@@ -26,7 +26,7 @@ them, but Rider shows an item written in a project file as a file of the project
The SDK version is pinned once, in `global.json`, not in every project:
```json
-{ "msbuild-sdks": { "Stellar.Sdk": "0.4.0" } }
+{ "msbuild-sdks": { "Stellar.Sdk": "0.4.1" } }
```
The SDK itself comes from the local feed through `NuGet.config`. `stellar project new` and `stellar modules new`
diff --git a/Docs/Engine/Modules.md b/Docs/Engine/Modules.md
index 5a78e12..957f2a3 100644
--- a/Docs/Engine/Modules.md
+++ b/Docs/Engine/Modules.md
@@ -35,6 +35,9 @@ stellar modules add ../Stellar.Logging
It is then part of the installation exactly like a folder of `modules/`, and gets a `NuGet.config` pointing at the
local feed if it has none.
+A game's own libraries are modules too, of the solution of the game and not of the installation: see
+[Modules of a solution](../Formats/SolutionFile.md#modules-of-a-solution).
+
## What a module project gets
The project of a module is nearly empty:
diff --git a/Docs/Engine/PostInstallSetup.md b/Docs/Engine/PostInstallSetup.md
new file mode 100644
index 0000000..b02eb18
--- /dev/null
+++ b/Docs/Engine/PostInstallSetup.md
@@ -0,0 +1,58 @@
+# Setting up the machine after the install
+
+- [README.md](../../README.md)
+
+What to know once the installation stands: how git behaves in a tree of nested repositories.
+
+## Git in a tree of repositories
+
+An installation is several repositories in one folder ([Repository](Repository.md)):
+
+| Folder | Repository |
+|---|---|
+| `/` | StellarEngine-Core |
+| `/modules//` | one repository per module |
+| `/tools//` | one repository per tool |
+
+Git has no idea of this tree. A command acts on the nearest `.git` found going up from the folder it runs in, and the
+core ignores `modules/` and `tools/`, so:
+
+- `git status` in `` never mentions a module, and in a module never mentions the core;
+- inside a module the folder is its own repository: its own history, its own branches, its own `origin`;
+- `modules/` and `tools/` hold files of their own (`Directory.Build.props`, `README.md`, ...) that `stellar install`
+ wrote: they belong to no repository.
+
+Standing in the folder of a module is enough, `git status` there is the status of that module. `-C` is for running a
+command in another folder without leaving yours:
+
+```powershell
+git -C modules/Stellar.FileSystem status
+```
+
+Three checks that tell where you are:
+
+```powershell
+git rev-parse --show-toplevel # the root of the repository the command acts on
+git status --short --branch # the branch, whether it follows a remote, what changed
+ls -Force # .git is a hidden folder: without -Force PowerShell does not list it
+```
+
+If `git rev-parse --show-toplevel` fails with "not a git repository", the folder is not inside any repository: a module
+that has not been through `git init` yet, or a copy of an installation made without the `.git` folders.
+
+### A new module needs its repository
+
+`stellar modules new` creates the files only. A module has a repository of its own once it went through `git init`,
+`git remote add origin ` and a first push of its branch; until then it has no history anyone else can see and the
+mirror (`scripts/mirror.ps1`) has nothing to take from it.
+
+### "Dubious ownership"
+
+Git refuses a repository whose folder belongs to another account than the one running it, which happens to folders
+created from an elevated shell or copied from another machine. The refusal names the exact command to run:
+
+```powershell
+git config --global --add safe.directory
+```
+
+Do it only for folders you trust; there is no need for `*`.
diff --git a/Docs/Engine/Repository.md b/Docs/Engine/Repository.md
index 4e6f7eb..071abb5 100644
--- a/Docs/Engine/Repository.md
+++ b/Docs/Engine/Repository.md
@@ -194,10 +194,14 @@ A version with a suffix (`0.9.0-rc.1`) is a pre-release, which the installer tak
`.github/workflows/mirror.yml` runs in the mirror (where the repository variable `STELLAR_MIRROR` is `true`) every
night and on demand: it clones every component the last `.orchestra` names, at its default branch, makes a snapshot
-when anything changed, pushes it and starts the docs workflow. A component it cannot clone (a private repository) is
+when anything changed and pushes it, which starts the docs workflow. A component it cannot clone (a private repository) is
kept as the mirror has it (`scripts/mirror.ps1 -Keep`); the secret `STELLAR_MIRROR_TOKEN` lets it read private ones
too. The first snapshot comes from a machine: `scripts/mirror.ps1 -Push`.
+The rulesets of the mirror let nobody write its branch, so the workflow pushes with the token of a GitHub App, installed
+on the mirror only and in the bypass list of the ruleset (`STELLAR_MIRROR_APP_ID`, `STELLAR_MIRROR_APP_KEY`). The token
+of a workflow does not do: it passes no ruleset, and cannot change the files of `.github/workflows/`.
+
After that the workflow is the only writer of the mirror: on a machine, `scripts/mirror.ps1` without `-Push` shows
what the next snapshot would be, and Run workflow publishes it. A snapshot is always made on top of the last one of
the mirror; one that cannot read the mirror stops instead of starting a history of its own.
diff --git a/Docs/Engine/toc.yml b/Docs/Engine/toc.yml
index c47ba0b..50e6efc 100644
--- a/Docs/Engine/toc.yml
+++ b/Docs/Engine/toc.yml
@@ -10,6 +10,8 @@
href: Modules.md
- name: Installation and repositories
href: Repository.md
+- name: Setting up the machine
+ href: PostInstallSetup.md
- name: Project
items:
- name: README
diff --git a/Docs/Formats/SolutionFile.md b/Docs/Formats/SolutionFile.md
index 7ec2065..0e9e69d 100644
--- a/Docs/Formats/SolutionFile.md
+++ b/Docs/Formats/SolutionFile.md
@@ -55,7 +55,34 @@ referenced project only from the solution, so with `Sources` the projects of the
wrapper) go to the solution folder `Engine` and the modules of the installation to `Modules`, built by Debug only.
`stellar solution sync` also adds a project you made in the directory of the solution, or a module you started to
-depend on. It writes the `.sln` from scratch: solution folders made by hand in the IDE are not kept.
+depend on. It writes the `.sln` from scratch: solution folders made by hand in the IDE are not kept. It first writes
+the catalog of the [modules of the solution](#modules-of-a-solution), since the references of the projects are read with it.
+
+## Modules of a solution
+
+A game keeps its own libraries (the code of a level, a tool, a game system) as modules, which follow the rules of the
+engine: a folder with a [`.stellar.module`](ModuleDescriptor.md) file, `"Level": "EndPoint"` (a custom module,
+`StellarSdkUsage` `Module`), depending on modules of lower levels, the engine's included.
+
+```text
+Demo/
+├── Demo.stellar.solution
+├── Demo/ the game: Stellar.FileSystem;DemoLib
+└── DemoLib/
+ ├── DemoLib.stellar.module { "Id": "DemoLib", "Level": "EndPoint", "Dependencies": ["Stellar.FileSystem"] }
+ └── DemoLib.csproj the project: src/Managed/DemoLib/DemoLib.csproj works too
+```
+
+`stellar solution sync` finds the modules below the directory of the solution (up to three levels, a module ends
+the search), and those in `Modules` (folders relative to the solution, for libraries kept elsewhere). It writes them into
+`.stellar/stellar.modules.props`, a catalog of the format of the installation's, which the SDK finds from any project
+below the solution and imports after the catalog of the installation. From then on the game names `DemoLib` like any
+module: the SDK references it, the runtime configuration lists it, and the runtime loads it in a context of its own
+after its dependencies and starts its entry point.
+
+A module of a solution is always taken as sources, in every configuration: it is never packed. Its id must not be one of
+the installation, and it cannot depend on another module of its own level. Run `stellar solution sync` again after
+adding a module or changing a descriptor.
## `Run`
diff --git a/Docs/Migration-0.10.md b/Docs/Migration-0.10.md
new file mode 100644
index 0000000..20c1546
--- /dev/null
+++ b/Docs/Migration-0.10.md
@@ -0,0 +1,95 @@
+# Migrating to 0.10
+
+- [README.md](https://github.com/QuantumDevTeam/StellarEngine-Core#readme)
+
+What changed for the code that uses the core, from 0.9. The release is small: the failure system got a name of its
+own, the logger got its contracts, and the SDK learned the modules of a game.
+
+| Component | 0.9 | 0.10 | Why |
+|---|---|---|---|
+| Orchester, Kernel, Core, Runtime | 0.9.0 | 0.10.0 | Breaking: the namespace of the failure system, and `ILogger` |
+| Stellar.Sdk | 0.4.0 | 0.4.1 | Compatible: the modules of a solution |
+| Stellar.Tools | 0.3.1 | 0.3.2 | Compatible |
+| `stellar` (CLI) | 0.2.2 | 0.2.3 | Compatible |
+| P/Invoke exports | 3.1 | 3.1 | Nothing changed in the native part |
+
+Every component has a version of its own: a breaking change raises the second number of that component, and only of
+the components it breaks. The orchestra takes the second number when any of its components does.
+
+## Where `global.json` points
+
+A project pins `Stellar.Sdk` in its `global.json`, and the local feed holds the version of the installation only, so
+after installing 0.10 every pin of `0.4.0` fails to restore. Change it to `0.4.1`:
+
+```json
+{ "msbuild-sdks": { "Stellar.Sdk": "0.4.1" } }
+```
+
+`stellar project new` and `stellar modules new` write the current one. Then build the engine again and install it
+(`scripts/build.ps1 -Configuration Release -Install`), so that the packages of the installation are the new ones.
+
+## Failures
+
+The types of the failure system moved from `Stellar.Kernel.Failures` to `Stellar.Kernel.FailureSystem`, named after
+the system as `Stellar.Kernel.LoggingSystem` is. Nothing else about them changed.
+
+| Before | Now |
+|---|---|
+| `using Stellar.Kernel.Failures;` | `using Stellar.Kernel.FailureSystem;` |
+| `Stellar.Kernel.Failures.Catcher`, `Failure`, `FailureException`, `FailureKind`, `FailureLevel`, `FailureReaction`, `IFailureSystem` | the same names in `Stellar.Kernel.FailureSystem` |
+
+The public members of Stellar.Core and Stellar.Runtime that mention them (`Engine.Failures`, `IRunContext.Failures`,
+`IEngineControl.RequestStop(reason, Failure)`, `RuntimeCatchers`) keep their names: only the types they use moved, so a
+module needs the new `using` and a rebuild. A module built against 0.9 does not load against 0.10.
+
+## Logging
+
+`Stellar.Kernel.LoggingSystem` has its contracts. The logging itself is a module; the Kernel says what it implements.
+
+| Before | Now |
+|---|---|
+| `ILogger : IRegistrableQuant` | `ILogger : IQuant`: a logger is found by its name, in a catalog, and is not put into a registry |
+| `ILogger`: `Log`, `LogWithoutFormat` | the same, and `Start()`, `Stop()`: a logger can be switched on and off |
+| nothing | `ILoggerCatalog : ICatalog`: the loggers of an engine by name, with the members of any catalog |
+| nothing | `LoggerExtensions`: `Info`, `Debug`, `Success`, `Warning`, `Error`, `Exception(message, exception)`, `Separator` |
+| `LogLevel`: `Info`, `Debug`, `Success`, `Warning`, `Error`, `Exception` | in the order of severity: `Debug` is 0 and `Info` is 1; the rest keep their values. Rebuild what stores or compares the numbers |
+| nothing | `LogFormat(Format, ColorizedFormat)`, and `LoggerFormat`: one `LogFormat` per level (`ForLevel`), with `LoggerFormat.Default` |
+
+A logger of a module is added to the catalog when the module starts and taken out when it stops:
+
+```csharp
+public override int Run(ref readonly TContext context)
+{
+ _catalog = context.Services?.Find();
+ _catalog?.TryAdd(Name, _logger);
+ return 0;
+}
+
+public override void RequestStop(ref readonly TContext context) => _catalog?.Remove(Name);
+```
+
+The catalog is published by the logging module, which also publishes the `ILogger` that writes into every logger of the
+catalog. Without one `Find()` is `null`. A class that implemented `ILogger` implements
+`Start` and `Stop` now.
+
+## Modules of a solution
+
+A game keeps its own libraries as modules, and the game names them in `StellarDependencies` like any module of the
+engine: a folder with `.stellar.module` (`"Level": "EndPoint"`), found below the solution or listed in `Modules` of
+`.stellar.solution`. `stellar solution sync` writes them into `.stellar/stellar.modules.props`, which the SDK imports
+after the catalog of the installation. They are always taken as sources, and are loaded by the runtime in a context of
+their own after their dependencies. See [`.stellar.solution`](Formats/SolutionFile.md#modules-of-a-solution).
+
+| Before | Now |
+|---|---|
+| a library of a game as a plain `ProjectReference`: it compiles, but the runtime never loads it as a module | a module of the solution, named in `StellarDependencies` |
+| `Unknown Stellar modules: X` for a library beside the game | the same message, which now also says to run `stellar solution sync` |
+
+The rest, for those who work on the tools:
+
+- `StellarSolutionModuleCatalog` (the property) is found from any project below the solution; `StellarUseSolutionModuleCatalog=false`
+ turns it off.
+- The catalog gives every module two properties, `StellarModuleCatalogFile` and `StellarModuleSyncCommand`, so that
+ STLRB102 checks a descriptor against the catalog it is in and names the command that writes it.
+- `ModuleSource.Solution`, `ModuleDiscovery.Discover(directories, depth)`, `ModuleCatalogGenerator.Render(modules, origin)`
+ and `SolutionModules` in `Stellar.Tools`. The search for modules skips `bin` and `obj`.
diff --git a/Docs/Reference/Sdk.Properties.md b/Docs/Reference/Sdk.Properties.md
index 355e32e..b4dcccf 100644
--- a/Docs/Reference/Sdk.Properties.md
+++ b/Docs/Reference/Sdk.Properties.md
@@ -32,6 +32,7 @@ The project wins over `config/`, `config/` over the defaults.
| `StellarUseArtifactsOutput` | `true` on the engine side, `false` for games | `false`: the plain `bin/` and `obj/` next to the project |
| `StellarArtifactsName` | `$(MSBuildProjectName)` | The folder of the project in `artifacts/bin` and `artifacts/obj` |
| `StellarModuleCatalog` | `$(StellarRoot)manifests/.generated/stellar.modules.props` | The catalog of modules |
+| `StellarSolutionModuleCatalog` | `.stellar/stellar.modules.props` of the solution above the project, if there is one | The catalog of the modules of the solution, imported after `StellarModuleCatalog`. `StellarUseSolutionModuleCatalog=false` finds none |
| `StellarUseModuleCatalog` | `true` | `false`: only the modules of the core exist |
| `StellarUseLocalFeed` | `true` | `false`: the local feed is not added to restore |
| `StellarImportCustomizations` | `true` | `false`: `config/` of the installation is not imported |
diff --git a/Docs/index.md b/Docs/index.md
index 0f41a35..e962b5b 100644
--- a/Docs/index.md
+++ b/Docs/index.md
@@ -41,5 +41,6 @@ The JSON schemas of these files are published here, under [`/schemas/`](https://
- [API reference](xref:Stellar.Kernel), generated from the code of `Stellar.Kernel`, `Stellar.Core`, `Stellar.Runtime` and `Stellar.Tools`
- [SDK properties and items](Reference/Sdk.Properties.md)
- [Diagnostics](Reference/Diagnostics.md)
+- [Migrating to 0.10](Migration-0.10.md)
- [Migrating to 0.9](Migration-0.9.md)
- [Migrating to 0.8](Migration-0.8.md)
diff --git a/Docs/toc.yml b/Docs/toc.yml
index bca823b..97adea3 100644
--- a/Docs/toc.yml
+++ b/Docs/toc.yml
@@ -36,6 +36,8 @@
href: Reference/Sdk.Properties.md
- name: Diagnostics
href: Reference/Diagnostics.md
+ - name: Migrating to 0.10
+ href: Migration-0.10.md
- name: Migrating to 0.9
href: Migration-0.9.md
- name: Migrating to 0.8
diff --git a/Kernel/src/Managed/Stellar.Kernel/EntryPoint/IRunContext.cs b/Kernel/src/Managed/Stellar.Kernel/EntryPoint/IRunContext.cs
index d869448..ce1e29a 100644
--- a/Kernel/src/Managed/Stellar.Kernel/EntryPoint/IRunContext.cs
+++ b/Kernel/src/Managed/Stellar.Kernel/EntryPoint/IRunContext.cs
@@ -1,5 +1,5 @@
using Stellar.Kernel.Data.Context;
-using Stellar.Kernel.Failures;
+using Stellar.Kernel.FailureSystem;
using Stellar.Kernel.Lifecycle;
using Stellar.Kernel.LoggingSystem;
using Stellar.Kernel.Services;
diff --git a/Kernel/src/Managed/Stellar.Kernel/Failures/Catcher.cs b/Kernel/src/Managed/Stellar.Kernel/FailureSystem/Catcher.cs
similarity index 99%
rename from Kernel/src/Managed/Stellar.Kernel/Failures/Catcher.cs
rename to Kernel/src/Managed/Stellar.Kernel/FailureSystem/Catcher.cs
index 8c8ee03..fae75b4 100644
--- a/Kernel/src/Managed/Stellar.Kernel/Failures/Catcher.cs
+++ b/Kernel/src/Managed/Stellar.Kernel/FailureSystem/Catcher.cs
@@ -8,7 +8,7 @@
using Stellar.Kernel.Quantization;
using Stellar.Kernel.Services;
-namespace Stellar.Kernel.Failures;
+namespace Stellar.Kernel.FailureSystem;
///
/// Catches failures around suspicious calls, reports them, and lets the work go on, or stops it, as the reaction says.
diff --git a/Kernel/src/Managed/Stellar.Kernel/Failures/Failure.cs b/Kernel/src/Managed/Stellar.Kernel/FailureSystem/Failure.cs
similarity index 99%
rename from Kernel/src/Managed/Stellar.Kernel/Failures/Failure.cs
rename to Kernel/src/Managed/Stellar.Kernel/FailureSystem/Failure.cs
index d8f0a02..0339414 100644
--- a/Kernel/src/Managed/Stellar.Kernel/Failures/Failure.cs
+++ b/Kernel/src/Managed/Stellar.Kernel/FailureSystem/Failure.cs
@@ -3,7 +3,7 @@
using Stellar.Kernel.Lifecycle;
using Stellar.Kernel.Quantization;
-namespace Stellar.Kernel.Failures;
+namespace Stellar.Kernel.FailureSystem;
///
/// A failure of the engine: what went wrong, where, how seriously, and what was done about it.
diff --git a/Kernel/src/Managed/Stellar.Kernel/Failures/FailureException.cs b/Kernel/src/Managed/Stellar.Kernel/FailureSystem/FailureException.cs
similarity index 97%
rename from Kernel/src/Managed/Stellar.Kernel/Failures/FailureException.cs
rename to Kernel/src/Managed/Stellar.Kernel/FailureSystem/FailureException.cs
index c936d3f..8ae35db 100644
--- a/Kernel/src/Managed/Stellar.Kernel/Failures/FailureException.cs
+++ b/Kernel/src/Managed/Stellar.Kernel/FailureSystem/FailureException.cs
@@ -1,6 +1,6 @@
using System;
-namespace Stellar.Kernel.Failures;
+namespace Stellar.Kernel.FailureSystem;
///
/// An exception of the engine: it carries its .
diff --git a/Kernel/src/Managed/Stellar.Kernel/Failures/FailureKind.cs b/Kernel/src/Managed/Stellar.Kernel/FailureSystem/FailureKind.cs
similarity index 98%
rename from Kernel/src/Managed/Stellar.Kernel/Failures/FailureKind.cs
rename to Kernel/src/Managed/Stellar.Kernel/FailureSystem/FailureKind.cs
index ce7266d..bbcb063 100644
--- a/Kernel/src/Managed/Stellar.Kernel/Failures/FailureKind.cs
+++ b/Kernel/src/Managed/Stellar.Kernel/FailureSystem/FailureKind.cs
@@ -1,6 +1,6 @@
using System;
-namespace Stellar.Kernel.Failures;
+namespace Stellar.Kernel.FailureSystem;
///
/// Where a failure comes from: the engine, a module, the file system, an audio module of a game.
diff --git a/Kernel/src/Managed/Stellar.Kernel/Failures/FailureLevel.cs b/Kernel/src/Managed/Stellar.Kernel/FailureSystem/FailureLevel.cs
similarity index 98%
rename from Kernel/src/Managed/Stellar.Kernel/Failures/FailureLevel.cs
rename to Kernel/src/Managed/Stellar.Kernel/FailureSystem/FailureLevel.cs
index 3085862..07370f0 100644
--- a/Kernel/src/Managed/Stellar.Kernel/Failures/FailureLevel.cs
+++ b/Kernel/src/Managed/Stellar.Kernel/FailureSystem/FailureLevel.cs
@@ -1,6 +1,6 @@
using System;
-namespace Stellar.Kernel.Failures;
+namespace Stellar.Kernel.FailureSystem;
///
/// How serious a failure is: a fixed scale, from the least to the most serious, so levels compare.
diff --git a/Kernel/src/Managed/Stellar.Kernel/Failures/IFailureSystem.cs b/Kernel/src/Managed/Stellar.Kernel/FailureSystem/IFailureSystem.cs
similarity index 98%
rename from Kernel/src/Managed/Stellar.Kernel/Failures/IFailureSystem.cs
rename to Kernel/src/Managed/Stellar.Kernel/FailureSystem/IFailureSystem.cs
index 9603310..687c9e0 100644
--- a/Kernel/src/Managed/Stellar.Kernel/Failures/IFailureSystem.cs
+++ b/Kernel/src/Managed/Stellar.Kernel/FailureSystem/IFailureSystem.cs
@@ -2,7 +2,7 @@
using Stellar.Kernel.Data.Catalog;
using Stellar.Kernel.Quantization;
-namespace Stellar.Kernel.Failures;
+namespace Stellar.Kernel.FailureSystem;
///
/// The failures of one engine: what is done about them, and who hears of them.
diff --git a/Kernel/src/Managed/Stellar.Kernel/FileSystem/DomainNotFoundException.cs b/Kernel/src/Managed/Stellar.Kernel/FileSystem/DomainNotFoundException.cs
index e70eb5b..78bb957 100644
--- a/Kernel/src/Managed/Stellar.Kernel/FileSystem/DomainNotFoundException.cs
+++ b/Kernel/src/Managed/Stellar.Kernel/FileSystem/DomainNotFoundException.cs
@@ -1,4 +1,4 @@
-using Stellar.Kernel.Failures;
+using Stellar.Kernel.FailureSystem;
namespace Stellar.Kernel.FileSystem;
diff --git a/Kernel/src/Managed/Stellar.Kernel/Lifecycle/IEngineControl.cs b/Kernel/src/Managed/Stellar.Kernel/Lifecycle/IEngineControl.cs
index 3f4409e..8073b3d 100644
--- a/Kernel/src/Managed/Stellar.Kernel/Lifecycle/IEngineControl.cs
+++ b/Kernel/src/Managed/Stellar.Kernel/Lifecycle/IEngineControl.cs
@@ -1,5 +1,5 @@
using Stellar.Kernel.EntryPoint;
-using Stellar.Kernel.Failures;
+using Stellar.Kernel.FailureSystem;
using Stellar.Kernel.Quantization;
namespace Stellar.Kernel.Lifecycle;
diff --git a/Kernel/src/Managed/Stellar.Kernel/LoggingSystem/ILogger.cs b/Kernel/src/Managed/Stellar.Kernel/LoggingSystem/ILogger.cs
index c7510f6..8018b26 100644
--- a/Kernel/src/Managed/Stellar.Kernel/LoggingSystem/ILogger.cs
+++ b/Kernel/src/Managed/Stellar.Kernel/LoggingSystem/ILogger.cs
@@ -6,7 +6,7 @@ namespace Stellar.Kernel.LoggingSystem;
/// Engine logger
///
public interface ILogger
- : IRegistrableQuant
+ : IQuant
{
///
/// Create log with formatting
@@ -20,4 +20,14 @@ public interface ILogger
///
/// just message to write
void LogWithoutFormat(string message);
+
+ ///
+ /// TODO: summary
+ ///
+ void Start();
+
+ ///
+ /// TODO: summary
+ ///
+ void Stop();
}
diff --git a/Kernel/src/Managed/Stellar.Kernel/LoggingSystem/ILoggerCatalog.cs b/Kernel/src/Managed/Stellar.Kernel/LoggingSystem/ILoggerCatalog.cs
new file mode 100644
index 0000000..690b751
--- /dev/null
+++ b/Kernel/src/Managed/Stellar.Kernel/LoggingSystem/ILoggerCatalog.cs
@@ -0,0 +1,9 @@
+using Stellar.Kernel.Data.Catalog;
+
+namespace Stellar.Kernel.LoggingSystem;
+
+///
+/// TODO: summary
+///
+public interface ILoggerCatalog
+ : ICatalog;
diff --git a/Kernel/src/Managed/Stellar.Kernel/LoggingSystem/LogFormat.cs b/Kernel/src/Managed/Stellar.Kernel/LoggingSystem/LogFormat.cs
new file mode 100644
index 0000000..b611c6a
--- /dev/null
+++ b/Kernel/src/Managed/Stellar.Kernel/LoggingSystem/LogFormat.cs
@@ -0,0 +1,18 @@
+namespace Stellar.Kernel.LoggingSystem;
+
+///
+/// {0} - date yyyy-MMM-dd
+/// {1} - time HH:mm:ss.fff
+/// {2} - engine clock name
+/// {3} - engine clock time HH:mm:ss.fff
+/// {4} - LogLevel
+/// {5} - Engine instance name
+/// {6} - Logger instance name
+/// {7} - Thread ID
+/// {8} - C# Type name
+/// {9} - C# Method name
+/// {10} - message
+///
+/// Format string
+/// Colorized Format string (ASCII)
+public record struct LogFormat(string Format, string? ColorizedFormat = null);
diff --git a/Kernel/src/Managed/Stellar.Kernel/LoggingSystem/LogLevel.cs b/Kernel/src/Managed/Stellar.Kernel/LoggingSystem/LogLevel.cs
index 78f6e54..9957153 100644
--- a/Kernel/src/Managed/Stellar.Kernel/LoggingSystem/LogLevel.cs
+++ b/Kernel/src/Managed/Stellar.Kernel/LoggingSystem/LogLevel.cs
@@ -6,32 +6,32 @@ namespace Stellar.Kernel.LoggingSystem;
public enum LogLevel
{
///
- /// Any Information
+ /// Debug message or information
///
- Info,
+ Debug = 0,
///
- /// Debug message or information
+ /// Any Information
///
- Debug,
+ Info = 1,
///
/// Operation succeed
///
- Success,
+ Success = 2,
///
/// A Warning
///
- Warning,
+ Warning = 3,
///
/// An Error
///
- Error,
+ Error = 4,
///
/// An Exception
///
- Exception
+ Exception = 5
}
diff --git a/Kernel/src/Managed/Stellar.Kernel/LoggingSystem/LoggerExtensions.cs b/Kernel/src/Managed/Stellar.Kernel/LoggingSystem/LoggerExtensions.cs
new file mode 100644
index 0000000..9b75f0e
--- /dev/null
+++ b/Kernel/src/Managed/Stellar.Kernel/LoggingSystem/LoggerExtensions.cs
@@ -0,0 +1,70 @@
+#if NET
+using System;
+
+namespace Stellar.Kernel.LoggingSystem;
+
+///
+/// TODO: summary
+///
+public static class LoggerExtensions
+{
+ ///
+ /// TODO: summary
+ ///
+ public static void Info(this ILogger logger, string message)
+ {
+ logger.Log(LogLevel.Info, message);
+ }
+
+ ///
+ /// TODO: summary
+ ///
+ public static void Debug(this ILogger logger, string message)
+ {
+ logger.Log(LogLevel.Debug, message);
+ }
+
+ ///
+ /// TODO: summary
+ ///
+ public static void Success(this ILogger logger, string message)
+ {
+ logger.Log(LogLevel.Success, message);
+ }
+
+ ///
+ /// TODO: summary
+ ///
+ public static void Warning(this ILogger logger, string message)
+ {
+ logger.Log(LogLevel.Warning, message);
+ }
+
+ ///
+ /// TODO: summary
+ ///
+ public static void Error(this ILogger logger, string message)
+ {
+ logger.Log(LogLevel.Error, message);
+ }
+
+ ///
+ /// TODO: summary
+ ///
+ public static void Exception(this ILogger logger, string message, Exception exception)
+ {
+ logger.Log(LogLevel.Exception,
+ $"{message}\n" +
+ $"{exception}\n" +
+ $"{exception.GetType()}: {exception.Message}");
+ }
+
+ ///
+ /// TODO: summary
+ ///
+ public static void Separator(this ILogger logger)
+ {
+ logger.LogWithoutFormat("");
+ }
+}
+#endif
diff --git a/Kernel/src/Managed/Stellar.Kernel/LoggingSystem/LoggerFormat.cs b/Kernel/src/Managed/Stellar.Kernel/LoggingSystem/LoggerFormat.cs
new file mode 100644
index 0000000..f83eb4b
--- /dev/null
+++ b/Kernel/src/Managed/Stellar.Kernel/LoggingSystem/LoggerFormat.cs
@@ -0,0 +1,195 @@
+using System;
+
+namespace Stellar.Kernel.LoggingSystem;
+
+///
+/// Full logger formats alias
+///
+/// Info log format
+/// Debug log format
+/// Success log format
+/// Warning log format
+/// Error log format
+/// Exception log format
+public readonly record struct LoggerFormat(
+ LogFormat Info,
+ LogFormat Debug,
+ LogFormat Success,
+ LogFormat Warning,
+ LogFormat Error,
+ LogFormat Exception)
+{
+ ///
+ /// Default Logger format
+ ///
+ public static readonly LoggerFormat Default = new(
+ new()
+ {
+ Format = "{0}:{1} | {2}:{3} | {4} | {5}:{6}:{7} : {8}.{9} - {10}",
+ ColorizedFormat = "\e[32m{0}\e[0m" +
+ "\e[31m:\e[0m" +
+ "\e[2;32m{1}\e[0m " +
+ "\e[31m|\e[0m " +
+ "\e[32m{2}\e[0m" +
+ "\e[31m:\e[0m" +
+ "\e[2;32m{3}\e[0m " +
+ "\e[31m|\e[0m " +
+ "\e[1;38m{4}\e[0m " +
+ "\e[31m|\e[0m " +
+ "\e[36m{5}\e[0m" +
+ "\e[31m:\e[0m" +
+ "\e[36m{6}\e[0m " +
+ "\e[31m:\e[0m" +
+ "\e[36m{7}\e[0m " +
+ "\e[31m:\e[0m " +
+ "\e[36m{8}\e[0m " +
+ "\e[31m.\e[0m" +
+ "\e[36m{9}\e[0m " +
+ "\e[31m-\e[0m " +
+ "\e[1;38m{10}\e[0m"
+ },
+ new()
+ {
+ Format = "{0}:{1} | {2}:{3} | {4} | {5}:{6}:{7} : {8}.{9} - {10}",
+ ColorizedFormat = "\e[32m{0}\e[0m" +
+ "\e[31m:\e[0m" +
+ "\e[2;32m{1}\e[0m " +
+ "\e[31m|\e[0m " +
+ "\e[32m{2}\e[0m" +
+ "\e[31m:\e[0m" +
+ "\e[2;32m{3}\e[0m " +
+ "\e[31m|\e[0m " +
+ "\e[1;33m{4}\e[0m " +
+ "\e[31m|\e[0m " +
+ "\e[36m{5}\e[0m" +
+ "\e[31m:\e[0m" +
+ "\e[36m{6}\e[0m " +
+ "\e[31m:\e[0m" +
+ "\e[36m{7}\e[0m " +
+ "\e[31m:\e[0m " +
+ "\e[36m{8}\e[0m " +
+ "\e[31m.\e[0m" +
+ "\e[36m{9}\e[0m " +
+ "\e[31m-\e[0m " +
+ "\e[1;33m{10}\e[0m"
+ },
+ new()
+ {
+ Format = "{0}:{1} | {2}:{3} | {4} | {5}:{6}:{7} : {8}.{9} - {10}",
+ ColorizedFormat = "\e[32m{0}\e[0m" +
+ "\e[31m:\e[0m" +
+ "\e[2;32m{1}\e[0m " +
+ "\e[31m|\e[0m " +
+ "\e[32m{2}\e[0m" +
+ "\e[31m:\e[0m" +
+ "\e[2;32m{3}\e[0m " +
+ "\e[31m|\e[0m " +
+ "\e[1;32m{4}\e[0m " +
+ "\e[31m|\e[0m " +
+ "\e[36m{5}\e[0m" +
+ "\e[31m:\e[0m" +
+ "\e[36m{6}\e[0m " +
+ "\e[31m:\e[0m" +
+ "\e[36m{7}\e[0m " +
+ "\e[31m:\e[0m " +
+ "\e[36m{8}\e[0m " +
+ "\e[31m.\e[0m" +
+ "\e[36m{9}\e[0m " +
+ "\e[31m-\e[0m " +
+ "\e[1;32m{10}\e[0m"
+ },
+ new()
+ {
+ Format = "{0}:{1} | {2}:{3} | {4} | {5}:{6}:{7} : {8}.{9} - {10}",
+ ColorizedFormat = "\e[32m{0}\e[0m" +
+ "\e[31m:\e[0m" +
+ "\e[2;32m{1}\e[0m " +
+ "\e[31m|\e[0m " +
+ "\e[32m{2}\e[0m" +
+ "\e[31m:\e[0m" +
+ "\e[2;32m{3}\e[0m " +
+ "\e[31m|\e[0m " +
+ "\e[1;34m{4}\e[0m " +
+ "\e[31m|\e[0m " +
+ "\e[36m{5}\e[0m" +
+ "\e[31m:\e[0m" +
+ "\e[36m{6}\e[0m " +
+ "\e[31m:\e[0m" +
+ "\e[36m{7}\e[0m " +
+ "\e[31m:\e[0m " +
+ "\e[36m{8}\e[0m " +
+ "\e[31m.\e[0m" +
+ "\e[36m{9}\e[0m " +
+ "\e[31m-\e[0m " +
+ "\e[1;34m{10}\e[0m"
+ },
+ new()
+ {
+ Format = "{0}:{1} | {2}:{3} | {4} | {5}:{6}:{7} : {8}.{9} - {10}",
+ ColorizedFormat = "\e[32m{0}\e[0m" +
+ "\e[31m:\e[0m" +
+ "\e[2;32m{1}\e[0m " +
+ "\e[31m|\e[0m " +
+ "\e[32m{2}\e[0m" +
+ "\e[31m:\e[0m" +
+ "\e[2;32m{3}\e[0m " +
+ "\e[31m|\e[0m " +
+ "\e[1;31m{4}\e[0m " +
+ "\e[31m|\e[0m " +
+ "\e[36m{5}\e[0m" +
+ "\e[31m:\e[0m" +
+ "\e[36m{6}\e[0m" +
+ "\e[31m:\e[0m" +
+ "\e[36m{7}\e[0m " +
+ "\e[31m:\e[0m " +
+ "\e[36m{8}\e[0m " +
+ "\e[31m.\e[0m" +
+ "\e[36m{9}\e[0m " +
+ "\e[31m-\e[0m " +
+ "\e[1;38m{10}\e[0m"
+ },
+ new()
+ {
+ Format = "{0}:{1} | {2}:{3} | {4} | {5}:{6}:{7} : {8}.{9} - {10}",
+ ColorizedFormat = "\e[32m{0}\e[0m" +
+ "\e[31m:\e[0m" +
+ "\e[2;32m{1}\e[0m " +
+ "\e[31m|\e[0m " +
+ "\e[32m{2}\e[0m" +
+ "\e[31m:\e[0m" +
+ "\e[2;32m{3}\e[0m " +
+ "\e[31m|\e[0m " +
+ "\e[1;31m{4}\e[0m " +
+ "\e[31m|\e[0m " +
+ "\e[36m{5}\e[0m" +
+ "\e[31m:\e[0m" +
+ "\e[36m{6}\e[0m " +
+ "\e[31m:\e[0m" +
+ "\e[36m{7}\e[0m " +
+ "\e[31m:\e[0m " +
+ "\e[36m{8}\e[0m " +
+ "\e[31m.\e[0m" +
+ "\e[36m{9}\e[0m " +
+ "\e[31m-\e[0m " +
+ "\e[1;31m{10}\e[0m"
+ }
+ );
+
+ ///
+ /// Gets LogFormat for a LogLevel
+ ///
+ /// Log level
+ /// a LogFormat for given LogLevel
+ /// if LogLevel is out of LogLevel enum
+ public LogFormat ForLevel(LogLevel level) => level switch
+ {
+ LogLevel.Info => Info,
+ LogLevel.Debug => Debug,
+ LogLevel.Success => Success,
+ LogLevel.Warning => Warning,
+ LogLevel.Error => Error,
+ LogLevel.Exception => Exception,
+ _ => throw new ArgumentException("LoggerFormat.ForLevel operate only levels writen in LogLevel enum",
+ nameof(level), null)
+ };
+}
diff --git a/Kernel/src/Managed/Stellar.Kernel/Stellar.Kernel.csproj b/Kernel/src/Managed/Stellar.Kernel/Stellar.Kernel.csproj
index f1e78ac..3c5ce23 100644
--- a/Kernel/src/Managed/Stellar.Kernel/Stellar.Kernel.csproj
+++ b/Kernel/src/Managed/Stellar.Kernel/Stellar.Kernel.csproj
@@ -24,7 +24,7 @@
-
+
diff --git a/README.md b/README.md
index e6c5331..b486cca 100644
--- a/README.md
+++ b/README.md
@@ -141,5 +141,6 @@ Reference:
Workflow:
- [Contributing](CONTRIBUTING.md), [Git policy](Docs/Engine/GitPolicy.md), [versioning](Docs/Engine/Versioning.md)
+- [Migrating to 0.10](Docs/Migration-0.10.md)
- [Migrating to 0.9](Docs/Migration-0.9.md)
- [Migrating modules to 0.8](Docs/Migration-0.8.md)
diff --git a/Runtime/src/Managed/Stellar.Runtime/Failures/RuntimeCatchers.cs b/Runtime/src/Managed/Stellar.Runtime/Failures/RuntimeCatchers.cs
index 1083dbd..90796ff 100644
--- a/Runtime/src/Managed/Stellar.Runtime/Failures/RuntimeCatchers.cs
+++ b/Runtime/src/Managed/Stellar.Runtime/Failures/RuntimeCatchers.cs
@@ -1,4 +1,4 @@
-using Stellar.Kernel.Failures;
+using Stellar.Kernel.FailureSystem;
using Stellar.Runtime.Diagnostics;
namespace Stellar.Runtime.Failures;
diff --git a/Runtime/src/Managed/Stellar.Runtime/Lifecycle/Contexts.cs b/Runtime/src/Managed/Stellar.Runtime/Lifecycle/Contexts.cs
index 9a903bf..f202208 100644
--- a/Runtime/src/Managed/Stellar.Runtime/Lifecycle/Contexts.cs
+++ b/Runtime/src/Managed/Stellar.Runtime/Lifecycle/Contexts.cs
@@ -1,5 +1,5 @@
using Stellar.Kernel.EntryPoint;
-using Stellar.Kernel.Failures;
+using Stellar.Kernel.FailureSystem;
using Stellar.Kernel.Lifecycle;
using Stellar.Kernel.LoggingSystem;
using Stellar.Kernel.Quantization;
diff --git a/Runtime/src/Managed/Stellar.Runtime/Lifecycle/EngineControl.cs b/Runtime/src/Managed/Stellar.Runtime/Lifecycle/EngineControl.cs
index 87579de..bff1707 100644
--- a/Runtime/src/Managed/Stellar.Runtime/Lifecycle/EngineControl.cs
+++ b/Runtime/src/Managed/Stellar.Runtime/Lifecycle/EngineControl.cs
@@ -1,5 +1,5 @@
using Stellar.Kernel.EntryPoint;
-using Stellar.Kernel.Failures;
+using Stellar.Kernel.FailureSystem;
using Stellar.Kernel.Lifecycle;
namespace Stellar.Runtime.Lifecycle;
diff --git a/Runtime/src/Managed/Stellar.Runtime/Lifecycle/ModuleStarter.cs b/Runtime/src/Managed/Stellar.Runtime/Lifecycle/ModuleStarter.cs
index 039ec14..92cc1fc 100644
--- a/Runtime/src/Managed/Stellar.Runtime/Lifecycle/ModuleStarter.cs
+++ b/Runtime/src/Managed/Stellar.Runtime/Lifecycle/ModuleStarter.cs
@@ -2,7 +2,7 @@
using System.Runtime.ExceptionServices;
using Stellar.Kernel.Configuration;
using Stellar.Kernel.EntryPoint;
-using Stellar.Kernel.Failures;
+using Stellar.Kernel.FailureSystem;
using Stellar.Kernel.Lifecycle;
using Stellar.Kernel.LoggingSystem;
using Stellar.Kernel.Services;
diff --git a/Runtime/src/Managed/Stellar.Runtime/Lifecycle/RuntimeContext.cs b/Runtime/src/Managed/Stellar.Runtime/Lifecycle/RuntimeContext.cs
index 152d737..bbbdc7e 100644
--- a/Runtime/src/Managed/Stellar.Runtime/Lifecycle/RuntimeContext.cs
+++ b/Runtime/src/Managed/Stellar.Runtime/Lifecycle/RuntimeContext.cs
@@ -1,5 +1,5 @@
using Stellar.Kernel.Configuration;
-using Stellar.Kernel.Failures;
+using Stellar.Kernel.FailureSystem;
using Stellar.Kernel.Lifecycle;
using Stellar.Kernel.LoggingSystem;
using Stellar.Kernel.Quantization;
diff --git a/Runtime/src/Managed/Stellar.Runtime/Lifecycle/RuntimePipeline.cs b/Runtime/src/Managed/Stellar.Runtime/Lifecycle/RuntimePipeline.cs
index a619741..77f9b3b 100644
--- a/Runtime/src/Managed/Stellar.Runtime/Lifecycle/RuntimePipeline.cs
+++ b/Runtime/src/Managed/Stellar.Runtime/Lifecycle/RuntimePipeline.cs
@@ -1,4 +1,4 @@
-using Stellar.Kernel.Failures;
+using Stellar.Kernel.FailureSystem;
using Stellar.Kernel.Lifecycle;
using Stellar.Kernel.Profiling;
diff --git a/Runtime/src/Managed/Stellar.Runtime/Loop/MainLoop.cs b/Runtime/src/Managed/Stellar.Runtime/Loop/MainLoop.cs
index 8d76562..8dc05bd 100644
--- a/Runtime/src/Managed/Stellar.Runtime/Loop/MainLoop.cs
+++ b/Runtime/src/Managed/Stellar.Runtime/Loop/MainLoop.cs
@@ -1,5 +1,5 @@
using Stellar.Kernel.EntryPoint;
-using Stellar.Kernel.Failures;
+using Stellar.Kernel.FailureSystem;
using Stellar.Kernel.Lifecycle;
using Stellar.Kernel.Profiling;
using Stellar.Kernel.Quantization;
diff --git a/Runtime/src/Managed/Stellar.Runtime/Loop/MainLoops.cs b/Runtime/src/Managed/Stellar.Runtime/Loop/MainLoops.cs
index 07fa0b0..f526699 100644
--- a/Runtime/src/Managed/Stellar.Runtime/Loop/MainLoops.cs
+++ b/Runtime/src/Managed/Stellar.Runtime/Loop/MainLoops.cs
@@ -1,4 +1,4 @@
-using Stellar.Kernel.Failures;
+using Stellar.Kernel.FailureSystem;
using Stellar.Kernel.Lifecycle;
using Stellar.Runtime.Failures;
using Stellar.Runtime.Lifecycle;
diff --git a/Runtime/src/Managed/Stellar.Runtime/Threading/MainThreadDispatcher.cs b/Runtime/src/Managed/Stellar.Runtime/Threading/MainThreadDispatcher.cs
index 49b4aba..fa58b44 100644
--- a/Runtime/src/Managed/Stellar.Runtime/Threading/MainThreadDispatcher.cs
+++ b/Runtime/src/Managed/Stellar.Runtime/Threading/MainThreadDispatcher.cs
@@ -1,5 +1,5 @@
-using Stellar.Kernel.Failures;
using System.Collections.Concurrent;
+using Stellar.Kernel.FailureSystem;
using Stellar.Kernel.Threading;
using Stellar.Runtime.Failures;
diff --git a/Runtime/src/Managed/Stellar.Runtime/Threading/MainThreadPump.cs b/Runtime/src/Managed/Stellar.Runtime/Threading/MainThreadPump.cs
index df15c84..456cc63 100644
--- a/Runtime/src/Managed/Stellar.Runtime/Threading/MainThreadPump.cs
+++ b/Runtime/src/Managed/Stellar.Runtime/Threading/MainThreadPump.cs
@@ -1,4 +1,4 @@
-using Stellar.Kernel.Failures;
+using Stellar.Kernel.FailureSystem;
using Stellar.Runtime.Failures;
namespace Stellar.Runtime.Threading;
diff --git a/Runtime/tests/Fixtures/Stellar.Runtime.Tests.Host/HostEntryPoint.cs b/Runtime/tests/Fixtures/Stellar.Runtime.Tests.Host/HostEntryPoint.cs
index 881aef0..7ffb32c 100644
--- a/Runtime/tests/Fixtures/Stellar.Runtime.Tests.Host/HostEntryPoint.cs
+++ b/Runtime/tests/Fixtures/Stellar.Runtime.Tests.Host/HostEntryPoint.cs
@@ -2,7 +2,7 @@
using Stellar.Kernel.Configuration;
using Stellar.Kernel.Data.Catalog;
using Stellar.Kernel.EntryPoint;
-using Stellar.Kernel.Failures;
+using Stellar.Kernel.FailureSystem;
using Stellar.Kernel.Lifecycle;
using Stellar.Kernel.Quantization;
using Stellar.Kernel.Services;
diff --git a/Runtime/tests/Stellar.Runtime.Tests/MainLoopTests.cs b/Runtime/tests/Stellar.Runtime.Tests/MainLoopTests.cs
index 8f843d9..e7d6b27 100644
--- a/Runtime/tests/Stellar.Runtime.Tests/MainLoopTests.cs
+++ b/Runtime/tests/Stellar.Runtime.Tests/MainLoopTests.cs
@@ -1,6 +1,6 @@
-using Stellar.Kernel.Failures;
using Stellar.Kernel;
using Stellar.Kernel.EntryPoint;
+using Stellar.Kernel.FailureSystem;
using Stellar.Kernel.Lifecycle;
using Stellar.Kernel.Profiling;
using Stellar.Kernel.Quantization;
diff --git a/SDK/src/MSBuild/Stellar.Sdk/Sdk/Stellar.Sdk.Catalog.targets b/SDK/src/MSBuild/Stellar.Sdk/Sdk/Stellar.Sdk.Catalog.targets
index fefe3f5..eb68c01 100644
--- a/SDK/src/MSBuild/Stellar.Sdk/Sdk/Stellar.Sdk.Catalog.targets
+++ b/SDK/src/MSBuild/Stellar.Sdk/Sdk/Stellar.Sdk.Catalog.targets
@@ -25,4 +25,8 @@
+
+
+
diff --git a/SDK/src/MSBuild/Stellar.Sdk/Sdk/Stellar.Sdk.Environment.props b/SDK/src/MSBuild/Stellar.Sdk/Sdk/Stellar.Sdk.Environment.props
index ad7ecbd..ab48837 100644
--- a/SDK/src/MSBuild/Stellar.Sdk/Sdk/Stellar.Sdk.Environment.props
+++ b/SDK/src/MSBuild/Stellar.Sdk/Sdk/Stellar.Sdk.Environment.props
@@ -34,6 +34,16 @@
$(StellarRoot)manifests/.generated/stellar.modules.props
+
+
+ <_StellarSolutionCatalogAbove>$([MSBuild]::GetDirectoryNameOfFileAbove('$(MSBuildProjectDirectory)', '.stellar/stellar.modules.props'))
+ $([MSBuild]::EnsureTrailingSlash('$(_StellarSolutionCatalogAbove)')).stellar/stellar.modules.props
+
+
- <_StellarCanCheckCatalog Condition="'$(StellarIsModule)' == 'true' and Exists('$(StellarModuleDescriptorFile)') and Exists('$(StellarModuleCatalog)')">true
+
+ <_StellarCatalogOfModule>$(StellarModuleCatalogFile)
+ <_StellarCatalogOfModule Condition="'$(_StellarCatalogOfModule)' == ''">$(StellarModuleCatalog)
+ stellar modules sync
+ <_StellarCanCheckCatalog Condition="'$(StellarIsModule)' == 'true' and Exists('$(StellarModuleDescriptorFile)') and Exists('$(_StellarCatalogOfModule)')">true
<_StellarDescriptorTicks Condition="'$(_StellarCanCheckCatalog)' == 'true'">$([System.IO.File]::GetLastWriteTime('$(StellarModuleDescriptorFile)').Ticks)
- <_StellarCatalogTicks Condition="'$(_StellarCanCheckCatalog)' == 'true'">$([System.IO.File]::GetLastWriteTime('$(StellarModuleCatalog)').Ticks)
+ <_StellarCatalogTicks Condition="'$(_StellarCanCheckCatalog)' == 'true'">$([System.IO.File]::GetLastWriteTime('$(_StellarCatalogOfModule)').Ticks)
<_StellarCatalogStale Condition="'$(_StellarCanCheckCatalog)' == 'true' and $(_StellarDescriptorTicks) > $(_StellarCatalogTicks)">true
@@ -25,9 +29,9 @@
Text="StellarSdkUsage=EngineCore is Stellar.Core itself. A core system is EngineCoreModule."/>
+ Text="$(_StellarDescriptorAbove)$(StellarModuleId).stellar.module describes this project, but the module catalog does not know it yet: run 'stellar modules sync' (a module of the installation) or 'stellar solution sync' (a module of a solution)."/>
+ Text="$(StellarModuleDescriptorFile) changed after the module catalog was generated: run '$(StellarModuleSyncCommand)'."/>
-/// stellar solution sync: writes the .sln again, after a project was added or "Engine" switched.
+/// stellar solution sync: writes the catalog of the modules of the solution, then the .sln again, after a
+/// project or a module was added or "Engine" switched.
///
public sealed class SyncSolutionCommand
: Command
@@ -31,6 +32,9 @@ public override int Execute(CommandContext context, SyncSolutionSettings setting
?? throw new ToolException($"No {StellarSolution.Extension} in {directory} or above it");
var home = StellarInstallation.Locate();
+
+ // First: the references of the projects are read with this catalog
+ SolutionModules.Sync(solution, home, ConsoleToolLogger.Instance);
var path = solution.Sync(new SolutionGenerator(home.Root, new MSBuildProjectReferenceReader(), ConsoleToolLogger.Instance));
AnsiConsole.MarkupLine($"[green]Solution written:[/] {path.EscapeMarkup()} [grey](engine: {(solution.File.Engine ?? "Packages").EscapeMarkup()})[/]");
diff --git a/SDK/src/Stellar.Tools/Modules/ModuleCatalogGenerator.cs b/SDK/src/Stellar.Tools/Modules/ModuleCatalogGenerator.cs
index 9d7cd86..75094a1 100644
--- a/SDK/src/Stellar.Tools/Modules/ModuleCatalogGenerator.cs
+++ b/SDK/src/Stellar.Tools/Modules/ModuleCatalogGenerator.cs
@@ -27,7 +27,9 @@ public static class ModuleCatalogGenerator
///
/// The enabled modules.
/// The text of the MSBuild file.
- public static string Render(IEnumerable modules)
+ /// What the file was generated from, for its header.
+ public static string Render(IEnumerable modules,
+ string origin = "'stellar modules sync' from the module descriptors and manifests/engine.manifest.json")
{
var sorted = modules.OrderBy(module => module.Id, System.StringComparer.Ordinal).ToList();
var project = new XElement("Project");
@@ -59,6 +61,9 @@ public static string Render(IEnumerable modules)
var group = new XElement("PropertyGroup",
new XAttribute("Condition", $"'$(StellarModuleId)' == '{module.Id}'"),
new XElement("StellarModuleKnown", "true"),
+ Fill("StellarModuleCatalogFile", "$(MSBuildThisFileFullPath)"),
+ Fill("StellarModuleSyncCommand",
+ module.Source == ModuleSource.Solution ? "stellar solution sync" : "stellar modules sync"),
Fill("StellarModuleLevel", module.Descriptor.Level.ToString()),
Fill("StellarModuleVersion", module.Descriptor.Version ?? string.Empty),
Fill("StellarModuleDependencies", string.Join(";", module.Descriptor.Dependencies)),
@@ -81,8 +86,7 @@ public static string Render(IEnumerable modules)
}
var document = new XDocument(
- new XComment(
- " Generated by 'stellar modules sync' from the module descriptors and manifests/engine.manifest.json. Do not edit. "),
+ new XComment($" Generated by {origin}. Do not edit. "),
project);
return document + "\n";
diff --git a/SDK/src/Stellar.Tools/Modules/ModuleDiscovery.cs b/SDK/src/Stellar.Tools/Modules/ModuleDiscovery.cs
index 9fac67a..cf5a412 100644
--- a/SDK/src/Stellar.Tools/Modules/ModuleDiscovery.cs
+++ b/SDK/src/Stellar.Tools/Modules/ModuleDiscovery.cs
@@ -23,10 +23,21 @@ public static IReadOnlyList Discover(StellarInstallation installation, M
if (!settings.Enabled)
return new string[0];
+ return Discover(settings.Directories.Select(installation.Resolve), settings.Depth);
+ }
+
+ ///
+ /// Finds the descriptor files below some folders: the search of an installation, and of a solution.
+ ///
+ /// The folders to search; those that do not exist are skipped.
+ /// How many levels below each folder a module may be.
+ /// The descriptor files, sorted.
+ public static IReadOnlyList Discover(IEnumerable directories, int depth)
+ {
var found = new List();
- foreach (var directory in settings.Directories.Select(installation.Resolve).Where(Directory.Exists))
- Search(directory, settings.Depth, found);
+ foreach (var directory in directories.Where(Directory.Exists))
+ Search(directory, depth, found);
return found.Distinct().OrderBy(path => path, System.StringComparer.Ordinal).ToList();
}
@@ -38,7 +49,11 @@ private static void Search(string directory, int depth, List found)
foreach (var child in Directory.GetDirectories(directory).OrderBy(path => path, System.StringComparer.Ordinal))
{
- if (Path.GetFileName(child).StartsWith("."))
+ var name = Path.GetFileName(child);
+
+ // Hidden folders and build output hold no modules of theirs
+ if (name.StartsWith(".") || name.Equals("bin", System.StringComparison.OrdinalIgnoreCase) ||
+ name.Equals("obj", System.StringComparison.OrdinalIgnoreCase))
continue;
var descriptor = ModuleDescriptorFile.Find(child);
diff --git a/SDK/src/Stellar.Tools/Modules/ModuleResolver.cs b/SDK/src/Stellar.Tools/Modules/ModuleResolver.cs
index ea86c45..3f11785 100644
--- a/SDK/src/Stellar.Tools/Modules/ModuleResolver.cs
+++ b/SDK/src/Stellar.Tools/Modules/ModuleResolver.cs
@@ -181,7 +181,7 @@ private static ModuleDescriptor Apply(ModuleDescriptor descriptor, ModuleOverrid
return descriptor;
}
- private static void ApplyConventions(ModuleDescriptor descriptor, string directory)
+ internal static void ApplyConventions(ModuleDescriptor descriptor, string directory)
{
descriptor.Version ??= StellarVersions.Engine;
descriptor.Project ??= ModuleConventions.FindManagedProject(directory, descriptor.Id) ?? string.Empty;
@@ -189,7 +189,7 @@ private static void ApplyConventions(ModuleDescriptor descriptor, string directo
descriptor.TestProjects ??= ModuleConventions.FindTestProjects(directory);
}
- private static ModuleDescriptor Copy(ModuleDescriptor source)
+ internal static ModuleDescriptor Copy(ModuleDescriptor source)
{
return new ModuleDescriptor
{
diff --git a/SDK/src/Stellar.Tools/Modules/ResolvedModule.cs b/SDK/src/Stellar.Tools/Modules/ResolvedModule.cs
index 00ac238..6a54baa 100644
--- a/SDK/src/Stellar.Tools/Modules/ResolvedModule.cs
+++ b/SDK/src/Stellar.Tools/Modules/ResolvedModule.cs
@@ -17,7 +17,10 @@ public enum ModuleSource
External,
/// Declared by the manifest only: the module exists as a package.
- Package
+ Package,
+
+ /// A module of a solution (level EndPoint), found by stellar solution sync beside the game.
+ Solution
}
///
diff --git a/SDK/src/Stellar.Tools/Solutions/SolutionModules.cs b/SDK/src/Stellar.Tools/Solutions/SolutionModules.cs
new file mode 100644
index 0000000..61fabf5
--- /dev/null
+++ b/SDK/src/Stellar.Tools/Solutions/SolutionModules.cs
@@ -0,0 +1,160 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using Stellar.Kernel.Configuration.Manifest;
+using Stellar.Kernel.Modules;
+using Stellar.Tools.Diagnostics;
+using Stellar.Tools.Environment;
+using Stellar.Tools.Modules;
+
+namespace Stellar.Tools.Solutions;
+
+///
+/// The modules of a solution: the libraries of a game, found beside it and put into a catalog of their own, so that
+/// the game names them as it names any module of the engine.
+///
+///
+/// A module of a solution is a folder with a <Id>.stellar.module file, as everywhere: found below the
+/// directory of the solution, or listed in Modules of the .stellar.solution file. It is a custom module,
+/// level (StellarSdkUsage Module), and depends only on modules of
+/// lower levels, those of the installation included.
+/// The catalog is .stellar/stellar.modules.props in the solution, the format of the catalog of the
+/// installation. The SDK imports it after that one. Modules of a game are never packed, so they are always taken as
+/// sources.
+///
+public static class SolutionModules
+{
+ /// The folder of the generated files of a solution.
+ public const string CatalogFolder = ".stellar";
+
+ /// The file name of the catalog.
+ public const string CatalogFileName = "stellar.modules.props";
+
+ /// The version of a module whose descriptor has none.
+ public const string DefaultVersion = "1.0.0";
+
+ private const int SearchDepth = 3;
+
+ ///
+ /// Gets the path of the catalog of a solution.
+ ///
+ /// The directory of the solution.
+ /// The path; the file may not exist.
+ public static string CatalogPath(string solutionDirectory)
+ {
+ return Path.Combine(solutionDirectory, CatalogFolder, CatalogFileName);
+ }
+
+ ///
+ /// Finds the modules of a solution and checks them against the modules of the installation.
+ ///
+ /// The solution.
+ /// The modules of the installation, which the new ones may depend on.
+ /// The modules of the solution, sorted by identifier.
+ /// Thrown if a module breaks the rules.
+ public static IReadOnlyList Resolve(
+ StellarSolution solution, IReadOnlyCollection installationModules)
+ {
+ var errors = new List();
+ var files = new List(ModuleDiscovery.Discover([solution.Directory], SearchDepth));
+
+ foreach (var entry in solution.File.Modules.Where(entry => !string.IsNullOrWhiteSpace(entry)))
+ {
+ var directory = Path.GetFullPath(Path.Combine(solution.Directory, entry));
+ var file = ModuleDescriptorFile.Find(directory);
+
+ if (file is null)
+ errors.Add($"{StellarSolution.Extension}: {entry} has no module descriptor ({directory})");
+ else if (!files.Contains(file, StringComparer.OrdinalIgnoreCase))
+ files.Add(file);
+ }
+
+ var modules = new List();
+
+ foreach (var file in files)
+ {
+ ModuleDescriptor descriptor;
+ try
+ {
+ descriptor = ModuleResolver.Copy(ModuleDescriptorFile.Read(file));
+ }
+ catch (ToolException exception)
+ {
+ errors.Add(exception.Message);
+ continue;
+ }
+
+ var directory = Path.GetDirectoryName(file)!;
+
+ if (descriptor.Level != ModuleLevel.EndPoint)
+ {
+ errors.Add($"{descriptor.Id}: a module of a solution is a custom module, level {ModuleLevel.EndPoint}, " +
+ $"not {descriptor.Level} ({file})");
+ continue;
+ }
+
+ descriptor.Version ??= DefaultVersion;
+ ModuleResolver.ApplyConventions(descriptor, directory);
+
+ // The core is implicit, as for the modules of the installation
+ descriptor.Dependencies = descriptor.Dependencies
+ .Where(dependency => !ModuleResolver.CoreModules.Contains(dependency)).ToArray();
+
+ var module = new ResolvedModule(descriptor, directory, ModuleSource.Solution, ModuleLink.Sources);
+
+ if (module.ProjectPath is not { } project)
+ errors.Add($"{descriptor.Id}: no managed project found in {directory}");
+ else if (!File.Exists(project))
+ errors.Add($"{descriptor.Id}: the project {project} does not exist");
+
+ modules.Add(module);
+ }
+
+ if (errors.Count == 0)
+ {
+ var graph = ModuleGraph.Analyze(installationModules.Concat(modules).Select(module => module.Descriptor));
+ errors.AddRange(graph.Errors);
+ }
+
+ if (errors.Count != 0)
+ throw new ToolException(
+ $"The modules of {solution.Name} are inconsistent:\n {string.Join("\n ", errors)}");
+
+ return modules.OrderBy(module => module.Id, StringComparer.Ordinal).ToList();
+ }
+
+ ///
+ /// Finds the modules of a solution and writes their catalog; with none, an old catalog is removed.
+ ///
+ /// The solution.
+ /// The installation the modules are built against.
+ /// The output.
+ /// The modules of the solution.
+ /// Thrown if the modules of the installation or the solution break the rules.
+ public static IReadOnlyList Sync(
+ StellarSolution solution, StellarInstallation installation, IToolLogger logger)
+ {
+ var modules = Resolve(solution, ModuleSynchronizer.Load(installation).LoadOrder);
+ var path = CatalogPath(solution.Directory);
+
+ if (modules.Count == 0)
+ {
+ if (File.Exists(path))
+ {
+ File.Delete(path);
+ logger.Info($"No modules in {solution.Name}: {path} removed");
+ }
+
+ return modules;
+ }
+
+ var text = ModuleCatalogGenerator.Render(modules, "'stellar solution sync' from the module descriptors of the solution");
+ if (FileWriter.WriteAllText(path, text))
+ logger.Info($"Module catalog of the solution updated: {modules.Count} module(s), {path}");
+ else
+ logger.Verbose("Module catalog of the solution is up to date");
+
+ return modules;
+ }
+}
diff --git a/SDK/src/Stellar.Tools/Solutions/StellarSolution.cs b/SDK/src/Stellar.Tools/Solutions/StellarSolution.cs
index 2abbba5..bd0a88c 100644
--- a/SDK/src/Stellar.Tools/Solutions/StellarSolution.cs
+++ b/SDK/src/Stellar.Tools/Solutions/StellarSolution.cs
@@ -23,6 +23,12 @@ public sealed class StellarSolutionFile
/// Gets or sets how stellar run runs the solution.
///
public RunConfiguration? Run { get; set; }
+
+ ///
+ /// Gets or sets folders of modules of the solution outside its directory, relative to it. The modules below the
+ /// directory of the solution are found without being listed.
+ ///
+ public List Modules { get; set; } = [];
}
///
diff --git a/SDK/tests/Stellar.Tools.Tests/SolutionModulesTests.cs b/SDK/tests/Stellar.Tools.Tests/SolutionModulesTests.cs
new file mode 100644
index 0000000..d579603
--- /dev/null
+++ b/SDK/tests/Stellar.Tools.Tests/SolutionModulesTests.cs
@@ -0,0 +1,131 @@
+using Stellar.Kernel.Configuration.Manifest;
+using Stellar.Kernel.Modules;
+using Stellar.Tools.Diagnostics;
+using Stellar.Tools.Environment;
+using Stellar.Tools.Modules;
+using Stellar.Tools.Solutions;
+
+namespace Stellar.Tools.Tests;
+
+public class SolutionModulesTests
+{
+ private static readonly ResolvedModule[] Installed =
+ [
+ new(new ModuleDescriptor { Id = "Stellar.FileSystem", Level = ModuleLevel.CoreModule, Version = "0.9.0" },
+ null, ModuleSource.Discovered, ModuleLink.Default)
+ ];
+
+ private static StellarSolution Solution(TempDirectory directory, string json = "{}")
+ {
+ directory.Write("Game.stellar.solution", json);
+ return StellarSolution.Find(directory.Path)!;
+ }
+
+ private static void Module(TempDirectory directory, string folder, string id, string json = "")
+ {
+ var body = json.Length == 0 ? string.Empty : ", " + json;
+ directory.Write($"{folder}/{id}.stellar.module", $$"""{ "Id": "{{id}}", "Level": "EndPoint"{{body}} }""");
+ directory.Write($"{folder}/{id}.csproj", "");
+ }
+
+ [Fact]
+ public void AModuleBesideTheGame_IsFound_AsACustomModuleTakenFromSources()
+ {
+ using var directory = new TempDirectory();
+ directory.Write("Game/Game.csproj", "");
+ Module(directory, "GameLib", "GameLib");
+ directory.Write("GameLib/bin/Debug/Copy.stellar.module", """{ "Id": "Copy" }""");
+
+ var module = SolutionModules.Resolve(Solution(directory), Installed).Should().ContainSingle().Subject;
+
+ module.Id.Should().Be("GameLib");
+ module.Source.Should().Be(ModuleSource.Solution);
+ module.Link.Should().Be(ModuleLink.Sources);
+ module.Descriptor.Version.Should().Be(SolutionModules.DefaultVersion);
+ module.ProjectPath.Should().EndWith(Path.Combine("GameLib", "GameLib.csproj"));
+ }
+
+ [Fact]
+ public void AModuleOutsideTheDirectory_IsFound_WhenTheSolutionListsIt()
+ {
+ using var directory = new TempDirectory();
+ directory.Write("game/Game.stellar.solution", """{ "Modules": ["../shared/Lib"] }""");
+ Module(directory, "shared/Lib", "Lib");
+ var solution = StellarSolution.Find(Path.Combine(directory.Path, "game"))!;
+
+ SolutionModules.Resolve(solution, Installed).Select(module => module.Id).Should().Equal("Lib");
+ }
+
+ [Fact]
+ public void AListedFolderWithoutADescriptor_IsAnError()
+ {
+ using var directory = new TempDirectory();
+ var solution = Solution(directory, """{ "Modules": ["Nothing"] }""");
+ Directory.CreateDirectory(Path.Combine(directory.Path, "Nothing"));
+
+ var action = () => SolutionModules.Resolve(solution, Installed);
+
+ action.Should().Throw().WithMessage("*Nothing*no module descriptor*");
+ }
+
+ [Fact]
+ public void AModule_OfAnotherLevel_IsRefused()
+ {
+ using var directory = new TempDirectory();
+ directory.Write("Lib/Lib.stellar.module", """{ "Id": "Lib", "Level": "HighLevel" }""");
+ directory.Write("Lib/Lib.csproj", "");
+
+ var action = () => SolutionModules.Resolve(Solution(directory), Installed);
+
+ action.Should().Throw().WithMessage("*Lib*EndPoint*HighLevel*");
+ }
+
+ [Fact]
+ public void AModule_MayDependOnAModuleOfTheInstallation_AndTheCoreIsImplicit()
+ {
+ using var directory = new TempDirectory();
+ Module(directory, "Lib", "Lib", """ "Dependencies": ["Stellar.FileSystem", "Stellar.Kernel", "Stellar.Core"] """);
+
+ var module = SolutionModules.Resolve(Solution(directory), Installed).Single();
+
+ module.Descriptor.Dependencies.Should().Equal("Stellar.FileSystem");
+ }
+
+ [Fact]
+ public void AnUnknownDependency_AndAnIdOfTheInstallation_AreRefused()
+ {
+ using var unknown = new TempDirectory();
+ Module(unknown, "Lib", "Lib", """ "Dependencies": ["Nope"] """);
+ using var twice = new TempDirectory();
+ Module(twice, "Lib", "Stellar.FileSystem");
+
+ var first = () => SolutionModules.Resolve(Solution(unknown), Installed);
+ var second = () => SolutionModules.Resolve(Solution(twice), Installed);
+
+ first.Should().Throw().WithMessage("*unknown module Nope*");
+ second.Should().Throw().WithMessage("*Stellar.FileSystem*twice*");
+ }
+
+ [Fact]
+ public void Sync_WritesTheCatalog_AndRemovesItWhenTheModulesAreGone()
+ {
+ using var directory = new TempDirectory();
+ var installation = FakeCore.Installed(directory);
+ directory.Write("game/Game.stellar.solution", "{}");
+ Module(directory, "game/GameLib", "GameLib");
+ var solution = StellarSolution.Find(Path.Combine(directory.Path, "game"))!;
+ var catalog = SolutionModules.CatalogPath(solution.Directory);
+
+ SolutionModules.Sync(solution, installation, NullToolLogger.Instance);
+
+ var text = File.ReadAllText(catalog);
+ text.Should().Contain("Include=\"GameLib\"").And.Contain("LinkMode=\"Sources\"")
+ .And.Contain("Source=\"Solution\"").And.Contain("Level=\"EndPoint\"")
+ .And.Contain("stellar solution sync").And.Contain("$(MSBuildThisFileFullPath)");
+
+ File.Delete(Path.Combine(directory.Path, "game", "GameLib", "GameLib.stellar.module"));
+ SolutionModules.Sync(solution, installation, NullToolLogger.Instance);
+
+ File.Exists(catalog).Should().BeFalse();
+ }
+}
diff --git a/Shared/Build/Stellar.Versions.props b/Shared/Build/Stellar.Versions.props
index 5484547..9ed9d35 100644
--- a/Shared/Build/Stellar.Versions.props
+++ b/Shared/Build/Stellar.Versions.props
@@ -7,15 +7,15 @@
-->
- 0.9.0
+ 0.10.0
- 0.9.0
- 0.9.0
- 0.9.0
- 0.3.1
- 0.4.0
- 0.2.2
+ 0.10.0
+ 0.10.0
+ 0.10.0
+ 0.3.2
+ 0.4.1
+ 0.2.3
0.9.0
diff --git a/Shared/Schemas/stellar.solution.schema.json b/Shared/Schemas/stellar.solution.schema.json
index 7a34969..5eb9cd4 100644
--- a/Shared/Schemas/stellar.solution.schema.json
+++ b/Shared/Schemas/stellar.solution.schema.json
@@ -9,6 +9,11 @@
"enum": ["Packages", "Sources"],
"description": "How the projects take the engine: its packages (the default), or its sources in Debug, listed in the solution after 'stellar solution sync'"
},
+ "Modules": {
+ "type": "array",
+ "items": { "type": "string" },
+ "description": "Folders of modules of the solution outside its directory, relative to it. Modules (folders with an .stellar.module file, level EndPoint) below the directory are found without being listed; 'stellar solution sync' writes them into .stellar/stellar.modules.props"
+ },
"Run": {
"type": "object",
"description": "How 'stellar run' runs the solution",
diff --git a/global.json b/global.json
index 5f68d40..e7a2998 100644
--- a/global.json
+++ b/global.json
@@ -5,6 +5,6 @@
"allowPrerelease": false
},
"msbuild-sdks": {
- "Stellar.Sdk": "0.4.0"
+ "Stellar.Sdk": "0.4.1"
}
}