Skip to content

Commit

Permalink
More nullables
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmarbach authored and DavidBoike committed Jun 12, 2023
1 parent 738c639 commit 02e4804
Show file tree
Hide file tree
Showing 17 changed files with 53 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1839,22 +1839,22 @@ namespace NServiceBus.MessageMutator
}
public class MutateOutgoingMessageContext : NServiceBus.ICancellableContext
{
public MutateOutgoingMessageContext(object outgoingMessage, System.Collections.Generic.Dictionary<string, string> outgoingHeaders, object incomingMessage, System.Collections.Generic.IReadOnlyDictionary<string, string> incomingHeaders, System.Threading.CancellationToken cancellationToken = default) { }
public MutateOutgoingMessageContext(object outgoingMessage, System.Collections.Generic.Dictionary<string, string> outgoingHeaders, object? incomingMessage, System.Collections.Generic.IReadOnlyDictionary<string, string>? incomingHeaders, System.Threading.CancellationToken cancellationToken = default) { }
public System.Threading.CancellationToken CancellationToken { get; }
public System.Collections.Generic.Dictionary<string, string> OutgoingHeaders { get; }
public object OutgoingMessage { get; set; }
public bool TryGetIncomingHeaders(out System.Collections.Generic.IReadOnlyDictionary<string, string> incomingHeaders) { }
public bool TryGetIncomingMessage(out object incomingMessage) { }
public bool TryGetIncomingHeaders([System.Diagnostics.CodeAnalysis.NotNullWhen(true)] out System.Collections.Generic.IReadOnlyDictionary<string, string>? incomingHeaders) { }
public bool TryGetIncomingMessage([System.Diagnostics.CodeAnalysis.NotNullWhen(true)] out object? incomingMessage) { }
}
public class MutateOutgoingTransportMessageContext : NServiceBus.ICancellableContext
{
public MutateOutgoingTransportMessageContext(System.ReadOnlyMemory<byte> outgoingBody, object outgoingMessage, System.Collections.Generic.Dictionary<string, string> outgoingHeaders, object incomingMessage, System.Collections.Generic.IReadOnlyDictionary<string, string> incomingHeaders, System.Threading.CancellationToken cancellationToken = default) { }
public MutateOutgoingTransportMessageContext(System.ReadOnlyMemory<byte> outgoingBody, object outgoingMessage, System.Collections.Generic.Dictionary<string, string> outgoingHeaders, object? incomingMessage, System.Collections.Generic.IReadOnlyDictionary<string, string>? incomingHeaders, System.Threading.CancellationToken cancellationToken = default) { }
public System.Threading.CancellationToken CancellationToken { get; }
public System.ReadOnlyMemory<byte> OutgoingBody { get; set; }
public System.Collections.Generic.Dictionary<string, string> OutgoingHeaders { get; }
public object OutgoingMessage { get; }
public bool TryGetIncomingHeaders(out System.Collections.Generic.IReadOnlyDictionary<string, string> incomingHeaders) { }
public bool TryGetIncomingMessage(out object incomingMessage) { }
public bool TryGetIncomingHeaders([System.Diagnostics.CodeAnalysis.NotNullWhen(true)] out System.Collections.Generic.IReadOnlyDictionary<string, string>? incomingHeaders) { }
public bool TryGetIncomingMessage([System.Diagnostics.CodeAnalysis.NotNullWhen(true)] out object? incomingMessage) { }
}
public static class MutatorRegistrationExtensions
{
Expand Down Expand Up @@ -2427,7 +2427,7 @@ namespace NServiceBus.Sagas
public interface ISagaFinder<TSagaData, TMessage> : NServiceBus.Sagas.IFinder
where TSagaData : NServiceBus.IContainSagaData
{
System.Threading.Tasks.Task<TSagaData> FindBy(TMessage message, NServiceBus.Persistence.ISynchronizedStorageSession storageSession, NServiceBus.Extensibility.IReadOnlyContextBag context, System.Threading.CancellationToken cancellationToken = default);
System.Threading.Tasks.Task<TSagaData?> FindBy(TMessage message, NServiceBus.Persistence.ISynchronizedStorageSession storageSession, NServiceBus.Extensibility.IReadOnlyContextBag context, System.Threading.CancellationToken cancellationToken = default);
}
public interface ISagaIdGenerator
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

namespace NServiceBus.MessageMutator
{
using System.Threading.Tasks;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

namespace NServiceBus.MessageMutator
{
using System.Threading.Tasks;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

namespace NServiceBus.MessageMutator
{
using System.Collections.Generic;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#nullable enable

namespace NServiceBus.MessageMutator
{
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Threading;

/// <summary>
Expand All @@ -11,7 +14,7 @@ public class MutateOutgoingMessageContext : ICancellableContext
/// <summary>
/// Initializes the context.
/// </summary>
public MutateOutgoingMessageContext(object outgoingMessage, Dictionary<string, string> outgoingHeaders, object incomingMessage, IReadOnlyDictionary<string, string> incomingHeaders, CancellationToken cancellationToken = default)
public MutateOutgoingMessageContext(object outgoingMessage, Dictionary<string, string> outgoingHeaders, object? incomingMessage, IReadOnlyDictionary<string, string>? incomingHeaders, CancellationToken cancellationToken = default)
{
Guard.ThrowIfNull(outgoingHeaders);
Guard.ThrowIfNull(outgoingMessage);
Expand Down Expand Up @@ -49,7 +52,7 @@ public object OutgoingMessage
/// <summary>
/// Gets the incoming message that initiated the current send if it exists.
/// </summary>
public bool TryGetIncomingMessage(out object incomingMessage)
public bool TryGetIncomingMessage([NotNullWhen(true)] out object? incomingMessage)
{
incomingMessage = this.incomingMessage;
return incomingMessage != null;
Expand All @@ -58,14 +61,14 @@ public bool TryGetIncomingMessage(out object incomingMessage)
/// <summary>
/// Gets the incoming headers that initiated the current send if it exists.
/// </summary>
public bool TryGetIncomingHeaders(out IReadOnlyDictionary<string, string> incomingHeaders)
public bool TryGetIncomingHeaders([NotNullWhen(true)] out IReadOnlyDictionary<string, string>? incomingHeaders)
{
incomingHeaders = this.incomingHeaders;
return incomingHeaders != null;
}

IReadOnlyDictionary<string, string> incomingHeaders;
object incomingMessage;
IReadOnlyDictionary<string, string>? incomingHeaders;
object? incomingMessage;

internal bool MessageInstanceChanged;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

namespace NServiceBus.MessageMutator
{
using System.Threading.Tasks;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

namespace NServiceBus.MessageMutator
{
using System.Threading.Tasks;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

namespace NServiceBus.MessageMutator
{
using System;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#nullable enable

namespace NServiceBus.MessageMutator
{
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Threading;

/// <summary>
Expand All @@ -12,7 +15,7 @@ public class MutateOutgoingTransportMessageContext : ICancellableContext
/// <summary>
/// Initializes a new instance of <see cref="MutateOutgoingTransportMessageContext" />.
/// </summary>
public MutateOutgoingTransportMessageContext(ReadOnlyMemory<byte> outgoingBody, object outgoingMessage, Dictionary<string, string> outgoingHeaders, object incomingMessage, IReadOnlyDictionary<string, string> incomingHeaders, CancellationToken cancellationToken = default)
public MutateOutgoingTransportMessageContext(ReadOnlyMemory<byte> outgoingBody, object outgoingMessage, Dictionary<string, string> outgoingHeaders, object? incomingMessage, IReadOnlyDictionary<string, string>? incomingHeaders, CancellationToken cancellationToken = default)
{
Guard.ThrowIfNull(outgoingHeaders);
Guard.ThrowIfNull(outgoingBody);
Expand Down Expand Up @@ -60,7 +63,7 @@ public ReadOnlyMemory<byte> OutgoingBody
/// <summary>
/// Gets the incoming message that initiated the current send if it exists.
/// </summary>
public bool TryGetIncomingMessage(out object incomingMessage)
public bool TryGetIncomingMessage([NotNullWhen(true)] out object? incomingMessage)
{
incomingMessage = this.incomingMessage;
return incomingMessage != null;
Expand All @@ -69,14 +72,14 @@ public bool TryGetIncomingMessage(out object incomingMessage)
/// <summary>
/// Gets the incoming headers that initiated the current send if it exists.
/// </summary>
public bool TryGetIncomingHeaders(out IReadOnlyDictionary<string, string> incomingHeaders)
public bool TryGetIncomingHeaders([NotNullWhen(true)] out IReadOnlyDictionary<string, string>? incomingHeaders)
{
incomingHeaders = this.incomingHeaders;
return incomingHeaders != null;
}

IReadOnlyDictionary<string, string> incomingHeaders;
object incomingMessage;
IReadOnlyDictionary<string, string>? incomingHeaders;
object? incomingMessage;

internal bool MessageBodyChanged;
ReadOnlyMemory<byte> outgoingBody;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

namespace NServiceBus
{
using System;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace NServiceBus
#nullable enable

namespace NServiceBus
{
using System;
using System.Linq.Expressions;
Expand Down
2 changes: 2 additions & 0 deletions src/NServiceBus.Core/Sagas/IContainSagaData.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

namespace NServiceBus
{
using System;
Expand Down
2 changes: 2 additions & 0 deletions src/NServiceBus.Core/Sagas/IFinder.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

namespace NServiceBus.Sagas
{
/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions src/NServiceBus.Core/Sagas/IHandleSagaNotFound.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

namespace NServiceBus.Sagas
{
using System.Threading.Tasks;
Expand Down
6 changes: 4 additions & 2 deletions src/NServiceBus.Core/Sagas/ISagaFinder.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

namespace NServiceBus.Sagas
{
using System.Threading;
Expand All @@ -15,6 +17,6 @@ public interface ISagaFinder<TSagaData, TMessage> : IFinder where TSagaData : IC
/// Finds a saga entity of the type <typeparamref name="TSagaData"/> using a message of type <typeparamref name="TMessage"/>.
/// </summary>
/// <exception cref="System.Exception">This exception will be thrown if <code>null</code> is returned. Return a Task&lt;T&gt; or mark the method as <code>async</code>.</exception>
Task<TSagaData> FindBy(TMessage message, ISynchronizedStorageSession storageSession, IReadOnlyContextBag context, CancellationToken cancellationToken = default);
Task<TSagaData?> FindBy(TMessage message, ISynchronizedStorageSession storageSession, IReadOnlyContextBag context, CancellationToken cancellationToken = default);
}
}
}
2 changes: 2 additions & 0 deletions src/NServiceBus.Core/Sagas/ISagaIdGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

namespace NServiceBus.Sagas
{
using System;
Expand Down
2 changes: 1 addition & 1 deletion src/NServiceBus.Core/Utils/Guard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace NServiceBus

static class Guard
{
public static void ThrowIfNull([NotNull] object? argument, [CallerArgumentExpression("argument")] string? paramName = null)
public static void ThrowIfNull<T>([NotNull] T? argument, [CallerArgumentExpression("argument")] string? paramName = null)
{
if (argument is null)
{
Expand Down

0 comments on commit 02e4804

Please sign in to comment.