mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-01-03 14:23:40 +01:00
fix: allow null in CallGateChannel args
This commit is contained in:
parent
e62984d270
commit
7864570a56
2 changed files with 30 additions and 1 deletions
21
Dalamud/Plugin/Ipc/Exceptions/IpcValueNullError.cs
Normal file
21
Dalamud/Plugin/Ipc/Exceptions/IpcValueNullError.cs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
using System;
|
||||
|
||||
namespace Dalamud.Plugin.Ipc.Exceptions;
|
||||
|
||||
/// <summary>
|
||||
/// This exception is thrown when a null value is passed to an IPC requiring a value type.
|
||||
/// </summary>
|
||||
public class IpcValueNullError : IpcError
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="IpcValueNullError"/> class.
|
||||
/// </summary>
|
||||
/// <param name="name">Name of the IPC.</param>
|
||||
/// <param name="expectedType">The type expected.</param>
|
||||
/// <param name="index">Index of the failing argument.</param>
|
||||
public IpcValueNullError(string name, Type expectedType, int index)
|
||||
: base($"IPC {name} expects a value type({expectedType.FullName}) at index {index}, null given.")
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
|
|
@ -105,7 +105,7 @@ namespace Dalamud.Plugin.Ipc.Internal
|
|||
var paramTypes = methodInfo.GetParameters()
|
||||
.Select(pi => pi.ParameterType).ToArray();
|
||||
|
||||
if (args.Length != paramTypes.Length)
|
||||
if (args?.Length != paramTypes.Length)
|
||||
throw new IpcLengthMismatchError(this.Name, args.Length, paramTypes.Length);
|
||||
|
||||
for (var i = 0; i < args.Length; i++)
|
||||
|
|
@ -113,6 +113,14 @@ namespace Dalamud.Plugin.Ipc.Internal
|
|||
var arg = args[i];
|
||||
var paramType = paramTypes[i];
|
||||
|
||||
if (arg == null)
|
||||
{
|
||||
if (paramType.IsValueType)
|
||||
throw new IpcValueNullError(this.Name, paramType, i);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
var argType = arg.GetType();
|
||||
if (argType != paramType)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue