Skip to content

EPPlus does not resolve localized DisplayAttribute values when ResourceType is used #2332

@DipuAlba1

Description

@DipuAlba1

Description

EPPlus currently supports DisplayAttribute, but it does not appear to handle the ResourceType property correctly.

According to the official Microsoft documentation for DisplayAttribute.ResourceType:

"If this value is null, the ShortName, Name, Prompt, and Description properties are assumed to be literal, non-localized strings. If this value is not null, the string properties are assumed to be the names of public static properties that return the actual string value."

Reference:
https://learn.microsoft.com/en-us/dotnet/api/system.componentmodel.dataannotations.displayattribute.resourcetype?view=netframework-4.8#system-componentmodel-dataannotations-displayattribute-resourcetype

Example

When the attribute is used like this:

[Display(Name = nameof(PropertyNames.First), ResourceType = typeof(PropertyNames))]
public string FirstName { get; set; }

the Excel column header should not be First.

Instead, EPPlus should resolve the resource property and use the actual localized text stored in the PropertyNames resource.

Expected behavior

EPPlus should use the value returned by the resource property referenced through ResourceType, rather than the resource property name itself.

Actual behavior

EPPlus uses the literal property name (First) as the column header instead of the localized string value from the resource.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

Status

In progress

Status

In progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions