Overriden property in a custom attribute crashes runtime

Open
#119,490 7 comments 0 reactions 1 assignee View on GitHub

@AaronRobinsonMSFT is already working on this.

Since Jul 10, 2026.

Assessment

This issue has not been assessed yet.

Description

area-System.Reflection

This crashes with internal CLR error.

using System;
using System.Reflection;

Console.WriteLine(typeof(Program).GetCustomAttribute<DerivedAttribute>().Prop);

[Derived(Prop = 123)]
partial class Program;

class BaseAttribute : Attribute
{
    public virtual object Prop { get; set; }
}

class DerivedAttribute : BaseAttribute
{
    public override Enum Prop { get => (Enum)base.Prop; }
}
Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotnet/runtime

All issues in dotnet/runtime

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.