Merge branch 'dev' into issue-2298

pull/17110/head
Salih 2 years ago
commit 751471160d

@ -16,6 +16,7 @@ on:
- 'templates/**/*.cshtml'
- 'templates/**/*.csproj'
- 'templates/**/*.razor'
- 'Directory.Build.props'
pull_request:
paths:
@ -31,6 +32,7 @@ on:
- 'templates/**/*.cshtml'
- 'templates/**/*.csproj'
- 'templates/**/*.razor'
- 'Directory.Build.props'
types:
- opened
- synchronize

@ -43,7 +43,7 @@
<IsTestProject Condition="$(MSBuildProjectFullPath.Contains('test')) and ($(MSBuildProjectName.EndsWith('.Tests')) or $(MSBuildProjectName.EndsWith('.TestBase')))">true</IsTestProject>
<!-- OpenIddict https://www.nuget.org/packages/OpenIddict.Core -->
<OpenIddictPackageVersion>4.5.0</OpenIddictPackageVersion>
<OpenIddictPackageVersion>4.6.0</OpenIddictPackageVersion>
</PropertyGroup>
@ -54,4 +54,4 @@
</PackageReference>
</ItemGroup>
</Project>
</Project>

@ -51,6 +51,14 @@ Please see the following migration documents, if you are upgrading from v7.2:
## Community News
### ABP Community Talks 2023.5: Mobile Development with the ABP Framework
![](community-talks.png)
In this episode, we'll talk about Exploring Options for Mobile Development with the ABP Framework.
> Join us to explore the options for Mobile Development in ABP Framework on July 27, 2023, at 17:00 UTC. You can register from [here](https://kommunity.com/volosoft/events/abp-community-talks-20235-mobile-development-with-the-abp-framework-68e64e59).
### New ABP Community Posts
There are exciting articles contributed by the ABP community as always. I will highlight some of them here:

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

@ -5,7 +5,7 @@ namespace Volo.Abp.AspNetCore.Components.Messages;
public class UiMessageEventArgs : EventArgs
{
public UiMessageEventArgs(UiMessageType messageType, string message, string title, UiMessageOptions options)
public UiMessageEventArgs(UiMessageType messageType, string message, string? title, UiMessageOptions options)
{
MessageType = messageType;
Message = message;
@ -13,7 +13,7 @@ public class UiMessageEventArgs : EventArgs
Options = options;
}
public UiMessageEventArgs(UiMessageType messageType, string message, string title, UiMessageOptions options, TaskCompletionSource<bool> callback)
public UiMessageEventArgs(UiMessageType messageType, string message, string? title, UiMessageOptions options, TaskCompletionSource<bool> callback)
{
MessageType = messageType;
Message = message;
@ -26,7 +26,7 @@ public class UiMessageEventArgs : EventArgs
public string Message { get; }
public string Title { get; }
public string? Title { get; }
public UiMessageOptions Options { get; }

@ -4,7 +4,7 @@ namespace Volo.Abp.AspNetCore.Components.Notifications;
public class UiNotificationEventArgs : EventArgs
{
public UiNotificationEventArgs(UiNotificationType notificationType, string message, string title, UiNotificationOptions options)
public UiNotificationEventArgs(UiNotificationType notificationType, string message, string? title, UiNotificationOptions options)
{
NotificationType = notificationType;
Message = message;
@ -16,7 +16,7 @@ public class UiNotificationEventArgs : EventArgs
public string Message { get; }
public string Title { get; }
public string? Title { get; }
public UiNotificationOptions Options { get; }
}

@ -22,8 +22,8 @@ public static class AbpAutoMapperExtensibleDtoExtensions
(source, destination, extraProps) =>
{
var result = extraProps.IsNullOrEmpty()
? new Dictionary<string, object>()
: new Dictionary<string, object>(extraProps);
? new Dictionary<string, object?>()
: new Dictionary<string, object?>(extraProps);
ExtensibleObjectMapper
.MapExtraPropertiesTo<TSource, TDestination>(

@ -5,6 +5,8 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net7.0</TargetFrameworks>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
<AssemblyName>Volo.Abp.AzureServiceBus</AssemblyName>
<PackageId>Volo.Abp.AzureServiceBus</PackageId>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>

@ -20,9 +20,9 @@ public class AzureServiceBusMessageConsumer : IAzureServiceBusMessageConsumer, I
private readonly IExceptionNotifier _exceptionNotifier;
private readonly IProcessorPool _processorPool;
private readonly ConcurrentBag<Func<ServiceBusReceivedMessage, Task>> _callbacks;
private string _connectionName;
private string _subscriptionName;
private string _topicName;
private string _connectionName = default!;
private string _subscriptionName = default!;
private string _topicName = default!;
public AzureServiceBusMessageConsumer(
IExceptionNotifier exceptionNotifier,
@ -37,7 +37,7 @@ public class AzureServiceBusMessageConsumer : IAzureServiceBusMessageConsumer, I
public virtual void Initialize(
[NotNull] string topicName,
[NotNull] string subscriptionName,
string connectionName)
string? connectionName)
{
Check.NotNull(topicName, nameof(topicName));
Check.NotNull(subscriptionName, nameof(subscriptionName));

@ -5,7 +5,7 @@ namespace Volo.Abp.AzureServiceBus;
public class ClientConfig
{
public string ConnectionString { get; set; }
public string ConnectionString { get; set; } = default!;
public ServiceBusAdministrationClientOptions Admin { get; set; } = new();

@ -5,6 +5,8 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net7.0</TargetFrameworks>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
<AssemblyName>Volo.Abp.BackgroundJobs.Abstractions</AssemblyName>
<PackageId>Volo.Abp.BackgroundJobs.Abstractions</PackageId>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>

@ -54,7 +54,7 @@ public class BackgroundJobExecuter : IBackgroundJobExecuter, ITransientDependenc
{
if (jobExecuteMethod.Name == nameof(IAsyncBackgroundJob<object>.ExecuteAsync))
{
await ((Task)jobExecuteMethod.Invoke(job, new[] { context.JobArgs }));
await ((Task)jobExecuteMethod.Invoke(job, new[] { context.JobArgs })!);
}
else
{
@ -74,7 +74,7 @@ public class BackgroundJobExecuter : IBackgroundJobExecuter, ITransientDependenc
throw new BackgroundJobExecutionException("A background job execution is failed. See inner exception for details.", ex)
{
JobType = context.JobType.AssemblyQualifiedName,
JobType = context.JobType.AssemblyQualifiedName!,
JobArgs = context.JobArgs
};
}

@ -6,9 +6,9 @@ namespace Volo.Abp.BackgroundJobs;
[Serializable]
public class BackgroundJobExecutionException : AbpException
{
public string JobType { get; set; }
public string JobType { get; set; } = default!;
public object JobArgs { get; set; }
public object JobArgs { get; set; } = default!;
public BackgroundJobExecutionException()
{

@ -22,11 +22,11 @@ public class BackgroundJobNameAttribute : Attribute, IBackgroundJobNameProvider
{
Check.NotNull(jobArgsType, nameof(jobArgsType));
return jobArgsType
.GetCustomAttributes(true)
.OfType<IBackgroundJobNameProvider>()
.FirstOrDefault()
?.Name
?? jobArgsType.FullName;
return (jobArgsType
.GetCustomAttributes(true)
.OfType<IBackgroundJobNameProvider>()
.FirstOrDefault()
?.Name
?? jobArgsType.FullName)!;
}
}

@ -5,6 +5,8 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net7.0</TargetFrameworks>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
<AssemblyName>Volo.Abp.BackgroundJobs.HangFire</AssemblyName>
<PackageId>Volo.Abp.BackgroundJobs.HangFire</PackageId>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>

@ -30,7 +30,7 @@ public class AbpBackgroundJobsHangfireModule : AbpModule
}
}
private BackgroundJobServer CreateOnlyEnqueueJobServer(IServiceProvider serviceProvider)
private BackgroundJobServer? CreateOnlyEnqueueJobServer(IServiceProvider serviceProvider)
{
serviceProvider.GetRequiredService<JobStorage>();
return null;

@ -39,7 +39,7 @@ public class HangfireJobExecutionAdapter<TArgs>
using (var scope = ServiceScopeFactory.CreateScope())
{
var jobType = Options.GetJob(typeof(TArgs)).JobType;
var context = new JobExecutionContext(scope.ServiceProvider, jobType, args, cancellationToken: cancellationToken);
var context = new JobExecutionContext(scope.ServiceProvider, jobType, args!, cancellationToken: cancellationToken);
await JobExecuter.ExecuteAsync(context);
}
}

@ -5,6 +5,8 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net7.0</TargetFrameworks>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
<AssemblyName>Volo.Abp.BackgroundJobs.Quartz</AssemblyName>
<PackageId>Volo.Abp.BackgroundJobs.Quartz</PackageId>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>

@ -30,7 +30,7 @@ public class AbpBackgroundJobQuartzOptions
{
exception.RefireImmediately = true;
var retryCount = executionContext.JobDetail.JobDataMap.GetString(QuartzBackgroundJobManager.JobDataPrefix + nameof(RetryCount)).To<int>();
var retryCount = executionContext.JobDetail.JobDataMap.GetString(QuartzBackgroundJobManager.JobDataPrefix + nameof(RetryCount))!.To<int>();
if (retryIndex > retryCount)
{
exception.RefireImmediately = false;
@ -38,7 +38,7 @@ public class AbpBackgroundJobQuartzOptions
return;
}
var retryInterval = executionContext.JobDetail.JobDataMap.GetString(QuartzBackgroundJobManager.JobDataPrefix + nameof(RetryIntervalMillisecond)).To<int>();
var retryInterval = executionContext.JobDetail.JobDataMap.GetString(QuartzBackgroundJobManager.JobDataPrefix + nameof(RetryIntervalMillisecond))!.To<int>();
await Task.Delay(retryInterval);
}
}

@ -19,10 +19,10 @@ public class AbpBackgroundJobsQuartzModule : AbpModule
public override void OnPreApplicationInitialization(ApplicationInitializationContext context)
{
var options = context.ServiceProvider.GetService<IOptions<AbpBackgroundJobOptions>>().Value;
var options = context.ServiceProvider.GetRequiredService<IOptions<AbpBackgroundJobOptions>>().Value;
if (!options.IsJobExecutionEnabled)
{
var quartzOptions = context.ServiceProvider.GetService<IOptions<AbpQuartzOptions>>().Value;
var quartzOptions = context.ServiceProvider.GetRequiredService<IOptions<AbpQuartzOptions>>().Value;
quartzOptions.StartSchedulerFactory = scheduler => Task.CompletedTask;
}
}

@ -6,7 +6,7 @@ namespace Volo.Abp.BackgroundJobs.Quartz;
public static class QuartzBackgroundJobManageExtensions
{
public static async Task<string> EnqueueAsync<TArgs>(this IBackgroundJobManager backgroundJobManager,
public static async Task<string?> EnqueueAsync<TArgs>(this IBackgroundJobManager backgroundJobManager,
TArgs args, int retryCount, int retryIntervalMillisecond,
BackgroundJobPriority priority = BackgroundJobPriority.Normal, TimeSpan? delay = null)
{

@ -37,7 +37,7 @@ public class QuartzBackgroundJobManager : IBackgroundJobManager, ITransientDepen
{
var jobDataMap = new JobDataMap
{
{nameof(TArgs), JsonSerializer.Serialize(args)},
{nameof(TArgs), JsonSerializer.Serialize(args!)},
{JobDataPrefix+ nameof(Options.RetryCount), retryCount.ToString()},
{JobDataPrefix+ nameof(Options.RetryIntervalMillisecond), retryIntervalMillisecond.ToString()},
{JobDataPrefix+ RetryIndex, "0"}

@ -38,9 +38,9 @@ public class QuartzJobExecutionAdapter<TArgs> : IJob
{
using (var scope = ServiceScopeFactory.CreateScope())
{
var args = JsonSerializer.Deserialize<TArgs>(context.JobDetail.JobDataMap.GetString(nameof(TArgs)));
var args = JsonSerializer.Deserialize<TArgs>(context.JobDetail.JobDataMap.GetString(nameof(TArgs))!);
var jobType = Options.GetJob(typeof(TArgs)).JobType;
var jobContext = new JobExecutionContext(scope.ServiceProvider, jobType, args, cancellationToken: context.CancellationToken);
var jobContext = new JobExecutionContext(scope.ServiceProvider, jobType, args!, cancellationToken: context.CancellationToken);
try
{
await JobExecuter.ExecuteAsync(jobContext);
@ -49,7 +49,7 @@ public class QuartzJobExecutionAdapter<TArgs> : IJob
{
var jobExecutionException = new JobExecutionException(exception);
var retryIndex = context.JobDetail.JobDataMap.GetString(QuartzBackgroundJobManager.JobDataPrefix + QuartzBackgroundJobManager.RetryIndex).To<int>();
var retryIndex = context.JobDetail.JobDataMap.GetString(QuartzBackgroundJobManager.JobDataPrefix + QuartzBackgroundJobManager.RetryIndex)!.To<int>();
retryIndex++;
context.JobDetail.JobDataMap.Put(QuartzBackgroundJobManager.JobDataPrefix + QuartzBackgroundJobManager.RetryIndex, retryIndex.ToString());

@ -5,6 +5,8 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net7.0</TargetFrameworks>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
<AssemblyName>Volo.Abp.BackgroundJobs.RabbitMQ</AssemblyName>
<PackageId>Volo.Abp.BackgroundJobs.RabbitMQ</PackageId>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>

@ -6,7 +6,7 @@ namespace Volo.Abp.BackgroundJobs.RabbitMQ;
public interface IJobQueue<in TArgs> : IRunnable, IDisposable
{
Task<string> EnqueueAsync(
Task<string?> EnqueueAsync(
TArgs args,
BackgroundJobPriority priority = BackgroundJobPriority.Normal,
TimeSpan? delay = null

@ -21,8 +21,8 @@ public class JobQueue<TArgs> : IJobQueue<TArgs>
protected BackgroundJobConfiguration JobConfiguration { get; }
protected JobQueueConfiguration QueueConfiguration { get; }
protected IChannelAccessor ChannelAccessor { get; private set; }
protected AsyncEventingBasicConsumer Consumer { get; private set; }
protected IChannelAccessor? ChannelAccessor { get; private set; }
protected AsyncEventingBasicConsumer? Consumer { get; private set; }
public ILogger<JobQueue<TArgs>> Logger { get; set; }
@ -71,7 +71,7 @@ public class JobQueue<TArgs> : IJobQueue<TArgs>
);
}
public virtual async Task<string> EnqueueAsync(
public virtual async Task<string?> EnqueueAsync(
TArgs args,
BackgroundJobPriority priority = BackgroundJobPriority.Normal,
TimeSpan? delay = null)
@ -176,11 +176,11 @@ public class JobQueue<TArgs> : IJobQueue<TArgs>
basicProperties.Expiration = delay.Value.TotalMilliseconds.ToString();
}
ChannelAccessor.Channel.BasicPublish(
ChannelAccessor!.Channel.BasicPublish(
exchange: "",
routingKey: routingKey,
basicProperties: basicProperties,
body: Serializer.Serialize(args)
body: Serializer.Serialize(args!)
);
return Task.CompletedTask;
@ -188,7 +188,7 @@ public class JobQueue<TArgs> : IJobQueue<TArgs>
protected virtual IBasicProperties CreateBasicPropertiesToPublish()
{
var properties = ChannelAccessor.Channel.CreateBasicProperties();
var properties = ChannelAccessor!.Channel.CreateBasicProperties();
properties.Persistent = true;
return properties;
}
@ -206,17 +206,17 @@ public class JobQueue<TArgs> : IJobQueue<TArgs>
try
{
await JobExecuter.ExecuteAsync(context);
ChannelAccessor.Channel.BasicAck(deliveryTag: ea.DeliveryTag, multiple: false);
ChannelAccessor!.Channel.BasicAck(deliveryTag: ea.DeliveryTag, multiple: false);
}
catch (BackgroundJobExecutionException)
{
//TODO: Reject like that?
ChannelAccessor.Channel.BasicReject(deliveryTag: ea.DeliveryTag, requeue: true);
ChannelAccessor!.Channel.BasicReject(deliveryTag: ea.DeliveryTag, requeue: true);
}
catch (Exception)
{
//TODO: Reject like that?
ChannelAccessor.Channel.BasicReject(deliveryTag: ea.DeliveryTag, requeue: false);
ChannelAccessor!.Channel.BasicReject(deliveryTag: ea.DeliveryTag, requeue: false);
}
}
}

@ -9,7 +9,7 @@ public class JobQueueConfiguration : QueueDeclareConfiguration
{
public Type JobArgsType { get; }
public string ConnectionName { get; set; }
public string? ConnectionName { get; set; }
public string DelayedQueueName { get; set; }
@ -17,7 +17,7 @@ public class JobQueueConfiguration : QueueDeclareConfiguration
Type jobArgsType,
string queueName,
string delayedQueueName,
string connectionName = null,
string? connectionName = null,
bool durable = true,
bool exclusive = false,
bool autoDelete = false,

@ -20,6 +20,6 @@ public class RabbitMqBackgroundJobManager : IBackgroundJobManager, ITransientDep
TimeSpan? delay = null)
{
var jobQueue = await _jobQueueManager.GetAsync<TArgs>();
return await jobQueue.EnqueueAsync(args, priority, delay);
return (await jobQueue.EnqueueAsync(args, priority, delay))!;
}
}

@ -5,6 +5,8 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net7.0</TargetFrameworks>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
<AssemblyName>Volo.Abp.BackgroundJobs</AssemblyName>
<PackageId>Volo.Abp.BackgroundJobs</PackageId>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>

@ -12,12 +12,12 @@ public class BackgroundJobInfo
/// <summary>
/// Name of the job.
/// </summary>
public virtual string JobName { get; set; }
public virtual string JobName { get; set; } = default!;
/// <summary>
/// Job arguments as serialized to string.
/// </summary>
public virtual string JobArgs { get; set; }
public virtual string JobArgs { get; set; } = default!;
/// <summary>
/// Try count of this job.

@ -32,7 +32,7 @@ public class DefaultBackgroundJobManager : IBackgroundJobManager, ITransientDepe
public virtual async Task<string> EnqueueAsync<TArgs>(TArgs args, BackgroundJobPriority priority = BackgroundJobPriority.Normal, TimeSpan? delay = null)
{
var jobName = BackgroundJobNameAttribute.GetName<TArgs>();
var jobId = await EnqueueAsync(jobName, args, priority, delay);
var jobId = await EnqueueAsync(jobName, args!, priority, delay);
return jobId.ToString();
}

@ -25,7 +25,7 @@ public class InMemoryBackgroundJobStore : IBackgroundJobStore, ISingletonDepende
public virtual Task<BackgroundJobInfo> FindAsync(Guid jobId)
{
return Task.FromResult(_jobs.GetOrDefault(jobId));
return Task.FromResult(_jobs.GetOrDefault(jobId))!;
}
public virtual Task InsertAsync(BackgroundJobInfo jobInfo)

@ -5,6 +5,8 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net7.0</TargetFrameworks>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
<AssemblyName>Volo.Abp.BackgroundWorkers.Hangfire</AssemblyName>
<PackageId>Volo.Abp.BackgroundWorkers.Hangfire</PackageId>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>

@ -38,7 +38,7 @@ public class AbpBackgroundWorkersHangfireModule : AbpModule
AsyncHelper.RunSync(() => OnPreApplicationInitializationAsync(context));
}
private BackgroundJobServer CreateOnlyEnqueueJobServer(IServiceProvider serviceProvider)
private BackgroundJobServer? CreateOnlyEnqueueJobServer(IServiceProvider serviceProvider)
{
serviceProvider.GetRequiredService<JobStorage>();
return null;

@ -6,11 +6,11 @@ namespace Volo.Abp.BackgroundWorkers.Hangfire;
public abstract class HangfireBackgroundWorkerBase : BackgroundWorkerBase, IHangfireBackgroundWorker
{
public string RecurringJobId { get; set; }
public string? RecurringJobId { get; set; }
public string CronExpression { get; set; }
public string CronExpression { get; set; } = default!;
public TimeZoneInfo TimeZone { get; set; }
public TimeZoneInfo? TimeZone { get; set; }
public string Queue { get; set; }

@ -14,7 +14,7 @@ namespace Volo.Abp.BackgroundWorkers.Hangfire;
[Dependency(ReplaceServices = true)]
public class HangfireBackgroundWorkerManager : BackgroundWorkerManager, ISingletonDependency
{
protected AbpHangfireBackgroundJobServer BackgroundJobServer { get; set; }
protected AbpHangfireBackgroundJobServer BackgroundJobServer { get; set; } = default!;
protected IServiceProvider ServiceProvider { get; }
public HangfireBackgroundWorkerManager(IServiceProvider serviceProvider)
@ -57,7 +57,7 @@ public class HangfireBackgroundWorkerManager : BackgroundWorkerManager, ISinglet
var timer = worker.GetType()
.GetProperty("Timer", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(worker);
var period = worker is AsyncPeriodicBackgroundWorkerBase ? ((AbpAsyncTimer)timer)?.Period : ((AbpTimer)timer)?.Period;
var period = worker is AsyncPeriodicBackgroundWorkerBase ? ((AbpAsyncTimer?)timer)?.Period : ((AbpTimer?)timer)?.Period;
if (period == null)
{
@ -65,7 +65,7 @@ public class HangfireBackgroundWorkerManager : BackgroundWorkerManager, ISinglet
}
var adapterType = typeof(HangfirePeriodicBackgroundWorkerAdapter<>).MakeGenericType(ProxyHelper.GetUnProxiedType(worker));
var workerAdapter = Activator.CreateInstance(adapterType) as IHangfireBackgroundWorker;
var workerAdapter = (Activator.CreateInstance(adapterType) as IHangfireBackgroundWorker)!;
RecurringJob.AddOrUpdate(() => workerAdapter.DoWorkAsync(cancellationToken), GetCron(period.Value), workerAdapter.TimeZone, workerAdapter.Queue);

@ -14,8 +14,8 @@ public class HangfirePeriodicBackgroundWorkerAdapter<TWorker> : HangfireBackgrou
public HangfirePeriodicBackgroundWorkerAdapter()
{
_doWorkAsyncMethod =
typeof(TWorker).GetMethod("DoWorkAsync", BindingFlags.Instance | BindingFlags.NonPublic);
_doWorkMethod = typeof(TWorker).GetMethod("DoWork", BindingFlags.Instance | BindingFlags.NonPublic);
typeof(TWorker).GetMethod("DoWorkAsync", BindingFlags.Instance | BindingFlags.NonPublic)!;
_doWorkMethod = typeof(TWorker).GetMethod("DoWork", BindingFlags.Instance | BindingFlags.NonPublic)!;
}
public async override Task DoWorkAsync(CancellationToken cancellationToken = default)
@ -26,7 +26,7 @@ public class HangfirePeriodicBackgroundWorkerAdapter<TWorker> : HangfireBackgrou
switch (worker)
{
case AsyncPeriodicBackgroundWorkerBase asyncPeriodicBackgroundWorker:
await (Task)_doWorkAsyncMethod.Invoke(asyncPeriodicBackgroundWorker, new object[] { workerContext });
await (Task)(_doWorkAsyncMethod.Invoke(asyncPeriodicBackgroundWorker, new object[] { workerContext })!);
break;
case PeriodicBackgroundWorkerBase periodicBackgroundWorker:
_doWorkMethod.Invoke(periodicBackgroundWorker, new object[] { workerContext });

@ -6,11 +6,11 @@ namespace Volo.Abp.BackgroundWorkers.Hangfire;
public interface IHangfireBackgroundWorker : IBackgroundWorker
{
string RecurringJobId { get; set; }
string? RecurringJobId { get; set; }
string CronExpression { get; set; }
TimeZoneInfo TimeZone { get; set; }
TimeZoneInfo? TimeZone { get; set; }
string Queue { get; set; }

@ -6,6 +6,8 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net7.0</TargetFrameworks>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
<AssemblyName>Volo.Abp.BackgroundWorkers.Quartz</AssemblyName>
<PackageId>Volo.Abp.BackgroundWorkers.Quartz</PackageId>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>

@ -12,5 +12,5 @@ public interface IQuartzBackgroundWorker : IBackgroundWorker, IJob
bool AutoRegister { get; set; }
Func<IScheduler, Task> ScheduleJob { get; set; }
Func<IScheduler, Task>? ScheduleJob { get; set; }
}

@ -6,13 +6,13 @@ namespace Volo.Abp.BackgroundWorkers.Quartz;
public abstract class QuartzBackgroundWorkerBase : BackgroundWorkerBase, IQuartzBackgroundWorker
{
public ITrigger Trigger { get; set; }
public ITrigger Trigger { get; set; } = default!;
public IJobDetail JobDetail { get; set; }
public IJobDetail JobDetail { get; set; } = default!;
public bool AutoRegister { get; set; } = true;
public Func<IScheduler, Task> ScheduleJob { get; set; } = null;
public Func<IScheduler, Task>? ScheduleJob { get; set; } = null;
public abstract Task Execute(IJobExecutionContext context);
}

@ -1,6 +1,7 @@
using System;
using System.Reflection;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Quartz;
using Volo.Abp.DynamicProxy;
using Volo.Abp.Threading;
@ -12,8 +13,8 @@ public class QuartzPeriodicBackgroundWorkerAdapter<TWorker> : QuartzBackgroundWo
IQuartzBackgroundWorkerAdapter
where TWorker : IBackgroundWorker
{
private readonly MethodInfo _doWorkAsyncMethod;
private readonly MethodInfo _doWorkMethod;
private readonly MethodInfo? _doWorkAsyncMethod;
private readonly MethodInfo? _doWorkMethod;
public QuartzPeriodicBackgroundWorkerAdapter()
{
@ -40,11 +41,11 @@ public class QuartzPeriodicBackgroundWorkerAdapter<TWorker> : QuartzBackgroundWo
if (worker is AsyncPeriodicBackgroundWorkerBase)
{
period = ((AbpAsyncTimer)timer)?.Period;
period = ((AbpAsyncTimer?)timer)?.Period;
}
else
{
period = ((AbpTimer)timer)?.Period;
period = ((AbpTimer?)timer)?.Period;
}
}
else
@ -59,17 +60,17 @@ public class QuartzPeriodicBackgroundWorkerAdapter<TWorker> : QuartzBackgroundWo
JobDetail = JobBuilder
.Create<QuartzPeriodicBackgroundWorkerAdapter<TWorker>>()
.WithIdentity(workerType.FullName)
.WithIdentity(workerType.FullName!)
.Build();
Trigger = TriggerBuilder.Create()
.WithIdentity(workerType.FullName)
.WithIdentity(workerType.FullName!)
.WithSimpleSchedule(builder => builder.WithInterval(TimeSpan.FromMilliseconds(period.Value)).RepeatForever())
.Build();
}
public async override Task Execute(IJobExecutionContext context)
{
var worker = (IBackgroundWorker) ServiceProvider.GetService(typeof(TWorker));
var worker = (IBackgroundWorker) ServiceProvider.GetRequiredService(typeof(TWorker));
var workerContext = new PeriodicBackgroundWorkerContext(ServiceProvider, context.CancellationToken);
switch (worker)
@ -78,7 +79,7 @@ public class QuartzPeriodicBackgroundWorkerAdapter<TWorker> : QuartzBackgroundWo
{
if (_doWorkAsyncMethod != null)
{
await (Task) _doWorkAsyncMethod.Invoke(asyncWorker, new object[] {workerContext});
await (Task) (_doWorkAsyncMethod.Invoke(asyncWorker, new object[] {workerContext})!);
}
break;

@ -5,6 +5,8 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net7.0</TargetFrameworks>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
<AssemblyName>Volo.Abp.BackgroundWorkers</AssemblyName>
<PackageId>Volo.Abp.BackgroundWorkers</PackageId>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>

@ -14,13 +14,13 @@ public abstract class BackgroundWorkerBase : IBackgroundWorker
{
//TODO: Add UOW, Localization and other useful properties..?
public IAbpLazyServiceProvider LazyServiceProvider { get; set; }
public IAbpLazyServiceProvider LazyServiceProvider { get; set; } = default!;
public IServiceProvider ServiceProvider { get; set; }
public IServiceProvider ServiceProvider { get; set; } = default!;
protected ILoggerFactory LoggerFactory => LazyServiceProvider.LazyGetRequiredService<ILoggerFactory>();
protected ILogger Logger => LazyServiceProvider.LazyGetService<ILogger>(provider => LoggerFactory?.CreateLogger(GetType().FullName) ?? NullLogger.Instance);
protected ILogger Logger => LazyServiceProvider.LazyGetService<ILogger>(provider => LoggerFactory?.CreateLogger(GetType().FullName!) ?? NullLogger.Instance);
protected CancellationTokenSource StoppingTokenSource { get; }
protected CancellationToken StoppingToken { get; }
@ -47,6 +47,6 @@ public abstract class BackgroundWorkerBase : IBackgroundWorker
public override string ToString()
{
return GetType().FullName;
return GetType().FullName!;
}
}

@ -37,7 +37,7 @@ public abstract class PeriodicBackgroundWorkerBase : BackgroundWorkerBase
await base.StopAsync(cancellationToken);
}
private void Timer_Elapsed(object sender, System.EventArgs e)
private void Timer_Elapsed(object? sender, System.EventArgs e)
{
using (var scope = ServiceScopeFactory.CreateScope())
{

@ -174,32 +174,32 @@ public abstract class AbpCrudPageBase<
where TCreateViewModel : class, new()
where TUpdateViewModel : class, new()
{
[Inject] protected TAppService AppService { get; set; }
[Inject] protected IStringLocalizer<AbpUiResource> UiLocalizer { get; set; }
[Inject] public IAbpEnumLocalizer AbpEnumLocalizer { get; set; }
[Inject] protected TAppService AppService { get; set; } = default!;
[Inject] protected IStringLocalizer<AbpUiResource> UiLocalizer { get; set; } = default!;
[Inject] public IAbpEnumLocalizer AbpEnumLocalizer { get; set; } = default!;
protected virtual int PageSize { get; } = LimitedResultRequestDto.DefaultMaxResultCount;
protected int CurrentPage = 1;
protected string CurrentSorting;
protected string CurrentSorting = default!;
protected int? TotalCount;
protected TGetListInput GetListInput = new TGetListInput();
protected IReadOnlyList<TListViewModel> Entities = Array.Empty<TListViewModel>();
protected TCreateViewModel NewEntity;
protected TKey EditingEntityId;
protected TKey EditingEntityId = default!;
protected TUpdateViewModel EditingEntity;
protected Modal CreateModal;
protected Modal EditModal;
protected Validations CreateValidationsRef;
protected Validations EditValidationsRef;
protected Modal? CreateModal;
protected Modal? EditModal;
protected Validations? CreateValidationsRef;
protected Validations? EditValidationsRef;
protected List<BreadcrumbItem> BreadcrumbItems = new List<BreadcrumbItem>(2);
protected DataGridEntityActionsColumn<TListViewModel> EntityActionsColumn;
protected DataGridEntityActionsColumn<TListViewModel> EntityActionsColumn = default!;
protected EntityActionDictionary EntityActions { get; set; }
protected TableColumnDictionary TableColumns { get; set; }
protected string CreatePolicyName { get; set; }
protected string UpdatePolicyName { get; set; }
protected string DeletePolicyName { get; set; }
protected string? CreatePolicyName { get; set; }
protected string? UpdatePolicyName { get; set; }
protected string? DeletePolicyName { get; set; }
public bool HasCreatePermission { get; set; }
public bool HasUpdatePermission { get; set; }
@ -360,7 +360,7 @@ public abstract class AbpCrudPageBase<
protected virtual Task CloseCreateModalAsync()
{
NewEntity = new TCreateViewModel();
return InvokeAsync(CreateModal.Hide);
return InvokeAsync(CreateModal!.Hide);
}
protected virtual Task ClosingCreateModal(ModalClosingEventArgs eventArgs)
@ -429,7 +429,7 @@ public abstract class AbpCrudPageBase<
protected virtual Task CloseEditModalAsync()
{
InvokeAsync(EditModal.Hide);
InvokeAsync(EditModal!.Hide);
return Task.CompletedTask;
}
@ -477,7 +477,7 @@ public abstract class AbpCrudPageBase<
NewEntity = new TCreateViewModel();
await GetEntitiesAsync();
await InvokeAsync(CreateModal.Hide);
await InvokeAsync(CreateModal!.Hide);
}
protected virtual async Task UpdateEntityAsync()
@ -515,7 +515,7 @@ public abstract class AbpCrudPageBase<
{
await GetEntitiesAsync();
await InvokeAsync(EditModal.Hide);
await InvokeAsync(EditModal!.Hide);
}
protected virtual async Task DeleteEntityAsync(TListViewModel entity)
@ -572,7 +572,7 @@ public abstract class AbpCrudPageBase<
/// Does nothing if <paramref name="policyName"/> is null or empty.
/// </summary>
/// <param name="policyName">A policy name to check</param>
protected virtual async Task CheckPolicyAsync([CanBeNull] string policyName)
protected virtual async Task CheckPolicyAsync(string? policyName)
{
if (string.IsNullOrEmpty(policyName))
{
@ -633,7 +633,7 @@ public abstract class AbpCrudPageBase<
if (propertyInfo.Name.EndsWith("_Text"))
{
var lookupPropertyName = propertyInfo.Name.RemovePostFix("_Text");
var lookupPropertyDefinition = properties.SingleOrDefault(t => t.Name == lookupPropertyName);
var lookupPropertyDefinition = properties.SingleOrDefault(t => t.Name == lookupPropertyName)!;
yield return new TableColumn
{
Title = lookupPropertyDefinition.GetLocalizedDisplayName(StringLocalizerFactory),
@ -658,7 +658,7 @@ public abstract class AbpCrudPageBase<
if (propertyInfo.Type.IsEnum)
{
column.ValueConverter = (val) =>
AbpEnumLocalizer.GetString(propertyInfo.Type, val.As<ExtensibleObject>().ExtraProperties[propertyInfo.Name], new IStringLocalizer[]{ StringLocalizerFactory.CreateDefaultOrNull() });
AbpEnumLocalizer.GetString(propertyInfo.Type, val.As<ExtensibleObject>().ExtraProperties[propertyInfo.Name]!, new IStringLocalizer?[]{ StringLocalizerFactory.CreateDefaultOrNull() });
}
yield return column;

@ -15,7 +15,7 @@ public class BlazoriseUiMessageService : IUiMessageService, IScopedDependency
/// <summary>
/// An event raised after the message is received. Used to notify the message dialog.
/// </summary>
public event EventHandler<UiMessageEventArgs> MessageReceived;
public event EventHandler<UiMessageEventArgs>? MessageReceived ;
private readonly IStringLocalizer<AbpUiResource> localizer;
@ -29,7 +29,7 @@ public class BlazoriseUiMessageService : IUiMessageService, IScopedDependency
Logger = NullLogger<BlazoriseUiMessageService>.Instance;
}
public Task Info(string message, string title = null, Action<UiMessageOptions> options = null)
public Task Info(string message, string? title = null, Action<UiMessageOptions>? options = null)
{
var uiMessageOptions = CreateDefaultOptions();
options?.Invoke(uiMessageOptions);
@ -39,7 +39,7 @@ public class BlazoriseUiMessageService : IUiMessageService, IScopedDependency
return Task.CompletedTask;
}
public Task Success(string message, string title = null, Action<UiMessageOptions> options = null)
public Task Success(string message, string? title = null, Action<UiMessageOptions>? options = null)
{
var uiMessageOptions = CreateDefaultOptions();
options?.Invoke(uiMessageOptions);
@ -49,7 +49,7 @@ public class BlazoriseUiMessageService : IUiMessageService, IScopedDependency
return Task.CompletedTask;
}
public Task Warn(string message, string title = null, Action<UiMessageOptions> options = null)
public Task Warn(string message, string? title = null, Action<UiMessageOptions>? options = null)
{
var uiMessageOptions = CreateDefaultOptions();
options?.Invoke(uiMessageOptions);
@ -59,7 +59,7 @@ public class BlazoriseUiMessageService : IUiMessageService, IScopedDependency
return Task.CompletedTask;
}
public Task Error(string message, string title = null, Action<UiMessageOptions> options = null)
public Task Error(string message, string? title = null, Action<UiMessageOptions>? options = null)
{
var uiMessageOptions = CreateDefaultOptions();
options?.Invoke(uiMessageOptions);
@ -69,7 +69,7 @@ public class BlazoriseUiMessageService : IUiMessageService, IScopedDependency
return Task.CompletedTask;
}
public Task<bool> Confirm(string message, string title = null, Action<UiMessageOptions> options = null)
public Task<bool> Confirm(string message, string? title = null, Action<UiMessageOptions>? options = null)
{
var uiMessageOptions = CreateDefaultOptions();
options?.Invoke(uiMessageOptions);

@ -11,9 +11,9 @@ public class BlazoriseUiNotificationService : IUiNotificationService, IScopedDep
/// <summary>
/// An event raised after the notification is received.
/// </summary>
public event EventHandler<UiNotificationEventArgs> NotificationReceived;
public event EventHandler<UiNotificationEventArgs>? NotificationReceived;
public Task Info(string message, string title = null, Action<UiNotificationOptions> options = null)
public Task Info(string message, string? title = null, Action<UiNotificationOptions>? options = null)
{
var uiNotificationOptions = CreateDefaultOptions();
options?.Invoke(uiNotificationOptions);
@ -23,7 +23,7 @@ public class BlazoriseUiNotificationService : IUiNotificationService, IScopedDep
return Task.CompletedTask;
}
public Task Success(string message, string title = null, Action<UiNotificationOptions> options = null)
public Task Success(string message, string? title = null, Action<UiNotificationOptions>? options = null)
{
var uiNotificationOptions = CreateDefaultOptions();
options?.Invoke(uiNotificationOptions);
@ -33,7 +33,7 @@ public class BlazoriseUiNotificationService : IUiNotificationService, IScopedDep
return Task.CompletedTask;
}
public Task Warn(string message, string title = null, Action<UiNotificationOptions> options = null)
public Task Warn(string message, string? title = null, Action<UiNotificationOptions>? options = null)
{
var uiNotificationOptions = CreateDefaultOptions();
options?.Invoke(uiNotificationOptions);
@ -43,7 +43,7 @@ public class BlazoriseUiNotificationService : IUiNotificationService, IScopedDep
return Task.CompletedTask;
}
public Task Error(string message, string title = null, Action<UiNotificationOptions> options = null)
public Task Error(string message, string? title = null, Action<UiNotificationOptions>? options = null)
{
var uiNotificationOptions = CreateDefaultOptions();
options?.Invoke(uiNotificationOptions);

@ -44,7 +44,7 @@ public static class BlazoriseUiObjectExtensionPropertyInfoExtensions
typeof(PhoneAttribute)
};
public static string GetDateEditInputFormatOrNull(this IBasicObjectExtensionPropertyInfo property)
public static string? GetDateEditInputFormatOrNull(this IBasicObjectExtensionPropertyInfo property)
{
if (property.IsDate())
{
@ -59,7 +59,7 @@ public static class BlazoriseUiObjectExtensionPropertyInfoExtensions
return null;
}
public static string GetTextInputValueOrNull(this IBasicObjectExtensionPropertyInfo property, object value)
public static string? GetTextInputValueOrNull(this IBasicObjectExtensionPropertyInfo property, object? value)
{
if (value == null)
{
@ -74,7 +74,7 @@ public static class BlazoriseUiObjectExtensionPropertyInfoExtensions
return value.ToString();
}
public static T GetInputValueOrDefault<T>(this IBasicObjectExtensionPropertyInfo property, object value)
public static T? GetInputValueOrDefault<T>(this IBasicObjectExtensionPropertyInfo property, object? value)
{
if (value == null)
{
@ -204,7 +204,7 @@ public static class BlazoriseUiObjectExtensionPropertyInfoExtensions
?? typeof(TextExtensionProperty<,>); //default
}
private static Type GetInputTypeFromAttributeOrNull(Attribute attribute)
private static Type? GetInputTypeFromAttributeOrNull(Attribute attribute)
{
var hasTextEditSupport = TextEditSupportedAttributeTypes.Any(t => t == attribute.GetType());
@ -238,7 +238,7 @@ public static class BlazoriseUiObjectExtensionPropertyInfoExtensions
return null;
}
private static Type GetInputTypeFromTypeOrNull(Type type)
private static Type? GetInputTypeFromTypeOrNull(Type type)
{
if (type == typeof(bool))
{

@ -12,9 +12,9 @@ public class BlazoriseUiPageProgressService : IUiPageProgressService,
/// <summary>
/// An event raised after the notification is received.
/// </summary>
public event EventHandler<UiPageProgressEventArgs> ProgressChanged;
public event EventHandler<UiPageProgressEventArgs>? ProgressChanged;
public Task Go(int? percentage, Action<UiPageProgressOptions> options = null)
public Task Go(int? percentage, Action<UiPageProgressOptions>? options = null)
{
var uiPageProgressOptions = CreateDefaultOptions();
options?.Invoke(uiPageProgressOptions);

@ -6,11 +6,11 @@ public class BreadcrumbItem
{
public string Text { get; set; }
public object Icon { get; set; }
public object? Icon { get; set; }
public string Url { get; set; }
public string? Url { get; set; }
public BreadcrumbItem(string text, string url = null, object icon = null)
public BreadcrumbItem(string text, string? url = null, object? icon = null)
{
Text = text;
Url = url;

@ -121,7 +121,7 @@
@{
var entity = context as IHasExtraProperties;
var propertyName = ExtensionPropertiesRegex.Match(column.Data).Groups[1].Value;
var propertyValue = entity.GetProperty(propertyName);
var propertyValue = entity?.GetProperty(propertyName);
if (propertyValue != null && propertyValue.GetType() == typeof(bool))
{
if ((bool) propertyValue)

@ -18,7 +18,7 @@ public partial class AbpExtensibleDataGrid<TItem> : ComponentBase
protected Regex ExtensionPropertiesRegex = new Regex(@"ExtraProperties\[(.*?)\]");
[Parameter] public IEnumerable<TItem> Data { get; set; }
[Parameter] public IEnumerable<TItem> Data { get; set; } = default!;
[Parameter] public EventCallback<DataGridReadDataEventArgs<TItem>> ReadData { get; set; }
@ -28,16 +28,16 @@ public partial class AbpExtensibleDataGrid<TItem> : ComponentBase
[Parameter] public int PageSize { get; set; }
[Parameter] public IEnumerable<TableColumn> Columns { get; set; }
[Parameter] public IEnumerable<TableColumn> Columns { get; set; } = default!;
[Parameter] public int CurrentPage { get; set; } = 1;
[Parameter] public string Class { get; set; }
[Parameter] public string? Class { get; set; }
[Parameter] public bool Responsive { get; set; }
[Inject]
public IStringLocalizerFactory StringLocalizerFactory { get; set; }
public IStringLocalizerFactory StringLocalizerFactory { get; set; } = default!;
protected virtual RenderFragment RenderCustomTableColumnComponent(Type type, object data)
{
@ -51,10 +51,10 @@ public partial class AbpExtensibleDataGrid<TItem> : ComponentBase
protected virtual string GetConvertedFieldValue(TItem item, TableColumn columnDefinition)
{
var convertedValue = columnDefinition.ValueConverter.Invoke(item);
var convertedValue = columnDefinition.ValueConverter!.Invoke(item!);
if (!columnDefinition.DisplayFormat.IsNullOrEmpty())
{
return string.Format(columnDefinition.DisplayFormatProvider, columnDefinition.DisplayFormat,
return string.Format(columnDefinition.DisplayFormatProvider, columnDefinition.DisplayFormat!,
convertedValue);
}

@ -4,6 +4,6 @@ namespace Volo.Abp.BlazoriseUI.Components;
internal class AlertWrapper
{
public AlertMessage AlertMessage { get; set; }
public AlertMessage AlertMessage { get; set; } = default!;
public bool IsVisible { get; set; }
}

@ -10,7 +10,7 @@ namespace Volo.Abp.BlazoriseUI.Components;
public partial class DataGridEntityActionsColumn<TItem> : DataGridColumn<TItem>
{
[Inject]
public IStringLocalizer<AbpUiResource> UiLocalizer { get; set; }
public IStringLocalizer<AbpUiResource> UiLocalizer { get; set; } = default!;
protected override async Task OnInitializedAsync()
{

@ -18,7 +18,7 @@ public partial class EntityAction<TItem> : ComponentBase
internal bool HasPermission { get; set; } = true;
[Parameter]
public string Text { get; set; }
public string Text { get; set; } = default!;
[Parameter]
public bool Primary { get; set; }
@ -28,25 +28,25 @@ public partial class EntityAction<TItem> : ComponentBase
[Parameter]
[Obsolete("Use Visible to hide actions based on permissions. Check the permission yourself. It is more performant. This option might be removed in future versions.")]
public string RequiredPolicy { get; set; }
public string? RequiredPolicy { get; set; }
[Parameter]
public Color Color { get; set; }
public Color? Color { get; set; }
[Parameter]
public Func<string> ConfirmationMessage { get; set; }
public Func<string>? ConfirmationMessage { get; set; }
[Parameter]
public string Icon { get; set; }
public string? Icon { get; set; }
[CascadingParameter]
public EntityActions<TItem> ParentActions { get; set; }
public EntityActions<TItem> ParentActions { get; set; } = default!;
[Inject]
protected IAuthorizationService AuthorizationService { get; set; }
protected IAuthorizationService AuthorizationService { get; set; } = default!;
[Inject]
protected IUiMessageService UiMessageService { get; set; }
protected IUiMessageService UiMessageService { get; set; } = default!;
protected async override Task OnInitializedAsync()
{
@ -55,7 +55,7 @@ public partial class EntityAction<TItem> : ComponentBase
if (!RequiredPolicy.IsNullOrEmpty())
{
HasPermission = await AuthorizationService.IsGrantedAsync(RequiredPolicy);
HasPermission = await AuthorizationService.IsGrantedAsync(RequiredPolicy!);
}
ParentActions.AddAction(this);
}

@ -6,7 +6,7 @@
@if ( HasPrimaryAction )
{
<Button Block="true"
Color="@PrimaryAction.Color"
Color="@PrimaryAction!.Color"
Clicked="async ()=> await PrimaryAction.ActionClickedAsync()"
Disabled=@PrimaryAction.Disabled>
@PrimaryAction.Text

@ -12,19 +12,19 @@ public partial class EntityActions<TItem> : ComponentBase
{
protected readonly List<EntityAction<TItem>> Actions = new List<EntityAction<TItem>>();
protected bool HasPrimaryAction => Actions.Any(t => t.Primary);
protected EntityAction<TItem> PrimaryAction => Actions.FirstOrDefault(t => t.Primary);
protected EntityAction<TItem>? PrimaryAction => Actions.FirstOrDefault(t => t.Primary);
[Parameter]
public Color ToggleColor { get; set; } = Color.Primary;
[Parameter]
public string ToggleText { get; set; }
public string? ToggleText { get; set; }
[Parameter]
public RenderFragment ChildContent { get; set; }
public RenderFragment ChildContent { get; set; } = default!;
[Parameter]
public DataGridEntityActionsColumn<TItem> EntityActionsColumn { get; set; }
public DataGridEntityActionsColumn<TItem> EntityActionsColumn { get; set; } = default!;
[Parameter]
public ActionType Type { get; set; } = ActionType.Dropdown;
@ -33,10 +33,10 @@ public partial class EntityActions<TItem> : ComponentBase
public bool Disabled { get; set; } = false;
[CascadingParameter]
public DataGridEntityActionsColumn<TItem> ParentEntityActionsColumn { get; set; }
public DataGridEntityActionsColumn<TItem>? ParentEntityActionsColumn { get; set; }
[Inject]
public IStringLocalizer<AbpUiResource> UiLocalizer { get; set; }
public IStringLocalizer<AbpUiResource> UiLocalizer { get; set; } = default!;
internal void AddAction(EntityAction<TItem> action)
{

@ -17,17 +17,17 @@ public static class EnumHelper
var localizedMemberName = AbpInternalLocalizationHelper.LocalizeWithFallback(
new[]
{
stringLocalizerFactory.CreateDefaultOrNull()
stringLocalizerFactory.CreateDefaultOrNull()
},
new[]
{
$"Enum:{enumType.Name}.{value}",
$"Enum:{enumType.Name}.{memberName}",
$"{enumType.Name}.{value}",
$"{enumType.Name}.{memberName}",
memberName
},
memberName
$"Enum:{enumType.Name}.{value}",
$"Enum:{enumType.Name}.{memberName}",
$"{enumType.Name}.{value}",
$"{enumType.Name}.{memberName}",
memberName
}!,
memberName!
);
return localizedMemberName;

@ -10,13 +10,13 @@ public partial class ExtensionProperties<TEntityType, TResourceType> : Component
where TEntityType : IHasExtraProperties
{
[Inject]
public IStringLocalizerFactory StringLocalizerFactory { get; set; }
public IStringLocalizerFactory StringLocalizerFactory { get; set; } = default!;
[Parameter]
public AbpBlazorMessageLocalizerHelper<TResourceType> LH { get; set; }
public AbpBlazorMessageLocalizerHelper<TResourceType> LH { get; set; } = default!;
[Parameter]
public TEntityType Entity { get; set; }
public TEntityType Entity { get; set; } = default!;
[Parameter]
public ExtensionPropertyModalType? ModalType { get; set; }

@ -16,22 +16,22 @@ public abstract class ExtensionPropertyComponentBase<TEntity, TResourceType> : O
where TEntity : IHasExtraProperties
{
[Inject]
public IStringLocalizerFactory StringLocalizerFactory { get; set; }
public IStringLocalizerFactory StringLocalizerFactory { get; set; } = default!;
[Inject]
public IAbpEnumLocalizer AbpEnumLocalizer { get; set; }
public IAbpEnumLocalizer AbpEnumLocalizer { get; set; } = default!;
[Inject]
public IValidationMessageLocalizerAttributeFinder ValidationMessageLocalizerAttributeFinder { get; set; }
public IValidationMessageLocalizerAttributeFinder ValidationMessageLocalizerAttributeFinder { get; set; } = default!;
[Parameter]
public TEntity Entity { get; set; }
public TEntity Entity { get; set; } = default!;
[Parameter]
public ObjectExtensionPropertyInfo PropertyInfo { get; set; }
public ObjectExtensionPropertyInfo PropertyInfo { get; set; } = default!;
[Parameter]
public AbpBlazorMessageLocalizerHelper<TResourceType> LH { get; set; }
public AbpBlazorMessageLocalizerHelper<TResourceType> LH { get; set; } = default!;
[Parameter]
public ExtensionPropertyModalType? ModalType { get; set; }

@ -25,11 +25,11 @@ public partial class LookupExtensionProperty<TEntity, TResourceType>
{
protected List<SelectItem<object>> lookupItems = new();
[Inject] public ILookupApiRequestService LookupApiService { get; set; }
[Inject] public ILookupApiRequestService LookupApiService { get; set; } = default!;
public string TextPropertyName => PropertyInfo.Name + "_Text";
public object SelectedValue {
public object? SelectedValue {
get { return Entity.GetProperty(PropertyInfo.Name); }
set {
Entity.SetProperty(PropertyInfo.Name, value, false);
@ -45,7 +45,7 @@ public partial class LookupExtensionProperty<TEntity, TResourceType>
{
lookupItems.Add(new SelectItem<object>
{
Text = Entity.GetProperty(TextPropertyName).ToString(),
Text = Entity.GetProperty(TextPropertyName)!.ToString()!,
Value = value
});
}
@ -61,7 +61,7 @@ public partial class LookupExtensionProperty<TEntity, TResourceType>
}
}
protected virtual void UpdateLookupTextProperty(object value)
protected virtual void UpdateLookupTextProperty(object? value)
{
var selectedItemText = lookupItems.SingleOrDefault(t => t.Value.Equals(value))?.Text;
Entity.SetProperty(TextPropertyName, selectedItemText);
@ -85,8 +85,8 @@ public partial class LookupExtensionProperty<TEntity, TResourceType>
{
selectItems.Add(new SelectItem<object>
{
Text = item.GetProperty(PropertyInfo.Lookup.DisplayPropertyName).GetString(),
Value = JsonSerializer.Deserialize(item.GetProperty(PropertyInfo.Lookup.ValuePropertyName).GetRawText(), PropertyInfo.Type)
Text = item.GetProperty(PropertyInfo.Lookup.DisplayPropertyName).GetString()!,
Value = JsonSerializer.Deserialize(item.GetProperty(PropertyInfo.Lookup.ValuePropertyName).GetRawText(), PropertyInfo.Type)!
});
}

@ -44,13 +44,13 @@ public partial class SelectExtensionProperty<TEntity, TResourceType>
if (!Entity.HasProperty(PropertyInfo.Name))
{
SelectedValue = (int)PropertyInfo.Type.GetEnumValues().GetValue(0);
SelectedValue = (int)PropertyInfo.Type.GetEnumValues().GetValue(0)!;
}
}
}
public class SelectItem<TValue>
{
public string Text { get; set; }
public TValue Value { get; set; }
public string Text { get; set; } = default!;
public TValue Value { get; set; } = default!;
}

@ -5,7 +5,7 @@ namespace Volo.Abp.BlazoriseUI.Components.ObjectExtending;
public partial class TextExtensionProperty<TEntity, TResourceType>
where TEntity : IHasExtraProperties
{
protected string Value {
protected string? Value {
get {
return PropertyInfo.GetTextInputValueOrNull(Entity.GetProperty(PropertyInfo.Name));
}

@ -14,10 +14,10 @@ public partial class PageAlert : ComponentBase, IDisposable
private List<AlertWrapper> Alerts = new List<AlertWrapper>();
[Inject]
protected IAlertManager AlertManager { get; set; }
protected IAlertManager AlertManager { get; set; } = default!;
[Inject]
protected NavigationManager NavigationManager { get; set; }
protected NavigationManager NavigationManager { get; set; } = default!;
protected override void OnInitialized()
{
@ -33,17 +33,17 @@ public partial class PageAlert : ComponentBase, IDisposable
}
//Since Blazor WASM doesn't support scoped dependency, we need to clear alerts on each location changed event.
private void NavigationManager_LocationChanged(object sender, LocationChangedEventArgs e)
private void NavigationManager_LocationChanged(object? sender, LocationChangedEventArgs e)
{
AlertManager.Alerts.Clear();
Alerts.Clear();
}
private void Alerts_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
private void Alerts_CollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
{
if (e.Action == NotifyCollectionChangedAction.Add)
{
foreach (var item in e.NewItems)
foreach (var item in e.NewItems!)
{
Alerts.Add(new AlertWrapper
{

@ -12,7 +12,7 @@ public partial class SubmitButton : ComponentBase
protected bool Submiting { get; set; }
[Parameter]
public string Form { get; set; }
public string Form { get; set; } = default!;
[Parameter]
public ButtonType Type { get; set; } = ButtonType.Submit;
@ -36,10 +36,10 @@ public partial class SubmitButton : ComponentBase
public EventCallback Clicked { get; set; }
[Parameter]
public RenderFragment ChildContent { get; set; }
public RenderFragment? ChildContent { get; set; }
[Inject]
protected IStringLocalizer<AbpUiResource> StringLocalizer { get; set; }
protected IStringLocalizer<AbpUiResource> StringLocalizer { get; set; } = default!;
protected bool IsDisabled
=> Disabled == true || Submiting;

@ -8,16 +8,16 @@ namespace Volo.Abp.BlazoriseUI.Components;
public partial class ToolbarButton : ComponentBase
{
[Parameter]
public Color Color { get; set; }
public Color? Color { get; set; }
[Parameter]
public object Icon { get; set; }
public object? Icon { get; set; }
[Parameter]
public string Text { get; set; }
public string Text { get; set; } = default!;
[Parameter]
public Func<Task> Clicked { get; set; }
public Func<Task> Clicked { get; set; } = default!;
[Parameter]
public bool Disabled { get; set; }

@ -10,7 +10,7 @@ namespace Volo.Abp.BlazoriseUI.Components;
public partial class UiMessageAlert : ComponentBase, IDisposable
{
protected Modal ModalRef { get; set; }
protected Modal ModalRef { get; set; } = default!;
protected virtual bool IsConfirmation
=> MessageType == UiMessageType.Confirmation;
@ -21,7 +21,7 @@ public partial class UiMessageAlert : ComponentBase, IDisposable
protected virtual bool ShowMessageIcon
=> Options?.ShowMessageIcon ?? true;
protected virtual object MessageIcon => Options?.MessageIcon ?? MessageType switch
protected virtual object? MessageIcon => Options?.MessageIcon ?? MessageType switch
{
UiMessageType.Info => IconName.Info,
UiMessageType.Success => IconName.Check,
@ -31,7 +31,7 @@ public partial class UiMessageAlert : ComponentBase, IDisposable
_ => null,
};
protected virtual string MessageIconColor => MessageType switch
protected virtual string? MessageIconColor => MessageType switch
{
// gets the color in the order of importance: Blazorise > Bootstrap > fallback color
UiMessageType.Info => "var(--b-theme-info, var(--info, #17a2b8))",
@ -63,13 +63,13 @@ public partial class UiMessageAlert : ComponentBase, IDisposable
[Parameter] public UiMessageType MessageType { get; set; }
[Parameter] public string Title { get; set; }
[Parameter] public string? Title { get; set; }
[Parameter] public string Message { get; set; }
[Parameter] public string Message { get; set; } = default!;
[Parameter] public TaskCompletionSource<bool> Callback { get; set; }
[Parameter] public TaskCompletionSource<bool>? Callback { get; set; }
[Parameter] public UiMessageOptions Options { get; set; }
[Parameter] public UiMessageOptions? Options { get; set; }
[Parameter] public EventCallback Okayed { get; set; }
@ -77,16 +77,19 @@ public partial class UiMessageAlert : ComponentBase, IDisposable
[Parameter] public EventCallback Canceled { get; set; }
[Inject] protected BlazoriseUiMessageService UiMessageService { get; set; }
[Inject] protected BlazoriseUiMessageService? UiMessageService { get; set; }
protected override void OnInitialized()
{
base.OnInitialized();
UiMessageService.MessageReceived += OnMessageReceived;
if (UiMessageService != null)
{
UiMessageService.MessageReceived += OnMessageReceived;
}
}
private async void OnMessageReceived(object sender, UiMessageEventArgs e)
private async void OnMessageReceived(object? sender, UiMessageEventArgs e)
{
MessageType = e.MessageType;
Message = e.Message;

@ -11,23 +11,23 @@ namespace Volo.Abp.BlazoriseUI.Components;
public partial class UiNotificationAlert : ComponentBase, IDisposable
{
protected SnackbarStack SnackbarStack { get; set; }
protected SnackbarStack SnackbarStack { get; set; } = default!;
[Parameter] public UiNotificationType NotificationType { get; set; }
[Parameter] public string Message { get; set; }
[Parameter] public string Message { get; set; } = default!;
[Parameter] public string Title { get; set; }
[Parameter] public string? Title { get; set; }
[Parameter] public UiNotificationOptions Options { get; set; }
[Parameter] public UiNotificationOptions? Options { get; set; }
[Parameter] public EventCallback Okayed { get; set; }
[Parameter] public EventCallback Closed { get; set; }
[Inject] protected BlazoriseUiNotificationService UiNotificationService { get; set; }
[Inject] protected BlazoriseUiNotificationService? UiNotificationService { get; set; }
[Inject] protected IStringLocalizerFactory StringLocalizerFactory { get; set; }
[Inject] protected IStringLocalizerFactory StringLocalizerFactory { get; set; } = default!;
protected virtual SnackbarColor GetSnackbarColor(UiNotificationType notificationType)
{
@ -45,10 +45,13 @@ public partial class UiNotificationAlert : ComponentBase, IDisposable
{
base.OnInitialized();
UiNotificationService.NotificationReceived += OnNotificationReceived;
if (UiNotificationService != null)
{
UiNotificationService.NotificationReceived += OnNotificationReceived;
}
}
protected virtual async void OnNotificationReceived(object sender, UiNotificationEventArgs e)
protected virtual async void OnNotificationReceived(object? sender, UiNotificationEventArgs e)
{
NotificationType = e.NotificationType;
Message = e.Message;
@ -62,7 +65,7 @@ public partial class UiNotificationAlert : ComponentBase, IDisposable
await SnackbarStack.PushAsync(Message, Title, GetSnackbarColor(e.NotificationType), (options) =>
{
options.CloseButtonIcon = IconName.Times;
options.ActionButtonText = okButtonText;
options.ActionButtonText = okButtonText!;
});
}

@ -7,24 +7,27 @@ namespace Volo.Abp.BlazoriseUI.Components;
public partial class UiPageProgress : ComponentBase, IDisposable
{
protected PageProgress PageProgressRef { get; set; }
protected PageProgress PageProgressRef { get; set; } = default!;
protected int? Percentage { get; set; }
protected bool Visible { get; set; }
protected Color Color { get; set; }
protected Color Color { get; set; } = default!;
[Inject] protected IUiPageProgressService UiPageProgressService { get; set; }
[Inject] protected IUiPageProgressService? UiPageProgressService { get; set; }
protected override void OnInitialized()
{
base.OnInitialized();
UiPageProgressService.ProgressChanged += OnProgressChanged;
if (UiPageProgressService != null)
{
UiPageProgressService.ProgressChanged += OnProgressChanged;
}
}
private async void OnProgressChanged(object sender, UiPageProgressEventArgs e)
private async void OnProgressChanged(object? sender, UiPageProgressEventArgs e)
{
Percentage = e.Percentage;
Visible = e.Percentage == null || (e.Percentage >= 0 && e.Percentage <= 100);

@ -5,6 +5,8 @@
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
</PropertyGroup>
<ItemGroup>

@ -5,6 +5,8 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net7.0</TargetFrameworks>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
<AssemblyName>Volo.Abp.BlobStoring.Aliyun</AssemblyName>
<PackageId>Volo.Abp.BlobStoring.Aliyun</PackageId>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>

@ -76,7 +76,7 @@ public class AliyunBlobProvider : BlobProviderBase, ITransientDependency
return Task.FromResult(BlobExists(ossClient, containerName, blobName));
}
public override async Task<Stream> GetOrNullAsync(BlobProviderGetArgs args)
public override async Task<Stream?> GetOrNullAsync(BlobProviderGetArgs args)
{
var containerName = GetContainerName(args);
var blobName = AliyunBlobNameCalculator.Calculate(args);
@ -94,7 +94,7 @@ public class AliyunBlobProvider : BlobProviderBase, ITransientDependency
var configuration = args.Configuration.GetAliyunConfiguration();
return configuration.ContainerName.IsNullOrWhiteSpace()
? args.ContainerName
: BlobNormalizeNamingService.NormalizeContainerName(args.Configuration, configuration.ContainerName);
: BlobNormalizeNamingService.NormalizeContainerName(args.Configuration, configuration.ContainerName!);
}
protected virtual bool BlobExists(IOss ossClient, string containerName, string blobName)

@ -70,7 +70,7 @@ public class AliyunBlobProviderConfiguration
/// The name must also be between 3 and 63 characters long.
/// If this parameter is not specified, the ContainerName of the <see cref="BlobProviderArgs"/> will be used.
/// </summary>
public string ContainerName {
public string? ContainerName {
get => _containerConfiguration.GetConfigurationOrDefault<string>(AliyunBlobProviderConfigurationNames.ContainerName);
set => _containerConfiguration.SetConfiguration(AliyunBlobProviderConfigurationNames.ContainerName, value);
}
@ -84,7 +84,7 @@ public class AliyunBlobProviderConfiguration
}
private readonly string _temporaryCredentialsCacheKey;
public string TemporaryCredentialsCacheKey {
public string? TemporaryCredentialsCacheKey {
get => _containerConfiguration.GetConfigurationOrDefault(AliyunBlobProviderConfigurationNames.TemporaryCredentialsCacheKey, _temporaryCredentialsCacheKey);
set => _containerConfiguration.SetConfiguration(AliyunBlobProviderConfigurationNames.TemporaryCredentialsCacheKey, value);
}

@ -8,11 +8,11 @@ namespace Volo.Abp.BlobStoring.Aliyun;
[Serializable]
public class AliyunTemporaryCredentialsCacheItem
{
public string AccessKeyId { get; set; }
public string AccessKeyId { get; set; } = default!;
public string AccessKeySecret { get; set; }
public string AccessKeySecret { get; set; } = default!;
public string SecurityToken { get; set; }
public string SecurityToken { get; set; } = default!;
public AliyunTemporaryCredentialsCacheItem()
{

@ -49,7 +49,7 @@ public class DefaultOssClientFactory : IOssClientFactory, ITransientDependency
{
Check.NotNullOrWhiteSpace(configuration.RoleArn, nameof(configuration.RoleArn));
Check.NotNullOrWhiteSpace(configuration.RoleSessionName, nameof(configuration.RoleSessionName));
var cacheItem = Cache.Get(configuration.TemporaryCredentialsCacheKey);
var cacheItem = Cache.Get(configuration.TemporaryCredentialsCacheKey!);
if (cacheItem == null)
{
IClientProfile profile = DefaultProfile.GetProfile(
@ -83,11 +83,11 @@ public class DefaultOssClientFactory : IOssClientFactory, ITransientDependency
AssumeRole_Credentials credentials)
{
var temporaryCredentialsCache = new AliyunTemporaryCredentialsCacheItem(
StringEncryptionService.Encrypt(credentials.AccessKeyId),
StringEncryptionService.Encrypt(credentials.AccessKeySecret),
StringEncryptionService.Encrypt(credentials.SecurityToken));
StringEncryptionService.Encrypt(credentials.AccessKeyId)!,
StringEncryptionService.Encrypt(credentials.AccessKeySecret)!,
StringEncryptionService.Encrypt(credentials.SecurityToken)!);
Cache.Set(configuration.TemporaryCredentialsCacheKey, temporaryCredentialsCache,
Cache.Set(configuration.TemporaryCredentialsCacheKey!, temporaryCredentialsCache,
new DistributedCacheEntryOptions
{
AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(configuration.DurationSeconds - 10)

@ -5,6 +5,8 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net7.0</TargetFrameworks>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>

@ -85,7 +85,7 @@ public class AwsBlobProvider : BlobProviderBase, ITransientDependency
}
}
public override async Task<Stream> GetOrNullAsync(BlobProviderGetArgs args)
public override async Task<Stream?> GetOrNullAsync(BlobProviderGetArgs args)
{
var blobName = AwsBlobNameCalculator.Calculate(args);
var containerName = GetContainerName(args);
@ -154,6 +154,6 @@ public class AwsBlobProvider : BlobProviderBase, ITransientDependency
var configuration = args.Configuration.GetAwsConfiguration();
return configuration.ContainerName.IsNullOrWhiteSpace()
? args.ContainerName
: BlobNormalizeNamingService.NormalizeContainerName(args.Configuration, configuration.ContainerName);
: BlobNormalizeNamingService.NormalizeContainerName(args.Configuration, configuration.ContainerName!);
}
}

@ -4,12 +4,12 @@ namespace Volo.Abp.BlobStoring.Aws;
public class AwsBlobProviderConfiguration
{
public string AccessKeyId {
public string? AccessKeyId {
get => _containerConfiguration.GetConfigurationOrDefault<string>(AwsBlobProviderConfigurationNames.AccessKeyId);
set => _containerConfiguration.SetConfiguration(AwsBlobProviderConfigurationNames.AccessKeyId, value);
}
public string SecretAccessKey {
public string? SecretAccessKey {
get => _containerConfiguration.GetConfigurationOrDefault<string>(AwsBlobProviderConfigurationNames.SecretAccessKey);
set => _containerConfiguration.SetConfiguration(AwsBlobProviderConfigurationNames.SecretAccessKey, value);
}
@ -29,12 +29,12 @@ public class AwsBlobProviderConfiguration
set => _containerConfiguration.SetConfiguration(AwsBlobProviderConfigurationNames.UseTemporaryFederatedCredentials, value);
}
public string ProfileName {
public string? ProfileName {
get => _containerConfiguration.GetConfigurationOrDefault<string>(AwsBlobProviderConfigurationNames.ProfileName);
set => _containerConfiguration.SetConfiguration(AwsBlobProviderConfigurationNames.ProfileName, value);
}
public string ProfilesLocation {
public string? ProfilesLocation {
get => _containerConfiguration.GetConfigurationOrDefault<string>(AwsBlobProviderConfigurationNames.ProfilesLocation);
set => _containerConfiguration.SetConfiguration(AwsBlobProviderConfigurationNames.ProfilesLocation, value);
}
@ -52,7 +52,7 @@ public class AwsBlobProviderConfiguration
set => _containerConfiguration.SetConfiguration(AwsBlobProviderConfigurationNames.Name, value);
}
public string Policy {
public string? Policy {
get => _containerConfiguration.GetConfigurationOrDefault<string>(AwsBlobProviderConfigurationNames.Policy);
set => _containerConfiguration.SetConfiguration(AwsBlobProviderConfigurationNames.Policy, value);
}
@ -68,7 +68,7 @@ public class AwsBlobProviderConfiguration
/// The name must also be between 3 and 63 characters long.
/// If this parameter is not specified, the ContainerName of the <see cref="BlobProviderArgs"/> will be used.
/// </summary>
public string ContainerName {
public string? ContainerName {
get => _containerConfiguration.GetConfigurationOrDefault<string>(AwsBlobProviderConfigurationNames.ContainerName);
set => _containerConfiguration.SetConfiguration(AwsBlobProviderConfigurationNames.ContainerName, value);
}
@ -82,7 +82,7 @@ public class AwsBlobProviderConfiguration
}
private readonly string _temporaryCredentialsCacheKey;
public string TemporaryCredentialsCacheKey {
public string? TemporaryCredentialsCacheKey {
get => _containerConfiguration.GetConfigurationOrDefault(AwsBlobProviderConfigurationNames.TemporaryCredentialsCacheKey, _temporaryCredentialsCacheKey);
set => _containerConfiguration.SetConfiguration(AwsBlobProviderConfigurationNames.TemporaryCredentialsCacheKey, value);
}

@ -5,11 +5,11 @@ namespace Volo.Abp.BlobStoring.Aws;
[Serializable]
public class AwsTemporaryCredentialsCacheItem
{
public string AccessKeyId { get; set; }
public string AccessKeyId { get; set; } = default!;
public string SecretAccessKey { get; set; }
public string SecretAccessKey { get; set; } = default!;
public string SessionToken { get; set; }
public string SessionToken { get; set; } = default!;
public AwsTemporaryCredentialsCacheItem()
{

@ -57,7 +57,7 @@ public class DefaultAmazonS3ClientFactory : IAmazonS3ClientFactory, ITransientDe
return new AmazonS3Client(configuration.AccessKeyId, configuration.SecretAccessKey, region);
}
protected virtual AWSCredentials GetAwsCredentials(
protected virtual AWSCredentials? GetAwsCredentials(
AwsBlobProviderConfiguration configuration)
{
if (configuration.ProfileName.IsNullOrWhiteSpace())
@ -78,7 +78,7 @@ public class DefaultAmazonS3ClientFactory : IAmazonS3ClientFactory, ITransientDe
protected virtual async Task<SessionAWSCredentials> GetTemporaryCredentialsAsync(
AwsBlobProviderConfiguration configuration)
{
var temporaryCredentialsCache = await Cache.GetAsync(configuration.TemporaryCredentialsCacheKey);
var temporaryCredentialsCache = await Cache.GetAsync(configuration.TemporaryCredentialsCacheKey!);
if (temporaryCredentialsCache == null)
{
@ -127,7 +127,7 @@ public class DefaultAmazonS3ClientFactory : IAmazonS3ClientFactory, ITransientDe
Check.NotNullOrWhiteSpace(configuration.Name, nameof(configuration.Name));
Check.NotNullOrWhiteSpace(configuration.Policy, nameof(configuration.Policy));
var temporaryCredentialsCache = await Cache.GetAsync(configuration.TemporaryCredentialsCacheKey);
var temporaryCredentialsCache = await Cache.GetAsync(configuration.TemporaryCredentialsCacheKey!);
if (temporaryCredentialsCache == null)
{
@ -177,11 +177,11 @@ public class DefaultAmazonS3ClientFactory : IAmazonS3ClientFactory, ITransientDe
Credentials credentials)
{
var temporaryCredentialsCache = new AwsTemporaryCredentialsCacheItem(
StringEncryptionService.Encrypt(credentials.AccessKeyId),
StringEncryptionService.Encrypt(credentials.SecretAccessKey),
StringEncryptionService.Encrypt(credentials.SessionToken));
StringEncryptionService.Encrypt(credentials.AccessKeyId)!,
StringEncryptionService.Encrypt(credentials.SecretAccessKey)!,
StringEncryptionService.Encrypt(credentials.SessionToken)!);
await Cache.SetAsync(configuration.TemporaryCredentialsCacheKey, temporaryCredentialsCache,
await Cache.SetAsync(configuration.TemporaryCredentialsCacheKey!, temporaryCredentialsCache,
new DistributedCacheEntryOptions
{
AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(configuration.DurationSeconds - 10)

@ -5,6 +5,8 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net7.0</TargetFrameworks>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
<AssemblyName>Volo.Abp.BlobStoring.Azure</AssemblyName>
<PackageId>Volo.Abp.BlobStoring.Azure</PackageId>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>

@ -56,7 +56,7 @@ public class AzureBlobProvider : BlobProviderBase, ITransientDependency
return await BlobExistsAsync(args, blobName);
}
public override async Task<Stream> GetOrNullAsync(BlobProviderGetArgs args)
public override async Task<Stream?> GetOrNullAsync(BlobProviderGetArgs args)
{
var blobName = AzureBlobNameCalculator.Calculate(args);
@ -101,7 +101,7 @@ public class AzureBlobProvider : BlobProviderBase, ITransientDependency
var configuration = args.Configuration.GetAzureConfiguration();
return configuration.ContainerName.IsNullOrWhiteSpace()
? args.ContainerName
: BlobNormalizeNamingService.NormalizeContainerName(args.Configuration, configuration.ContainerName);
: BlobNormalizeNamingService.NormalizeContainerName(args.Configuration, configuration.ContainerName!);
}
protected virtual async Task<bool> ContainerExistsAsync(BlobContainerClient blobContainerClient)

@ -13,7 +13,7 @@ public class AzureBlobProviderConfiguration
/// The name must also be between 3 and 63 characters long.
/// If this parameter is not specified, the ContainerName of the <see cref="BlobProviderArgs"/> will be used.
/// </summary>
public string ContainerName {
public string? ContainerName {
get => _containerConfiguration.GetConfigurationOrDefault<string>(AzureBlobProviderConfigurationNames.ContainerName);
set => _containerConfiguration.SetConfiguration(AzureBlobProviderConfigurationNames.ContainerName, value);
}

@ -5,6 +5,8 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net7.0</TargetFrameworks>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
<AssemblyName>Volo.Abp.BlobStoring.FileSystem</AssemblyName>
<PackageId>Volo.Abp.BlobStoring.FileSystem</PackageId>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>

@ -25,7 +25,7 @@ public class FileSystemBlobProvider : BlobProviderBase, ITransientDependency
throw new BlobAlreadyExistsException($"Saving BLOB '{args.BlobName}' does already exists in the container '{args.ContainerName}'! Set {nameof(args.OverrideExisting)} if it should be overwritten.");
}
DirectoryHelper.CreateIfNotExists(Path.GetDirectoryName(filePath));
DirectoryHelper.CreateIfNotExists(Path.GetDirectoryName(filePath)!);
var fileMode = args.OverrideExisting
? FileMode.Create
@ -59,7 +59,7 @@ public class FileSystemBlobProvider : BlobProviderBase, ITransientDependency
return ExistsAsync(filePath);
}
public override async Task<Stream> GetOrNullAsync(BlobProviderGetArgs args)
public override async Task<Stream?> GetOrNullAsync(BlobProviderGetArgs args)
{
var filePath = FilePathCalculator.Calculate(args);

@ -4,6 +4,8 @@
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
<AssemblyName>Volo.Abp.BlobStoring.Minio</AssemblyName>
<PackageId>Volo.Abp.BlobStoring.Minio</PackageId>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>

@ -69,7 +69,7 @@ public class MinioBlobProvider : BlobProviderBase, ITransientDependency
return await BlobExistsAsync(client, containerName, blobName);
}
public override async Task<Stream> GetOrNullAsync(BlobProviderGetArgs args)
public override async Task<Stream?> GetOrNullAsync(BlobProviderGetArgs args)
{
var blobName = MinioBlobNameCalculator.Calculate(args);
var client = GetMinioClient(args);
@ -152,6 +152,6 @@ public class MinioBlobProvider : BlobProviderBase, ITransientDependency
return configuration.BucketName.IsNullOrWhiteSpace()
? args.ContainerName
: BlobNormalizeNamingService.NormalizeContainerName(args.Configuration, configuration.BucketName);
: BlobNormalizeNamingService.NormalizeContainerName(args.Configuration, configuration.BucketName!);
}
}

@ -2,7 +2,7 @@
public class MinioBlobProviderConfiguration
{
public string BucketName {
public string? BucketName {
get => _containerConfiguration.GetConfigurationOrDefault<string>(MinioBlobProviderConfigurationNames.BucketName);
set => _containerConfiguration.SetConfiguration(MinioBlobProviderConfigurationNames.BucketName, value);
}

@ -5,6 +5,8 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net7.0</TargetFrameworks>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
<AssemblyName>Volo.Abp.BlobStoring</AssemblyName>
<PackageId>Volo.Abp.BlobStoring</PackageId>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>

@ -61,7 +61,7 @@ public class BlobContainer<TContainer> : IBlobContainer<TContainer>
);
}
public Task<Stream> GetOrNullAsync(
public Task<Stream?> GetOrNullAsync(
string name,
CancellationToken cancellationToken = default)
{
@ -118,9 +118,9 @@ public class BlobContainer : IBlobContainer
await Provider.SaveAsync(
new BlobProviderSaveArgs(
blobNormalizeNaming.ContainerName,
blobNormalizeNaming.ContainerName!,
Configuration,
blobNormalizeNaming.BlobName,
blobNormalizeNaming.BlobName!,
stream,
overrideExisting,
CancellationTokenProvider.FallbackToProvider(cancellationToken)
@ -140,9 +140,9 @@ public class BlobContainer : IBlobContainer
return await Provider.DeleteAsync(
new BlobProviderDeleteArgs(
blobNormalizeNaming.ContainerName,
blobNormalizeNaming.ContainerName!,
Configuration,
blobNormalizeNaming.BlobName,
blobNormalizeNaming.BlobName!,
CancellationTokenProvider.FallbackToProvider(cancellationToken)
)
);
@ -160,9 +160,9 @@ public class BlobContainer : IBlobContainer
return await Provider.ExistsAsync(
new BlobProviderExistsArgs(
blobNormalizeNaming.ContainerName,
blobNormalizeNaming.ContainerName!,
Configuration,
blobNormalizeNaming.BlobName,
blobNormalizeNaming.BlobName!,
CancellationTokenProvider.FallbackToProvider(cancellationToken)
)
);
@ -185,7 +185,7 @@ public class BlobContainer : IBlobContainer
return stream;
}
public virtual async Task<Stream> GetOrNullAsync(
public virtual async Task<Stream?> GetOrNullAsync(
string name,
CancellationToken cancellationToken = default)
{
@ -196,9 +196,9 @@ public class BlobContainer : IBlobContainer
return await Provider.GetOrNullAsync(
new BlobProviderGetArgs(
blobNormalizeNaming.ContainerName,
blobNormalizeNaming.ContainerName!,
Configuration,
blobNormalizeNaming.BlobName,
blobNormalizeNaming.BlobName!,
CancellationTokenProvider.FallbackToProvider(cancellationToken)
)
);

@ -10,7 +10,7 @@ public class BlobContainerConfiguration
/// <summary>
/// The provider to be used to store BLOBs of this container.
/// </summary>
public Type ProviderType { get; set; }
public Type? ProviderType { get; set; }
/// <summary>
/// Indicates whether this container is multi-tenant or not.
@ -26,25 +26,23 @@ public class BlobContainerConfiguration
public ITypeList<IBlobNamingNormalizer> NamingNormalizers { get; }
[NotNull] private readonly Dictionary<string, object> _properties;
[NotNull] private readonly Dictionary<string, object?> _properties;
[CanBeNull] private readonly BlobContainerConfiguration _fallbackConfiguration;
private readonly BlobContainerConfiguration? _fallbackConfiguration;
public BlobContainerConfiguration(BlobContainerConfiguration fallbackConfiguration = null)
public BlobContainerConfiguration(BlobContainerConfiguration? fallbackConfiguration = null)
{
NamingNormalizers = new TypeList<IBlobNamingNormalizer>();
_fallbackConfiguration = fallbackConfiguration;
_properties = new Dictionary<string, object>();
_properties = new Dictionary<string, object?>();
}
[CanBeNull]
public T GetConfigurationOrDefault<T>(string name, T defaultValue = default)
public T? GetConfigurationOrDefault<T>(string name, T? defaultValue = default)
{
return (T)GetConfigurationOrNull(name, defaultValue);
return (T?)GetConfigurationOrNull(name, defaultValue);
}
[CanBeNull]
public object GetConfigurationOrNull(string name, object defaultValue = null)
public object? GetConfigurationOrNull(string name, object? defaultValue = null)
{
return _properties.GetOrDefault(name) ??
_fallbackConfiguration?.GetConfigurationOrNull(name, defaultValue) ??
@ -52,7 +50,7 @@ public class BlobContainerConfiguration
}
[NotNull]
public BlobContainerConfiguration SetConfiguration([NotNull] string name, [CanBeNull] object value)
public BlobContainerConfiguration SetConfiguration([NotNull] string name, object? value)
{
Check.NotNullOrWhiteSpace(name, nameof(name));
Check.NotNull(value, nameof(value));

@ -37,7 +37,7 @@ public static class BlobContainerExtensions
}
}
public static async Task<byte[]> GetAllBytesOrNullAsync(
public static async Task<byte[]?> GetAllBytesOrNullAsync(
this IBlobContainer container,
string name,
CancellationToken cancellationToken = default)

@ -32,7 +32,7 @@ public class BlobContainerNameAttribute : Attribute
if (nameAttribute == null)
{
return type.FullName;
return type.FullName!;
}
return nameAttribute.GetName(type);

@ -2,11 +2,11 @@
public class BlobNormalizeNaming
{
public string ContainerName { get; }
public string? ContainerName { get; }
public string BlobName { get; }
public string? BlobName { get; }
public BlobNormalizeNaming(string containerName, string blobName)
public BlobNormalizeNaming(string? containerName, string? blobName)
{
ContainerName = containerName;
BlobName = blobName;

@ -16,8 +16,8 @@ public class BlobNormalizeNamingService : IBlobNormalizeNamingService, ITransien
public BlobNormalizeNaming NormalizeNaming(
BlobContainerConfiguration configuration,
string containerName,
string blobName)
string? containerName,
string? blobName)
{
if (!configuration.NamingNormalizers.Any())
@ -33,8 +33,8 @@ public class BlobNormalizeNamingService : IBlobNormalizeNamingService, ITransien
.GetRequiredService(normalizerType)
.As<IBlobNamingNormalizer>();
containerName = containerName.IsNullOrWhiteSpace() ? containerName : normalizer.NormalizeContainerName(containerName);
blobName = blobName.IsNullOrWhiteSpace() ? blobName : normalizer.NormalizeBlobName(blobName);
containerName = containerName.IsNullOrWhiteSpace() ? containerName : normalizer.NormalizeContainerName(containerName!);
blobName = blobName.IsNullOrWhiteSpace() ? blobName : normalizer.NormalizeBlobName(blobName!);
}
return new BlobNormalizeNaming(containerName, blobName);
@ -48,7 +48,7 @@ public class BlobNormalizeNamingService : IBlobNormalizeNamingService, ITransien
return containerName;
}
return NormalizeNaming(configuration, containerName, null).ContainerName;
return NormalizeNaming(configuration, containerName, null).ContainerName!;
}
public string NormalizeBlobName(BlobContainerConfiguration configuration, string blobName)
@ -58,6 +58,6 @@ public class BlobNormalizeNamingService : IBlobNormalizeNamingService, ITransien
return blobName;
}
return NormalizeNaming(configuration, null, blobName).BlobName;
return NormalizeNaming(configuration, null, blobName).BlobName!;
}
}

@ -12,9 +12,9 @@ public abstract class BlobProviderBase : IBlobProvider
public abstract Task<bool> ExistsAsync(BlobProviderExistsArgs args);
public abstract Task<Stream> GetOrNullAsync(BlobProviderGetArgs args);
public abstract Task<Stream?> GetOrNullAsync(BlobProviderGetArgs args);
protected virtual async Task<Stream> TryCopyToMemoryStreamAsync(Stream stream, CancellationToken cancellationToken = default)
protected virtual async Task<Stream?> TryCopyToMemoryStreamAsync(Stream? stream, CancellationToken cancellationToken = default)
{
if (stream == null)
{

@ -78,7 +78,7 @@ public interface IBlobContainer
/// <returns>
/// A <see cref="Stream"/> to read the blob data.
/// </returns>
Task<Stream> GetOrNullAsync(
Task<Stream?> GetOrNullAsync(
string name,
CancellationToken cancellationToken = default
);

@ -11,5 +11,5 @@ public interface IBlobProvider
Task<bool> ExistsAsync(BlobProviderExistsArgs args);
Task<Stream> GetOrNullAsync(BlobProviderGetArgs args);
Task<Stream?> GetOrNullAsync(BlobProviderGetArgs args);
}

@ -62,7 +62,7 @@ public static class Check
[ContractAnnotation("value:null => halt")]
public static string NotNullOrWhiteSpace(
string value,
string? value,
[InvokerParameterName][NotNull] string parameterName,
int maxLength = int.MaxValue,
int minLength = 0)
@ -72,7 +72,7 @@ public static class Check
throw new ArgumentException($"{parameterName} can not be null, empty or white space!", parameterName);
}
if (value.Length > maxLength)
if (value!.Length > maxLength)
{
throw new ArgumentException($"{parameterName} length must be equal to or lower than {maxLength}!", parameterName);
}
@ -87,7 +87,7 @@ public static class Check
[ContractAnnotation("value:null => halt")]
public static string NotNullOrEmpty(
string value,
string? value,
[InvokerParameterName][NotNull] string parameterName,
int maxLength = int.MaxValue,
int minLength = 0)
@ -97,7 +97,7 @@ public static class Check
throw new ArgumentException($"{parameterName} can not be null or empty!", parameterName);
}
if (value.Length > maxLength)
if (value!.Length > maxLength)
{
throw new ArgumentException($"{parameterName} length must be equal to or lower than {maxLength}!", parameterName);
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save