Browse Source
Merge pull request #17608 from abpframework/NotNullWhen
Add `NotNullWhen` attribute to `IsNullOrEmpty& IsNullOrWhiteSpace`.
pull/17663/head
liangshiwei
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
8 additions and
2 deletions
-
framework/src/Volo.Abp.Core/System/AbpStringExtensions.cs
-
framework/src/Volo.Abp.Core/Volo.Abp.Core.csproj
|
|
|
@ -47,7 +47,7 @@ public static class AbpStringExtensions |
|
|
|
/// Indicates whether this string is null or an System.String.Empty string.
|
|
|
|
/// </summary>
|
|
|
|
[ContractAnnotation("str:null => true")] |
|
|
|
public static bool IsNullOrEmpty(this string? str) |
|
|
|
public static bool IsNullOrEmpty([System.Diagnostics.CodeAnalysis.NotNullWhen(false)]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.
|
|
|
|
/// </summary>
|
|
|
|
[ContractAnnotation("str:null => true")] |
|
|
|
public static bool IsNullOrWhiteSpace(this string? str) |
|
|
|
public static bool IsNullOrWhiteSpace([System.Diagnostics.CodeAnalysis.NotNullWhen(false)]this string? str) |
|
|
|
{ |
|
|
|
return string.IsNullOrWhiteSpace(str); |
|
|
|
} |
|
|
|
|
|
|
|
@ -37,4 +37,10 @@ |
|
|
|
<ItemGroup Condition=" '$(TargetFrameworkIdentifier)' == '.NETStandard' And $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '2.1')) "> |
|
|
|
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" /> |
|
|
|
</ItemGroup> |
|
|
|
<ItemGroup Condition=" '$(TargetFrameworkIdentifier)' == '.NETStandard' And $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '2.0')) "> |
|
|
|
<PackageReference Include="Nullable" Version="1.3.1"> |
|
|
|
<PrivateAssets>all</PrivateAssets> |
|
|
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> |
|
|
|
</PackageReference> |
|
|
|
</ItemGroup> |
|
|
|
</Project> |
|
|
|
|