Ver a proveniência

Enable #nullable for azureservicebus.

master
Savorboard há 3 anos
ascendente
cometimento
2537471779
5 ficheiros alterados com 17 adições e 17 eliminações
  1. +10
    -10
      src/DotNetCore.CAP.AzureServiceBus/AzureServiceBusConsumerClient.cs
  2. +2
    -2
      src/DotNetCore.CAP.AzureServiceBus/AzureServiceBusConsumerCommitInput.cs
  3. +2
    -2
      src/DotNetCore.CAP.AzureServiceBus/CAP.AzureServiceBusOptions.cs
  4. +1
    -1
      src/DotNetCore.CAP.AzureServiceBus/DotNetCore.CAP.AzureServiceBus.csproj
  5. +2
    -2
      src/DotNetCore.CAP.AzureServiceBus/ITransport.AzureServiceBus.cs

+ 10
- 10
src/DotNetCore.CAP.AzureServiceBus/AzureServiceBusConsumerClient.cs Ver ficheiro

@@ -24,7 +24,7 @@ namespace DotNetCore.CAP.AzureServiceBus
private readonly string _subscriptionName;
private readonly AzureServiceBusOptions _asbOptions;

private SubscriptionClient _consumerClient;
private SubscriptionClient? _consumerClient;

public AzureServiceBusConsumerClient(
ILogger logger,
@@ -36,11 +36,11 @@ namespace DotNetCore.CAP.AzureServiceBus
_asbOptions = options.Value ?? throw new ArgumentNullException(nameof(options));
}

public event EventHandler<TransportMessage> OnMessageReceived;
public event EventHandler<TransportMessage>? OnMessageReceived;

public event EventHandler<LogMessageEventArgs> OnLog;
public event EventHandler<LogMessageEventArgs>? OnLog;

public BrokerAddress BrokerAddress => new BrokerAddress("AzureServiceBus", _asbOptions.ConnectionString);
public BrokerAddress BrokerAddress => new ("AzureServiceBus", _asbOptions.ConnectionString);

public void Subscribe(IEnumerable<string> topics)
{
@@ -51,7 +51,7 @@ namespace DotNetCore.CAP.AzureServiceBus

ConnectAsync().GetAwaiter().GetResult();

var allRuleNames = _consumerClient.GetRulesAsync().GetAwaiter().GetResult().Select(x => x.Name);
var allRuleNames = _consumerClient!.GetRulesAsync().GetAwaiter().GetResult().Select(x => x.Name);

foreach (var newRule in topics.Except(allRuleNames))
{
@@ -80,7 +80,7 @@ namespace DotNetCore.CAP.AzureServiceBus

if (_asbOptions.EnableSessions)
{
_consumerClient.RegisterSessionHandler(OnConsumerReceivedWithSession,
_consumerClient!.RegisterSessionHandler(OnConsumerReceivedWithSession,
new SessionHandlerOptions(OnExceptionReceived)
{
AutoComplete = false,
@@ -89,7 +89,7 @@ namespace DotNetCore.CAP.AzureServiceBus
}
else
{
_consumerClient.RegisterMessageHandler(OnConsumerReceived,
_consumerClient!.RegisterMessageHandler(OnConsumerReceived,
new MessageHandlerOptions(OnExceptionReceived)
{
AutoComplete = false,
@@ -111,15 +111,15 @@ namespace DotNetCore.CAP.AzureServiceBus
var commitInput = (AzureServiceBusConsumerCommitInput) sender;
if (_asbOptions.EnableSessions)
{
commitInput.Session.CompleteAsync(commitInput.LockToken);
commitInput.Session?.CompleteAsync(commitInput.LockToken);
}
else
{
_consumerClient.CompleteAsync(commitInput.LockToken);
_consumerClient!.CompleteAsync(commitInput.LockToken);
}
}

public void Reject(object sender)
public void Reject(object? sender)
{
// ignore
}


+ 2
- 2
src/DotNetCore.CAP.AzureServiceBus/AzureServiceBusConsumerCommitInput.cs Ver ficheiro

@@ -4,13 +4,13 @@ namespace DotNetCore.CAP.AzureServiceBus
{
public class AzureServiceBusConsumerCommitInput
{
public AzureServiceBusConsumerCommitInput(string lockToken, IMessageSession session = null)
public AzureServiceBusConsumerCommitInput(string lockToken, IMessageSession? session = null)
{
LockToken = lockToken;
Session = session;
}
public IMessageSession Session { get; set; }
public IMessageSession? Session { get; set; }
public string LockToken { get; set; }
}
}

+ 2
- 2
src/DotNetCore.CAP.AzureServiceBus/CAP.AzureServiceBusOptions.cs Ver ficheiro

@@ -20,7 +20,7 @@ namespace DotNetCore.CAP
/// <summary>
/// Azure Service Bus Namespace connection string. Must not contain topic information.
/// </summary>
public string ConnectionString { get; set; }
public string ConnectionString { get; set; } = default!;

/// <summary>
/// Whether Service Bus sessions are enabled. If enabled, all messages must contain a
@@ -36,6 +36,6 @@ namespace DotNetCore.CAP
/// <summary>
/// Represents the Azure Active Directory token provider for Azure Managed Service Identity integration.
/// </summary>
public ITokenProvider ManagementTokenProvider { get; set; }
public ITokenProvider? ManagementTokenProvider { get; set; }
}
}

+ 1
- 1
src/DotNetCore.CAP.AzureServiceBus/DotNetCore.CAP.AzureServiceBus.csproj Ver ficheiro

@@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<AssemblyName>DotNetCore.CAP.AzureServiceBus</AssemblyName>
<Nullable>enable</Nullable>
<PackageTags>$(PackageTags);AzureServiceBus</PackageTags>
</PropertyGroup>



+ 2
- 2
src/DotNetCore.CAP.AzureServiceBus/ITransport.AzureServiceBus.cs Ver ficheiro

@@ -20,7 +20,7 @@ namespace DotNetCore.CAP.AzureServiceBus
private readonly ILogger _logger;
private readonly IOptions<AzureServiceBusOptions> _asbOptions;

private ITopicClient _topicClient;
private ITopicClient? _topicClient;

public AzureServiceBusTransport(
ILogger<AzureServiceBusTransport> logger,
@@ -57,7 +57,7 @@ namespace DotNetCore.CAP.AzureServiceBus
message.UserProperties.Add(header.Key, header.Value);
}

await _topicClient.SendAsync(message);
await _topicClient!.SendAsync(message);

_logger.LogDebug($"Azure Service Bus message [{transportMessage.GetName()}] has been published.");



Carregando…
Cancelar
Guardar