Skip to content

[ECS] Dialog optional button2 throws exception when left null #376

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
CiprianN23 opened this issue Jan 8, 2021 · 1 comment
Closed

[ECS] Dialog optional button2 throws exception when left null #376

CiprianN23 opened this issue Jan 8, 2021 · 1 comment

Comments

@CiprianN23
Copy link
Contributor

CiprianN23 commented Jan 8, 2021

If you build either a list dialog or message box dialog and just specify button1 server crash due to Value cannot be null on button2 even if this button its actually optional and does not need to be specified as it has default valeu

Repo:

public class DialogTestSystem : ISystem
    {
        [Event]
        public void OnPlayerConnect(Player player, IDialogService dialogService)
        {
            var testDialog = new MessageDialog("Test dialog", "Test content", "Button 1");

            void TestDialogHandler(MessageDialogResponse r)
            {

            }

            dialogService.Show(player.Entity, testDialog, TestDialogHandler);
        }
    }

Stack trace:
[SampSharp:ERROR] Unhandled exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.ArgumentNullException: Value cannot be null. (Parameter 'chars')
   at System.Text.ASCIIEncoding.GetByteCount(String chars)
   at SampSharp.Core.Natives.NativeObjects.FastNatives.NativeUtils.GetByteCount(String input) in D:\SourceCode\SampSharp\src\SampSharp.Core\Natives\NativeObjects\FastNatives\NativeUtils.cs:line 41
   at NativePlayerProxyClass_3.ShowPlayerDialog(Int32 , Int32 , String , String , String , String )
   at SampSharp.Entities.SAMP.DialogService.Show[TResponse](EntityId player, IDialog`1 dialog, Action`1 responseHandler) in D:\SourceCode\SampSharp\src\SampSharp.Entities\SAMP\Dialogs\DialogService.cs:line 59
   at PrisonRP.GameMode.Features.Players.DialogTestSystem.OnPlayerConnect(Player player, IDialogService dialogService) in D:\SourceCode\PrisonRP\src\PrisonRP\PrisonRP.GameMode\Features\Players\DialogTestSystem.cs:line 25
   at lambda_method3(Closure , Object , Object[] , IServiceProvider , IEntityManager )
   at SampSharp.Entities.EventService.<>c__DisplayClass11_0.<CreateInvoker>b__0(Object instance, EventContext eventContext) in D:\SourceCode\SampSharp\src\SampSharp.Entities\Events\EventService.cs:line 178
   at SampSharp.Entities.EventService.Invoke(EventContext context) in D:\SourceCode\SampSharp\src\SampSharp.Entities\Events\EventService.cs:line 108
   at SampSharp.Entities.SAMP.PlayerConnectMiddleware.Invoke(EventContext context, IEntityManager entityManager) in D:\SourceCode\SampSharp\src\SampSharp.Entities\SAMP\Middleware\PlayerConnectMiddleware.cs:line 38
   at lambda_method14(Closure , Object , EventContext , IServiceProvider )
   at SampSharp.Entities.EcsBuilderUseMiddlewareExtensions.<>c__DisplayClass3_1.<UseMiddleware>b__2(EventContext context) in D:\SourceCode\SampSharp\src\SampSharp.Entities\EcsBuilderUseMiddlewareExtensions.cs:line 115
   at SampSharp.Entities.EventService.<>c__DisplayClass12_0.<BuildInvoke>b__0(Object[] args) in D:\SourceCode\SampSharp\src\SampSharp.Entities\Events\EventService.cs:line 200
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at SampSharp.Core.Callbacks.Callback.Invoke(Byte[] buffer, Int32 startIndex) in D:\SourceCode\SampSharp\src\SampSharp.Core\Callbacks\Callback.cs:line 201
   at SampSharp.Core.HostedGameModeClient.PublicCall(String name, IntPtr data, Int32 length) in D:\SourceCode\SampSharp\src\SampSharp.Core\HostedGameModeClient.cs:line 117```
@ikkentim
Copy link
Owner

ikkentim commented Jan 9, 2021

Good catch, for now you can probably put an empty string into button2. I'll fix this for the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants