Browse Source

Enable nullable annotations for Volo.Abp.Http.* packages

pull/17560/head
liangshiwei 2 years ago
parent
commit
96febd9fdf
  1. 2
      framework/src/Volo.Abp.Http.Abstractions/Volo.Abp.Http.Abstractions.csproj
  2. 2
      framework/src/Volo.Abp.Http.Abstractions/Volo/Abp/Http/ClientProxyExceptionEventData.cs
  3. 2
      framework/src/Volo.Abp.Http.Client.Dapr/Volo.Abp.Http.Client.Dapr.csproj
  4. 2
      framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpInvocationHandler.cs
  5. 2
      framework/src/Volo.Abp.Http.Client.IdentityModel.MauiBlazor/Volo.Abp.Http.Client.IdentityModel.MauiBlazor.csproj
  6. 2
      framework/src/Volo.Abp.Http.Client.IdentityModel.MauiBlazor/Volo/Abp/Http/Client/IdentityModel/MauiBlazor/MauiBlazorAbpAccessTokenProvider.cs
  7. 2
      framework/src/Volo.Abp.Http.Client.IdentityModel.Web/Volo.Abp.Http.Client.IdentityModel.Web.csproj
  8. 2
      framework/src/Volo.Abp.Http.Client.IdentityModel.Web/Volo/Abp/Http/Client/IdentityModel/Web/HttpContextAbpAccessTokenProvider.cs
  9. 2
      framework/src/Volo.Abp.Http.Client.IdentityModel.WebAssembly/Volo.Abp.Http.Client.IdentityModel.WebAssembly.csproj
  10. 4
      framework/src/Volo.Abp.Http.Client.IdentityModel.WebAssembly/Volo/Abp/Http/Client/IdentityModel/WebAssembly/WebAssemblyAbpAccessTokenProvider.cs
  11. 2
      framework/src/Volo.Abp.Http.Client.IdentityModel/Volo.Abp.Http.Client.IdentityModel.csproj
  12. 3
      framework/src/Volo.Abp.Http.Client.IdentityModel/Volo/Abp/Http/Client/RemoteServiceConfigurationExtensions.cs
  13. 2
      framework/src/Volo.Abp.Http.Client.Web/Volo.Abp.Http.Client.Web.csproj
  14. 18
      framework/src/Volo.Abp.Http.Client.Web/Volo/Abp/Http/Client/Web/Conventions/AbpHttpClientProxyServiceConvention.cs
  15. 2
      framework/src/Volo.Abp.IdentityModel/Volo.Abp.IdentityModel.csproj
  16. 4
      framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/AbpIdentityClientOptions.cs
  17. 2
      framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IIdentityModelAuthenticationService.cs
  18. 20
      framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IdentityClientConfiguration.cs
  19. 4
      framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IdentityClientConfigurationDictionary.cs
  20. 4
      framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IdentityModelAuthenticationService.cs
  21. 4
      framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IdentityModelDiscoveryDocumentCacheItem.cs
  22. 2
      framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IdentityModelHttpRequestMessageOptions.cs
  23. 2
      framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IdentityModelTokenCacheItem.cs

2
framework/src/Volo.Abp.Http.Abstractions/Volo.Abp.Http.Abstractions.csproj

@ -5,6 +5,8 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net7.0</TargetFrameworks>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
<AssemblyName>Volo.Abp.Http.Abstractions</AssemblyName>
<PackageId>Volo.Abp.Http.Abstractions</PackageId>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>

2
framework/src/Volo.Abp.Http.Abstractions/Volo/Abp/Http/ClientProxyExceptionEventData.cs

@ -4,5 +4,5 @@ public class ClientProxyExceptionEventData
{
public int? StatusCode { get; set; }
public string ReasonPhrase { get; set; }
public string? ReasonPhrase { get; set; }
}

2
framework/src/Volo.Abp.Http.Client.Dapr/Volo.Abp.Http.Client.Dapr.csproj

@ -5,6 +5,8 @@
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
<RootNamespace />
</PropertyGroup>

2
framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpInvocationHandler.cs

@ -12,7 +12,7 @@ public class AbpInvocationHandler : InvocationHandler, ITransientDependency
{
if (!daprOptions.Value.HttpEndpoint.IsNullOrWhiteSpace())
{
DaprEndpoint = daprOptions.Value.HttpEndpoint;
DaprEndpoint = daprOptions.Value.HttpEndpoint!;
}
}
}

2
framework/src/Volo.Abp.Http.Client.IdentityModel.MauiBlazor/Volo.Abp.Http.Client.IdentityModel.MauiBlazor.csproj

@ -5,6 +5,8 @@
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
<PackageId>Volo.Abp.Http.Client.IdentityModel.MauiBlazor</PackageId>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>

2
framework/src/Volo.Abp.Http.Client.IdentityModel.MauiBlazor/Volo/Abp/Http/Client/IdentityModel/MauiBlazor/MauiBlazorAbpAccessTokenProvider.cs

@ -7,7 +7,7 @@ namespace Volo.Abp.Http.Client.IdentityModel.MauiBlazor;
[Dependency(ReplaceServices = true)]
public class MauiBlazorAbpAccessTokenProvider : IAbpAccessTokenProvider, ITransientDependency
{
public virtual Task<string> GetTokenAsync()
public virtual Task<string?> GetTokenAsync()
{
return Task.FromResult(null as string);
}

2
framework/src/Volo.Abp.Http.Client.IdentityModel.Web/Volo.Abp.Http.Client.IdentityModel.Web.csproj

@ -5,6 +5,8 @@
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
<AssemblyName>Volo.Abp.Http.Client.IdentityModel.Web</AssemblyName>
<PackageId>Volo.Abp.Http.Client.IdentityModel.Web</PackageId>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>

2
framework/src/Volo.Abp.Http.Client.IdentityModel.Web/Volo/Abp/Http/Client/IdentityModel/Web/HttpContextAbpAccessTokenProvider.cs

@ -16,7 +16,7 @@ public class HttpContextAbpAccessTokenProvider : IAbpAccessTokenProvider, ITrans
HttpContextAccessor = httpContextAccessor;
}
public virtual async Task<string> GetTokenAsync()
public virtual async Task<string?> GetTokenAsync()
{
var httpContext = HttpContextAccessor?.HttpContext;
if (httpContext == null)

2
framework/src/Volo.Abp.Http.Client.IdentityModel.WebAssembly/Volo.Abp.Http.Client.IdentityModel.WebAssembly.csproj

@ -5,6 +5,8 @@
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
<AssemblyName>Volo.Abp.Http.Client.IdentityModel.WebAssembly</AssemblyName>
<PackageId>Volo.Abp.Http.Client.IdentityModel.WebAssembly</PackageId>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>

4
framework/src/Volo.Abp.Http.Client.IdentityModel.WebAssembly/Volo/Abp/Http/Client/IdentityModel/WebAssembly/WebAssemblyAbpAccessTokenProvider.cs

@ -8,14 +8,14 @@ namespace Volo.Abp.Http.Client.IdentityModel.WebAssembly;
[Dependency(ReplaceServices = true)]
public class WebAssemblyAbpAccessTokenProvider : IAbpAccessTokenProvider, ITransientDependency
{
protected IAccessTokenProvider AccessTokenProvider { get; }
protected IAccessTokenProvider? AccessTokenProvider { get; }
public WebAssemblyAbpAccessTokenProvider(IAccessTokenProvider accessTokenProvider)
{
AccessTokenProvider = accessTokenProvider;
}
public virtual async Task<string> GetTokenAsync()
public virtual async Task<string?> GetTokenAsync()
{
if (AccessTokenProvider == null)
{

2
framework/src/Volo.Abp.Http.Client.IdentityModel/Volo.Abp.Http.Client.IdentityModel.csproj

@ -5,6 +5,8 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net7.0</TargetFrameworks>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
<AssemblyName>Volo.Abp.Http.Client.IdentityModel</AssemblyName>
<PackageId>Volo.Abp.Http.Client.IdentityModel</PackageId>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>

3
framework/src/Volo.Abp.Http.Client.IdentityModel/Volo/Abp/Http/Client/RemoteServiceConfigurationExtensions.cs

@ -8,8 +8,7 @@ public static class RemoteServiceConfigurationExtensions
public const string IdentityClientName = "IdentityClient";
public const string UseCurrentAccessTokenName = "UseCurrentAccessToken";
[CanBeNull]
public static string GetIdentityClient([NotNull] this RemoteServiceConfiguration configuration)
public static string? GetIdentityClient([NotNull] this RemoteServiceConfiguration configuration)
{
Check.NotNullOrEmpty(configuration, nameof(configuration));

2
framework/src/Volo.Abp.Http.Client.Web/Volo.Abp.Http.Client.Web.csproj

@ -5,6 +5,8 @@
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
<AssemblyName>Volo.Abp.Http.Client.Web</AssemblyName>
<PackageId>Volo.Abp.Http.Client.Web</PackageId>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>

18
framework/src/Volo.Abp.Http.Client.Web/Volo/Abp/Http/Client/Web/Conventions/AbpHttpClientProxyServiceConvention.cs

@ -69,7 +69,7 @@ public class AbpHttpClientProxyServiceConvention : AbpServiceConvention
if (controllerApiDescription != null &&
!controllerApiDescription.ControllerGroupName.IsNullOrWhiteSpace())
{
controller.ControllerName = controllerApiDescription.ControllerGroupName;
controller.ControllerName = controllerApiDescription.ControllerGroupName!;
}
ConfigureClientProxySelector(controller);
@ -115,7 +115,7 @@ public class AbpHttpClientProxyServiceConvention : AbpServiceConvention
{
var selector = controller.Selectors.FirstOrDefault();
selector?.EndpointMetadata.Add(new AreaAttribute(moduleApiDescription.RootPath));
controller.RouteValues.Add(new KeyValuePair<string, string>("area", moduleApiDescription.RootPath));
controller.RouteValues.Add(new KeyValuePair<string, string?>("area", moduleApiDescription.RootPath));
}
var controllerType = controller.ControllerType.AsType();
@ -163,7 +163,7 @@ public class AbpHttpClientProxyServiceConvention : AbpServiceConvention
var abpServiceSelectorModel = new SelectorModel
{
AttributeRouteModel = new AttributeRouteModel(new RouteAttribute(template: actionApiDescriptionModel.Url)),
ActionConstraints = { new HttpMethodActionConstraint(new[] { actionApiDescriptionModel.HttpMethod }) }
ActionConstraints = { new HttpMethodActionConstraint(new[] { actionApiDescriptionModel.HttpMethod! }) }
};
action.Selectors.Add(abpServiceSelectorModel);
@ -190,7 +190,7 @@ public class AbpHttpClientProxyServiceConvention : AbpServiceConvention
if (!selector.ActionConstraints.OfType<HttpMethodActionConstraint>().Any())
{
selector.ActionConstraints.Add(new HttpMethodActionConstraint(new[] { httpMethod }));
selector.ActionConstraints.Add(new HttpMethodActionConstraint(new[] { httpMethod! }));
}
}
}
@ -226,7 +226,7 @@ public class AbpHttpClientProxyServiceConvention : AbpServiceConvention
}
}
protected virtual ModuleApiDescriptionModel FindModuleApiDescriptionModel(ControllerModel controller)
protected virtual ModuleApiDescriptionModel? FindModuleApiDescriptionModel(ControllerModel controller)
{
var appServiceType = FindAppServiceInterfaceType(controller);
if (appServiceType == null)
@ -246,7 +246,7 @@ public class AbpHttpClientProxyServiceConvention : AbpServiceConvention
return null;
}
protected virtual ControllerApiDescriptionModel FindControllerApiDescriptionModel(ControllerModel controller)
protected virtual ControllerApiDescriptionModel? FindControllerApiDescriptionModel(ControllerModel controller)
{
var appServiceType = FindAppServiceInterfaceType(controller);
if (appServiceType == null)
@ -266,7 +266,7 @@ public class AbpHttpClientProxyServiceConvention : AbpServiceConvention
return null;
}
protected virtual ActionApiDescriptionModel FindActionApiDescriptionModel(ControllerModel controller, ActionModel action)
protected virtual ActionApiDescriptionModel? FindActionApiDescriptionModel(ControllerModel controller, ActionModel action)
{
var appServiceType = FindAppServiceInterfaceType(controller);
if (appServiceType == null)
@ -285,7 +285,7 @@ public class AbpHttpClientProxyServiceConvention : AbpServiceConvention
return null;
}
if (actionApiDescriptionModel.ImplementFrom.StartsWith("Volo.Abp.Application.Services"))
if (actionApiDescriptionModel.ImplementFrom!.StartsWith("Volo.Abp.Application.Services"))
{
return actionApiDescriptionModel;
}
@ -298,7 +298,7 @@ public class AbpHttpClientProxyServiceConvention : AbpServiceConvention
return null;
}
protected virtual Type FindAppServiceInterfaceType(ControllerModel controller)
protected virtual Type? FindAppServiceInterfaceType(ControllerModel controller)
{
return controller.ControllerType.GetInterfaces()
.FirstOrDefault(type => !type.IsGenericType &&

2
framework/src/Volo.Abp.IdentityModel/Volo.Abp.IdentityModel.csproj

@ -5,6 +5,8 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net7.0</TargetFrameworks>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
<AssemblyName>Volo.Abp.IdentityModel</AssemblyName>
<PackageId>Volo.Abp.IdentityModel</PackageId>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>

4
framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/AbpIdentityClientOptions.cs

@ -14,7 +14,7 @@ public class AbpIdentityClientOptions
IdentityClients = new IdentityClientConfigurationDictionary();
}
public IdentityClientConfiguration GetClientConfiguration(ICurrentTenant currentTenant, string identityClientName = null)
public IdentityClientConfiguration? GetClientConfiguration(ICurrentTenant currentTenant, string? identityClientName = null)
{
if (identityClientName.IsNullOrWhiteSpace())
{
@ -35,7 +35,7 @@ public class AbpIdentityClientOptions
}
}
return IdentityClients.GetOrDefault(identityClientName) ??
return IdentityClients.GetOrDefault(identityClientName!) ??
IdentityClients.Default;
}
}

2
framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IIdentityModelAuthenticationService.cs

@ -9,7 +9,7 @@ public interface IIdentityModelAuthenticationService
{
Task<bool> TryAuthenticateAsync(
[NotNull] HttpClient client,
string identityClientName = null);
string? identityClientName = null);
Task<string> GetAccessTokenAsync(
IdentityClientConfiguration configuration);

20
framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IdentityClientConfiguration.cs

@ -5,14 +5,14 @@ using IdentityModel;
namespace Volo.Abp.IdentityModel;
public class IdentityClientConfiguration : Dictionary<string, string>
public class IdentityClientConfiguration : Dictionary<string, string?>
{
/// <summary>
/// Possible values: "client_credentials" or "password".
/// Default value: "client_credentials".
/// </summary>
public string GrantType {
get => this.GetOrDefault(nameof(GrantType));
get => this.GetOrDefault(nameof(GrantType))!;
set => this[nameof(GrantType)] = value;
}
@ -20,7 +20,7 @@ public class IdentityClientConfiguration : Dictionary<string, string>
/// Client Id.
/// </summary>
public string ClientId {
get => this.GetOrDefault(nameof(ClientId));
get => this.GetOrDefault(nameof(ClientId))!;
set => this[nameof(ClientId)] = value;
}
@ -28,7 +28,7 @@ public class IdentityClientConfiguration : Dictionary<string, string>
/// Client secret (as plain text - without hashed).
/// </summary>
public string ClientSecret {
get => this.GetOrDefault(nameof(ClientSecret));
get => this.GetOrDefault(nameof(ClientSecret))!;
set => this[nameof(ClientSecret)] = value;
}
@ -36,7 +36,7 @@ public class IdentityClientConfiguration : Dictionary<string, string>
/// User name.
/// Valid only if <see cref="GrantType"/> is "password".
/// </summary>
public string UserName {
public string? UserName {
get => this.GetOrDefault(nameof(UserName));
set => this[nameof(UserName)] = value;
}
@ -45,7 +45,7 @@ public class IdentityClientConfiguration : Dictionary<string, string>
/// Password of the <see cref="UserName"/>.
/// Valid only if <see cref="GrantType"/> is "password".
/// </summary>
public string UserPassword {
public string? UserPassword {
get => this.GetOrDefault(nameof(UserPassword));
set => this[nameof(UserPassword)] = value;
}
@ -54,7 +54,7 @@ public class IdentityClientConfiguration : Dictionary<string, string>
/// Authority.
/// </summary>
public string Authority {
get => this.GetOrDefault(nameof(Authority));
get => this.GetOrDefault(nameof(Authority))!;
set => this[nameof(Authority)] = value;
}
@ -62,7 +62,7 @@ public class IdentityClientConfiguration : Dictionary<string, string>
/// Scope.
/// </summary>
public string Scope {
get => this.GetOrDefault(nameof(Scope));
get => this.GetOrDefault(nameof(Scope))!;
set => this[nameof(Scope)] = value;
}
@ -113,8 +113,8 @@ public class IdentityClientConfiguration : Dictionary<string, string>
string clientId,
string clientSecret,
string grantType = OidcConstants.GrantTypes.ClientCredentials,
string userName = null,
string userPassword = null,
string? userName = null,
string? userPassword = null,
bool requireHttps = true,
int cacheAbsoluteExpiration = 60 * 30,
bool validateIssuerName = true,

4
framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IdentityClientConfigurationDictionary.cs

@ -2,11 +2,11 @@
namespace Volo.Abp.IdentityModel;
public class IdentityClientConfigurationDictionary : Dictionary<string, IdentityClientConfiguration>
public class IdentityClientConfigurationDictionary : Dictionary<string, IdentityClientConfiguration?>
{
public const string DefaultName = "Default";
public IdentityClientConfiguration Default {
public IdentityClientConfiguration? Default {
get => this.GetOrDefault(DefaultName);
set => this[DefaultName] = value;
}

4
framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IdentityModelAuthenticationService.cs

@ -54,7 +54,7 @@ public class IdentityModelAuthenticationService : IIdentityModelAuthenticationSe
public async Task<bool> TryAuthenticateAsync(
[NotNull] HttpClient client,
string identityClientName = null)
string? identityClientName = null)
{
var accessToken = await GetAccessTokenOrNullAsync(identityClientName);
if (accessToken == null)
@ -66,7 +66,7 @@ public class IdentityModelAuthenticationService : IIdentityModelAuthenticationSe
return true;
}
protected virtual async Task<string> GetAccessTokenOrNullAsync(string identityClientName)
protected virtual async Task<string?> GetAccessTokenOrNullAsync(string? identityClientName)
{
var configuration = ClientOptions.GetClientConfiguration(CurrentTenant, identityClientName);
if (configuration == null)

4
framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IdentityModelDiscoveryDocumentCacheItem.cs

@ -7,9 +7,9 @@ namespace Volo.Abp.IdentityModel;
[IgnoreMultiTenancy]
public class IdentityModelDiscoveryDocumentCacheItem
{
public string TokenEndpoint { get; set; }
public string TokenEndpoint { get; set; } = default!;
public string DeviceAuthorizationEndpoint { get; set; }
public string DeviceAuthorizationEndpoint { get; set; } = default!;
public IdentityModelDiscoveryDocumentCacheItem()
{

2
framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IdentityModelHttpRequestMessageOptions.cs

@ -5,5 +5,5 @@ namespace Volo.Abp.IdentityModel;
public class IdentityModelHttpRequestMessageOptions
{
public Action<HttpRequestMessage> ConfigureHttpRequestMessage { get; set; }
public Action<HttpRequestMessage>? ConfigureHttpRequestMessage { get; set; }
}

2
framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IdentityModelTokenCacheItem.cs

@ -7,7 +7,7 @@ namespace Volo.Abp.IdentityModel;
[Serializable]
public class IdentityModelTokenCacheItem
{
public string AccessToken { get; set; }
public string AccessToken { get; set; } = default!;
public IdentityModelTokenCacheItem()
{

Loading…
Cancel
Save