Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attribute [Tag] behaves different than [DisplayName] in case of overrides #32

Closed
Ireanicus opened this issue Nov 12, 2020 · 2 comments
Closed

Comments

@Ireanicus
Copy link

Ireanicus commented Nov 12, 2020

Hello,

I prepared minimal example of the issue here

When [Tag] attribute is placed on overriding method - it is ignored. However [DisplayName] follows overridden method attribute.
I think that Hangfire.Tags behavior should be aligned with the Hangfire behavior.

[Tag("base-class")]
public class BaseService
{
    [Tag("base-method")]
    [DisplayName("base-method")]
    public virtual void Run()
    {
    }
}
[Tag("overriding-class")]
public class OverridingService : BaseService 
{
    [Tag("overriding-method")]
    [DisplayName("overriding-method")]
    public override void Run() 
    {
        base.Run();
    }
}

image
image

Note1: I tested it also using PostgreSql Storage so it doesn't seem to be storage related.
Note2: There is other issue present in my example url (not related to this one)

@Ireanicus
Copy link
Author

Ireanicus commented Nov 12, 2020

I've done some digging for code causing this behavior:

Hangfire.Core HtmlHelper - DisplayNameAttribute handling (line 41 and 129)

Hangfire.Tags CreateJobFilter - TagAttribute handling. It seems like the Hangfire.Core itself is returning base method reference from filterContext.Job.Method

@erwin-faceit
Copy link
Contributor

Fixed in 1.7.2. Basically: the filterContext contains the basetype of the method, and the type on which execution should take place. The dashboard get's the type on the derived type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants