Browse Source

`GetDefaultServices` without case sensitive.

Resolve #20022
pull/20023/head
maliming 2 years ago
parent
commit
aa727a85a7
No known key found for this signature in database GPG Key ID: A646B9CB645ECEA4
  1. 2
      framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/ExposeServicesAttribute.cs
  2. 20
      framework/test/Volo.Abp.Core.Tests/Volo/Abp/DependencyInjection/AutoRegistrationHelper_Tests.cs

2
framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/ExposeServicesAttribute.cs

@ -60,7 +60,7 @@ public class ExposeServicesAttribute : Attribute, IExposedServiceTypesProvider
interfaceName = interfaceName.Right(interfaceName.Length - 1); interfaceName = interfaceName.Right(interfaceName.Length - 1);
} }
if (type.Name.EndsWith(interfaceName)) if (type.Name.EndsWith(interfaceName, StringComparison.OrdinalIgnoreCase))
{ {
serviceTypes.Add(interfaceType); serviceTypes.Add(interfaceType);
} }

20
framework/test/Volo.Abp.Core.Tests/Volo/Abp/DependencyInjection/AutoRegistrationHelper_Tests.cs

@ -20,6 +20,22 @@ public class AutoRegistrationHelper_Tests
exposedServices.ShouldContain(typeof(IDerivedService)); exposedServices.ShouldContain(typeof(IDerivedService));
} }
[Fact]
public void Should_Get_Conventional_Exposed_Types_By_Default_Case_Insensitive()
{
//Act
var exposedServices = ExposedServiceExplorer.GetExposedServices(typeof(defaultderivedservice));
//Assert
exposedServices.Count.ShouldBe(3);
exposedServices.ShouldContain(typeof(defaultderivedservice));
exposedServices.ShouldContain(typeof(IService));
exposedServices.ShouldContain(typeof(IDerivedService));
}
[Fact] [Fact]
public void Should_Get_Custom_Exposed_Types_If_Available() public void Should_Get_Custom_Exposed_Types_If_Available()
{ {
@ -52,6 +68,10 @@ public class AutoRegistrationHelper_Tests
{ {
} }
public class defaultderivedservice : IDerivedService
{
}
public interface IService public interface IService
{ {
} }

Loading…
Cancel
Save