-
-
Notifications
You must be signed in to change notification settings - Fork 761
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
Add support for <inheritdoc> cref #7656
Comments
It's not inconsistent (it's working for the I've changed the title and type of this issue accordingly. |
Hey y'all, I was investigating this a bit and wanted to share my findings. It seems to me that this issue stems from this section of code: Lines 295 to 336 in d3da9b0
By Line 310, we've validated that the child element represents an Here are some prospective solutions I thought of. Though, I imagine there are far better ones:
Lastly, another bit of value could come from adding support for the optional |
If you want you can raise a PR. |
We currently have this code in our custom doc-provider, but it is ugly and only supports Type-crefs. We have to scan all assemblies in the current app domain to find the type 😭 private MemberInfo? GetInheritdocBaseMember(XElement inheritdoc, MemberInfo member)
{
var cref = inheritdoc.Attribute(Cref);
if (cref is not null && !string.IsNullOrWhiteSpace(cref.Value))
{
if (!cref.Value.StartsWith("T:", StringComparison.Ordinal))
return null; // We don't support other cref items like properties or methods yet.
var typeName = cref.Value[2..];
var type = _knownInheritdocAssemblies.ToArray()
.Select(assembly => assembly.GetType(typeName, false))
.FirstOrDefault(x => x != null);
if (type is null)
{
type = AppDomain.CurrentDomain.GetAssemblies()
.Select(assembly => assembly.GetType(typeName, false))
.FirstOrDefault(x => x != null);
if (type != null)
_knownInheritdocAssemblies.Add(type.Assembly);
}
return type;
}
var baseType =
member.DeclaringType?.GetTypeInfo().BaseType;
var baseMember =
baseType?.GetTypeInfo().DeclaredMembers
.SingleOrDefault(m => m.Name == member.Name);
return baseMember;
} The reason we use this is so we don't have to duplicate our documentation on both commandhandlers and mutations, like this: /// <inheritdoc cref="MyCommandHandler "/>
[Mutation]
public static async Task<MyCommandResult> MyMutation(
MyCommandHandler commandHandler, MyCommand input, CancellationToken cancellationToken)
{
return await commandHandler.Handle(input, cancellationToken);
} |
Product
Hot Chocolate
Version
14.0.0
Link to minimal reproduction
https://github.com/kuglitsd/HotChocolateInheritdoc
Steps to reproduce
Run the project.
Inheritdoc only seems to be working for Implementations of Interface Methods. Everything else does NOT seem to work
What is expected?
The tag should correctly inherit and display the documentation comments from the specified members, classes, or interfaces in the schema
What is actually happening?
Only the comment inherited from the IQuery interface implementation seems to work.
Relevant log output
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: