Say I have this:
internal abstract class Animal
{
    internal bool IsExtinct { get; set; }
}
internal sealed class WoollyMammoth : Animal
{
    internal int WeightLbs { get; set; }
    /// <summary>
    /// Construct a new instance with <see cref="IsExtinct"/> // this throws an error "XML comment has cref attribute 'IsExtinct' that could not be resolved".
    /// set to "true" and <see cref="WeightLbs"/> // this works just fine.
    /// initialized to 0.
    /// </summary>
    WoollyMammoth()
    {
        // no problem with either of these, of course.
        IsExtinct = true; 
        WeightLbs = 0;
    }
}
Why am I getting an error when trying to reference the IsExtinct property, defined in the base class, from the <see/> XML comment tag?  I can access properties that are defined in the derived class, like WeightLbs.
To reference a base class symbol, use a qualified name: <see cref="Animal.IsExtinct"/>.
There is no particular reason why this should be required. The Roslyn code base contains a test which specifically tests that base class symbols are not found (CrefTests.TypeScope4) which mentions that the reason is simply is because that is what the previous compiler did:
// As in dev11, we ignore the inherited method symbol.
It looks like a historic accident, and since the workaround is trivial it's unlikely to be changed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With