Browse Source

Enable nullable annotations for Volo.Abp.Ddd.Domain

pull/17303/head
liangshiwei 3 years ago
parent
commit
ac97d57fe1
  1. 2
      framework/src/Volo.Abp.Auditing.Contracts/Volo/Abp/Auditing/IDeletionAuditedObject.cs
  2. 3
      framework/src/Volo.Abp.Auditing.Contracts/Volo/Abp/Auditing/IMayHaveCreator.cs
  3. 2
      framework/src/Volo.Abp.Auditing.Contracts/Volo/Abp/Auditing/IModificationAuditedObject.cs
  4. 2
      framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/LookupExtensionProperty.razor
  5. 2
      framework/src/Volo.Abp.Ddd.Domain/Volo.Abp.Ddd.Domain.csproj
  6. 10
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/DependencyInjection/AbpCommonDbContextRegistrationOptions.cs
  7. 2
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/DependencyInjection/IAbpCommonDbContextRegistrationOptionsBuilder.cs
  8. 2
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/DependencyInjection/MultiTenantDbContextType.cs
  9. 8
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/AuditedAggregateRootWithUser.cs
  10. 8
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/AuditedEntityWithUser.cs
  11. 4
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/CreationAuditedAggregateRootWithUser.cs
  12. 4
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/CreationAuditedEntityWithUser.cs
  13. 12
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/FullAuditedAggregateRootWithUser.cs
  14. 12
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/FullAuditedEntityWithUser.cs
  15. 12
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Caching/EntityCacheBase.cs
  16. 6
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Caching/EntityCacheServiceCollectionExtensions.cs
  17. 2
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Caching/EntityCacheWithObjectMapper.cs
  18. 2
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Caching/EntityCacheWithoutCacheItem.cs
  19. 3
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Caching/IEntityCache.cs
  20. 8
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Entity.cs
  21. 16
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/EntityHelper.cs
  22. 7
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Events/Distributed/EntitySynchronizer.cs
  23. 2
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Events/Distributed/EntityToEtoMapper.cs
  24. 2
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Events/EntityChangeEventHelper.cs
  25. 2
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Events/EntityEventData.cs
  26. 2
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/IEntity.cs
  27. 6
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/BasicRepositoryBase.cs
  28. 2
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/IReadOnlyBasicRepository.cs
  29. 2
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/IRepository.cs
  30. 12
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryAsyncExtensions.cs
  31. 8
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryBase.cs
  32. 8
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryExtensions.cs
  33. 4
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryRegistrarBase.cs
  34. 6
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Services/DomainService.cs
  35. 8
      framework/src/Volo.Abp.Threading/Volo/Abp/Linq/AsyncQueryableExecuter.cs
  36. 8
      framework/src/Volo.Abp.Threading/Volo/Abp/Linq/IAsyncQueryableExecuter.cs
  37. 8
      framework/src/Volo.Abp.Threading/Volo/Abp/Linq/IAsyncQueryableProvider.cs

2
framework/src/Volo.Abp.Auditing.Contracts/Volo/Abp/Auditing/IDeletionAuditedObject.cs

@ -22,5 +22,5 @@ public interface IDeletionAuditedObject<TUser> : IDeletionAuditedObject
/// <summary>
/// Reference to the deleter user.
/// </summary>
TUser Deleter { get; }
TUser? Deleter { get; }
}

3
framework/src/Volo.Abp.Auditing.Contracts/Volo/Abp/Auditing/IMayHaveCreator.cs

@ -8,8 +8,7 @@ public interface IMayHaveCreator<TCreator>
/// <summary>
/// Reference to the creator.
/// </summary>
[CanBeNull]
TCreator Creator { get; }
TCreator? Creator { get; }
}
/// <summary>

2
framework/src/Volo.Abp.Auditing.Contracts/Volo/Abp/Auditing/IModificationAuditedObject.cs

@ -22,5 +22,5 @@ public interface IModificationAuditedObject<TUser> : IModificationAuditedObject
/// <summary>
/// Reference to the last modifier user of this entity.
/// </summary>
TUser LastModifier { get; }
TUser? LastModifier { get; }
}

2
framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/LookupExtensionProperty.razor

@ -9,7 +9,7 @@
<Autocomplete Data="@lookupItems"
TItem="SelectItem<object>"
TValue="object"
TextField="item => item?.Text"
TextField="item => item?.Text!"
ValueField="item => item?.Value"
SelectedValue="@SelectedValue"
SelectedValueChanged="@SelectedValueChanged"

2
framework/src/Volo.Abp.Ddd.Domain/Volo.Abp.Ddd.Domain.csproj

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

10
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/DependencyInjection/AbpCommonDbContextRegistrationOptions.cs

@ -16,13 +16,13 @@ public abstract class AbpCommonDbContextRegistrationOptions : IAbpCommonDbContex
public IServiceCollection Services { get; }
public Dictionary<MultiTenantDbContextType, Type> ReplacedDbContextTypes { get; }
public Dictionary<MultiTenantDbContextType, Type?> ReplacedDbContextTypes { get; }
public Type DefaultRepositoryDbContextType { get; protected set; }
public Type DefaultRepositoryImplementationType { get; private set; }
public Type? DefaultRepositoryImplementationType { get; private set; }
public Type DefaultRepositoryImplementationTypeWithoutKey { get; private set; }
public Type? DefaultRepositoryImplementationTypeWithoutKey { get; private set; }
public bool RegisterDefaultRepositories { get; private set; }
@ -40,7 +40,7 @@ public abstract class AbpCommonDbContextRegistrationOptions : IAbpCommonDbContex
Services = services;
DefaultRepositoryDbContextType = originalDbContextType;
CustomRepositories = new Dictionary<Type, Type>();
ReplacedDbContextTypes = new Dictionary<MultiTenantDbContextType, Type>();
ReplacedDbContextTypes = new Dictionary<MultiTenantDbContextType, Type?>();
SpecifiedDefaultRepositories = new List<Type>();
}
@ -54,7 +54,7 @@ public abstract class AbpCommonDbContextRegistrationOptions : IAbpCommonDbContex
return ReplaceDbContext(typeof(TOtherDbContext), typeof(TTargetDbContext), multiTenancySides);
}
public IAbpCommonDbContextRegistrationOptionsBuilder ReplaceDbContext(Type otherDbContextType, Type targetDbContextType = null, MultiTenancySides multiTenancySides = MultiTenancySides.Both)
public IAbpCommonDbContextRegistrationOptionsBuilder ReplaceDbContext(Type otherDbContextType, Type? targetDbContextType = null, MultiTenancySides multiTenancySides = MultiTenancySides.Both)
{
if (!otherDbContextType.IsAssignableFrom(OriginalDbContextType))
{

2
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/DependencyInjection/IAbpCommonDbContextRegistrationOptionsBuilder.cs

@ -90,5 +90,5 @@ public interface IAbpCommonDbContextRegistrationOptionsBuilder
/// <param name="otherDbContextType">The DbContext type to be replaced</param>
/// <param name="targetDbContextType">The target DbContext type (optional, used this DbContext type if not provided)</param>
/// <param name="multiTenancySides">MultiTenancy side</param>
IAbpCommonDbContextRegistrationOptionsBuilder ReplaceDbContext(Type otherDbContextType, Type targetDbContextType = null, MultiTenancySides multiTenancySides = MultiTenancySides.Both);
IAbpCommonDbContextRegistrationOptionsBuilder ReplaceDbContext(Type otherDbContextType, Type? targetDbContextType = null, MultiTenancySides multiTenancySides = MultiTenancySides.Both);
}

2
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/DependencyInjection/MultiTenantDbContextType.cs

@ -15,7 +15,7 @@ public class MultiTenantDbContextType
MultiTenancySide = multiTenancySide;
}
public override bool Equals(object obj)
public override bool Equals(object? obj)
{
var other = obj as MultiTenantDbContextType;

8
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/AuditedAggregateRootWithUser.cs

@ -12,10 +12,10 @@ public abstract class AuditedAggregateRootWithUser<TUser> : AuditedAggregateRoot
where TUser : IEntity<Guid>
{
/// <inheritdoc />
public virtual TUser Creator { get; protected set; }
public virtual TUser? Creator { get; protected set; }
/// <inheritdoc />
public virtual TUser LastModifier { get; set; }
public virtual TUser? LastModifier { get; set; }
}
/// <summary>
@ -28,10 +28,10 @@ public abstract class AuditedAggregateRootWithUser<TKey, TUser> : AuditedAggrega
where TUser : IEntity<Guid>
{
/// <inheritdoc />
public virtual TUser Creator { get; protected set; }
public virtual TUser? Creator { get; protected set; }
/// <inheritdoc />
public virtual TUser LastModifier { get; set; }
public virtual TUser? LastModifier { get; set; }
protected AuditedAggregateRootWithUser()
{

8
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/AuditedEntityWithUser.cs

@ -12,10 +12,10 @@ public abstract class AuditedEntityWithUser<TUser> : AuditedEntity, IAuditedObje
where TUser : IEntity<Guid>
{
/// <inheritdoc />
public virtual TUser Creator { get; protected set; }
public virtual TUser? Creator { get; protected set; }
/// <inheritdoc />
public virtual TUser LastModifier { get; set; }
public virtual TUser? LastModifier { get; set; }
}
/// <summary>
@ -28,10 +28,10 @@ public abstract class AuditedEntityWithUser<TKey, TUser> : AuditedEntity<TKey>,
where TUser : IEntity<Guid>
{
/// <inheritdoc />
public virtual TUser Creator { get; protected set; }
public virtual TUser? Creator { get; protected set; }
/// <inheritdoc />
public virtual TUser LastModifier { get; set; }
public virtual TUser? LastModifier { get; set; }
protected AuditedEntityWithUser()
{

4
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/CreationAuditedAggregateRootWithUser.cs

@ -11,7 +11,7 @@ namespace Volo.Abp.Domain.Entities.Auditing;
public abstract class CreationAuditedAggregateRootWithUser<TUser> : CreationAuditedAggregateRoot, ICreationAuditedObject<TUser>
{
/// <inheritdoc />
public virtual TUser Creator { get; protected set; }
public virtual TUser? Creator { get; protected set; }
}
/// <summary>
@ -23,7 +23,7 @@ public abstract class CreationAuditedAggregateRootWithUser<TUser> : CreationAudi
public abstract class CreationAuditedAggregateRootWithUser<TKey, TUser> : CreationAuditedAggregateRoot<TKey>, ICreationAuditedObject<TUser>
{
/// <inheritdoc />
public virtual TUser Creator { get; protected set; }
public virtual TUser? Creator { get; protected set; }
protected CreationAuditedAggregateRootWithUser()
{

4
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/CreationAuditedEntityWithUser.cs

@ -11,7 +11,7 @@ namespace Volo.Abp.Domain.Entities.Auditing;
public abstract class CreationAuditedEntityWithUser<TUser> : CreationAuditedEntity, ICreationAuditedObject<TUser>
{
/// <inheritdoc />
public virtual TUser Creator { get; protected set; }
public virtual TUser? Creator { get; protected set; }
}
/// <summary>
@ -23,7 +23,7 @@ public abstract class CreationAuditedEntityWithUser<TUser> : CreationAuditedEnti
public abstract class CreationAuditedEntityWithUser<TKey, TUser> : CreationAuditedEntity<TKey>, ICreationAuditedObject<TUser>
{
/// <inheritdoc />
public virtual TUser Creator { get; protected set; }
public virtual TUser? Creator { get; protected set; }
protected CreationAuditedEntityWithUser()
{

12
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/FullAuditedAggregateRootWithUser.cs

@ -12,13 +12,13 @@ public abstract class FullAuditedAggregateRootWithUser<TUser> : FullAuditedAggre
where TUser : IEntity<Guid>
{
/// <inheritdoc />
public virtual TUser Deleter { get; set; }
public virtual TUser? Deleter { get; set; }
/// <inheritdoc />
public virtual TUser Creator { get; protected set; }
public virtual TUser? Creator { get; protected set; }
/// <inheritdoc />
public virtual TUser LastModifier { get; set; }
public virtual TUser? LastModifier { get; set; }
}
/// <summary>
@ -31,13 +31,13 @@ public abstract class FullAuditedAggregateRootWithUser<TKey, TUser> : FullAudite
where TUser : IEntity<Guid>
{
/// <inheritdoc />
public virtual TUser Deleter { get; set; }
public virtual TUser? Deleter { get; set; }
/// <inheritdoc />
public virtual TUser Creator { get; protected set; }
public virtual TUser? Creator { get; protected set; }
/// <inheritdoc />
public virtual TUser LastModifier { get; set; }
public virtual TUser? LastModifier { get; set; }
protected FullAuditedAggregateRootWithUser()
{

12
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/FullAuditedEntityWithUser.cs

@ -12,13 +12,13 @@ public abstract class FullAuditedEntityWithUser<TUser> : FullAuditedEntity, IFul
where TUser : IEntity<Guid>
{
/// <inheritdoc />
public virtual TUser Deleter { get; set; }
public virtual TUser? Deleter { get; set; }
/// <inheritdoc />
public virtual TUser Creator { get; protected set; }
public virtual TUser? Creator { get; protected set; }
/// <inheritdoc />
public virtual TUser LastModifier { get; set; }
public virtual TUser? LastModifier { get; set; }
}
/// <summary>
@ -31,13 +31,13 @@ public abstract class FullAuditedEntityWithUser<TKey, TUser> : FullAuditedEntity
where TUser : IEntity<Guid>
{
/// <inheritdoc />
public virtual TUser Deleter { get; set; }
public virtual TUser? Deleter { get; set; }
/// <inheritdoc />
public virtual TUser Creator { get; protected set; }
public virtual TUser? Creator { get; protected set; }
/// <inheritdoc />
public virtual TUser LastModifier { get; set; }
public virtual TUser? LastModifier { get; set; }
protected FullAuditedEntityWithUser()
{

12
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Caching/EntityCacheBase.cs

@ -27,23 +27,23 @@ public abstract class EntityCacheBase<TEntity, TEntityCacheItem, TKey> :
UnitOfWorkManager = unitOfWorkManager;
}
public virtual async Task<TEntityCacheItem> FindAsync(TKey id)
public virtual async Task<TEntityCacheItem?> FindAsync(TKey id)
{
return await Cache.GetOrAddAsync(
id,
async () => MapToCacheItem(await Repository.FindAsync(id))
async () => MapToCacheItem(await Repository.FindAsync(id))!
);
}
public virtual async Task<TEntityCacheItem> GetAsync(TKey id)
{
return await Cache.GetOrAddAsync(
return (await Cache.GetOrAddAsync(
id,
async () => MapToCacheItem(await Repository.GetAsync(id))
);
async () => MapToCacheItem(await Repository.GetAsync(id))!
))!;
}
protected abstract TEntityCacheItem MapToCacheItem(TEntity entity);
protected abstract TEntityCacheItem? MapToCacheItem(TEntity? entity);
public async Task HandleEventAsync(EntityChangedEventData<TEntity> eventData)
{

6
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Caching/EntityCacheServiceCollectionExtensions.cs

@ -13,7 +13,7 @@ public static class EntityCacheServiceCollectionExtensions
{
public static IServiceCollection AddEntityCache<TEntity, TKey>(
this IServiceCollection services,
[CanBeNull] DistributedCacheEntryOptions cacheOptions = null)
DistributedCacheEntryOptions? cacheOptions = null)
where TEntity : Entity<TKey>
{
services
@ -39,7 +39,7 @@ public static class EntityCacheServiceCollectionExtensions
public static IServiceCollection AddEntityCache<TEntity, TEntityCacheItem, TKey>(
this IServiceCollection services,
[CanBeNull] DistributedCacheEntryOptions cacheOptions = null)
DistributedCacheEntryOptions? cacheOptions = null)
where TEntity : Entity<TKey>
where TEntityCacheItem : class
{
@ -61,7 +61,7 @@ public static class EntityCacheServiceCollectionExtensions
public static IServiceCollection AddEntityCache<TObjectMapperContext, TEntity, TEntityCacheItem, TKey>(
this IServiceCollection services,
[CanBeNull] DistributedCacheEntryOptions cacheOptions = null)
DistributedCacheEntryOptions? cacheOptions = null)
where TEntity : Entity<TKey>
where TEntityCacheItem : class
{

2
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Caching/EntityCacheWithObjectMapper.cs

@ -23,7 +23,7 @@ public class EntityCacheWithObjectMapper<TEntity, TEntityCacheItem, TKey> :
ObjectMapper = objectMapper;
}
protected override TEntityCacheItem MapToCacheItem(TEntity entity)
protected override TEntityCacheItem? MapToCacheItem(TEntity? entity)
{
if (entity == null)
{

2
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Caching/EntityCacheWithoutCacheItem.cs

@ -16,7 +16,7 @@ public class EntityCacheWithoutCacheItem<TEntity, TKey> :
{
}
protected override TEntity MapToCacheItem(TEntity entity)
protected override TEntity? MapToCacheItem(TEntity? entity)
{
return entity;
}

3
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Caching/IEntityCache.cs

@ -10,8 +10,7 @@ public interface IEntityCache<TEntityCacheItem, in TKey>
/// Gets the entity with given <paramref name="id"/>,
/// or returns null if the entity was not found.
/// </summary>
[ItemCanBeNull]
Task<TEntityCacheItem> FindAsync(TKey id);
Task<TEntityCacheItem?> FindAsync(TKey id);
/// <summary>
/// Gets the entity with given <paramref name="id"/>,

8
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Entity.cs

@ -18,7 +18,7 @@ public abstract class Entity : IEntity
return $"[ENTITY: {GetType().Name}] Keys = {GetKeys().JoinAsString(", ")}";
}
public abstract object[] GetKeys();
public abstract object?[] GetKeys();
public bool EntityEquals(IEntity other)
{
@ -31,7 +31,7 @@ public abstract class Entity : IEntity
public abstract class Entity<TKey> : Entity, IEntity<TKey>
{
/// <inheritdoc/>
public virtual TKey Id { get; protected set; }
public virtual TKey Id { get; protected set; } = default!;
protected Entity()
{
@ -43,9 +43,9 @@ public abstract class Entity<TKey> : Entity, IEntity<TKey>
Id = id;
}
public override object[] GetKeys()
public override object?[] GetKeys()
{
return new object[] { Id };
return new object?[] { Id };
}
/// <inheritdoc/>

16
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/EntityHelper.cs

@ -25,7 +25,7 @@ public static class EntityHelper
return typeof(IMultiTenant).IsAssignableFrom(type);
}
public static bool EntityEquals(IEntity entity1, IEntity entity2)
public static bool EntityEquals(IEntity? entity1, IEntity? entity2)
{
if (entity1 == null || entity2 == null)
{
@ -131,7 +131,7 @@ public static class EntityHelper
return IsValueObjectPredicate(type);
}
public static bool IsValueObject(object obj)
public static bool IsValueObject(object? obj)
{
return obj != null && IsValueObject(obj.GetType());
}
@ -161,7 +161,7 @@ public static class EntityHelper
public static bool HasDefaultId<TKey>(IEntity<TKey> entity)
{
if (EqualityComparer<TKey>.Default.Equals(entity.Id, default))
if (EqualityComparer<TKey>.Default.Equals(entity.Id, default!))
{
return true;
}
@ -180,7 +180,7 @@ public static class EntityHelper
return false;
}
private static bool IsDefaultKeyValue(object value)
private static bool IsDefaultKeyValue(object? value)
{
if (value == null)
{
@ -222,8 +222,7 @@ public static class EntityHelper
/// Tries to find the primary key type of the given entity type.
/// May return null if given type does not implement <see cref="IEntity{TKey}"/>
/// </summary>
[CanBeNull]
public static Type FindPrimaryKeyType<TEntity>()
public static Type? FindPrimaryKeyType<TEntity>()
where TEntity : IEntity
{
return FindPrimaryKeyType(typeof(TEntity));
@ -233,8 +232,7 @@ public static class EntityHelper
/// Tries to find the primary key type of the given entity type.
/// May return null if given type does not implement <see cref="IEntity{TKey}"/>
/// </summary>
[CanBeNull]
public static Type FindPrimaryKeyType([NotNull] Type entityType)
public static Type? FindPrimaryKeyType([NotNull] Type entityType)
{
if (!typeof(IEntity).IsAssignableFrom(entityType))
{
@ -260,7 +258,7 @@ public static class EntityHelper
var lambdaParam = Expression.Parameter(typeof(TEntity));
var leftExpression = Expression.PropertyOrField(lambdaParam, "Id");
var idValue = Convert.ChangeType(id, typeof(TKey));
Expression<Func<object>> closure = () => idValue;
Expression<Func<object?>> closure = () => idValue;
var rightExpression = Expression.Convert(closure.Body, leftExpression.Type);
var lambdaBody = Expression.Equal(leftExpression, rightExpression);
return Expression.Lambda<Func<TEntity, bool>>(lambdaBody, lambdaParam);

7
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Events/Distributed/EntitySynchronizer.cs

@ -22,7 +22,7 @@ public abstract class EntitySynchronizer<TEntity, TKey, TSourceEntityEto> :
Repository = repository;
}
protected override Task<TEntity> FindLocalEntityAsync(TSourceEntityEto eto)
protected override Task<TEntity?> FindLocalEntityAsync(TSourceEntityEto eto)
{
return Repository.FindAsync(eto.Id);
}
@ -154,10 +154,9 @@ public abstract class EntitySynchronizer<TEntity, TSourceEntityEto> :
return true;
}
[ItemCanBeNull]
protected abstract Task<TEntity> FindLocalEntityAsync(TSourceEntityEto eto);
protected abstract Task<TEntity?> FindLocalEntityAsync(TSourceEntityEto eto);
protected virtual Task<bool> IsEtoNewerAsync(TSourceEntityEto eto, [CanBeNull] TEntity localEntity)
protected virtual Task<bool> IsEtoNewerAsync(TSourceEntityEto eto, TEntity? localEntity)
{
if (localEntity is IHasEntityVersion versionedLocalEntity && eto is IHasEntityVersion versionedEto)
{

2
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Events/Distributed/EntityToEtoMapper.cs

@ -21,7 +21,7 @@ public class EntityToEtoMapper : IEntityToEtoMapper, ITransientDependency
Options = options.Value;
}
public object Map(object entityObj)
public object? Map(object entityObj)
{
Check.NotNull(entityObj, nameof(entityObj));

2
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Events/EntityChangeEventHelper.cs

@ -133,7 +133,7 @@ public class EntityChangeEventHelper : IEntityChangeEventHelper, ITransientDepen
{
var entityType = ProxyHelper.UnProxy(entityOrEto).GetType();
var eventType = genericEventType.MakeGenericType(entityType);
var eventData = Activator.CreateInstance(eventType, entityOrEto);
var eventData = Activator.CreateInstance(eventType, entityOrEto)!;
var currentUow = UnitOfWorkManager.Current;
if (currentUow == null)

2
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Events/EntityEventData.cs

@ -27,7 +27,7 @@ public class EntityEventData<TEntity> : IEventDataWithInheritableGenericArgument
public virtual object[] GetConstructorArgs()
{
return new object[] { Entity };
return new object[] { Entity! };
}
public virtual bool IsMultiTenant(out Guid? tenantId)

2
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/IEntity.cs

@ -10,7 +10,7 @@ public interface IEntity
/// Returns an array of ordered keys for this entity.
/// </summary>
/// <returns></returns>
object[] GetKeys();
object?[] GetKeys();
}
/// <summary>

6
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/BasicRepositoryBase.cs

@ -20,9 +20,9 @@ public abstract class BasicRepositoryBase<TEntity> :
IUnitOfWorkEnabled
where TEntity : class, IEntity
{
public IAbpLazyServiceProvider LazyServiceProvider { get; set; }
public IAbpLazyServiceProvider LazyServiceProvider { get; set; } = default!;
public IServiceProvider ServiceProvider { get; set; }
public IServiceProvider ServiceProvider { get; set; } = default!;
public IDataFilter DataFilter => LazyServiceProvider.LazyGetRequiredService<IDataFilter>();
@ -123,7 +123,7 @@ public abstract class BasicRepositoryBase<TEntity, TKey> : BasicRepositoryBase<T
return entity;
}
public abstract Task<TEntity> FindAsync(TKey id, bool includeDetails = true, CancellationToken cancellationToken = default);
public abstract Task<TEntity?> FindAsync(TKey id, bool includeDetails = true, CancellationToken cancellationToken = default);
public virtual async Task DeleteAsync(TKey id, bool autoSave = false, CancellationToken cancellationToken = default)
{

2
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/IReadOnlyBasicRepository.cs

@ -51,5 +51,5 @@ public interface IReadOnlyBasicRepository<TEntity, TKey> : IReadOnlyBasicReposit
/// <param name="includeDetails">Set true to include all children of this entity</param>
/// <param name="cancellationToken">A <see cref="T:System.Threading.CancellationToken" /> to observe while waiting for the task to complete.</param>
/// <returns>Entity or null</returns>
Task<TEntity> FindAsync(TKey id, bool includeDetails = true, CancellationToken cancellationToken = default);
Task<TEntity?> FindAsync(TKey id, bool includeDetails = true, CancellationToken cancellationToken = default);
}

2
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/IRepository.cs

@ -28,7 +28,7 @@ public interface IRepository<TEntity> : IReadOnlyRepository<TEntity>, IBasicRepo
/// <param name="predicate">A condition to find the entity</param>
/// <param name="includeDetails">Set true to include all children of this entity</param>
/// <param name="cancellationToken">A <see cref="T:System.Threading.CancellationToken" /> to observe while waiting for the task to complete.</param>
Task<TEntity> FindAsync(
Task<TEntity?> FindAsync(
[NotNull] Expression<Func<TEntity, bool>> predicate,
bool includeDetails = true,
CancellationToken cancellationToken = default

12
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryAsyncExtensions.cs

@ -120,7 +120,7 @@ public static class RepositoryAsyncExtensions
return await repository.AsyncExecuter.FirstAsync(queryable, predicate, cancellationToken);
}
public static async Task<T> FirstOrDefaultAsync<T>(
public static async Task<T?> FirstOrDefaultAsync<T>(
[NotNull] this IReadOnlyRepository<T> repository,
CancellationToken cancellationToken = default)
where T : class, IEntity
@ -129,7 +129,7 @@ public static class RepositoryAsyncExtensions
return await repository.AsyncExecuter.FirstOrDefaultAsync(queryable, cancellationToken);
}
public static async Task<T> FirstOrDefaultAsync<T>(
public static async Task<T?> FirstOrDefaultAsync<T>(
[NotNull] this IReadOnlyRepository<T> repository,
[NotNull] Expression<Func<T, bool>> predicate,
CancellationToken cancellationToken = default)
@ -162,7 +162,7 @@ public static class RepositoryAsyncExtensions
return await repository.AsyncExecuter.LastAsync(queryable, predicate, cancellationToken);
}
public static async Task<T> LastOrDefaultAsync<T>(
public static async Task<T?> LastOrDefaultAsync<T>(
[NotNull] this IReadOnlyRepository<T> repository,
CancellationToken cancellationToken = default)
where T : class, IEntity
@ -171,7 +171,7 @@ public static class RepositoryAsyncExtensions
return await repository.AsyncExecuter.LastOrDefaultAsync(queryable, cancellationToken);
}
public static async Task<T> LastOrDefaultAsync<T>(
public static async Task<T?> LastOrDefaultAsync<T>(
[NotNull] this IReadOnlyRepository<T> repository,
[NotNull] Expression<Func<T, bool>> predicate,
CancellationToken cancellationToken = default)
@ -204,7 +204,7 @@ public static class RepositoryAsyncExtensions
return await repository.AsyncExecuter.SingleAsync(queryable, predicate, cancellationToken);
}
public static async Task<T> SingleOrDefaultAsync<T>(
public static async Task<T?> SingleOrDefaultAsync<T>(
[NotNull] this IReadOnlyRepository<T> repository,
CancellationToken cancellationToken = default)
where T : class, IEntity
@ -213,7 +213,7 @@ public static class RepositoryAsyncExtensions
return await repository.AsyncExecuter.SingleOrDefaultAsync(queryable, cancellationToken);
}
public static async Task<T> SingleOrDefaultAsync<T>(
public static async Task<T?> SingleOrDefaultAsync<T>(
[NotNull] this IReadOnlyRepository<T> repository,
[NotNull] Expression<Func<T, bool>> predicate,
CancellationToken cancellationToken = default)

8
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryBase.cs

@ -41,7 +41,7 @@ public abstract class RepositoryBase<TEntity> : BasicRepositoryBase<TEntity>, IR
public abstract Task<IQueryable<TEntity>> GetQueryableAsync();
public abstract Task<TEntity> FindAsync(
public abstract Task<TEntity?> FindAsync(
Expression<Func<TEntity, bool>> predicate,
bool includeDetails = true,
CancellationToken cancellationToken = default);
@ -76,13 +76,13 @@ public abstract class RepositoryBase<TEntity> : BasicRepositoryBase<TEntity>, IR
{
if (typeof(ISoftDelete).IsAssignableFrom(typeof(TOtherEntity)))
{
query = (TQueryable)query.WhereIf(DataFilter.IsEnabled<ISoftDelete>(), e => ((ISoftDelete)e).IsDeleted == false);
query = (TQueryable)query.WhereIf(DataFilter.IsEnabled<ISoftDelete>(), e => ((ISoftDelete)e!).IsDeleted == false);
}
if (typeof(IMultiTenant).IsAssignableFrom(typeof(TOtherEntity)))
{
var tenantId = CurrentTenant.Id;
query = (TQueryable)query.WhereIf(DataFilter.IsEnabled<IMultiTenant>(), e => ((IMultiTenant)e).TenantId == tenantId);
query = (TQueryable)query.WhereIf(DataFilter.IsEnabled<IMultiTenant>(), e => ((IMultiTenant)e!).TenantId == tenantId);
}
return query;
@ -94,7 +94,7 @@ public abstract class RepositoryBase<TEntity, TKey> : RepositoryBase<TEntity>, I
{
public abstract Task<TEntity> GetAsync(TKey id, bool includeDetails = true, CancellationToken cancellationToken = default);
public abstract Task<TEntity> FindAsync(TKey id, bool includeDetails = true, CancellationToken cancellationToken = default);
public abstract Task<TEntity?> FindAsync(TKey id, bool includeDetails = true, CancellationToken cancellationToken = default);
public virtual async Task DeleteAsync(TKey id, bool autoSave = false, CancellationToken cancellationToken = default)
{

8
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryExtensions.cs

@ -54,7 +54,7 @@ public static class RepositoryExtensions
)
where TEntity : class, IEntity<TKey>
{
if (!await repository.AnyAsync(x => x.Id.Equals(id), cancellationToken))
if (!await repository.AnyAsync(x => x.Id!.Equals(id), cancellationToken))
{
throw new EntityNotFoundException(typeof(TEntity), id);
}
@ -87,7 +87,7 @@ public static class RepositoryExtensions
{
using (var uow = uowManager.Begin())
{
await HardDeleteWithUnitOfWorkAsync(repository, predicate, autoSave, cancellationToken, uowManager.Current);
await HardDeleteWithUnitOfWorkAsync(repository, predicate, autoSave, cancellationToken, uowManager.Current!);
await uow.CompleteAsync(cancellationToken);
}
}
@ -111,7 +111,7 @@ public static class RepositoryExtensions
{
using (var uow = uowManager.Begin())
{
await HardDeleteWithUnitOfWorkAsync(repository, entities, autoSave, cancellationToken, uowManager.Current);
await HardDeleteWithUnitOfWorkAsync(repository, entities, autoSave, cancellationToken, uowManager.Current!);
await uow.CompleteAsync(cancellationToken);
}
}
@ -135,7 +135,7 @@ public static class RepositoryExtensions
{
using (var uow = uowManager.Begin())
{
await HardDeleteWithUnitOfWorkAsync(repository, entity, autoSave, cancellationToken, uowManager.Current);
await HardDeleteWithUnitOfWorkAsync(repository, entity, autoSave, cancellationToken, uowManager.Current!);
await uow.CompleteAsync(cancellationToken);
}
}

4
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryRegistrarBase.cs

@ -75,12 +75,12 @@ public abstract class RepositoryRegistrarBase<TOptions>
if (primaryKeyType == null)
{
return Options.SpecifiedDefaultRepositoryTypes
? Options.DefaultRepositoryImplementationTypeWithoutKey.MakeGenericType(entityType)
? Options.DefaultRepositoryImplementationTypeWithoutKey!.MakeGenericType(entityType)
: GetRepositoryType(Options.DefaultRepositoryDbContextType, entityType);
}
return Options.SpecifiedDefaultRepositoryTypes
? Options.DefaultRepositoryImplementationType.MakeGenericType(entityType, primaryKeyType)
? Options.DefaultRepositoryImplementationType!.MakeGenericType(entityType, primaryKeyType)
: GetRepositoryType(Options.DefaultRepositoryDbContextType, entityType, primaryKeyType);
}

6
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Services/DomainService.cs

@ -11,10 +11,10 @@ namespace Volo.Abp.Domain.Services;
public abstract class DomainService : IDomainService
{
public IAbpLazyServiceProvider LazyServiceProvider { get; set; }
public IAbpLazyServiceProvider LazyServiceProvider { get; set; } = default!;
[Obsolete("Use LazyServiceProvider instead.")]
public IServiceProvider ServiceProvider { get; set; }
public IServiceProvider ServiceProvider { get; set; } = default!;
protected IClock Clock => LazyServiceProvider.LazyGetRequiredService<IClock>();
@ -26,5 +26,5 @@ public abstract class DomainService : IDomainService
protected IAsyncQueryableExecuter AsyncExecuter => LazyServiceProvider.LazyGetRequiredService<IAsyncQueryableExecuter>();
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);
}

8
framework/src/Volo.Abp.Threading/Volo/Abp/Linq/AsyncQueryableExecuter.cs

@ -209,7 +209,7 @@ public class AsyncQueryableExecuter : IAsyncQueryableExecuter, ISingletonDepende
return Task.FromResult(queryable.SingleOrDefault(predicate))!;
}
public Task<T?> MinAsync<T>(IQueryable<T> queryable, CancellationToken cancellationToken = default)
public Task<T> MinAsync<T>(IQueryable<T> queryable, CancellationToken cancellationToken = default)
{
var provider = FindProvider(queryable);
@ -221,7 +221,7 @@ public class AsyncQueryableExecuter : IAsyncQueryableExecuter, ISingletonDepende
return Task.FromResult(queryable.Min())!;
}
public Task<TResult?> MinAsync<T, TResult>(IQueryable<T> queryable, Expression<Func<T, TResult>> selector, CancellationToken cancellationToken = default)
public Task<TResult> MinAsync<T, TResult>(IQueryable<T> queryable, Expression<Func<T, TResult>> selector, CancellationToken cancellationToken = default)
{
var provider = FindProvider(queryable);
@ -233,7 +233,7 @@ public class AsyncQueryableExecuter : IAsyncQueryableExecuter, ISingletonDepende
return Task.FromResult(queryable.Min(selector))!;
}
public Task<T?> MaxAsync<T>(IQueryable<T> queryable, CancellationToken cancellationToken = default)
public Task<T> MaxAsync<T>(IQueryable<T> queryable, CancellationToken cancellationToken = default)
{
var provider = FindProvider(queryable);
@ -245,7 +245,7 @@ public class AsyncQueryableExecuter : IAsyncQueryableExecuter, ISingletonDepende
return Task.FromResult(queryable.Max())!;
}
public Task<TResult?> MaxAsync<T, TResult>(IQueryable<T> queryable, Expression<Func<T, TResult>> selector, CancellationToken cancellationToken = default)
public Task<TResult> MaxAsync<T, TResult>(IQueryable<T> queryable, Expression<Func<T, TResult>> selector, CancellationToken cancellationToken = default)
{
var provider = FindProvider(queryable);

8
framework/src/Volo.Abp.Threading/Volo/Abp/Linq/IAsyncQueryableExecuter.cs

@ -137,12 +137,12 @@ public interface IAsyncQueryableExecuter
#region Min
Task<T?> MinAsync<T>(
Task<T> MinAsync<T>(
[NotNull] IQueryable<T> queryable,
CancellationToken cancellationToken = default);
Task<TResult?> MinAsync<T, TResult>(
Task<TResult> MinAsync<T, TResult>(
[NotNull] IQueryable<T> queryable,
[NotNull] Expression<Func<T, TResult>> selector,
CancellationToken cancellationToken = default);
@ -151,12 +151,12 @@ public interface IAsyncQueryableExecuter
#region Max
Task<T?> MaxAsync<T>(
Task<T> MaxAsync<T>(
[NotNull] IQueryable<T> queryable,
CancellationToken cancellationToken = default);
Task<TResult?> MaxAsync<T, TResult>(
Task<TResult> MaxAsync<T, TResult>(
[NotNull] IQueryable<T> queryable,
[NotNull] Expression<Func<T, TResult>> selector,
CancellationToken cancellationToken = default);

8
framework/src/Volo.Abp.Threading/Volo/Abp/Linq/IAsyncQueryableProvider.cs

@ -139,12 +139,12 @@ public interface IAsyncQueryableProvider
#region Min
Task<T?> MinAsync<T>(
Task<T> MinAsync<T>(
[NotNull] IQueryable<T> queryable,
CancellationToken cancellationToken = default);
Task<TResult?> MinAsync<T, TResult>(
Task<TResult> MinAsync<T, TResult>(
[NotNull] IQueryable<T> queryable,
[NotNull] Expression<Func<T, TResult>> selector,
CancellationToken cancellationToken = default);
@ -153,12 +153,12 @@ public interface IAsyncQueryableProvider
#region Max
Task<T?> MaxAsync<T>(
Task<T> MaxAsync<T>(
[NotNull] IQueryable<T> queryable,
CancellationToken cancellationToken = default);
Task<TResult?> MaxAsync<T, TResult>(
Task<TResult> MaxAsync<T, TResult>(
[NotNull] IQueryable<T> queryable,
[NotNull] Expression<Func<T, TResult>> selector,
CancellationToken cancellationToken = default);

Loading…
Cancel
Save