diff --git a/src/core/Akka.API.Tests/verify/CoreAPISpec.ApproveTestKit.DotNet.verified.txt b/src/core/Akka.API.Tests/verify/CoreAPISpec.ApproveTestKit.DotNet.verified.txt index d03820034c4..03eca1dd3b2 100644 --- a/src/core/Akka.API.Tests/verify/CoreAPISpec.ApproveTestKit.DotNet.verified.txt +++ b/src/core/Akka.API.Tests/verify/CoreAPISpec.ApproveTestKit.DotNet.verified.txt @@ -622,43 +622,51 @@ namespace Akka.TestKit.Extensions } namespace Akka.TestKit.Internal { + [System.Runtime.CompilerServices.NullableAttribute(0)] public class CustomEventFilter : Akka.TestKit.Internal.EventFilterBase { public CustomEventFilter(System.Predicate predicate) { } protected override string FilterDescriptiveName { get; } protected override bool IsMatch(Akka.Event.LogEvent evt) { } } + [System.Runtime.CompilerServices.NullableAttribute(0)] public class DebugFilter : Akka.TestKit.Internal.EventFilterBase { public DebugFilter(Akka.TestKit.Internal.StringMatcher.IStringMatcher messageMatcher = null, Akka.TestKit.Internal.StringMatcher.IStringMatcher sourceMatcher = null) { } protected override string FilterDescriptiveName { get; } protected override bool IsMatch(Akka.Event.LogEvent evt) { } } + [System.Runtime.CompilerServices.NullableAttribute(0)] public class ErrorFilter : Akka.TestKit.Internal.EventFilterBase { public ErrorFilter(Akka.TestKit.Internal.StringMatcher.IStringMatcher messageMatcher = null, Akka.TestKit.Internal.StringMatcher.IStringMatcher sourceMatcher = null) { } public ErrorFilter(System.Type exceptionType, Akka.TestKit.Internal.StringMatcher.IStringMatcher messageMatcher = null, Akka.TestKit.Internal.StringMatcher.IStringMatcher sourceMatcher = null, bool recurseInnerExceptions = False) { } + [System.Runtime.CompilerServices.NullableAttribute(1)] protected override string FilterDescriptiveName { get; } protected override bool IsMatch(Akka.Event.LogEvent evt) { } } + [System.Runtime.CompilerServices.NullableAttribute(0)] public abstract class EventFilterBase : Akka.TestKit.IEventFilter { protected EventFilterBase(Akka.TestKit.Internal.StringMatcher.IStringMatcher messageMatcher, Akka.TestKit.Internal.StringMatcher.IStringMatcher sourceMatcher) { } protected abstract string FilterDescriptiveName { get; } + [System.Runtime.CompilerServices.NullableAttribute(2)] public event Akka.TestKit.Internal.EventMatched EventMatched; public bool Apply(Akka.Event.LogEvent logEvent) { } - protected bool InternalDoMatch(string src, object msg) { } + protected bool InternalDoMatch(string src, [System.Runtime.CompilerServices.NullableAttribute(2)] object msg) { } protected abstract bool IsMatch(Akka.Event.LogEvent evt); protected virtual void OnEventMatched(Akka.Event.LogEvent logEvent) { } public override string ToString() { } } public delegate void EventMatched(Akka.TestKit.Internal.EventFilterBase eventFilter, Akka.Event.LogEvent logEvent); + [System.Runtime.CompilerServices.NullableAttribute(0)] public class InfoFilter : Akka.TestKit.Internal.EventFilterBase { public InfoFilter(Akka.TestKit.Internal.StringMatcher.IStringMatcher messageMatcher = null, Akka.TestKit.Internal.StringMatcher.IStringMatcher sourceMatcher = null) { } protected override string FilterDescriptiveName { get; } protected override bool IsMatch(Akka.Event.LogEvent evt) { } } + [System.Runtime.CompilerServices.NullableAttribute(0)] public class InternalEventFilterApplier : Akka.TestKit.IEventFilterApplier { public InternalEventFilterApplier(Akka.TestKit.TestKitBase testkit, Akka.Actor.ActorSystem system, System.Collections.Generic.IReadOnlyList filters) { } @@ -667,32 +675,32 @@ namespace Akka.TestKit.Internal protected System.Threading.Tasks.Task AwaitDoneAsync(System.TimeSpan timeout, System.Nullable expectedOccurrences, Akka.TestKit.Internal.InternalEventFilterApplier.MatchedEventHandler matchedEventHandler, System.Threading.CancellationToken cancellationToken = null) { } public void Expect(int expectedCount, System.Action action, System.Threading.CancellationToken cancellationToken = null) { } public void Expect(int expectedCount, System.TimeSpan timeout, System.Action action, System.Threading.CancellationToken cancellationToken = null) { } - public T Expect(int expectedCount, System.Func func, System.Threading.CancellationToken cancellationToken = null) { } - public T Expect(int expectedCount, System.TimeSpan timeout, System.Func func, System.Threading.CancellationToken cancellationToken = null) { } + public T Expect<[System.Runtime.CompilerServices.NullableAttribute(2)] T>(int expectedCount, System.Func func, System.Threading.CancellationToken cancellationToken = null) { } + public T Expect<[System.Runtime.CompilerServices.NullableAttribute(2)] T>(int expectedCount, System.TimeSpan timeout, System.Func func, System.Threading.CancellationToken cancellationToken = null) { } public System.Threading.Tasks.Task ExpectAsync(int expectedCount, System.Func actionAsync, System.Threading.CancellationToken cancellationToken = null) { } public System.Threading.Tasks.Task ExpectAsync(int expectedCount, System.Func actionAsync, System.Nullable timeout, System.Threading.CancellationToken cancellationToken = null) { } public System.Threading.Tasks.Task ExpectAsync(int expectedCount, System.TimeSpan timeout, System.Func action, System.Threading.CancellationToken cancellationToken = null) { } public System.Threading.Tasks.Task ExpectAsync(int expectedCount, System.TimeSpan timeout, System.Action action, System.Threading.CancellationToken cancellationToken = null) { } - public System.Threading.Tasks.Task ExpectAsync(int expectedCount, System.Func> func, System.Threading.CancellationToken cancellationToken = null) { } - public System.Threading.Tasks.Task ExpectAsync(int expectedCount, System.TimeSpan timeout, System.Func> func, System.Threading.CancellationToken cancellationToken = null) { } + public System.Threading.Tasks.Task ExpectAsync<[System.Runtime.CompilerServices.NullableAttribute(2)] T>(int expectedCount, System.Func> func, System.Threading.CancellationToken cancellationToken = null) { } + public System.Threading.Tasks.Task ExpectAsync<[System.Runtime.CompilerServices.NullableAttribute(2)] T>(int expectedCount, System.TimeSpan timeout, System.Func> func, System.Threading.CancellationToken cancellationToken = null) { } public void ExpectOne(System.Action action, System.Threading.CancellationToken cancellationToken = null) { } public void ExpectOne(System.TimeSpan timeout, System.Action action, System.Threading.CancellationToken cancellationToken = null) { } - public T ExpectOne(System.Func func, System.Threading.CancellationToken cancellationToken = null) { } - public T ExpectOne(System.TimeSpan timeout, System.Func func, System.Threading.CancellationToken cancellationToken = null) { } + public T ExpectOne<[System.Runtime.CompilerServices.NullableAttribute(2)] T>(System.Func func, System.Threading.CancellationToken cancellationToken = null) { } + public T ExpectOne<[System.Runtime.CompilerServices.NullableAttribute(2)] T>(System.TimeSpan timeout, System.Func func, System.Threading.CancellationToken cancellationToken = null) { } [System.ObsoleteAttribute("Only for backwards compat. Use ExpectOneAsync(Func, CancellationToken) inst" + "ead beginning in Akka.NET v1.5")] public System.Threading.Tasks.Task ExpectOneAsync(System.Action action, System.Threading.CancellationToken cancellationToken = null) { } public System.Threading.Tasks.Task ExpectOneAsync(System.Func action, System.Threading.CancellationToken cancellationToken = null) { } public System.Threading.Tasks.Task ExpectOneAsync(System.TimeSpan timeout, System.Func action, System.Threading.CancellationToken cancellationToken = null) { } - public System.Threading.Tasks.Task ExpectOneAsync(System.Func> func, System.Threading.CancellationToken cancellationToken = null) { } - public System.Threading.Tasks.Task ExpectOneAsync(System.TimeSpan timeout, System.Func> func, System.Threading.CancellationToken cancellationToken = null) { } + public System.Threading.Tasks.Task ExpectOneAsync<[System.Runtime.CompilerServices.NullableAttribute(2)] T>(System.Func> func, System.Threading.CancellationToken cancellationToken = null) { } + public System.Threading.Tasks.Task ExpectOneAsync<[System.Runtime.CompilerServices.NullableAttribute(2)] T>(System.TimeSpan timeout, System.Func> func, System.Threading.CancellationToken cancellationToken = null) { } protected static string GetMessageString(int number) { } - protected T Intercept(System.Func func, Akka.Actor.ActorSystem system, System.Nullable timeout, System.Nullable expectedOccurrences, Akka.TestKit.Internal.InternalEventFilterApplier.MatchedEventHandler matchedEventHandler = null, System.Threading.CancellationToken cancellationToken = null) { } - protected System.Threading.Tasks.Task InterceptAsync(System.Func> func, Akka.Actor.ActorSystem system, System.Nullable timeout, System.Nullable expectedOccurrences, Akka.TestKit.Internal.InternalEventFilterApplier.MatchedEventHandler matchedEventHandler = null, System.Threading.CancellationToken cancellationToken = null) { } - public T Mute(System.Func func, System.Threading.CancellationToken cancellationToken = null) { } + protected T Intercept<[System.Runtime.CompilerServices.NullableAttribute(2)] T>(System.Func func, Akka.Actor.ActorSystem system, System.Nullable timeout, System.Nullable expectedOccurrences, [System.Runtime.CompilerServices.NullableAttribute(2)] Akka.TestKit.Internal.InternalEventFilterApplier.MatchedEventHandler matchedEventHandler = null, System.Threading.CancellationToken cancellationToken = null) { } + protected System.Threading.Tasks.Task InterceptAsync<[System.Runtime.CompilerServices.NullableAttribute(2)] T>(System.Func> func, Akka.Actor.ActorSystem system, System.Nullable timeout, System.Nullable expectedOccurrences, [System.Runtime.CompilerServices.NullableAttribute(2)] Akka.TestKit.Internal.InternalEventFilterApplier.MatchedEventHandler matchedEventHandler = null, System.Threading.CancellationToken cancellationToken = null) { } + public T Mute<[System.Runtime.CompilerServices.NullableAttribute(2)] T>(System.Func func, System.Threading.CancellationToken cancellationToken = null) { } public void Mute(System.Action action, System.Threading.CancellationToken cancellationToken = null) { } public Akka.TestKit.IUnmutableFilter Mute() { } - public System.Threading.Tasks.Task MuteAsync(System.Func> func, System.Threading.CancellationToken cancellationToken = null) { } + public System.Threading.Tasks.Task MuteAsync<[System.Runtime.CompilerServices.NullableAttribute(2)] T>(System.Func> func, System.Threading.CancellationToken cancellationToken = null) { } public System.Threading.Tasks.Task MuteAsync(System.Func action, System.Threading.CancellationToken cancellationToken = null) { } public System.Threading.Tasks.Task MuteAsync(System.Action action, System.Threading.CancellationToken cancellationToken = null) { } protected class InternalUnmutableFilter : Akka.TestKit.IUnmutableFilter, System.IDisposable @@ -749,6 +757,7 @@ namespace Akka.TestKit.Internal public static bool IsZero(this System.Nullable timeSpan) { } public static System.TimeSpan Min(this System.TimeSpan a, System.Nullable b) { } } + [System.Runtime.CompilerServices.NullableAttribute(0)] public class WarningFilter : Akka.TestKit.Internal.EventFilterBase { public WarningFilter(Akka.TestKit.Internal.StringMatcher.IStringMatcher messageMatcher = null, Akka.TestKit.Internal.StringMatcher.IStringMatcher sourceMatcher = null) { } @@ -758,18 +767,21 @@ namespace Akka.TestKit.Internal } namespace Akka.TestKit.Internal.StringMatcher { + [System.Runtime.CompilerServices.NullableAttribute(0)] public class ContainsString : Akka.TestKit.Internal.StringMatcher.IStringMatcher { public ContainsString(string part) { } public bool IsMatch(string s) { } public override string ToString() { } } + [System.Runtime.CompilerServices.NullableAttribute(0)] public class EqualsString : Akka.TestKit.Internal.StringMatcher.IStringMatcher { public EqualsString(string s) { } public bool IsMatch(string s) { } public override string ToString() { } } + [System.Runtime.CompilerServices.NullableAttribute(0)] public class EqualsStringAndPathMatcher : Akka.TestKit.Internal.StringMatcher.IStringMatcher { public EqualsStringAndPathMatcher(string path, bool canBeRelative = True) { } @@ -780,24 +792,28 @@ namespace Akka.TestKit.Internal.StringMatcher { bool IsMatch(string s); } + [System.Runtime.CompilerServices.NullableAttribute(0)] public class MatchesAll : Akka.TestKit.Internal.StringMatcher.IStringMatcher { public static Akka.TestKit.Internal.StringMatcher.IStringMatcher Instance { get; } public bool IsMatch(string s) { } public override string ToString() { } } + [System.Runtime.CompilerServices.NullableAttribute(0)] public class PredicateMatcher : Akka.TestKit.Internal.StringMatcher.IStringMatcher { public PredicateMatcher(System.Predicate predicate, string hint = "") { } public bool IsMatch(string s) { } public override string ToString() { } } + [System.Runtime.CompilerServices.NullableAttribute(0)] public class RegexMatcher : Akka.TestKit.Internal.StringMatcher.IStringMatcher { public RegexMatcher(System.Text.RegularExpressions.Regex regex) { } public bool IsMatch(string s) { } public override string ToString() { } } + [System.Runtime.CompilerServices.NullableAttribute(0)] public class StartsWithString : Akka.TestKit.Internal.StringMatcher.IStringMatcher { public StartsWithString(string start) { } diff --git a/src/core/Akka.API.Tests/verify/CoreAPISpec.ApproveTestKit.Net.verified.txt b/src/core/Akka.API.Tests/verify/CoreAPISpec.ApproveTestKit.Net.verified.txt index 2d42253c767..38ababa3327 100644 --- a/src/core/Akka.API.Tests/verify/CoreAPISpec.ApproveTestKit.Net.verified.txt +++ b/src/core/Akka.API.Tests/verify/CoreAPISpec.ApproveTestKit.Net.verified.txt @@ -622,43 +622,51 @@ namespace Akka.TestKit.Extensions } namespace Akka.TestKit.Internal { + [System.Runtime.CompilerServices.NullableAttribute(0)] public class CustomEventFilter : Akka.TestKit.Internal.EventFilterBase { public CustomEventFilter(System.Predicate predicate) { } protected override string FilterDescriptiveName { get; } protected override bool IsMatch(Akka.Event.LogEvent evt) { } } + [System.Runtime.CompilerServices.NullableAttribute(0)] public class DebugFilter : Akka.TestKit.Internal.EventFilterBase { public DebugFilter(Akka.TestKit.Internal.StringMatcher.IStringMatcher messageMatcher = null, Akka.TestKit.Internal.StringMatcher.IStringMatcher sourceMatcher = null) { } protected override string FilterDescriptiveName { get; } protected override bool IsMatch(Akka.Event.LogEvent evt) { } } + [System.Runtime.CompilerServices.NullableAttribute(0)] public class ErrorFilter : Akka.TestKit.Internal.EventFilterBase { public ErrorFilter(Akka.TestKit.Internal.StringMatcher.IStringMatcher messageMatcher = null, Akka.TestKit.Internal.StringMatcher.IStringMatcher sourceMatcher = null) { } public ErrorFilter(System.Type exceptionType, Akka.TestKit.Internal.StringMatcher.IStringMatcher messageMatcher = null, Akka.TestKit.Internal.StringMatcher.IStringMatcher sourceMatcher = null, bool recurseInnerExceptions = False) { } + [System.Runtime.CompilerServices.NullableAttribute(1)] protected override string FilterDescriptiveName { get; } protected override bool IsMatch(Akka.Event.LogEvent evt) { } } + [System.Runtime.CompilerServices.NullableAttribute(0)] public abstract class EventFilterBase : Akka.TestKit.IEventFilter { protected EventFilterBase(Akka.TestKit.Internal.StringMatcher.IStringMatcher messageMatcher, Akka.TestKit.Internal.StringMatcher.IStringMatcher sourceMatcher) { } protected abstract string FilterDescriptiveName { get; } + [System.Runtime.CompilerServices.NullableAttribute(2)] public event Akka.TestKit.Internal.EventMatched EventMatched; public bool Apply(Akka.Event.LogEvent logEvent) { } - protected bool InternalDoMatch(string src, object msg) { } + protected bool InternalDoMatch(string src, [System.Runtime.CompilerServices.NullableAttribute(2)] object msg) { } protected abstract bool IsMatch(Akka.Event.LogEvent evt); protected virtual void OnEventMatched(Akka.Event.LogEvent logEvent) { } public override string ToString() { } } public delegate void EventMatched(Akka.TestKit.Internal.EventFilterBase eventFilter, Akka.Event.LogEvent logEvent); + [System.Runtime.CompilerServices.NullableAttribute(0)] public class InfoFilter : Akka.TestKit.Internal.EventFilterBase { public InfoFilter(Akka.TestKit.Internal.StringMatcher.IStringMatcher messageMatcher = null, Akka.TestKit.Internal.StringMatcher.IStringMatcher sourceMatcher = null) { } protected override string FilterDescriptiveName { get; } protected override bool IsMatch(Akka.Event.LogEvent evt) { } } + [System.Runtime.CompilerServices.NullableAttribute(0)] public class InternalEventFilterApplier : Akka.TestKit.IEventFilterApplier { public InternalEventFilterApplier(Akka.TestKit.TestKitBase testkit, Akka.Actor.ActorSystem system, System.Collections.Generic.IReadOnlyList filters) { } @@ -667,32 +675,32 @@ namespace Akka.TestKit.Internal protected System.Threading.Tasks.Task AwaitDoneAsync(System.TimeSpan timeout, System.Nullable expectedOccurrences, Akka.TestKit.Internal.InternalEventFilterApplier.MatchedEventHandler matchedEventHandler, System.Threading.CancellationToken cancellationToken = null) { } public void Expect(int expectedCount, System.Action action, System.Threading.CancellationToken cancellationToken = null) { } public void Expect(int expectedCount, System.TimeSpan timeout, System.Action action, System.Threading.CancellationToken cancellationToken = null) { } - public T Expect(int expectedCount, System.Func func, System.Threading.CancellationToken cancellationToken = null) { } - public T Expect(int expectedCount, System.TimeSpan timeout, System.Func func, System.Threading.CancellationToken cancellationToken = null) { } + public T Expect<[System.Runtime.CompilerServices.NullableAttribute(2)] T>(int expectedCount, System.Func func, System.Threading.CancellationToken cancellationToken = null) { } + public T Expect<[System.Runtime.CompilerServices.NullableAttribute(2)] T>(int expectedCount, System.TimeSpan timeout, System.Func func, System.Threading.CancellationToken cancellationToken = null) { } public System.Threading.Tasks.Task ExpectAsync(int expectedCount, System.Func actionAsync, System.Threading.CancellationToken cancellationToken = null) { } public System.Threading.Tasks.Task ExpectAsync(int expectedCount, System.Func actionAsync, System.Nullable timeout, System.Threading.CancellationToken cancellationToken = null) { } public System.Threading.Tasks.Task ExpectAsync(int expectedCount, System.TimeSpan timeout, System.Func action, System.Threading.CancellationToken cancellationToken = null) { } public System.Threading.Tasks.Task ExpectAsync(int expectedCount, System.TimeSpan timeout, System.Action action, System.Threading.CancellationToken cancellationToken = null) { } - public System.Threading.Tasks.Task ExpectAsync(int expectedCount, System.Func> func, System.Threading.CancellationToken cancellationToken = null) { } - public System.Threading.Tasks.Task ExpectAsync(int expectedCount, System.TimeSpan timeout, System.Func> func, System.Threading.CancellationToken cancellationToken = null) { } + public System.Threading.Tasks.Task ExpectAsync<[System.Runtime.CompilerServices.NullableAttribute(2)] T>(int expectedCount, System.Func> func, System.Threading.CancellationToken cancellationToken = null) { } + public System.Threading.Tasks.Task ExpectAsync<[System.Runtime.CompilerServices.NullableAttribute(2)] T>(int expectedCount, System.TimeSpan timeout, System.Func> func, System.Threading.CancellationToken cancellationToken = null) { } public void ExpectOne(System.Action action, System.Threading.CancellationToken cancellationToken = null) { } public void ExpectOne(System.TimeSpan timeout, System.Action action, System.Threading.CancellationToken cancellationToken = null) { } - public T ExpectOne(System.Func func, System.Threading.CancellationToken cancellationToken = null) { } - public T ExpectOne(System.TimeSpan timeout, System.Func func, System.Threading.CancellationToken cancellationToken = null) { } + public T ExpectOne<[System.Runtime.CompilerServices.NullableAttribute(2)] T>(System.Func func, System.Threading.CancellationToken cancellationToken = null) { } + public T ExpectOne<[System.Runtime.CompilerServices.NullableAttribute(2)] T>(System.TimeSpan timeout, System.Func func, System.Threading.CancellationToken cancellationToken = null) { } [System.ObsoleteAttribute("Only for backwards compat. Use ExpectOneAsync(Func, CancellationToken) inst" + "ead beginning in Akka.NET v1.5")] public System.Threading.Tasks.Task ExpectOneAsync(System.Action action, System.Threading.CancellationToken cancellationToken = null) { } public System.Threading.Tasks.Task ExpectOneAsync(System.Func action, System.Threading.CancellationToken cancellationToken = null) { } public System.Threading.Tasks.Task ExpectOneAsync(System.TimeSpan timeout, System.Func action, System.Threading.CancellationToken cancellationToken = null) { } - public System.Threading.Tasks.Task ExpectOneAsync(System.Func> func, System.Threading.CancellationToken cancellationToken = null) { } - public System.Threading.Tasks.Task ExpectOneAsync(System.TimeSpan timeout, System.Func> func, System.Threading.CancellationToken cancellationToken = null) { } + public System.Threading.Tasks.Task ExpectOneAsync<[System.Runtime.CompilerServices.NullableAttribute(2)] T>(System.Func> func, System.Threading.CancellationToken cancellationToken = null) { } + public System.Threading.Tasks.Task ExpectOneAsync<[System.Runtime.CompilerServices.NullableAttribute(2)] T>(System.TimeSpan timeout, System.Func> func, System.Threading.CancellationToken cancellationToken = null) { } protected static string GetMessageString(int number) { } - protected T Intercept(System.Func func, Akka.Actor.ActorSystem system, System.Nullable timeout, System.Nullable expectedOccurrences, Akka.TestKit.Internal.InternalEventFilterApplier.MatchedEventHandler matchedEventHandler = null, System.Threading.CancellationToken cancellationToken = null) { } - protected System.Threading.Tasks.Task InterceptAsync(System.Func> func, Akka.Actor.ActorSystem system, System.Nullable timeout, System.Nullable expectedOccurrences, Akka.TestKit.Internal.InternalEventFilterApplier.MatchedEventHandler matchedEventHandler = null, System.Threading.CancellationToken cancellationToken = null) { } - public T Mute(System.Func func, System.Threading.CancellationToken cancellationToken = null) { } + protected T Intercept<[System.Runtime.CompilerServices.NullableAttribute(2)] T>(System.Func func, Akka.Actor.ActorSystem system, System.Nullable timeout, System.Nullable expectedOccurrences, [System.Runtime.CompilerServices.NullableAttribute(2)] Akka.TestKit.Internal.InternalEventFilterApplier.MatchedEventHandler matchedEventHandler = null, System.Threading.CancellationToken cancellationToken = null) { } + protected System.Threading.Tasks.Task InterceptAsync<[System.Runtime.CompilerServices.NullableAttribute(2)] T>(System.Func> func, Akka.Actor.ActorSystem system, System.Nullable timeout, System.Nullable expectedOccurrences, [System.Runtime.CompilerServices.NullableAttribute(2)] Akka.TestKit.Internal.InternalEventFilterApplier.MatchedEventHandler matchedEventHandler = null, System.Threading.CancellationToken cancellationToken = null) { } + public T Mute<[System.Runtime.CompilerServices.NullableAttribute(2)] T>(System.Func func, System.Threading.CancellationToken cancellationToken = null) { } public void Mute(System.Action action, System.Threading.CancellationToken cancellationToken = null) { } public Akka.TestKit.IUnmutableFilter Mute() { } - public System.Threading.Tasks.Task MuteAsync(System.Func> func, System.Threading.CancellationToken cancellationToken = null) { } + public System.Threading.Tasks.Task MuteAsync<[System.Runtime.CompilerServices.NullableAttribute(2)] T>(System.Func> func, System.Threading.CancellationToken cancellationToken = null) { } public System.Threading.Tasks.Task MuteAsync(System.Func action, System.Threading.CancellationToken cancellationToken = null) { } public System.Threading.Tasks.Task MuteAsync(System.Action action, System.Threading.CancellationToken cancellationToken = null) { } protected class InternalUnmutableFilter : Akka.TestKit.IUnmutableFilter, System.IDisposable @@ -749,6 +757,7 @@ namespace Akka.TestKit.Internal public static bool IsZero(this System.Nullable timeSpan) { } public static System.TimeSpan Min(this System.TimeSpan a, System.Nullable b) { } } + [System.Runtime.CompilerServices.NullableAttribute(0)] public class WarningFilter : Akka.TestKit.Internal.EventFilterBase { public WarningFilter(Akka.TestKit.Internal.StringMatcher.IStringMatcher messageMatcher = null, Akka.TestKit.Internal.StringMatcher.IStringMatcher sourceMatcher = null) { } @@ -758,18 +767,21 @@ namespace Akka.TestKit.Internal } namespace Akka.TestKit.Internal.StringMatcher { + [System.Runtime.CompilerServices.NullableAttribute(0)] public class ContainsString : Akka.TestKit.Internal.StringMatcher.IStringMatcher { public ContainsString(string part) { } public bool IsMatch(string s) { } public override string ToString() { } } + [System.Runtime.CompilerServices.NullableAttribute(0)] public class EqualsString : Akka.TestKit.Internal.StringMatcher.IStringMatcher { public EqualsString(string s) { } public bool IsMatch(string s) { } public override string ToString() { } } + [System.Runtime.CompilerServices.NullableAttribute(0)] public class EqualsStringAndPathMatcher : Akka.TestKit.Internal.StringMatcher.IStringMatcher { public EqualsStringAndPathMatcher(string path, bool canBeRelative = True) { } @@ -780,24 +792,28 @@ namespace Akka.TestKit.Internal.StringMatcher { bool IsMatch(string s); } + [System.Runtime.CompilerServices.NullableAttribute(0)] public class MatchesAll : Akka.TestKit.Internal.StringMatcher.IStringMatcher { public static Akka.TestKit.Internal.StringMatcher.IStringMatcher Instance { get; } public bool IsMatch(string s) { } public override string ToString() { } } + [System.Runtime.CompilerServices.NullableAttribute(0)] public class PredicateMatcher : Akka.TestKit.Internal.StringMatcher.IStringMatcher { public PredicateMatcher(System.Predicate predicate, string hint = "") { } public bool IsMatch(string s) { } public override string ToString() { } } + [System.Runtime.CompilerServices.NullableAttribute(0)] public class RegexMatcher : Akka.TestKit.Internal.StringMatcher.IStringMatcher { public RegexMatcher(System.Text.RegularExpressions.Regex regex) { } public bool IsMatch(string s) { } public override string ToString() { } } + [System.Runtime.CompilerServices.NullableAttribute(0)] public class StartsWithString : Akka.TestKit.Internal.StringMatcher.IStringMatcher { public StartsWithString(string start) { } diff --git a/src/core/Akka.TestKit/EventFilter/Internal/CustomEventFilter.cs b/src/core/Akka.TestKit/EventFilter/Internal/CustomEventFilter.cs index d2a25e6a6e4..81769f51515 100644 --- a/src/core/Akka.TestKit/EventFilter/Internal/CustomEventFilter.cs +++ b/src/core/Akka.TestKit/EventFilter/Internal/CustomEventFilter.cs @@ -8,38 +8,38 @@ using System; using Akka.Event; -namespace Akka.TestKit.Internal +#nullable enable +namespace Akka.TestKit.Internal; + +/// +/// Note! Part of internal API. Breaking changes may occur without notice. Use at own risk. +/// +public class CustomEventFilter : EventFilterBase { + private readonly Predicate _predicate; + /// - /// Note! Part of internal API. Breaking changes may occur without notice. Use at own risk. + /// TBD /// - public class CustomEventFilter : EventFilterBase + /// TBD + public CustomEventFilter(Predicate predicate) + : base(null, null) { - private readonly Predicate _predicate; - - /// - /// TBD - /// - /// TBD - public CustomEventFilter(Predicate predicate) - : base(null, null) - { - _predicate = predicate; - } - - /// - /// TBD - /// - /// TBD - /// TBD - protected override bool IsMatch(LogEvent evt) - { - return _predicate(evt); - } + _predicate = predicate; + } - /// - /// TBD - /// - protected override string FilterDescriptiveName { get { return "Custom"; } } + /// + /// TBD + /// + /// TBD + /// TBD + protected override bool IsMatch(LogEvent evt) + { + return _predicate(evt); } -} + + /// + /// TBD + /// + protected override string FilterDescriptiveName { get { return "Custom"; } } +} \ No newline at end of file diff --git a/src/core/Akka.TestKit/EventFilter/Internal/DebugFilter.cs b/src/core/Akka.TestKit/EventFilter/Internal/DebugFilter.cs index 638ea0e545f..823fdbfce36 100644 --- a/src/core/Akka.TestKit/EventFilter/Internal/DebugFilter.cs +++ b/src/core/Akka.TestKit/EventFilter/Internal/DebugFilter.cs @@ -8,42 +8,42 @@ using Akka.Event; using Akka.TestKit.Internal.StringMatcher; -namespace Akka.TestKit.Internal +#nullable enable +namespace Akka.TestKit.Internal; + +/// +/// Note! Part of internal API. Breaking changes may occur without notice. Use at own risk. +/// +public class DebugFilter : EventFilterBase { /// - /// Note! Part of internal API. Breaking changes may occur without notice. Use at own risk. + /// TBD /// - public class DebugFilter : EventFilterBase + /// TBD + /// TBD + public DebugFilter(IStringMatcher? messageMatcher = null, IStringMatcher? sourceMatcher = null) + : base(messageMatcher,sourceMatcher) { - /// - /// TBD - /// - /// TBD - /// TBD - public DebugFilter(IStringMatcher messageMatcher = null, IStringMatcher sourceMatcher = null) - : base(messageMatcher,sourceMatcher) - { - } + } - /// - /// TBD - /// - /// TBD - /// TBD - protected override bool IsMatch(LogEvent evt) + /// + /// TBD + /// + /// TBD + /// TBD + protected override bool IsMatch(LogEvent evt) + { + var debug = evt as Debug; + if(debug != null) { - var debug = evt as Debug; - if(debug != null) - { - return InternalDoMatch(debug.LogSource, debug.Message); - } - - return false; + return InternalDoMatch(debug.LogSource, debug.Message); } - /// - /// TBD - /// - protected override string FilterDescriptiveName { get { return "Debug"; } } + return false; } -} + + /// + /// TBD + /// + protected override string FilterDescriptiveName { get { return "Debug"; } } +} \ No newline at end of file diff --git a/src/core/Akka.TestKit/EventFilter/Internal/ErrorFilter.cs b/src/core/Akka.TestKit/EventFilter/Internal/ErrorFilter.cs index 369fae0d5e1..8fc70b68cec 100644 --- a/src/core/Akka.TestKit/EventFilter/Internal/ErrorFilter.cs +++ b/src/core/Akka.TestKit/EventFilter/Internal/ErrorFilter.cs @@ -10,110 +10,108 @@ using Akka.TestKit.Internal.StringMatcher; using Akka.Util; -namespace Akka.TestKit.Internal +#nullable enable +namespace Akka.TestKit.Internal; + +/// +/// Note! Part of internal API. Breaking changes may occur without notice. Use at own risk. +/// +public class ErrorFilter : EventFilterBase { + private readonly Type? _exceptionType; + private readonly bool _recurseInnerExceptions; + /// - /// Note! Part of internal API. Breaking changes may occur without notice. Use at own risk. + /// TBD /// - public class ErrorFilter : EventFilterBase + /// TBD + /// TBD + public ErrorFilter(IStringMatcher? messageMatcher = null, IStringMatcher? sourceMatcher = null) + : this(null, messageMatcher, sourceMatcher, false) { - private readonly Type _exceptionType; - private readonly bool _recurseInnerExceptions; + } - /// - /// TBD - /// - /// TBD - /// TBD - public ErrorFilter(IStringMatcher messageMatcher = null, IStringMatcher sourceMatcher = null) - : this(null,messageMatcher,sourceMatcher, false) - { - } + /// + /// TBD + /// + /// TBD + /// TBD + /// TBD + /// TBD + /// + /// This exception is thrown when the specified does not implement . + /// + public ErrorFilter(Type? exceptionType, IStringMatcher? messageMatcher = null, IStringMatcher? sourceMatcher = null, bool recurseInnerExceptions = false) + : base(messageMatcher,sourceMatcher) + { + if(exceptionType is not null && !exceptionType.Implements()) + throw new ArgumentException($"The type must be an exception. It was: {exceptionType}", nameof(exceptionType)); + _exceptionType = exceptionType; + _recurseInnerExceptions = recurseInnerExceptions; + } - /// - /// TBD - /// - /// TBD - /// TBD - /// TBD - /// TBD - /// - /// This exception is thrown when the specified does not implement . - /// - public ErrorFilter(Type exceptionType, IStringMatcher messageMatcher = null, IStringMatcher sourceMatcher = null, bool recurseInnerExceptions=false) - : base(messageMatcher,sourceMatcher) + /// + /// TBD + /// + /// TBD + /// TBD + protected override bool IsMatch(LogEvent evt) + { + if(evt is Error error) { - if(exceptionType!=null && !exceptionType.Implements()) throw new ArgumentException($"The type must be an exception. It was: {exceptionType}", nameof(exceptionType)); - _exceptionType = exceptionType; - _recurseInnerExceptions = recurseInnerExceptions; + var logSource = error.LogSource; + var errorMessage = error.Message; + var cause = error.Cause; + return IsMatch(logSource, errorMessage, cause); } - /// - /// TBD - /// - /// TBD - /// TBD - protected override bool IsMatch(LogEvent evt) + return false; + } + + private bool IsMatch(string logSource, object? errorMessage, Exception? cause) + { + if (_exceptionType is null) { - var error = evt as Error; - if(error != null) + if (cause is null) { - var logSource = error.LogSource; - var errorMessage = error.Message; - var cause = error.Cause; - return IsMatch(logSource, errorMessage, cause); + return InternalDoMatch(logSource, errorMessage); } - - return false; } - - private bool IsMatch(string logSource, object errorMessage, Exception cause) + else { - var hasCause = cause != null; - var matchAnyErrorType = _exceptionType == null; - if (matchAnyErrorType) + //Must match type. If no cause, then it does not match the specified exception type + if (cause is null) { - if (!hasCause) - { - return InternalDoMatch(logSource, errorMessage); - } + return false; } - else + if (!cause.GetType().Implements(_exceptionType)) { - //Must match type. If no cause, then it does not match the specified exception type - if (!hasCause) - { - return false; - } - if (!cause.GetType().Implements(_exceptionType)) - { - //The cause did not implement the specified type. - if (_recurseInnerExceptions) - return IsMatch(logSource, errorMessage, cause.InnerException); - return false; - } + //The cause did not implement the specified type. + if (_recurseInnerExceptions) + return IsMatch(logSource, errorMessage, cause.InnerException); + return false; } - //At this stage we have a cause, and it's of the specified type. - //Check that message matches, if nothing matches, recurse - var causeMessage = cause.Message; - var noMessages = (errorMessage == null && string.IsNullOrEmpty(causeMessage)); - return noMessages - || InternalDoMatch(logSource, errorMessage) - || InternalDoMatch(logSource, causeMessage) - || (_recurseInnerExceptions && IsMatch(logSource, errorMessage, cause.InnerException)); } + //At this stage we have a cause, and it's of the specified type. + //Check that message matches, if nothing matches, recurse + var causeMessage = cause.Message; + var noMessages = (errorMessage == null && string.IsNullOrEmpty(causeMessage)); + return noMessages + || InternalDoMatch(logSource, errorMessage) + || InternalDoMatch(logSource, causeMessage) + || (_recurseInnerExceptions && IsMatch(logSource, errorMessage, cause.InnerException)); + } - /// - /// TBD - /// - protected override string FilterDescriptiveName + /// + /// TBD + /// + protected override string FilterDescriptiveName + { + get { - get - { - if(_exceptionType == null) - return "Error"; - return "Error with Cause <" + _exceptionType + ">"; - } + if(_exceptionType == null) + return "Error"; + return "Error with Cause <" + _exceptionType + ">"; } } -} +} \ No newline at end of file diff --git a/src/core/Akka.TestKit/EventFilter/Internal/EventFilterApplier.cs b/src/core/Akka.TestKit/EventFilter/Internal/EventFilterApplier.cs index 77a666b9d9f..aa92bb0eda1 100644 --- a/src/core/Akka.TestKit/EventFilter/Internal/EventFilterApplier.cs +++ b/src/core/Akka.TestKit/EventFilter/Internal/EventFilterApplier.cs @@ -14,576 +14,576 @@ using Akka.TestKit.TestEvent; using Nito.AsyncEx.Synchronous; -namespace Akka.TestKit.Internal +#nullable enable +namespace Akka.TestKit.Internal; + +/// +/// Note! Part of internal API. Breaking changes may occur without notice. Use at own risk. +/// +public class InternalEventFilterApplier : IEventFilterApplier { - /// - /// Note! Part of internal API. Breaking changes may occur without notice. Use at own risk. - /// - public class InternalEventFilterApplier : IEventFilterApplier + private readonly IReadOnlyList _filters; + private readonly TestKitBase _testkit; + private readonly ActorSystem _actorSystem; + + public InternalEventFilterApplier(TestKitBase testkit, ActorSystem system, IReadOnlyList filters) { - private readonly IReadOnlyList _filters; - private readonly TestKitBase _testkit; - private readonly ActorSystem _actorSystem; + _filters = filters; + _testkit = testkit; + _actorSystem = system; + } - public InternalEventFilterApplier(TestKitBase testkit, ActorSystem system, IReadOnlyList filters) - { - _filters = filters; - _testkit = testkit; - _actorSystem = system; - } + public void ExpectOne(Action action, CancellationToken cancellationToken = default) + { + ExpectOneAsync(() => { action(); return Task.CompletedTask; }, cancellationToken) + .WaitAndUnwrapException(cancellationToken); + } - public void ExpectOne(Action action, CancellationToken cancellationToken = default) + /// + /// Async version of + /// + /// + /// + /// + /// This is for backwards compat. + /// + [Obsolete("Only for backwards compat. Use ExpectOneAsync(Func, CancellationToken) instead beginning in Akka.NET v1.5")] + public async Task ExpectOneAsync(Action action, CancellationToken cancellationToken = default) + { + Task Wrapped() { - ExpectOneAsync(() => { action(); return Task.CompletedTask; }, cancellationToken) - .WaitAndUnwrapException(cancellationToken); + action(); + return Task.CompletedTask; } - - /// - /// Async version of - /// - /// - /// - /// - /// This is for backwards compat. - /// - [Obsolete("Only for backwards compat. Use ExpectOneAsync(Func, CancellationToken) instead beginning in Akka.NET v1.5")] - public async Task ExpectOneAsync(Action action, CancellationToken cancellationToken = default) - { - Task Wrapped() - { - action(); - return Task.CompletedTask; - } - await ExpectOneAsync(Wrapped, cancellationToken) - ; - } + await ExpectOneAsync(Wrapped, cancellationToken) + ; + } - /// - /// Async version of - /// - public async Task ExpectOneAsync(Func action, CancellationToken cancellationToken = default) - { - await InternalExpectAsync( - actionAsync: action, - actorSystem: _actorSystem, - expectedCount: 1, - timeout: null, - cancellationToken: cancellationToken) - ; - } + /// + /// Async version of + /// + public async Task ExpectOneAsync(Func action, CancellationToken cancellationToken = default) + { + await InternalExpectAsync( + actionAsync: action, + actorSystem: _actorSystem, + expectedCount: 1, + timeout: null, + cancellationToken: cancellationToken) + ; + } - public void ExpectOne( - TimeSpan timeout, - Action action, - CancellationToken cancellationToken = default) - { - ExpectOneAsync(timeout, () => { action(); return Task.CompletedTask; }, cancellationToken) - .WaitAndUnwrapException(cancellationToken); - } + public void ExpectOne( + TimeSpan timeout, + Action action, + CancellationToken cancellationToken = default) + { + ExpectOneAsync(timeout, () => { action(); return Task.CompletedTask; }, cancellationToken) + .WaitAndUnwrapException(cancellationToken); + } - /// - /// Async version of - /// - public async Task ExpectOneAsync( - TimeSpan timeout, - Func action, - CancellationToken cancellationToken = default) - { - await InternalExpectAsync( - actionAsync: action, - actorSystem: _actorSystem, - expectedCount: 1, - timeout: timeout, - cancellationToken: cancellationToken) - ; - } + /// + /// Async version of + /// + public async Task ExpectOneAsync( + TimeSpan timeout, + Func action, + CancellationToken cancellationToken = default) + { + await InternalExpectAsync( + actionAsync: action, + actorSystem: _actorSystem, + expectedCount: 1, + timeout: timeout, + cancellationToken: cancellationToken) + ; + } - public void Expect( - int expectedCount, - Action action, - CancellationToken cancellationToken = default) - { - ExpectAsync(expectedCount, () => { action(); return Task.CompletedTask; }, cancellationToken) - .WaitAndUnwrapException(cancellationToken); - } + public void Expect( + int expectedCount, + Action action, + CancellationToken cancellationToken = default) + { + ExpectAsync(expectedCount, () => { action(); return Task.CompletedTask; }, cancellationToken) + .WaitAndUnwrapException(cancellationToken); + } - /// - /// Async version of Expect - /// - public async Task ExpectAsync( - int expectedCount, - Func actionAsync, - CancellationToken cancellationToken = default) - => await InternalExpectAsync( - actionAsync: actionAsync, - actorSystem: _actorSystem, - expectedCount: expectedCount, - timeout: null, - cancellationToken: cancellationToken) - ; + /// + /// Async version of Expect + /// + public async Task ExpectAsync( + int expectedCount, + Func actionAsync, + CancellationToken cancellationToken = default) + => await InternalExpectAsync( + actionAsync: actionAsync, + actorSystem: _actorSystem, + expectedCount: expectedCount, + timeout: null, + cancellationToken: cancellationToken) + ; - /// - /// Async version of Expect - /// - public async Task ExpectAsync( - int expectedCount, - Func actionAsync, - TimeSpan? timeout, - CancellationToken cancellationToken = default) - { - await InternalExpectAsync( - actionAsync: actionAsync, - actorSystem: _actorSystem, - expectedCount: expectedCount, - timeout: timeout, - cancellationToken: cancellationToken) - ; - } + /// + /// Async version of Expect + /// + public async Task ExpectAsync( + int expectedCount, + Func actionAsync, + TimeSpan? timeout, + CancellationToken cancellationToken = default) + { + await InternalExpectAsync( + actionAsync: actionAsync, + actorSystem: _actorSystem, + expectedCount: expectedCount, + timeout: timeout, + cancellationToken: cancellationToken) + ; + } - public void Expect( - int expectedCount, - TimeSpan timeout, - Action action, - CancellationToken cancellationToken = default) - { - ExpectAsync(expectedCount, timeout, () => { action(); return Task.CompletedTask; }, cancellationToken) - .WaitAndUnwrapException(cancellationToken); - } + public void Expect( + int expectedCount, + TimeSpan timeout, + Action action, + CancellationToken cancellationToken = default) + { + ExpectAsync(expectedCount, timeout, () => { action(); return Task.CompletedTask; }, cancellationToken) + .WaitAndUnwrapException(cancellationToken); + } - /// - /// Async version of - /// - public async Task ExpectAsync( - int expectedCount, - TimeSpan timeout, - Func action, - CancellationToken cancellationToken = default) - { - await InternalExpectAsync( - actionAsync: action, - actorSystem: _actorSystem, - expectedCount: expectedCount, - timeout: timeout, - cancellationToken: cancellationToken) - ; - } + /// + /// Async version of + /// + public async Task ExpectAsync( + int expectedCount, + TimeSpan timeout, + Func action, + CancellationToken cancellationToken = default) + { + await InternalExpectAsync( + actionAsync: action, + actorSystem: _actorSystem, + expectedCount: expectedCount, + timeout: timeout, + cancellationToken: cancellationToken) + ; + } - public async Task ExpectAsync(int expectedCount, TimeSpan timeout, Action action, CancellationToken cancellationToken = default) - { - await ExpectAsync(expectedCount, timeout, Wrapped, cancellationToken); - return; + public async Task ExpectAsync(int expectedCount, TimeSpan timeout, Action action, CancellationToken cancellationToken = default) + { + await ExpectAsync(expectedCount, timeout, Wrapped, cancellationToken); + return; - Task Wrapped() - { - action(); - return Task.CompletedTask; - } - } - - public T ExpectOne(Func func, CancellationToken cancellationToken = default) + Task Wrapped() { - return ExpectOneAsync(() => Task.FromResult(func()), cancellationToken) - .WaitAndUnwrapException(cancellationToken); + action(); + return Task.CompletedTask; } + } - /// - /// Async version of ExpectOne - /// - public Task ExpectOneAsync( - Func> func, - CancellationToken cancellationToken = default) - { - return InterceptAsync( - func: func, - system: _actorSystem, - timeout: null, - expectedOccurrences: 1, - cancellationToken: cancellationToken); - } + public T ExpectOne(Func func, CancellationToken cancellationToken = default) + { + return ExpectOneAsync(() => Task.FromResult(func()), cancellationToken) + .WaitAndUnwrapException(cancellationToken); + } - public T ExpectOne( - TimeSpan timeout, - Func func, - CancellationToken cancellationToken = default) - { - return ExpectOneAsync(timeout, () => Task.FromResult(func()), cancellationToken) - .WaitAndUnwrapException(); - } + /// + /// Async version of ExpectOne + /// + public Task ExpectOneAsync( + Func> func, + CancellationToken cancellationToken = default) + { + return InterceptAsync( + func: func, + system: _actorSystem, + timeout: null, + expectedOccurrences: 1, + cancellationToken: cancellationToken); + } - /// - /// Async version of ExpectOne - /// - public Task ExpectOneAsync( - TimeSpan timeout, - Func> func, - CancellationToken cancellationToken = default) - { - return InterceptAsync( - func: func, - system: _actorSystem, - timeout: timeout, - expectedOccurrences: 1, - matchedEventHandler: null, - cancellationToken: cancellationToken); - } + public T ExpectOne( + TimeSpan timeout, + Func func, + CancellationToken cancellationToken = default) + { + return ExpectOneAsync(timeout, () => Task.FromResult(func()), cancellationToken) + .WaitAndUnwrapException(); + } - public T Expect( - int expectedCount, - Func func, - CancellationToken cancellationToken = default) - { - return ExpectAsync(expectedCount, () => Task.FromResult(func()), cancellationToken) - .WaitAndUnwrapException(); - } + /// + /// Async version of ExpectOne + /// + public Task ExpectOneAsync( + TimeSpan timeout, + Func> func, + CancellationToken cancellationToken = default) + { + return InterceptAsync( + func: func, + system: _actorSystem, + timeout: timeout, + expectedOccurrences: 1, + matchedEventHandler: null, + cancellationToken: cancellationToken); + } + + public T Expect( + int expectedCount, + Func func, + CancellationToken cancellationToken = default) + { + return ExpectAsync(expectedCount, () => Task.FromResult(func()), cancellationToken) + .WaitAndUnwrapException(); + } - /// - /// Async version of Expect - /// - public Task ExpectAsync( - int expectedCount, - Func> func, - CancellationToken cancellationToken = default) - { - return InterceptAsync( - func: func, - system: _actorSystem, - timeout: null, - expectedOccurrences: expectedCount, - matchedEventHandler: null, - cancellationToken: cancellationToken); - } + /// + /// Async version of Expect + /// + public Task ExpectAsync( + int expectedCount, + Func> func, + CancellationToken cancellationToken = default) + { + return InterceptAsync( + func: func, + system: _actorSystem, + timeout: null, + expectedOccurrences: expectedCount, + matchedEventHandler: null, + cancellationToken: cancellationToken); + } - public T Expect( - int expectedCount, - TimeSpan timeout, - Func func, - CancellationToken cancellationToken = default) - { - return ExpectAsync(expectedCount, timeout, () => Task.FromResult(func()), cancellationToken) - .WaitAndUnwrapException(); - } + public T Expect( + int expectedCount, + TimeSpan timeout, + Func func, + CancellationToken cancellationToken = default) + { + return ExpectAsync(expectedCount, timeout, () => Task.FromResult(func()), cancellationToken) + .WaitAndUnwrapException(); + } - /// - /// Async version of Expect - /// Note: might not get awaited. - /// - public Task ExpectAsync( - int expectedCount, - TimeSpan timeout, - Func> func, - CancellationToken cancellationToken = default) - { - return InterceptAsync( - func: func, - system: _actorSystem, - timeout: timeout, - expectedOccurrences: expectedCount, - matchedEventHandler: null, - cancellationToken: cancellationToken); - } + /// + /// Async version of Expect + /// Note: might not get awaited. + /// + public Task ExpectAsync( + int expectedCount, + TimeSpan timeout, + Func> func, + CancellationToken cancellationToken = default) + { + return InterceptAsync( + func: func, + system: _actorSystem, + timeout: timeout, + expectedOccurrences: expectedCount, + matchedEventHandler: null, + cancellationToken: cancellationToken); + } - public T Mute(Func func, CancellationToken cancellationToken = default) - { - return MuteAsync(() => Task.FromResult(func()), cancellationToken) - .WaitAndUnwrapException(); - } + public T Mute(Func func, CancellationToken cancellationToken = default) + { + return MuteAsync(() => Task.FromResult(func()), cancellationToken) + .WaitAndUnwrapException(); + } - /// - /// Async version of Mute - /// - public Task MuteAsync(Func> func, CancellationToken cancellationToken = default) - { - return InterceptAsync( - func: func, - system: _actorSystem, - timeout: null, - expectedOccurrences: null, - matchedEventHandler: null, - cancellationToken: cancellationToken); - } + /// + /// Async version of Mute + /// + public Task MuteAsync(Func> func, CancellationToken cancellationToken = default) + { + return InterceptAsync( + func: func, + system: _actorSystem, + timeout: null, + expectedOccurrences: null, + matchedEventHandler: null, + cancellationToken: cancellationToken); + } - public void Mute(Action action, CancellationToken cancellationToken = default) - { - MuteAsync(() => { action(); return Task.CompletedTask; }, cancellationToken) - .WaitAndUnwrapException(cancellationToken); - } + public void Mute(Action action, CancellationToken cancellationToken = default) + { + MuteAsync(() => { action(); return Task.CompletedTask; }, cancellationToken) + .WaitAndUnwrapException(cancellationToken); + } - /// - /// Async version of Mute - /// - public async Task MuteAsync(Func action, CancellationToken cancellationToken = default) - { - await InterceptAsync( - func: async () => - { - await action(); - return NotUsed.Instance; - }, - system: _actorSystem, - timeout: null, - expectedOccurrences: null, - matchedEventHandler: null, - cancellationToken: cancellationToken) - ; - } + /// + /// Async version of Mute + /// + public async Task MuteAsync(Func action, CancellationToken cancellationToken = default) + { + await InterceptAsync( + func: async () => + { + await action(); + return NotUsed.Instance; + }, + system: _actorSystem, + timeout: null, + expectedOccurrences: null, + matchedEventHandler: null, + cancellationToken: cancellationToken) + ; + } - public async Task MuteAsync(Action action, CancellationToken cancellationToken = default) - { - await MuteAsync(Wrapped, cancellationToken); - return; + public async Task MuteAsync(Action action, CancellationToken cancellationToken = default) + { + await MuteAsync(Wrapped, cancellationToken); + return; - Task Wrapped() - { - action(); - return Task.CompletedTask; - } - } - - public IUnmutableFilter Mute() + Task Wrapped() { - _actorSystem.EventStream.Publish(new Mute(_filters)); - return new InternalUnmutableFilter(_filters, _actorSystem); + action(); + return Task.CompletedTask; } + } + + public IUnmutableFilter Mute() + { + _actorSystem.EventStream.Publish(new Mute(_filters)); + return new InternalUnmutableFilter(_filters, _actorSystem); + } - public EventFilterFactory And + public EventFilterFactory And + { + get { - get - { - return new EventFilterFactory(_testkit, _actorSystem, _filters); - } + return new EventFilterFactory(_testkit, _actorSystem, _filters); } + } - protected T Intercept( - Func func, - ActorSystem system, - TimeSpan? timeout, - int? expectedOccurrences, - MatchedEventHandler matchedEventHandler = null, - CancellationToken cancellationToken = default) + protected T Intercept( + Func func, + ActorSystem system, + TimeSpan? timeout, + int? expectedOccurrences, + MatchedEventHandler? matchedEventHandler = null, + CancellationToken cancellationToken = default) + { + return InterceptAsync( + func: () => Task.FromResult(func()), + system: system, + timeout: timeout, + expectedOccurrences: expectedOccurrences, + matchedEventHandler: matchedEventHandler, + cancellationToken: cancellationToken) + .WaitAndUnwrapException(); + } + + /// + /// Async version of + /// + protected async Task InterceptAsync( + Func> func, + ActorSystem system, + TimeSpan? timeout, + int? expectedOccurrences, + MatchedEventHandler? matchedEventHandler = null, + CancellationToken cancellationToken = default) + { + var leeway = system.HasExtension() + ? TestKitExtension.For(system).TestEventFilterLeeway + : _testkit.TestKitSettings.TestEventFilterLeeway; + + // Calculate timeout - if an explicit timeout is provided, use that (after dilating) + // Otherwise, if we're in a WithinAsync block use its remaining time + // NOTE: the leeway value is really supposed to be the WithinAsync block's epsilon value + // But the design of the testkit doesn't make it feasible to pass that value back currently + TimeSpan timeoutValue; + if (timeout.HasValue) { - return InterceptAsync( - func: () => Task.FromResult(func()), - system: system, - timeout: timeout, - expectedOccurrences: expectedOccurrences, - matchedEventHandler: matchedEventHandler, - cancellationToken: cancellationToken) - .WaitAndUnwrapException(); + timeoutValue = _testkit.Dilated(timeout.Value); } - - /// - /// Async version of - /// - protected async Task InterceptAsync( - Func> func, - ActorSystem system, - TimeSpan? timeout, - int? expectedOccurrences, - MatchedEventHandler matchedEventHandler = null, - CancellationToken cancellationToken = default) + else { - var leeway = system.HasExtension() - ? TestKitExtension.For(system).TestEventFilterLeeway - : _testkit.TestKitSettings.TestEventFilterLeeway; - - // Calculate timeout - if an explicit timeout is provided, use that (after dilating) - // Otherwise, if we're in a WithinAsync block use its remaining time - // NOTE: the leeway value is really supposed to be the WithinAsync block's epsilon value - // But the design of the testkit doesn't make it feasible to pass that value back currently - TimeSpan timeoutValue; - if (timeout.HasValue) - { - timeoutValue = _testkit.Dilated(timeout.Value); - } - else - { - timeoutValue = _testkit.RemainingOrDefault; - } + timeoutValue = _testkit.RemainingOrDefault; + } - matchedEventHandler ??= new MatchedEventHandler(); - system.EventStream.Publish(new Mute(_filters)); - try + matchedEventHandler ??= new MatchedEventHandler(); + system.EventStream.Publish(new Mute(_filters)); + try + { + foreach(var filter in _filters) { - foreach(var filter in _filters) - { - filter.EventMatched += matchedEventHandler.HandleEvent; - } - var result = await func(); + filter.EventMatched += matchedEventHandler.HandleEvent; + } + var result = await func(); - if(!await AwaitDoneAsync(timeoutValue, expectedOccurrences, matchedEventHandler, cancellationToken)) + if(!await AwaitDoneAsync(timeoutValue, expectedOccurrences, matchedEventHandler, cancellationToken)) + { + var actualNumberOfEvents = matchedEventHandler.ReceivedCount; + string msg; + if(expectedOccurrences.HasValue) { - var actualNumberOfEvents = matchedEventHandler.ReceivedCount; - string msg; - if(expectedOccurrences.HasValue) + var expectedNumberOfEvents = expectedOccurrences.Value; + if(actualNumberOfEvents < expectedNumberOfEvents) + msg = + $"Timeout ({timeoutValue}) while waiting for messages. " + + $"Only received {actualNumberOfEvents}/{expectedNumberOfEvents} messages " + + $"that matched filter [{string.Join(",", _filters)}]"; + else { - var expectedNumberOfEvents = expectedOccurrences.Value; - if(actualNumberOfEvents < expectedNumberOfEvents) - msg = - $"Timeout ({timeoutValue}) while waiting for messages. " + - $"Only received {actualNumberOfEvents}/{expectedNumberOfEvents} messages " + - $"that matched filter [{string.Join(",", _filters)}]"; - else - { - var tooMany = actualNumberOfEvents - expectedNumberOfEvents; - msg = - $"Received {tooMany} {GetMessageString(tooMany)} too many. " + - $"Expected {expectedNumberOfEvents} {GetMessageString(expectedNumberOfEvents)} " + - $"but received {actualNumberOfEvents} that matched filter [{string.Join(",", _filters)}]"; - } + var tooMany = actualNumberOfEvents - expectedNumberOfEvents; + msg = + $"Received {tooMany} {GetMessageString(tooMany)} too many. " + + $"Expected {expectedNumberOfEvents} {GetMessageString(expectedNumberOfEvents)} " + + $"but received {actualNumberOfEvents} that matched filter [{string.Join(",", _filters)}]"; } - else - msg = $"Timeout ({timeoutValue}) while waiting for messages that matched filter [{_filters}]"; - - var assertionsProvider = system.HasExtension() - ? TestKitAssertionsExtension.For(system) - : TestKitAssertionsExtension.For(_testkit.Sys); - assertionsProvider.Assertions.Fail(msg); } - return result; + else + msg = $"Timeout ({timeoutValue}) while waiting for messages that matched filter [{_filters}]"; + + var assertionsProvider = system.HasExtension() + ? TestKitAssertionsExtension.For(system) + : TestKitAssertionsExtension.For(_testkit.Sys); + assertionsProvider.Assertions.Fail(msg); } - finally + return result; + } + finally + { + foreach(var filter in _filters) { - foreach(var filter in _filters) - { - filter.EventMatched -= matchedEventHandler.HandleEvent; - } - system.EventStream.Publish(new Unmute(_filters)); + filter.EventMatched -= matchedEventHandler.HandleEvent; } + system.EventStream.Publish(new Unmute(_filters)); } + } - protected bool AwaitDone( - TimeSpan timeout, - int? expectedOccurrences, - MatchedEventHandler matchedEventHandler, - CancellationToken cancellationToken = default) - { - return AwaitDoneAsync(timeout, expectedOccurrences, matchedEventHandler, cancellationToken) - .WaitAndUnwrapException(); - } + protected bool AwaitDone( + TimeSpan timeout, + int? expectedOccurrences, + MatchedEventHandler matchedEventHandler, + CancellationToken cancellationToken = default) + { + return AwaitDoneAsync(timeout, expectedOccurrences, matchedEventHandler, cancellationToken) + .WaitAndUnwrapException(); + } - /// - /// Async version of - /// - protected async Task AwaitDoneAsync( - TimeSpan timeout, - int? expectedOccurrences, - MatchedEventHandler matchedEventHandler, - CancellationToken cancellationToken = default) + /// + /// Async version of + /// + protected async Task AwaitDoneAsync( + TimeSpan timeout, + int? expectedOccurrences, + MatchedEventHandler matchedEventHandler, + CancellationToken cancellationToken = default) + { + if(expectedOccurrences.HasValue) { - if(expectedOccurrences.HasValue) + var expected = expectedOccurrences.GetValueOrDefault(); + if (expected > 0) { - var expected = expectedOccurrences.GetValueOrDefault(); - if (expected > 0) - { - await _testkit.AwaitConditionNoThrowAsync(() => Task.FromResult(matchedEventHandler.ReceivedCount >= expected), timeout, cancellationToken: cancellationToken); - return matchedEventHandler.ReceivedCount == expected; - } - else - { - // if expecting no events to arrive - assert that given condition will never match - var foundEvent = await _testkit.AwaitConditionNoThrowAsync(() => Task.FromResult(matchedEventHandler.ReceivedCount > 0), timeout, cancellationToken: cancellationToken); - return foundEvent == false; - } + await _testkit.AwaitConditionNoThrowAsync(() => Task.FromResult(matchedEventHandler.ReceivedCount >= expected), timeout, cancellationToken: cancellationToken); + return matchedEventHandler.ReceivedCount == expected; + } + else + { + // if expecting no events to arrive - assert that given condition will never match + var foundEvent = await _testkit.AwaitConditionNoThrowAsync(() => Task.FromResult(matchedEventHandler.ReceivedCount > 0), timeout, cancellationToken: cancellationToken); + return foundEvent == false; } - return true; } + return true; + } - protected static string GetMessageString(int number) - { - return number == 1 ? "message" : "messages"; - } + protected static string GetMessageString(int number) + { + return number == 1 ? "message" : "messages"; + } - private async Task InternalExpectAsync( - Func actionAsync, - ActorSystem actorSystem, - int expectedCount, - TimeSpan? timeout = null, - CancellationToken cancellationToken = default) - { - await InterceptAsync( - async () => - { - await actionAsync(); - return NotUsed.Instance; - }, actorSystem, timeout, expectedCount, cancellationToken: cancellationToken) - ; - } + private async Task InternalExpectAsync( + Func actionAsync, + ActorSystem actorSystem, + int expectedCount, + TimeSpan? timeout = null, + CancellationToken cancellationToken = default) + { + await InterceptAsync( + async () => + { + await actionAsync(); + return NotUsed.Instance; + }, actorSystem, timeout, expectedCount, cancellationToken: cancellationToken) + ; + } - protected class MatchedEventHandler - { - private int _receivedCount; + protected class MatchedEventHandler + { + private int _receivedCount; - public int ReceivedCount { get { return _receivedCount; } } + public int ReceivedCount { get { return _receivedCount; } } - public virtual void HandleEvent(EventFilterBase eventFilter, LogEvent logEvent) - { - if(_receivedCount != int.MaxValue) Interlocked.Increment(ref _receivedCount); - } + public virtual void HandleEvent(EventFilterBase eventFilter, LogEvent logEvent) + { + if(_receivedCount != int.MaxValue) Interlocked.Increment(ref _receivedCount); } + } - protected class InternalUnmutableFilter : IUnmutableFilter - { - private IReadOnlyCollection _filters; - private readonly ActorSystem _system; + protected class InternalUnmutableFilter : IUnmutableFilter + { + private IReadOnlyCollection? _filters; + private readonly ActorSystem _system; - public InternalUnmutableFilter(IReadOnlyCollection filters, ActorSystem system) - { - _filters = filters; - _system = system; - } + public InternalUnmutableFilter(IReadOnlyCollection filters, ActorSystem system) + { + _filters = filters; + _system = system; + } - public void Unmute() + public void Unmute() + { + var filters = _filters; + _filters = null; + if(!_isDisposed && filters != null) { - var filters = _filters; - _filters = null; - if(!_isDisposed && filters != null) - { - _system.EventStream.Publish(new Unmute(filters)); - } + _system.EventStream.Publish(new Unmute(filters)); } + } - private bool _isDisposed; //Automatically initialized to false; + private bool _isDisposed; //Automatically initialized to false; - public void Dispose() - { - Dispose(true); - //Take this object off the finalization queue and prevent finalization code for this object - //from executing a second time. - GC.SuppressFinalize(this); - } + public void Dispose() + { + Dispose(true); + //Take this object off the finalization queue and prevent finalization code for this object + //from executing a second time. + GC.SuppressFinalize(this); + } - /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. - /// if set to true the method has been called directly or indirectly by a - /// user's code. Managed and unmanaged resources will be disposed.
- /// if set to false the method has been called by the runtime from inside the finalizer and only - /// unmanaged resources can be disposed. - protected virtual void Dispose(bool disposing) - { - // If disposing equals false, the method has been called by the - // runtime from inside the finalizer and you should not reference - // other objects. Only unmanaged resources can be disposed. + /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. + /// if set to true the method has been called directly or indirectly by a + /// user's code. Managed and unmanaged resources will be disposed.
+ /// if set to false the method has been called by the runtime from inside the finalizer and only + /// unmanaged resources can be disposed. + protected virtual void Dispose(bool disposing) + { + // If disposing equals false, the method has been called by the + // runtime from inside the finalizer and you should not reference + // other objects. Only unmanaged resources can be disposed. - try + try + { + //Make sure Dispose does not get called more than once, by checking the disposed field + if(!_isDisposed) { - //Make sure Dispose does not get called more than once, by checking the disposed field - if(!_isDisposed) + if(disposing) { - if(disposing) - { - Unmute(); - } - //Clean up unmanaged resources + Unmute(); } - _isDisposed = true; - } - finally - { - // base.dispose(disposing); + //Clean up unmanaged resources } + _isDisposed = true; + } + finally + { + // base.dispose(disposing); } } } -} +} \ No newline at end of file diff --git a/src/core/Akka.TestKit/EventFilter/Internal/EventFilterBase.cs b/src/core/Akka.TestKit/EventFilter/Internal/EventFilterBase.cs index 80ff0790281..3901dcaf46b 100644 --- a/src/core/Akka.TestKit/EventFilter/Internal/EventFilterBase.cs +++ b/src/core/Akka.TestKit/EventFilter/Internal/EventFilterBase.cs @@ -9,124 +9,124 @@ using Akka.Event; using Akka.TestKit.Internal.StringMatcher; -namespace Akka.TestKit.Internal +#nullable enable +namespace Akka.TestKit.Internal; + +/// +/// TBD +/// +/// TBD +/// TBD +public delegate void EventMatched(EventFilterBase eventFilter, LogEvent logEvent); + +/// Internal! +/// Facilities for selectively filtering out expected events from logging so +/// that you can keep your test run’s console output clean and do not miss real +/// error messages. +/// Note! Part of internal API. Breaking changes may occur without notice. Use at own risk. +/// +public abstract class EventFilterBase : IEventFilter { + private readonly IStringMatcher _sourceMatcher; + private readonly IStringMatcher _messageMatcher; + /// /// TBD /// - /// TBD - /// TBD - public delegate void EventMatched(EventFilterBase eventFilter, LogEvent logEvent); + /// TBD + /// TBD + protected EventFilterBase(IStringMatcher? messageMatcher, IStringMatcher? sourceMatcher) + { + _messageMatcher = messageMatcher ?? MatchesAll.Instance; + _sourceMatcher = sourceMatcher ?? MatchesAll.Instance; + } - /// Internal! - /// Facilities for selectively filtering out expected events from logging so - /// that you can keep your test run’s console output clean and do not miss real - /// error messages. - /// Note! Part of internal API. Breaking changes may occur without notice. Use at own risk. + /// + /// TBD /// - public abstract class EventFilterBase : IEventFilter - { - private readonly IStringMatcher _sourceMatcher; - private readonly IStringMatcher _messageMatcher; + public event EventMatched? EventMatched; + + /// + /// Determines whether the specified event should be filtered or not. + /// + /// TBD + /// true to filter the event. + protected abstract bool IsMatch(LogEvent evt); //In Akka JVM this is called matches - /// - /// TBD - /// - /// TBD - /// TBD - protected EventFilterBase(IStringMatcher messageMatcher, IStringMatcher sourceMatcher) + /// + /// TBD + /// + /// TBD + /// TBD + public bool Apply(LogEvent logEvent) + { + if(IsMatch(logEvent)) { - _messageMatcher = messageMatcher ?? MatchesAll.Instance; - _sourceMatcher = sourceMatcher ?? MatchesAll.Instance; + OnEventMatched(logEvent); + return true; } - /// - /// TBD - /// - public event EventMatched EventMatched; + return false; + } - /// - /// Determines whether the specified event should be filtered or not. - /// - /// TBD - /// true to filter the event. - protected abstract bool IsMatch(LogEvent evt); //In Akka JVM this is called matches + /// + /// TBD + /// + /// TBD + protected virtual void OnEventMatched(LogEvent logEvent) + { + var delegt = EventMatched; + if(delegt != null) delegt(this, logEvent); + } - /// - /// TBD - /// - /// TBD - /// TBD - public bool Apply(LogEvent logEvent) - { - if(IsMatch(logEvent)) - { - OnEventMatched(logEvent); - return true; - } + /// Internal helper. + /// Note! Part of internal API. Breaking changes may occur without notice. Use at own risk. + /// + /// TBD + /// TBD + /// TBD + protected bool InternalDoMatch(string src, object? msg) + { + var msgstr = msg == null ? "null" : msg.ToString() ?? "null"; + return _sourceMatcher.IsMatch(src) && _messageMatcher.IsMatch(msgstr); + } - return false; - } + /// + /// TBD + /// + protected abstract string FilterDescriptiveName { get; } - /// - /// TBD - /// - /// TBD - protected virtual void OnEventMatched(LogEvent logEvent) + /// + /// TBD + /// + /// TBD + public override string ToString() + { + var sb = new StringBuilder(); + //if(_occurences > 1) + // sb.Append(_occurences == int.MaxValue ? "infinite" : _occurences.ToString(CultureInfo.InvariantCulture)).Append(" occurences of "); + sb.Append(FilterDescriptiveName); + var hasMessageMatcher = !(_messageMatcher is MatchesAll); + var hasSourceMatcher = !(_sourceMatcher is MatchesAll); + var hasBothMessageAndSourceMatcher = hasMessageMatcher && hasSourceMatcher; + if(hasMessageMatcher || hasSourceMatcher) { - var delegt = EventMatched; - if(delegt != null) delegt(this, logEvent); + sb.Append(" when"); } - - /// Internal helper. - /// Note! Part of internal API. Breaking changes may occur without notice. Use at own risk. - /// - /// TBD - /// TBD - /// TBD - protected bool InternalDoMatch(string src, object msg) + if(hasMessageMatcher) { - var msgstr = msg == null ? "null" : msg.ToString(); - return _sourceMatcher.IsMatch(src) && _messageMatcher.IsMatch(msgstr); + sb.Append(" Message "); + sb.Append(_messageMatcher); } - - /// - /// TBD - /// - protected abstract string FilterDescriptiveName { get; } - - /// - /// TBD - /// - /// TBD - public override string ToString() + if(hasBothMessageAndSourceMatcher) + { + sb.Append(" and"); + } + if(hasSourceMatcher) { - var sb = new StringBuilder(); - //if(_occurences > 1) - // sb.Append(_occurences == int.MaxValue ? "infinite" : _occurences.ToString(CultureInfo.InvariantCulture)).Append(" occurences of "); - sb.Append(FilterDescriptiveName); - var hasMessageMatcher = !(_messageMatcher is MatchesAll); - var hasSourceMatcher = !(_sourceMatcher is MatchesAll); - var hasBothMessageAndSourceMatcher = hasMessageMatcher && hasSourceMatcher; - if(hasMessageMatcher || hasSourceMatcher) - { - sb.Append(" when"); - } - if(hasMessageMatcher) - { - sb.Append(" Message "); - sb.Append(_messageMatcher); - } - if(hasBothMessageAndSourceMatcher) - { - sb.Append(" and"); - } - if(hasSourceMatcher) - { - sb.Append(" Source "); - sb.Append(_sourceMatcher); - } - return sb.ToString(); + sb.Append(" Source "); + sb.Append(_sourceMatcher); } + return sb.ToString(); } -} +} \ No newline at end of file diff --git a/src/core/Akka.TestKit/EventFilter/Internal/InfoFilter.cs b/src/core/Akka.TestKit/EventFilter/Internal/InfoFilter.cs index b1caf23dbfa..8872b3ae3cc 100644 --- a/src/core/Akka.TestKit/EventFilter/Internal/InfoFilter.cs +++ b/src/core/Akka.TestKit/EventFilter/Internal/InfoFilter.cs @@ -8,42 +8,42 @@ using Akka.Event; using Akka.TestKit.Internal.StringMatcher; -namespace Akka.TestKit.Internal +#nullable enable +namespace Akka.TestKit.Internal; + +/// +/// Note! Part of internal API. Breaking changes may occur without notice. Use at own risk. +/// +public class InfoFilter : EventFilterBase { /// - /// Note! Part of internal API. Breaking changes may occur without notice. Use at own risk. + /// TBD /// - public class InfoFilter : EventFilterBase + /// TBD + /// TBD + public InfoFilter(IStringMatcher? messageMatcher = null, IStringMatcher? sourceMatcher = null) + : base(messageMatcher, sourceMatcher) { - /// - /// TBD - /// - /// TBD - /// TBD - public InfoFilter(IStringMatcher messageMatcher = null, IStringMatcher sourceMatcher = null) - : base(messageMatcher, sourceMatcher) - { - } + } - /// - /// TBD - /// - /// TBD - /// TBD - protected override bool IsMatch(LogEvent evt) + /// + /// TBD + /// + /// TBD + /// TBD + protected override bool IsMatch(LogEvent evt) + { + var info = evt as Info; + if(info != null) { - var info = evt as Info; - if(info != null) - { - return InternalDoMatch(info.LogSource, info.Message); - } - - return false; + return InternalDoMatch(info.LogSource, info.Message); } - /// - /// TBD - /// - protected override string FilterDescriptiveName { get { return "Info"; } } + return false; } -} + + /// + /// TBD + /// + protected override string FilterDescriptiveName { get { return "Info"; } } +} \ No newline at end of file diff --git a/src/core/Akka.TestKit/EventFilter/Internal/StringMatcher/ContainsString.cs b/src/core/Akka.TestKit/EventFilter/Internal/StringMatcher/ContainsString.cs index 0bb5523bbd9..43278d72d7d 100644 --- a/src/core/Akka.TestKit/EventFilter/Internal/StringMatcher/ContainsString.cs +++ b/src/core/Akka.TestKit/EventFilter/Internal/StringMatcher/ContainsString.cs @@ -7,41 +7,41 @@ using System; -namespace Akka.TestKit.Internal.StringMatcher +#nullable enable +namespace Akka.TestKit.Internal.StringMatcher; + +/// +/// Note! Part of internal API. Breaking changes may occur without notice. Use at own risk. +/// +public class ContainsString : IStringMatcher { + private readonly string _part; + /// - /// Note! Part of internal API. Breaking changes may occur without notice. Use at own risk. + /// TBD /// - public class ContainsString : IStringMatcher + /// TBD + public ContainsString(string part) { - private readonly string _part; - - /// - /// TBD - /// - /// TBD - public ContainsString(string part) - { - _part = part; - } + _part = part; + } - /// - /// TBD - /// - /// TBD - /// TBD - public bool IsMatch(string s) - { - return s.IndexOf(_part, StringComparison.OrdinalIgnoreCase) >= 0; - } + /// + /// TBD + /// + /// TBD + /// TBD + public bool IsMatch(string s) + { + return s.IndexOf(_part, StringComparison.OrdinalIgnoreCase) >= 0; + } - /// - /// TBD - /// - /// TBD - public override string ToString() - { - return "contains \"" + _part + "\""; - } + /// + /// TBD + /// + /// TBD + public override string ToString() + { + return "contains \"" + _part + "\""; } -} +} \ No newline at end of file diff --git a/src/core/Akka.TestKit/EventFilter/Internal/StringMatcher/EqualsString.cs b/src/core/Akka.TestKit/EventFilter/Internal/StringMatcher/EqualsString.cs index b38da57a12e..46cefdf803e 100644 --- a/src/core/Akka.TestKit/EventFilter/Internal/StringMatcher/EqualsString.cs +++ b/src/core/Akka.TestKit/EventFilter/Internal/StringMatcher/EqualsString.cs @@ -7,41 +7,41 @@ using System; -namespace Akka.TestKit.Internal.StringMatcher +#nullable enable +namespace Akka.TestKit.Internal.StringMatcher; + +/// +/// Note! Part of internal API. Breaking changes may occur without notice. Use at own risk. +/// +public class EqualsString : IStringMatcher { + private readonly string _s; + /// - /// Note! Part of internal API. Breaking changes may occur without notice. Use at own risk. + /// TBD /// - public class EqualsString : IStringMatcher + /// TBD + public EqualsString(string s) { - private readonly string _s; - - /// - /// TBD - /// - /// TBD - public EqualsString(string s) - { - _s = s; - } + _s = s; + } - /// - /// TBD - /// - /// TBD - /// TBD - public bool IsMatch(string s) - { - return String.Equals(_s, s, StringComparison.OrdinalIgnoreCase); - } + /// + /// TBD + /// + /// TBD + /// TBD + public bool IsMatch(string s) + { + return String.Equals(_s, s, StringComparison.OrdinalIgnoreCase); + } - /// - /// TBD - /// - /// TBD - public override string ToString() - { - return "== \"" + _s + "\""; - } + /// + /// TBD + /// + /// TBD + public override string ToString() + { + return "== \"" + _s + "\""; } -} +} \ No newline at end of file diff --git a/src/core/Akka.TestKit/EventFilter/Internal/StringMatcher/EqualsStringAndPathMatcher.cs b/src/core/Akka.TestKit/EventFilter/Internal/StringMatcher/EqualsStringAndPathMatcher.cs index 32c6164e0a6..c89429aa6be 100644 --- a/src/core/Akka.TestKit/EventFilter/Internal/StringMatcher/EqualsStringAndPathMatcher.cs +++ b/src/core/Akka.TestKit/EventFilter/Internal/StringMatcher/EqualsStringAndPathMatcher.cs @@ -8,49 +8,49 @@ using System; using Akka.Actor; -namespace Akka.TestKit.Internal.StringMatcher +#nullable enable +namespace Akka.TestKit.Internal.StringMatcher; + +/// +/// Note! Part of internal API. Breaking changes may occur without notice. Use at own risk. +/// +public class EqualsStringAndPathMatcher : IStringMatcher { + private readonly string _path; + private readonly bool _canBeRelative; + /// - /// Note! Part of internal API. Breaking changes may occur without notice. Use at own risk. + /// TBD /// - public class EqualsStringAndPathMatcher : IStringMatcher + /// TBD + /// TBD + public EqualsStringAndPathMatcher(string path, bool canBeRelative=true) { - private readonly string _path; - private readonly bool _canBeRelative; - - /// - /// TBD - /// - /// TBD - /// TBD - public EqualsStringAndPathMatcher(string path, bool canBeRelative=true) - { - _path = path; - _canBeRelative = canBeRelative; - } + _path = path; + _canBeRelative = canBeRelative; + } - /// - /// TBD - /// - /// TBD - /// TBD - public bool IsMatch(string path) - { - if (String.Equals(_path, path, StringComparison.OrdinalIgnoreCase)) return true; - if(!_canBeRelative)return false; + /// + /// TBD + /// + /// TBD + /// TBD + public bool IsMatch(string path) + { + if (String.Equals(_path, path, StringComparison.OrdinalIgnoreCase)) return true; + if(!_canBeRelative)return false; - if (!ActorPath.TryParse(path, out var actorPath)) return false; - var pathWithoutAddress = actorPath.ToStringWithoutAddress(); - return String.Equals(_path, pathWithoutAddress, StringComparison.OrdinalIgnoreCase); - } + if (!ActorPath.TryParse(path, out var actorPath)) return false; + var pathWithoutAddress = actorPath.ToStringWithoutAddress(); + return String.Equals(_path, pathWithoutAddress, StringComparison.OrdinalIgnoreCase); + } - /// - /// TBD - /// - /// TBD - public override string ToString() - { - return "== \"" + _path + "\""; - } + /// + /// TBD + /// + /// TBD + public override string ToString() + { + return "== \"" + _path + "\""; } -} +} \ No newline at end of file diff --git a/src/core/Akka.TestKit/EventFilter/Internal/StringMatcher/IStringMatcher.cs b/src/core/Akka.TestKit/EventFilter/Internal/StringMatcher/IStringMatcher.cs index 4baa45d138b..d6b641d08d1 100644 --- a/src/core/Akka.TestKit/EventFilter/Internal/StringMatcher/IStringMatcher.cs +++ b/src/core/Akka.TestKit/EventFilter/Internal/StringMatcher/IStringMatcher.cs @@ -5,18 +5,18 @@ // //----------------------------------------------------------------------- -namespace Akka.TestKit.Internal.StringMatcher +#nullable enable +namespace Akka.TestKit.Internal.StringMatcher; + +/// +/// Note! Part of internal API. Breaking changes may occur without notice. Use at own risk. +/// +public interface IStringMatcher { /// - /// Note! Part of internal API. Breaking changes may occur without notice. Use at own risk. + /// TBD /// - public interface IStringMatcher - { - /// - /// TBD - /// - /// TBD - /// TBD - bool IsMatch(string s); - } -} + /// TBD + /// TBD + bool IsMatch(string s); +} \ No newline at end of file diff --git a/src/core/Akka.TestKit/EventFilter/Internal/StringMatcher/MatchesAll.cs b/src/core/Akka.TestKit/EventFilter/Internal/StringMatcher/MatchesAll.cs index 87a05b5cd7f..7bdef327c2d 100644 --- a/src/core/Akka.TestKit/EventFilter/Internal/StringMatcher/MatchesAll.cs +++ b/src/core/Akka.TestKit/EventFilter/Internal/StringMatcher/MatchesAll.cs @@ -5,36 +5,36 @@ // //----------------------------------------------------------------------- -namespace Akka.TestKit.Internal.StringMatcher +#nullable enable +namespace Akka.TestKit.Internal.StringMatcher; + +/// +/// Note! Part of internal API. Breaking changes may occur without notice. Use at own risk. +/// +public class MatchesAll : IStringMatcher { - /// - /// Note! Part of internal API. Breaking changes may occur without notice. Use at own risk. - /// - public class MatchesAll : IStringMatcher + private MatchesAll() { - private MatchesAll() - { - } + } - public static IStringMatcher Instance { get; } = new MatchesAll(); + public static IStringMatcher Instance { get; } = new MatchesAll(); - /// - /// TBD - /// - /// TBD - /// TBD - public bool IsMatch(string s) - { - return true; - } + /// + /// TBD + /// + /// TBD + /// TBD + public bool IsMatch(string s) + { + return true; + } - /// - /// TBD - /// - /// TBD - public override string ToString() - { - return ""; - } + /// + /// TBD + /// + /// TBD + public override string ToString() + { + return ""; } -} +} \ No newline at end of file diff --git a/src/core/Akka.TestKit/EventFilter/Internal/StringMatcher/PredicateMatcher.cs b/src/core/Akka.TestKit/EventFilter/Internal/StringMatcher/PredicateMatcher.cs index 970fe6d98fb..1c150cb7ab6 100644 --- a/src/core/Akka.TestKit/EventFilter/Internal/StringMatcher/PredicateMatcher.cs +++ b/src/core/Akka.TestKit/EventFilter/Internal/StringMatcher/PredicateMatcher.cs @@ -7,44 +7,44 @@ using System; -namespace Akka.TestKit.Internal.StringMatcher +#nullable enable +namespace Akka.TestKit.Internal.StringMatcher; + +/// +/// Note! Part of internal API. Breaking changes may occur without notice. Use at own risk. +/// +public class PredicateMatcher : IStringMatcher { + private readonly Predicate _predicate; + private readonly string _hint; + /// - /// Note! Part of internal API. Breaking changes may occur without notice. Use at own risk. + /// TBD /// - public class PredicateMatcher : IStringMatcher + /// TBD + /// TBD + public PredicateMatcher(Predicate predicate, string hint="") { - private readonly Predicate _predicate; - private readonly string _hint; - - /// - /// TBD - /// - /// TBD - /// TBD - public PredicateMatcher(Predicate predicate, string hint="") - { - _predicate = predicate; - _hint = hint; - } + _predicate = predicate; + _hint = hint; + } - /// - /// TBD - /// - /// TBD - /// TBD - public bool IsMatch(string s) - { - return _predicate(s); - } + /// + /// TBD + /// + /// TBD + /// TBD + public bool IsMatch(string s) + { + return _predicate(s); + } - /// - /// TBD - /// - /// TBD - public override string ToString() - { - return "matches predicate "+_hint; - } + /// + /// TBD + /// + /// TBD + public override string ToString() + { + return "matches predicate "+_hint; } -} +} \ No newline at end of file diff --git a/src/core/Akka.TestKit/EventFilter/Internal/StringMatcher/RegexMatcher.cs b/src/core/Akka.TestKit/EventFilter/Internal/StringMatcher/RegexMatcher.cs index f14b5030441..577ebf43454 100644 --- a/src/core/Akka.TestKit/EventFilter/Internal/StringMatcher/RegexMatcher.cs +++ b/src/core/Akka.TestKit/EventFilter/Internal/StringMatcher/RegexMatcher.cs @@ -7,41 +7,41 @@ using System.Text.RegularExpressions; -namespace Akka.TestKit.Internal.StringMatcher +#nullable enable +namespace Akka.TestKit.Internal.StringMatcher; + +/// +/// Note! Part of internal API. Breaking changes may occur without notice. Use at own risk. +/// +public class RegexMatcher : IStringMatcher { + private readonly Regex _regex; + /// - /// Note! Part of internal API. Breaking changes may occur without notice. Use at own risk. + /// TBD /// - public class RegexMatcher : IStringMatcher + /// TBD + public RegexMatcher(Regex regex) { - private readonly Regex _regex; - - /// - /// TBD - /// - /// TBD - public RegexMatcher(Regex regex) - { - _regex = regex; - } + _regex = regex; + } - /// - /// TBD - /// - /// TBD - /// TBD - public bool IsMatch(string s) - { - return _regex.IsMatch(s); - } + /// + /// TBD + /// + /// TBD + /// TBD + public bool IsMatch(string s) + { + return _regex.IsMatch(s); + } - /// - /// TBD - /// - /// TBD - public override string ToString() - { - return "matches regex \"" + _regex + "\""; - } + /// + /// TBD + /// + /// TBD + public override string ToString() + { + return "matches regex \"" + _regex + "\""; } -} +} \ No newline at end of file diff --git a/src/core/Akka.TestKit/EventFilter/Internal/StringMatcher/StartsWithString.cs b/src/core/Akka.TestKit/EventFilter/Internal/StringMatcher/StartsWithString.cs index 0264dfab903..b1f91162fd3 100644 --- a/src/core/Akka.TestKit/EventFilter/Internal/StringMatcher/StartsWithString.cs +++ b/src/core/Akka.TestKit/EventFilter/Internal/StringMatcher/StartsWithString.cs @@ -7,41 +7,41 @@ using System; -namespace Akka.TestKit.Internal.StringMatcher +#nullable enable +namespace Akka.TestKit.Internal.StringMatcher; + +/// +/// Note! Part of internal API. Breaking changes may occur without notice. Use at own risk. +/// +public class StartsWithString : IStringMatcher { + private readonly string _start; + /// - /// Note! Part of internal API. Breaking changes may occur without notice. Use at own risk. + /// TBD /// - public class StartsWithString : IStringMatcher + /// TBD + public StartsWithString(string start) { - private readonly string _start; - - /// - /// TBD - /// - /// TBD - public StartsWithString(string start) - { - _start = start; - } + _start = start; + } - /// - /// TBD - /// - /// TBD - /// TBD - public bool IsMatch(string s) - { - return s.StartsWith(_start, StringComparison.OrdinalIgnoreCase); - } + /// + /// TBD + /// + /// TBD + /// TBD + public bool IsMatch(string s) + { + return s.StartsWith(_start, StringComparison.OrdinalIgnoreCase); + } - /// - /// TBD - /// - /// TBD - public override string ToString() - { - return "starts with \"" + _start + "\""; - } + /// + /// TBD + /// + /// TBD + public override string ToString() + { + return "starts with \"" + _start + "\""; } -} +} \ No newline at end of file diff --git a/src/core/Akka.TestKit/EventFilter/Internal/WarningFilter.cs b/src/core/Akka.TestKit/EventFilter/Internal/WarningFilter.cs index c410c7054d2..f9ea100dfb2 100644 --- a/src/core/Akka.TestKit/EventFilter/Internal/WarningFilter.cs +++ b/src/core/Akka.TestKit/EventFilter/Internal/WarningFilter.cs @@ -8,41 +8,41 @@ using Akka.Event; using Akka.TestKit.Internal.StringMatcher; -namespace Akka.TestKit.Internal +#nullable enable +namespace Akka.TestKit.Internal; + +/// +/// Note! Part of internal API. Breaking changes may occur without notice. Use at own risk. +/// +public class WarningFilter : EventFilterBase { /// - /// Note! Part of internal API. Breaking changes may occur without notice. Use at own risk. + /// TBD /// - public class WarningFilter : EventFilterBase + /// TBD + /// TBD + public WarningFilter(IStringMatcher? messageMatcher = null, IStringMatcher? sourceMatcher = null) + : base(messageMatcher, sourceMatcher) { - /// - /// TBD - /// - /// TBD - /// TBD - public WarningFilter(IStringMatcher messageMatcher = null, IStringMatcher sourceMatcher = null) - : base(messageMatcher, sourceMatcher) - { - } + } - /// - /// TBD - /// - /// TBD - /// TBD - protected override bool IsMatch(LogEvent evt) + /// + /// TBD + /// + /// TBD + /// TBD + protected override bool IsMatch(LogEvent evt) + { + var warning = evt as Warning; + if(warning != null) { - var warning = evt as Warning; - if(warning != null) - { - return InternalDoMatch(warning.LogSource, warning.Message); - } - return false; + return InternalDoMatch(warning.LogSource, warning.Message); } - - /// - /// TBD - /// - protected override string FilterDescriptiveName { get { return "Warning"; } } + return false; } -} + + /// + /// TBD + /// + protected override string FilterDescriptiveName { get { return "Warning"; } } +} \ No newline at end of file