Browse Source

Merge pull request #17096 from abpframework/liangshiwei/group6

pull/17107/head
maliming 3 years ago
committed by GitHub
parent
commit
415e109742
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      framework/src/Volo.Abp.AspNetCore.Serilog/Volo.Abp.AspNetCore.Serilog.csproj
  2. 2
      framework/src/Volo.Abp.AspNetCore.SignalR/Volo.Abp.AspNetCore.SignalR.csproj
  3. 2
      framework/src/Volo.Abp.AspNetCore.SignalR/Volo/Abp/AspNetCore/SignalR/AbpAspNetCoreSignalRModule.cs
  4. 48
      framework/src/Volo.Abp.AspNetCore.SignalR/Volo/Abp/AspNetCore/SignalR/AbpHub.cs
  5. 4
      framework/src/Volo.Abp.AspNetCore.SignalR/Volo/Abp/AspNetCore/SignalR/AbpHubContext.cs
  6. 2
      framework/src/Volo.Abp.AspNetCore.SignalR/Volo/Abp/AspNetCore/SignalR/AbpHubContextAccessorHubFilter.cs
  7. 2
      framework/src/Volo.Abp.AspNetCore.SignalR/Volo/Abp/AspNetCore/SignalR/AbpSignalRUserIdProvider.cs
  8. 4
      framework/src/Volo.Abp.AspNetCore.SignalR/Volo/Abp/AspNetCore/SignalR/Auditing/AbpAuditHubFilter.cs
  9. 10
      framework/src/Volo.Abp.AspNetCore.SignalR/Volo/Abp/AspNetCore/SignalR/Authentication/AbpAuthenticationHubFilter.cs
  10. 2
      framework/src/Volo.Abp.AspNetCore.SignalR/Volo/Abp/AspNetCore/SignalR/DefaultAbpHubContextAccessor.cs
  11. 2
      framework/src/Volo.Abp.AspNetCore.SignalR/Volo/Abp/AspNetCore/SignalR/HubConfig.cs
  12. 4
      framework/src/Volo.Abp.AspNetCore.SignalR/Volo/Abp/AspNetCore/SignalR/HubConfigList.cs
  13. 2
      framework/src/Volo.Abp.AspNetCore.TestBase/Volo.Abp.AspNetCore.TestBase.csproj
  14. 12
      framework/src/Volo.Abp.AspNetCore.TestBase/Volo/Abp/AspNetCore/TestBase/AbpAspNetCoreAsyncIntegratedTestBase.cs
  15. 2
      framework/src/Volo.Abp.AspNetCore.TestBase/Volo/Abp/AspNetCore/TestBase/TestServerAccessor.cs

2
framework/src/Volo.Abp.AspNetCore.Serilog/Volo.Abp.AspNetCore.Serilog.csproj

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

2
framework/src/Volo.Abp.AspNetCore.SignalR/Volo.Abp.AspNetCore.SignalR.csproj

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

2
framework/src/Volo.Abp.AspNetCore.SignalR/Volo/Abp/AspNetCore/SignalR/AbpAspNetCoreSignalRModule.cs

