From 30786a0e53dfd47eba8271c145c7334155c4ace9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Thu, 16 Jun 2022 14:21:50 +0300 Subject: [PATCH 1/3] Implement ContractAnnotation for IsNullOrEmpty & IsNullOrWhiteSpace extension methods. --- framework/src/Volo.Abp.Core/System/AbpStringExtensions.cs | 2 ++ .../System/Collections/Generic/AbpCollectionExtensions.cs | 1 + 2 files changed, 3 insertions(+) diff --git a/framework/src/Volo.Abp.Core/System/AbpStringExtensions.cs b/framework/src/Volo.Abp.Core/System/AbpStringExtensions.cs index 0e71df6b59..d433fff59b 100644 --- a/framework/src/Volo.Abp.Core/System/AbpStringExtensions.cs +++ b/framework/src/Volo.Abp.Core/System/AbpStringExtensions.cs @@ -46,6 +46,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) { return string.IsNullOrEmpty(str); @@ -54,6 +55,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) { return string.IsNullOrWhiteSpace(str); 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 4df3010aba..83fbf59629 100644 --- a/framework/src/Volo.Abp.Core/System/Collections/Generic/AbpCollectionExtensions.cs +++ b/framework/src/Volo.Abp.Core/System/Collections/Generic/AbpCollectionExtensions.cs @@ -12,6 +12,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) { return source == null || source.Count <= 0; From 806c640bc566137fdf38ed690d4282af7248a986 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Thu, 16 Jun 2022 14:27:13 +0300 Subject: [PATCH 2/3] Use ContractAnnotation attributed for string extensions. --- .../src/Volo.Abp.Core/System/AbpStringExtensions.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/framework/src/Volo.Abp.Core/System/AbpStringExtensions.cs b/framework/src/Volo.Abp.Core/System/AbpStringExtensions.cs index d433fff59b..c7e1bef3b2 100644 --- a/framework/src/Volo.Abp.Core/System/AbpStringExtensions.cs +++ b/framework/src/Volo.Abp.Core/System/AbpStringExtensions.cs @@ -119,6 +119,7 @@ public static class AbpStringExtensions /// The string. /// one or more postfix. /// Modified string or the same string if it has not any of given postfixes + [ContractAnnotation("null <= str:null")] public static string RemovePostFix(this string str, params string[] postFixes) { return str.RemovePostFix(StringComparison.Ordinal, postFixes); @@ -131,6 +132,7 @@ public static class AbpStringExtensions /// String comparison type /// one or more postfix. /// Modified string or the same string if it has not any of given postfixes + [ContractAnnotation("null <= str:null")] public static string RemovePostFix(this string str, StringComparison comparisonType, params string[] postFixes) { if (str.IsNullOrEmpty()) @@ -160,6 +162,7 @@ public static class AbpStringExtensions /// The string. /// one or more prefix. /// Modified string or the same string if it has not any of given prefixes + [ContractAnnotation("null <= str:null")] public static string RemovePreFix(this string str, params string[] preFixes) { return str.RemovePreFix(StringComparison.Ordinal, preFixes); @@ -172,6 +175,7 @@ public static class AbpStringExtensions /// String comparison type /// one or more prefix. /// Modified string or the same string if it has not any of given prefixes + [ContractAnnotation("null <= str:null")] public static string RemovePreFix(this string str, StringComparison comparisonType, params string[] preFixes) { if (str.IsNullOrEmpty()) @@ -264,6 +268,7 @@ public static class AbpStringExtensions /// set true to use current culture. Otherwise, invariant culture will be used. /// set true to if you want to convert 'XYZ' to 'xyz'. /// camelCase of the string + [ContractAnnotation("null <= str:null")] public static string ToCamelCase(this string str, bool useCurrentCulture = false, bool handleAbbreviations = false) { if (string.IsNullOrWhiteSpace(str)) @@ -290,6 +295,7 @@ public static class AbpStringExtensions /// /// String to convert. /// set true to use current culture. Otherwise, invariant culture will be used. + [ContractAnnotation("null <= str:null")] public static string ToSentenceCase(this string str, bool useCurrentCulture = false) { if (string.IsNullOrWhiteSpace(str)) @@ -307,6 +313,7 @@ public static class AbpStringExtensions /// /// String to convert. /// set true to use current culture. Otherwise, invariant culture will be used. + [ContractAnnotation("null <= str:null")] public static string ToKebabCase(this string str, bool useCurrentCulture = false) { if (string.IsNullOrWhiteSpace(str)) @@ -440,6 +447,7 @@ public static class AbpStringExtensions /// String to convert /// set true to use current culture. Otherwise, invariant culture will be used. /// PascalCase of the string + [ContractAnnotation("null <= str:null")] public static string ToPascalCase(this string str, bool useCurrentCulture = false) { if (string.IsNullOrWhiteSpace(str)) @@ -458,7 +466,7 @@ public static class AbpStringExtensions /// /// Gets a substring of a string from beginning of the string if it exceeds maximum length. /// - /// Thrown if is null + [ContractAnnotation("null <= str:null")] public static string Truncate(this string str, int maxLength) { if (str == null) @@ -477,7 +485,7 @@ public static class AbpStringExtensions /// /// Gets a substring of a string from Ending of the string if it exceeds maximum length. /// - /// Thrown if is null + [ContractAnnotation("null <= str:null")] public static string TruncateFromBeginning(this string str, int maxLength) { if (str == null) @@ -510,6 +518,7 @@ public static class AbpStringExtensions /// Returning string can not be longer than maxLength. /// /// Thrown if is null + [ContractAnnotation("null <= str:null")] public static string TruncateWithPostfix(this string str, int maxLength, string postfix) { if (str == null) From 7206583617a26d4f68ee6f28bf368c44ea66e750 Mon Sep 17 00:00:00 2001 From: Berkan Sasmaz Date: Thu, 16 Jun 2022 17:11:02 +0300 Subject: [PATCH 3/3] Update en.json --- .../AbpIoLocalization/Commercial/Localization/Resources/en.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/en.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/en.json index 4b3abd4d6d..d0022b30a5 100644 --- a/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/en.json +++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/en.json @@ -376,7 +376,7 @@ "StartTrial": "Start My Free Trial", "ContactUsQuestions": "Contact us if you have any questions", "TrialActivatedWarning": "A user is entitled to have only 1 free trial period. You already used your trial period.", - "ActivationRequirement": "You are last one step away from starting a free trial.
After checking your information, we will activate your license. Once your license is activated, we will send an email to {0}. Don't worry, this process won't take long!", + "ActivationRequirement": "You are last one step away from starting your trial.
After checking your information, we will activate your license. Once your license is activated, we will send an email to {0}. Don't worry, this process won't take long!", "SaveAndDownload": "Save And Download", "CompanyNameValidationMessage": "Company name is too long!", "AddressValidationMessage": "Address is too long!",