diff --git a/framework/src/Volo.Abp.Core/Microsoft/Extensions/Configuration/AbpConfigurationBuilderOptions.cs b/framework/src/Volo.Abp.Core/Microsoft/Extensions/Configuration/AbpConfigurationBuilderOptions.cs
index f9f2ca23ad..1956c64f65 100644
--- a/framework/src/Volo.Abp.Core/Microsoft/Extensions/Configuration/AbpConfigurationBuilderOptions.cs
+++ b/framework/src/Volo.Abp.Core/Microsoft/Extensions/Configuration/AbpConfigurationBuilderOptions.cs
@@ -8,13 +8,13 @@ public class AbpConfigurationBuilderOptions
/// Used to set assembly which is used to get the user secret id for the application.
/// Use this or (higher priority)
///
- public Assembly UserSecretsAssembly { get; set; }
+ public Assembly? UserSecretsAssembly { get; set; }
///
/// Used to set user secret id for the application.
/// Use this (higher priority) or
///
- public string UserSecretsId { get; set; }
+ public string? UserSecretsId { get; set; }
///
/// Default value: "appsettings".
@@ -34,20 +34,20 @@ public class AbpConfigurationBuilderOptions
///
/// Environment name. Generally used "Development", "Staging" or "Production".
///
- public string EnvironmentName { get; set; }
+ public string? EnvironmentName { get; set; }
///
/// Base path to read the configuration file indicated by .
///
- public string BasePath { get; set; }
+ public string? BasePath { get; set; }
///
/// Prefix for the environment variables.
///
- public string EnvironmentVariablesPrefix { get; set; }
+ public string? EnvironmentVariablesPrefix { get; set; }
///
/// Command line arguments.
///
- public string[] CommandLineArgs { get; set; }
+ public string[]? CommandLineArgs { get; set; }
}
diff --git a/framework/src/Volo.Abp.Core/Microsoft/Extensions/Configuration/ConfigurationHelper.cs b/framework/src/Volo.Abp.Core/Microsoft/Extensions/Configuration/ConfigurationHelper.cs
index 28ea8326ac..f31feff873 100644
--- a/framework/src/Volo.Abp.Core/Microsoft/Extensions/Configuration/ConfigurationHelper.cs
+++ b/framework/src/Volo.Abp.Core/Microsoft/Extensions/Configuration/ConfigurationHelper.cs
@@ -6,8 +6,8 @@ namespace Microsoft.Extensions.Configuration;
public static class ConfigurationHelper
{
public static IConfigurationRoot BuildConfiguration(
- AbpConfigurationBuilderOptions options = null,
- Action builderAction = null)
+ AbpConfigurationBuilderOptions? options = null,
+ Action? builderAction = null)
{
options ??= new AbpConfigurationBuilderOptions();
@@ -17,7 +17,7 @@ public static class ConfigurationHelper
}
var builder = new ConfigurationBuilder()
- .SetBasePath(options.BasePath)
+ .SetBasePath(options.BasePath!)
.AddJsonFile(options.FileName + ".json", optional: options.Optional, reloadOnChange: options.ReloadOnChange);
if (!options.EnvironmentName.IsNullOrEmpty())
diff --git a/framework/src/Volo.Abp.Core/Microsoft/Extensions/DependencyInjection/ServiceCollectionApplicationExtensions.cs b/framework/src/Volo.Abp.Core/Microsoft/Extensions/DependencyInjection/ServiceCollectionApplicationExtensions.cs
index 3ad02c7f1d..5b81be3285 100644
--- a/framework/src/Volo.Abp.Core/Microsoft/Extensions/DependencyInjection/ServiceCollectionApplicationExtensions.cs
+++ b/framework/src/Volo.Abp.Core/Microsoft/Extensions/DependencyInjection/ServiceCollectionApplicationExtensions.cs
@@ -10,7 +10,7 @@ public static class ServiceCollectionApplicationExtensions
{
public static IAbpApplicationWithExternalServiceProvider AddApplication(
[NotNull] this IServiceCollection services,
- [CanBeNull] Action optionsAction = null)
+ Action? optionsAction = null)
where TStartupModule : IAbpModule
{
return AbpApplicationFactory.Create(services, optionsAction);
@@ -19,14 +19,14 @@ public static class ServiceCollectionApplicationExtensions
public static IAbpApplicationWithExternalServiceProvider AddApplication(
[NotNull] this IServiceCollection services,
[NotNull] Type startupModuleType,
- [CanBeNull] Action optionsAction = null)
+ Action? optionsAction = null)
{
return AbpApplicationFactory.Create(startupModuleType, services, optionsAction);
}
public async static Task AddApplicationAsync(
[NotNull] this IServiceCollection services,
- [CanBeNull] Action optionsAction = null)
+ Action? optionsAction = null)
where TStartupModule : IAbpModule
{
return await AbpApplicationFactory.CreateAsync(services, optionsAction);
@@ -35,13 +35,12 @@ public static class ServiceCollectionApplicationExtensions
public async static Task AddApplicationAsync(
[NotNull] this IServiceCollection services,
[NotNull] Type startupModuleType,
- [CanBeNull] Action optionsAction = null)
+ Action? optionsAction = null)
{
return await AbpApplicationFactory.CreateAsync(startupModuleType, services, optionsAction);
}
- [CanBeNull]
- public static string GetApplicationName(this IServiceCollection services)
+ public static string? GetApplicationName(this IServiceCollection services)
{
return services.GetSingletonInstance().ApplicationName;
}
diff --git a/framework/src/Volo.Abp.Core/Microsoft/Extensions/DependencyInjection/ServiceCollectionCommonExtensions.cs b/framework/src/Volo.Abp.Core/Microsoft/Extensions/DependencyInjection/ServiceCollectionCommonExtensions.cs
index 9cf4200788..7301b0b7a9 100644
--- a/framework/src/Volo.Abp.Core/Microsoft/Extensions/DependencyInjection/ServiceCollectionCommonExtensions.cs
+++ b/framework/src/Volo.Abp.Core/Microsoft/Extensions/DependencyInjection/ServiceCollectionCommonExtensions.cs
@@ -24,9 +24,9 @@ public static class ServiceCollectionCommonExtensions
return services.GetSingletonInstance();
}
- public static T GetSingletonInstanceOrNull(this IServiceCollection services)
+ public static T? GetSingletonInstanceOrNull(this IServiceCollection services)
{
- return (T)services
+ return (T?)services
.FirstOrDefault(d => d.ServiceType == typeof(T))
?.ImplementationInstance;
}
@@ -65,13 +65,13 @@ public static class ServiceCollectionCommonExtensions
.GetMethods()
.Single(m => m.Name == nameof(BuildServiceProviderFromFactory) && m.IsGenericMethod)
.MakeGenericMethod(containerBuilderType)
- .Invoke(null, new object[] { services, null });
+ .Invoke(null, new object?[] { services, null })!;
}
return services.BuildServiceProvider();
}
- public static IServiceProvider BuildServiceProviderFromFactory([NotNull] this IServiceCollection services, Action builderAction = null)
+ public static IServiceProvider BuildServiceProviderFromFactory([NotNull] this IServiceCollection services, Action? builderAction = null) where TContainerBuilder : notnull
{
Check.NotNull(services, nameof(services));
@@ -90,7 +90,7 @@ public static class ServiceCollectionCommonExtensions
/// Resolves a dependency using given .
/// This method should be used only after dependency injection registration phase completed.
///
- internal static T GetService(this IServiceCollection services)
+ internal static T? GetService(this IServiceCollection services)
{
return services
.GetSingletonInstance()
@@ -102,7 +102,7 @@ public static class ServiceCollectionCommonExtensions
/// Resolves a dependency using given .
/// This method should be used only after dependency injection registration phase completed.
///
- internal static object GetService(this IServiceCollection services, Type type)
+ internal static object? GetService(this IServiceCollection services, Type type)
{
return services
.GetSingletonInstance()
@@ -115,7 +115,7 @@ public static class ServiceCollectionCommonExtensions
/// Throws exception if service is not registered.
/// This method should be used only after dependency injection registration phase completed.
///
- public static T GetRequiredService(this IServiceCollection services)
+ public static T GetRequiredService(this IServiceCollection services) where T : notnull
{
return services
.GetSingletonInstance()
@@ -140,25 +140,25 @@ public static class ServiceCollectionCommonExtensions
/// Returns a to resolve a service from given
/// once dependency injection registration phase completed.
///
- public static Lazy GetServiceLazy(this IServiceCollection services)
+ public static Lazy GetServiceLazy(this IServiceCollection services)
{
- return new Lazy(services.GetService, true);
+ return new Lazy(services.GetService, true);
}
///
/// Returns a to resolve a service from given
/// once dependency injection registration phase completed.
///
- public static Lazy GetServiceLazy(this IServiceCollection services, Type type)
+ public static Lazy GetServiceLazy(this IServiceCollection services, Type type)
{
- return new Lazy(() => services.GetService(type), true);
+ return new Lazy(() => services.GetService(type), true);
}
///
/// Returns a to resolve a service from given
/// once dependency injection registration phase completed.
///
- public static Lazy GetRequiredServiceLazy(this IServiceCollection services)
+ public static Lazy GetRequiredServiceLazy(this IServiceCollection services) where T : notnull
{
return new Lazy(services.GetRequiredService, true);
}
@@ -172,7 +172,7 @@ public static class ServiceCollectionCommonExtensions
return new Lazy(() => services.GetRequiredService(type), true);
}
- public static IServiceProvider GetServiceProviderOrNull(this IServiceCollection services)
+ public static IServiceProvider? GetServiceProviderOrNull(this IServiceCollection services)
{
return services.GetObjectOrNull();
}
diff --git a/framework/src/Volo.Abp.Core/Microsoft/Extensions/DependencyInjection/ServiceCollectionConfigurationExtensions.cs b/framework/src/Volo.Abp.Core/Microsoft/Extensions/DependencyInjection/ServiceCollectionConfigurationExtensions.cs
index 61cde24347..e9dd5cdb66 100644
--- a/framework/src/Volo.Abp.Core/Microsoft/Extensions/DependencyInjection/ServiceCollectionConfigurationExtensions.cs
+++ b/framework/src/Volo.Abp.Core/Microsoft/Extensions/DependencyInjection/ServiceCollectionConfigurationExtensions.cs
@@ -21,7 +21,7 @@ public static class ServiceCollectionConfigurationExtensions
}
[CanBeNull]
- public static IConfiguration GetConfigurationOrNull(this IServiceCollection services)
+ public static IConfiguration? GetConfigurationOrNull(this IServiceCollection services)
{
var hostBuilderContext = services.GetSingletonInstanceOrNull();
if (hostBuilderContext?.Configuration != null)
diff --git a/framework/src/Volo.Abp.Core/Microsoft/Extensions/DependencyInjection/ServiceCollectionObjectAccessorExtensions.cs b/framework/src/Volo.Abp.Core/Microsoft/Extensions/DependencyInjection/ServiceCollectionObjectAccessorExtensions.cs
index 52f26fd75e..1c3692274a 100644
--- a/framework/src/Volo.Abp.Core/Microsoft/Extensions/DependencyInjection/ServiceCollectionObjectAccessorExtensions.cs
+++ b/framework/src/Volo.Abp.Core/Microsoft/Extensions/DependencyInjection/ServiceCollectionObjectAccessorExtensions.cs
@@ -40,7 +40,7 @@ public static class ServiceCollectionObjectAccessorExtensions
return accessor;
}
- public static T GetObjectOrNull(this IServiceCollection services)
+ public static T? GetObjectOrNull(this IServiceCollection services)
where T : class
{
return services.GetSingletonInstanceOrNull>()?.Value;
diff --git a/framework/src/Volo.Abp.Core/Microsoft/Extensions/Logging/AbpLoggerExtensions.cs b/framework/src/Volo.Abp.Core/Microsoft/Extensions/Logging/AbpLoggerExtensions.cs
index daa017d385..18a93f7348 100644
--- a/framework/src/Volo.Abp.Core/Microsoft/Extensions/Logging/AbpLoggerExtensions.cs
+++ b/framework/src/Volo.Abp.Core/Microsoft/Extensions/Logging/AbpLoggerExtensions.cs
@@ -83,7 +83,7 @@ public static class AbpLoggerExtensions
private static void LogData(ILogger logger, Exception exception, LogLevel logLevel)
{
- if (exception.Data == null || exception.Data.Count <= 0)
+ if (exception.Data.Count <= 0)
{
return;
}
@@ -102,23 +102,22 @@ public static class AbpLoggerExtensions
{
var loggingExceptions = new List();
- if (exception is IExceptionWithSelfLogging)
+ if (exception is IExceptionWithSelfLogging logging)
{
- loggingExceptions.Add(exception as IExceptionWithSelfLogging);
+ loggingExceptions.Add(logging);
}
- else if (exception is AggregateException && exception.InnerException != null)
+ else if (exception is AggregateException aggException && aggException.InnerException != null)
{
- var aggException = exception as AggregateException;
- if (aggException.InnerException is IExceptionWithSelfLogging)
+ if (aggException.InnerException is IExceptionWithSelfLogging selfLogging)
{
- loggingExceptions.Add(aggException.InnerException as IExceptionWithSelfLogging);
+ loggingExceptions.Add(selfLogging);
}
foreach (var innerException in aggException.InnerExceptions)
{
- if (innerException is IExceptionWithSelfLogging)
+ if (innerException is IExceptionWithSelfLogging withSelfLogging)
{
- loggingExceptions.AddIfNotContains(innerException as IExceptionWithSelfLogging);
+ loggingExceptions.AddIfNotContains(withSelfLogging);
}
}
}
diff --git a/framework/src/Volo.Abp.Core/System/AbpObjectExtensions.cs b/framework/src/Volo.Abp.Core/System/AbpObjectExtensions.cs
index 24ece0e52e..d098a1602b 100644
--- a/framework/src/Volo.Abp.Core/System/AbpObjectExtensions.cs
+++ b/framework/src/Volo.Abp.Core/System/AbpObjectExtensions.cs
@@ -36,7 +36,7 @@ public static class AbpObjectExtensions
{
if (typeof(T) == typeof(Guid))
{
- return (T)TypeDescriptor.GetConverter(typeof(T)).ConvertFromInvariantString(obj.ToString());
+ return (T)TypeDescriptor.GetConverter(typeof(T)).ConvertFromInvariantString(obj.ToString()!)!;
}
return (T)Convert.ChangeType(obj, typeof(T), CultureInfo.InvariantCulture);
diff --git a/framework/src/Volo.Abp.Core/System/AbpStringExtensions.cs b/framework/src/Volo.Abp.Core/System/AbpStringExtensions.cs
index 57f2c59d57..c7153264ae 100644
--- a/framework/src/Volo.Abp.Core/System/AbpStringExtensions.cs
+++ b/framework/src/Volo.Abp.Core/System/AbpStringExtensions.cs
@@ -47,7 +47,7 @@ public static class AbpStringExtensions
/// Indicates whether this string is null or an System.String.Empty string.
///
[ContractAnnotation("str:null => true")]
- public static bool IsNullOrEmpty(this string str)
+ public static bool IsNullOrEmpty(this string? str)
{
return string.IsNullOrEmpty(str);
}
@@ -56,7 +56,7 @@ public static class AbpStringExtensions
/// indicates whether this string is null, empty, or consists only of white-space characters.
///
[ContractAnnotation("str:null => true")]
- public static bool IsNullOrWhiteSpace(this string str)
+ public static bool IsNullOrWhiteSpace(this string? str)
{
return string.IsNullOrWhiteSpace(str);
}
@@ -482,7 +482,7 @@ public static class AbpStringExtensions
/// Gets a substring of a string from beginning of the string if it exceeds maximum length.
///
[ContractAnnotation("null <= str:null")]
- public static string Truncate(this string str, int maxLength)
+ public static string? Truncate(this string? str, int maxLength)
{
if (str == null)
{
@@ -501,7 +501,7 @@ public static class AbpStringExtensions
/// Gets a substring of a string from Ending of the string if it exceeds maximum length.
///
[ContractAnnotation("null <= str:null")]
- public static string TruncateFromBeginning(this string str, int maxLength)
+ public static string? TruncateFromBeginning(this string? str, int maxLength)
{
if (str == null)
{
@@ -522,7 +522,7 @@ public static class AbpStringExtensions
/// Returning string can not be longer than maxLength.
///
/// Thrown if is null
- public static string TruncateWithPostfix(this string str, int maxLength)
+ public static string? TruncateWithPostfix(this string? str, int maxLength)
{
return TruncateWithPostfix(str, maxLength, "...");
}
@@ -534,7 +534,7 @@ public static class AbpStringExtensions
///
/// Thrown if is null
[ContractAnnotation("null <= str:null")]
- public static string TruncateWithPostfix(this string str, int maxLength, string postfix)
+ public static string? TruncateWithPostfix(this string? str, int maxLength, string postfix)
{
if (str == null)
{
diff --git a/framework/src/Volo.Abp.Core/System/AbpTypeExtensions.cs b/framework/src/Volo.Abp.Core/System/AbpTypeExtensions.cs
index 956b2be1af..4d6d6c5d7a 100644
--- a/framework/src/Volo.Abp.Core/System/AbpTypeExtensions.cs
+++ b/framework/src/Volo.Abp.Core/System/AbpTypeExtensions.cs
@@ -72,9 +72,9 @@ public static class AbpTypeExtensions
private static void AddTypeAndBaseTypesRecursively(
[NotNull] List types,
- [CanBeNull] Type type,
+ Type? type,
bool includeObject,
- [CanBeNull] Type stoppingType = null)
+ Type? stoppingType = null)
{
if (type == null || type == stoppingType)
{
diff --git a/framework/src/Volo.Abp.Core/System/Collections/Generic/AbpCollectionExtensions.cs b/framework/src/Volo.Abp.Core/System/Collections/Generic/AbpCollectionExtensions.cs
index 83fbf59629..af6fc698f4 100644
--- a/framework/src/Volo.Abp.Core/System/Collections/Generic/AbpCollectionExtensions.cs
+++ b/framework/src/Volo.Abp.Core/System/Collections/Generic/AbpCollectionExtensions.cs
@@ -13,7 +13,7 @@ public static class AbpCollectionExtensions
/// Checks whatever given collection object is null or has no item.
///
[ContractAnnotation("source:null => true")]
- public static bool IsNullOrEmpty([CanBeNull] this ICollection source)
+ public static bool IsNullOrEmpty(this ICollection? source)
{
return source == null || source.Count <= 0;
}
diff --git a/framework/src/Volo.Abp.Core/System/Collections/Generic/AbpDictionaryExtensions.cs b/framework/src/Volo.Abp.Core/System/Collections/Generic/AbpDictionaryExtensions.cs
index 6ac5601f7d..61c87864ad 100644
--- a/framework/src/Volo.Abp.Core/System/Collections/Generic/AbpDictionaryExtensions.cs
+++ b/framework/src/Volo.Abp.Core/System/Collections/Generic/AbpDictionaryExtensions.cs
@@ -16,9 +16,9 @@ public static class AbpDictionaryExtensions
/// Key
/// Value of the key (or default value if key not exists)
/// True if key does exists in the dictionary
- internal static bool TryGetValue(this IDictionary dictionary, string key, out T value)
+ internal static bool TryGetValue(this IDictionary dictionary, string key, out T? value)
{
- object valueObj;
+ object? valueObj;
if (dictionary.TryGetValue(key, out valueObj) && valueObj is T)
{
value = (T)valueObj;
@@ -37,9 +37,9 @@ public static class AbpDictionaryExtensions
/// Type of the key
/// Type of the value
/// Value if found, default if can not found.
- public static TValue GetOrDefault(this Dictionary dictionary, TKey key)
+ public static TValue? GetOrDefault(this Dictionary dictionary, TKey key) where TKey : notnull
{
- TValue obj;
+ TValue? obj;
return dictionary.TryGetValue(key, out obj) ? obj : default;
}
@@ -51,7 +51,7 @@ public static class AbpDictionaryExtensions
/// Type of the key
/// Type of the value
/// Value if found, default if can not found.
- public static TValue GetOrDefault(this IDictionary dictionary, TKey key)
+ public static TValue? GetOrDefault(this IDictionary dictionary, TKey key)
{
return dictionary.TryGetValue(key, out var obj) ? obj : default;
}
@@ -64,7 +64,7 @@ public static class AbpDictionaryExtensions
/// Type of the key
/// Type of the value
/// Value if found, default if can not found.
- public static TValue GetOrDefault(this IReadOnlyDictionary dictionary, TKey key)
+ public static TValue? GetOrDefault(this IReadOnlyDictionary dictionary, TKey key)
{
return dictionary.TryGetValue(key, out var obj) ? obj : default;
}
@@ -77,7 +77,7 @@ public static class AbpDictionaryExtensions
/// Type of the key
/// Type of the value
/// Value if found, default if can not found.
- public static TValue GetOrDefault(this ConcurrentDictionary dictionary, TKey key)
+ public static TValue? GetOrDefault(this ConcurrentDictionary dictionary, TKey key) where TKey : notnull
{
return dictionary.TryGetValue(key, out var obj) ? obj : default;
}
@@ -93,7 +93,7 @@ public static class AbpDictionaryExtensions
/// Value if found, default if can not found.
public static TValue GetOrAdd(this IDictionary dictionary, TKey key, Func factory)
{
- TValue obj;
+ TValue? obj;
if (dictionary.TryGetValue(key, out obj))
{
return obj;
@@ -125,7 +125,7 @@ public static class AbpDictionaryExtensions
/// Type of the key
/// Type of the value
/// Value if found, default if can not found.
- public static TValue GetOrAdd(this ConcurrentDictionary dictionary, TKey key, Func factory)
+ public static TValue GetOrAdd(this ConcurrentDictionary dictionary, TKey key, Func factory) where TKey : notnull
{
return dictionary.GetOrAdd(key, k => factory());
}
@@ -138,7 +138,7 @@ public static class AbpDictionaryExtensions
public static dynamic ConvertToDynamicObject(this Dictionary dictionary)
{
var expandoObject = new ExpandoObject();
- var expendObjectCollection = (ICollection>)expandoObject;
+ var expendObjectCollection = (ICollection>)expandoObject!;
foreach (var keyValuePair in dictionary)
{
diff --git a/framework/src/Volo.Abp.Core/System/Collections/Generic/AbpListExtensions.cs b/framework/src/Volo.Abp.Core/System/Collections/Generic/AbpListExtensions.cs
index 679876412f..84a12e7008 100644
--- a/framework/src/Volo.Abp.Core/System/Collections/Generic/AbpListExtensions.cs
+++ b/framework/src/Volo.Abp.Core/System/Collections/Generic/AbpListExtensions.cs
@@ -196,7 +196,7 @@ public static class AbpListExtensions
public static List SortByDependencies(
this IEnumerable source,
Func> getDependencies,
- IEqualityComparer comparer = null)
+ IEqualityComparer? comparer = null) where T : notnull
{
/* See: http://www.codeproject.com/Articles/869059/Topological-sorting-in-Csharp
* http://en.wikipedia.org/wiki/Topological_sorting
@@ -222,7 +222,7 @@ public static class AbpListExtensions
/// List with the sortet items
/// Dictionary with the visited items
private static void SortByDependenciesVisit(T item, Func> getDependencies, List sorted,
- Dictionary visited)
+ Dictionary visited) where T : notnull
{
bool inProcess;
var alreadyVisited = visited.TryGetValue(item, out inProcess);
diff --git a/framework/src/Volo.Abp.Core/System/Linq/PredicateOperator.cs b/framework/src/Volo.Abp.Core/System/Linq/PredicateOperator.cs
index 4d8284f858..df66790ca2 100644
--- a/framework/src/Volo.Abp.Core/System/Linq/PredicateOperator.cs
+++ b/framework/src/Volo.Abp.Core/System/Linq/PredicateOperator.cs
@@ -42,7 +42,7 @@ public static class PredicateBuilder
}
/// Start an expression
- public static ExpressionStarter New(Expression> expr = null)
+ public static ExpressionStarter New(Expression>? expr = null)
{
return new ExpressionStarter(expr);
}
@@ -58,7 +58,7 @@ public static class PredicateBuilder
[NotNull] Expression> expr2)
{
var expr2Body = new RebindParameterVisitor(expr2.Parameters[0], expr1.Parameters[0]).Visit(expr2.Body);
- return Expression.Lambda>(Expression.OrElse(expr1.Body, expr2Body), expr1.Parameters);
+ return Expression.Lambda>(Expression.OrElse(expr1.Body, expr2Body!), expr1.Parameters);
}
/// AND
@@ -66,7 +66,7 @@ public static class PredicateBuilder
[NotNull] Expression> expr2)
{
var expr2Body = new RebindParameterVisitor(expr2.Parameters[0], expr1.Parameters[0]).Visit(expr2.Body);
- return Expression.Lambda>(Expression.AndAlso(expr1.Body, expr2Body), expr1.Parameters);
+ return Expression.Lambda>(Expression.AndAlso(expr1.Body, expr2Body!), expr1.Parameters);
}
///
@@ -120,16 +120,16 @@ public class ExpressionStarter
}
}
- public ExpressionStarter(Expression> exp) : this(false)
+ public ExpressionStarter(Expression>? exp) : this(false)
{
_predicate = exp;
}
/// The actual Predicate. It can only be set by calling Start.
private Expression> Predicate =>
- (IsStarted || !UseDefaultExpression) ? _predicate : DefaultExpression;
+ ((IsStarted || !UseDefaultExpression) ? _predicate : DefaultExpression)!;
- private Expression> _predicate;
+ private Expression>? _predicate;
/// Determines if the predicate is started.
public bool IsStarted => _predicate != null;
@@ -138,7 +138,7 @@ public class ExpressionStarter
public bool UseDefaultExpression => DefaultExpression != null;
/// The default expression
- public Expression> DefaultExpression { get; set; }
+ public Expression>? DefaultExpression { get; set; }
/// Set the Expression predicate
/// The first expression
@@ -165,7 +165,7 @@ public class ExpressionStarter
}
/// Show predicate string
- public override string ToString()
+ public override string? ToString()
{
return Predicate?.ToString();
}
@@ -176,7 +176,7 @@ public class ExpressionStarter
/// Allows this object to be implicitely converted to an Expression{Func{T, bool}}.
///
///
- public static implicit operator Expression>(ExpressionStarter right)
+ public static implicit operator Expression>?(ExpressionStarter? right)
{
return right?.Predicate;
}
@@ -185,7 +185,7 @@ public class ExpressionStarter
/// Allows this object to be implicitely converted to an Expression{Func{T, bool}}.
///
///
- public static implicit operator Func(ExpressionStarter right)
+ public static implicit operator Func?(ExpressionStarter? right)
{
return right == null ? null :
(right.IsStarted || right.UseDefaultExpression) ? right.Predicate.Compile() : null;
@@ -195,7 +195,7 @@ public class ExpressionStarter
/// Allows this object to be implicitely converted to an Expression{Func{T, bool}}.
///
///
- public static implicit operator ExpressionStarter(Expression> right)
+ public static implicit operator ExpressionStarter?(Expression>? right)
{
return right == null ? null : new ExpressionStarter(right);
}
@@ -240,7 +240,7 @@ public class ExpressionStarter
#if !(NET35)
///
- public string Name => Predicate.Name;
+ public string? Name => Predicate.Name;
///
public Type ReturnType => Predicate.ReturnType;
diff --git a/framework/src/Volo.Abp.Core/System/Reflection/AbpAssemblyExtensions.cs b/framework/src/Volo.Abp.Core/System/Reflection/AbpAssemblyExtensions.cs
index d8cf8c01ab..7f66460099 100644
--- a/framework/src/Volo.Abp.Core/System/Reflection/AbpAssemblyExtensions.cs
+++ b/framework/src/Volo.Abp.Core/System/Reflection/AbpAssemblyExtensions.cs
@@ -6,6 +6,6 @@ public static class AbpAssemblyExtensions
{
public static string GetFileVersion(this Assembly assembly)
{
- return FileVersionInfo.GetVersionInfo(assembly.Location).FileVersion;
+ return FileVersionInfo.GetVersionInfo(assembly.Location).FileVersion!;
}
}
diff --git a/framework/src/Volo.Abp.Core/System/Reflection/AbpMemberInfoExtensions.cs b/framework/src/Volo.Abp.Core/System/Reflection/AbpMemberInfoExtensions.cs
index 12bf926fbd..c0bb5694e3 100644
--- a/framework/src/Volo.Abp.Core/System/Reflection/AbpMemberInfoExtensions.cs
+++ b/framework/src/Volo.Abp.Core/System/Reflection/AbpMemberInfoExtensions.cs
@@ -14,7 +14,7 @@ public static class AbpMemberInfoExtensions
/// The member that will be checked for the attribute
/// Include inherited attributes
/// Returns the attribute object if found. Returns null if not found.
- public static TAttribute GetSingleAttributeOrNull(this MemberInfo memberInfo, bool inherit = true)
+ public static TAttribute? GetSingleAttributeOrNull(this MemberInfo memberInfo, bool inherit = true)
where TAttribute : Attribute
{
if (memberInfo == null)
@@ -32,7 +32,7 @@ public static class AbpMemberInfoExtensions
}
- public static TAttribute GetSingleAttributeOfTypeOrBaseTypesOrNull(this Type type, bool inherit = true)
+ public static TAttribute? GetSingleAttributeOfTypeOrBaseTypesOrNull(this Type type, bool inherit = true)
where TAttribute : Attribute
{
var attr = type.GetTypeInfo().GetSingleAttributeOrNull();
@@ -46,6 +46,6 @@ public static class AbpMemberInfoExtensions
return null;
}
- return type.GetTypeInfo().BaseType.GetSingleAttributeOfTypeOrBaseTypesOrNull(inherit);
+ return type.GetTypeInfo().BaseType?.GetSingleAttributeOfTypeOrBaseTypesOrNull(inherit);
}
}
diff --git a/framework/src/Volo.Abp.Core/Volo.Abp.Core.csproj b/framework/src/Volo.Abp.Core/Volo.Abp.Core.csproj
index 8bf90f7767..4cc06f5c98 100644
--- a/framework/src/Volo.Abp.Core/Volo.Abp.Core.csproj
+++ b/framework/src/Volo.Abp.Core/Volo.Abp.Core.csproj
@@ -5,6 +5,7 @@
netstandard2.0;netstandard2.1;net7.0
+ enable
Volo.Abp.Core
Volo.Abp.Core
$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/AbpApplicationBase.cs b/framework/src/Volo.Abp.Core/Volo/Abp/AbpApplicationBase.cs
index 609b880566..0ccff2db23 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/AbpApplicationBase.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/AbpApplicationBase.cs
@@ -19,13 +19,13 @@ public abstract class AbpApplicationBase : IAbpApplication
[NotNull]
public Type StartupModuleType { get; }
- public IServiceProvider ServiceProvider { get; private set; }
+ public IServiceProvider ServiceProvider { get; private set; } = default!;
public IServiceCollection Services { get; }
public IReadOnlyList Modules { get; }
- public string ApplicationName { get; }
+ public string? ApplicationName { get; }
public string InstanceId { get; } = Guid.NewGuid().ToString();
@@ -34,7 +34,7 @@ public abstract class AbpApplicationBase : IAbpApplication
internal AbpApplicationBase(
[NotNull] Type startupModuleType,
[NotNull] IServiceCollection services,
- [CanBeNull] Action optionsAction)
+ Action? optionsAction)
{
Check.NotNull(startupModuleType, nameof(startupModuleType));
Check.NotNull(services, nameof(services));
@@ -224,7 +224,7 @@ public abstract class AbpApplicationBase : IAbpApplication
{
if (module.Instance is AbpModule abpModule)
{
- abpModule.ServiceConfigurationContext = null;
+ abpModule.ServiceConfigurationContext = null!;
}
}
@@ -315,7 +315,7 @@ public abstract class AbpApplicationBase : IAbpApplication
{
if (module.Instance is AbpModule abpModule)
{
- abpModule.ServiceConfigurationContext = null;
+ abpModule.ServiceConfigurationContext = null!;
}
}
@@ -324,11 +324,11 @@ public abstract class AbpApplicationBase : IAbpApplication
TryToSetEnvironment(Services);
}
- private static string GetApplicationName(AbpApplicationCreationOptions options)
+ private static string? GetApplicationName(AbpApplicationCreationOptions options)
{
if (!string.IsNullOrWhiteSpace(options.ApplicationName))
{
- return options.ApplicationName;
+ return options.ApplicationName!;
}
var configuration = options.Services.GetConfigurationOrNull();
@@ -337,7 +337,7 @@ public abstract class AbpApplicationBase : IAbpApplication
var appNameConfig = configuration["ApplicationName"];
if (!string.IsNullOrWhiteSpace(appNameConfig))
{
- return appNameConfig;
+ return appNameConfig!;
}
}
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/AbpApplicationCreationOptions.cs b/framework/src/Volo.Abp.Core/Volo/Abp/AbpApplicationCreationOptions.cs
index e1f7f4c997..f0b8f0e06e 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/AbpApplicationCreationOptions.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/AbpApplicationCreationOptions.cs
@@ -21,11 +21,9 @@ public class AbpApplicationCreationOptions
public bool SkipConfigureServices { get; set; }
- [CanBeNull]
- public string ApplicationName { get; set; }
+ public string? ApplicationName { get; set; }
- [CanBeNull]
- public string Environment { get; set; }
+ public string? Environment { get; set; }
public AbpApplicationCreationOptions([NotNull] IServiceCollection services)
{
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/AbpApplicationFactory.cs b/framework/src/Volo.Abp.Core/Volo/Abp/AbpApplicationFactory.cs
index 3d64b39b7c..accf892f7e 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/AbpApplicationFactory.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/AbpApplicationFactory.cs
@@ -9,7 +9,7 @@ namespace Volo.Abp;
public static class AbpApplicationFactory
{
public async static Task CreateAsync(
- [CanBeNull] Action optionsAction = null)
+ Action? optionsAction = null)
where TStartupModule : IAbpModule
{
var app = Create(typeof(TStartupModule), options =>
@@ -23,7 +23,7 @@ public static class AbpApplicationFactory
public async static Task CreateAsync(
[NotNull] Type startupModuleType,
- [CanBeNull] Action optionsAction = null)
+ Action? optionsAction = null)
{
var app = new AbpApplicationWithInternalServiceProvider(startupModuleType, options =>
{
@@ -36,7 +36,7 @@ public static class AbpApplicationFactory
public async static Task CreateAsync(
[NotNull] IServiceCollection services,
- [CanBeNull] Action optionsAction = null)
+ Action? optionsAction = null)
where TStartupModule : IAbpModule
{
var app = Create(typeof(TStartupModule), services, options =>
@@ -51,7 +51,7 @@ public static class AbpApplicationFactory
public async static Task CreateAsync(
[NotNull] Type startupModuleType,
[NotNull] IServiceCollection services,
- [CanBeNull] Action optionsAction = null)
+ Action? optionsAction = null)
{
var app = new AbpApplicationWithExternalServiceProvider(startupModuleType, services, options =>
{
@@ -63,7 +63,7 @@ public static class AbpApplicationFactory
}
public static IAbpApplicationWithInternalServiceProvider Create(
- [CanBeNull] Action optionsAction = null)
+ Action? optionsAction = null)
where TStartupModule : IAbpModule
{
return Create(typeof(TStartupModule), optionsAction);
@@ -71,14 +71,14 @@ public static class AbpApplicationFactory
public static IAbpApplicationWithInternalServiceProvider Create(
[NotNull] Type startupModuleType,
- [CanBeNull] Action optionsAction = null)
+ Action? optionsAction = null)
{
return new AbpApplicationWithInternalServiceProvider(startupModuleType, optionsAction);
}
public static IAbpApplicationWithExternalServiceProvider Create(
[NotNull] IServiceCollection services,
- [CanBeNull] Action optionsAction = null)
+ Action? optionsAction = null)
where TStartupModule : IAbpModule
{
return Create(typeof(TStartupModule), services, optionsAction);
@@ -87,7 +87,7 @@ public static class AbpApplicationFactory
public static IAbpApplicationWithExternalServiceProvider Create(
[NotNull] Type startupModuleType,
[NotNull] IServiceCollection services,
- [CanBeNull] Action optionsAction = null)
+ Action? optionsAction = null)
{
return new AbpApplicationWithExternalServiceProvider(startupModuleType, services, optionsAction);
}
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/AbpApplicationWithExternalServiceProvider.cs b/framework/src/Volo.Abp.Core/Volo/Abp/AbpApplicationWithExternalServiceProvider.cs
index fbb9d611cf..d80e46c5d7 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/AbpApplicationWithExternalServiceProvider.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/AbpApplicationWithExternalServiceProvider.cs
@@ -10,7 +10,7 @@ internal class AbpApplicationWithExternalServiceProvider : AbpApplicationBase, I
public AbpApplicationWithExternalServiceProvider(
[NotNull] Type startupModuleType,
[NotNull] IServiceCollection services,
- [CanBeNull] Action optionsAction
+ Action? optionsAction
) : base(
startupModuleType,
services,
@@ -23,6 +23,7 @@ internal class AbpApplicationWithExternalServiceProvider : AbpApplicationBase, I
{
Check.NotNull(serviceProvider, nameof(serviceProvider));
+ // ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
if (ServiceProvider != null)
{
if (ServiceProvider != serviceProvider)
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/AbpApplicationWithInternalServiceProvider.cs b/framework/src/Volo.Abp.Core/Volo/Abp/AbpApplicationWithInternalServiceProvider.cs
index 5f09157fcc..c5e5eccc83 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/AbpApplicationWithInternalServiceProvider.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/AbpApplicationWithInternalServiceProvider.cs
@@ -7,11 +7,11 @@ namespace Volo.Abp;
internal class AbpApplicationWithInternalServiceProvider : AbpApplicationBase, IAbpApplicationWithInternalServiceProvider
{
- public IServiceScope ServiceScope { get; private set; }
+ public IServiceScope? ServiceScope { get; private set; }
public AbpApplicationWithInternalServiceProvider(
[NotNull] Type startupModuleType,
- [CanBeNull] Action optionsAction
+ Action? optionsAction
) : this(
startupModuleType,
new ServiceCollection(),
@@ -23,7 +23,7 @@ internal class AbpApplicationWithInternalServiceProvider : AbpApplicationBase, I
private AbpApplicationWithInternalServiceProvider(
[NotNull] Type startupModuleType,
[NotNull] IServiceCollection services,
- [CanBeNull] Action optionsAction
+ Action? optionsAction
) : base(
startupModuleType,
services,
@@ -34,6 +34,7 @@ internal class AbpApplicationWithInternalServiceProvider : AbpApplicationBase, I
public IServiceProvider CreateServiceProvider()
{
+ // ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
if (ServiceProvider != null)
{
return ServiceProvider;
@@ -42,7 +43,7 @@ internal class AbpApplicationWithInternalServiceProvider : AbpApplicationBase, I
ServiceScope = Services.BuildServiceProviderFromFactory().CreateScope();
SetServiceProvider(ServiceScope.ServiceProvider);
- return ServiceProvider;
+ return ServiceProvider!;
}
public async Task InitializeAsync()
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/AbpHostEnvironment.cs b/framework/src/Volo.Abp.Core/Volo/Abp/AbpHostEnvironment.cs
index a2682909a1..a16e563767 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/AbpHostEnvironment.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/AbpHostEnvironment.cs
@@ -2,5 +2,5 @@
public class AbpHostEnvironment : IAbpHostEnvironment
{
- public string EnvironmentName { get; set; }
+ public string? EnvironmentName { get; set; }
}
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/Bundling/BundleContext.cs b/framework/src/Volo.Abp.Core/Volo/Abp/Bundling/BundleContext.cs
index 70cf98303a..ab30160866 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/Bundling/BundleContext.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/Bundling/BundleContext.cs
@@ -14,7 +14,7 @@ public class BundleContext
}
public void Add(string source, bool excludeFromBundle = false,
- Dictionary additionalProperties = null)
+ Dictionary? additionalProperties = null)
{
var bundleDefinition = new BundleDefinition
{
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/Bundling/BundleDefinition.cs b/framework/src/Volo.Abp.Core/Volo/Abp/Bundling/BundleDefinition.cs
index 7fa2a70f85..750b11be75 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/Bundling/BundleDefinition.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/Bundling/BundleDefinition.cs
@@ -4,7 +4,7 @@ namespace Volo.Abp.Bundling;
public class BundleDefinition
{
- public string Source { get; set; }
+ public string Source { get; set; } = default!;
public Dictionary AdditionalProperties { get; set; }
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/BusinessException.cs b/framework/src/Volo.Abp.Core/Volo/Abp/BusinessException.cs
index 2faac22046..268985014f 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/BusinessException.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/BusinessException.cs
@@ -13,17 +13,17 @@ public class BusinessException : Exception,
IHasErrorDetails,
IHasLogLevel
{
- public string Code { get; set; }
+ public string? Code { get; set; }
- public string Details { get; set; }
+ public string? Details { get; set; }
public LogLevel LogLevel { get; set; }
public BusinessException(
- string code = null,
- string message = null,
- string details = null,
- Exception innerException = null,
+ string? code = null,
+ string? message = null,
+ string? details = null,
+ Exception? innerException = null,
LogLevel logLevel = LogLevel.Warning)
: base(message, innerException)
{
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/Check.cs b/framework/src/Volo.Abp.Core/Volo/Abp/Check.cs
index a2448190a5..dbb8dc20fb 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/Check.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/Check.cs
@@ -136,8 +136,8 @@ public static class Check
return type;
}
- public static string Length(
- [CanBeNull] string value,
+ public static string? Length(
+ string? value,
[InvokerParameterName][NotNull] string parameterName,
int maxLength,
int minLength = 0)
@@ -149,7 +149,7 @@ public static class Check
throw new ArgumentException(parameterName + " can not be null or empty!", parameterName);
}
- if (value.Length < minLength)
+ if (value!.Length < minLength)
{
throw new ArgumentException($"{parameterName} length must be equal to or bigger than {minLength}!", parameterName);
}
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/Content/IRemoteStreamContent.cs b/framework/src/Volo.Abp.Core/Volo/Abp/Content/IRemoteStreamContent.cs
index 6cefb68855..7d7cca4297 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/Content/IRemoteStreamContent.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/Content/IRemoteStreamContent.cs
@@ -5,7 +5,7 @@ namespace Volo.Abp.Content;
public interface IRemoteStreamContent : IDisposable
{
- string FileName { get; }
+ string? FileName { get; }
string ContentType { get; }
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/Content/RemoteStreamContent.cs b/framework/src/Volo.Abp.Core/Volo/Abp/Content/RemoteStreamContent.cs
index 02ca48a2b1..bc67fac38f 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/Content/RemoteStreamContent.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/Content/RemoteStreamContent.cs
@@ -8,13 +8,13 @@ public class RemoteStreamContent : IRemoteStreamContent
private readonly bool _disposeStream;
private bool _disposed;
- public virtual string FileName { get; }
+ public virtual string? FileName { get; }
public virtual string ContentType { get; } = "application/octet-stream";
public virtual long? ContentLength { get; }
- public RemoteStreamContent(Stream stream, string fileName = null, string contentType = null, long? readOnlyLength = null, bool disposeStream = true)
+ public RemoteStreamContent(Stream stream, string? fileName = null, string? contentType = null, long? readOnlyLength = null, bool disposeStream = true)
{
_stream = stream;
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/AbpLazyServiceProvider.cs b/framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/AbpLazyServiceProvider.cs
index a180592a01..431546a234 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/AbpLazyServiceProvider.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/AbpLazyServiceProvider.cs
@@ -28,12 +28,12 @@ public class AbpLazyServiceProvider :
return this.GetRequiredService(serviceType);
}
- public virtual T LazyGetService()
+ public virtual T? LazyGetService()
{
- return (T)LazyGetService(typeof(T));
+ return (T?)LazyGetService(typeof(T));
}
- public virtual object LazyGetService(Type serviceType)
+ public virtual object? LazyGetService(Type serviceType)
{
return GetService(serviceType);
}
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/CachedServiceProviderBase.cs b/framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/CachedServiceProviderBase.cs
index 21f2b1c516..5e8d9d251a 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/CachedServiceProviderBase.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/CachedServiceProviderBase.cs
@@ -6,26 +6,26 @@ namespace Volo.Abp.DependencyInjection;
public abstract class CachedServiceProviderBase : ICachedServiceProviderBase
{
protected IServiceProvider ServiceProvider { get; }
- protected ConcurrentDictionary> CachedServices { get; }
+ protected ConcurrentDictionary> CachedServices { get; }
protected CachedServiceProviderBase(IServiceProvider serviceProvider)
{
ServiceProvider = serviceProvider;
- CachedServices = new ConcurrentDictionary>();
- CachedServices.TryAdd(typeof(IServiceProvider), new Lazy(() => ServiceProvider));
+ CachedServices = new ConcurrentDictionary>();
+ CachedServices.TryAdd(typeof(IServiceProvider), new Lazy(() => ServiceProvider));
}
- public virtual object GetService(Type serviceType)
+ public virtual object? GetService(Type serviceType)
{
return CachedServices.GetOrAdd(
serviceType,
- _ => new Lazy(() => ServiceProvider.GetService(serviceType))
+ _ => new Lazy(() => ServiceProvider.GetService(serviceType))
).Value;
}
public T GetService(T defaultValue)
{
- return (T)GetService(typeof(T), defaultValue);
+ return (T)GetService(typeof(T), defaultValue!);
}
public object GetService(Type serviceType, object defaultValue)
@@ -42,7 +42,7 @@ public abstract class CachedServiceProviderBase : ICachedServiceProviderBase
{
return CachedServices.GetOrAdd(
serviceType,
- _ => new Lazy(() => factory(ServiceProvider))
- ).Value;
+ _ => new Lazy(() => factory(ServiceProvider))
+ ).Value!;
}
}
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/ConventionalRegistrarBase.cs b/framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/ConventionalRegistrarBase.cs
index dc116903df..c7190e6c4d 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/ConventionalRegistrarBase.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/ConventionalRegistrarBase.cs
@@ -52,12 +52,12 @@ public abstract class ConventionalRegistrarBase : IConventionalRegistrar
}
}
- protected virtual DependencyAttribute GetDependencyAttributeOrNull(Type type)
+ protected virtual DependencyAttribute? GetDependencyAttributeOrNull(Type type)
{
return type.GetCustomAttribute(true);
}
- protected virtual ServiceLifetime? GetLifeTimeOrNull(Type type, [CanBeNull] DependencyAttribute dependencyAttribute)
+ protected virtual ServiceLifetime? GetLifeTimeOrNull(Type type, DependencyAttribute? dependencyAttribute)
{
return dependencyAttribute?.Lifetime ?? GetServiceLifetimeFromClassHierarchy(type) ?? GetDefaultLifeTimeOrNull(type);
}
@@ -110,7 +110,7 @@ public abstract class ConventionalRegistrarBase : IConventionalRegistrar
{
return ServiceDescriptor.Describe(
exposingServiceType,
- provider => provider.GetService(redirectedType),
+ provider => provider.GetService(redirectedType)!,
lifeTime
);
}
@@ -123,7 +123,7 @@ public abstract class ConventionalRegistrarBase : IConventionalRegistrar
);
}
- protected virtual Type GetRedirectedTypeOrNull(
+ protected virtual Type? GetRedirectedTypeOrNull(
Type implementationType,
Type exposingServiceType,
List allExposingServiceTypes)
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/IAbpLazyServiceProvider.cs b/framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/IAbpLazyServiceProvider.cs
index cd5f1da67f..4d32c88f1b 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/IAbpLazyServiceProvider.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/IAbpLazyServiceProvider.cs
@@ -24,13 +24,13 @@ public interface IAbpLazyServiceProvider : ICachedServiceProviderBase
/// This method is equivalent of the GetService method.
/// It does exists for backward compatibility.
///
- T LazyGetService();
+ T? LazyGetService();
///
/// This method is equivalent of the GetService method.
/// It does exists for backward compatibility.
///
- object LazyGetService(Type serviceType);
+ object? LazyGetService(Type serviceType);
///
/// This method is equivalent of the method.
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/IObjectAccessor.cs b/framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/IObjectAccessor.cs
index 328b008f54..5286c4672e 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/IObjectAccessor.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/IObjectAccessor.cs
@@ -4,6 +4,5 @@ namespace Volo.Abp.DependencyInjection;
public interface IObjectAccessor
{
- [CanBeNull]
- T Value { get; }
+ T? Value { get; }
}
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/ObjectAccessor.cs b/framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/ObjectAccessor.cs
index 3e3014507c..612732b370 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/ObjectAccessor.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/ObjectAccessor.cs
@@ -4,14 +4,14 @@ namespace Volo.Abp.DependencyInjection;
public class ObjectAccessor : IObjectAccessor
{
- public T Value { get; set; }
+ public T? Value { get; set; }
public ObjectAccessor()
{
}
- public ObjectAccessor([CanBeNull] T obj)
+ public ObjectAccessor(T? obj)
{
Value = obj;
}
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/RootServiceProvider.cs b/framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/RootServiceProvider.cs
index cbb6fb8984..a406bc5597 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/RootServiceProvider.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/RootServiceProvider.cs
@@ -9,10 +9,10 @@ public class RootServiceProvider : IRootServiceProvider, ISingletonDependency
public RootServiceProvider(IObjectAccessor objectAccessor)
{
- ServiceProvider = objectAccessor.Value;
+ ServiceProvider = objectAccessor.Value!;
}
- public virtual object GetService(Type serviceType)
+ public virtual object? GetService(Type serviceType)
{
return ServiceProvider.GetService(serviceType);
}
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/DisposeAction.cs b/framework/src/Volo.Abp.Core/Volo/Abp/DisposeAction.cs
index 0bb9cf46a8..7edb18485c 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/DisposeAction.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/DisposeAction.cs
@@ -37,8 +37,7 @@ public class DisposeAction : IDisposable
{
private readonly Action _action;
- [CanBeNull]
- private readonly T _parameter;
+ private readonly T? _parameter;
///
/// Creates a new object.
@@ -55,6 +54,9 @@ public class DisposeAction : IDisposable
public void Dispose()
{
- _action(_parameter);
+ if (_parameter != null)
+ {
+ _action(_parameter);
+ }
}
}
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/DynamicProxy/ProxyHelper.cs b/framework/src/Volo.Abp.Core/Volo/Abp/DynamicProxy/ProxyHelper.cs
index 2bf147573f..5b4f6c6349 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/DynamicProxy/ProxyHelper.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/DynamicProxy/ProxyHelper.cs
@@ -28,7 +28,7 @@ public static class ProxyHelper
return obj;
}
- return targetField.GetValue(obj);
+ return targetField.GetValue(obj)!;
}
public static Type GetUnProxiedType(object obj)
@@ -36,15 +36,12 @@ public static class ProxyHelper
if (obj.GetType().Namespace == ProxyNamespace)
{
var target = UnProxy(obj);
- if (target != null)
+ if (target == obj)
{
- if (target == obj)
- {
- return obj.GetType().GetTypeInfo().BaseType;
- }
-
- return target.GetType();
+ return obj.GetType().GetTypeInfo().BaseType!;
}
+
+ return target.GetType();
}
return obj.GetType();
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/ExceptionHandling/IHasErrorCode.cs b/framework/src/Volo.Abp.Core/Volo/Abp/ExceptionHandling/IHasErrorCode.cs
index 6ab509230d..10f6d39c0b 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/ExceptionHandling/IHasErrorCode.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/ExceptionHandling/IHasErrorCode.cs
@@ -2,5 +2,5 @@
public interface IHasErrorCode
{
- string Code { get; }
+ string? Code { get; }
}
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/ExceptionHandling/IHasErrorDetails.cs b/framework/src/Volo.Abp.Core/Volo/Abp/ExceptionHandling/IHasErrorDetails.cs
index aa79ec6fd6..c6e7214031 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/ExceptionHandling/IHasErrorDetails.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/ExceptionHandling/IHasErrorDetails.cs
@@ -2,5 +2,5 @@ namespace Volo.Abp.ExceptionHandling;
public interface IHasErrorDetails
{
- string Details { get; }
+ string? Details { get; }
}
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/IAbpHostEnvironment.cs b/framework/src/Volo.Abp.Core/Volo/Abp/IAbpHostEnvironment.cs
index 383361b9ed..2d111173ea 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/IAbpHostEnvironment.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/IAbpHostEnvironment.cs
@@ -2,5 +2,5 @@
public interface IAbpHostEnvironment
{
- string EnvironmentName { get; set; }
+ string? EnvironmentName { get; set; }
}
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/IApplicationInfoAccessor.cs b/framework/src/Volo.Abp.Core/Volo/Abp/IApplicationInfoAccessor.cs
index 01d20cfbc7..f9b45a4515 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/IApplicationInfoAccessor.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/IApplicationInfoAccessor.cs
@@ -9,8 +9,7 @@ public interface IApplicationInfoAccessor
/// This is useful for systems with multiple applications, to distinguish
/// resources of the applications located together.
///
- [CanBeNull]
- string ApplicationName { get; }
+ string? ApplicationName { get; }
///
/// A unique identifier for this application instance.
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/IO/FileHelper.cs b/framework/src/Volo.Abp.Core/Volo/Abp/IO/FileHelper.cs
index cfd9407470..c4daaed745 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/IO/FileHelper.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/IO/FileHelper.cs
@@ -36,8 +36,7 @@ public static class FileHelper
/// Returns extension without dot.
/// Returns null if given does not include dot.
///
- [CanBeNull]
- public static string GetExtension([NotNull] string fileNameWithExtension)
+ public static string? GetExtension([NotNull] string fileNameWithExtension)
{
Check.NotNull(fileNameWithExtension, nameof(fileNameWithExtension));
@@ -90,7 +89,7 @@ public static class FileHelper
/// Indicates FileStream options. Default is Asynchronous (The file is to be used for asynchronous reading.) and SequentialScan (The file is to be accessed sequentially from beginning to end.)
/// A string containing all lines of the file.
public static async Task ReadAllLinesAsync(string path,
- Encoding encoding = null,
+ Encoding? encoding = null,
FileMode fileMode = FileMode.Open,
FileAccess fileAccess = FileAccess.Read,
FileShare fileShare = FileShare.Read,
@@ -114,7 +113,7 @@ public static class FileHelper
{
using (var reader = new StreamReader(stream, encoding))
{
- string line;
+ string? line;
while ((line = await reader.ReadLineAsync()) != null)
{
lines.Add(line);
@@ -134,6 +133,6 @@ public static class FileHelper
{
var content = await ReadAllBytesAsync(path);
- return StringHelper.ConvertFromBytesWithoutBom(content);
+ return StringHelper.ConvertFromBytesWithoutBom(content)!;
}
}
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/Localization/CultureHelper.cs b/framework/src/Volo.Abp.Core/Volo/Abp/Localization/CultureHelper.cs
index d2e15fdf25..7f12dce8bd 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/Localization/CultureHelper.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/Localization/CultureHelper.cs
@@ -7,7 +7,7 @@ namespace Volo.Abp.Localization;
public static class CultureHelper
{
- public static IDisposable Use([NotNull] string culture, string uiCulture = null)
+ public static IDisposable Use([NotNull] string culture, string? uiCulture = null)
{
Check.NotNull(culture, nameof(culture));
@@ -19,7 +19,7 @@ public static class CultureHelper
);
}
- public static IDisposable Use([NotNull] CultureInfo culture, CultureInfo uiCulture = null)
+ public static IDisposable Use([NotNull] CultureInfo culture, CultureInfo? uiCulture = null)
{
Check.NotNull(culture, nameof(culture));
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/Logging/AbpInitLogEntry.cs b/framework/src/Volo.Abp.Core/Volo/Abp/Logging/AbpInitLogEntry.cs
index 3624f1da2e..ea17388b9f 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/Logging/AbpInitLogEntry.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/Logging/AbpInitLogEntry.cs
@@ -9,11 +9,11 @@ public class AbpInitLogEntry
public EventId EventId { get; set; }
- public object State { get; set; }
+ public object State { get; set; } = default!;
- public Exception Exception { get; set; }
+ public Exception? Exception { get; set; }
- public Func Formatter { get; set; }
+ public Func Formatter { get; set; } = default!;
public string Message => Formatter(State, Exception);
}
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/Logging/DefaultInitLogger.cs b/framework/src/Volo.Abp.Core/Volo/Abp/Logging/DefaultInitLogger.cs
index ca6901a628..98264aab74 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/Logging/DefaultInitLogger.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/Logging/DefaultInitLogger.cs
@@ -13,13 +13,13 @@ public class DefaultInitLogger : IInitLogger
Entries = new List();
}
- public virtual void Log(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func formatter)
+ public virtual void Log(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func formatter)
{
Entries.Add(new AbpInitLogEntry
{
LogLevel = logLevel,
EventId = eventId,
- State = state,
+ State = state!,
Exception = exception,
Formatter = (s, e) => formatter((TState)s, e),
});
@@ -30,7 +30,7 @@ public class DefaultInitLogger : IInitLogger
return logLevel != LogLevel.None;
}
- public virtual IDisposable BeginScope(TState state)
+ public virtual IDisposable BeginScope(TState state) where TState : notnull
{
return NullDisposable.Instance;
}
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/Modularity/AbpModule.cs b/framework/src/Volo.Abp.Core/Volo/Abp/Modularity/AbpModule.cs
index ae2bec3112..11e69bd920 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/Modularity/AbpModule.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/Modularity/AbpModule.cs
@@ -29,7 +29,7 @@ public abstract class AbpModule :
internal set => _serviceConfigurationContext = value;
}
- private ServiceConfigurationContext _serviceConfigurationContext;
+ private ServiceConfigurationContext? _serviceConfigurationContext;
public virtual Task PreConfigureServicesAsync(ServiceConfigurationContext context)
{
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/Modularity/DependsOnAttribute.cs b/framework/src/Volo.Abp.Core/Volo/Abp/Modularity/DependsOnAttribute.cs
index eefa03a438..89970859e8 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/Modularity/DependsOnAttribute.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/Modularity/DependsOnAttribute.cs
@@ -12,7 +12,7 @@ public class DependsOnAttribute : Attribute, IDependedTypesProvider
[NotNull]
public Type[] DependedTypes { get; }
- public DependsOnAttribute(params Type[] dependedTypes)
+ public DependsOnAttribute(params Type[]? dependedTypes)
{
DependedTypes = dependedTypes ?? new Type[0];
}
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/Modularity/ModuleLoader.cs b/framework/src/Volo.Abp.Core/Volo/Abp/Modularity/ModuleLoader.cs
index a44bf0cf22..5a2f31a972 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/Modularity/ModuleLoader.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/Modularity/ModuleLoader.cs
@@ -85,7 +85,7 @@ public class ModuleLoader : IModuleLoader
protected virtual IAbpModule CreateAndRegisterModule(IServiceCollection services, Type moduleType)
{
- var module = (IAbpModule)Activator.CreateInstance(moduleType);
+ var module = (IAbpModule)Activator.CreateInstance(moduleType)!;
services.AddSingleton(moduleType, module);
return module;
}
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/Modularity/PlugIns/FilePlugInSource.cs b/framework/src/Volo.Abp.Core/Volo/Abp/Modularity/PlugIns/FilePlugInSource.cs
index 9a0d3a47f6..49132629d0 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/Modularity/PlugIns/FilePlugInSource.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/Modularity/PlugIns/FilePlugInSource.cs
@@ -8,7 +8,7 @@ public class FilePlugInSource : IPlugInSource
{
public string[] FilePaths { get; }
- public FilePlugInSource(params string[] filePaths)
+ public FilePlugInSource(params string[]? filePaths)
{
FilePaths = filePaths ?? new string[0];
}
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/Modularity/PlugIns/FolderPlugInSource.cs b/framework/src/Volo.Abp.Core/Volo/Abp/Modularity/PlugIns/FolderPlugInSource.cs
index d1756ef3c8..0dec6db303 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/Modularity/PlugIns/FolderPlugInSource.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/Modularity/PlugIns/FolderPlugInSource.cs
@@ -15,7 +15,7 @@ public class FolderPlugInSource : IPlugInSource
public SearchOption SearchOption { get; set; }
- public Func Filter { get; set; }
+ public Func? Filter { get; set; }
public FolderPlugInSource(
[NotNull] string folder,
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/Modularity/PlugIns/TypePlugInSource.cs b/framework/src/Volo.Abp.Core/Volo/Abp/Modularity/PlugIns/TypePlugInSource.cs
index 78065f5442..78f9a215ab 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/Modularity/PlugIns/TypePlugInSource.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/Modularity/PlugIns/TypePlugInSource.cs
@@ -7,7 +7,7 @@ public class TypePlugInSource : IPlugInSource
{
private readonly Type[] _moduleTypes;
- public TypePlugInSource(params Type[] moduleTypes)
+ public TypePlugInSource(params Type[]? moduleTypes)
{
_moduleTypes = moduleTypes ?? new Type[0];
}
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/Modularity/ServiceConfigurationContext.cs b/framework/src/Volo.Abp.Core/Volo/Abp/Modularity/ServiceConfigurationContext.cs
index efb2f5fc74..6141777cec 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/Modularity/ServiceConfigurationContext.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/Modularity/ServiceConfigurationContext.cs
@@ -8,7 +8,7 @@ public class ServiceConfigurationContext
{
public IServiceCollection Services { get; }
- public IDictionary Items { get; }
+ public IDictionary Items { get; }
///
/// Gets/sets arbitrary named objects those can be stored during
@@ -19,7 +19,7 @@ public class ServiceConfigurationContext
///
///
///
- public object this[string key] {
+ public object? this[string key] {
get => Items.GetOrDefault(key);
set => Items[key] = value;
}
@@ -27,6 +27,6 @@ public class ServiceConfigurationContext
public ServiceConfigurationContext([NotNull] IServiceCollection services)
{
Services = Check.NotNull(services, nameof(services));
- Items = new Dictionary();
+ Items = new Dictionary();
}
}
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/NameValue.cs b/framework/src/Volo.Abp.Core/Volo/Abp/NameValue.cs
index 224976b3d9..721d6330ad 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/NameValue.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/NameValue.cs
@@ -29,12 +29,12 @@ public class NameValue
///
/// Name.
///
- public string Name { get; set; }
+ public string Name { get; set; } = default!;
///
/// Value.
///
- public T Value { get; set; }
+ public T Value { get; set; } = default!;
public NameValue()
{
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/ObjectHelper.cs b/framework/src/Volo.Abp.Core/Volo/Abp/ObjectHelper.cs
index a8471b90c4..3ba332afab 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/ObjectHelper.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/ObjectHelper.cs
@@ -9,8 +9,8 @@ namespace Volo.Abp;
public static class ObjectHelper
{
- private static readonly ConcurrentDictionary CachedObjectProperties =
- new ConcurrentDictionary();
+ private static readonly ConcurrentDictionary CachedObjectProperties =
+ new ConcurrentDictionary();
public static void TrySetProperty(
TObject obj,
@@ -25,9 +25,9 @@ public static class ObjectHelper
TObject obj,
Expression> propertySelector,
Func valueFactory,
- params Type[] ignoreAttributeTypes)
+ params Type[]? ignoreAttributeTypes)
{
- var cacheKey = $"{obj.GetType().FullName}-" +
+ var cacheKey = $"{obj?.GetType().FullName}-" +
$"{propertySelector}-" +
$"{(ignoreAttributeTypes != null ? "-" + string.Join("-", ignoreAttributeTypes.Select(x => x.FullName)) : "")}";
@@ -40,7 +40,7 @@ public static class ObjectHelper
var memberExpression = propertySelector.Body.As();
- var propertyInfo = obj.GetType().GetProperties().FirstOrDefault(x =>
+ var propertyInfo = obj?.GetType().GetProperties().FirstOrDefault(x =>
x.Name == memberExpression.Member.Name &&
x.GetSetMethod(true) != null);
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/Options/AbpOptionsFactory.cs b/framework/src/Volo.Abp.Core/Volo/Abp/Options/AbpOptionsFactory.cs
index 754d3914ad..1f86e73eb3 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/Options/AbpOptionsFactory.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/Options/AbpOptionsFactory.cs
@@ -9,7 +9,7 @@ public class AbpOptionsFactory : IOptionsFactory where TOpti
{
private readonly IEnumerable> _setups;
private readonly IEnumerable> _postConfigures;
- private readonly IEnumerable> _validations;
+ private readonly IEnumerable>? _validations;
public AbpOptionsFactory(
IEnumerable> setups,
@@ -22,7 +22,7 @@ public class AbpOptionsFactory : IOptionsFactory where TOpti
public AbpOptionsFactory(
IEnumerable> setups,
IEnumerable> postConfigures,
- IEnumerable> validations)
+ IEnumerable>? validations)
{
_setups = setups;
_postConfigures = postConfigures;
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/Reflection/AssemblyHelper.cs b/framework/src/Volo.Abp.Core/Volo/Abp/Reflection/AssemblyHelper.cs
index 8b855476e4..8e71f011fe 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/Reflection/AssemblyHelper.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/Reflection/AssemblyHelper.cs
@@ -31,7 +31,7 @@ internal static class AssemblyHelper
}
catch (ReflectionTypeLoadException ex)
{
- return ex.Types;
+ return ex.Types!;
}
}
}
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/Reflection/ReflectionHelper.cs b/framework/src/Volo.Abp.Core/Volo/Abp/Reflection/ReflectionHelper.cs
index bb10a13a68..ab26313736 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/Reflection/ReflectionHelper.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/Reflection/ReflectionHelper.cs
@@ -80,7 +80,7 @@ public static class ReflectionHelper
/// MemberInfo
/// Default value (null as default)
/// Inherit attribute from base classes
- public static TAttribute GetSingleAttributeOrDefault(MemberInfo memberInfo, TAttribute defaultValue = default, bool inherit = true)
+ public static TAttribute? GetSingleAttributeOrDefault(MemberInfo memberInfo, TAttribute? defaultValue = default, bool inherit = true)
where TAttribute : Attribute
{
//Get attribute on the member
@@ -100,7 +100,7 @@ public static class ReflectionHelper
/// MemberInfo
/// Default value (null as default)
/// Inherit attribute from base classes
- public static TAttribute GetSingleAttributeOfMemberOrDeclaringTypeOrDefault(MemberInfo memberInfo, TAttribute defaultValue = default, bool inherit = true)
+ public static TAttribute? GetSingleAttributeOfMemberOrDeclaringTypeOrDefault(MemberInfo memberInfo, TAttribute? defaultValue = default, bool inherit = true)
where TAttribute : class
{
return memberInfo.GetCustomAttributes(true).OfType().FirstOrDefault()
@@ -128,7 +128,7 @@ public static class ReflectionHelper
///
/// Gets value of a property by it's full path from given object
///
- public static object GetValueByPath(object obj, Type objectType, string propertyPath)
+ public static object? GetValueByPath(object obj, Type objectType, string propertyPath)
{
var value = obj;
var currentType = objectType;
@@ -167,7 +167,7 @@ public static class ReflectionHelper
{
var currentType = objectType;
PropertyInfo property;
- var objectPath = currentType.FullName;
+ var objectPath = currentType.FullName!;
var absolutePropertyPath = propertyPath;
if (absolutePropertyPath.StartsWith(objectPath))
{
@@ -178,19 +178,19 @@ public static class ReflectionHelper
if (properties.Length == 1)
{
- property = objectType.GetProperty(properties.First());
+ property = objectType.GetProperty(properties.First())!;
property.SetValue(obj, value);
return;
}
for (int i = 0; i < properties.Length - 1; i++)
{
- property = currentType.GetProperty(properties[i]);
- obj = property.GetValue(obj, null);
+ property = currentType.GetProperty(properties[i])!;
+ obj = property.GetValue(obj, null)!;
currentType = property.PropertyType;
}
- property = currentType.GetProperty(properties.Last());
+ property = currentType.GetProperty(properties.Last())!;
property.SetValue(obj, value);
}
@@ -215,7 +215,7 @@ public static class ReflectionHelper
constants.AddRange(targetType.GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy)
.Where(x => x.IsLiteral && !x.IsInitOnly)
- .Select(x => x.GetValue(null).ToString()));
+ .Select(x => x.GetValue(null)!.ToString()!));
var nestedTypes = targetType.GetNestedTypes(BindingFlags.Public);
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/Reflection/TypeHelper.cs b/framework/src/Volo.Abp.Core/Volo/Abp/Reflection/TypeHelper.cs
index 4828dc1b32..b439a5a07b 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/Reflection/TypeHelper.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/Reflection/TypeHelper.cs
@@ -43,7 +43,7 @@ public static class TypeHelper
return NonNullablePrimitiveTypes.Contains(type);
}
- public static bool IsFunc(object obj)
+ public static bool IsFunc(object? obj)
{
if (obj == null)
{
@@ -59,7 +59,7 @@ public static class TypeHelper
return type.GetGenericTypeDefinition() == typeof(Func<>);
}
- public static bool IsFunc(object obj)
+ public static bool IsFunc(object? obj)
{
return obj != null && obj.GetType() == typeof(Func);
}
@@ -88,13 +88,13 @@ public static class TypeHelper
{
if (t.GetGenericArguments().Length > 0 && t.GetGenericTypeDefinition() == typeof(Nullable<>))
{
- return t.GetGenericArguments().FirstOrDefault();
+ return t.GetGenericArguments().First();
}
return t;
}
- public static bool IsEnumerable(Type type, out Type itemType, bool includePrimitives = true)
+ public static bool IsEnumerable(Type type, out Type? itemType, bool includePrimitives = true)
{
if (!includePrimitives && IsPrimitiveExtended(type))
{
@@ -119,7 +119,7 @@ public static class TypeHelper
return false;
}
- public static bool IsDictionary(Type type, out Type keyType, out Type valueType)
+ public static bool IsDictionary(Type type, out Type? keyType, out Type? valueType)
{
var dictionaryTypes = ReflectionHelper
.GetImplementedGenericTypes(
@@ -167,12 +167,12 @@ public static class TypeHelper
type == typeof(Guid);
}
- public static T GetDefaultValue()
+ public static T? GetDefaultValue()
{
return default;
}
- public static object GetDefaultValue(Type type)
+ public static object? GetDefaultValue(Type type)
{
if (type.IsValueType)
{
@@ -194,7 +194,8 @@ public static class TypeHelper
if (type.IsGenericType)
{
var genericType = type.GetGenericTypeDefinition();
- return $"{genericType.FullName.Left(genericType.FullName.IndexOf('`'))}<{type.GenericTypeArguments.Select(GetFullNameHandlingNullableAndGenerics).JoinAsString(",")}>";
+ var genericTypeFullName = genericType.FullName!;
+ return $"{genericTypeFullName.Left(genericTypeFullName.IndexOf('`'))}<{type.GenericTypeArguments.Select(GetFullNameHandlingNullableAndGenerics).JoinAsString(",")}>";
}
return type.FullName ?? type.Name;
@@ -212,7 +213,8 @@ public static class TypeHelper
if (type.IsGenericType)
{
var genericType = type.GetGenericTypeDefinition();
- return $"{genericType.FullName.Left(genericType.FullName.IndexOf('`'))}<{type.GenericTypeArguments.Select(GetSimplifiedName).JoinAsString(",")}>";
+ var genericTypeFullName = genericType.FullName!;
+ return $"{genericTypeFullName.Left(genericTypeFullName.IndexOf('`'))}<{type.GenericTypeArguments.Select(GetSimplifiedName).JoinAsString(",")}>";
}
if (type == typeof(string))
@@ -303,12 +305,12 @@ public static class TypeHelper
return type.FullName ?? type.Name;
}
- public static object ConvertFromString(string value)
+ public static object? ConvertFromString(string value)
{
return ConvertFromString(typeof(TTargetType), value);
}
- public static object ConvertFromString(Type targetType, string value)
+ public static object? ConvertFromString(Type targetType, string? value)
{
if (value == null)
{
@@ -354,7 +356,7 @@ public static class TypeHelper
{
return TypeDescriptor
.GetConverter(targetType)
- .ConvertFrom(value);
+ .ConvertFrom(value)!;
}
public static Type StripNullable(Type type)
@@ -364,7 +366,7 @@ public static class TypeHelper
: type;
}
- public static bool IsDefaultValue([CanBeNull] object obj)
+ public static bool IsDefaultValue(object? obj)
{
if (obj == null)
{
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/RemoteServiceAttribute.cs b/framework/src/Volo.Abp.Core/Volo/Abp/RemoteServiceAttribute.cs
index 7d2c3ac3a2..21ccb458bb 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/RemoteServiceAttribute.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/RemoteServiceAttribute.cs
@@ -22,7 +22,7 @@ public class RemoteServiceAttribute : Attribute //TODO: Can we move this to anot
/// Group names of all services of a module expected to be the same.
/// This name is also used to distinguish the service endpoint of this group.
///
- public string Name { get; set; }
+ public string Name { get; set; } = default!;
public RemoteServiceAttribute(bool isEnabled = true)
{
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/SimpleStateChecking/ISimpleStateCheckerSerializer.cs b/framework/src/Volo.Abp.Core/Volo/Abp/SimpleStateChecking/ISimpleStateCheckerSerializer.cs
index ffbed53cf7..96c0785d6e 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/SimpleStateChecking/ISimpleStateCheckerSerializer.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/SimpleStateChecking/ISimpleStateCheckerSerializer.cs
@@ -4,9 +4,9 @@ namespace Volo.Abp.SimpleStateChecking;
public interface ISimpleStateCheckerSerializer
{
- public string Serialize(ISimpleStateChecker checker)
+ public string? Serialize(ISimpleStateChecker checker)
where TState : IHasSimpleStateCheckers;
- public ISimpleStateChecker Deserialize(JsonObject jsonObject, TState state)
+ public ISimpleStateChecker? Deserialize(JsonObject jsonObject, TState state)
where TState : IHasSimpleStateCheckers;
}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/SimpleStateChecking/ISimpleStateCheckerSerializerContributor.cs b/framework/src/Volo.Abp.Core/Volo/Abp/SimpleStateChecking/ISimpleStateCheckerSerializerContributor.cs
index d65c90eee6..588e138f42 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/SimpleStateChecking/ISimpleStateCheckerSerializerContributor.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/SimpleStateChecking/ISimpleStateCheckerSerializerContributor.cs
@@ -5,11 +5,9 @@ namespace Volo.Abp.SimpleStateChecking;
public interface ISimpleStateCheckerSerializerContributor
{
- [CanBeNull]
- public string SerializeToJson(ISimpleStateChecker checker)
+ public string? SerializeToJson(ISimpleStateChecker checker)
where TState : IHasSimpleStateCheckers;
- [CanBeNull]
- public ISimpleStateChecker Deserialize(JsonObject jsonObject, TState state)
+ public ISimpleStateChecker? Deserialize(JsonObject jsonObject, TState state)
where TState : IHasSimpleStateCheckers;
}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/SimpleStateChecking/SimpleStateCheckerSerializer.cs b/framework/src/Volo.Abp.Core/Volo/Abp/SimpleStateChecking/SimpleStateCheckerSerializer.cs
index d5d931ffae..0cdd300050 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/SimpleStateChecking/SimpleStateCheckerSerializer.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/SimpleStateChecking/SimpleStateCheckerSerializer.cs
@@ -16,8 +16,7 @@ public class SimpleStateCheckerSerializer :
_contributors = contributors;
}
- [CanBeNull]
- public string Serialize(ISimpleStateChecker checker)
+ public string? Serialize(ISimpleStateChecker checker)
where TState : IHasSimpleStateCheckers
{
foreach (var contributor in _contributors)
@@ -32,8 +31,7 @@ public class SimpleStateCheckerSerializer :
return null;
}
- [CanBeNull]
- public ISimpleStateChecker Deserialize(JsonObject jsonObject, TState state)
+ public ISimpleStateChecker? Deserialize(JsonObject jsonObject, TState state)
where TState : IHasSimpleStateCheckers
{
foreach (var contributor in _contributors)
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/SimpleStateChecking/SimpleStateCheckerSerializerExtensions.cs b/framework/src/Volo.Abp.Core/Volo/Abp/SimpleStateChecking/SimpleStateCheckerSerializerExtensions.cs
index 3594261741..8d06c7cfc3 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/SimpleStateChecking/SimpleStateCheckerSerializerExtensions.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/SimpleStateChecking/SimpleStateCheckerSerializerExtensions.cs
@@ -7,7 +7,7 @@ namespace Volo.Abp.SimpleStateChecking;
public static class SimpleStateCheckerSerializerExtensions
{
- public static string Serialize(
+ public static string? Serialize(
this ISimpleStateCheckerSerializer serializer,
IList> stateCheckers)
where TState : IHasSimpleStateCheckers
@@ -73,7 +73,7 @@ public static class SimpleStateCheckerSerializerExtensions
return new[] { checker };
}
- var checkers = new List>();
+ var checkers = new List?>();
for (var i = 0; i < array.Count; i++)
{
@@ -85,6 +85,6 @@ public static class SimpleStateCheckerSerializerExtensions
checkers.Add(serializer.Deserialize(jsonObject, state));
}
- return checkers.Where(x => x != null).ToArray();
+ return checkers.Where(x => x != null).ToArray()!;
}
}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/Text/Formatting/FormattedStringValueExtracter.cs b/framework/src/Volo.Abp.Core/Volo/Abp/Text/Formatting/FormattedStringValueExtracter.cs
index 4cf476f56b..280fe100fe 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/Text/Formatting/FormattedStringValueExtracter.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/Text/Formatting/FormattedStringValueExtracter.cs
@@ -68,7 +68,7 @@ public class FormattedStringValueExtracter
Debug.Assert(previousToken != null, "previousToken can not be null since i > 0 here");
- result.Matches.Add(new NameValue(previousToken.Text, str.Substring(0, matchIndex)));
+ result.Matches.Add(new NameValue(previousToken!.Text, str.Substring(0, matchIndex)));
str = str.Substring(matchIndex + currentToken.Text.Length);
}
}
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/Text/StringHelper.cs b/framework/src/Volo.Abp.Core/Volo/Abp/Text/StringHelper.cs
index 6b84220257..d45baa86d7 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/Text/StringHelper.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/Text/StringHelper.cs
@@ -10,7 +10,7 @@ public class StringHelper
/// The byte[] to be converted to string
/// The encoding to get string. Default is UTF8
///
- public static string ConvertFromBytesWithoutBom(byte[] bytes, Encoding encoding = null)
+ public static string? ConvertFromBytesWithoutBom(byte[]? bytes, Encoding? encoding = null)
{
if (bytes == null)
{
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/Threading/InternalAsyncHelper.cs b/framework/src/Volo.Abp.Core/Volo/Abp/Threading/InternalAsyncHelper.cs
index 827d59c79f..48a468098c 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/Threading/InternalAsyncHelper.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/Threading/InternalAsyncHelper.cs
@@ -9,9 +9,9 @@ namespace Volo.Abp.Threading;
//TODO: Cache GetMethod reflection!
public static class InternalAsyncHelper
{
- public static async Task AwaitTaskWithFinally(Task actualReturnValue, Action finalAction)
+ public static async Task AwaitTaskWithFinally(Task actualReturnValue, Action finalAction)
{
- Exception exception = null;
+ Exception? exception = null;
try
{
@@ -28,9 +28,9 @@ public static class InternalAsyncHelper
}
}
- public static async Task AwaitTaskWithPostActionAndFinally(Task actualReturnValue, Func postAction, Action finalAction)
+ public static async Task AwaitTaskWithPostActionAndFinally(Task actualReturnValue, Func postAction, Action finalAction)
{
- Exception exception = null;
+ Exception? exception = null;
try
{
@@ -48,9 +48,9 @@ public static class InternalAsyncHelper
}
}
- public static async Task AwaitTaskWithPreActionAndPostActionAndFinally(Func actualReturnValue, Func preAction = null, Func postAction = null, Action finalAction = null)
+ public static async Task AwaitTaskWithPreActionAndPostActionAndFinally(Func actualReturnValue, Func? preAction = null, Func? postAction = null, Action? finalAction = null)
{
- Exception exception = null;
+ Exception? exception = null;
try
{
@@ -80,9 +80,9 @@ public static class InternalAsyncHelper
}
}
- public static async Task AwaitTaskWithFinallyAndGetResult(Task actualReturnValue, Action finalAction)
+ public static async Task AwaitTaskWithFinallyAndGetResult(Task actualReturnValue, Action finalAction)
{
- Exception exception = null;
+ Exception? exception = null;
try
{
@@ -103,14 +103,14 @@ public static class InternalAsyncHelper
{
return typeof(InternalAsyncHelper)
.GetTypeInfo()
- .GetMethod("AwaitTaskWithFinallyAndGetResult", BindingFlags.Public | BindingFlags.Static)
+ .GetMethod("AwaitTaskWithFinallyAndGetResult", BindingFlags.Public | BindingFlags.Static)!
.MakeGenericMethod(taskReturnType)
- .Invoke(null, new object[] { actualReturnValue, finalAction });
+ .Invoke(null, new object[] { actualReturnValue, finalAction })!;
}
- public static async Task AwaitTaskWithPostActionAndFinallyAndGetResult(Task actualReturnValue, Func postAction, Action finalAction)
+ public static async Task AwaitTaskWithPostActionAndFinallyAndGetResult(Task actualReturnValue, Func postAction, Action finalAction)
{
- Exception exception = null;
+ Exception? exception = null;
try
{
@@ -133,14 +133,14 @@ public static class InternalAsyncHelper
{
return typeof(InternalAsyncHelper)
.GetTypeInfo()
- .GetMethod("AwaitTaskWithPostActionAndFinallyAndGetResult", BindingFlags.Public | BindingFlags.Static)
+ .GetMethod("AwaitTaskWithPostActionAndFinallyAndGetResult", BindingFlags.Public | BindingFlags.Static)!
.MakeGenericMethod(taskReturnType)
- .Invoke(null, new object[] { actualReturnValue, action, finalAction });
+ .Invoke(null, new object[] { actualReturnValue, action, finalAction })!;
}
- public static async Task AwaitTaskWithPreActionAndPostActionAndFinallyAndGetResult(Func> actualReturnValue, Func preAction = null, Func postAction = null, Action finalAction = null)
+ public static async Task AwaitTaskWithPreActionAndPostActionAndFinallyAndGetResult(Func> actualReturnValue, Func