Open Closed

ABP CLI 7.0.1 Creates Code That Uses Volo.* 7.0.0 Packages and Upgrading Throws Automapper Exceptions #4402


User avatar
0
tylerje created

If you're creating a bug/problem report, please include followings:

  • ABP Framework version: v7.0.1
  • UI type: blazor-server
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no
  • Exception message and stack trace:

AutoMapper.AutoMapperConfigurationException: Unmapped members were found. Review the types and members below. Add a custom mapping expression, ignore, add a custom resolver, or modify the source/destination type For no matching constructor, add a no-arg ctor, add optional arguments, or map all of the constructor parameters

Language -> LanguageInfo (Destination member list) Volo.Abp.LanguageManagement.Language -> Volo.Abp.Localization.LanguageInfo (Destination member list)

Unmapped properties: TwoLetterISOLanguageName

at Volo.Abp.AutoMapper.AbpAutoMapperModule.<>c__DisplayClass2_1.<CreateMappings>g__ValidateAll|2(IConfigurationProvider config) at Volo.Abp.AutoMapper.AbpAutoMapperModule.CreateMappings(IServiceProvider serviceProvider) at Autofac.Extensions.DependencyInjection.AutofacRegistration.<>c__DisplayClass3_0.<Register>b__0(IComponentContext context, IEnumerable1 parameters) at Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable1 parameters) at Autofac.Core.Activators.Delegate.DelegateActivator.<ConfigurePipeline>b__2_0(ResolveRequestContext ctxt, Action1 next) at Autofac.Core.Resolving.Middleware.DelegateMiddleware.Execute(ResolveRequestContext context, Action1 next) at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt) at Autofac.Core.Resolving.Middleware.DisposalTrackingMiddleware.Execute(ResolveRequestContext context, Action1 next) at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt) at Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action1 next)

  • Steps to reproduce the issue:" 1) Update ABP CLI to 7.0.1 from 7.0.0. 2) Create a new solution using blazor-server. 3) Add two modules using --new --add-to-the-solution. 4) Run DbMigrator. 5) Upgrade Volo.* NuGet packages from 7.0.0 to 7.0.1. 6) Run in debug mode and get the above error.

7 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Can you add this to your automapper profile?

    CreateMap<Language, LanguageInfo>()
        .Ignore(x => x.TwoLetterISOLanguageName);
    
  • User Avatar
    0
    tylerje created
    using AutoMapper;
    using Volo.Abp.AutoMapper;
    using Volo.Abp.LanguageManagement;
    using Volo.Abp.Localization;
    
    namespace Platform.Portal.Blazor;
    
    public class PortalBlazorAutoMapperProfile : Profile
    {
        public PortalBlazorAutoMapperProfile()
        {
            //Define your AutoMapper configuration here for the Blazor project.
            CreateMap<Language, LanguageInfo>()
                .Ignore(x => x.TwoLetterISOLanguageName);
        }
    }
    

    Adding that eliminates the error. So that leaves two questions.

    1. Why does the 7.0.1 CLI still use the 7.0.0 packages?
    2. Why does this bug exist in the 7.0.1 packages when it is so easily discovered in simple happy path testing?
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    We have released the 7.0.1 packages. And it was fixed in 7.0.1

    Please check your solution package version

  • User Avatar
    0
    tylerje created

    The bug doesn't happen in the 7.0.0 packages. The bug happens in the 7.0.1 packages. It's definitely not fixed. So I have no idea what you're talking about when you say "We have released the 7.0.1 packages. And it was fixed in 7.0.1"

    The fix to the LanguageInfo class would appear be simple. You have TwoLetterISOLanguageName marked NotNull but you provide no ctor with that property. Either fix the class or add the exclusion to AutoMapper in your own code.

    using System;
    using System.Globalization;
    using JetBrains.Annotations;
    
    namespace Volo.Abp.Localization;
    
    [Serializable]
    public class LanguageInfo : ILanguageInfo
    {
        [NotNull]
        public virtual string CultureName { get; protected set; }
    
        [NotNull]
        public virtual string UiCultureName { get; protected set; }
    
        [NotNull]
        public virtual string DisplayName { get; protected set; }
    
        [NotNull]
        public virtual string TwoLetterISOLanguageName { get; protected set; }
    
        [CanBeNull]
        public virtual string FlagIcon { get; set; }
    
        
        protected LanguageInfo()
        {
    
        }
    
        public LanguageInfo(
            string cultureName,
            string uiCultureName = null,
            string displayName = null,
            string flagIcon = null)
        {
            ChangeCultureInternal(cultureName, uiCultureName, displayName);
            FlagIcon = flagIcon;
        }
    
        public virtual void ChangeCulture(string cultureName, string uiCultureName = null, string displayName = null)
        {
            ChangeCultureInternal(cultureName, uiCultureName, displayName);
        }
    
        private void ChangeCultureInternal(string cultureName, string uiCultureName, string displayName)
        {
            CultureName = Check.NotNullOrWhiteSpace(cultureName, nameof(cultureName));
    
            UiCultureName = !uiCultureName.IsNullOrWhiteSpace()
                ? uiCultureName
                : cultureName;
    
            DisplayName = !displayName.IsNullOrWhiteSpace()
                ? displayName
                : cultureName;
            
            TwoLetterISOLanguageName = new CultureInfo(cultureName)
                .TwoLetterISOLanguageName;
        }
    }
    
  • User Avatar
    0
    tylerje created

    Just to be clear. I'm asking two questions:

    1. Why does the 7.0.1 CLI still produce solutions that reference the 7.0.0 packages?
    2. Why does the bug identified above exist in the 7.0.1 packages when it is so easily identified and fixed?

    The answers to those two questions will help me evaluate your approach to quality and testing. I need to know that you're taking a proactive approach to resolving these issues and preventing them from happening again.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    I created a new project and it uses the latest 7.0.1 packages. and there is no automapper error.

    > abp new BookStore -t app-pro                           
    [20:21:21 INF] ABP CLI 7.0.1
    [20:21:21 INF] Creating your project...
    [20:21:21 INF] Project name: BookStore
    [20:21:21 INF] Template: app-pro
    [20:21:21 INF] Output folder: /Users/maliming/Downloads/a
    [20:21:23 INF] Using cached template: app-pro, version: 7.0.1
    [20:21:23 INF] Theme: LeptonX
    [20:21:23 INF] Theme Style: System
    [20:21:24 INF] Check out the documents at https://docs.abp.io/en/commercial/latest
    

  • User Avatar
    0
    tylerje created

    That's weird. The CLI now creates solutions with 7.0.1 packages. Just a week ago, it did not. I tried it multiple times.

Made with ❤️ on ABP v9.1.0-preview. Updated on December 12, 2024, 07:15