From bf608c6a57b7c798b3ef64f81be27b5cbcbe6f7b Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Mon, 7 Aug 2023 14:49:39 +0800 Subject: [PATCH] Enable nullable annotations for Volo.Abp.Application.Contracts --- .../Volo.Abp.Ddd.Application.Contracts.csproj | 2 ++ .../Abp/Application/Dtos/AuditedEntityWithUserDto.cs | 8 ++++---- .../Dtos/CreationAuditedEntityWithUserDto.cs | 4 ++-- .../Volo/Abp/Application/Dtos/EntityDto.cs | 2 +- .../Dtos/ExtensibleAuditedEntityWithUserDto.cs | 8 ++++---- .../ExtensibleCreationAuditedEntityWithUserDto.cs | 4 ++-- .../Volo/Abp/Application/Dtos/ExtensibleEntityDto.cs | 2 +- .../Dtos/ExtensibleFullAuditedEntityWithUserDto.cs | 12 ++++++------ .../Application/Dtos/FullAuditedEntityWithUserDto.cs | 12 ++++++------ .../Abp/Application/Dtos/ISortedResultRequest.cs | 2 +- .../Abp/Application/Dtos/LimitedResultRequestDto.cs | 4 ++-- .../Volo/Abp/Application/Dtos/ListResultDto.cs | 4 ++-- .../Dtos/PagedAndSortedResultRequestDto.cs | 4 ++-- .../Events/Distributed/IEntityToEtoMapper.cs | 3 +-- .../Entities/Events/Distributed/EntityToEtoMapper.cs | 2 +- 15 files changed, 37 insertions(+), 36 deletions(-) diff --git a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo.Abp.Ddd.Application.Contracts.csproj b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo.Abp.Ddd.Application.Contracts.csproj index ae01d66fd0..891a4b8a33 100644 --- a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo.Abp.Ddd.Application.Contracts.csproj +++ b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo.Abp.Ddd.Application.Contracts.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable Volo.Abp.Ddd.Application.Contracts Volo.Abp.Ddd.Application.Contracts $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; diff --git a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/AuditedEntityWithUserDto.cs b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/AuditedEntityWithUserDto.cs index 992abc68fe..dfdbb10590 100644 --- a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/AuditedEntityWithUserDto.cs +++ b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/AuditedEntityWithUserDto.cs @@ -12,10 +12,10 @@ namespace Volo.Abp.Application.Dtos; public abstract class AuditedEntityWithUserDto : AuditedEntityDto, IAuditedObject { /// - public TUserDto Creator { get; set; } + public TUserDto? Creator { get; set; } /// - public TUserDto LastModifier { get; set; } + public TUserDto? LastModifier { get; set; } } /// @@ -28,8 +28,8 @@ public abstract class AuditedEntityWithUserDto : AuditedEntityDto, IAu public abstract class AuditedEntityWithUserDto : AuditedEntityDto, IAuditedObject { /// - public TUserDto Creator { get; set; } + public TUserDto? Creator { get; set; } /// - public TUserDto LastModifier { get; set; } + public TUserDto? LastModifier { get; set; } } diff --git a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/CreationAuditedEntityWithUserDto.cs b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/CreationAuditedEntityWithUserDto.cs index e566e8852b..241944bb69 100644 --- a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/CreationAuditedEntityWithUserDto.cs +++ b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/CreationAuditedEntityWithUserDto.cs @@ -11,7 +11,7 @@ namespace Volo.Abp.Application.Dtos; [Serializable] public abstract class CreationAuditedEntityWithUserDto : CreationAuditedEntityDto, ICreationAuditedObject { - public TUserDto Creator { get; set; } + public TUserDto? Creator { get; set; } } /// @@ -23,5 +23,5 @@ public abstract class CreationAuditedEntityWithUserDto : CreationAudit [Serializable] public abstract class CreationAuditedEntityWithUserDto : CreationAuditedEntityDto, ICreationAuditedObject { - public TUserDto Creator { get; set; } + public TUserDto? Creator { get; set; } } diff --git a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/EntityDto.cs b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/EntityDto.cs index a205549695..656e63b0d5 100644 --- a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/EntityDto.cs +++ b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/EntityDto.cs @@ -17,7 +17,7 @@ public abstract class EntityDto : EntityDto, IEntityDto /// /// Id of the entity. /// - public TKey Id { get; set; } + public TKey Id { get; set; } = default!; public override string ToString() { diff --git a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/ExtensibleAuditedEntityWithUserDto.cs b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/ExtensibleAuditedEntityWithUserDto.cs index 5f6fd28628..212dcfd807 100644 --- a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/ExtensibleAuditedEntityWithUserDto.cs +++ b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/ExtensibleAuditedEntityWithUserDto.cs @@ -15,10 +15,10 @@ namespace Volo.Abp.Application.Dtos; public abstract class ExtensibleAuditedEntityWithUserDto : ExtensibleAuditedEntityDto, IAuditedObject { /// - public TUserDto Creator { get; set; } + public TUserDto? Creator { get; set; } /// - public TUserDto LastModifier { get; set; } + public TUserDto? LastModifier { get; set; } protected ExtensibleAuditedEntityWithUserDto() : this(true) @@ -44,10 +44,10 @@ public abstract class ExtensibleAuditedEntityWithUserDto : ExtensibleA IAuditedObject { /// - public TUserDto Creator { get; set; } + public TUserDto? Creator { get; set; } /// - public TUserDto LastModifier { get; set; } + public TUserDto? LastModifier { get; set; } protected ExtensibleAuditedEntityWithUserDto() : this(true) diff --git a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/ExtensibleCreationAuditedEntityWithUserDto.cs b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/ExtensibleCreationAuditedEntityWithUserDto.cs index 3ea1be97ab..21677718cb 100644 --- a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/ExtensibleCreationAuditedEntityWithUserDto.cs +++ b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/ExtensibleCreationAuditedEntityWithUserDto.cs @@ -14,7 +14,7 @@ namespace Volo.Abp.Application.Dtos; [Serializable] public abstract class ExtensibleCreationAuditedEntityWithUserDto : ExtensibleCreationAuditedEntityDto, ICreationAuditedObject { - public TUserDto Creator { get; set; } + public TUserDto? Creator { get; set; } protected ExtensibleCreationAuditedEntityWithUserDto() : this(true) @@ -39,7 +39,7 @@ public abstract class ExtensibleCreationAuditedEntityWithUserDto : ExtensibleCreationAuditedEntityDto, ICreationAuditedObject { - public TUserDto Creator { get; set; } + public TUserDto? Creator { get; set; } protected ExtensibleCreationAuditedEntityWithUserDto() : this(true) diff --git a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/ExtensibleEntityDto.cs b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/ExtensibleEntityDto.cs index 1af46a3287..9687af0cf7 100644 --- a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/ExtensibleEntityDto.cs +++ b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/ExtensibleEntityDto.cs @@ -9,7 +9,7 @@ public abstract class ExtensibleEntityDto : ExtensibleObject, IEntityDto /// Id of the entity. /// - public TKey Id { get; set; } + public TKey Id { get; set; } = default!; protected ExtensibleEntityDto() : this(true) diff --git a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/ExtensibleFullAuditedEntityWithUserDto.cs b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/ExtensibleFullAuditedEntityWithUserDto.cs index 018a84cd7a..9793774a47 100644 --- a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/ExtensibleFullAuditedEntityWithUserDto.cs +++ b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/ExtensibleFullAuditedEntityWithUserDto.cs @@ -15,13 +15,13 @@ namespace Volo.Abp.Application.Dtos; public abstract class ExtensibleFullAuditedEntityWithUserDto : ExtensibleFullAuditedEntityDto, IFullAuditedObject { /// - public TUserDto Creator { get; set; } + public TUserDto? Creator { get; set; } /// - public TUserDto LastModifier { get; set; } + public TUserDto? LastModifier { get; set; } /// - public TUserDto Deleter { get; set; } + public TUserDto? Deleter { get; set; } protected ExtensibleFullAuditedEntityWithUserDto() : this(true) @@ -47,13 +47,13 @@ public abstract class ExtensibleFullAuditedEntityWithUserDto : Extensi IFullAuditedObject { /// - public TUserDto Creator { get; set; } + public TUserDto? Creator { get; set; } /// - public TUserDto LastModifier { get; set; } + public TUserDto? LastModifier { get; set; } /// - public TUserDto Deleter { get; set; } + public TUserDto? Deleter { get; set; } protected ExtensibleFullAuditedEntityWithUserDto() : this(true) diff --git a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/FullAuditedEntityWithUserDto.cs b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/FullAuditedEntityWithUserDto.cs index 0575c348b4..c9941d9127 100644 --- a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/FullAuditedEntityWithUserDto.cs +++ b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/FullAuditedEntityWithUserDto.cs @@ -12,13 +12,13 @@ namespace Volo.Abp.Application.Dtos; public abstract class FullAuditedEntityWithUserDto : FullAuditedEntityDto, IFullAuditedObject { /// - public TUserDto Creator { get; set; } + public TUserDto? Creator { get; set; } /// - public TUserDto LastModifier { get; set; } + public TUserDto? LastModifier { get; set; } /// - public TUserDto Deleter { get; set; } + public TUserDto? Deleter { get; set; } } /// @@ -31,11 +31,11 @@ public abstract class FullAuditedEntityWithUserDto : FullAuditedEntity public abstract class FullAuditedEntityWithUserDto : FullAuditedEntityDto, IFullAuditedObject { /// - public TUserDto Creator { get; set; } + public TUserDto? Creator { get; set; } /// - public TUserDto LastModifier { get; set; } + public TUserDto? LastModifier { get; set; } /// - public TUserDto Deleter { get; set; } + public TUserDto? Deleter { get; set; } } diff --git a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/ISortedResultRequest.cs b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/ISortedResultRequest.cs index 0f0a4fe90f..b27c3bf99d 100644 --- a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/ISortedResultRequest.cs +++ b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/ISortedResultRequest.cs @@ -16,5 +16,5 @@ public interface ISortedResultRequest /// "Name DESC" /// "Name ASC, Age DESC" /// - string Sorting { get; set; } + string? Sorting { get; set; } } diff --git a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/LimitedResultRequestDto.cs b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/LimitedResultRequestDto.cs index d72f7b0a77..646eb4d45e 100644 --- a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/LimitedResultRequestDto.cs +++ b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/LimitedResultRequestDto.cs @@ -42,7 +42,7 @@ public class LimitedResultRequestDto : ILimitedResultRequest, IValidatableObject "MaxResultCountExceededExceptionMessage", nameof(MaxResultCount), MaxMaxResultCount, - typeof(LimitedResultRequestDto).FullName, + typeof(LimitedResultRequestDto).FullName!, nameof(MaxMaxResultCount) ], new[] { nameof(MaxResultCount) }); @@ -90,7 +90,7 @@ public class ExtensibleLimitedResultRequestDto : ExtensibleEntityDto, ILimitedRe "MaxResultCountExceededExceptionMessage", nameof(MaxResultCount), MaxMaxResultCount, - typeof(ExtensibleLimitedResultRequestDto).FullName, + typeof(ExtensibleLimitedResultRequestDto).FullName!, nameof(MaxMaxResultCount) ], new[] { nameof(MaxResultCount) }); diff --git a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/ListResultDto.cs b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/ListResultDto.cs index 361b27faac..56937e7049 100644 --- a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/ListResultDto.cs +++ b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/ListResultDto.cs @@ -13,7 +13,7 @@ public class ListResultDto : IListResult get { return _items ?? (_items = new List()); } set { _items = value; } } - private IReadOnlyList _items; + private IReadOnlyList? _items; /// /// Creates a new object. @@ -42,7 +42,7 @@ public class ExtensibleListResultDto : ExtensibleObject, IListResult get { return _items ?? (_items = new List()); } set { _items = value; } } - private IReadOnlyList _items; + private IReadOnlyList? _items; /// /// Creates a new object. diff --git a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/PagedAndSortedResultRequestDto.cs b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/PagedAndSortedResultRequestDto.cs index 229178adbf..8a9b62bb60 100644 --- a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/PagedAndSortedResultRequestDto.cs +++ b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/PagedAndSortedResultRequestDto.cs @@ -8,7 +8,7 @@ namespace Volo.Abp.Application.Dtos; [Serializable] public class PagedAndSortedResultRequestDto : PagedResultRequestDto, IPagedAndSortedResultRequest { - public virtual string Sorting { get; set; } + public virtual string? Sorting { get; set; } } /// @@ -17,5 +17,5 @@ public class PagedAndSortedResultRequestDto : PagedResultRequestDto, IPagedAndSo [Serializable] public class ExtensiblePagedAndSortedResultRequestDto : ExtensiblePagedResultRequestDto, IPagedAndSortedResultRequest { - public virtual string Sorting { get; set; } + public virtual string? Sorting { get; set; } } diff --git a/framework/src/Volo.Abp.Ddd.Domain.Shared/Volo/Abp/Domain/Entities/Events/Distributed/IEntityToEtoMapper.cs b/framework/src/Volo.Abp.Ddd.Domain.Shared/Volo/Abp/Domain/Entities/Events/Distributed/IEntityToEtoMapper.cs index 6f0ea7a880..67406fd0d4 100644 --- a/framework/src/Volo.Abp.Ddd.Domain.Shared/Volo/Abp/Domain/Entities/Events/Distributed/IEntityToEtoMapper.cs +++ b/framework/src/Volo.Abp.Ddd.Domain.Shared/Volo/Abp/Domain/Entities/Events/Distributed/IEntityToEtoMapper.cs @@ -4,6 +4,5 @@ namespace Volo.Abp.Domain.Entities.Events.Distributed; public interface IEntityToEtoMapper { - [CanBeNull] - object Map(object entityObj); + object? Map(object entityObj); } 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 1710fe81e3..cab3fe4614 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 @@ -36,7 +36,7 @@ public class EntityToEtoMapper : IEntityToEtoMapper, ITransientDependency if (etoMappingItem == null) { var keys = entity.GetKeys().JoinAsString(","); - return new EntityEto(entityType.FullName, keys); + return new EntityEto(entityType.FullName!, keys); } using (var scope = HybridServiceScopeFactory.CreateScope())