From a91130038dd6da5f42ef817c10f1f40fdaea421d Mon Sep 17 00:00:00 2001 From: Starlk Date: Mon, 18 Nov 2024 09:39:26 +0300 Subject: [PATCH] Fix Bedrock.Framework nullability issues. (#163) * Fix Bedrock.Framework nullability issues. And introduced a property to store whether the `ProtocolReadResult` was faulty or not. * Remove IsFaulted --- .../Middleware/Tls/TlsOptions.cs | 10 +++++----- .../Protocols/ProtocolReadResult.cs | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/Bedrock.Framework/Middleware/Tls/TlsOptions.cs b/src/Bedrock.Framework/Middleware/Tls/TlsOptions.cs index 4e924d25..e9c833ff 100644 --- a/src/Bedrock.Framework/Middleware/Tls/TlsOptions.cs +++ b/src/Bedrock.Framework/Middleware/Tls/TlsOptions.cs @@ -34,7 +34,7 @@ public TlsOptions() /// If the certificate has an Extended Key Usage extension, the usages must include Server Authentication (OID 1.3.6.1.5.5.7.3.1). /// /// - public X509Certificate2 LocalCertificate { get; set; } + public X509Certificate2? LocalCertificate { get; set; } /// /// @@ -45,7 +45,7 @@ public TlsOptions() /// If the certificate has an Extended Key Usage extension, the usages must include Server Authentication (OID 1.3.6.1.5.5.7.3.1). /// /// - public Func LocalServerCertificateSelector { get; set; } + public Func? LocalServerCertificateSelector { get; set; } /// /// Specifies the remote endpoint certificate requirements for a TLS connection. Defaults to . @@ -56,7 +56,7 @@ public TlsOptions() /// Specifies a callback for additional remote certificate validation that will be invoked during authentication. This will be ignored /// if is called after this callback is set. /// - public RemoteCertificateValidator RemoteCertificateValidation { get; set; } + public RemoteCertificateValidator? RemoteCertificateValidation { get; set; } /// /// Specifies allowable SSL protocols. Defaults to and . @@ -85,13 +85,13 @@ public void AllowAnyRemoteCertificate() /// Provides direct configuration of the on a per-connection basis. /// This is called after all of the other settings have already been applied. /// - public Action OnAuthenticateAsServer { get; set; } + public Action? OnAuthenticateAsServer { get; set; } /// /// Provides direct configuration of the on a per-connection basis. /// This is called after all of the other settings have already been applied. /// - public Action OnAuthenticateAsClient { get; set; } + public Action? OnAuthenticateAsClient { get; set; } /// /// Specifies the maximum amount of time allowed for the TLS/SSL handshake. This must be positive and finite. diff --git a/src/Bedrock.Framework/Protocols/ProtocolReadResult.cs b/src/Bedrock.Framework/Protocols/ProtocolReadResult.cs index e80d18f2..bc87c304 100644 --- a/src/Bedrock.Framework/Protocols/ProtocolReadResult.cs +++ b/src/Bedrock.Framework/Protocols/ProtocolReadResult.cs @@ -1,5 +1,9 @@ namespace Bedrock.Framework.Protocols { + /// + /// Represents a reading result from . + /// + /// The read message. public readonly struct ProtocolReadResult { public ProtocolReadResult(TMessage message, bool isCanceled, bool isCompleted) @@ -9,8 +13,19 @@ public ProtocolReadResult(TMessage message, bool isCanceled, bool isCompleted) IsCompleted = isCompleted; } + /// + /// The read message. + /// public TMessage Message { get; } + + /// + /// Whether the reading operation was cancelled (true) or not (false). + /// public bool IsCanceled { get; } + + /// + /// Whether the reading operation was completed (true) or not (false). + /// public bool IsCompleted { get; } } }