Open patridge opened 7 years ago
Some implementation notes ... the type xml for a class that derives from a generic class with a concrete value for the type parameter looks like this:
<Base>
<BaseTypeName>My.Sample.SomeGenericClass<System.String></BaseTypeName>
<BaseTypeArguments>
<BaseTypeArgument TypeParamName="T">System.String</BaseTypeArgument>
</BaseTypeArguments>
</Base>
link generation (#30) will have to take this into account and use the BaseTypeName, and systematically replace the arguments using the TypeParamName
, in order to generate the link to the actual type being used. We should probably use the EcmaUrlParser
, to parse the value of BaseTypeName
(prefixed with "T:"
).
ultimately, this could be used to also build links to the concrete type used as the type parameter (System.String
, in the example above) ... that way, SomeGenericClass
links to the proper type, as does the parameter value.
For methods that accept generic arguments with concrete type parameters, it is a bit more complex:
<Member MemberName="AcceptsConcreteGenericParam">
<MemberSignature Language="C#" Value="public void AcceptsConcreteGenericParam (My.Sample.SomeGenericClass<string> value);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance void AcceptsConcreteGenericParam(class My.Sample.SomeGenericClass`1<string> value) cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="value" Type="My.Sample.SomeGenericClass<System.String>" />
</Parameters>
<Docs>
<param name="value">To be added.</param>
<summary>To be added.</summary>
<remarks>To be added.</remarks>
</Docs>
</Member>
Where the type XML has the useful BaseTypeArgument
, the method isn't so helpful :( This means that we will have to do an impromptu lookup when rendering this signature by creating a type link in the form of T:My.Sample.SomeGenericClass
1, and then use that to lookup the value(s) of
/TypeParameters/TypeParameter` to generate the proper link.
There may be more affected links, but at least one example is when a class inherits from a generic variant of a class. For example,
ListView
under Xamarin.Forms inherits fromItemsView<Cell>
, which results in this URL. https://developer.xamarin.com/api/type/Xamarin.Forms.ItemsView%3CXamarin.Forms.Cell%3E/In this case,
ItemsView<…>
should actually point toItemsView<TVisual>
, whereTVisual : BindableObject
. (AndCell
inherits fromElement
which inherits fromBindableObject
.)