Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ protected virtual string MakeNamedArgumentString(string name, string value)
return $"{name}={value}";
}

public static string MakeAttributesValueString(object v, TypeReference valueType)
public virtual string MakeAttributesValueString(object v, TypeReference valueType)
{
var formatters = new[] {
new AttributeValueFormatter (),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Mono.Cecil;

namespace Mono.Documentation.Updater.Formatters
{
class CppWinRtAttributeFormatter : AttributeFormatter
{
public override string PrefixBrackets { get; } = "/// [";
public override string SurfixBrackets { get; } = "]";
public override string Language => Consts.CppWinRt;

public override string MakeAttributesValueString(object v, TypeReference valueType)
{
string baseValue = base.MakeAttributesValueString(v, valueType);
return baseValue.StartsWith("typeof(") ? baseValue.Substring(7, baseValue.Length - 8) : baseValue;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ private StringBuilder AppendParameter (StringBuilder buf, ParameterDefinition pa
buf.Append (parameter.Name);
if (parameter.HasDefault && parameter.IsOptional && parameter.HasConstant)
{
var ReturnVal = AttributeFormatter.MakeAttributesValueString(parameter.Constant, parameter.ParameterType);
var ReturnVal = new AttributeFormatter().MakeAttributesValueString(parameter.Constant, parameter.ParameterType);
buf.AppendFormat (" = {0}", ReturnVal == "null" ? "default" : ReturnVal);
}
return buf;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ protected override StringBuilder AppendParameter(StringBuilder buf, ParameterDef

if (parameter.HasDefault && parameter.IsOptional && parameter.HasConstant)
{
buf.AppendFormat(" = {0}", AttributeFormatter.MakeAttributesValueString(parameter.Constant, parameter.ParameterType));
buf.AppendFormat(" = {0}", new AttributeFormatter().MakeAttributesValueString(parameter.Constant, parameter.ParameterType));
}

return buf;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public static void AddFormatter(string langId)
case Consts.CppWinRtLowCase:
TypeFormatters.Add(new CppWinRtMemberFormatter(map));
MemberFormatters.Add(new CppWinRtFullMemberFormatter(map));
AdditionalAttributeFormatters.Add(new CppWinRtAttributeFormatter());
break;
case Consts.FSharpLowCase:
case "fsharp":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ private StringBuilder AppendParameter(StringBuilder buf, ParameterDefinition par
buf.Append(GetTypeName(parameter.ParameterType, new DynamicParserContext(parameter)));
if (parameter.HasDefault && parameter.IsOptional && parameter.HasConstant)
{
var parameterValue = AttributeFormatter.MakeAttributesValueString(parameter.Constant, parameter.ParameterType);
var parameterValue = new AttributeFormatter().MakeAttributesValueString(parameter.Constant, parameter.ParameterType);
buf.AppendFormat(" = {0}", parameterValue == "null" ? "Nothing" : parameterValue);
}
return buf;
Expand Down
1 change: 1 addition & 0 deletions mdoc/Test/ClassEnumeratorECMA.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
<Attribute>
<AttributeName Language="C#">[System.STAThread]</AttributeName>
<AttributeName Language="F#">[&lt;System.STAThread&gt;]</AttributeName>
<AttributeName Language="C++ WINRT">/// [System.STAThread]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
Expand Down
4 changes: 4 additions & 0 deletions mdoc/Test/TestEcmaDocs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<Attribute>
<AttributeName Language="C#">[CLSCompliantAttribute(true)]</AttributeName>
<AttributeName Language="F#">[&lt;CLSCompliantAttribute(true)&gt;]</AttributeName>
<AttributeName Language="C++ WINRT">/// [CLSCompliantAttribute(true)]</AttributeName>
<Excluded>0</Excluded>
</Attribute>
</Attributes>
Expand Down Expand Up @@ -61,6 +62,7 @@
<Attribute>
<AttributeName Language="C#">[CLSCompliantAttribute(true)]</AttributeName>
<AttributeName Language="F#">[&lt;CLSCompliantAttribute(true)&gt;]</AttributeName>
<AttributeName Language="C++ WINRT">/// [CLSCompliantAttribute(true)]</AttributeName>
<Excluded>0</Excluded>
</Attribute>
</Attributes>
Expand Down Expand Up @@ -96,6 +98,7 @@
<Attribute>
<AttributeName Language="C#">[CLSCompliantAttribute(true)]</AttributeName>
<AttributeName Language="F#">[&lt;CLSCompliantAttribute(true)&gt;]</AttributeName>
<AttributeName Language="C++ WINRT">/// [CLSCompliantAttribute(true)]</AttributeName>
<Excluded>0</Excluded>
</Attribute>
</Attributes>
Expand Down Expand Up @@ -194,6 +197,7 @@
<Attribute>
<AttributeName Language="C#">[CLSCompliantAttribute(true)]</AttributeName>
<AttributeName Language="F#">[&lt;CLSCompliantAttribute(true)&gt;]</AttributeName>
<AttributeName Language="C++ WINRT">/// [CLSCompliantAttribute(true)]</AttributeName>
<Excluded>0</Excluded>
</Attribute>
</Attributes>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<Attributes>
<Attribute>
<AttributeName Language="C#">[Mono.DocTest.Doc("arg!")]</AttributeName>
<AttributeName Language="C++ WINRT">/// [Mono.DocTest.Doc("arg!")]</AttributeName>
</Attribute>
</Attributes>
<Constraints>
Expand All @@ -21,6 +22,7 @@
<Attributes>
<Attribute>
<AttributeName Language="C#">[Mono.DocTest.Doc("ret!")]</AttributeName>
<AttributeName Language="C++ WINRT">/// [Mono.DocTest.Doc("ret!")]</AttributeName>
</Attribute>
</Attributes>
<Constraints>
Expand All @@ -34,13 +36,15 @@
<Attributes>
<Attribute>
<AttributeName Language="C#">[Mono.DocTest.Doc("method")]</AttributeName>
<AttributeName Language="C++ WINRT">/// [Mono.DocTest.Doc("method")]</AttributeName>
</Attribute>
</Attributes>
<Parameters>
<Parameter Name="a" Type="TArg">
<Attributes>
<Attribute>
<AttributeName Language="C#">[Mono.DocTest.Doc("arg-actual")]</AttributeName>
<AttributeName Language="C++ WINRT">/// [Mono.DocTest.Doc("arg-actual")]</AttributeName>
</Attribute>
</Attributes>
</Parameter>
Expand All @@ -50,6 +54,7 @@
<Attributes>
<Attribute>
<AttributeName Language="C#">[Mono.DocTest.Doc("return", Field=false)]</AttributeName>
<AttributeName Language="C++ WINRT">/// [Mono.DocTest.Doc("return", Field=false)]</AttributeName>
</Attribute>
</Attributes>
</ReturnValue>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
<Attributes>
<Attribute>
<AttributeName Language="C#">[Mono.DocTest.Doc("S")]</AttributeName>
<AttributeName Language="C++ WINRT">/// [Mono.DocTest.Doc("S")]</AttributeName>
</Attribute>
</Attributes>
</TypeParameter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<Attributes>
<Attribute>
<AttributeName Language="C#">[Mono.DocTest.Doc("Type Parameter!")]</AttributeName>
<AttributeName Language="C++ WINRT">/// [Mono.DocTest.Doc("Type Parameter!")]</AttributeName>
</Attribute>
</Attributes>
</TypeParameter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<Attributes>
<Attribute>
<AttributeName Language="C#">[System.AttributeUsage(System.AttributeTargets.All)]</AttributeName>
<AttributeName Language="C++ WINRT">/// [System.AttributeUsage(System.AttributeTargets.All)]</AttributeName>
</Attribute>
</Attributes>
<Docs>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<Attributes>
<Attribute>
<AttributeName Language="C#">[System.Flags]</AttributeName>
<AttributeName Language="C++ WINRT">/// [System.Flags]</AttributeName>
</Attribute>
</Attributes>
<Docs>
Expand Down
16 changes: 16 additions & 0 deletions mdoc/Test/en.expected-cppwinrt2/Mono.DocTest/Widget.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,15 @@
<Attributes>
<Attribute>
<AttributeName Language="C#">[Mono.DocTest.Doc("Del event")]</AttributeName>
<AttributeName Language="C++ WINRT">/// [Mono.DocTest.Doc("Del event")]</AttributeName>
</Attribute>
<Attribute>
<AttributeName Language="C#">[add: Mono.DocTest.Doc("Del add accessor")]</AttributeName>
<AttributeName Language="C++ WINRT">/// [add: Mono.DocTest.Doc("Del add accessor")]</AttributeName>
</Attribute>
<Attribute>
<AttributeName Language="C#">[remove: Mono.DocTest.Doc("Del remove accessor")]</AttributeName>
<AttributeName Language="C++ WINRT">/// [remove: Mono.DocTest.Doc("Del remove accessor")]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
Expand Down Expand Up @@ -311,6 +314,7 @@
<Attributes>
<Attribute>
<AttributeName Language="C#">[System.Obsolete("why not")]</AttributeName>
<AttributeName Language="C++ WINRT">/// [System.Obsolete("why not")]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
Expand Down Expand Up @@ -380,6 +384,7 @@
<Attributes>
<Attribute>
<AttributeName Language="C#">[Mono.DocTest.Doc("Height property")]</AttributeName>
<AttributeName Language="C++ WINRT">/// [Mono.DocTest.Doc("Height property")]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
Expand All @@ -402,9 +407,11 @@
<Attributes>
<Attribute>
<AttributeName Language="C#">[Mono.DocTest.Doc("Item property")]</AttributeName>
<AttributeName Language="C++ WINRT">/// [Mono.DocTest.Doc("Item property")]</AttributeName>
</Attribute>
<Attribute>
<AttributeName Language="C#">[set: Mono.DocTest.Doc("Item property set accessor")]</AttributeName>
<AttributeName Language="C++ WINRT">/// [set: Mono.DocTest.Doc("Item property set accessor")]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
Expand Down Expand Up @@ -471,13 +478,15 @@
<Attributes>
<Attribute>
<AttributeName Language="C#">[Mono.DocTest.Doc("normal DocAttribute", Field=true)]</AttributeName>
<AttributeName Language="C++ WINRT">/// [Mono.DocTest.Doc("normal DocAttribute", Field=true)]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
<Attributes>
<Attribute>
<AttributeName Language="C#">[Mono.DocTest.Doc("return:DocAttribute", Property=typeof(Mono.DocTest.Widget))]</AttributeName>
<AttributeName Language="C++ WINRT">/// [Mono.DocTest.Doc("return:DocAttribute", Property=Mono.DocTest.Widget)]</AttributeName>
</Attribute>
</Attributes>
</ReturnValue>
Expand All @@ -486,20 +495,23 @@
<Attributes>
<Attribute>
<AttributeName Language="C#">[Mono.DocTest.Doc("c", FlagsEnum=System.ConsoleModifiers.Alt | System.ConsoleModifiers.Control)]</AttributeName>
<AttributeName Language="C++ WINRT">/// [Mono.DocTest.Doc("c", FlagsEnum=System.ConsoleModifiers.Alt | System.ConsoleModifiers.Control)]</AttributeName>
</Attribute>
</Attributes>
</Parameter>
<Parameter Name="f" Type="System.Single" RefType="out">
<Attributes>
<Attribute>
<AttributeName Language="C#">[Mono.DocTest.Doc("f", NonFlagsEnum=Mono.DocTest.Color.Red)]</AttributeName>
<AttributeName Language="C++ WINRT">/// [Mono.DocTest.Doc("f", NonFlagsEnum=Mono.DocTest.Color.Red)]</AttributeName>
</Attribute>
</Attributes>
</Parameter>
<Parameter Name="v" Type="Mono.DocTest.DocValueType" RefType="ref">
<Attributes>
<Attribute>
<AttributeName Language="C#">[Mono.DocTest.Doc("v")]</AttributeName>
<AttributeName Language="C++ WINRT">/// [Mono.DocTest.Doc("v")]</AttributeName>
</Attribute>
</Attributes>
</Parameter>
Expand Down Expand Up @@ -618,6 +630,7 @@
<Attributes>
<Attribute>
<AttributeName Language="C#">[System.ParamArray]</AttributeName>
<AttributeName Language="C++ WINRT">/// [System.ParamArray]</AttributeName>
</Attribute>
</Attributes>
</Parameter>
Expand Down Expand Up @@ -843,12 +856,15 @@
<Attributes>
<Attribute>
<AttributeName Language="C#">[Mono.DocTest.Doc("Width property")]</AttributeName>
<AttributeName Language="C++ WINRT">/// [Mono.DocTest.Doc("Width property")]</AttributeName>
</Attribute>
<Attribute>
<AttributeName Language="C#">[get: Mono.DocTest.Doc("Width get accessor")]</AttributeName>
<AttributeName Language="C++ WINRT">/// [get: Mono.DocTest.Doc("Width get accessor")]</AttributeName>
</Attribute>
<Attribute>
<AttributeName Language="C#">[set: Mono.DocTest.Doc("Width set accessor")]</AttributeName>
<AttributeName Language="C++ WINRT">/// [set: Mono.DocTest.Doc("Width set accessor")]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
<Attribute>
<AttributeName Language="C#">[System.STAThread]</AttributeName>
<AttributeName Language="F#">[&lt;System.STAThread&gt;]</AttributeName>
<AttributeName Language="C++ WINRT">/// [System.STAThread]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
<Attribute>
<AttributeName Language="C#">[System.STAThread]</AttributeName>
<AttributeName Language="F#">[&lt;System.STAThread&gt;]</AttributeName>
<AttributeName Language="C++ WINRT">/// [System.STAThread]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
<Attribute>
<AttributeName Language="C#">[System.STAThread]</AttributeName>
<AttributeName Language="F#">[&lt;System.STAThread&gt;]</AttributeName>
<AttributeName Language="C++ WINRT">/// [System.STAThread]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
Expand Down
5 changes: 5 additions & 0 deletions mdoc/Test/en.expected/Mono.DocTest.Generic/Func`2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<Attribute>
<AttributeName Language="C#">[Mono.DocTest.Doc("arg!")]</AttributeName>
<AttributeName Language="F#">[&lt;Mono.DocTest.Doc("arg!")&gt;]</AttributeName>
<AttributeName Language="C++ WINRT">/// [Mono.DocTest.Doc("arg!")]</AttributeName>
</Attribute>
</Attributes>
<Constraints>
Expand All @@ -27,6 +28,7 @@
<Attribute>
<AttributeName Language="C#">[Mono.DocTest.Doc("ret!")]</AttributeName>
<AttributeName Language="F#">[&lt;Mono.DocTest.Doc("ret!")&gt;]</AttributeName>
<AttributeName Language="C++ WINRT">/// [Mono.DocTest.Doc("ret!")]</AttributeName>
</Attribute>
</Attributes>
<Constraints>
Expand All @@ -41,6 +43,7 @@
<Attribute>
<AttributeName Language="C#">[Mono.DocTest.Doc("method")]</AttributeName>
<AttributeName Language="F#">[&lt;Mono.DocTest.Doc("method")&gt;]</AttributeName>
<AttributeName Language="C++ WINRT">/// [Mono.DocTest.Doc("method")]</AttributeName>
</Attribute>
</Attributes>
<Parameters>
Expand All @@ -49,6 +52,7 @@
<Attribute>
<AttributeName Language="C#">[Mono.DocTest.Doc("arg-actual")]</AttributeName>
<AttributeName Language="F#">[&lt;Mono.DocTest.Doc("arg-actual")&gt;]</AttributeName>
<AttributeName Language="C++ WINRT">/// [Mono.DocTest.Doc("arg-actual")]</AttributeName>
</Attribute>
</Attributes>
</Parameter>
Expand All @@ -59,6 +63,7 @@
<Attribute>
<AttributeName Language="C#">[Mono.DocTest.Doc("return", Field=false)]</AttributeName>
<AttributeName Language="F#">[&lt;Mono.DocTest.Doc("return", Field=false)&gt;]</AttributeName>
<AttributeName Language="C++ WINRT">/// [Mono.DocTest.Doc("return", Field=false)]</AttributeName>
</Attribute>
</Attributes>
</ReturnValue>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
<Attribute>
<AttributeName Language="C#">[Mono.DocTest.Doc("S")]</AttributeName>
<AttributeName Language="F#">[&lt;Mono.DocTest.Doc("S")&gt;]</AttributeName>
<AttributeName Language="C++ WINRT">/// [Mono.DocTest.Doc("S")]</AttributeName>
</Attribute>
</Attributes>
</TypeParameter>
Expand Down
1 change: 1 addition & 0 deletions mdoc/Test/en.expected/Mono.DocTest.Generic/MyList`1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<Attribute>
<AttributeName Language="C#">[Mono.DocTest.Doc("Type Parameter!")]</AttributeName>
<AttributeName Language="F#">[&lt;Mono.DocTest.Doc("Type Parameter!")&gt;]</AttributeName>
<AttributeName Language="C++ WINRT">/// [Mono.DocTest.Doc("Type Parameter!")]</AttributeName>
</Attribute>
</Attributes>
</TypeParameter>
Expand Down
1 change: 1 addition & 0 deletions mdoc/Test/en.expected/Mono.DocTest/DocAttribute.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<Attribute>
<AttributeName Language="C#">[System.AttributeUsage(System.AttributeTargets.All)]</AttributeName>
<AttributeName Language="F#">[&lt;System.AttributeUsage(System.AttributeTargets.All)&gt;]</AttributeName>
<AttributeName Language="C++ WINRT">/// [System.AttributeUsage(System.AttributeTargets.All)]</AttributeName>
</Attribute>
</Attributes>
<Docs>
Expand Down
1 change: 1 addition & 0 deletions mdoc/Test/en.expected/Mono.DocTest/Widget+Direction.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<Attribute>
<AttributeName Language="C#">[System.Flags]</AttributeName>
<AttributeName Language="F#">[&lt;System.Flags&gt;]</AttributeName>
<AttributeName Language="C++ WINRT">/// [System.Flags]</AttributeName>
</Attribute>
</Attributes>
<Docs>
Expand Down
Loading