From b1a365a01e21758990974314a6e142d590e0adf7 Mon Sep 17 00:00:00 2001 From: MarcT1me Date: Thu, 26 Nov 2026 02:49:23 +0700 Subject: [PATCH 1/3] [CORE] [TESTS] skip the tests of the native core without it --- .../Stellar.Core.Tests/EngineInstanceTests.cs | 18 ++--- .../Stellar.Core.Tests/FailureTests.cs | 73 ++++++++++++------ .../Stellar.Core.Tests/RegistryTests.cs | 41 ++++++---- .../Stellar.Core.Tests/WrapperTests.cs | 74 ++++++++++--------- 4 files changed, 124 insertions(+), 82 deletions(-) diff --git a/Core/tests/Managed/Stellar.Core.Tests/EngineInstanceTests.cs b/Core/tests/Managed/Stellar.Core.Tests/EngineInstanceTests.cs index 0f4b62d..29ccf85 100644 --- a/Core/tests/Managed/Stellar.Core.Tests/EngineInstanceTests.cs +++ b/Core/tests/Managed/Stellar.Core.Tests/EngineInstanceTests.cs @@ -3,9 +3,7 @@ using Stellar.Core.Global; using Stellar.Core.Native; using Stellar.Core.Quantization; -using Stellar.Kernel; using Stellar.Kernel.Configuration; -using Stellar.Kernel.EntryPoint; using Stellar.Kernel.Lifecycle; using Stellar.Kernel.Services; using Stellar.Kernel.Threading; @@ -18,7 +16,7 @@ namespace Stellar.Core.Tests; /// public class EngineInstanceTests { - [Fact] + [NativeFact] public void TwoEngines_HaveTheirOwnServicesAndRegistries() { var editor = new FakeEngine("Editor"); @@ -57,7 +55,7 @@ public void Outside_AnyEngine_TheDefaultIsUsed() } } - [Fact] + [NativeFact] public async Task TheScope_FollowsTheWork_IntoAwaitAndOtherThreads() { var engine = new FakeEngine("Flowing"); @@ -67,7 +65,7 @@ public async Task TheScope_FollowsTheWork_IntoAwaitAndOtherThreads() await Task.Yield(); CoreEngine.Current.Instance.Should().BeSameAs(engine); - var seen = await Task.Run(() => CoreEngine.Current.Instance); + IEngineInstance? seen = await Task.Run(() => CoreEngine.Current.Instance); seen.Should().BeSameAs(engine); IEngineInstance? onThread = null; @@ -80,7 +78,7 @@ public async Task TheScope_FollowsTheWork_IntoAwaitAndOtherThreads() CoreEngine.Release(engine); } - [Fact] + [NativeFact] public void AQuant_LeavesTheRegistryOfTheEngineItWasMadeIn() { var first = new FakeEngine("First"); @@ -106,11 +104,11 @@ public void AQuant_LeavesTheRegistryOfTheEngineItWasMadeIn() CoreEngine.Release(second); } - [Fact] + [NativeFact] public void Releasing_AnEngine_DisposesItsNativeRegistries() { var engine = new FakeEngine("Short"); - var native = CoreEngine.For(engine).Native; + CoreContext native = CoreEngine.For(engine).Native; CoreEngine.Release(engine).Should().BeTrue(); @@ -119,7 +117,7 @@ public void Releasing_AnEngine_DisposesItsNativeRegistries() CoreEngine.Release(engine).Should().BeFalse(); } - [Fact] + [NativeFact] public void TheCoreModule_RunsForTheEngineOfItsContext() { var engine = new FakeEngine("Hosted"); @@ -155,6 +153,6 @@ private sealed class FakeEngine(string name) public IMainThreadDispatcher Dispatcher => throw new NotSupportedException(); - public IServiceCatalog? Services => CoreEngine.For(this).Services; + public IServiceCatalog Services => CoreEngine.For(this).Services; } } diff --git a/Core/tests/Managed/Stellar.Core.Tests/FailureTests.cs b/Core/tests/Managed/Stellar.Core.Tests/FailureTests.cs index 9e5c475..84bc331 100644 --- a/Core/tests/Managed/Stellar.Core.Tests/FailureTests.cs +++ b/Core/tests/Managed/Stellar.Core.Tests/FailureTests.cs @@ -26,11 +26,21 @@ private sealed class RecordingLogger : ILogger public Kernel.Data.Registry.IRegistrations Registrations => throw new NotSupportedException(); - public TMeta? FindMeta() where TMeta : class, IMetaQuant => null; + public TMeta? FindMeta() + where TMeta : class, IMetaQuant + { + return null; + } - public void Log(LogLevel level, string message) => Lines.Add((level, message)); + public void Log(LogLevel level, string message) + { + Lines.Add((level, message)); + } - public void LogWithoutFormat(string message) => Lines.Add((LogLevel.Info, message)); + public void LogWithoutFormat(string message) + { + Lines.Add((LogLevel.Info, message)); + } public void Start() { @@ -47,21 +57,28 @@ private sealed class RecordingControl : IEngineControl public Failure? Stopped { get; private set; } - public void RequestStop(StopReason reason, Failure? failure = null) => Stopped = failure; + public void RequestStop(StopReason reason, Failure? failure = null) + { + Stopped = failure; + } } private sealed class Recorder : IFailureHandler { public List Heard { get; } = []; - public void Handle(Failure failure) => Heard.Add(failure); + public void Handle(Failure failure) + { + Heard.Add(failure); + } } [Theory] [InlineData(FailureLevel.NonCritical, FailureReaction.None)] [InlineData(FailureLevel.Warning, FailureReaction.Log)] [InlineData(FailureLevel.Error, FailureReaction.Log | FailureReaction.StopExecution)] - [InlineData(FailureLevel.CriticalError, FailureReaction.Log | FailureReaction.StopExecution | FailureReaction.StopEngine)] + [InlineData(FailureLevel.CriticalError, + FailureReaction.Log | FailureReaction.StopExecution | FailureReaction.StopEngine)] public void Levels_HaveTheirReactionsByDefault(FailureLevel level, FailureReaction reaction) { new FailureSystem().ReactionTo(new Failure(FailureKind.Engine, level, "x")).Should().Be(reaction); @@ -130,8 +147,8 @@ public void AFailureThatLetsTheWorkGoOn_GivesTheFallback() { using var catcher = new Catcher(FailureKind.FileSystem, FailureLevel.Warning); - var save = catcher.Try(() => throw new IOException("no save"), fallback: "empty"); - var next = catcher.Run(() => { }); + string save = catcher.Try(() => throw new IOException("no save"), "empty"); + bool next = catcher.Run(() => { }); save.Should().Be("empty"); next.Should().BeTrue(); @@ -142,9 +159,9 @@ public void AFailureThatLetsTheWorkGoOn_GivesTheFallback() [Fact] public void AFailureThatStopsTheWork_IsThrownOn_AndTheWholeTryStops() { - var reached = false; + bool reached = false; - var block = () => + Action block = () => { using var catcher = new Catcher(FailureKind.FileSystem); catcher.Run(() => throw new IOException("disk gone")); @@ -158,8 +175,8 @@ public void AFailureThatStopsTheWork_IsThrownOn_AndTheWholeTryStops() [Fact] public void CatchBlocks_HandleTheirExceptions_AndAreNotReported() { - var firstRun = false; - using var catcher = new Catcher(FailureKind.FileSystem) + bool firstRun = false; + using Catcher catcher = new Catcher(FailureKind.FileSystem) .Catch(_ => firstRun = true) .Catch(FailureLevel.Warning); @@ -175,9 +192,9 @@ public void ErrorsOfTheEngine_KeepTheirFailure() { using var catcher = new Catcher(FailureKind.Application, FailureLevel.Warning); - var block = () => catcher.Run(() => throw new DomainNotFoundException("assets")); + Func block = () => catcher.Run(() => throw new DomainNotFoundException("assets")); - var thrown = block.Should().Throw().Which; + DomainNotFoundException thrown = block.Should().Throw().Which; thrown.Failure.Kind.Should().Be(FailureKind.FileSystem); catcher.Failures.Should().ContainSingle().Which.Should().BeSameAs(thrown.Failure); } @@ -192,7 +209,7 @@ public void AFailureCaughtAgain_KeepsItsFirstReaction() using var outer = new Catcher(system, FailureKind.Engine, FailureLevel.Warning); // A stop goes up through every catcher, as if none were there, until a plain try; it is reported once - var block = () => outer.Run(() => + Func block = () => outer.Run(() => { using var inner = new Catcher(system, FailureKind.Engine); inner.Run(() => throw new InvalidOperationException("deep")); @@ -209,7 +226,7 @@ public void ACatcherThatKeepsAFew_KeepsTheLastOnes_AndCountsThemAll() using var catcher = new Catcher(FailureKind.Engine, FailureLevel.Warning) { Keeps = 2 }; using var forgetful = new Catcher(FailureKind.Engine, FailureLevel.Warning) { Keeps = 0 }; - for (var i = 0; i < 5; i++) + for (int i = 0; i < 5; i++) { catcher.Report($"failure {i}"); forgetful.Report($"failure {i}"); @@ -219,7 +236,7 @@ public void ACatcherThatKeepsAFew_KeepsTheLastOnes_AndCountsThemAll() catcher.Failures.Select(failure => failure.Message).Should().Equal("failure 3", "failure 4"); forgetful.HasFailed.Should().BeTrue(); forgetful.Failures.Should().BeEmpty(); - var negative = () => new Catcher { Keeps = -1 }; + Func negative = () => new Catcher { Keeps = -1 }; negative.Should().Throw(); } @@ -228,7 +245,8 @@ public void Guard_NeverThrows_AndGivesTheFailure() { using var catcher = new Catcher(FailureKind.Engine, FailureLevel.CriticalError); - var failure = catcher.Guard(() => throw new InvalidOperationException("boom"), "the frame", phase: FramePhase.Update); + Failure? failure = catcher.Guard(() => throw new InvalidOperationException("boom"), "the frame", + phase: FramePhase.Update); failure.Should().NotBeNull(); failure!.Message.Should().Be("the frame: boom"); @@ -257,7 +275,8 @@ public void Cancellation_IsNotAFailure() { using var catcher = new Catcher(); - catcher.Invoking(c => c.Run(() => throw new OperationCanceledException())).Should().Throw(); + catcher.Invoking(c => c.Run(() => throw new OperationCanceledException())).Should() + .Throw(); catcher.HasFailed.Should().BeFalse(); } @@ -269,10 +288,11 @@ public void ThrowIfFailed_ThrowsTheWorst() catcher.Report(new InvalidOperationException("worse"), level: FailureLevel.NonCritical); catcher.Report("the worst", FailureLevel.Warning); - catcher.Invoking(c => c.ThrowIfFailed()).Should().Throw().WithMessage("a placeholder was used"); + catcher.Invoking(c => c.ThrowIfFailed()).Should().Throw() + .WithMessage("a placeholder was used"); } - [Fact] + [NativeFact] public void InAnEngine_TheCatcherReportsToItsSystem() { var engine = new ScopeEngine("Failing"); @@ -283,7 +303,9 @@ public void InAnEngine_TheCatcherReportsToItsSystem() using (EngineScope.Enter(engine)) using (var catcher = new Catcher(FailureKind.Engine, FailureLevel.Warning)) + { catcher.Run(() => throw new InvalidOperationException("in the engine")); + } recorder.Count.Should().Be(1); CoreEngine.Release(engine); @@ -293,7 +315,10 @@ private sealed class FailureSystemRecorder : IFailureHandler { public int Count { get; private set; } - public void Handle(Failure failure) => Count++; + public void Handle(Failure failure) + { + Count++; + } } } @@ -310,12 +335,12 @@ public void EntryPoint_IsQuantAndDisposable() [Fact] public void Constructor_WithNullConfiguration_Throws() { - var action = () => new EntryPoint(null!); + Func action = () => new EntryPoint(null!); action.Should().Throw(); } - [Fact] + [NativeFact] public void Run_PublishesTheFailureSystem_AndDisposeWithdrawsIt() { var engine = new ScopeEngine("Entry"); diff --git a/Core/tests/Managed/Stellar.Core.Tests/RegistryTests.cs b/Core/tests/Managed/Stellar.Core.Tests/RegistryTests.cs index 9f3cde8..76c69a7 100644 --- a/Core/tests/Managed/Stellar.Core.Tests/RegistryTests.cs +++ b/Core/tests/Managed/Stellar.Core.Tests/RegistryTests.cs @@ -1,7 +1,6 @@ using Stellar.Core.Data.Registry; using Stellar.Core.Global; using Stellar.Core.Quantization; -using Stellar.Kernel; using Stellar.Kernel.Data.Registry; using Stellar.Kernel.Lifecycle; using Stellar.Kernel.Quantization; @@ -31,7 +30,7 @@ private sealed class Prop() public void ADerivedQuant_IsInTheRegistryOfItsBase_AndFoundAsWhatItIs() { using var player = new Player(); - var actors = CoreEngine.Current.Registry.Of(); + IRegistry actors = CoreEngine.Current.Registry.Of(); actors.Get(player.UID).Should().BeSameAs(player); actors.Get(player.UID).Should().BeSameAs(player); @@ -49,7 +48,7 @@ public void AGetOfTheWrongType_IsNull_NotAGuess() public void MarkedTypes_HaveRegistriesOfTheirOwn() { using var player = new Player(); - var registries = CoreEngine.Current.Registry; + CoreEngine.CoreRegistries registries = CoreEngine.Current.Registry; registries.Of().Get(player.UID).Should().BeSameAs(player); registries.Of().Get(player.UID).Should().BeSameAs(player); @@ -60,9 +59,9 @@ public void MarkedTypes_HaveRegistriesOfTheirOwn() [Fact] public void KeysAndValues_FollowTheRegistry() { - var registry = CoreEngine.Current.Registry.Of(); + IRegistry registry = CoreEngine.Current.Registry.Of(); var first = new Crate(); - var values = registry.Values; + ICollection values = registry.Values; registry.Values.Should().BeSameAs(values); using var second = new Crate(); @@ -79,7 +78,7 @@ private sealed class Crate() public void Dispose_LeavesEveryRegistry() { var player = new Player(); - var registries = CoreEngine.Current.Registry; + CoreEngine.CoreRegistries registries = CoreEngine.Current.Registry; player.Dispose(); @@ -93,7 +92,7 @@ public void Dispose_LeavesEveryRegistry() public void AnyRegistry_CanTakeAnObject_AndTheObjectKnows() { using var prop = new Prop(); - var mine = new Registry(); + Registry mine = new(); prop.Registrations.Should().BeEmpty(); CoreEngine.Current.Registry.Of().Exists(prop.UID).Should().BeFalse(); @@ -110,7 +109,7 @@ public void AnyRegistry_CanTakeAnObject_AndTheObjectKnows() public void Dispose_LeavesARegistryMadeByHand() { var prop = new Prop(); - var mine = new Registry(); + Registry mine = new(); mine.Register(prop); prop.Dispose(); @@ -121,23 +120,31 @@ public void Dispose_LeavesARegistryMadeByHand() [Fact] public void ATypeWithoutRegistrableObjects_HasNoRegistry() { - FluentActions.Invoking(() => CoreEngine.Current.Registry.Of(typeof(string))).Should().Throw(); + FluentActions.Invoking(() => CoreEngine.Current.Registry.Of(typeof(string))).Should() + .Throw(); } - [Fact] + [NativeFact] public void RegistriesOfTwoEngines_AreApart() { var first = new ScopeEngine("First"); var second = new ScopeEngine("Second"); Actor actor; - using (EngineScope.Enter(first)) actor = new Actor(); + using (EngineScope.Enter(first)) + { + actor = new Actor(); + } CoreEngine.For(first).Registry.Of().Exists(actor.UID).Should().BeTrue(); CoreEngine.For(second).Registry.Of().Exists(actor.UID).Should().BeFalse(); // Disposed anywhere, it leaves the registries it is really in - using (EngineScope.Enter(second)) actor.Dispose(); + using (EngineScope.Enter(second)) + { + actor.Dispose(); + } + CoreEngine.For(first).Registry.Of().Exists(actor.UID).Should().BeFalse(); CoreEngine.Release(first); @@ -148,7 +155,7 @@ public void RegistriesOfTwoEngines_AreApart() [Collection(DetachedPolicyCollection.Name)] public class DetachedPolicyTests { - [Fact] + [NativeFact] public void Outside_AnyEngine_TheDefaultIsUsed_UnlessThePolicySaysOtherwise() { using (EngineScope.Enter(null)) @@ -156,14 +163,18 @@ public void Outside_AnyEngine_TheDefaultIsUsed_UnlessThePolicySaysOtherwise() EngineScope.Resolve().Should().BeNull(); CoreEngine.Current.Should().BeSameAs(CoreEngine.Default); - var previous = EngineScope.Detached; + DetachedPolicy previous = EngineScope.Detached; EngineScope.Detached = DetachedPolicy.Throw; try { FluentActions.Invoking(() => CoreEngine.Current).Should().Throw(); var engine = new ScopeEngine("Strict"); - using (EngineScope.Enter(engine)) CoreEngine.Current.Instance.Should().BeSameAs(engine); + using (EngineScope.Enter(engine)) + { + CoreEngine.Current.Instance.Should().BeSameAs(engine); + } + CoreEngine.Release(engine); } finally diff --git a/Core/tests/Managed/Stellar.Core.Tests/WrapperTests.cs b/Core/tests/Managed/Stellar.Core.Tests/WrapperTests.cs index c30694e..3d25f0b 100644 --- a/Core/tests/Managed/Stellar.Core.Tests/WrapperTests.cs +++ b/Core/tests/Managed/Stellar.Core.Tests/WrapperTests.cs @@ -1,12 +1,11 @@ using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using Stellar.Core.Data.Registry; -using Stellar.Core.Modules; -using Stellar.Core.Native; + using Stellar.Kernel; using Stellar.Kernel.Interop; using Stellar.Kernel.Versioning; +using Stellar.Core.Native; namespace Stellar.Core.Tests; @@ -17,7 +16,8 @@ internal static class Build { private static string Metadata(string key) { - return typeof(Build).Assembly.GetCustomAttributes() + return typeof(Build).Assembly + .GetCustomAttributes() .Single(attribute => attribute.Key == key).Value ?? string.Empty; } @@ -61,11 +61,14 @@ public class ContractTests [InlineData(1u, 1u, 1u, 2u, false)] [InlineData(2u, 0u, 1u, 0u, false)] [InlineData(1u, 0u, 2u, 0u, false)] - public void Satisfies_FollowsTheVersionRule(uint major, uint minor, uint requiredMajor, uint requiredMinor, - bool expected) + public void Satisfies_FollowsTheVersionRule( + uint major, uint minor, uint requiredMajor, uint requiredMinor, + bool expected + ) { - new ContractVersion(major, minor).Satisfies(new ContractVersion(requiredMajor, requiredMinor)).Should() - .Be(expected); + new ContractVersion(major, minor) + .Satisfies(new ContractVersion(requiredMajor, requiredMinor)) + .Should().Be(expected); } [Fact] @@ -85,7 +88,7 @@ public void Handle_WithZeroGeneration_IsInvalid() } /// -/// The behaviour every wrapper must have. The suite runs once per wrapper: -p:StellarNativeWrapper=.... +/// The behavior every wrapper must have. The suite runs once per wrapper: -p:StellarNativeWrapper=.... /// public class WrapperTests { @@ -99,14 +102,19 @@ public void Wrapper_IsTheOneTheSdkChose() public void Identifier_HasTheBytesOfTheNativeCore() { // The vector of the native tests: the same text gives the same 16 bytes on both sides - Identifier.Parse("00112233-4455-6677-8899-aabbccddeeff").ToBytes().Should().Equal( - 0x33, 0x22, 0x11, 0x00, 0x55, 0x44, 0x77, 0x66, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF); + Identifier.Parse("00112233-4455-6677-8899-aabbccddeeff").ToBytes() + .Should().Equal( + 0x33, 0x22, 0x11, 0x00, + 0x55, 0x44, + 0x77, 0x66, + 0x88, 0x99, + 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF); } [NativeFact] public void Failures_ComeBackAsExceptions() { - var load = () => CoreContext.Current.Modules.Load("no-such-module.dll"); + Func load = () => CoreContext.Current.Modules.Load("no-such-module.dll"); load.Should().Throw() .Where(exception => exception.Result == NativeResult.NotFound) @@ -117,9 +125,9 @@ public void Failures_ComeBackAsExceptions() public void StaleModuleHandle_IsRejected() { var stale = new NativeHandle(1000, 1); - var getName = () => CoreContext.Current.Modules.GetName(stale); - CoreContext.Current.Modules.Unload(stale).Should().BeFalse(); + + Func getName = () => CoreContext.Current.Modules.GetName(stale); getName.Should().Throw() .Where(exception => exception.Result == NativeResult.InvalidHandle); } @@ -137,39 +145,29 @@ public class WrapperParityTests internal static string ManagedPath => Path.Combine(Build.EngineCoreDir, "artifacts", "bin", "Stellar.Native.Core.Wrapper.Managed", Build.Configuration, "Stellar.Native.Core.Wrapper.Managed.dll"); - [BothWrappersFact] - public void Wrappers_DefineTheSameApi() - { - var cli = Surface(CliPath); - var managed = Surface(ManagedPath); - - cli.Except(managed).Should().BeEmpty("the C++/CLI wrapper must not have what the Managed one lacks"); - managed.Except(cli).Should().BeEmpty("the Managed wrapper must not have what the C++/CLI one lacks"); - } - private static SortedSet Surface(string path) { - var runtime = Directory.GetFiles(RuntimeEnvironment.GetRuntimeDirectory(), "*.dll"); - var kernel = typeof(NativeHandle).Assembly.Location; + string[] runtime = Directory.GetFiles(RuntimeEnvironment.GetRuntimeDirectory(), "*.dll"); + string kernel = typeof(NativeHandle).Assembly.Location; var resolver = new PathAssemblyResolver(runtime.Append(kernel).Append(path)); using var context = new MetadataLoadContext(resolver); - var assembly = context.LoadFromAssemblyPath(path); - var surface = new SortedSet(StringComparer.Ordinal); + Assembly assembly = context.LoadFromAssemblyPath(path); + SortedSet surface = new(StringComparer.Ordinal); const BindingFlags members = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly; - foreach (var type in assembly.GetExportedTypes()) + foreach (Type type in assembly.GetExportedTypes()) { surface.Add($"type {type.FullName}"); - foreach (var member in type.GetMembers(members)) + foreach (MemberInfo member in type.GetMembers(members)) { - var signature = member switch + string? signature = member switch { - MethodBase { IsSpecialName: true } method when !method.IsConstructor && - !method.Name.StartsWith("op_") => null, + MethodBase { IsSpecialName: true, IsConstructor: false } method + when !method.Name.StartsWith("op_") => null, MethodBase method => $"{Name(method)}({string.Join(", ", method.GetParameters().Select(Parameter))})" + (method is MethodInfo info ? $" : {TypeName(info.ReturnType)}" : string.Empty), @@ -211,4 +209,14 @@ static string Parameter(ParameterInfo parameter) $"{TypeName(parameter.ParameterType)} {parameter.Name}{(parameter.IsOptional ? " = optional" : string.Empty)}"; } } + + [BothWrappersFact] + public void Wrappers_DefineTheSameApi() + { + SortedSet cli = Surface(CliPath); + SortedSet managed = Surface(ManagedPath); + + cli.Except(managed).Should().BeEmpty("the C++/CLI wrapper must not have what the Managed one lacks"); + managed.Except(cli).Should().BeEmpty("the Managed wrapper must not have what the C++/CLI one lacks"); + } } From 22104b01326992187b089ffba1a7e1fbbe26a817 Mon Sep 17 00:00:00 2001 From: MarcT1me Date: Thu, 26 Nov 2026 02:49:32 +0700 Subject: [PATCH 2/3] [SDK] clean up the analyzers --- .../ConfigurationFileAnalyzer.cs | 15 +- .../EntryPoint/StellarEntryPointAnalyzer.cs | 65 ++++---- .../Modules/ModuleArchitectureAnalyzer.cs | 156 ++++++++++-------- .../StellarAnalyzerProjectDtos.cs | 14 +- .../StellarProjectConfigReader.cs | 97 ++++++----- .../Internal/ModuleLevels.cs | 4 +- 6 files changed, 189 insertions(+), 162 deletions(-) diff --git a/SDK/src/Roslyn/Stellar.Sdk.Analyzers/Analyzers/Configuration/ConfigurationFileAnalyzer.cs b/SDK/src/Roslyn/Stellar.Sdk.Analyzers/Analyzers/Configuration/ConfigurationFileAnalyzer.cs index cf36310..f8031d4 100644 --- a/SDK/src/Roslyn/Stellar.Sdk.Analyzers/Analyzers/Configuration/ConfigurationFileAnalyzer.cs +++ b/SDK/src/Roslyn/Stellar.Sdk.Analyzers/Analyzers/Configuration/ConfigurationFileAnalyzer.cs @@ -1,8 +1,10 @@ using System; using System.Collections.Immutable; + using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Text; + using Stellar.Sdk.Analyzers.Diagnostics; using Stellar.Sdk.Analyzers.Internal; @@ -16,7 +18,9 @@ namespace Stellar.Sdk.Analyzers.Analyzers.Configuration; public sealed class ConfigurationFileAnalyzer : DiagnosticAnalyzer { - private static readonly string[] Extensions = { ".stellar.project", ".stellar.module" }; + private static readonly string[] Extensions = [".stellar.project", ".stellar.module"]; + + // ── DiagnosticAnalyzer ──────────────────────────────────────────────── /// public override ImmutableArray SupportedDiagnostics => @@ -30,19 +34,22 @@ public override void Initialize(AnalysisContext context) context.RegisterAdditionalFileAction(Analyze); } + // ── Additional file action ──────────────────────────────────────────── + private static void Analyze(AdditionalFileAnalysisContext context) { - var path = context.AdditionalFile.Path; + string path = context.AdditionalFile.Path; if (Array.TrueForAll(Extensions, extension => !path.EndsWith(extension, StringComparison.OrdinalIgnoreCase))) return; - var text = context.AdditionalFile.GetText(context.CancellationToken); - if (text is null || JsonSyntaxChecker.TryCheck(text.ToString(), out var position, out var message)) + SourceText? text = context.AdditionalFile.GetText(context.CancellationToken); + if (text is null || JsonSyntaxChecker.TryCheck(text.ToString(), out int position, out string message)) return; var span = new TextSpan(Math.Min(position, Math.Max(0, text.Length - 1)), text.Length == 0 ? 0 : 1); var location = Location.Create(path, span, text.Lines.GetLinePositionSpan(span)); + // ── STLR0301: malformed configuration file ──────────────────────── context.ReportDiagnostic(Diagnostic.Create( StellarDiagnosticDescriptors.MalformedConfigurationFile, location, diff --git a/SDK/src/Roslyn/Stellar.Sdk.Analyzers/Analyzers/EntryPoint/StellarEntryPointAnalyzer.cs b/SDK/src/Roslyn/Stellar.Sdk.Analyzers/Analyzers/EntryPoint/StellarEntryPointAnalyzer.cs index 2cfadda..bbc0ef2 100644 --- a/SDK/src/Roslyn/Stellar.Sdk.Analyzers/Analyzers/EntryPoint/StellarEntryPointAnalyzer.cs +++ b/SDK/src/Roslyn/Stellar.Sdk.Analyzers/Analyzers/EntryPoint/StellarEntryPointAnalyzer.cs @@ -2,8 +2,11 @@ using System.Collections.Concurrent; using System.Collections.Immutable; using System.Linq; + using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Diagnostics; +using Microsoft.CodeAnalysis.Text; + using Stellar.Sdk.Analyzers.Configuration; using Stellar.Sdk.Analyzers.Diagnostics; using Stellar.Sdk.Analyzers.Internal; @@ -22,6 +25,23 @@ public sealed class StellarEntryPointAnalyzer : DiagnosticAnalyzer private const string EntryPointBaseFqn = "Stellar.Kernel.EntryPoint.StellarEntryPoint"; private const string EntryPointAttributeFqn = "Stellar.Kernel.EntryPoint.StellarEntryPointAttribute"; + // ── Helpers ─────────────────────────────────────────────────────────── + + private static string ResolveEntryPointTypeName( + string rawValue, + string? assemblyName + ) + { + if (string.IsNullOrEmpty(rawValue) + || string.Equals(rawValue, DefaultEntryPointKeyword, StringComparison.OrdinalIgnoreCase)) + // Convention: {AssemblyName}.EntryPoint in the root namespace + return string.IsNullOrEmpty(assemblyName) + ? DefaultEntryPointTypeSuffix + : $"{assemblyName}.{DefaultEntryPointTypeSuffix}"; + + return rawValue; // fully-qualified name written by the developer + } + // ── DiagnosticAnalyzer ──────────────────────────────────────────────── public override ImmutableArray SupportedDiagnostics => @@ -45,36 +65,36 @@ public override void Initialize(AnalysisContext context) private static void OnCompilationStart(CompilationStartAnalysisContext ctx) { // 1. Locate .stellar.project in AdditionalFiles - var configFile = ctx.Options.AdditionalFiles + AdditionalText? configFile = ctx.Options.AdditionalFiles .FirstOrDefault(f => f.Path.EndsWith( StellarProjectFileExtension, StringComparison.OrdinalIgnoreCase)); if (configFile is null) return; - var sourceText = configFile.GetText(ctx.CancellationToken); + SourceText? sourceText = configFile.GetText(ctx.CancellationToken); if (sourceText is null) return; // 2. Parse config — bail silently on malformed JSON // (the build task will produce a proper build error for that) - var readResult = StellarProjectConfigReader.TryRead(sourceText.ToString()); + ConfigReadResult readResult = StellarProjectConfigReader.TryRead(sourceText.ToString()); if (!readResult.IsSuccess) return; - var rawEntryPointValue = + string rawEntryPointValue = readResult.Config!.Project?.StellarEntryPoint?.Trim() ?? DefaultEntryPointKeyword; // 3. Resolve well-known Stellar symbols — they may be null if the // kernel assembly isn't referenced, which is fine for pure // library projects; checks will be skipped gracefully. - var baseTypeSymbol = + INamedTypeSymbol? baseTypeSymbol = ctx.Compilation.GetTypeByMetadataName(EntryPointBaseFqn); - var attributeTypeSymbol = + INamedTypeSymbol? attributeTypeSymbol = ctx.Compilation.GetTypeByMetadataName(EntryPointAttributeFqn); // 4. Collect all types in this compilation that carry [StellarEntryPoint]. // ConcurrentBag because RegisterSymbolAction may run in parallel. - var decoratedTypes = new ConcurrentBag(); + ConcurrentBag decoratedTypes = new(); if (attributeTypeSymbol is not null) ctx.RegisterSymbolAction(symbolCtx => @@ -105,15 +125,13 @@ private static void AnalyzeCompilationEnd( string rawEntryPointValue, INamedTypeSymbol? baseTypeSymbol, INamedTypeSymbol? attributeTypeSymbol, - ConcurrentBag decoratedTypes) + ConcurrentBag decoratedTypes + ) { - var compilation = ctx.Compilation; - - // Resolve the configured type name - var resolvedTypeName = ResolveEntryPointTypeName(rawEntryPointValue, compilation.AssemblyName); + Compilation compilation = ctx.Compilation; // Location of the value token inside the .stellar.project file - var configValueLocation = JsonTextLocator.FindValueLocation( + Location configValueLocation = JsonTextLocator.FindValueLocation( sourceText, configFilePath, "StellarEntryPoint"); // ── STLR0104: no entry-point types at all in the module ─────────── @@ -126,7 +144,8 @@ private static void AnalyzeCompilationEnd( compilation.AssemblyName ?? "")); // ── Resolve the configured type ─────────────────────────────────── - var configuredType = compilation.GetTypeByMetadataName(resolvedTypeName); + string resolvedTypeName = ResolveEntryPointTypeName(rawEntryPointValue, compilation.AssemblyName); + INamedTypeSymbol? configuredType = compilation.GetTypeByMetadataName(resolvedTypeName); // ── STLR0101: type not found ────────────────────────────────────── if (configuredType is null) @@ -140,7 +159,7 @@ private static void AnalyzeCompilationEnd( // Use the first declaration location on the type itself for STLR0102/0103 // so the squiggle lands on the class keyword. - var typeLocation = configuredType.Locations.FirstOrDefault() ?? Location.None; + Location typeLocation = configuredType.Locations.FirstOrDefault() ?? Location.None; // ── STLR0102: missing inheritance ───────────────────────────────── if (baseTypeSymbol is not null @@ -158,20 +177,4 @@ private static void AnalyzeCompilationEnd( typeLocation, resolvedTypeName)); } - - // ── Helpers ─────────────────────────────────────────────────────────── - - private static string ResolveEntryPointTypeName( - string rawValue, - string? assemblyName) - { - if (string.IsNullOrEmpty(rawValue) - || string.Equals(rawValue, DefaultEntryPointKeyword, StringComparison.OrdinalIgnoreCase)) - // Convention: {AssemblyName}.EntryPoint in the root namespace - return string.IsNullOrEmpty(assemblyName) - ? DefaultEntryPointTypeSuffix - : $"{assemblyName}.{DefaultEntryPointTypeSuffix}"; - - return rawValue; // fully-qualified name written by the developer - } } diff --git a/SDK/src/Roslyn/Stellar.Sdk.Analyzers/Analyzers/Modules/ModuleArchitectureAnalyzer.cs b/SDK/src/Roslyn/Stellar.Sdk.Analyzers/Analyzers/Modules/ModuleArchitectureAnalyzer.cs index f55e309..ceb665b 100644 --- a/SDK/src/Roslyn/Stellar.Sdk.Analyzers/Analyzers/Modules/ModuleArchitectureAnalyzer.cs +++ b/SDK/src/Roslyn/Stellar.Sdk.Analyzers/Analyzers/Modules/ModuleArchitectureAnalyzer.cs @@ -2,8 +2,11 @@ using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; + using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Diagnostics; +using Microsoft.CodeAnalysis.Text; + using Stellar.Sdk.Analyzers.Configuration; using Stellar.Sdk.Analyzers.Diagnostics; using Stellar.Sdk.Analyzers.Internal; @@ -23,9 +26,68 @@ namespace Stellar.Sdk.Analyzers.Analyzers.Modules; public sealed class ModuleArchitectureAnalyzer : DiagnosticAnalyzer { + // ── Well-known Stellar type names ───────────────────────────────────── + private const string MetadataAttribute = "System.Reflection.AssemblyMetadataAttribute"; private const string DescriptorExtension = ".stellar.module"; + // ── Helpers ─────────────────────────────────────────────────────────── + + private static Dictionary ReadMetadata(IAssemblySymbol assembly) + { + Dictionary values = new(StringComparer.Ordinal); + + foreach (AttributeData attribute in assembly.GetAttributes()) + { + if (attribute.AttributeClass?.ToDisplayString() != MetadataAttribute || + attribute.ConstructorArguments.Length != 2) + continue; + + if (attribute.ConstructorArguments[0].Value is string key && + attribute.ConstructorArguments[1].Value is string value) + values[key] = value; + } + + return values; + } + + private static void CheckDescriptor(CompilationAnalysisContext context, string id) + { + AdditionalText? descriptor = context.Options.AdditionalFiles.FirstOrDefault(file => + file.Path.EndsWith(DescriptorExtension, StringComparison.OrdinalIgnoreCase)); + SourceText? text = descriptor?.GetText(context.CancellationToken); + if (descriptor is null || text is null) + return; + + string? describedId = MinimalJson.GetString(text.ToString(), "Id"); + if (describedId is null || string.Equals(describedId, id, StringComparison.Ordinal)) + return; + + // ── STLR0203: module descriptor mismatch ────────────────────────── + context.ReportDiagnostic(Diagnostic.Create( + StellarDiagnosticDescriptors.ModuleDescriptorMismatch, + JsonTextLocator.FindValueLocation(text, descriptor.Path, "Id"), + describedId, id)); + } + + private static void AddDependencies( + Dictionary metadata, + Dictionary> modules, + HashSet found + ) + { + if (!metadata.TryGetValue("StellarModuleDependencies", out string? list)) + return; + + foreach (string dependency in list + .Split([';'], StringSplitOptions.RemoveEmptyEntries) + .Select(name => name.Trim())) + if (found.Add(dependency) && modules.TryGetValue(dependency, out Dictionary? next)) + AddDependencies(next, modules, found); + } + + // ── DiagnosticAnalyzer ──────────────────────────────────────────────── + /// public override ImmutableArray SupportedDiagnostics => ImmutableArray.Create( @@ -41,62 +103,68 @@ public override void Initialize(AnalysisContext context) context.RegisterCompilationAction(Analyze); } + // ── Compilation action ──────────────────────────────────────────────── + private static void Analyze(CompilationAnalysisContext context) { - var options = context.Options.AnalyzerConfigOptionsProvider.GlobalOptions; + AnalyzerConfigOptions options = context.Options.AnalyzerConfigOptionsProvider.GlobalOptions; string? Property(string name) { - return options.TryGetValue("build_property." + name, out var value) && !string.IsNullOrWhiteSpace(value) + return options.TryGetValue("build_property." + name, out string? value) + && !string.IsNullOrWhiteSpace(value) ? value.Trim() : null; } - var id = Property("StellarModuleId") ?? context.Compilation.AssemblyName ?? string.Empty; - var isModule = string.Equals(Property("StellarIsModule"), "true", StringComparison.OrdinalIgnoreCase); - var level = ModuleLevels.Parse(Property("StellarModuleLevel")) ?? - ModuleLevels.FromUsage(Property("StellarSdkUsage")); + string id = Property("StellarModuleId") ?? context.Compilation.AssemblyName ?? string.Empty; + bool isModule = string.Equals(Property("StellarIsModule"), "true", StringComparison.OrdinalIgnoreCase); + int? level = ModuleLevels.Parse(Property("StellarModuleLevel")) + ?? ModuleLevels.FromUsage(Property("StellarSdkUsage")); if (level is null) return; - var declared = new HashSet( + HashSet declared = new( (Property("StellarModuleDependencies") ?? string.Empty) - .Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).Select(name => name.Trim()), + .Split([';'], StringSplitOptions.RemoveEmptyEntries).Select(name => name.Trim()), StringComparer.Ordinal); // Every referenced module, with what it says about itself - var modules = new Dictionary>(StringComparer.Ordinal); - foreach (var reference in context.Compilation.References) + Dictionary> modules = new(StringComparer.Ordinal); + foreach (MetadataReference reference in context.Compilation.References) { if (context.Compilation.GetAssemblyOrModuleSymbol(reference) is not IAssemblySymbol assembly) continue; - var metadata = ReadMetadata(assembly); - if (metadata.TryGetValue("StellarModuleId", out var dependencyId) && - !string.Equals(dependencyId, id, StringComparison.Ordinal)) + Dictionary metadata = ReadMetadata(assembly); + if (metadata.TryGetValue("StellarModuleId", out string? dependencyId) + && !string.Equals(dependencyId, id, StringComparison.Ordinal)) modules[dependencyId] = metadata; } // The compiler sees transitive references too. A module another referenced module depends on is not a // dependency of this project: only the direct ones are checked - var transitive = new HashSet(StringComparer.Ordinal); - foreach (var metadata in modules.Values) + HashSet transitive = new(StringComparer.Ordinal); + foreach (Dictionary metadata in modules.Values) AddDependencies(metadata, modules, transitive); - foreach (var pair in modules.Where(pair => !transitive.Contains(pair.Key)) + foreach (KeyValuePair> pair in modules + .Where(pair => !transitive.Contains(pair.Key)) .OrderBy(pair => pair.Key, StringComparer.Ordinal)) { - var dependencyId = pair.Key; - pair.Value.TryGetValue("StellarModuleLevel", out var dependencyLevelName); - var dependencyLevel = ModuleLevels.Parse(dependencyLevelName); + string dependencyId = pair.Key; + pair.Value.TryGetValue("StellarModuleLevel", out string? dependencyLevelName); + int? dependencyLevel = ModuleLevels.Parse(dependencyLevelName); + // ── STLR0201: module level violation ────────────────────────── if (dependencyLevel is { } known && !ModuleLevels.MayDependOn(level.Value, known)) context.ReportDiagnostic(Diagnostic.Create( StellarDiagnosticDescriptors.ModuleLevelViolation, Location.None, id, ModuleLevels.Name(level.Value), dependencyId, ModuleLevels.Name(known))); + // ── STLR0202: undeclared module dependency ──────────────────── if (isModule && !ModuleLevels.IsCore(dependencyId) && !declared.Contains(dependencyId)) context.ReportDiagnostic(Diagnostic.Create( StellarDiagnosticDescriptors.UndeclaredModuleDependency, @@ -107,54 +175,4 @@ private static void Analyze(CompilationAnalysisContext context) if (isModule) CheckDescriptor(context, id); } - - private static void CheckDescriptor(CompilationAnalysisContext context, string id) - { - var descriptor = context.Options.AdditionalFiles.FirstOrDefault(file => - file.Path.EndsWith(DescriptorExtension, StringComparison.OrdinalIgnoreCase)); - var text = descriptor?.GetText(context.CancellationToken); - if (descriptor is null || text is null) - return; - - var describedId = MinimalJson.GetString(text.ToString(), "Id"); - if (describedId is null || string.Equals(describedId, id, StringComparison.Ordinal)) - return; - - context.ReportDiagnostic(Diagnostic.Create( - StellarDiagnosticDescriptors.ModuleDescriptorMismatch, - JsonTextLocator.FindValueLocation(text, descriptor.Path, "Id"), - describedId, id)); - } - - private static void AddDependencies( - Dictionary metadata, - Dictionary> modules, - HashSet found) - { - if (!metadata.TryGetValue("StellarModuleDependencies", out var list)) - return; - - foreach (var dependency in list.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries) - .Select(name => name.Trim())) - if (found.Add(dependency) && modules.TryGetValue(dependency, out var next)) - AddDependencies(next, modules, found); - } - - private static Dictionary ReadMetadata(IAssemblySymbol assembly) - { - var values = new Dictionary(StringComparer.Ordinal); - - foreach (var attribute in assembly.GetAttributes()) - { - if (attribute.AttributeClass?.ToDisplayString() != MetadataAttribute || - attribute.ConstructorArguments.Length != 2) - continue; - - if (attribute.ConstructorArguments[0].Value is string key && - attribute.ConstructorArguments[1].Value is string value) - values[key] = value; - } - - return values; - } } diff --git a/SDK/src/Roslyn/Stellar.Sdk.Analyzers/Configuration/StellarAnalyzerProjectDtos.cs b/SDK/src/Roslyn/Stellar.Sdk.Analyzers/Configuration/StellarAnalyzerProjectDtos.cs index dce467e..efedc9f 100644 --- a/SDK/src/Roslyn/Stellar.Sdk.Analyzers/Configuration/StellarAnalyzerProjectDtos.cs +++ b/SDK/src/Roslyn/Stellar.Sdk.Analyzers/Configuration/StellarAnalyzerProjectDtos.cs @@ -7,13 +7,6 @@ namespace Stellar.Sdk.Analyzers.Configuration; // These are thin, analyzer-private mirrors of the public DTOs. // ───────────────────────────────────────────────────────────────────────── -internal sealed class StellarAnalyzerConfigFile -{ - public StellarAnalyzerProjectConfig? Project { get; set; } - - // Runtime section intentionally omitted — analyzers don't need it. -} - internal sealed class StellarAnalyzerProjectConfig { public string? StellarEntryPoint { get; set; } @@ -21,3 +14,10 @@ internal sealed class StellarAnalyzerProjectConfig // Other fields (Assets, Localizations …) will be added here // as future analyzers need them — zero cost when unused. } + +internal sealed class StellarAnalyzerConfigFile +{ + public StellarAnalyzerProjectConfig? Project { get; set; } + + // Runtime section intentionally omitted — analyzers don't need it. +} diff --git a/SDK/src/Roslyn/Stellar.Sdk.Analyzers/Configuration/StellarProjectConfigReader.cs b/SDK/src/Roslyn/Stellar.Sdk.Analyzers/Configuration/StellarProjectConfigReader.cs index cb0e621..451faa0 100644 --- a/SDK/src/Roslyn/Stellar.Sdk.Analyzers/Configuration/StellarProjectConfigReader.cs +++ b/SDK/src/Roslyn/Stellar.Sdk.Analyzers/Configuration/StellarProjectConfigReader.cs @@ -37,50 +37,30 @@ public static ConfigReadResult Failure(string errorMessage) internal static class MinimalJson { - public static string? GetNestedString(string json, string parentKey, string childKey) - { - var parentIndex = json.IndexOf($"\"{parentKey}\"", StringComparison.Ordinal); - if (parentIndex < 0) return null; - - var colonIndex = json.IndexOf(':', parentIndex); - if (colonIndex < 0) return null; - - var objStart = json.IndexOf('{', colonIndex); - if (objStart < 0) return null; - - var objEnd = FindMatchingBrace(json, objStart); - if (objEnd < 0) return null; - - // from here on only the inside of Project { ... } is looked at - var span = json.Substring(objStart, objEnd - objStart + 1); - - return GetString(span, childKey); - } - - public static string? GetString(string json, string key) + private static int FindStringEnd(string json, int start) { - var keyIndex = json.IndexOf($"\"{key}\"", StringComparison.Ordinal); - if (keyIndex < 0) return null; - - var colonIndex = json.IndexOf(':', keyIndex); - if (colonIndex < 0) return null; - - var startQuote = json.IndexOf('"', colonIndex + 1); - if (startQuote < 0) return null; + for (int i = start; i < json.Length; i++) + { + if (json[i] == '\\') // skip escaped char + { + i++; + continue; + } - var endQuote = FindStringEnd(json, startQuote + 1); - if (endQuote < 0) return null; + if (json[i] == '"') + return i; + } - return json.Substring(startQuote + 1, endQuote - startQuote - 1); + return -1; } private static int FindMatchingBrace(string json, int start) { - var depth = 0; + int depth = 0; - for (var i = start; i < json.Length; i++) + for (int i = start; i < json.Length; i++) { - var c = json[i]; + char c = json[i]; if (c == '{') { @@ -102,21 +82,41 @@ private static int FindMatchingBrace(string json, int start) return -1; } - private static int FindStringEnd(string json, int start) + public static string? GetString(string json, string key) { - for (var i = start; i < json.Length; i++) - { - if (json[i] == '\\') // skip escaped char - { - i++; - continue; - } + int keyIndex = json.IndexOf($"\"{key}\"", StringComparison.Ordinal); + if (keyIndex < 0) return null; - if (json[i] == '"') - return i; - } + int colonIndex = json.IndexOf(':', keyIndex); + if (colonIndex < 0) return null; - return -1; + int startQuote = json.IndexOf('"', colonIndex + 1); + if (startQuote < 0) return null; + + int endQuote = FindStringEnd(json, startQuote + 1); + if (endQuote < 0) return null; + + return json.Substring(startQuote + 1, endQuote - startQuote - 1); + } + + public static string? GetNestedString(string json, string parentKey, string childKey) + { + int parentIndex = json.IndexOf($"\"{parentKey}\"", StringComparison.Ordinal); + if (parentIndex < 0) return null; + + int colonIndex = json.IndexOf(':', parentIndex); + if (colonIndex < 0) return null; + + int objStart = json.IndexOf('{', colonIndex); + if (objStart < 0) return null; + + int objEnd = FindMatchingBrace(json, objStart); + if (objEnd < 0) return null; + + // from here on only the inside of Project { ... } is looked at + string span = json.Substring(objStart, objEnd - objStart + 1); + + return GetString(span, childKey); } } @@ -129,8 +129,7 @@ public static ConfigReadResult TryRead(string json) try { - var entryPoint = MinimalJson.GetNestedString( - json, + string? entryPoint = MinimalJson.GetNestedString(json, "Project", "StellarEntryPoint"); diff --git a/SDK/src/Roslyn/Stellar.Sdk.Analyzers/Internal/ModuleLevels.cs b/SDK/src/Roslyn/Stellar.Sdk.Analyzers/Internal/ModuleLevels.cs index d328f9d..2e5c857 100644 --- a/SDK/src/Roslyn/Stellar.Sdk.Analyzers/Internal/ModuleLevels.cs +++ b/SDK/src/Roslyn/Stellar.Sdk.Analyzers/Internal/ModuleLevels.cs @@ -69,7 +69,7 @@ public static string Name(int level) public static bool IsCore(string id) { - return string.Equals(id, "Stellar.Kernel", StringComparison.Ordinal) || - string.Equals(id, "Stellar.Core", StringComparison.Ordinal); + return string.Equals(id, "Stellar.Kernel", StringComparison.Ordinal) + || string.Equals(id, "Stellar.Core", StringComparison.Ordinal); } } From 89dca0e7b5b537c75ad227ead14db8248f99ee74 Mon Sep 17 00:00:00 2001 From: MarcT1me Date: Thu, 26 Nov 2026 02:49:37 +0700 Subject: [PATCH 3/3] [SDK] [DOCS] raise the versions, describe the migration --- Docs/Migration-0.11.md | 31 +++++++++++++++++++++++++++++ Docs/index.md | 1 + Docs/toc.yml | 2 ++ README.md | 1 + Shared/Build/Stellar.Versions.props | 12 +++++------ 5 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 Docs/Migration-0.11.md diff --git a/Docs/Migration-0.11.md b/Docs/Migration-0.11.md new file mode 100644 index 0000000..da292bd --- /dev/null +++ b/Docs/Migration-0.11.md @@ -0,0 +1,31 @@ +# Migrating to 0.11 + +- [README.md](https://github.com/QuantumDevTeam/StellarEngine-Core#readme) + +What changed for the code that uses the core, from 0.10. Nothing of the core breaks: the orchestra takes the second +number because the logging module enters it. + +| Component | 0.10 | 0.11 | Why | +|---|---|---|---| +| Orchester | 0.10.0 | 0.11.0 | The logging module, and the file system published by its module | +| Kernel | 0.10.0 | 0.10.1 | Compatible: a color of `LoggerFormat.Default` | +| Runtime | 0.10.0 | 0.10.1 | Compatible: settings of the command line reach modules | +| Stellar.Tools | 0.3.2 | 0.3.3 | Compatible: marks; a module is packed before its tests | +| `stellar` (CLI) | 0.2.3 | 0.2.4 | Compatible: `stellar marks` | +| Core, Stellar.Sdk, P/Invoke exports | 0.10.0, 0.4.1, 3.1 | the same | Nothing changed | + +Build the engine again and install it (`scripts/build.ps1 -Configuration Release -Install`). `global.json` stays. + +## Settings + +`RuntimeConfiguration.Settings` holds the settings of the project and those of the command line +(`--stellar:Name=Value`), which win; names are in any case. Before, a module saw those of the project only. + +## Logging + +When the module that published the logger stops, the runtime goes back to the error output: what fails after it is +told there instead of being lost. + +## Marks + +Marks in the comments of the code, checked by git and by the workflows: [Marks](https://quantumdevteam.github.io/StellarEngine-Mono/guide/Marks.html). diff --git a/Docs/index.md b/Docs/index.md index e962b5b..334443f 100644 --- a/Docs/index.md +++ b/Docs/index.md @@ -41,6 +41,7 @@ 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.11](Migration-0.11.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 97adea3..cc3371d 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.11 + href: Migration-0.11.md - name: Migrating to 0.10 href: Migration-0.10.md - name: Migrating to 0.9 diff --git a/README.md b/README.md index b486cca..ee2f060 100644 --- a/README.md +++ b/README.md @@ -141,6 +141,7 @@ Reference: Workflow: - [Contributing](CONTRIBUTING.md), [Git policy](Docs/Engine/GitPolicy.md), [versioning](Docs/Engine/Versioning.md) +- [Migrating to 0.11](Docs/Migration-0.11.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/Shared/Build/Stellar.Versions.props b/Shared/Build/Stellar.Versions.props index 9ed9d35..13398c0 100644 --- a/Shared/Build/Stellar.Versions.props +++ b/Shared/Build/Stellar.Versions.props @@ -7,18 +7,18 @@ --> - 0.10.0 + 0.11.0 - 0.10.0 + 0.10.1 0.10.0 - 0.10.0 - 0.3.2 + 0.10.1 + 0.3.3 0.4.1 - 0.2.3 + 0.2.4 - 0.9.0 + 0.11.0 3