From 70d1185068b64954e86854d1f42add85166388af Mon Sep 17 00:00:00 2001 From: Sakari Bergen Date: Sat, 12 Oct 2024 13:14:17 +0300 Subject: [PATCH] Make interface members + downstream types internal (#249) This will allow more flexible non-breaking changes in the future. Made possible by C#8 (and we no longer support older Unity versions). --- CHANGELOG.md | 5 ++++- .../Assets/EditorTests/FakeOperationState.cs | 4 ++-- .../Runtime/AssemblyInfo.cs | 8 ++++++++ .../Runtime/AssemblyInfo.cs.meta | 11 +++++++++++ .../Runtime/Context/RunContext.cs | 3 +-- .../Runtime/IExternalResultSource.cs | 2 +- .../Runtime/IFailureListener.cs | 2 +- .../Runtime/IGlobalContextProvider.cs | 2 +- .../Runtime/ITestOperation.cs | 2 +- .../Runtime/ITestScheduler.cs | 6 +++--- .../Runtime/State/BoxedOperationState.cs | 2 +- .../Runtime/State/ITestOperationState.cs | 10 ++++------ .../Runtime/State/SelectOperationState.cs | 2 +- .../Runtime/State/TestOperationStatus.cs | 4 +--- .../Runtime/State/TestOperationsState.cs | 16 +++++++++------- .../Runtime/State/UntilResponderState.cs | 2 +- .../ContinuationTestInstruction.cs | 2 +- .../ExpectConditionInstruction.cs | 2 +- .../TestInstructions/ExpectTestResponse.cs | 2 +- .../TestInstructions/GroupedAsInstruction.cs | 2 +- .../TestInstructions/SequencedTestInstruction.cs | 2 +- .../SynchronousTestInstruction.cs | 2 +- .../TestInstructions/WaitForFramesInstruction.cs | 2 +- .../TestInstructions/WaitForInstruction.cs | 2 +- .../Runtime/TestResponders/AnyOfResponder.cs | 2 +- .../TestResponders/RepeatedlyResponder.cs | 2 +- .../Runtime/TestResponders/SelectResponder.cs | 2 +- .../Runtime/TestResponders/TestResponder.cs | 2 +- .../TestWaitConditions/AllOfWaitCondition.cs | 2 +- .../TestWaitConditions/ContinuedWaitCondition.cs | 2 +- .../TestWaitConditions/PollingWaitCondition.cs | 2 +- .../TestWaitConditions/RepeatUntilCondition.cs | 4 ++-- .../RespondToAllOfWaitCondition.cs | 2 +- .../TestWaitConditions/SequencedWaitCondition.cs | 2 +- .../TestWaitConditions/TaskWaitCondition.cs | 2 +- .../Runtime/Unity/ConstraintWaitCondition.cs | 2 +- .../Runtime/Unity/CoroutineWaitCondition.cs | 2 +- .../Runtime/Utilities/IMultipleTaskAwaiter.cs | 2 +- .../Runtime/Utilities/IMultipleTaskSource.cs | 2 +- .../Runtime/Utilities/MultipleTaskSource.cs | 2 +- .../Runtime/Utilities/RepeatedTaskSource.cs | 2 +- 41 files changed, 76 insertions(+), 57 deletions(-) create mode 100644 com.beatwaves.responsible/Runtime/AssemblyInfo.cs create mode 100644 com.beatwaves.responsible/Runtime/AssemblyInfo.cs.meta diff --git a/CHANGELOG.md b/CHANGELOG.md index 8392b991..93f4c59e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,10 @@ Experimental features are also **not** under semantic versioning. ### Changed - Breaking change: `RunAs(Simulated)Loop` is now an `async` method. - This had to be done to support Unity's async cancellation state to propagate to state strings. + This had to be done to support Unity's async cancellation state to propagate to state strings. +- Breaking change: Make interface members that were always only intended for internal use internal. + This was not possible before C#8, but now that we no longer support older Unity versions, + it can be done, allowing more flexibility to change things without breaking things in the future. ### Fixed - Fix instructions that were canceled because of a failure not showing up as canceled on Unity. diff --git a/ResponsibleUnity/Assets/EditorTests/FakeOperationState.cs b/ResponsibleUnity/Assets/EditorTests/FakeOperationState.cs index 74e62104..ff47bccb 100644 --- a/ResponsibleUnity/Assets/EditorTests/FakeOperationState.cs +++ b/ResponsibleUnity/Assets/EditorTests/FakeOperationState.cs @@ -18,8 +18,8 @@ public FakeOperationState(Exception exception) this.Exception = exception; } - public TestOperationStatus Status => throw new NotImplementedException(); - public void BuildDescription(StateStringBuilder builder) => throw new NotImplementedException(); + TestOperationStatus ITestOperationState.Status => throw new NotImplementedException(); + void ITestOperationState.BuildDescription(StateStringBuilder builder) => throw new NotImplementedException(); public override string ToString() => this.Exception != null ? throw this.Exception diff --git a/com.beatwaves.responsible/Runtime/AssemblyInfo.cs b/com.beatwaves.responsible/Runtime/AssemblyInfo.cs new file mode 100644 index 00000000..4e6b4b72 --- /dev/null +++ b/com.beatwaves.responsible/Runtime/AssemblyInfo.cs @@ -0,0 +1,8 @@ +using System.Runtime.CompilerServices; + +// Testing the Unity Editor utilities is very tedious without +// implementing fake operation states. +// We don't want to test internals in the core tests, +// but here it's ok, as long as the use is very limited. +[assembly:InternalsVisibleTo("Responsible.EditorTests")] +[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] diff --git a/com.beatwaves.responsible/Runtime/AssemblyInfo.cs.meta b/com.beatwaves.responsible/Runtime/AssemblyInfo.cs.meta new file mode 100644 index 00000000..3c07a519 --- /dev/null +++ b/com.beatwaves.responsible/Runtime/AssemblyInfo.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9c07d9f58a5880041b69aa63687e4b23 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.beatwaves.responsible/Runtime/Context/RunContext.cs b/com.beatwaves.responsible/Runtime/Context/RunContext.cs index baede5c7..a6051c97 100644 --- a/com.beatwaves.responsible/Runtime/Context/RunContext.cs +++ b/com.beatwaves.responsible/Runtime/Context/RunContext.cs @@ -2,9 +2,8 @@ namespace Responsible.Context { /// /// Represents the context in which a test operation is run from. - /// Only for internal use. /// - public readonly struct RunContext + internal readonly struct RunContext { internal readonly ITestScheduler Scheduler; internal readonly SourceContext SourceContext; diff --git a/com.beatwaves.responsible/Runtime/IExternalResultSource.cs b/com.beatwaves.responsible/Runtime/IExternalResultSource.cs index 845b20f5..bdbb01cf 100644 --- a/com.beatwaves.responsible/Runtime/IExternalResultSource.cs +++ b/com.beatwaves.responsible/Runtime/IExternalResultSource.cs @@ -22,6 +22,6 @@ public interface IExternalResultSource /// /// Type of the test instruction being executed. /// A task which will cause early failure or completion of the executed test instruction. - Task GetExternalResult(CancellationToken cancellationToken); + public Task GetExternalResult(CancellationToken cancellationToken); } } diff --git a/com.beatwaves.responsible/Runtime/IFailureListener.cs b/com.beatwaves.responsible/Runtime/IFailureListener.cs index 1c814691..4f78ec5a 100644 --- a/com.beatwaves.responsible/Runtime/IFailureListener.cs +++ b/com.beatwaves.responsible/Runtime/IFailureListener.cs @@ -14,6 +14,6 @@ public interface IFailureListener /// /// Message detailing the failure, including the state of the operation. /// - void OperationFailed(Exception exception, string failureMessage); + public void OperationFailed(Exception exception, string failureMessage); } } diff --git a/com.beatwaves.responsible/Runtime/IGlobalContextProvider.cs b/com.beatwaves.responsible/Runtime/IGlobalContextProvider.cs index 4ef40240..69b1e86f 100644 --- a/com.beatwaves.responsible/Runtime/IGlobalContextProvider.cs +++ b/com.beatwaves.responsible/Runtime/IGlobalContextProvider.cs @@ -11,6 +11,6 @@ public interface IGlobalContextProvider /// Add any details that might be useful as global context to include when test operations fail. /// /// The string builder to use to build the context. - void BuildGlobalContext(StateStringBuilder contextBuilder); + public void BuildGlobalContext(StateStringBuilder contextBuilder); } } diff --git a/com.beatwaves.responsible/Runtime/ITestOperation.cs b/com.beatwaves.responsible/Runtime/ITestOperation.cs index 17a6588a..0a12f204 100644 --- a/com.beatwaves.responsible/Runtime/ITestOperation.cs +++ b/com.beatwaves.responsible/Runtime/ITestOperation.cs @@ -34,6 +34,6 @@ public interface ITestOperation /// [Pure] [NotNull] - ITestOperationState CreateState(); + public ITestOperationState CreateState(); } } diff --git a/com.beatwaves.responsible/Runtime/ITestScheduler.cs b/com.beatwaves.responsible/Runtime/ITestScheduler.cs index 48b178da..05e2521e 100644 --- a/com.beatwaves.responsible/Runtime/ITestScheduler.cs +++ b/com.beatwaves.responsible/Runtime/ITestScheduler.cs @@ -15,7 +15,7 @@ public interface ITestScheduler /// Used for waiting for frames, and for providing state details for operations. /// /// Current frame value. - int FrameNow { get; } + public int FrameNow { get; } /// /// Returns the current time. @@ -26,7 +26,7 @@ public interface ITestScheduler /// /// This exists mostly so that it can be mocked in internal Responsible tests. /// - DateTimeOffset TimeNow { get; } + public DateTimeOffset TimeNow { get; } /// /// Registers a poll callback to be called at least once per frame. @@ -35,6 +35,6 @@ public interface ITestScheduler /// /// Action to call at least once on every frame. /// A disposable instance, which must unregister the callback when disposed. - IDisposable RegisterPollCallback(Action action); + public IDisposable RegisterPollCallback(Action action); } } diff --git a/com.beatwaves.responsible/Runtime/State/BoxedOperationState.cs b/com.beatwaves.responsible/Runtime/State/BoxedOperationState.cs index 24de64fc..e13e56e0 100644 --- a/com.beatwaves.responsible/Runtime/State/BoxedOperationState.cs +++ b/com.beatwaves.responsible/Runtime/State/BoxedOperationState.cs @@ -26,7 +26,7 @@ protected override async Task ExecuteInner(RunContext runContext, Cance return this.boxingSelector(result); } - public override void BuildDescription(StateStringBuilder builder) => this.state.BuildDescription(builder); + protected override void BuildDescription(StateStringBuilder builder) => this.state.BuildDescription(builder); } internal class BoxedOperationState : BoxedOperationState diff --git a/com.beatwaves.responsible/Runtime/State/ITestOperationState.cs b/com.beatwaves.responsible/Runtime/State/ITestOperationState.cs index 01246dbf..55c21553 100644 --- a/com.beatwaves.responsible/Runtime/State/ITestOperationState.cs +++ b/com.beatwaves.responsible/Runtime/State/ITestOperationState.cs @@ -11,16 +11,16 @@ namespace Responsible.State public interface ITestOperationState { /// - /// Current status of the test operation. Intended for internal use only. + /// Current status of the test operation. /// /// The current state of this test operation run. - TestOperationStatus Status { get; } + internal TestOperationStatus Status { get; } /// /// Adds a detailed description of the operation to the builder. /// /// State string builder to append the description of this operation state to. - void BuildDescription(StateStringBuilder builder); + internal void BuildDescription(StateStringBuilder builder); } /// @@ -40,8 +40,6 @@ public interface ITestOperationState : ITestOperationState { /// /// Starts execution of the the operation this state was created from. - /// - /// Intended for internal use only. /// /// The test operation run context this run is part of. /// Cancellation token for canceling the run. @@ -53,7 +51,7 @@ public interface ITestOperationState : ITestOperationState /// we have to use this unsafe method. However, it is used only from an extension method, /// which does the correct type inference for us, so overall, things are safe. /// - Task ExecuteUnsafe(RunContext runContext, CancellationToken cancellationToken); + internal Task ExecuteUnsafe(RunContext runContext, CancellationToken cancellationToken); // where T : TResult <-- not supported in C# } } diff --git a/com.beatwaves.responsible/Runtime/State/SelectOperationState.cs b/com.beatwaves.responsible/Runtime/State/SelectOperationState.cs index 6caaa3d2..a2bc6e60 100644 --- a/com.beatwaves.responsible/Runtime/State/SelectOperationState.cs +++ b/com.beatwaves.responsible/Runtime/State/SelectOperationState.cs @@ -35,7 +35,7 @@ protected override async Task ExecuteInner(RunContext runContext, Cancellati return await this.selectState.Execute(runContext, cancellationToken); } - public override void BuildDescription(StateStringBuilder builder) => + protected override void BuildDescription(StateStringBuilder builder) => builder.AddSelect(this.first, this.SelectStatus); } } diff --git a/com.beatwaves.responsible/Runtime/State/TestOperationStatus.cs b/com.beatwaves.responsible/Runtime/State/TestOperationStatus.cs index a5df5670..b549b8f9 100644 --- a/com.beatwaves.responsible/Runtime/State/TestOperationStatus.cs +++ b/com.beatwaves.responsible/Runtime/State/TestOperationStatus.cs @@ -12,10 +12,8 @@ namespace Responsible.State /// * Completed /// * Failed /// * Canceled - /// - /// Not intended for public use. /// - public abstract class TestOperationStatus + internal abstract class TestOperationStatus { internal abstract string MakeStatusLine(string description); diff --git a/com.beatwaves.responsible/Runtime/State/TestOperationsState.cs b/com.beatwaves.responsible/Runtime/State/TestOperationsState.cs index ab2ece58..84152feb 100644 --- a/com.beatwaves.responsible/Runtime/State/TestOperationsState.cs +++ b/com.beatwaves.responsible/Runtime/State/TestOperationsState.cs @@ -8,42 +8,44 @@ namespace Responsible.State internal abstract class TestOperationState : ITestOperationState { private readonly SourceContext? sourceContext; + private TestOperationStatus status = TestOperationStatus.NotExecuted.Instance; - public TestOperationStatus Status { get; private set; } = TestOperationStatus.NotExecuted.Instance; + TestOperationStatus ITestOperationState.Status => this.status; protected TestOperationState(SourceContext? sourceContext) { this.sourceContext = sourceContext; } - public async Task ExecuteUnsafe(RunContext runContext, CancellationToken cancellationToken) + async Task ITestOperationState.ExecuteUnsafe(RunContext runContext, CancellationToken cancellationToken) { var nestedRunContext = this.sourceContext != null ? runContext.MakeNested(this.sourceContext.Value) : runContext; - this.Status = new TestOperationStatus.Waiting(this.Status, runContext.MakeWaitContext()); + this.status = new TestOperationStatus.Waiting(this.status, runContext.MakeWaitContext()); try { var result = await this.ExecuteInner(nestedRunContext, cancellationToken); - this.Status = new TestOperationStatus.Completed(this.Status); + this.status = new TestOperationStatus.Completed(this.status); return (TResult)(object)result; // See the Execute extension method for why this is safe. } catch (OperationCanceledException) { - this.Status = new TestOperationStatus.Canceled(this.Status); + this.status = new TestOperationStatus.Canceled(this.status); throw; } catch (Exception e) { - this.Status = new TestOperationStatus.Failed(this.Status, e, nestedRunContext.SourceContext); + this.status = new TestOperationStatus.Failed(this.status, e, nestedRunContext.SourceContext); throw; } } protected abstract Task ExecuteInner(RunContext runContext, CancellationToken cancellationToken); - public abstract void BuildDescription(StateStringBuilder builder); + void ITestOperationState.BuildDescription(StateStringBuilder builder) => this.BuildDescription(builder); + protected abstract void BuildDescription(StateStringBuilder builder); public override string ToString() => StateStringBuilder.MakeState(this); } diff --git a/com.beatwaves.responsible/Runtime/State/UntilResponderState.cs b/com.beatwaves.responsible/Runtime/State/UntilResponderState.cs index e95f093b..e2508573 100644 --- a/com.beatwaves.responsible/Runtime/State/UntilResponderState.cs +++ b/com.beatwaves.responsible/Runtime/State/UntilResponderState.cs @@ -52,7 +52,7 @@ protected override async Task ExecuteInner(RunContext runContext, Cancellatio } } - public override void BuildDescription(StateStringBuilder builder) => + protected override void BuildDescription(StateStringBuilder builder) => builder.AddUntilResponder( "RESPOND TO", this.respondTo, diff --git a/com.beatwaves.responsible/Runtime/TestInstructions/ContinuationTestInstruction.cs b/com.beatwaves.responsible/Runtime/TestInstructions/ContinuationTestInstruction.cs index a3852f2a..b106a849 100644 --- a/com.beatwaves.responsible/Runtime/TestInstructions/ContinuationTestInstruction.cs +++ b/com.beatwaves.responsible/Runtime/TestInstructions/ContinuationTestInstruction.cs @@ -37,7 +37,7 @@ protected override async Task ExecuteInner(RunContext runContext, Cancellati return await this.continuation.Execute(firstResult, runContext, cancellationToken); } - public override void BuildDescription(StateStringBuilder builder) => + protected override void BuildDescription(StateStringBuilder builder) => builder.AddContinuation(this.first, this.continuation.State); } } diff --git a/com.beatwaves.responsible/Runtime/TestInstructions/ExpectConditionInstruction.cs b/com.beatwaves.responsible/Runtime/TestInstructions/ExpectConditionInstruction.cs index f107df4e..6c662951 100644 --- a/com.beatwaves.responsible/Runtime/TestInstructions/ExpectConditionInstruction.cs +++ b/com.beatwaves.responsible/Runtime/TestInstructions/ExpectConditionInstruction.cs @@ -35,7 +35,7 @@ protected override Task ExecuteInner(RunContext runContext, CancellationToken cancellationToken, ct => this.condition.Execute(runContext, ct)); - public override void BuildDescription(StateStringBuilder builder) => + protected override void BuildDescription(StateStringBuilder builder) => builder.AddExpectWithin(this, this.timeout, this.condition); } } diff --git a/com.beatwaves.responsible/Runtime/TestInstructions/ExpectTestResponse.cs b/com.beatwaves.responsible/Runtime/TestInstructions/ExpectTestResponse.cs index c4099938..f1a19bf5 100644 --- a/com.beatwaves.responsible/Runtime/TestInstructions/ExpectTestResponse.cs +++ b/com.beatwaves.responsible/Runtime/TestInstructions/ExpectTestResponse.cs @@ -38,7 +38,7 @@ protected override async Task ExecuteInner(RunContext runContext, Cancellatio return await instruction.Execute(runContext, cancellationToken); } - public override void BuildDescription(StateStringBuilder builder) => + protected override void BuildDescription(StateStringBuilder builder) => builder.AddExpectWithin(this, this.timeout, this.responder); } } diff --git a/com.beatwaves.responsible/Runtime/TestInstructions/GroupedAsInstruction.cs b/com.beatwaves.responsible/Runtime/TestInstructions/GroupedAsInstruction.cs index 1eee2646..904724a2 100644 --- a/com.beatwaves.responsible/Runtime/TestInstructions/GroupedAsInstruction.cs +++ b/com.beatwaves.responsible/Runtime/TestInstructions/GroupedAsInstruction.cs @@ -31,7 +31,7 @@ public State( protected override Task ExecuteInner(RunContext runContext, CancellationToken cancellationToken) => this.state.Execute(runContext, cancellationToken); - public override void BuildDescription(StateStringBuilder builder) => + protected override void BuildDescription(StateStringBuilder builder) => builder.AddParentWithChildren(this.description, this, new[] { this.state }); } } diff --git a/com.beatwaves.responsible/Runtime/TestInstructions/SequencedTestInstruction.cs b/com.beatwaves.responsible/Runtime/TestInstructions/SequencedTestInstruction.cs index c9a808f3..d7e459b1 100644 --- a/com.beatwaves.responsible/Runtime/TestInstructions/SequencedTestInstruction.cs +++ b/com.beatwaves.responsible/Runtime/TestInstructions/SequencedTestInstruction.cs @@ -38,7 +38,7 @@ protected override async Task ExecuteInner( return await this.second.Execute(runContext, cancellationToken); } - public override void BuildDescription(StateStringBuilder builder) => + protected override void BuildDescription(StateStringBuilder builder) => builder.AddContinuation(this.first, new ContinuationState.Available(this.second)); } } diff --git a/com.beatwaves.responsible/Runtime/TestInstructions/SynchronousTestInstruction.cs b/com.beatwaves.responsible/Runtime/TestInstructions/SynchronousTestInstruction.cs index 6fc68e87..4d337c17 100644 --- a/com.beatwaves.responsible/Runtime/TestInstructions/SynchronousTestInstruction.cs +++ b/com.beatwaves.responsible/Runtime/TestInstructions/SynchronousTestInstruction.cs @@ -28,7 +28,7 @@ public State(string description, Func action, SourceContext sourceContext) protected override Task ExecuteInner(RunContext runContext, CancellationToken cancellationToken) => Task.FromResult(this.action()); - public override void BuildDescription(StateStringBuilder builder) => + protected override void BuildDescription(StateStringBuilder builder) => builder.AddInstruction(this, this.description); } } diff --git a/com.beatwaves.responsible/Runtime/TestInstructions/WaitForFramesInstruction.cs b/com.beatwaves.responsible/Runtime/TestInstructions/WaitForFramesInstruction.cs index 00ef0228..0fe66add 100644 --- a/com.beatwaves.responsible/Runtime/TestInstructions/WaitForFramesInstruction.cs +++ b/com.beatwaves.responsible/Runtime/TestInstructions/WaitForFramesInstruction.cs @@ -33,7 +33,7 @@ protected override Task ExecuteInner(RunContext runContext, Cancellation cancellationToken); } - public override void BuildDescription(StateStringBuilder builder) => + protected override void BuildDescription(StateStringBuilder builder) => builder.AddInstruction(this, $"WAIT FOR {this.wholeFramesToWaitFor} FRAME(S)"); } } diff --git a/com.beatwaves.responsible/Runtime/TestInstructions/WaitForInstruction.cs b/com.beatwaves.responsible/Runtime/TestInstructions/WaitForInstruction.cs index 405751dd..c6ec55b6 100644 --- a/com.beatwaves.responsible/Runtime/TestInstructions/WaitForInstruction.cs +++ b/com.beatwaves.responsible/Runtime/TestInstructions/WaitForInstruction.cs @@ -35,7 +35,7 @@ protected override Task ExecuteInner( cancellationToken); } - public override void BuildDescription(StateStringBuilder builder) => + protected override void BuildDescription(StateStringBuilder builder) => builder.AddInstruction(this, $"WAIT FOR {this.waitTime:g}"); } } diff --git a/com.beatwaves.responsible/Runtime/TestResponders/AnyOfResponder.cs b/com.beatwaves.responsible/Runtime/TestResponders/AnyOfResponder.cs index 041c77a9..79e066c3 100644 --- a/com.beatwaves.responsible/Runtime/TestResponders/AnyOfResponder.cs +++ b/com.beatwaves.responsible/Runtime/TestResponders/AnyOfResponder.cs @@ -36,7 +36,7 @@ DeferredTask> MakeLauncher( return Task.FromResult(MultipleTaskSource.Make(this.responders.Select(MakeLauncher))); } - public override void BuildDescription(StateStringBuilder builder) => + protected override void BuildDescription(StateStringBuilder builder) => builder.AddToPreviousLineWithChildren(" ANY OF", this.responders); } } diff --git a/com.beatwaves.responsible/Runtime/TestResponders/RepeatedlyResponder.cs b/com.beatwaves.responsible/Runtime/TestResponders/RepeatedlyResponder.cs index 150a884d..639a8743 100644 --- a/com.beatwaves.responsible/Runtime/TestResponders/RepeatedlyResponder.cs +++ b/com.beatwaves.responsible/Runtime/TestResponders/RepeatedlyResponder.cs @@ -53,7 +53,7 @@ protected override Task>> Execut })); } - public override void BuildDescription(StateStringBuilder builder) + protected override void BuildDescription(StateStringBuilder builder) { if (!this.states.Any()) { diff --git a/com.beatwaves.responsible/Runtime/TestResponders/SelectResponder.cs b/com.beatwaves.responsible/Runtime/TestResponders/SelectResponder.cs index 79318999..2ed8a70a 100644 --- a/com.beatwaves.responsible/Runtime/TestResponders/SelectResponder.cs +++ b/com.beatwaves.responsible/Runtime/TestResponders/SelectResponder.cs @@ -43,7 +43,7 @@ protected override async Task> ExecuteInner( return this.selectState; } - public override void BuildDescription(StateStringBuilder builder) => + protected override void BuildDescription(StateStringBuilder builder) => builder.AddSelect( this.responder, this.selectState?.SelectStatus ?? TestOperationStatus.NotExecuted.Instance); diff --git a/com.beatwaves.responsible/Runtime/TestResponders/TestResponder.cs b/com.beatwaves.responsible/Runtime/TestResponders/TestResponder.cs index 0f4ca3ad..73bf8b78 100644 --- a/com.beatwaves.responsible/Runtime/TestResponders/TestResponder.cs +++ b/com.beatwaves.responsible/Runtime/TestResponders/TestResponder.cs @@ -48,7 +48,7 @@ protected override async Task> ExecuteInner( return instruction; } - public override void BuildDescription(StateStringBuilder builder) => builder.AddResponder(this); + protected override void BuildDescription(StateStringBuilder builder) => builder.AddResponder(this); } } } diff --git a/com.beatwaves.responsible/Runtime/TestWaitConditions/AllOfWaitCondition.cs b/com.beatwaves.responsible/Runtime/TestWaitConditions/AllOfWaitCondition.cs index 51d9b74b..6403ba76 100644 --- a/com.beatwaves.responsible/Runtime/TestWaitConditions/AllOfWaitCondition.cs +++ b/com.beatwaves.responsible/Runtime/TestWaitConditions/AllOfWaitCondition.cs @@ -38,7 +38,7 @@ protected override async Task ExecuteInner(RunContext runContext, Cancellat } - public override void BuildDescription(StateStringBuilder builder) => + protected override void BuildDescription(StateStringBuilder builder) => builder.AddParentWithChildren( "WAIT FOR ALL OF", this, diff --git a/com.beatwaves.responsible/Runtime/TestWaitConditions/ContinuedWaitCondition.cs b/com.beatwaves.responsible/Runtime/TestWaitConditions/ContinuedWaitCondition.cs index 5de217cb..530e95cc 100644 --- a/com.beatwaves.responsible/Runtime/TestWaitConditions/ContinuedWaitCondition.cs +++ b/com.beatwaves.responsible/Runtime/TestWaitConditions/ContinuedWaitCondition.cs @@ -40,7 +40,7 @@ protected override async Task ExecuteInner( return await this.continuation.Execute(firstResult, runContext, cancellationToken); } - public override void BuildDescription(StateStringBuilder builder) => + protected override void BuildDescription(StateStringBuilder builder) => builder.AddContinuation(this.first, this.continuation.State); } } diff --git a/com.beatwaves.responsible/Runtime/TestWaitConditions/PollingWaitCondition.cs b/com.beatwaves.responsible/Runtime/TestWaitConditions/PollingWaitCondition.cs index c807cd12..769d0b12 100644 --- a/com.beatwaves.responsible/Runtime/TestWaitConditions/PollingWaitCondition.cs +++ b/com.beatwaves.responsible/Runtime/TestWaitConditions/PollingWaitCondition.cs @@ -48,7 +48,7 @@ protected override Task ExecuteInner(RunContext runContext, CancellationToken this.condition, cancellationToken); - public override void BuildDescription(StateStringBuilder builder) => builder.AddWait(this); + protected override void BuildDescription(StateStringBuilder builder) => builder.AddWait(this); } } } diff --git a/com.beatwaves.responsible/Runtime/TestWaitConditions/RepeatUntilCondition.cs b/com.beatwaves.responsible/Runtime/TestWaitConditions/RepeatUntilCondition.cs index ae6ec998..4031bcd8 100644 --- a/com.beatwaves.responsible/Runtime/TestWaitConditions/RepeatUntilCondition.cs +++ b/com.beatwaves.responsible/Runtime/TestWaitConditions/RepeatUntilCondition.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using Responsible.Context; @@ -37,7 +37,7 @@ public State( this.waitState = condition.CreateState(); } - public override void BuildDescription(StateStringBuilder builder) + protected override void BuildDescription(StateStringBuilder builder) { builder.AddNestedDetails("UNTIL", this.waitState.BuildDescription); builder.AddNestedDetails("REPEATEDLY EXECUTING", b => diff --git a/com.beatwaves.responsible/Runtime/TestWaitConditions/RespondToAllOfWaitCondition.cs b/com.beatwaves.responsible/Runtime/TestWaitConditions/RespondToAllOfWaitCondition.cs index 4b415aa9..dadf64c9 100644 --- a/com.beatwaves.responsible/Runtime/TestWaitConditions/RespondToAllOfWaitCondition.cs +++ b/com.beatwaves.responsible/Runtime/TestWaitConditions/RespondToAllOfWaitCondition.cs @@ -46,7 +46,7 @@ protected override async Task ExecuteInner(RunContext runContext, Cancellat return results; } - public override void BuildDescription(StateStringBuilder builder) => + protected override void BuildDescription(StateStringBuilder builder) => builder.AddToPreviousLineWithChildren(" ALL OF", this.responders); } } diff --git a/com.beatwaves.responsible/Runtime/TestWaitConditions/SequencedWaitCondition.cs b/com.beatwaves.responsible/Runtime/TestWaitConditions/SequencedWaitCondition.cs index 087fb972..330303a1 100644 --- a/com.beatwaves.responsible/Runtime/TestWaitConditions/SequencedWaitCondition.cs +++ b/com.beatwaves.responsible/Runtime/TestWaitConditions/SequencedWaitCondition.cs @@ -38,7 +38,7 @@ protected override async Task ExecuteInner( return await this.second.Execute(runContext, cancellationToken); } - public override void BuildDescription(StateStringBuilder builder) => + protected override void BuildDescription(StateStringBuilder builder) => builder.AddContinuation(this.first, new ContinuationState.Available(this.second)); } } diff --git a/com.beatwaves.responsible/Runtime/TestWaitConditions/TaskWaitCondition.cs b/com.beatwaves.responsible/Runtime/TestWaitConditions/TaskWaitCondition.cs index d0598855..2e672194 100644 --- a/com.beatwaves.responsible/Runtime/TestWaitConditions/TaskWaitCondition.cs +++ b/com.beatwaves.responsible/Runtime/TestWaitConditions/TaskWaitCondition.cs @@ -30,7 +30,7 @@ public State(string description, Func> taskRunner, So protected override Task ExecuteInner(RunContext runContext, CancellationToken cancellationToken) => this.taskRunner(cancellationToken); - public override void BuildDescription(StateStringBuilder builder) + protected override void BuildDescription(StateStringBuilder builder) => builder.AddWait(this); } } diff --git a/com.beatwaves.responsible/Runtime/Unity/ConstraintWaitCondition.cs b/com.beatwaves.responsible/Runtime/Unity/ConstraintWaitCondition.cs index 95620b4b..11f82271 100644 --- a/com.beatwaves.responsible/Runtime/Unity/ConstraintWaitCondition.cs +++ b/com.beatwaves.responsible/Runtime/Unity/ConstraintWaitCondition.cs @@ -57,7 +57,7 @@ protected override Task ExecuteInner(RunContext runContext, CancellationToken obj => this.constraint.ApplyTo(obj).IsSuccess, cancellationToken); - public override void BuildDescription(StateStringBuilder builder) => builder.AddWait(this); + protected override void BuildDescription(StateStringBuilder builder) => builder.AddWait(this); private void AddDetails(StateStringBuilder stateBuilder) { diff --git a/com.beatwaves.responsible/Runtime/Unity/CoroutineWaitCondition.cs b/com.beatwaves.responsible/Runtime/Unity/CoroutineWaitCondition.cs index 9eee450c..888e6bc2 100644 --- a/com.beatwaves.responsible/Runtime/Unity/CoroutineWaitCondition.cs +++ b/com.beatwaves.responsible/Runtime/Unity/CoroutineWaitCondition.cs @@ -97,7 +97,7 @@ private IEnumerator RunCoroutine( HandleImpossibleConcurrentCancellation(cancellationToken, completionSource); } - public override void BuildDescription(StateStringBuilder builder) => builder.AddWait(this); + protected override void BuildDescription(StateStringBuilder builder) => builder.AddWait(this); [ExcludeFromCodeCoverage] private static void HandleImpossibleConcurrentCancellation( diff --git a/com.beatwaves.responsible/Runtime/Utilities/IMultipleTaskAwaiter.cs b/com.beatwaves.responsible/Runtime/Utilities/IMultipleTaskAwaiter.cs index 224b8759..c94f4869 100644 --- a/com.beatwaves.responsible/Runtime/Utilities/IMultipleTaskAwaiter.cs +++ b/com.beatwaves.responsible/Runtime/Utilities/IMultipleTaskAwaiter.cs @@ -9,7 +9,7 @@ namespace Responsible.Utilities /// Intended only for internal use, but is public, because it's visible from other interfaces. /// /// Type of the tasks that this instance yields. - public interface IMultipleTaskAwaiter + internal interface IMultipleTaskAwaiter { /// /// Determines if there are more tasks to await for. diff --git a/com.beatwaves.responsible/Runtime/Utilities/IMultipleTaskSource.cs b/com.beatwaves.responsible/Runtime/Utilities/IMultipleTaskSource.cs index b49c396a..5fadd3c6 100644 --- a/com.beatwaves.responsible/Runtime/Utilities/IMultipleTaskSource.cs +++ b/com.beatwaves.responsible/Runtime/Utilities/IMultipleTaskSource.cs @@ -19,6 +19,6 @@ public interface IMultipleTaskSource /// Cancellation token passed to all the tasks started by this source. /// /// A multiple task awaiter for the deferred tasks in this source. - IMultipleTaskAwaiter Start(CancellationToken cancellationToken); + internal IMultipleTaskAwaiter Start(CancellationToken cancellationToken); } } diff --git a/com.beatwaves.responsible/Runtime/Utilities/MultipleTaskSource.cs b/com.beatwaves.responsible/Runtime/Utilities/MultipleTaskSource.cs index 7ac78a4b..1c42c2e7 100644 --- a/com.beatwaves.responsible/Runtime/Utilities/MultipleTaskSource.cs +++ b/com.beatwaves.responsible/Runtime/Utilities/MultipleTaskSource.cs @@ -19,7 +19,7 @@ public MultipleTaskSource(IEnumerable> deferredTasks) this.taskFactories = deferredTasks.ToList(); } - public IMultipleTaskAwaiter Start(CancellationToken cancellationToken) + IMultipleTaskAwaiter IMultipleTaskSource.Start(CancellationToken cancellationToken) => MultipleTaskAwaiter.Make(this.taskFactories .Select(factory => factory(cancellationToken))); } diff --git a/com.beatwaves.responsible/Runtime/Utilities/RepeatedTaskSource.cs b/com.beatwaves.responsible/Runtime/Utilities/RepeatedTaskSource.cs index cd8c0b4c..8b10ddfd 100644 --- a/com.beatwaves.responsible/Runtime/Utilities/RepeatedTaskSource.cs +++ b/com.beatwaves.responsible/Runtime/Utilities/RepeatedTaskSource.cs @@ -15,7 +15,7 @@ public RepeatedTaskSource(DeferredTask taskFactory) this.taskFactory = taskFactory; } - public IMultipleTaskAwaiter Start(CancellationToken cancellationToken) + IMultipleTaskAwaiter IMultipleTaskSource.Start(CancellationToken cancellationToken) { return new Awaiter(this.taskFactory, cancellationToken); }