From 0c11ccb6f1dd4790b28ec5319f6dd37401fdb78d Mon Sep 17 00:00:00 2001 From: PolarGoose <35307286+PolarGoose@users.noreply.github.com> Date: Sun, 4 Feb 2024 19:21:15 +0100 Subject: [PATCH] * Fix a potential NullReferenceException in the InvocationInfo class * Make FireAsync_TriggerWithMoreThanThreeParameters unit test culturally invariant. Otherwise it fails on some system locales. --- src/Stateless/Reflection/InvocationInfo.cs | 4 +++- test/Stateless.Tests/AsyncActionsFixture.cs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Stateless/Reflection/InvocationInfo.cs b/src/Stateless/Reflection/InvocationInfo.cs index 9f0270fa..5cec4727 100644 --- a/src/Stateless/Reflection/InvocationInfo.cs +++ b/src/Stateless/Reflection/InvocationInfo.cs @@ -63,9 +63,11 @@ public string Description { if (_description != null) return _description; + if (MethodName == null) + return ""; if (MethodName.IndexOfAny(new char[] { '<', '>', '`' }) >= 0) return DefaultFunctionDescription; - return MethodName ?? ""; + return MethodName; } } diff --git a/test/Stateless.Tests/AsyncActionsFixture.cs b/test/Stateless.Tests/AsyncActionsFixture.cs index 79ff95f5..d175183b 100644 --- a/test/Stateless.Tests/AsyncActionsFixture.cs +++ b/test/Stateless.Tests/AsyncActionsFixture.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using Xunit; +using System.Globalization; namespace Stateless.Tests { @@ -544,7 +545,8 @@ public async Task OnEntryFromAsync_WhenEnteringByAnotherTrigger_InvokesAction() [Fact] public async Task FireAsync_TriggerWithMoreThanThreeParameters() { - const string expectedParam = "42-Stateless-True-420.69-Y"; + var decimalSeparator = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator; + string expectedParam = $"42-Stateless-True-420{decimalSeparator}69-Y"; string actualParam = null; var sm = new StateMachine(State.A);