diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/DaprAspNetCore/AbpDaprEndpointRouteBuilderExtensions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/DaprAspNetCore/AbpDaprEndpointRouteBuilderExtensions.cs index b5866c5a68..24f68ef9ab 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/DaprAspNetCore/AbpDaprEndpointRouteBuilderExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/DaprAspNetCore/AbpDaprEndpointRouteBuilderExtensions.cs @@ -30,7 +30,7 @@ namespace Dapr /// /// An optional delegate used to configure the subscriptions. /// - public Func, Task> SubscriptionsCallback { get; set; } + public Func, Task>? SubscriptionsCallback { get; set; } } /// @@ -41,32 +41,32 @@ namespace Dapr /// /// Gets or sets the topic name. /// - public string Topic { get; set; } + public string Topic { get; set; } = default!; /// /// Gets or sets the pubsub name /// - public string PubsubName { get; set; } + public string PubsubName { get; set; } = default!; /// /// Gets or sets the route /// - public string Route { get; set; } + public string? Route { get; set; } /// /// Gets or sets the routes /// - public AbpRoutes Routes { get; set; } + public AbpRoutes? Routes { get; set; } /// /// Gets or sets the metadata. /// - public AbpMetadata Metadata { get; set; } + public AbpMetadata? Metadata { get; set; } /// /// Gets or sets the deadletter topic. /// - public string DeadLetterTopic { get; set; } + public string? DeadLetterTopic { get; set; } } /// @@ -99,12 +99,12 @@ namespace Dapr /// /// Gets or sets the default route /// - public string Default { get; set; } + public string? Default { get; set; } /// /// Gets or sets the routing rules /// - public List Rules { get; set; } + public List? Rules { get; set; } } /// @@ -115,12 +115,12 @@ namespace Dapr /// /// Gets or sets the CEL expression to match this route. /// - public string Match { get; set; } + public string Match { get; set; } = default!; /// /// Gets or sets the path of the route. /// - public string Path { get; set; } + public string Path { get; set; } = default!; } } @@ -166,7 +166,7 @@ namespace Microsoft.AspNetCore.Builder return CreateSubscribeEndPoint(endpoints, options); } - private static IEndpointConventionBuilder CreateSubscribeEndPoint(IEndpointRouteBuilder endpoints, AbpSubscribeOptions options = null) + private static IEndpointConventionBuilder CreateSubscribeEndPoint(IEndpointRouteBuilder endpoints, AbpSubscribeOptions? options = null) { if (endpoints is null) { @@ -175,7 +175,7 @@ namespace Microsoft.AspNetCore.Builder return endpoints.MapGet("dapr/subscribe", async context => { - var logger = context.RequestServices.GetRequiredService().CreateLogger("DaprTopicSubscription"); + var logger = context.RequestServices.GetService()?.CreateLogger("DaprTopicSubscription"); var dataSource = context.RequestServices.GetRequiredService(); var subscriptions = dataSource.Endpoints .OfType() @@ -185,7 +185,7 @@ namespace Microsoft.AspNetCore.Builder var topicMetadata = e.Metadata.GetOrderedMetadata(); var originalTopicMetadata = e.Metadata.GetOrderedMetadata(); - var subs = new List<(string PubsubName, string Name, string DeadLetterTopic, bool? EnableRawPayload, string Match, int Priority, Dictionary OriginalTopicMetadata, string MetadataSeparator, RoutePattern RoutePattern)>(); + var subs = new List<(string PubsubName, string Name, string? DeadLetterTopic, bool? EnableRawPayload, string Match, int Priority, Dictionary OriginalTopicMetadata, string? MetadataSeparator, RoutePattern RoutePattern)>(); for (int i = 0; i < topicMetadata.Count(); i++) { @@ -211,7 +211,7 @@ namespace Microsoft.AspNetCore.Builder { var first = e.First(); var rawPayload = e.Any(e => e.EnableRawPayload.GetValueOrDefault()); - var metadataSeparator = e.FirstOrDefault(e => !string.IsNullOrEmpty(e.MetadataSeparator)).MetadataSeparator ?? ","; + var metadataSeparator = e.FirstOrDefault(e => !string.IsNullOrEmpty(e.MetadataSeparator)).MetadataSeparator?.ToString() ?? ","; var rules = e.Where(e => !string.IsNullOrEmpty(e.Match)).ToList(); var defaultRoutes = e.Where(e => string.IsNullOrEmpty(e.Match)).Select(e => RoutePatternToString(e.RoutePattern)).ToList(); var defaultRoute = defaultRoutes.FirstOrDefault(); @@ -276,7 +276,7 @@ namespace Microsoft.AspNetCore.Builder .OrderBy(e => (e.PubsubName, e.Topic)) .ToList(); - await options?.SubscriptionsCallback(subscriptions); + await options?.SubscriptionsCallback!(subscriptions)!; await context.Response.WriteAsync(JsonSerializer.Serialize(subscriptions, new JsonSerializerOptions { diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus.csproj b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus.csproj index f31ded0e06..96b196b67f 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus.csproj +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus.csproj @@ -5,6 +5,8 @@ net7.0 + enable + Nullable diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/Controllers/AbpAspNetCoreMvcDaprEventsController.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/Controllers/AbpAspNetCoreMvcDaprEventsController.cs index b1d5bac7fb..946c39f59c 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/Controllers/AbpAspNetCoreMvcDaprEventsController.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/Controllers/AbpAspNetCoreMvcDaprEventsController.cs @@ -41,8 +41,8 @@ public class AbpAspNetCoreMvcDaprEventsController : AbpController } else { - var eventData = daprSerializer.Deserialize(data, distributedEventBus.GetEventType(topic)); - await distributedEventBus.TriggerHandlersAsync(distributedEventBus.GetEventType(topic), eventData); + var eventData = daprSerializer.Deserialize(data, distributedEventBus.GetEventType(topic!)); + await distributedEventBus.TriggerHandlersAsync(distributedEventBus.GetEventType(topic!), eventData); } return Ok(); diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo.Abp.AspNetCore.Mvc.Dapr.csproj b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo.Abp.AspNetCore.Mvc.Dapr.csproj index 03bb453ba2..1839113d06 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo.Abp.AspNetCore.Mvc.Dapr.csproj +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo.Abp.AspNetCore.Mvc.Dapr.csproj @@ -5,6 +5,8 @@ net7.0 + enable + Nullable diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo/Abp/AspNetCore/Mvc/Dapr/DaprAppApiTokenValidator.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo/Abp/AspNetCore/Mvc/Dapr/DaprAppApiTokenValidator.cs index dd0c6a5300..aa7d17072b 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo/Abp/AspNetCore/Mvc/Dapr/DaprAppApiTokenValidator.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo/Abp/AspNetCore/Mvc/Dapr/DaprAppApiTokenValidator.cs @@ -50,9 +50,9 @@ public class DaprAppApiTokenValidator : IDaprAppApiTokenValidator, ISingletonDep return expectedAppApiToken == headerAppApiToken; } - public virtual string GetDaprAppApiTokenOrNull() + public virtual string? GetDaprAppApiTokenOrNull() { - string apiTokenHeader = HttpContext.Request.Headers["dapr-api-token"]; + string? apiTokenHeader = HttpContext.Request.Headers["dapr-api-token"]; if (string.IsNullOrEmpty(apiTokenHeader) || apiTokenHeader.Length < 1) { return null; @@ -61,7 +61,7 @@ public class DaprAppApiTokenValidator : IDaprAppApiTokenValidator, ISingletonDep return apiTokenHeader; } - protected virtual string GetConfiguredAppApiTokenOrNull() + protected virtual string? GetConfiguredAppApiTokenOrNull() { return HttpContext .RequestServices diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo/Abp/AspNetCore/Mvc/Dapr/DaprHttpContextExtensions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo/Abp/AspNetCore/Mvc/Dapr/DaprHttpContextExtensions.cs index aa81765b12..e73eaec4f7 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo/Abp/AspNetCore/Mvc/Dapr/DaprHttpContextExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo/Abp/AspNetCore/Mvc/Dapr/DaprHttpContextExtensions.cs @@ -22,7 +22,7 @@ public static class DaprHttpContextExtensions .IsValidDaprAppApiToken(); } - public static string GetDaprAppApiTokenOrNull(HttpContext httpContext) + public static string? GetDaprAppApiTokenOrNull(HttpContext httpContext) { return httpContext .RequestServices diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo/Abp/AspNetCore/Mvc/Dapr/IDaprAppApiTokenValidator.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo/Abp/AspNetCore/Mvc/Dapr/IDaprAppApiTokenValidator.cs index 66fd833b77..f54f0aa8cf 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo/Abp/AspNetCore/Mvc/Dapr/IDaprAppApiTokenValidator.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo/Abp/AspNetCore/Mvc/Dapr/IDaprAppApiTokenValidator.cs @@ -6,5 +6,5 @@ public interface IDaprAppApiTokenValidator bool IsValidDaprAppApiToken(); - string GetDaprAppApiTokenOrNull(); + string? GetDaprAppApiTokenOrNull(); } diff --git a/framework/src/Volo.Abp.Imaging.Abstractions/Volo.Abp.Imaging.Abstractions.csproj b/framework/src/Volo.Abp.Imaging.Abstractions/Volo.Abp.Imaging.Abstractions.csproj index 6b7c0434ed..288f43c7d4 100644 --- a/framework/src/Volo.Abp.Imaging.Abstractions/Volo.Abp.Imaging.Abstractions.csproj +++ b/framework/src/Volo.Abp.Imaging.Abstractions/Volo.Abp.Imaging.Abstractions.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable Volo.Abp.Imaging.Abstractions $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; false diff --git a/framework/src/Volo.Abp.Imaging.Abstractions/Volo/Abp/Imaging/IImageCompressor.cs b/framework/src/Volo.Abp.Imaging.Abstractions/Volo/Abp/Imaging/IImageCompressor.cs index 949a3fb848..6d80cd1c6b 100644 --- a/framework/src/Volo.Abp.Imaging.Abstractions/Volo/Abp/Imaging/IImageCompressor.cs +++ b/framework/src/Volo.Abp.Imaging.Abstractions/Volo/Abp/Imaging/IImageCompressor.cs @@ -9,13 +9,13 @@ public interface IImageCompressor { Task> CompressAsync( Stream stream, - [CanBeNull] string mimeType = null, + string? mimeType = null, CancellationToken cancellationToken = default ); Task> CompressAsync( byte[] bytes, - [CanBeNull] string mimeType = null, + string? mimeType = null, CancellationToken cancellationToken = default ); } \ No newline at end of file diff --git a/framework/src/Volo.Abp.Imaging.Abstractions/Volo/Abp/Imaging/IImageCompressorContributor.cs b/framework/src/Volo.Abp.Imaging.Abstractions/Volo/Abp/Imaging/IImageCompressorContributor.cs index 84087d983a..7fc9362c77 100644 --- a/framework/src/Volo.Abp.Imaging.Abstractions/Volo/Abp/Imaging/IImageCompressorContributor.cs +++ b/framework/src/Volo.Abp.Imaging.Abstractions/Volo/Abp/Imaging/IImageCompressorContributor.cs @@ -9,10 +9,10 @@ public interface IImageCompressorContributor { Task> TryCompressAsync( Stream stream, - [CanBeNull] string mimeType = null, + string? mimeType = null, CancellationToken cancellationToken = default); Task> TryCompressAsync( byte[] bytes, - [CanBeNull] string mimeType = null, + string? mimeType = null, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/framework/src/Volo.Abp.Imaging.Abstractions/Volo/Abp/Imaging/IImageResizer.cs b/framework/src/Volo.Abp.Imaging.Abstractions/Volo/Abp/Imaging/IImageResizer.cs index c2ae1b62e9..2c9c2878ed 100644 --- a/framework/src/Volo.Abp.Imaging.Abstractions/Volo/Abp/Imaging/IImageResizer.cs +++ b/framework/src/Volo.Abp.Imaging.Abstractions/Volo/Abp/Imaging/IImageResizer.cs @@ -10,14 +10,14 @@ public interface IImageResizer Task> ResizeAsync( Stream stream, ImageResizeArgs resizeArgs, - [CanBeNull] string mimeType = null, + string? mimeType = null, CancellationToken cancellationToken = default ); Task> ResizeAsync( byte[] bytes, ImageResizeArgs resizeArgs, - [CanBeNull] string mimeType = null, + string? mimeType = null, CancellationToken cancellationToken = default ); } \ No newline at end of file diff --git a/framework/src/Volo.Abp.Imaging.Abstractions/Volo/Abp/Imaging/IImageResizerContributor.cs b/framework/src/Volo.Abp.Imaging.Abstractions/Volo/Abp/Imaging/IImageResizerContributor.cs index fed4ce4a4c..a6603ea136 100644 --- a/framework/src/Volo.Abp.Imaging.Abstractions/Volo/Abp/Imaging/IImageResizerContributor.cs +++ b/framework/src/Volo.Abp.Imaging.Abstractions/Volo/Abp/Imaging/IImageResizerContributor.cs @@ -10,12 +10,12 @@ public interface IImageResizerContributor Task> TryResizeAsync( Stream stream, ImageResizeArgs resizeArgs, - [CanBeNull] string mimeType = null, + string? mimeType = null, CancellationToken cancellationToken = default); Task> TryResizeAsync( byte[] bytes, ImageResizeArgs resizeArgs, - [CanBeNull] string mimeType = null, + string? mimeType = null, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/framework/src/Volo.Abp.Imaging.Abstractions/Volo/Abp/Imaging/ImageCompressor.cs b/framework/src/Volo.Abp.Imaging.Abstractions/Volo/Abp/Imaging/ImageCompressor.cs index 11789776c7..d36a9d6ea0 100644 --- a/framework/src/Volo.Abp.Imaging.Abstractions/Volo/Abp/Imaging/ImageCompressor.cs +++ b/framework/src/Volo.Abp.Imaging.Abstractions/Volo/Abp/Imaging/ImageCompressor.cs @@ -23,7 +23,7 @@ public class ImageCompressor : IImageCompressor, ITransientDependency public virtual async Task> CompressAsync( [NotNull] Stream stream, - [CanBeNull] string mimeType = null, + string? mimeType = null, CancellationToken cancellationToken = default) { Check.NotNull(stream, nameof(stream)); @@ -45,7 +45,7 @@ public class ImageCompressor : IImageCompressor, ITransientDependency public virtual async Task> CompressAsync( [NotNull] byte[] bytes, - [CanBeNull] string mimeType = null, + string? mimeType = null, CancellationToken cancellationToken = default) { Check.NotNull(bytes, nameof(bytes)); diff --git a/framework/src/Volo.Abp.Imaging.Abstractions/Volo/Abp/Imaging/ImageResizer.cs b/framework/src/Volo.Abp.Imaging.Abstractions/Volo/Abp/Imaging/ImageResizer.cs index 139fc194dd..e2c4ad7d77 100644 --- a/framework/src/Volo.Abp.Imaging.Abstractions/Volo/Abp/Imaging/ImageResizer.cs +++ b/framework/src/Volo.Abp.Imaging.Abstractions/Volo/Abp/Imaging/ImageResizer.cs @@ -31,7 +31,7 @@ public class ImageResizer : IImageResizer, ITransientDependency public virtual async Task> ResizeAsync( [NotNull] Stream stream, ImageResizeArgs resizeArgs, - [CanBeNull] string mimeType = null, + string? mimeType = null, CancellationToken cancellationToken = default) { Check.NotNull(stream, nameof(stream)); @@ -56,7 +56,7 @@ public class ImageResizer : IImageResizer, ITransientDependency public virtual async Task> ResizeAsync( [NotNull] byte[] bytes, ImageResizeArgs resizeArgs, - [CanBeNull] string mimeType = null, + string? mimeType = null, CancellationToken cancellationToken = default) { Check.NotNull(bytes, nameof(bytes)); diff --git a/framework/src/Volo.Abp.Imaging.AspNetCore/Volo.Abp.Imaging.AspNetCore.csproj b/framework/src/Volo.Abp.Imaging.AspNetCore/Volo.Abp.Imaging.AspNetCore.csproj index d727d99a7c..8b8810e000 100644 --- a/framework/src/Volo.Abp.Imaging.AspNetCore/Volo.Abp.Imaging.AspNetCore.csproj +++ b/framework/src/Volo.Abp.Imaging.AspNetCore/Volo.Abp.Imaging.AspNetCore.csproj @@ -5,6 +5,8 @@ net7.0 + enable + Nullable Volo.Abp.Imaging.AspNetCore $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; false diff --git a/framework/src/Volo.Abp.Imaging.AspNetCore/Volo/Abp/Imaging/CompressImageAttribute.cs b/framework/src/Volo.Abp.Imaging.AspNetCore/Volo/Abp/Imaging/CompressImageAttribute.cs index 1ddd8822be..e49a5abc9f 100644 --- a/framework/src/Volo.Abp.Imaging.AspNetCore/Volo/Abp/Imaging/CompressImageAttribute.cs +++ b/framework/src/Volo.Abp.Imaging.AspNetCore/Volo/Abp/Imaging/CompressImageAttribute.cs @@ -28,7 +28,7 @@ public class CompressImageAttribute : ActionFilterAttribute foreach (var (key, value) in parameters) { - object compressedValue = value switch { + object? compressedValue = value switch { IFormFile file => await CompressImageAsync(file, imageCompressor), IRemoteStreamContent remoteStreamContent => await CompressImageAsync(remoteStreamContent, imageCompressor), Stream stream => await CompressImageAsync(stream, imageCompressor), diff --git a/framework/src/Volo.Abp.Imaging.AspNetCore/Volo/Abp/Imaging/ResizeImageAttribute.cs b/framework/src/Volo.Abp.Imaging.AspNetCore/Volo/Abp/Imaging/ResizeImageAttribute.cs index 799cd81877..65b59bef6f 100644 --- a/framework/src/Volo.Abp.Imaging.AspNetCore/Volo/Abp/Imaging/ResizeImageAttribute.cs +++ b/framework/src/Volo.Abp.Imaging.AspNetCore/Volo/Abp/Imaging/ResizeImageAttribute.cs @@ -41,7 +41,7 @@ public class ResizeImageAttribute : ActionFilterAttribute foreach (var (key, value) in parameters) { - object resizedValue = value switch { + object? resizedValue = value switch { IFormFile file => await ResizeImageAsync(file, imageResizer), IRemoteStreamContent remoteStreamContent => await ResizeImageAsync(remoteStreamContent, imageResizer), Stream stream => await ResizeImageAsync(stream, imageResizer), diff --git a/framework/src/Volo.Abp.Imaging.ImageSharp/Volo.Abp.Imaging.ImageSharp.csproj b/framework/src/Volo.Abp.Imaging.ImageSharp/Volo.Abp.Imaging.ImageSharp.csproj index d523a292ba..29d6a3944e 100644 --- a/framework/src/Volo.Abp.Imaging.ImageSharp/Volo.Abp.Imaging.ImageSharp.csproj +++ b/framework/src/Volo.Abp.Imaging.ImageSharp/Volo.Abp.Imaging.ImageSharp.csproj @@ -5,6 +5,8 @@ netstandard2.0; + enable + Nullable Volo.Abp.Imaging.ImageSharp $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; false diff --git a/framework/src/Volo.Abp.Imaging.ImageSharp/Volo/Abp/Imaging/ImageSharpImageCompressorContributor.cs b/framework/src/Volo.Abp.Imaging.ImageSharp/Volo/Abp/Imaging/ImageSharpImageCompressorContributor.cs index a54d006b30..8d2f29dd02 100644 --- a/framework/src/Volo.Abp.Imaging.ImageSharp/Volo/Abp/Imaging/ImageSharpImageCompressorContributor.cs +++ b/framework/src/Volo.Abp.Imaging.ImageSharp/Volo/Abp/Imaging/ImageSharpImageCompressorContributor.cs @@ -26,7 +26,7 @@ public class ImageSharpImageCompressorContributor : IImageCompressorContributor, public virtual async Task> TryCompressAsync( Stream stream, - [CanBeNull] string mimeType = null, + string? mimeType = null, CancellationToken cancellationToken = default) { if (!string.IsNullOrWhiteSpace(mimeType) && !CanCompress(mimeType)) @@ -54,7 +54,7 @@ public class ImageSharpImageCompressorContributor : IImageCompressorContributor, public virtual async Task> TryCompressAsync( byte[] bytes, - [CanBeNull] string mimeType = null, + string? mimeType = null, CancellationToken cancellationToken = default) { if (!string.IsNullOrWhiteSpace(mimeType) && !CanCompress(mimeType)) @@ -75,7 +75,7 @@ public class ImageSharpImageCompressorContributor : IImageCompressorContributor, return new ImageCompressResult(newBytes, result.State); } - protected virtual bool CanCompress(string mimeType) + protected virtual bool CanCompress(string? mimeType) { return mimeType switch { MimeTypes.Image.Jpeg => true, diff --git a/framework/src/Volo.Abp.Imaging.ImageSharp/Volo/Abp/Imaging/ImageSharpImageResizerContributor.cs b/framework/src/Volo.Abp.Imaging.ImageSharp/Volo/Abp/Imaging/ImageSharpImageResizerContributor.cs index d2ac92eaf7..92dbc25034 100644 --- a/framework/src/Volo.Abp.Imaging.ImageSharp/Volo/Abp/Imaging/ImageSharpImageResizerContributor.cs +++ b/framework/src/Volo.Abp.Imaging.ImageSharp/Volo/Abp/Imaging/ImageSharpImageResizerContributor.cs @@ -16,7 +16,7 @@ public class ImageSharpImageResizerContributor : IImageResizerContributor, ITran public virtual async Task> TryResizeAsync( Stream stream, ImageResizeArgs resizeArgs, - [CanBeNull] string mimeType = null, + string? mimeType = null, CancellationToken cancellationToken = default) { if (!string.IsNullOrWhiteSpace(mimeType) && !CanResize(mimeType)) @@ -58,7 +58,7 @@ public class ImageSharpImageResizerContributor : IImageResizerContributor, ITran public virtual async Task> TryResizeAsync( byte[] bytes, ImageResizeArgs resizeArgs, - [CanBeNull] string mimeType = null, + string? mimeType = null, CancellationToken cancellationToken = default) { if (!string.IsNullOrWhiteSpace(mimeType) && !CanResize(mimeType)) @@ -82,7 +82,7 @@ public class ImageSharpImageResizerContributor : IImageResizerContributor, ITran return new ImageResizeResult(newBytes, result.State); } - protected virtual bool CanResize(string mimeType) + protected virtual bool CanResize(string? mimeType) { return mimeType switch { MimeTypes.Image.Jpeg => true, diff --git a/framework/src/Volo.Abp.Imaging.MagickNet/Volo.Abp.Imaging.MagickNet.csproj b/framework/src/Volo.Abp.Imaging.MagickNet/Volo.Abp.Imaging.MagickNet.csproj index 535f689663..0e3581908a 100644 --- a/framework/src/Volo.Abp.Imaging.MagickNet/Volo.Abp.Imaging.MagickNet.csproj +++ b/framework/src/Volo.Abp.Imaging.MagickNet/Volo.Abp.Imaging.MagickNet.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable Volo.Abp.Imaging.MagicNet $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; false diff --git a/framework/src/Volo.Abp.Imaging.MagickNet/Volo/Abp/Imaging/MagickImageCompressorContributor.cs b/framework/src/Volo.Abp.Imaging.MagickNet/Volo/Abp/Imaging/MagickImageCompressorContributor.cs index a0900cd14a..3aba7f5000 100644 --- a/framework/src/Volo.Abp.Imaging.MagickNet/Volo/Abp/Imaging/MagickImageCompressorContributor.cs +++ b/framework/src/Volo.Abp.Imaging.MagickNet/Volo/Abp/Imaging/MagickImageCompressorContributor.cs @@ -28,7 +28,7 @@ public class MagickImageCompressorContributor : IImageCompressorContributor, ITr public virtual async Task> TryCompressAsync( Stream stream, - [CanBeNull] string mimeType = null, + string? mimeType = null, CancellationToken cancellationToken = default) { if (!string.IsNullOrWhiteSpace(mimeType) && !CanCompress(mimeType)) @@ -63,7 +63,7 @@ public class MagickImageCompressorContributor : IImageCompressorContributor, ITr public virtual async Task> TryCompressAsync( byte[] bytes, - [CanBeNull] string mimeType = null, + string? mimeType = null, CancellationToken cancellationToken = default) { if (!string.IsNullOrWhiteSpace(mimeType) && !CanCompress(mimeType)) @@ -86,7 +86,7 @@ public class MagickImageCompressorContributor : IImageCompressorContributor, ITr return new ImageCompressResult(newBytes, result.State); } - protected virtual bool CanCompress(string mimeType) + protected virtual bool CanCompress(string? mimeType) { return mimeType switch { MimeTypes.Image.Jpeg => true, diff --git a/framework/src/Volo.Abp.Imaging.MagickNet/Volo/Abp/Imaging/MagickImageResizerContributor.cs b/framework/src/Volo.Abp.Imaging.MagickNet/Volo/Abp/Imaging/MagickImageResizerContributor.cs index 9ffb6133e5..b71230e8bb 100644 --- a/framework/src/Volo.Abp.Imaging.MagickNet/Volo/Abp/Imaging/MagickImageResizerContributor.cs +++ b/framework/src/Volo.Abp.Imaging.MagickNet/Volo/Abp/Imaging/MagickImageResizerContributor.cs @@ -16,7 +16,7 @@ public class MagickImageResizerContributor : IImageResizerContributor, ITransien public virtual async Task> TryResizeAsync( Stream stream, ImageResizeArgs resizeArgs, - [CanBeNull] string mimeType = null, + string? mimeType = null, CancellationToken cancellationToken = default) { if (!mimeType.IsNullOrWhiteSpace() && !CanResize(mimeType)) @@ -54,7 +54,7 @@ public class MagickImageResizerContributor : IImageResizerContributor, ITransien public virtual Task> TryResizeAsync( byte[] bytes, ImageResizeArgs resizeArgs, - [CanBeNull] string mimeType = null, + string? mimeType = null, CancellationToken cancellationToken = default) { if (!mimeType.IsNullOrWhiteSpace() && !CanResize(mimeType)) @@ -74,7 +74,7 @@ public class MagickImageResizerContributor : IImageResizerContributor, ITransien return Task.FromResult(new ImageResizeResult(image.ToByteArray(), ImageProcessState.Done)); } - protected virtual bool CanResize(string mimeType) + protected virtual bool CanResize(string? mimeType) { return mimeType switch { MimeTypes.Image.Jpeg => true, diff --git a/framework/src/Volo.Abp.Json/Volo.Abp.Json.csproj b/framework/src/Volo.Abp.Json/Volo.Abp.Json.csproj index 40049addba..67dfaf2a28 100644 --- a/framework/src/Volo.Abp.Json/Volo.Abp.Json.csproj +++ b/framework/src/Volo.Abp.Json/Volo.Abp.Json.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable Volo.Abp.Json Volo.Abp.Json $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; diff --git a/framework/src/Volo.Abp.TextTemplating.Core/Volo.Abp.TextTemplating.Core.csproj b/framework/src/Volo.Abp.TextTemplating.Core/Volo.Abp.TextTemplating.Core.csproj index 8581d01dc4..f405dfe00c 100644 --- a/framework/src/Volo.Abp.TextTemplating.Core/Volo.Abp.TextTemplating.Core.csproj +++ b/framework/src/Volo.Abp.TextTemplating.Core/Volo.Abp.TextTemplating.Core.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable diff --git a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/AbpTemplateRenderer.cs b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/AbpTemplateRenderer.cs index 43cc829010..6e17d6701a 100644 --- a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/AbpTemplateRenderer.cs +++ b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/AbpTemplateRenderer.cs @@ -25,9 +25,9 @@ public class AbpTemplateRenderer : ITemplateRenderer, ITransientDependency public virtual async Task RenderAsync( string templateName, - object model = null, - string cultureName = null, - Dictionary globalContext = null) + object? model = null, + string? cultureName = null, + Dictionary? globalContext = null) { var templateDefinition = await TemplateDefinitionManager.GetAsync(templateName); @@ -38,7 +38,7 @@ public class AbpTemplateRenderer : ITemplateRenderer, ITransientDependency renderEngine = Options.DefaultRenderingEngine; } - var providerType = Options.RenderingEngines.GetOrDefault(renderEngine); + var providerType = Options.RenderingEngines.GetOrDefault(renderEngine!); if (providerType != null && typeof(ITemplateRenderingEngine).IsAssignableFrom(providerType)) { diff --git a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/AbpTextTemplatingOptions.cs b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/AbpTextTemplatingOptions.cs index 28b2e28ad0..40dac35703 100644 --- a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/AbpTextTemplatingOptions.cs +++ b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/AbpTextTemplatingOptions.cs @@ -10,7 +10,7 @@ public class AbpTextTemplatingOptions public ITypeList ContentContributors { get; } public IDictionary RenderingEngines { get; } - public string DefaultRenderingEngine { get; set; } + public string? DefaultRenderingEngine { get; set; } public HashSet DeletedTemplates { get; } diff --git a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/IDynamicTemplateDefinitionStore.cs b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/IDynamicTemplateDefinitionStore.cs index e275eb39be..205cae5824 100644 --- a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/IDynamicTemplateDefinitionStore.cs +++ b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/IDynamicTemplateDefinitionStore.cs @@ -10,5 +10,5 @@ public interface IDynamicTemplateDefinitionStore Task> GetAllAsync(); - Task GetOrNullAsync(string name); + Task GetOrNullAsync(string name); } diff --git a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/IStaticTemplateDefinitionStore.cs b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/IStaticTemplateDefinitionStore.cs index d298a42541..6e6d763616 100644 --- a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/IStaticTemplateDefinitionStore.cs +++ b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/IStaticTemplateDefinitionStore.cs @@ -10,5 +10,5 @@ public interface IStaticTemplateDefinitionStore Task> GetAllAsync(); - Task GetOrNullAsync(string name); + Task GetOrNullAsync(string name); } diff --git a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/ITemplateContentContributor.cs b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/ITemplateContentContributor.cs index fadd8696a8..086644db98 100644 --- a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/ITemplateContentContributor.cs +++ b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/ITemplateContentContributor.cs @@ -4,5 +4,5 @@ namespace Volo.Abp.TextTemplating; public interface ITemplateContentContributor { - Task GetOrNullAsync(TemplateContentContributorContext context); + Task GetOrNullAsync(TemplateContentContributorContext context); } diff --git a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/ITemplateContentProvider.cs b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/ITemplateContentProvider.cs index ac944946c0..1fe3f25d5f 100644 --- a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/ITemplateContentProvider.cs +++ b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/ITemplateContentProvider.cs @@ -5,16 +5,16 @@ namespace Volo.Abp.TextTemplating; public interface ITemplateContentProvider { - Task GetContentOrNullAsync( + Task GetContentOrNullAsync( [NotNull] string templateName, - [CanBeNull] string cultureName = null, + string? cultureName = null, bool tryDefaults = true, bool useCurrentCultureIfCultureNameIsNull = true ); - Task GetContentOrNullAsync( + Task GetContentOrNullAsync( [NotNull] TemplateDefinition templateDefinition, - [CanBeNull] string cultureName = null, + string? cultureName = null, bool tryDefaults = true, bool useCurrentCultureIfCultureNameIsNull = true ); diff --git a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/ITemplateDefinitionContext.cs b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/ITemplateDefinitionContext.cs index f2caa3c805..fd219ea23c 100644 --- a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/ITemplateDefinitionContext.cs +++ b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/ITemplateDefinitionContext.cs @@ -6,7 +6,7 @@ public interface ITemplateDefinitionContext { IReadOnlyList GetAll(); - TemplateDefinition GetOrNull(string name); + TemplateDefinition? GetOrNull(string name); void Add(params TemplateDefinition[] definitions); } diff --git a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/ITemplateDefinitionManager.cs b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/ITemplateDefinitionManager.cs index fa20673cea..b8903db522 100644 --- a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/ITemplateDefinitionManager.cs +++ b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/ITemplateDefinitionManager.cs @@ -12,6 +12,5 @@ public interface ITemplateDefinitionManager [ItemNotNull] Task> GetAllAsync(); - [ItemCanBeNull] - Task GetOrNullAsync(string name); + Task GetOrNullAsync(string name); } diff --git a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/ITemplateRenderer.cs b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/ITemplateRenderer.cs index 62e17f69a8..324984d44b 100644 --- a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/ITemplateRenderer.cs +++ b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/ITemplateRenderer.cs @@ -17,8 +17,8 @@ public interface ITemplateRenderer /// Task RenderAsync( [NotNull] string templateName, - [CanBeNull] object model = null, - [CanBeNull] string cultureName = null, - [CanBeNull] Dictionary globalContext = null + object? model = null, + string? cultureName = null, + Dictionary? globalContext = null ); } diff --git a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/ITemplateRenderingEngine.cs b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/ITemplateRenderingEngine.cs index da080ffdb3..e100825011 100644 --- a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/ITemplateRenderingEngine.cs +++ b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/ITemplateRenderingEngine.cs @@ -19,8 +19,8 @@ public interface ITemplateRenderingEngine /// Task RenderAsync( [NotNull] string templateName, - [CanBeNull] object model = null, - [CanBeNull] string cultureName = null, - [CanBeNull] Dictionary globalContext = null + object? model = null, + string? cultureName = null, + Dictionary? globalContext = null ); } diff --git a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/NullIDynamicTemplateDefinitionStore.cs b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/NullIDynamicTemplateDefinitionStore.cs index 115f46b2ac..5c72c6e7c4 100644 --- a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/NullIDynamicTemplateDefinitionStore.cs +++ b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/NullIDynamicTemplateDefinitionStore.cs @@ -8,13 +8,13 @@ namespace Volo.Abp.TextTemplating; public class NullIDynamicTemplateDefinitionStore : IDynamicTemplateDefinitionStore, ISingletonDependency { - private readonly static Task CachedTemplateResult = Task.FromResult((TemplateDefinition)null); + private readonly static Task CachedTemplateResult = Task.FromResult((TemplateDefinition?)null); private readonly static Task> CachedTemplatesResult = Task.FromResult((IReadOnlyList)Array.Empty().ToImmutableList()); public Task GetAsync(string name) { - return CachedTemplateResult; + return CachedTemplateResult!; } public Task> GetAllAsync() @@ -22,7 +22,7 @@ public class NullIDynamicTemplateDefinitionStore : IDynamicTemplateDefinitionSto return CachedTemplatesResult; } - public Task GetOrNullAsync(string name) + public Task GetOrNullAsync(string name) { return CachedTemplateResult; } diff --git a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/StaticTemplateDefinitionStore.cs b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/StaticTemplateDefinitionStore.cs index d12db86da8..4231f39b4d 100644 --- a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/StaticTemplateDefinitionStore.cs +++ b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/StaticTemplateDefinitionStore.cs @@ -36,7 +36,7 @@ public class StaticTemplateDefinitionStore : IStaticTemplateDefinitionStore, ISi throw new AbpException("Undefined template: " + name); } - return template; + return template!; } public virtual Task> GetAllAsync() @@ -44,7 +44,7 @@ public class StaticTemplateDefinitionStore : IStaticTemplateDefinitionStore, ISi return Task.FromResult>(TemplateDefinitions.Value.Values.ToImmutableList()); } - public virtual Task GetOrNullAsync(string name) + public virtual Task GetOrNullAsync(string name) { return Task.FromResult(TemplateDefinitions.Value.GetOrDefault(name)); } @@ -57,7 +57,7 @@ public class StaticTemplateDefinitionStore : IStaticTemplateDefinitionStore, ISi { var providers = Options .DefinitionProviders - .Select(p => scope.ServiceProvider.GetRequiredService(p) as ITemplateDefinitionProvider) + .Select(p => (scope.ServiceProvider.GetRequiredService(p) as ITemplateDefinitionProvider)!) .ToList(); var context = new TemplateDefinitionContext(templates); diff --git a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/TemplateContentContributorContext.cs b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/TemplateContentContributorContext.cs index 11b9af255a..8ea941114a 100644 --- a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/TemplateContentContributorContext.cs +++ b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/TemplateContentContributorContext.cs @@ -11,13 +11,12 @@ public class TemplateContentContributorContext [NotNull] public IServiceProvider ServiceProvider { get; } - [CanBeNull] - public string Culture { get; } + public string? Culture { get; } public TemplateContentContributorContext( [NotNull] TemplateDefinition templateDefinition, [NotNull] IServiceProvider serviceProvider, - [CanBeNull] string culture) + string? culture) { TemplateDefinition = Check.NotNull(templateDefinition, nameof(templateDefinition)); ServiceProvider = Check.NotNull(serviceProvider, nameof(serviceProvider)); diff --git a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/TemplateContentProvider.cs b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/TemplateContentProvider.cs index 64ecd1f4c7..5c9a51be82 100644 --- a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/TemplateContentProvider.cs +++ b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/TemplateContentProvider.cs @@ -26,9 +26,9 @@ public class TemplateContentProvider : ITemplateContentProvider, ITransientDepen _templateDefinitionManager = templateDefinitionManager; } - public virtual async Task GetContentOrNullAsync( + public virtual async Task GetContentOrNullAsync( [NotNull] string templateName, - [CanBeNull] string cultureName = null, + string? cultureName = null, bool tryDefaults = true, bool useCurrentCultureIfCultureNameIsNull = true) { @@ -36,9 +36,9 @@ public class TemplateContentProvider : ITemplateContentProvider, ITransientDepen return await GetContentOrNullAsync(template, cultureName); } - public virtual async Task GetContentOrNullAsync( + public virtual async Task GetContentOrNullAsync( [NotNull] TemplateDefinition templateDefinition, - [CanBeNull] string cultureName = null, + string? cultureName = null, bool tryDefaults = true, bool useCurrentCultureIfCultureNameIsNull = true) { @@ -53,7 +53,7 @@ public class TemplateContentProvider : ITemplateContentProvider, ITransientDepen using (var scope = ServiceScopeFactory.CreateScope()) { - string templateString = null; + string? templateString = null; if (cultureName == null && useCurrentCultureIfCultureNameIsNull) { @@ -151,7 +151,7 @@ public class TemplateContentProvider : ITemplateContentProvider, ITransientDepen .ToArray(); } - protected virtual async Task GetContentOrNullAsync( + protected virtual async Task GetContentOrNullAsync( ITemplateContentContributor[] contributors, TemplateContentContributorContext context) { diff --git a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/TemplateDefinition.cs b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/TemplateDefinition.cs index 64aeba815e..a371fc3a9a 100644 --- a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/TemplateDefinition.cs +++ b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/TemplateDefinition.cs @@ -20,23 +20,19 @@ public class TemplateDefinition : IHasNameWithLocalizableDisplayName _displayName = value; } } - private ILocalizableString _displayName; + private ILocalizableString _displayName = default!; public bool IsLayout { get; } - [CanBeNull] - public string Layout { get; set; } + public string? Layout { get; set; } - [CanBeNull] - public string LocalizationResourceName { get; set; } + public string? LocalizationResourceName { get; set; } public bool IsInlineLocalized { get; set; } - [CanBeNull] - public string DefaultCultureName { get; } + public string? DefaultCultureName { get; } - [CanBeNull] - public string RenderEngine { get; set; } + public string? RenderEngine { get; set; } /// /// Gets/sets a key-value on the . @@ -46,8 +42,7 @@ public class TemplateDefinition : IHasNameWithLocalizableDisplayName /// Returns the value in the dictionary by given . /// Returns null if given is not present in the dictionary. /// - [CanBeNull] - public object this[string name] { + public object? this[string name] { get => Properties.GetOrDefault(name); set => Properties[name] = value; } @@ -56,15 +51,15 @@ public class TemplateDefinition : IHasNameWithLocalizableDisplayName /// Can be used to get/set custom properties for this feature. /// [NotNull] - public Dictionary Properties { get; } + public Dictionary Properties { get; } public TemplateDefinition( [NotNull] string name, [NotNull] Type localizationResource, - [CanBeNull] ILocalizableString displayName = null, + ILocalizableString? displayName = null, bool isLayout = false, - string layout = null, - string defaultCultureName = null) + string? layout = null, + string? defaultCultureName = null) : this(name, LocalizationResourceNameAttribute.GetName(localizationResource), displayName, isLayout, layout, defaultCultureName) { @@ -72,11 +67,11 @@ public class TemplateDefinition : IHasNameWithLocalizableDisplayName public TemplateDefinition( [NotNull] string name, - [CanBeNull] string localizationResourceName = null, - [CanBeNull] ILocalizableString displayName = null, + string? localizationResourceName = null, + ILocalizableString? displayName = null, bool isLayout = false, - string layout = null, - string defaultCultureName = null) + string? layout = null, + string? defaultCultureName = null) { Name = Check.NotNullOrWhiteSpace(name, nameof(name), MaxNameLength); LocalizationResourceName = localizationResourceName; @@ -84,7 +79,7 @@ public class TemplateDefinition : IHasNameWithLocalizableDisplayName IsLayout = isLayout; Layout = layout; DefaultCultureName = defaultCultureName; - Properties = new Dictionary(); + Properties = new Dictionary(); } /// diff --git a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/TemplateDefinitionContext.cs b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/TemplateDefinitionContext.cs index b32332807f..9edd370ecf 100644 --- a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/TemplateDefinitionContext.cs +++ b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/TemplateDefinitionContext.cs @@ -17,7 +17,7 @@ public class TemplateDefinitionContext : ITemplateDefinitionContext return Templates.Values.ToImmutableList(); } - public virtual TemplateDefinition GetOrNull(string name) + public virtual TemplateDefinition? GetOrNull(string name) { return Templates.GetOrDefault(name); } diff --git a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/TemplateDefinitionExtensions.cs b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/TemplateDefinitionExtensions.cs index 35cc69275d..0d830e65ef 100644 --- a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/TemplateDefinitionExtensions.cs +++ b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/TemplateDefinitionExtensions.cs @@ -21,7 +21,7 @@ public static class TemplateDefinitionExtensions ); } - public static string GetVirtualFilePathOrNull( + public static string? GetVirtualFilePathOrNull( [NotNull] this TemplateDefinition templateDefinition) { Check.NotNull(templateDefinition, nameof(templateDefinition)); diff --git a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/TemplateDefinitionManager.cs b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/TemplateDefinitionManager.cs index 7e2920e446..32d4d8eeab 100644 --- a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/TemplateDefinitionManager.cs +++ b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/TemplateDefinitionManager.cs @@ -28,7 +28,7 @@ public class TemplateDefinitionManager : ITemplateDefinitionManager, ISingletonD return permission; } - public virtual async Task GetOrNullAsync(string name) + public virtual async Task GetOrNullAsync(string name) { Check.NotNull(name, nameof(name)); diff --git a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/TemplateRenderingEngineBase.cs b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/TemplateRenderingEngineBase.cs index a2c354801d..62c8dee43c 100644 --- a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/TemplateRenderingEngineBase.cs +++ b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/TemplateRenderingEngineBase.cs @@ -22,14 +22,14 @@ public abstract class TemplateRenderingEngineBase : ITemplateRenderingEngine StringLocalizerFactory = stringLocalizerFactory; } - public abstract Task RenderAsync(string templateName, object model = null, string cultureName = null, Dictionary globalContext = null); + public abstract Task RenderAsync(string templateName, object? model = null, string? cultureName = null, Dictionary? globalContext = null); - protected virtual async Task GetContentOrNullAsync(TemplateDefinition templateDefinition) + protected virtual async Task GetContentOrNullAsync(TemplateDefinition templateDefinition) { return await TemplateContentProvider.GetContentOrNullAsync(templateDefinition); } - protected virtual IStringLocalizer GetLocalizerOrNull(TemplateDefinition templateDefinition) + protected virtual IStringLocalizer? GetLocalizerOrNull(TemplateDefinition templateDefinition) { if (templateDefinition.LocalizationResourceName != null) { diff --git a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/VirtualFiles/FileInfoLocalizedTemplateContentReader.cs b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/VirtualFiles/FileInfoLocalizedTemplateContentReader.cs index 27e400c082..81074936e6 100644 --- a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/VirtualFiles/FileInfoLocalizedTemplateContentReader.cs +++ b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/VirtualFiles/FileInfoLocalizedTemplateContentReader.cs @@ -5,8 +5,8 @@ namespace Volo.Abp.TextTemplating.VirtualFiles; public class FileInfoLocalizedTemplateContentReader : ILocalizedTemplateContentReader { - private IFileInfo _fileInfo; - private string _content; + private IFileInfo _fileInfo = default!; + private string _content = default!; public async Task ReadContentsAsync(IFileInfo fileInfo) { @@ -14,7 +14,7 @@ public class FileInfoLocalizedTemplateContentReader : ILocalizedTemplateContentR _content = await fileInfo.ReadAsStringAsync(); } - public string GetContentOrNull(string culture) + public string? GetContentOrNull(string? culture) { if (culture == null) { diff --git a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/VirtualFiles/ILocalizedTemplateContentReader.cs b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/VirtualFiles/ILocalizedTemplateContentReader.cs index 9fc15d1954..ab2380c069 100644 --- a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/VirtualFiles/ILocalizedTemplateContentReader.cs +++ b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/VirtualFiles/ILocalizedTemplateContentReader.cs @@ -4,5 +4,5 @@ namespace Volo.Abp.TextTemplating.VirtualFiles; public interface ILocalizedTemplateContentReader { - public string GetContentOrNull([CanBeNull] string culture); + public string? GetContentOrNull(string? culture); } diff --git a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/VirtualFiles/NullLocalizedTemplateContentReader.cs b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/VirtualFiles/NullLocalizedTemplateContentReader.cs index 878428b5ef..f2988d8197 100644 --- a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/VirtualFiles/NullLocalizedTemplateContentReader.cs +++ b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/VirtualFiles/NullLocalizedTemplateContentReader.cs @@ -9,7 +9,7 @@ public class NullLocalizedTemplateContentReader : ILocalizedTemplateContentReade } - public string GetContentOrNull(string culture) + public string? GetContentOrNull(string? culture) { return null; } diff --git a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/VirtualFiles/TemplateContentFileInfo.cs b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/VirtualFiles/TemplateContentFileInfo.cs index 5469700432..45dbd6e553 100644 --- a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/VirtualFiles/TemplateContentFileInfo.cs +++ b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/VirtualFiles/TemplateContentFileInfo.cs @@ -2,7 +2,7 @@ namespace Volo.Abp.TextTemplating.VirtualFiles; public class TemplateContentFileInfo { - public string FileName { get; set; } + public string FileName { get; set; } = default!; - public string FileContent { get; set; } + public string FileContent { get; set; } = default!; } diff --git a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/VirtualFiles/VirtualFileTemplateContentContributor.cs b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/VirtualFiles/VirtualFileTemplateContentContributor.cs index 7bd66f2f50..999bc62de9 100644 --- a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/VirtualFiles/VirtualFileTemplateContentContributor.cs +++ b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/VirtualFiles/VirtualFileTemplateContentContributor.cs @@ -15,7 +15,7 @@ public class VirtualFileTemplateContentContributor : ITemplateContentContributor _localizedTemplateContentReaderFactory = localizedTemplateContentReaderFactory; } - public virtual async Task GetOrNullAsync(TemplateContentContributorContext context) + public virtual async Task GetOrNullAsync(TemplateContentContributorContext context) { var localizedReader = await _localizedTemplateContentReaderFactory .CreateAsync(context.TemplateDefinition); diff --git a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/VirtualFiles/VirtualFolderLocalizedTemplateContentReader.cs b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/VirtualFiles/VirtualFolderLocalizedTemplateContentReader.cs index 828978b1d2..0e6c9b13c2 100644 --- a/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/VirtualFiles/VirtualFolderLocalizedTemplateContentReader.cs +++ b/framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/VirtualFiles/VirtualFolderLocalizedTemplateContentReader.cs @@ -9,7 +9,7 @@ namespace Volo.Abp.TextTemplating.VirtualFiles; public class VirtualFolderLocalizedTemplateContentReader : ILocalizedTemplateContentReader { - private Dictionary _dictionary; + private Dictionary _dictionary = default!; private readonly string[] _fileExtension; public VirtualFolderLocalizedTemplateContentReader(string[] fileExtension) @@ -44,7 +44,7 @@ public class VirtualFolderLocalizedTemplateContentReader : ILocalizedTemplateCon } } - public string GetContentOrNull(string cultureName) + public string? GetContentOrNull(string? cultureName) { if (cultureName == null) { diff --git a/framework/src/Volo.Abp.TextTemplating.Razor/Volo.Abp.TextTemplating.Razor.csproj b/framework/src/Volo.Abp.TextTemplating.Razor/Volo.Abp.TextTemplating.Razor.csproj index 962746bd0a..4242ca9f29 100644 --- a/framework/src/Volo.Abp.TextTemplating.Razor/Volo.Abp.TextTemplating.Razor.csproj +++ b/framework/src/Volo.Abp.TextTemplating.Razor/Volo.Abp.TextTemplating.Razor.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable diff --git a/framework/src/Volo.Abp.TextTemplating.Razor/Volo/Abp/TextTemplating/Razor/AbpRazorTemplateCSharpCompiler.cs b/framework/src/Volo.Abp.TextTemplating.Razor/Volo/Abp/TextTemplating/Razor/AbpRazorTemplateCSharpCompiler.cs index c1dc5005b1..bdc8897ddf 100644 --- a/framework/src/Volo.Abp.TextTemplating.Razor/Volo/Abp/TextTemplating/Razor/AbpRazorTemplateCSharpCompiler.cs +++ b/framework/src/Volo.Abp.TextTemplating.Razor/Volo/Abp/TextTemplating/Razor/AbpRazorTemplateCSharpCompiler.cs @@ -40,7 +40,7 @@ public class AbpRazorTemplateCSharpCompiler : ISingletonDependency .Select(x => MetadataReference.CreateFromFile(x.Location)) .ToImmutableList(); - public virtual Stream CreateAssembly(string code, string assemblyName, List references = null, CSharpCompilationOptions options = null) + public virtual Stream CreateAssembly(string code, string assemblyName, List? references = null, CSharpCompilationOptions? options = null) { var defaultReferences = DefaultReferences.Concat(Options.References); try diff --git a/framework/src/Volo.Abp.TextTemplating.Razor/Volo/Abp/TextTemplating/Razor/DefaultAbpRazorProjectEngineFactory.cs b/framework/src/Volo.Abp.TextTemplating.Razor/Volo/Abp/TextTemplating/Razor/DefaultAbpRazorProjectEngineFactory.cs index d15d70ded6..d17bfaea4f 100644 --- a/framework/src/Volo.Abp.TextTemplating.Razor/Volo/Abp/TextTemplating/Razor/DefaultAbpRazorProjectEngineFactory.cs +++ b/framework/src/Volo.Abp.TextTemplating.Razor/Volo/Abp/TextTemplating/Razor/DefaultAbpRazorProjectEngineFactory.cs @@ -7,7 +7,7 @@ namespace Volo.Abp.TextTemplating.Razor; public class DefaultAbpRazorProjectEngineFactory : IAbpRazorProjectEngineFactory, ITransientDependency { - public virtual async Task CreateAsync(Action configure = null) + public virtual async Task CreateAsync(Action? configure = null) { return RazorProjectEngine.Create(await CreateRazorConfigurationAsync(), EmptyProjectFileSystem.Empty, configure); } diff --git a/framework/src/Volo.Abp.TextTemplating.Razor/Volo/Abp/TextTemplating/Razor/EmptyProjectFileSystem.cs b/framework/src/Volo.Abp.TextTemplating.Razor/Volo/Abp/TextTemplating/Razor/EmptyProjectFileSystem.cs index fd2b90a6b1..8c8d8703dd 100644 --- a/framework/src/Volo.Abp.TextTemplating.Razor/Volo/Abp/TextTemplating/Razor/EmptyProjectFileSystem.cs +++ b/framework/src/Volo.Abp.TextTemplating.Razor/Volo/Abp/TextTemplating/Razor/EmptyProjectFileSystem.cs @@ -21,7 +21,7 @@ internal class EmptyProjectFileSystem : RazorProjectFileSystem return GetItem(path, fileKind: null); } - public override RazorProjectItem GetItem(string path, string fileKind) + public override RazorProjectItem GetItem(string path, string? fileKind) { NormalizeAndEnsureValidPath(path); return new NotFoundProjectItem(string.Empty, path, fileKind); diff --git a/framework/src/Volo.Abp.TextTemplating.Razor/Volo/Abp/TextTemplating/Razor/IAbpRazorProjectEngineFactory.cs b/framework/src/Volo.Abp.TextTemplating.Razor/Volo/Abp/TextTemplating/Razor/IAbpRazorProjectEngineFactory.cs index 969ce762d1..197133ef72 100644 --- a/framework/src/Volo.Abp.TextTemplating.Razor/Volo/Abp/TextTemplating/Razor/IAbpRazorProjectEngineFactory.cs +++ b/framework/src/Volo.Abp.TextTemplating.Razor/Volo/Abp/TextTemplating/Razor/IAbpRazorProjectEngineFactory.cs @@ -6,5 +6,5 @@ namespace Volo.Abp.TextTemplating.Razor; public interface IAbpRazorProjectEngineFactory { - Task CreateAsync(Action configure = null); + Task CreateAsync(Action? configure = null); } diff --git a/framework/src/Volo.Abp.TextTemplating.Razor/Volo/Abp/TextTemplating/Razor/IRazorTemplatePage.cs b/framework/src/Volo.Abp.TextTemplating.Razor/Volo/Abp/TextTemplating/Razor/IRazorTemplatePage.cs index 78b80941e9..f4b2a17006 100644 --- a/framework/src/Volo.Abp.TextTemplating.Razor/Volo/Abp/TextTemplating/Razor/IRazorTemplatePage.cs +++ b/framework/src/Volo.Abp.TextTemplating.Razor/Volo/Abp/TextTemplating/Razor/IRazorTemplatePage.cs @@ -8,24 +8,24 @@ namespace Volo.Abp.TextTemplating.Razor; public interface IRazorTemplatePage : IRazorTemplatePage { - TModel Model { get; set; } + TModel? Model { get; set; } } public interface IRazorTemplatePage { IServiceProvider ServiceProvider { get; set; } - IStringLocalizer Localizer { get; set; } + IStringLocalizer? Localizer { get; set; } - HtmlEncoder HtmlEncoder { get; set; } + HtmlEncoder? HtmlEncoder { get; set; } - JavaScriptEncoder JavaScriptEncoder { get; set; } + JavaScriptEncoder? JavaScriptEncoder { get; set; } - UrlEncoder UrlEncoder { get; set; } + UrlEncoder? UrlEncoder { get; set; } Dictionary GlobalContext { get; set; } - string Body { get; set; } + string? Body { get; set; } Task ExecuteAsync(); diff --git a/framework/src/Volo.Abp.TextTemplating.Razor/Volo/Abp/TextTemplating/Razor/NotFoundProjectItem.cs b/framework/src/Volo.Abp.TextTemplating.Razor/Volo/Abp/TextTemplating/Razor/NotFoundProjectItem.cs index 5db2c8f582..2651237d2d 100644 --- a/framework/src/Volo.Abp.TextTemplating.Razor/Volo/Abp/TextTemplating/Razor/NotFoundProjectItem.cs +++ b/framework/src/Volo.Abp.TextTemplating.Razor/Volo/Abp/TextTemplating/Razor/NotFoundProjectItem.cs @@ -6,7 +6,7 @@ namespace Volo.Abp.TextTemplating.Razor; internal class NotFoundProjectItem : RazorProjectItem { - public NotFoundProjectItem(string basePath, string path, string fileKind) + public NotFoundProjectItem(string basePath, string path, string? fileKind) { BasePath = basePath; FilePath = path; diff --git a/framework/src/Volo.Abp.TextTemplating.Razor/Volo/Abp/TextTemplating/Razor/RazorTemplatePageBase.cs b/framework/src/Volo.Abp.TextTemplating.Razor/Volo/Abp/TextTemplating/Razor/RazorTemplatePageBase.cs index fd2d2c13e7..a85d9d1480 100644 --- a/framework/src/Volo.Abp.TextTemplating.Razor/Volo/Abp/TextTemplating/Razor/RazorTemplatePageBase.cs +++ b/framework/src/Volo.Abp.TextTemplating.Razor/Volo/Abp/TextTemplating/Razor/RazorTemplatePageBase.cs @@ -9,30 +9,30 @@ namespace Volo.Abp.TextTemplating.Razor; public abstract class RazorTemplatePageBase : RazorTemplatePageBase, IRazorTemplatePage { - public TModel Model { get; set; } + public TModel? Model { get; set; } } public abstract class RazorTemplatePageBase : IRazorTemplatePage { - public Dictionary GlobalContext { get; set; } + public Dictionary GlobalContext { get; set; } = default!; - public IServiceProvider ServiceProvider { get; set; } + public IServiceProvider ServiceProvider { get; set; } = default!; - public IStringLocalizer Localizer { get; set; } + public IStringLocalizer? Localizer { get; set; } - public HtmlEncoder HtmlEncoder { get; set; } + public HtmlEncoder? HtmlEncoder { get; set; } - public JavaScriptEncoder JavaScriptEncoder { get; set; } + public JavaScriptEncoder? JavaScriptEncoder { get; set; } - public UrlEncoder UrlEncoder { get; set; } + public UrlEncoder? UrlEncoder { get; set; } - public string Body { get; set; } + public string? Body { get; set; } private readonly StringBuilder _stringBuilder = new StringBuilder(); private AttributeInfo _attributeInfo; - public virtual void WriteLiteral(string literal = null) + public virtual void WriteLiteral(string? literal = null) { if (!literal.IsNullOrEmpty()) { @@ -40,7 +40,7 @@ public abstract class RazorTemplatePageBase : IRazorTemplatePage } } - public virtual void Write(object value = null) + public virtual void Write(object? value = null) { if (value is null) { diff --git a/framework/src/Volo.Abp.TextTemplating.Razor/Volo/Abp/TextTemplating/Razor/RazorTemplateRenderingEngine.cs b/framework/src/Volo.Abp.TextTemplating.Razor/Volo/Abp/TextTemplating/Razor/RazorTemplateRenderingEngine.cs index 86298f2daf..2384bd8740 100644 --- a/framework/src/Volo.Abp.TextTemplating.Razor/Volo/Abp/TextTemplating/Razor/RazorTemplateRenderingEngine.cs +++ b/framework/src/Volo.Abp.TextTemplating.Razor/Volo/Abp/TextTemplating/Razor/RazorTemplateRenderingEngine.cs @@ -34,9 +34,9 @@ public class RazorTemplateRenderingEngine : TemplateRenderingEngineBase, ITransi public override async Task RenderAsync( [NotNull] string templateName, - [CanBeNull] object model = null, - [CanBeNull] string cultureName = null, - [CanBeNull] Dictionary globalContext = null) + object? model = null, + string? cultureName = null, + Dictionary? globalContext = null) { Check.NotNullOrWhiteSpace(templateName, nameof(templateName)); @@ -70,9 +70,9 @@ public class RazorTemplateRenderingEngine : TemplateRenderingEngineBase, ITransi protected virtual async Task RenderInternalAsync( string templateName, - string body, + string? body, Dictionary globalContext, - object model = null) + object? model = null) { var templateDefinition = await TemplateDefinitionManager.GetAsync(templateName); @@ -97,9 +97,9 @@ public class RazorTemplateRenderingEngine : TemplateRenderingEngineBase, ITransi protected virtual async Task RenderSingleTemplateAsync( TemplateDefinition templateDefinition, - string body, + string? body, Dictionary globalContext, - object model = null) + object? model = null) { return await RenderTemplateContentWithRazorAsync( templateDefinition, @@ -111,13 +111,13 @@ public class RazorTemplateRenderingEngine : TemplateRenderingEngineBase, ITransi protected virtual async Task RenderTemplateContentWithRazorAsync( TemplateDefinition templateDefinition, - string body, + string? body, Dictionary globalContext, - object model = null) + object? model = null) { var assembly = await AbpCompiledViewProvider.GetAssemblyAsync(templateDefinition); - var templateType = assembly.GetType(AbpRazorTemplateConsts.TypeName); - var template = (IRazorTemplatePage)Activator.CreateInstance(templateType); + var templateType = assembly.GetType(AbpRazorTemplateConsts.TypeName)!; + var template = (IRazorTemplatePage)Activator.CreateInstance(templateType)!; using (var scope = ServiceScopeFactory.CreateScope()) { @@ -147,11 +147,11 @@ public class RazorTemplateRenderingEngine : TemplateRenderingEngineBase, ITransi } } - private void SetModel(IRazorTemplatePage razorTemplatePage, object model = null) + private void SetModel(IRazorTemplatePage razorTemplatePage, object? model = null) { if (razorTemplatePage is IRazorTemplatePage razorTemplatePageWithModel) { - razorTemplatePageWithModel.Model = (TModel)model; + razorTemplatePageWithModel.Model = (TModel?)model; } } } diff --git a/framework/src/Volo.Abp.TextTemplating.Scriban/Volo.Abp.TextTemplating.Scriban.csproj b/framework/src/Volo.Abp.TextTemplating.Scriban/Volo.Abp.TextTemplating.Scriban.csproj index d18d90c8f9..ea1d0f0f8d 100644 --- a/framework/src/Volo.Abp.TextTemplating.Scriban/Volo.Abp.TextTemplating.Scriban.csproj +++ b/framework/src/Volo.Abp.TextTemplating.Scriban/Volo.Abp.TextTemplating.Scriban.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable diff --git a/framework/src/Volo.Abp.TextTemplating.Scriban/Volo/Abp/TextTemplating/Scriban/ScribanTemplateLocalizer.cs b/framework/src/Volo.Abp.TextTemplating.Scriban/Volo/Abp/TextTemplating/Scriban/ScribanTemplateLocalizer.cs index 91af004cf9..6bf32d1a58 100644 --- a/framework/src/Volo.Abp.TextTemplating.Scriban/Volo/Abp/TextTemplating/Scriban/ScribanTemplateLocalizer.cs +++ b/framework/src/Volo.Abp.TextTemplating.Scriban/Volo/Abp/TextTemplating/Scriban/ScribanTemplateLocalizer.cs @@ -44,7 +44,7 @@ public class ScribanTemplateLocalizer : IScriptCustomFunction } var args = arguments.Skip(1).Where(x => x != null && !x.ToString().IsNullOrWhiteSpace()).ToArray(); - return args.Any() ? _localizer[name.ToString(), args] : _localizer[name.ToString()]; + return args.Any() ? _localizer[name.ToString()!, args] : _localizer[name.ToString()!]; } public int RequiredParameterCount => 1; diff --git a/framework/src/Volo.Abp.TextTemplating.Scriban/Volo/Abp/TextTemplating/Scriban/ScribanTemplateRenderingEngine.cs b/framework/src/Volo.Abp.TextTemplating.Scriban/Volo/Abp/TextTemplating/Scriban/ScribanTemplateRenderingEngine.cs index a4da669893..7a5ac79592 100644 --- a/framework/src/Volo.Abp.TextTemplating.Scriban/Volo/Abp/TextTemplating/Scriban/ScribanTemplateRenderingEngine.cs +++ b/framework/src/Volo.Abp.TextTemplating.Scriban/Volo/Abp/TextTemplating/Scriban/ScribanTemplateRenderingEngine.cs @@ -24,9 +24,9 @@ public class ScribanTemplateRenderingEngine : TemplateRenderingEngineBase, ITran public override async Task RenderAsync( [NotNull] string templateName, - [CanBeNull] object model = null, - [CanBeNull] string cultureName = null, - [CanBeNull] Dictionary globalContext = null) + object? model = null, + string? cultureName = null, + Dictionary? globalContext = null) { Check.NotNullOrWhiteSpace(templateName, nameof(templateName)); @@ -59,7 +59,7 @@ public class ScribanTemplateRenderingEngine : TemplateRenderingEngineBase, ITran protected virtual async Task RenderInternalAsync( string templateName, Dictionary globalContext, - object model = null) + object? model = null) { var templateDefinition = await TemplateDefinitionManager.GetAsync(templateName); @@ -84,13 +84,13 @@ public class ScribanTemplateRenderingEngine : TemplateRenderingEngineBase, ITran protected virtual async Task RenderSingleTemplateAsync( TemplateDefinition templateDefinition, Dictionary globalContext, - object model = null) + object? model = null) { var rawTemplateContent = await GetContentOrNullAsync(templateDefinition); return await RenderTemplateContentWithScribanAsync( templateDefinition, - rawTemplateContent, + rawTemplateContent!, globalContext, model ); @@ -100,7 +100,7 @@ public class ScribanTemplateRenderingEngine : TemplateRenderingEngineBase, ITran TemplateDefinition templateDefinition, string templateContent, Dictionary globalContext, - object model = null) + object? model = null) { var context = CreateScribanTemplateContext( templateDefinition, @@ -116,7 +116,7 @@ public class ScribanTemplateRenderingEngine : TemplateRenderingEngineBase, ITran protected virtual TemplateContext CreateScribanTemplateContext( TemplateDefinition templateDefinition, Dictionary globalContext, - object model = null) + object? model = null) { var context = new TemplateContext(); diff --git a/framework/src/Volo.Abp.TextTemplating/Volo.Abp.TextTemplating.csproj b/framework/src/Volo.Abp.TextTemplating/Volo.Abp.TextTemplating.csproj index 27907183c0..f8d1d85192 100644 --- a/framework/src/Volo.Abp.TextTemplating/Volo.Abp.TextTemplating.csproj +++ b/framework/src/Volo.Abp.TextTemplating/Volo.Abp.TextTemplating.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable