0

In C#, I have an implicit conversion operator (A) -> B defined on Type A.

When creating the documentation with DocFx, the conversion operator only appears for type A, but not for type B.

As a work-around, I tried to define the same conversion operator on type B, but this causes an "ambiguous operator definition" error.

I believe the documentation should list the conversion operator on both types, A and B. Is there a way to get DocFx to do this, or am I missing something?

DhyMik
  • 333
  • 3
  • 12
  • 1
    I can't say I agree with your expectation. For example, I don't expect all the LINQ to XML conversions to be listed in `int`, `decimal` etc - it would make the documentation really messy. You could *potentially* post-process the metadata files yourself to basically add links to the "source" conversion, but personally it's already doing what I think it should. – Jon Skeet Jun 16 '21 at 11:56
  • @JonSkeet thank you for your assessment. Are there any best practices as to on which of the two types the operator should be defined? On which type do devs expect the docs? `A` is the more basic type (holding config data), `B` is the ' higher' type, like a business model. – DhyMik Jun 16 '21 at 12:07
  • 1
    I would be a bit careful with implicit conversion operators, since implicit conversion may be unexpected if you are not familiar with the code-base. – JonasH Jun 16 '21 at 12:41
  • @JonasH thank you, I made the operator explicit. – DhyMik Jun 16 '21 at 12:55
  • 1
    I would personally *usually* define the operator on the source type rather than the target type. But I don't know of any official guideline around that – Jon Skeet Jun 16 '21 at 12:56

0 Answers0