@ -23,7 +23,7 @@ public class AbpAspNetCoreSignalRModule : AbpModule
{
private static readonly MethodInfo MapHubGenericMethodInfo =
typeof(AbpAspNetCoreSignalRModule)
.GetMethod("MapHub", BindingFlags.Static | BindingFlags.NonPublic);
.GetMethod("MapHub", BindingFlags.Static | BindingFlags.NonPublic)!;
public override void PreConfigureServices(ServiceConfigurationContext context)
{

48
framework/src/Volo.Abp.AspNetCore.SignalR/Volo/Abp/AspNetCore/SignalR/AbpHub.cs

@ -14,24 +14,24 @@ namespace Volo.Abp.AspNetCore.SignalR;
public abstract class AbpHub : Hub
{
public IAbpLazyServiceProvider LazyServiceProvider { get; set; }
public IAbpLazyServiceProvider LazyServiceProvider { get; set; } = default!;
[Obsolete("Use LazyServiceProvider instead.")]
public IServiceProvider ServiceProvider { get; set; }
public IServiceProvider ServiceProvider { get; set; } = default!;
protected ILoggerFactory LoggerFactory => LazyServiceProvider.LazyGetService<ILoggerFactory>();
protected ILoggerFactory? LoggerFactory => LazyServiceProvider.LazyGetService<ILoggerFactory>();
protected ILogger Logger => LazyServiceProvider.LazyGetService<ILogger>(provider => LoggerFactory?.CreateLogger(GetType().FullName) ?? NullLogger.Instance);
protected ILogger Logger => LazyServiceProvider.LazyGetService<ILogger>(provider => LoggerFactory?.CreateLogger(GetType().FullName!) ?? NullLogger.Instance);
protected ICurrentUser CurrentUser => LazyServiceProvider.LazyGetService<ICurrentUser>();
protected ICurrentUser CurrentUser => LazyServiceProvider.LazyGetService<ICurrentUser>()!;
protected ICurrentTenant CurrentTenant => LazyServiceProvider.LazyGetService<ICurrentTenant>();
protected ICurrentTenant CurrentTenant => LazyServiceProvider.LazyGetService<ICurrentTenant>()!;
protected IAuthorizationService AuthorizationService => LazyServiceProvider.LazyGetService<IAuthorizationService>();
protected IAuthorizationService AuthorizationService => LazyServiceProvider.LazyGetService<IAuthorizationService>()!;
protected IClock Clock => LazyServiceProvider.LazyGetService<IClock>();
protected IClock Clock => LazyServiceProvider.LazyGetService<IClock>()!;
protected IStringLocalizerFactory StringLocalizerFactory => LazyServiceProvider.LazyGetService<IStringLocalizerFactory>();
protected IStringLocalizerFactory StringLocalizerFactory => LazyServiceProvider.LazyGetService<IStringLocalizerFactory>()!;
protected IStringLocalizer L {
get {
@ -43,16 +43,16 @@ public abstract class AbpHub : Hub
return _localizer;
}
}
private IStringLocalizer _localizer;
private IStringLocalizer? _localizer;
protected Type LocalizationResource {
protected Type? LocalizationResource {
get => _localizationResource;
set {
_localizationResource = value;
_localizer = null;
}
}
private Type _localizationResource = typeof(DefaultResource);
private Type? _localizationResource = typeof(DefaultResource);
protected virtual IStringLocalizer CreateLocalizer()
{
@ -74,23 +74,23 @@ public abstract class AbpHub : Hub
public abstract class AbpHub<T> : Hub<T>
where T : class
{
public IAbpLazyServiceProvider LazyServiceProvider { get; set; }
public IAbpLazyServiceProvider LazyServiceProvider { get; set; } = default!;
public IServiceProvider ServiceProvider { get; set; }
public IServiceProvider ServiceProvider { get; set; } = default!;
protected ILoggerFactory LoggerFactory => LazyServiceProvider.LazyGetService<ILoggerFactory>();
protected ILoggerFactory? LoggerFactory => LazyServiceProvider.LazyGetService<ILoggerFactory>();
protected ILogger Logger => LazyServiceProvider.LazyGetService<ILogger>(provider => LoggerFactory?.CreateLogger(GetType().FullName) ?? NullLogger.Instance);
protected ILogger Logger => LazyServiceProvider.LazyGetService<ILogger>(provider => LoggerFactory?.CreateLogger(GetType().FullName!) ?? NullLogger.Instance);
protected ICurrentUser CurrentUser => LazyServiceProvider.LazyGetService<ICurrentUser>();
protected ICurrentUser CurrentUser => LazyServiceProvider.LazyGetService<ICurrentUser>()!;
protected ICurrentTenant CurrentTenant => LazyServiceProvider.LazyGetService<ICurrentTenant>();
protected ICurrentTenant CurrentTenant => LazyServiceProvider.LazyGetService<ICurrentTenant>()!;
protected IAuthorizationService AuthorizationService => LazyServiceProvider.LazyGetService<IAuthorizationService>();
protected IAuthorizationService AuthorizationService => LazyServiceProvider.LazyGetService<IAuthorizationService>()!;
protected IClock Clock => LazyServiceProvider.LazyGetService<IClock>();
protected IClock Clock => LazyServiceProvider.LazyGetService<IClock>()!;
protected IStringLocalizerFactory StringLocalizerFactory => LazyServiceProvider.LazyGetService<IStringLocalizerFactory>();
protected IStringLocalizerFactory StringLocalizerFactory => LazyServiceProvider.LazyGetService<IStringLocalizerFactory>()!;
protected IStringLocalizer L {
get {
@ -102,16 +102,16 @@ public abstract class AbpHub<T> : Hub<T>
return _localizer;
}
}
private IStringLocalizer _localizer;
private IStringLocalizer? _localizer;
protected Type LocalizationResource {
protected Type? LocalizationResource {
get => _localizationResource;
set {
_localizationResource = value;
_localizer = null;
}
}
private Type _localizationResource = typeof(DefaultResource);
private Type? _localizationResource = typeof(DefaultResource);
protected virtual IStringLocalizer CreateLocalizer()
{

4
framework/src/Volo.Abp.AspNetCore.SignalR/Volo/Abp/AspNetCore/SignalR/AbpHubContext.cs

@ -13,9 +13,9 @@ public class AbpHubContext
public MethodInfo HubMethod { get; }
public IReadOnlyList<object> HubMethodArguments { get; }
public IReadOnlyList<object?> HubMethodArguments { get; }
public AbpHubContext(IServiceProvider serviceProvider, Hub hub, MethodInfo hubMethod, IReadOnlyList<object> hubMethodArguments)
public AbpHubContext(IServiceProvider serviceProvider, Hub hub, MethodInfo hubMethod, IReadOnlyList<object?> hubMethodArguments)
{
ServiceProvider = serviceProvider;
Hub = hub;

2
framework/src/Volo.Abp.AspNetCore.SignalR/Volo/Abp/AspNetCore/SignalR/AbpHubContextAccessorHubFilter.cs

@ -7,7 +7,7 @@ namespace Volo.Abp.AspNetCore.SignalR;
public class AbpHubContextAccessorHubFilter : IHubFilter
{
public virtual async ValueTask<object> InvokeMethodAsync(HubInvocationContext invocationContext, Func<HubInvocationContext, ValueTask<object>> next)
public virtual async ValueTask<object?> InvokeMethodAsync(HubInvocationContext invocationContext, Func<HubInvocationContext, ValueTask<object?>> next)
{
var hubContextAccessor = invocationContext.ServiceProvider.GetRequiredService<IAbpHubContextAccessor>();
using (hubContextAccessor.Change(new AbpHubContext(

2
framework/src/Volo.Abp.AspNetCore.SignalR/Volo/Abp/AspNetCore/SignalR/AbpSignalRUserIdProvider.cs

@ -17,7 +17,7 @@ public class AbpSignalRUserIdProvider : IUserIdProvider, ITransientDependency
_currentUser = currentUser;
}
public virtual string GetUserId(HubConnectionContext connection)
public virtual string? GetUserId(HubConnectionContext connection)
{
using (_currentPrincipalAccessor.Change(connection.User))
{

4
framework/src/Volo.Abp.AspNetCore.SignalR/Volo/Abp/AspNetCore/SignalR/Auditing/AbpAuditHubFilter.cs

@ -14,7 +14,7 @@ namespace Volo.Abp.AspNetCore.SignalR.Auditing;
public class AbpAuditHubFilter : IHubFilter
{
public virtual async ValueTask<object> InvokeMethodAsync(HubInvocationContext invocationContext, Func<HubInvocationContext, ValueTask<object>> next)
public virtual async ValueTask<object?> InvokeMethodAsync(HubInvocationContext invocationContext, Func<HubInvocationContext, ValueTask<object?>> next)
{
var options = invocationContext.ServiceProvider.GetRequiredService<IOptions<AbpAuditingOptions>>().Value;
if (!options.IsEnabled)
@ -27,7 +27,7 @@ public class AbpAuditHubFilter : IHubFilter
using (var saveHandle = auditingManager.BeginScope())
{
Debug.Assert(auditingManager.Current != null);
object result;
object? result;
try
{
result = await next(invocationContext);

10
framework/src/Volo.Abp.AspNetCore.SignalR/Volo/Abp/AspNetCore/SignalR/Authentication/AbpAuthenticationHubFilter.cs

@ -8,10 +8,10 @@ namespace Volo.Abp.AspNetCore.SignalR.Authentication;
public class AbpAuthenticationHubFilter : IHubFilter
{
public virtual async ValueTask<object> InvokeMethodAsync(HubInvocationContext invocationContext, Func<HubInvocationContext, ValueTask<object>> next)
public virtual async ValueTask<object?> InvokeMethodAsync(HubInvocationContext invocationContext, Func<HubInvocationContext, ValueTask<object?>> next)
{
var currentPrincipalAccessor = invocationContext.ServiceProvider.GetRequiredService<ICurrentPrincipalAccessor>();
using (currentPrincipalAccessor.Change(invocationContext.Context.User))
using (currentPrincipalAccessor.Change(invocationContext.Context.User!))
{
return await next(invocationContext);
}
@ -20,16 +20,16 @@ public class AbpAuthenticationHubFilter : IHubFilter
public virtual async Task OnConnectedAsync(HubLifetimeContext context, Func<HubLifetimeContext, Task> next)
{
var currentPrincipalAccessor = context.ServiceProvider.GetRequiredService<ICurrentPrincipalAccessor>();
using (currentPrincipalAccessor.Change(context.Context.User))
using (currentPrincipalAccessor.Change(context.Context.User!))
{
await next(context);
}
}
public virtual async Task OnDisconnectedAsync(HubLifetimeContext context, Exception exception, Func<HubLifetimeContext, Exception, Task> next)
public virtual async Task OnDisconnectedAsync(HubLifetimeContext context, Exception? exception, Func<HubLifetimeContext, Exception?, Task> next)
{
var currentPrincipalAccessor = context.ServiceProvider.GetRequiredService<ICurrentPrincipalAccessor>();
using (currentPrincipalAccessor.Change(context.Context.User))
using (currentPrincipalAccessor.Change(context.Context.User!))
{
await next(context, exception);
}

2
framework/src/Volo.Abp.AspNetCore.SignalR/Volo/Abp/AspNetCore/SignalR/DefaultAbpHubContextAccessor.cs

@ -6,7 +6,7 @@ namespace Volo.Abp.AspNetCore.SignalR;
public class DefaultAbpHubContextAccessor : IAbpHubContextAccessor, ISingletonDependency
{
public AbpHubContext Context => _currentHubContext.Value;
public AbpHubContext Context => _currentHubContext.Value!;
private readonly AsyncLocal<AbpHubContext> _currentHubContext = new AsyncLocal<AbpHubContext>();

2
framework/src/Volo.Abp.AspNetCore.SignalR/Volo/Abp/AspNetCore/SignalR/HubConfig.cs

@ -20,7 +20,7 @@ public class HubConfig
public HubConfig(
[NotNull] Type hubType,
[NotNull] string routePattern,
[CanBeNull] Action<HttpConnectionDispatcherOptions> configureAction = null)
Action<HttpConnectionDispatcherOptions>? configureAction = null)
{
HubType = Check.NotNull(hubType, nameof(hubType));
RoutePattern = Check.NotNullOrWhiteSpace(routePattern, nameof(routePattern));

4
framework/src/Volo.Abp.AspNetCore.SignalR/Volo/Abp/AspNetCore/SignalR/HubConfigList.cs

@ -6,12 +6,12 @@ namespace Volo.Abp.AspNetCore.SignalR;
public class HubConfigList : List<HubConfig>
{
public void AddOrUpdate<THub>(Action<HubConfig> configAction = null)
public void AddOrUpdate<THub>(Action<HubConfig>? configAction = null)
{
AddOrUpdate(typeof(THub));
}
public void AddOrUpdate(Type hubType, Action<HubConfig> configAction = null)
public void AddOrUpdate(Type hubType, Action<HubConfig>? configAction = null)
{
var hubConfig = this.GetOrAdd(
c => c.HubType == hubType,

2
framework/src/Volo.Abp.AspNetCore.TestBase/Volo.Abp.AspNetCore.TestBase.csproj

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

12
framework/src/Volo.Abp.AspNetCore.TestBase/Volo/Abp/AspNetCore/TestBase/AbpAspNetCoreAsyncIntegratedTestBase.cs

@ -16,20 +16,20 @@ namespace Volo.Abp.AspNetCore.TestBase;
public class AbpAspNetCoreAsyncIntegratedTestBase<TModule>
where TModule : IAbpModule
{
protected WebApplication WebApplication { get; set; }
protected WebApplication WebApplication { get; set; } = default!;
protected TestServer Server { get; set; }
protected TestServer Server { get; set; } = default!;
protected HttpClient Client { get; set; }
protected HttpClient Client { get; set; } = default!;
protected IServiceProvider ServiceProvider { get; set; }
protected IServiceProvider ServiceProvider { get; set; } = default!;
protected virtual T GetService<T>()
protected virtual T? GetService<T>()
{
return ServiceProvider.GetService<T>();
}
protected virtual T GetRequiredService<T>()
protected virtual T GetRequiredService<T>() where T : notnull
{
return ServiceProvider.GetRequiredService<T>();
}

2
framework/src/Volo.Abp.AspNetCore.TestBase/Volo/Abp/AspNetCore/TestBase/TestServerAccessor.cs

@ -5,5 +5,5 @@ namespace Volo.Abp.AspNetCore.TestBase;
public class TestServerAccessor : ITestServerAccessor, ISingletonDependency
{
public TestServer Server { get; set; }
public TestServer Server { get; set; } = default!;
}

Loading…
Cancel
Save