diff --git a/framework/src/Volo.Abp.Auditing/Volo.Abp.Auditing.csproj b/framework/src/Volo.Abp.Auditing/Volo.Abp.Auditing.csproj index 6a29572457..00abec3b37 100644 --- a/framework/src/Volo.Abp.Auditing/Volo.Abp.Auditing.csproj +++ b/framework/src/Volo.Abp.Auditing/Volo.Abp.Auditing.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable Volo.Abp.Auditing Volo.Abp.Auditing $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; diff --git a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AbpAuditingOptions.cs b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AbpAuditingOptions.cs index 623733e8e5..30b32c3587 100644 --- a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AbpAuditingOptions.cs +++ b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AbpAuditingOptions.cs @@ -26,7 +26,7 @@ public class AbpAuditingOptions /// The name of the application or service writing audit logs. /// Default: null. /// - public string ApplicationName { get; set; } + public string? ApplicationName { get; set; } /// /// Default: true. diff --git a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditLogActionInfo.cs b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditLogActionInfo.cs index e312f947e4..f9f2c66cd0 100644 --- a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditLogActionInfo.cs +++ b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditLogActionInfo.cs @@ -7,11 +7,11 @@ namespace Volo.Abp.Auditing; [Serializable] public class AuditLogActionInfo : IHasExtraProperties { - public string ServiceName { get; set; } + public string ServiceName { get; set; } = default!; - public string MethodName { get; set; } + public string MethodName { get; set; } = default!; - public string Parameters { get; set; } + public string Parameters { get; set; } = default!; public DateTime ExecutionTime { get; set; } diff --git a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditLogInfo.cs b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditLogInfo.cs index 4df472da24..962b143e8c 100644 --- a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditLogInfo.cs +++ b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditLogInfo.cs @@ -9,43 +9,43 @@ namespace Volo.Abp.Auditing; [Serializable] public class AuditLogInfo : IHasExtraProperties { - public string ApplicationName { get; set; } + public string? ApplicationName { get; set; } public Guid? UserId { get; set; } - public string UserName { get; set; } + public string? UserName { get; set; } public Guid? TenantId { get; set; } - public string TenantName { get; set; } + public string? TenantName { get; set; } public Guid? ImpersonatorUserId { get; set; } public Guid? ImpersonatorTenantId { get; set; } - public string ImpersonatorUserName { get; set; } + public string? ImpersonatorUserName { get; set; } - public string ImpersonatorTenantName { get; set; } + public string? ImpersonatorTenantName { get; set; } public DateTime ExecutionTime { get; set; } public int ExecutionDuration { get; set; } - public string ClientId { get; set; } + public string? ClientId { get; set; } - public string CorrelationId { get; set; } + public string? CorrelationId { get; set; } - public string ClientIpAddress { get; set; } + public string? ClientIpAddress { get; set; } - public string ClientName { get; set; } + public string? ClientName { get; set; } - public string BrowserInfo { get; set; } + public string? BrowserInfo { get; set; } - public string HttpMethod { get; set; } + public string? HttpMethod { get; set; } public int? HttpStatusCode { get; set; } - public string Url { get; set; } + public string? Url { get; set; } public List Actions { get; set; } diff --git a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingHelper.cs b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingHelper.cs index 7468f10986..aadbeccabb 100644 --- a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingHelper.cs +++ b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingHelper.cs @@ -52,7 +52,7 @@ public class AuditingHelper : IAuditingHelper, ITransientDependency CorrelationIdProvider = correlationIdProvider; } - public virtual bool ShouldSaveAudit(MethodInfo methodInfo, bool defaultValue = false, bool ignoreIntegrationServiceAttribute = false) + public virtual bool ShouldSaveAudit(MethodInfo? methodInfo, bool defaultValue = false, bool ignoreIntegrationServiceAttribute = false) { if (methodInfo == null) { @@ -150,23 +150,23 @@ public class AuditingHelper : IAuditingHelper, ITransientDependency public virtual AuditLogActionInfo CreateAuditLogAction( AuditLogInfo auditLog, - Type type, + Type? type, MethodInfo method, - object[] arguments) + object?[] arguments) { return CreateAuditLogAction(auditLog, type, method, CreateArgumentsDictionary(method, arguments)); } public virtual AuditLogActionInfo CreateAuditLogAction( AuditLogInfo auditLog, - Type type, + Type? type, MethodInfo method, - IDictionary arguments) + IDictionary arguments) { var actionInfo = new AuditLogActionInfo { ServiceName = type != null - ? type.FullName + ? type.FullName! : "", MethodName = method.Name, Parameters = SerializeConvertArguments(arguments), @@ -198,7 +198,7 @@ public class AuditingHelper : IAuditingHelper, ITransientDependency } } - protected virtual string SerializeConvertArguments(IDictionary arguments) + protected virtual string SerializeConvertArguments(IDictionary arguments) { try { @@ -207,7 +207,7 @@ public class AuditingHelper : IAuditingHelper, ITransientDependency return "{}"; } - var dictionary = new Dictionary(); + var dictionary = new Dictionary(); foreach (var argument in arguments) { @@ -230,14 +230,14 @@ public class AuditingHelper : IAuditingHelper, ITransientDependency } } - protected virtual Dictionary CreateArgumentsDictionary(MethodInfo method, object[] arguments) + protected virtual Dictionary CreateArgumentsDictionary(MethodInfo method, object?[] arguments) { var parameters = method.GetParameters(); - var dictionary = new Dictionary(); + var dictionary = new Dictionary(); for (var i = 0; i < parameters.Length; i++) { - dictionary[parameters[i].Name] = arguments[i]; + dictionary[parameters[i].Name!] = arguments[i]; } return dictionary; diff --git a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingInterceptor.cs b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingInterceptor.cs index bee71b723a..6be28d24cf 100644 --- a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingInterceptor.cs +++ b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingInterceptor.cs @@ -80,7 +80,7 @@ public class AuditingInterceptor : AbpInterceptor, ITransientDependency { var auditLog = auditLogScope.Log; - AuditLogActionInfo auditLogAction = null; + AuditLogActionInfo? auditLogAction = null; if (!options.DisableLogActionInfo) { auditLogAction = auditingHelper.CreateAuditLogAction( @@ -127,10 +127,10 @@ public class AuditingInterceptor : AbpInterceptor, ITransientDependency { try { - await ProceedByLoggingAsync(invocation, options, auditingHelper, auditingManager.Current); + await ProceedByLoggingAsync(invocation, options, auditingHelper, auditingManager.Current!); Debug.Assert(auditingManager.Current != null); - if (auditingManager.Current.Log.Exceptions.Any()) + if (auditingManager.Current!.Log.Exceptions.Any()) { hasError = true; } @@ -142,7 +142,7 @@ public class AuditingInterceptor : AbpInterceptor, ITransientDependency } finally { - if (await ShouldWriteAuditLogAsync(invocation, auditingManager.Current.Log, options, currentUser, hasError)) + if (await ShouldWriteAuditLogAsync(invocation, auditingManager.Current!.Log, options, currentUser, hasError)) { if (unitOfWorkManager.Current != null) { diff --git a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingManager.cs b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingManager.cs index 43d86825ec..df6c435de1 100644 --- a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingManager.cs +++ b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingManager.cs @@ -38,7 +38,7 @@ public class AuditingManager : IAuditingManager, ITransientDependency _auditingStore = auditingStore; } - public IAuditLogScope Current => _ambientScopeProvider.GetValue(AmbientContextKey); + public IAuditLogScope? Current => _ambientScopeProvider.GetValue(AmbientContextKey); public IAuditLogSaveHandle BeginScope() { @@ -49,7 +49,7 @@ public class AuditingManager : IAuditingManager, ITransientDependency Debug.Assert(Current != null, "Current != null"); - return new DisposableSaveHandle(this, ambientScope, Current.Log, Stopwatch.StartNew()); + return new DisposableSaveHandle(this, ambientScope, Current!.Log, Stopwatch.StartNew()); } protected virtual void ExecutePostContributors(AuditLogInfo auditLogInfo) diff --git a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/EntityChangeInfo.cs b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/EntityChangeInfo.cs index 9ed4114e48..261809a968 100644 --- a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/EntityChangeInfo.cs +++ b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/EntityChangeInfo.cs @@ -19,15 +19,15 @@ public class EntityChangeInfo : IHasExtraProperties /// public Guid? EntityTenantId { get; set; } - public string EntityId { get; set; } + public string? EntityId { get; set; } - public string EntityTypeFullName { get; set; } + public string? EntityTypeFullName { get; set; } - public List PropertyChanges { get; set; } + public List PropertyChanges { get; set; } = default!; public ExtraPropertyDictionary ExtraProperties { get; } - public virtual object EntityEntry { get; set; } //TODO: Try to remove since it breaks serializability + public virtual object EntityEntry { get; set; } = default!; //TODO: Try to remove since it breaks serializability public EntityChangeInfo() { diff --git a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/EntityPropertyChangeInfo.cs b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/EntityPropertyChangeInfo.cs index 5e92f6622e..e25369d7b2 100644 --- a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/EntityPropertyChangeInfo.cs +++ b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/EntityPropertyChangeInfo.cs @@ -23,11 +23,11 @@ public class EntityPropertyChangeInfo /// public static int MaxPropertyTypeFullNameLength = 192; - public virtual string NewValue { get; set; } + public virtual string? NewValue { get; set; } - public virtual string OriginalValue { get; set; } + public virtual string? OriginalValue { get; set; } - public virtual string PropertyName { get; set; } + public virtual string PropertyName { get; set; } = default!; - public virtual string PropertyTypeFullName { get; set; } + public virtual string PropertyTypeFullName { get; set; } = default!; } diff --git a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IAuditingHelper.cs b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IAuditingHelper.cs index 5a2878d1b0..e6fa20bc90 100644 --- a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IAuditingHelper.cs +++ b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IAuditingHelper.cs @@ -7,7 +7,7 @@ namespace Volo.Abp.Auditing; //TODO: Move ShouldSaveAudit & IsEntityHistoryEnabled and rename to IAuditingFactory public interface IAuditingHelper { - bool ShouldSaveAudit(MethodInfo methodInfo, bool defaultValue = false, bool ignoreIntegrationServiceAttribute = false); + bool ShouldSaveAudit(MethodInfo? methodInfo, bool defaultValue = false, bool ignoreIntegrationServiceAttribute = false); bool IsEntityHistoryEnabled(Type entityType, bool defaultValue = false); @@ -15,15 +15,15 @@ public interface IAuditingHelper AuditLogActionInfo CreateAuditLogAction( AuditLogInfo auditLog, - Type type, + Type? type, MethodInfo method, - object[] arguments + object?[] arguments ); AuditLogActionInfo CreateAuditLogAction( AuditLogInfo auditLog, - Type type, + Type? type, MethodInfo method, - IDictionary arguments + IDictionary arguments ); } diff --git a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IAuditingManager.cs b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IAuditingManager.cs index 35a465396d..a1091b8600 100644 --- a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IAuditingManager.cs +++ b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IAuditingManager.cs @@ -4,8 +4,7 @@ namespace Volo.Abp.Auditing; public interface IAuditingManager { - [CanBeNull] - IAuditLogScope Current { get; } + IAuditLogScope? Current { get; } IAuditLogSaveHandle BeginScope(); } diff --git a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/EntityHistory/EntityHistoryHelper.cs b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/EntityHistory/EntityHistoryHelper.cs index 801e772e26..d21e4c43c5 100644 --- a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/EntityHistory/EntityHistoryHelper.cs +++ b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/EntityHistory/EntityHistoryHelper.cs @@ -177,10 +177,10 @@ public class EntityHistoryHelper : IEntityHistoryHelper, ITransientDependency { propertyChanges.Add(new EntityPropertyChangeInfo { - NewValue = isDeleted ? null : JsonSerializer.Serialize(propertyEntry.CurrentValue).TruncateWithPostfix(EntityPropertyChangeInfo.MaxValueLength), - OriginalValue = isCreated ? null : JsonSerializer.Serialize(propertyEntry.OriginalValue).TruncateWithPostfix(EntityPropertyChangeInfo.MaxValueLength), + NewValue = isDeleted ? null : JsonSerializer.Serialize(propertyEntry.CurrentValue!).TruncateWithPostfix(EntityPropertyChangeInfo.MaxValueLength), + OriginalValue = isCreated ? null : JsonSerializer.Serialize(propertyEntry.OriginalValue!).TruncateWithPostfix(EntityPropertyChangeInfo.MaxValueLength), PropertyName = property.Name, - PropertyTypeFullName = property.ClrType.GetFirstGenericArgumentIfNullable().FullName + PropertyTypeFullName = property.ClrType.GetFirstGenericArgumentIfNullable().FullName! }); } }