Browse Source

Merge pull request #24281 from abpframework/auto-merge/rel-10-0/4161

Merge branch dev with rel-10.0
pull/24287/head
Ma Liming 2 months ago
committed by GitHub
parent
commit
a3ed100939
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 3
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationPartSorter.cs
  2. 13
      framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/ApplicationPart/ApplicationPartSorter_Tests.cs

3
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationPartSorter.cs

@ -15,7 +15,8 @@ public static class ApplicationPartSorter
{
var orderedModuleAssemblies = moduleContainer.Modules
.Select((moduleDescriptor, index) => new { moduleDescriptor.Assembly, index })
.ToDictionary(x => x.Assembly, x => x.index);
.GroupBy(x => x.Assembly)
.ToDictionary(g => g.Key, g => g.First().index);
var modulesAssemblies = moduleContainer.Modules.Select(x => x.Assembly).ToList();
var sortedTypes = partManager.ApplicationParts

13
framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/ApplicationPart/ApplicationPartSorter_Tests.cs

@ -26,6 +26,13 @@ public class ApplicationPartSorter_Tests
partManager.ApplicationParts.Add(new AssemblyPart(assembly));
moduleDescriptors.Add(CreateModuleDescriptor(assembly));
}
var dumplicateAssembly = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName($"ModuleB.dll"), AssemblyBuilderAccess.Run);
partManager.ApplicationParts.Add(new AssemblyPart(dumplicateAssembly));
partManager.ApplicationParts.Add(new AssemblyPart(dumplicateAssembly));
moduleDescriptors.Add(CreateModuleDescriptor(dumplicateAssembly));
moduleDescriptors.Add(CreateModuleDescriptor(dumplicateAssembly));
var randomApplicationParts = partManager.ApplicationParts.OrderBy(x => Guid.NewGuid()).ToList(); // Shuffle the parts
// Additional part
@ -44,7 +51,7 @@ public class ApplicationPartSorter_Tests
ApplicationPartSorter.Sort(partManager, moduleContainer);
// Act
partManager.ApplicationParts.Count.ShouldBe(13); // 10 modules + 3 additional parts
partManager.ApplicationParts.Count.ShouldBe(15); // 10 modules + 3 additional parts + 2 duplicate parts
var applicationParts = partManager.ApplicationParts.Reverse().ToList(); // Reverse the order to match the expected output
@ -60,7 +67,9 @@ public class ApplicationPartSorter_Tests
applicationParts[9].ShouldBeOfType<AssemblyPart>().Assembly.GetName().Name.ShouldStartWith("ModuleA7");
applicationParts[10].ShouldBeOfType<AssemblyPart>().Assembly.GetName().Name.ShouldStartWith("ModuleA8");
applicationParts[11].ShouldBeOfType<AssemblyPart>().Assembly.GetName().Name.ShouldStartWith("ModuleA9");
applicationParts[12].ShouldBeOfType<CompiledRazorAssemblyPart>().Assembly.ShouldBe(typeof(AbpVirtualFileSystemModule).Assembly);
applicationParts[12].ShouldBeOfType<AssemblyPart>().Assembly.GetName().Name.ShouldStartWith("ModuleB");
applicationParts[13].ShouldBeOfType<AssemblyPart>().Assembly.GetName().Name.ShouldStartWith("ModuleB");
applicationParts[14].ShouldBeOfType<CompiledRazorAssemblyPart>().Assembly.ShouldBe(typeof(AbpVirtualFileSystemModule).Assembly);
}
private static IModuleContainer CreateFakeModuleContainer(List<IAbpModuleDescriptor> moduleDescriptors)

Loading…
Cancel
Save