diff --git a/framework/src/Volo.Abp.Auditing.Contracts/Volo/Abp/Auditing/IDeletionAuditedObject.cs b/framework/src/Volo.Abp.Auditing.Contracts/Volo/Abp/Auditing/IDeletionAuditedObject.cs index a7be0c29a1..afec5e4e5f 100644 --- a/framework/src/Volo.Abp.Auditing.Contracts/Volo/Abp/Auditing/IDeletionAuditedObject.cs +++ b/framework/src/Volo.Abp.Auditing.Contracts/Volo/Abp/Auditing/IDeletionAuditedObject.cs @@ -22,5 +22,5 @@ public interface IDeletionAuditedObject : IDeletionAuditedObject /// /// Reference to the deleter user. /// - TUser Deleter { get; } + TUser? Deleter { get; } } diff --git a/framework/src/Volo.Abp.Auditing.Contracts/Volo/Abp/Auditing/IMayHaveCreator.cs b/framework/src/Volo.Abp.Auditing.Contracts/Volo/Abp/Auditing/IMayHaveCreator.cs index 25748f5af9..78989e16d2 100644 --- a/framework/src/Volo.Abp.Auditing.Contracts/Volo/Abp/Auditing/IMayHaveCreator.cs +++ b/framework/src/Volo.Abp.Auditing.Contracts/Volo/Abp/Auditing/IMayHaveCreator.cs @@ -8,8 +8,7 @@ public interface IMayHaveCreator /// /// Reference to the creator. /// - [CanBeNull] - TCreator Creator { get; } + TCreator? Creator { get; } } /// diff --git a/framework/src/Volo.Abp.Auditing.Contracts/Volo/Abp/Auditing/IModificationAuditedObject.cs b/framework/src/Volo.Abp.Auditing.Contracts/Volo/Abp/Auditing/IModificationAuditedObject.cs index 48f26b6299..a82e1452e8 100644 --- a/framework/src/Volo.Abp.Auditing.Contracts/Volo/Abp/Auditing/IModificationAuditedObject.cs +++ b/framework/src/Volo.Abp.Auditing.Contracts/Volo/Abp/Auditing/IModificationAuditedObject.cs @@ -22,5 +22,5 @@ public interface IModificationAuditedObject : IModificationAuditedObject /// /// Reference to the last modifier user of this entity. /// - TUser LastModifier { get; } + TUser? LastModifier { get; } } diff --git a/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/LookupExtensionProperty.razor b/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/LookupExtensionProperty.razor index 7c32549d51..ecdae979f2 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/LookupExtensionProperty.razor +++ b/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/LookupExtensionProperty.razor @@ -9,7 +9,7 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable Volo.Abp.Ddd.Domain Volo.Abp.Ddd.Domain $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/DependencyInjection/AbpCommonDbContextRegistrationOptions.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/DependencyInjection/AbpCommonDbContextRegistrationOptions.cs index bc50368645..8342451056 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/DependencyInjection/AbpCommonDbContextRegistrationOptions.cs +++ b/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 ReplacedDbContextTypes { get; } + public Dictionary 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(); - ReplacedDbContextTypes = new Dictionary(); + ReplacedDbContextTypes = new Dictionary(); SpecifiedDefaultRepositories = new List(); } @@ -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)) { diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/DependencyInjection/IAbpCommonDbContextRegistrationOptionsBuilder.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/DependencyInjection/IAbpCommonDbContextRegistrationOptionsBuilder.cs index 58a82bf77d..ee580332a8 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/DependencyInjection/IAbpCommonDbContextRegistrationOptionsBuilder.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/DependencyInjection/IAbpCommonDbContextRegistrationOptionsBuilder.cs @@ -90,5 +90,5 @@ public interface IAbpCommonDbContextRegistrationOptionsBuilder /// The DbContext type to be replaced /// The target DbContext type (optional, used this DbContext type if not provided) /// MultiTenancy side - IAbpCommonDbContextRegistrationOptionsBuilder ReplaceDbContext(Type otherDbContextType, Type targetDbContextType = null, MultiTenancySides multiTenancySides = MultiTenancySides.Both); + IAbpCommonDbContextRegistrationOptionsBuilder ReplaceDbContext(Type otherDbContextType, Type? targetDbContextType = null, MultiTenancySides multiTenancySides = MultiTenancySides.Both); } diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/DependencyInjection/MultiTenantDbContextType.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/DependencyInjection/MultiTenantDbContextType.cs index ff0d74608a..b015b9204a 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/DependencyInjection/MultiTenantDbContextType.cs +++ b/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; diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/AuditedAggregateRootWithUser.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/AuditedAggregateRootWithUser.cs index ebb573579b..f38c21d2fe 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/AuditedAggregateRootWithUser.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/AuditedAggregateRootWithUser.cs @@ -12,10 +12,10 @@ public abstract class AuditedAggregateRootWithUser : AuditedAggregateRoot where TUser : IEntity { /// - public virtual TUser Creator { get; protected set; } + public virtual TUser? Creator { get; protected set; } /// - public virtual TUser LastModifier { get; set; } + public virtual TUser? LastModifier { get; set; } } /// @@ -28,10 +28,10 @@ public abstract class AuditedAggregateRootWithUser : AuditedAggrega where TUser : IEntity { /// - public virtual TUser Creator { get; protected set; } + public virtual TUser? Creator { get; protected set; } /// - public virtual TUser LastModifier { get; set; } + public virtual TUser? LastModifier { get; set; } protected AuditedAggregateRootWithUser() { diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/AuditedEntityWithUser.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/AuditedEntityWithUser.cs index 99b9b66303..3f8598d348 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/AuditedEntityWithUser.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/AuditedEntityWithUser.cs @@ -12,10 +12,10 @@ public abstract class AuditedEntityWithUser : AuditedEntity, IAuditedObje where TUser : IEntity { /// - public virtual TUser Creator { get; protected set; } + public virtual TUser? Creator { get; protected set; } /// - public virtual TUser LastModifier { get; set; } + public virtual TUser? LastModifier { get; set; } } /// @@ -28,10 +28,10 @@ public abstract class AuditedEntityWithUser : AuditedEntity, where TUser : IEntity { /// - public virtual TUser Creator { get; protected set; } + public virtual TUser? Creator { get; protected set; } /// - public virtual TUser LastModifier { get; set; } + public virtual TUser? LastModifier { get; set; } protected AuditedEntityWithUser() { diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/CreationAuditedAggregateRootWithUser.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/CreationAuditedAggregateRootWithUser.cs index 73da9d2026..4407a93de8 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/CreationAuditedAggregateRootWithUser.cs +++ b/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 : CreationAuditedAggregateRoot, ICreationAuditedObject { /// - public virtual TUser Creator { get; protected set; } + public virtual TUser? Creator { get; protected set; } } /// @@ -23,7 +23,7 @@ public abstract class CreationAuditedAggregateRootWithUser : CreationAudi public abstract class CreationAuditedAggregateRootWithUser : CreationAuditedAggregateRoot, ICreationAuditedObject { /// - public virtual TUser Creator { get; protected set; } + public virtual TUser? Creator { get; protected set; } protected CreationAuditedAggregateRootWithUser() { diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/CreationAuditedEntityWithUser.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/CreationAuditedEntityWithUser.cs index 203967fb89..635bb06183 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/CreationAuditedEntityWithUser.cs +++ b/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 : CreationAuditedEntity, ICreationAuditedObject { /// - public virtual TUser Creator { get; protected set; } + public virtual TUser? Creator { get; protected set; } } /// @@ -23,7 +23,7 @@ public abstract class CreationAuditedEntityWithUser : CreationAuditedEnti public abstract class CreationAuditedEntityWithUser : CreationAuditedEntity, ICreationAuditedObject { /// - public virtual TUser Creator { get; protected set; } + public virtual TUser? Creator { get; protected set; } protected CreationAuditedEntityWithUser() { diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/FullAuditedAggregateRootWithUser.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/FullAuditedAggregateRootWithUser.cs index 918270088e..af8f196f00 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/FullAuditedAggregateRootWithUser.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/FullAuditedAggregateRootWithUser.cs @@ -12,13 +12,13 @@ public abstract class FullAuditedAggregateRootWithUser : FullAuditedAggre where TUser : IEntity { /// - public virtual TUser Deleter { get; set; } + public virtual TUser? Deleter { get; set; } /// - public virtual TUser Creator { get; protected set; } + public virtual TUser? Creator { get; protected set; } /// - public virtual TUser LastModifier { get; set; } + public virtual TUser? LastModifier { get; set; } } /// @@ -31,13 +31,13 @@ public abstract class FullAuditedAggregateRootWithUser : FullAudite where TUser : IEntity { /// - public virtual TUser Deleter { get; set; } + public virtual TUser? Deleter { get; set; } /// - public virtual TUser Creator { get; protected set; } + public virtual TUser? Creator { get; protected set; } /// - public virtual TUser LastModifier { get; set; } + public virtual TUser? LastModifier { get; set; } protected FullAuditedAggregateRootWithUser() { diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/FullAuditedEntityWithUser.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/FullAuditedEntityWithUser.cs index 1f4886f4c0..834b106d95 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/FullAuditedEntityWithUser.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/FullAuditedEntityWithUser.cs @@ -12,13 +12,13 @@ public abstract class FullAuditedEntityWithUser : FullAuditedEntity, IFul where TUser : IEntity { /// - public virtual TUser Deleter { get; set; } + public virtual TUser? Deleter { get; set; } /// - public virtual TUser Creator { get; protected set; } + public virtual TUser? Creator { get; protected set; } /// - public virtual TUser LastModifier { get; set; } + public virtual TUser? LastModifier { get; set; } } /// @@ -31,13 +31,13 @@ public abstract class FullAuditedEntityWithUser : FullAuditedEntity where TUser : IEntity { /// - public virtual TUser Deleter { get; set; } + public virtual TUser? Deleter { get; set; } /// - public virtual TUser Creator { get; protected set; } + public virtual TUser? Creator { get; protected set; } /// - public virtual TUser LastModifier { get; set; } + public virtual TUser? LastModifier { get; set; } protected FullAuditedEntityWithUser() { diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Caching/EntityCacheBase.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Caching/EntityCacheBase.cs index 7e5b17b687..2cb2b2c32b 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Caching/EntityCacheBase.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Caching/EntityCacheBase.cs @@ -27,23 +27,23 @@ public abstract class EntityCacheBase : UnitOfWorkManager = unitOfWorkManager; } - public virtual async Task FindAsync(TKey id) + public virtual async Task FindAsync(TKey id) { return await Cache.GetOrAddAsync( id, - async () => MapToCacheItem(await Repository.FindAsync(id)) + async () => MapToCacheItem(await Repository.FindAsync(id))! ); } public virtual async Task 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 eventData) { diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Caching/EntityCacheServiceCollectionExtensions.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Caching/EntityCacheServiceCollectionExtensions.cs index bf7ceac45c..c208c7b107 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Caching/EntityCacheServiceCollectionExtensions.cs +++ b/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( this IServiceCollection services, - [CanBeNull] DistributedCacheEntryOptions cacheOptions = null) + DistributedCacheEntryOptions? cacheOptions = null) where TEntity : Entity { services @@ -39,7 +39,7 @@ public static class EntityCacheServiceCollectionExtensions public static IServiceCollection AddEntityCache( this IServiceCollection services, - [CanBeNull] DistributedCacheEntryOptions cacheOptions = null) + DistributedCacheEntryOptions? cacheOptions = null) where TEntity : Entity where TEntityCacheItem : class { @@ -61,7 +61,7 @@ public static class EntityCacheServiceCollectionExtensions public static IServiceCollection AddEntityCache( this IServiceCollection services, - [CanBeNull] DistributedCacheEntryOptions cacheOptions = null) + DistributedCacheEntryOptions? cacheOptions = null) where TEntity : Entity where TEntityCacheItem : class { diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Caching/EntityCacheWithObjectMapper.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Caching/EntityCacheWithObjectMapper.cs index 727df63ea7..a37ad49b1e 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Caching/EntityCacheWithObjectMapper.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Caching/EntityCacheWithObjectMapper.cs @@ -23,7 +23,7 @@ public class EntityCacheWithObjectMapper : ObjectMapper = objectMapper; } - protected override TEntityCacheItem MapToCacheItem(TEntity entity) + protected override TEntityCacheItem? MapToCacheItem(TEntity? entity) { if (entity == null) { diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Caching/EntityCacheWithoutCacheItem.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Caching/EntityCacheWithoutCacheItem.cs index c81f3e5e9e..0f300a7f28 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Caching/EntityCacheWithoutCacheItem.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Caching/EntityCacheWithoutCacheItem.cs @@ -16,7 +16,7 @@ public class EntityCacheWithoutCacheItem : { } - protected override TEntity MapToCacheItem(TEntity entity) + protected override TEntity? MapToCacheItem(TEntity? entity) { return entity; } diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Caching/IEntityCache.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Caching/IEntityCache.cs index 84f4486c65..bd8ba80a63 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Caching/IEntityCache.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Caching/IEntityCache.cs @@ -10,8 +10,7 @@ public interface IEntityCache /// Gets the entity with given , /// or returns null if the entity was not found. /// - [ItemCanBeNull] - Task FindAsync(TKey id); + Task FindAsync(TKey id); /// /// Gets the entity with given , diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Entity.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Entity.cs index 54ebd01d1e..9e52d1abfd 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Entity.cs +++ b/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 : Entity, IEntity { /// - 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 : Entity, IEntity Id = id; } - public override object[] GetKeys() + public override object?[] GetKeys() { - return new object[] { Id }; + return new object?[] { Id }; } /// diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/EntityHelper.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/EntityHelper.cs index f7a4f27e5f..584807fac5 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/EntityHelper.cs +++ b/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(IEntity entity) { - if (EqualityComparer.Default.Equals(entity.Id, default)) + if (EqualityComparer.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 /// - [CanBeNull] - public static Type FindPrimaryKeyType() + public static Type? FindPrimaryKeyType() 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 /// - [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> closure = () => idValue; + Expression> closure = () => idValue; var rightExpression = Expression.Convert(closure.Body, leftExpression.Type); var lambdaBody = Expression.Equal(leftExpression, rightExpression); return Expression.Lambda>(lambdaBody, lambdaParam); diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Events/Distributed/EntitySynchronizer.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Events/Distributed/EntitySynchronizer.cs index b971acc25f..5640c427c2 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Events/Distributed/EntitySynchronizer.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Events/Distributed/EntitySynchronizer.cs @@ -22,7 +22,7 @@ public abstract class EntitySynchronizer : Repository = repository; } - protected override Task FindLocalEntityAsync(TSourceEntityEto eto) + protected override Task FindLocalEntityAsync(TSourceEntityEto eto) { return Repository.FindAsync(eto.Id); } @@ -154,10 +154,9 @@ public abstract class EntitySynchronizer : return true; } - [ItemCanBeNull] - protected abstract Task FindLocalEntityAsync(TSourceEntityEto eto); + protected abstract Task FindLocalEntityAsync(TSourceEntityEto eto); - protected virtual Task IsEtoNewerAsync(TSourceEntityEto eto, [CanBeNull] TEntity localEntity) + protected virtual Task IsEtoNewerAsync(TSourceEntityEto eto, TEntity? localEntity) { if (localEntity is IHasEntityVersion versionedLocalEntity && eto is IHasEntityVersion versionedEto) { diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Events/Distributed/EntityToEtoMapper.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Events/Distributed/EntityToEtoMapper.cs index b9d5911375..1710fe81e3 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Events/Distributed/EntityToEtoMapper.cs +++ b/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)); diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Events/EntityChangeEventHelper.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Events/EntityChangeEventHelper.cs index 20556f16ff..44eb5c058a 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Events/EntityChangeEventHelper.cs +++ b/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) diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Events/EntityEventData.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Events/EntityEventData.cs index c2845da60e..b295f22f4e 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Events/EntityEventData.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Events/EntityEventData.cs @@ -27,7 +27,7 @@ public class EntityEventData : IEventDataWithInheritableGenericArgument public virtual object[] GetConstructorArgs() { - return new object[] { Entity }; + return new object[] { Entity! }; } public virtual bool IsMultiTenant(out Guid? tenantId) diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/IEntity.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/IEntity.cs index 7f4d425df2..1df1b75696 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/IEntity.cs +++ b/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. /// /// - object[] GetKeys(); + object?[] GetKeys(); } /// diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/BasicRepositoryBase.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/BasicRepositoryBase.cs index 8a87f9c391..0d86045eea 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/BasicRepositoryBase.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/BasicRepositoryBase.cs @@ -20,9 +20,9 @@ public abstract class BasicRepositoryBase : 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(); @@ -123,7 +123,7 @@ public abstract class BasicRepositoryBase : BasicRepositoryBase FindAsync(TKey id, bool includeDetails = true, CancellationToken cancellationToken = default); + public abstract Task FindAsync(TKey id, bool includeDetails = true, CancellationToken cancellationToken = default); public virtual async Task DeleteAsync(TKey id, bool autoSave = false, CancellationToken cancellationToken = default) { diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/IReadOnlyBasicRepository.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/IReadOnlyBasicRepository.cs index 6d447552f9..0736685709 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/IReadOnlyBasicRepository.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/IReadOnlyBasicRepository.cs @@ -51,5 +51,5 @@ public interface IReadOnlyBasicRepository : IReadOnlyBasicReposit /// Set true to include all children of this entity /// A to observe while waiting for the task to complete. /// Entity or null - Task FindAsync(TKey id, bool includeDetails = true, CancellationToken cancellationToken = default); + Task FindAsync(TKey id, bool includeDetails = true, CancellationToken cancellationToken = default); } diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/IRepository.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/IRepository.cs index da915626a8..3c7ae81875 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/IRepository.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/IRepository.cs @@ -28,7 +28,7 @@ public interface IRepository : IReadOnlyRepository, IBasicRepo /// A condition to find the entity /// Set true to include all children of this entity /// A to observe while waiting for the task to complete. - Task FindAsync( + Task FindAsync( [NotNull] Expression> predicate, bool includeDetails = true, CancellationToken cancellationToken = default diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryAsyncExtensions.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryAsyncExtensions.cs index 304f9ea0bd..2115d00200 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryAsyncExtensions.cs +++ b/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 FirstOrDefaultAsync( + public static async Task FirstOrDefaultAsync( [NotNull] this IReadOnlyRepository 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 FirstOrDefaultAsync( + public static async Task FirstOrDefaultAsync( [NotNull] this IReadOnlyRepository repository, [NotNull] Expression> predicate, CancellationToken cancellationToken = default) @@ -162,7 +162,7 @@ public static class RepositoryAsyncExtensions return await repository.AsyncExecuter.LastAsync(queryable, predicate, cancellationToken); } - public static async Task LastOrDefaultAsync( + public static async Task LastOrDefaultAsync( [NotNull] this IReadOnlyRepository 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 LastOrDefaultAsync( + public static async Task LastOrDefaultAsync( [NotNull] this IReadOnlyRepository repository, [NotNull] Expression> predicate, CancellationToken cancellationToken = default) @@ -204,7 +204,7 @@ public static class RepositoryAsyncExtensions return await repository.AsyncExecuter.SingleAsync(queryable, predicate, cancellationToken); } - public static async Task SingleOrDefaultAsync( + public static async Task SingleOrDefaultAsync( [NotNull] this IReadOnlyRepository 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 SingleOrDefaultAsync( + public static async Task SingleOrDefaultAsync( [NotNull] this IReadOnlyRepository repository, [NotNull] Expression> predicate, CancellationToken cancellationToken = default) diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryBase.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryBase.cs index d843584fc4..eb2457f8c8 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryBase.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryBase.cs @@ -41,7 +41,7 @@ public abstract class RepositoryBase : BasicRepositoryBase, IR public abstract Task> GetQueryableAsync(); - public abstract Task FindAsync( + public abstract Task FindAsync( Expression> predicate, bool includeDetails = true, CancellationToken cancellationToken = default); @@ -76,13 +76,13 @@ public abstract class RepositoryBase : BasicRepositoryBase, IR { if (typeof(ISoftDelete).IsAssignableFrom(typeof(TOtherEntity))) { - query = (TQueryable)query.WhereIf(DataFilter.IsEnabled(), e => ((ISoftDelete)e).IsDeleted == false); + query = (TQueryable)query.WhereIf(DataFilter.IsEnabled(), e => ((ISoftDelete)e!).IsDeleted == false); } if (typeof(IMultiTenant).IsAssignableFrom(typeof(TOtherEntity))) { var tenantId = CurrentTenant.Id; - query = (TQueryable)query.WhereIf(DataFilter.IsEnabled(), e => ((IMultiTenant)e).TenantId == tenantId); + query = (TQueryable)query.WhereIf(DataFilter.IsEnabled(), e => ((IMultiTenant)e!).TenantId == tenantId); } return query; @@ -94,7 +94,7 @@ public abstract class RepositoryBase : RepositoryBase, I { public abstract Task GetAsync(TKey id, bool includeDetails = true, CancellationToken cancellationToken = default); - public abstract Task FindAsync(TKey id, bool includeDetails = true, CancellationToken cancellationToken = default); + public abstract Task FindAsync(TKey id, bool includeDetails = true, CancellationToken cancellationToken = default); public virtual async Task DeleteAsync(TKey id, bool autoSave = false, CancellationToken cancellationToken = default) { diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryExtensions.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryExtensions.cs index 379203f46a..cbebf62196 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryExtensions.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryExtensions.cs @@ -54,7 +54,7 @@ public static class RepositoryExtensions ) where TEntity : class, IEntity { - 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); } } diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryRegistrarBase.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryRegistrarBase.cs index 320aed8312..d162f2ffea 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryRegistrarBase.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryRegistrarBase.cs @@ -75,12 +75,12 @@ public abstract class RepositoryRegistrarBase 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); } diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Services/DomainService.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Services/DomainService.cs index 32cf42409c..b36b32eafd 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Services/DomainService.cs +++ b/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(); @@ -26,5 +26,5 @@ public abstract class DomainService : IDomainService protected IAsyncQueryableExecuter AsyncExecuter => LazyServiceProvider.LazyGetRequiredService(); - protected ILogger Logger => LazyServiceProvider.LazyGetService(provider => LoggerFactory?.CreateLogger(GetType().FullName) ?? NullLogger.Instance); + protected ILogger Logger => LazyServiceProvider.LazyGetService(provider => LoggerFactory?.CreateLogger(GetType().FullName!) ?? NullLogger.Instance); } diff --git a/framework/src/Volo.Abp.Threading/Volo/Abp/Linq/AsyncQueryableExecuter.cs b/framework/src/Volo.Abp.Threading/Volo/Abp/Linq/AsyncQueryableExecuter.cs index 108d3bb595..a6b9fb7949 100644 --- a/framework/src/Volo.Abp.Threading/Volo/Abp/Linq/AsyncQueryableExecuter.cs +++ b/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 MinAsync(IQueryable queryable, CancellationToken cancellationToken = default) + public Task MinAsync(IQueryable queryable, CancellationToken cancellationToken = default) { var provider = FindProvider(queryable); @@ -221,7 +221,7 @@ public class AsyncQueryableExecuter : IAsyncQueryableExecuter, ISingletonDepende return Task.FromResult(queryable.Min())!; } - public Task MinAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + public Task MinAsync(IQueryable queryable, Expression> 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 MaxAsync(IQueryable queryable, CancellationToken cancellationToken = default) + public Task MaxAsync(IQueryable queryable, CancellationToken cancellationToken = default) { var provider = FindProvider(queryable); @@ -245,7 +245,7 @@ public class AsyncQueryableExecuter : IAsyncQueryableExecuter, ISingletonDepende return Task.FromResult(queryable.Max())!; } - public Task MaxAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + public Task MaxAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) { var provider = FindProvider(queryable); diff --git a/framework/src/Volo.Abp.Threading/Volo/Abp/Linq/IAsyncQueryableExecuter.cs b/framework/src/Volo.Abp.Threading/Volo/Abp/Linq/IAsyncQueryableExecuter.cs index 2bea6c4604..4ee0666f4c 100644 --- a/framework/src/Volo.Abp.Threading/Volo/Abp/Linq/IAsyncQueryableExecuter.cs +++ b/framework/src/Volo.Abp.Threading/Volo/Abp/Linq/IAsyncQueryableExecuter.cs @@ -137,12 +137,12 @@ public interface IAsyncQueryableExecuter #region Min - Task MinAsync( + Task MinAsync( [NotNull] IQueryable queryable, CancellationToken cancellationToken = default); - Task MinAsync( + Task MinAsync( [NotNull] IQueryable queryable, [NotNull] Expression> selector, CancellationToken cancellationToken = default); @@ -151,12 +151,12 @@ public interface IAsyncQueryableExecuter #region Max - Task MaxAsync( + Task MaxAsync( [NotNull] IQueryable queryable, CancellationToken cancellationToken = default); - Task MaxAsync( + Task MaxAsync( [NotNull] IQueryable queryable, [NotNull] Expression> selector, CancellationToken cancellationToken = default); diff --git a/framework/src/Volo.Abp.Threading/Volo/Abp/Linq/IAsyncQueryableProvider.cs b/framework/src/Volo.Abp.Threading/Volo/Abp/Linq/IAsyncQueryableProvider.cs index 3f38553ac5..3239fde6d6 100644 --- a/framework/src/Volo.Abp.Threading/Volo/Abp/Linq/IAsyncQueryableProvider.cs +++ b/framework/src/Volo.Abp.Threading/Volo/Abp/Linq/IAsyncQueryableProvider.cs @@ -139,12 +139,12 @@ public interface IAsyncQueryableProvider #region Min - Task MinAsync( + Task MinAsync( [NotNull] IQueryable queryable, CancellationToken cancellationToken = default); - Task MinAsync( + Task MinAsync( [NotNull] IQueryable queryable, [NotNull] Expression> selector, CancellationToken cancellationToken = default); @@ -153,12 +153,12 @@ public interface IAsyncQueryableProvider #region Max - Task MaxAsync( + Task MaxAsync( [NotNull] IQueryable queryable, CancellationToken cancellationToken = default); - Task MaxAsync( + Task MaxAsync( [NotNull] IQueryable queryable, [NotNull] Expression> selector, CancellationToken cancellationToken = default);