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> <PropertyGroup>
<TargetFramework>net7.0</TargetFramework> <TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
<AssemblyName>Volo.Abp.AspNetCore.Serilog</AssemblyName> <AssemblyName>Volo.Abp.AspNetCore.Serilog</AssemblyName>
<PackageId>Volo.Abp.AspNetCore.Serilog</PackageId> <PackageId>Volo.Abp.AspNetCore.Serilog</PackageId>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback> <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> <PropertyGroup>
<TargetFramework>net7.0</TargetFramework> <TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
<AssemblyName>Volo.Abp.AspNetCore.SignalR</AssemblyName> <AssemblyName>Volo.Abp.AspNetCore.SignalR</AssemblyName>
<PackageId>Volo.Abp.AspNetCore.SignalR</PackageId> <PackageId>Volo.Abp.AspNetCore.SignalR</PackageId>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback> <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 = private static readonly MethodInfo MapHubGenericMethodInfo =
typeof(AbpAspNetCoreSignalRModule) typeof(AbpAspNetCoreSignalRModule)
.GetMethod("MapHub", BindingFlags.Static | BindingFlags.NonPublic); .GetMethod("MapHub", BindingFlags.Static | BindingFlags.NonPublic)!;
public override void PreConfigureServices(ServiceConfigurationContext context) 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 abstract class AbpHub : Hub
{ {
public IAbpLazyServiceProvider LazyServiceProvider { get; set; } public IAbpLazyServiceProvider LazyServiceProvider { get; set; } = default!;
[Obsolete("Use LazyServiceProvider instead.")] [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 { protected IStringLocalizer L {
get { get {
@ -43,16 +43,16 @@ public abstract class AbpHub : Hub
return _localizer; return _localizer;
} }
} }
private IStringLocalizer _localizer; private IStringLocalizer? _localizer;
protected Type LocalizationResource { protected Type? LocalizationResource {
get => _localizationResource; get => _localizationResource;
set { set {
_localizationResource = value; _localizationResource = value;
_localizer = null; _localizer = null;
} }
} }
private Type _localizationResource = typeof(DefaultResource); private Type? _localizationResource = typeof(DefaultResource);
protected virtual IStringLocalizer CreateLocalizer() protected virtual IStringLocalizer CreateLocalizer()
{ {
@ -74,23 +74,23 @@ public abstract class AbpHub : Hub
public abstract class AbpHub<T> : Hub<T> public abstract class AbpHub<T> : Hub<T>
where T : class 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 { protected IStringLocalizer L {
get { get {
@ -102,16 +102,16 @@ public abstract class AbpHub<T> : Hub<T>
return _localizer; return _localizer;
} }
} }
private IStringLocalizer _localizer; private IStringLocalizer? _localizer;
protected Type LocalizationResource { protected Type? LocalizationResource {
get => _localizationResource; get => _localizationResource;
set { set {
_localizationResource = value; _localizationResource = value;
_localizer = null; _localizer = null;
} }
} }
private Type _localizationResource = typeof(DefaultResource); private Type? _localizationResource = typeof(DefaultResource);
protected virtual IStringLocalizer CreateLocalizer() 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 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; ServiceProvider = serviceProvider;
Hub = hub; 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 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>(); var hubContextAccessor = invocationContext.ServiceProvider.GetRequiredService<IAbpHubContextAccessor>();
using (hubContextAccessor.Change(new AbpHubContext( 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; _currentUser = currentUser;
} }
public virtual string GetUserId(HubConnectionContext connection) public virtual string? GetUserId(HubConnectionContext connection)
{ {
using (_currentPrincipalAccessor.Change(connection.User)) 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 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; var options = invocationContext.ServiceProvider.GetRequiredService<IOptions<AbpAuditingOptions>>().Value;
if (!options.IsEnabled) if (!options.IsEnabled)
@ -27,7 +27,7 @@ public class AbpAuditHubFilter : IHubFilter
using (var saveHandle = auditingManager.BeginScope()) using (var saveHandle = auditingManager.BeginScope())
{ {
Debug.Assert(auditingManager.Current != null); Debug.Assert(auditingManager.Current != null);
object result; object? result;
try try
{ {
result = await next(invocationContext); 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 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>(); var currentPrincipalAccessor = invocationContext.ServiceProvider.GetRequiredService<ICurrentPrincipalAccessor>();
using (currentPrincipalAccessor.Change(invocationContext.Context.User)) using (currentPrincipalAccessor.Change(invocationContext.Context.User!))
{ {
return await next(invocationContext); return await next(invocationContext);
} }
@ -20,16 +20,16 @@ public class AbpAuthenticationHubFilter : IHubFilter
public virtual async Task OnConnectedAsync(HubLifetimeContext context, Func<HubLifetimeContext, Task> next) public virtual async Task OnConnectedAsync(HubLifetimeContext context, Func<HubLifetimeContext, Task> next)
{ {
var currentPrincipalAccessor = context.ServiceProvider.GetRequiredService<ICurrentPrincipalAccessor>(); var currentPrincipalAccessor = context.ServiceProvider.GetRequiredService<ICurrentPrincipalAccessor>();
using (currentPrincipalAccessor.Change(context.Context.User)) using (currentPrincipalAccessor.Change(context.Context.User!))
{ {
await next(context); 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>(); var currentPrincipalAccessor = context.ServiceProvider.GetRequiredService<ICurrentPrincipalAccessor>();
using (currentPrincipalAccessor.Change(context.Context.User)) using (currentPrincipalAccessor.Change(context.Context.User!))
{ {
await next(context, exception); 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 class DefaultAbpHubContextAccessor : IAbpHubContextAccessor, ISingletonDependency
{ {
public AbpHubContext Context => _currentHubContext.Value; public AbpHubContext Context => _currentHubContext.Value!;
private readonly AsyncLocal<AbpHubContext> _currentHubContext = new AsyncLocal<AbpHubContext>(); 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( public HubConfig(
[NotNull] Type hubType, [NotNull] Type hubType,
[NotNull] string routePattern, [NotNull] string routePattern,
[CanBeNull] Action<HttpConnectionDispatcherOptions> configureAction = null) Action<HttpConnectionDispatcherOptions>? configureAction = null)
{ {
HubType = Check.NotNull(hubType, nameof(hubType)); HubType = Check.NotNull(hubType, nameof(hubType));
RoutePattern = Check.NotNullOrWhiteSpace(routePattern, nameof(routePattern)); 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 class HubConfigList : List<HubConfig>
{ {
public void AddOrUpdate<THub>(Action<HubConfig> configAction = null) public void AddOrUpdate<THub>(Action<HubConfig>? configAction = null)
{ {
AddOrUpdate(typeof(THub)); 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( var hubConfig = this.GetOrAdd(
c => c.HubType == hubType, c => c.HubType == hubType,

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

@ -5,6 +5,8 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>net7.0</TargetFramework> <TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
<AssemblyName>Volo.Abp.AspNetCore.TestBase</AssemblyName> <AssemblyName>Volo.Abp.AspNetCore.TestBase</AssemblyName>
<PackageId>Volo.Abp.AspNetCore.TestBase</PackageId> <PackageId>Volo.Abp.AspNetCore.TestBase</PackageId>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback> <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> public class AbpAspNetCoreAsyncIntegratedTestBase<TModule>
where TModule : IAbpModule 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>(); return ServiceProvider.GetService<T>();
} }
protected virtual T GetRequiredService<T>() protected virtual T GetRequiredService<T>() where T : notnull
{ {
return ServiceProvider.GetRequiredService<T>(); 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 class TestServerAccessor : ITestServerAccessor, ISingletonDependency
{ {
public TestServer Server { get; set; } public TestServer Server { get; set; } = default!;
} }

Loading…
Cancel
Save