1
0
mirror of https://github.com/oliverbooth/VpSharp synced 2024-11-22 19:18:47 +00:00

Fix nullability (again)

This commit is contained in:
Oliver Booth 2022-11-30 18:55:42 +00:00
parent a8e5fafbb4
commit c2748567fc
No known key found for this signature in database
GPG Key ID: 32A00B35503AF634
4 changed files with 6 additions and 6 deletions

View File

@ -11,7 +11,7 @@ internal sealed class Connection : IDisposable
private byte[] _pendingBuffer; private byte[] _pendingBuffer;
private readonly List<byte[]> _readyBuffers = new(); private readonly List<byte[]> _readyBuffers = new();
private Timer _timer; private Timer? _timer;
private nint _vpConnection; private nint _vpConnection;
public Connection(nint vpConnection, object lockObject) public Connection(nint vpConnection, object lockObject)
@ -65,8 +65,8 @@ internal sealed class Connection : IDisposable
{ {
GCHandle handle = GCHandle.FromIntPtr(ptr); GCHandle handle = GCHandle.FromIntPtr(ptr);
var connection = handle.Target as Connection; var connection = handle.Target as Connection;
string host = Marshal.PtrToStringAnsi(hostPtr); string? host = Marshal.PtrToStringAnsi(hostPtr);
if (connection is not null) if (connection is not null && host is not null)
{ {
return connection.Connect(host, port); return connection.Connect(host, port);
} }

View File

@ -45,7 +45,7 @@ public sealed partial class VirtualParadiseClient
return; return;
} }
VirtualParadiseObject virtualParadiseObject = reason == ReasonCode.Success ? await ExtractObjectAsync(sender) : null; VirtualParadiseObject? virtualParadiseObject = reason == ReasonCode.Success ? await ExtractObjectAsync(sender).ConfigureAwait(true) : null;
taskCompletionSource.SetResult((reason, virtualParadiseObject)); taskCompletionSource.SetResult((reason, virtualParadiseObject));
} }

View File

@ -244,7 +244,7 @@ public sealed partial class VirtualParadiseClient
virtualParadiseObject = null; virtualParadiseObject = null;
} }
_objects.TryRemove(objectId, out VirtualParadiseObject? _); _objects.TryRemove(objectId, out VirtualParadiseObject _);
var args = new ObjectDeletedEventArgs(avatar!, objectId, virtualParadiseObject!); var args = new ObjectDeletedEventArgs(avatar!, objectId, virtualParadiseObject!);
RaiseEvent(ObjectDeleted, args); RaiseEvent(ObjectDeleted, args);

View File

@ -98,7 +98,7 @@ public sealed partial class VirtualParadiseClient
ReasonCode reason; ReasonCode reason;
if (!_objectCompletionSources.TryGetValue(id, if (!_objectCompletionSources.TryGetValue(id,
out TaskCompletionSource<(ReasonCode, VirtualParadiseObject?)>? taskCompletionSource)) out TaskCompletionSource<(ReasonCode, VirtualParadiseObject)>? taskCompletionSource))
{ {
taskCompletionSource = new TaskCompletionSource<(ReasonCode, VirtualParadiseObject?)>(); taskCompletionSource = new TaskCompletionSource<(ReasonCode, VirtualParadiseObject?)>();
_objectCompletionSources.TryAdd(id, taskCompletionSource); _objectCompletionSources.TryAdd(id, taskCompletionSource);