0
ahmednfwela@bdaya-dev.com created
The bug described here: https://github.com/abpframework/abp/issues/21191
Is causing our production app to fail Please provide us with a workaround until it's fixed
5 Answer(s)
-
0
Thanks. I will check it asap.
-
0
hi
Can you try to replace the
ILocalizableStringSerializer
withMyLocalizableStringSerializer
?if (value.IsNullOrEmpty()) { return new FixedLocalizableString(string.Empty); } if (value.Length < 3 || value[1] != ':') { return new FixedLocalizableString(value); }
using System; using Microsoft.Extensions.Options; using Volo.Abp.DependencyInjection; namespace Volo.Abp.Localization; [Dependency(ReplaceServices = true)] [ExposeServices(typeof(ILocalizableStringSerializer))] public class MyLocalizableStringSerializer : ILocalizableStringSerializer, ITransientDependency { protected AbpLocalizationOptions LocalizationOptions { get; } public MyLocalizableStringSerializer(IOptions<AbpLocalizationOptions> localizationOptions) { LocalizationOptions = localizationOptions.Value; } public virtual string? Serialize(ILocalizableString? localizableString) { if (localizableString == null) { return null; } if (localizableString is LocalizableString realLocalizableString) { return $"L:{realLocalizableString.ResourceName},{realLocalizableString.Name}"; } if (localizableString is FixedLocalizableString fixedLocalizableString) { return $"F:{fixedLocalizableString.Value}"; } throw new AbpException($"Unknown {nameof(ILocalizableString)} type: {localizableString.GetType().FullName}"); } public virtual ILocalizableString Deserialize(string value) { if (value.IsNullOrEmpty()) { return new FixedLocalizableString(string.Empty); } if (value.Length < 3 || value[1] != ':') { return new FixedLocalizableString(value); } var type = value[0]; switch (type) { case 'F': return new FixedLocalizableString(value.Substring(2)); case 'L': var commaPosition = value.IndexOf(',', 2); if (commaPosition == -1) { throw new AbpException("Invalid LocalizableString value: " + value); } var resourceName = value.Substring(2, commaPosition - 2); var name = value.Substring(commaPosition + 1); if (name.IsNullOrWhiteSpace()) { throw new AbpException("Invalid LocalizableString value: " + value); } return LocalizableString.Create(name, resourceName); default: return new FixedLocalizableString(value); } } }
-
0
I am using this right now and it solves my issue:
[Dependency(ReplaceServices = true)] [ExposeServices(typeof(LocalizableStringSerializer), typeof(ILocalizableStringSerializer), typeof(FixedLocalizableStringSerializer))] public class FixedLocalizableStringSerializer(IOptions<AbpLocalizationOptions> localizationOptions) : LocalizableStringSerializer(localizationOptions), ITransientDependency { public override ILocalizableString Deserialize(string? value) { if (value == null) { return new FixedLocalizableString(""); } return base.Deserialize(value); } }
is there a problem with my workaround ?
-
0
No problem, Its same way.
-
0
hi
https://github.com/abpframework/abp/pull/21206