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
1 change: 0 additions & 1 deletion mdoc/Mono.Documentation/MDocUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2452,7 +2452,6 @@ private void UpdateMember (DocsNodeInfo info, FrameworkTypeEntry typeEntry, Dict

info.Node = WriteElement (me, "Docs");
MakeDocNode (info, typeEntry.Framework.Importers, typeEntry);


foreach (MemberFormatter f in FormatterManager.MemberFormatters)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@ protected override string GetCppType(string t)
case "System.Object": typeToCompare = "Platform::Object"; break;
case "System.Type": typeToCompare = "Platform::Type"; break;
case "System.Attribute": typeToCompare = "Platform::Metadata::Attribute"; break;
case "Windows.Foundation.Numerics.Matrix3x2": typeToCompare = "float3x2"; break;
case "Windows.Foundation.Numerics.Matrix4x4": typeToCompare = "float4x4"; break;
case "Windows.Foundation.Numerics.Plane": typeToCompare = "plane"; break;
case "Windows.Foundation.Numerics.Quaternion": typeToCompare = "quaternion"; break;
case "Windows.Foundation.Numerics.Vector2": typeToCompare = "float2"; break;
case "Windows.Foundation.Numerics.Vector3": typeToCompare = "float3"; break;
case "Windows.Foundation.Numerics.Vector4": typeToCompare = "float4"; break;
}

if (splitType != null)
Expand Down Expand Up @@ -202,9 +209,10 @@ protected override string GetTypeDeclaration(TypeDefinition type)

buf.Append(GetTypeKind(type));
buf.Append(" ");
buf.Append(GetCppType(type.FullName) == null
var cppType = GetCppType(type.FullName);
buf.Append(cppType == null
? GetNameWithOptions(type, false, false)
: type.Name);
: cppType);

if (type.IsAbstract && !type.IsInterface)
buf.Append(" abstract");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,10 @@ protected override string GetTypeDeclaration (TypeDefinition type)

buf.Append(GetTypeKind (type));
buf.Append(" ");
buf.Append(GetCppType(type.FullName) == null
var cppType = GetCppType(type.FullName);
buf.Append(cppType == null
? GetNameWithOptions(type, false, false)
: type.Name);
: cppType);

if (type.IsAbstract && !type.IsInterface)
buf.Append(" abstract");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,26 @@ protected override string GetCppType(string t)
case "System.Int16": typeToCompare = "short"; break;
case "System.Int32": typeToCompare = "int"; break;
case "System.Int64": typeToCompare = "long"; break;
case "System.UInt16": typeToCompare = "unsigned short"; break;
case "System.UInt16": typeToCompare = "uint16_t"; break;
case "System.UInt32": typeToCompare = "uint32_t"; break;
case "System.UInt64": typeToCompare = "uint64_t"; break;

case "System.Single": typeToCompare = "float"; break;
case "System.Double": typeToCompare = "double"; break;

case "System.Boolean": typeToCompare = "bool"; break;
case "System.Char": typeToCompare = "char"; break;
case "System.Void": typeToCompare = "void"; break;

//API specific type is "winrt::hstring"; but c++ in built type is better variant
case "System.String": typeToCompare = "winrt::hstring"; break;
case "System.Guid": typeToCompare = "winrt::guid"; break;
case "System.Object": typeToCompare = "winrt::Windows::Foundation::IInspectable"; break;
case "Windows.Foundation.Numerics.Matrix3x2": typeToCompare = "float3x2"; break;
case "Windows.Foundation.Numerics.Matrix4x4": typeToCompare = "float4x4"; break;
case "Windows.Foundation.Numerics.Plane": typeToCompare = "plane"; break;
case "Windows.Foundation.Numerics.Quaternion": typeToCompare = "quaternion"; break;
case "Windows.Foundation.Numerics.Vector2": typeToCompare = "float2"; break;
case "Windows.Foundation.Numerics.Vector3": typeToCompare = "float3"; break;
case "Windows.Foundation.Numerics.Vector4": typeToCompare = "float4"; break;
}

if (splitType != null)
Expand Down Expand Up @@ -205,9 +211,10 @@ protected override string GetTypeDeclaration(TypeDefinition type)

buf.Append(GetTypeKind(type));
buf.Append(" ");
buf.Append(GetCppType(type.FullName) == null
var cppType = GetCppType(type.FullName);
buf.Append(cppType == null
? GetNameWithOptions(type, false, false)
: type.Name);
: cppType);

if (type.IsAbstract && !type.IsInterface)
buf.Append(" abstract");
Expand Down
20 changes: 6 additions & 14 deletions mdoc/mdoc.Test/CppCxFormatterMembersTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,30 +43,22 @@ public void Method_GetPrimesUnordered()
Windows::Foundation::IAsyncActionWithProgress<double> ^ GetPrimesUnordered(int first, int last);");
}

//[Test]
//[Category("Method")]
//public void Method_CreateNewGuid()
//{
// TestMethodSignature(CppCxTestLibName, "UwpTestWinRtComponentCpp.Class1", "CreateNewGuid",
// @"public: Platform::Guid ^ CreateNewGuid();");
//}

[Test]
public void CreateNewGuid()
[Category("Method")]
public void Method_CreateNewGuid()
{
var member = GetMethod(typeof(GuidClass), m => m.Name == "CreateNewGuid");
var sig = formatter.GetDeclaration(member);
Assert.AreEqual(@"public:
static Platform::Guid CreateNewGuid();", sig);
Assert.AreEqual("public:\n static Platform::Guid CreateNewGuid();", sig);
}

[Test]
public void ObjectIndentical()
[Category("Method")]
public void Method_ObjectIndentical()
{
var member = GetMethod(typeof(GuidClass), m => m.Name == "ObjectIndentical");
var sig = formatter.GetDeclaration(member);
Assert.AreEqual(@"public:
bool ObjectIndentical(Platform::Guid objGuid1, Platform::Guid objGuid2);", sig);
Assert.AreEqual("public:\n bool ObjectIndentical(Platform::Guid objGuid1, Platform::Guid objGuid2);", sig);
}

[Test]
Expand Down
66 changes: 66 additions & 0 deletions mdoc/mdoc.Test/CppCxFormatterTypesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class CppCxFormatterTypesTests : BasicFormatterTests<CppCxMemberFormatter
{
protected override CppCxMemberFormatter formatter => new CppCxMemberFormatter();

private string _cppWinRtTestLibName = "../../../../external/Windows/Windows.Foundation.UniversalApiContract.winmd";
private string _cppCxTestLibName = "../../../../external/Test/UwpTestWinRtComponentCpp.winmd";

protected override TypeDefinition GetType(Type type)
Expand Down Expand Up @@ -85,8 +86,73 @@ public void TypeSignature_ValueClass()
TestTypeSignature(_cppCxTestLibName, "Namespace2.Class4", "public value class Class4");
}

[Test]
[Category("Type")]
public void TypeSignature_NumericsMatrix3x2()
{
TestTypeSignature(_cppWinRtTestLibName, "Windows.Foundation.Numerics.Matrix3x2", "public value class float3x2");
}

[Test]
[Category("Type")]
public void TypeSignature_NumericsMatrix4x4()
{
TestTypeSignature(_cppWinRtTestLibName, "Windows.Foundation.Numerics.Matrix4x4", "public value class float4x4");
}

[Test]
[Category("Type")]
public void TypeSignature_NumericsQuaternion()
{
TestTypeSignature(_cppWinRtTestLibName, "Windows.Foundation.Numerics.Quaternion", "public value class quaternion");
}

[Test]
[Category("Type")]
public void TypeSignature_NumericsVector2()
{
TestTypeSignature(_cppWinRtTestLibName, "Windows.Foundation.Numerics.Vector2", "public value class float2");
}

[Test]
[Category("Type")]
public void TypeSignature_NumericsVector3()
{
TestTypeSignature(_cppWinRtTestLibName, "Windows.Foundation.Numerics.Vector3", "public value class float3");
}

[Test]
[Category("Type")]
public void TypeSignature_NumericsVector4()
{
TestTypeSignature(_cppWinRtTestLibName, "Windows.Foundation.Numerics.Vector4", "public value class float4");
}

[Test]
[Category("Type")]
public void TypeSignature_ValueGuid()
{
TestTypeSignature(typeof(Guid),
"public value class Platform::Guid : IComparable, IComparable<Platform::Guid>, IEquatable<Platform::Guid>, IFormattable");
}

[Test]
[Category("Type")]
public void TypeSignature_ValueSingle()
{
TestTypeSignature(typeof(Single),
"public value class float : IComparable, IComparable<float>, IConvertible, IEquatable<float>, IFormattable");
}

#region NoSupport

[Test]
[Category("Type")]
public void TypeSignature_NumericsPlane()
{
TestTypeSignature(_cppWinRtTestLibName, "Windows.Foundation.Numerics.Plane", null);
}

[Test]
[Category("NoSupport")]
public void NoSupport_GenericDelegate()
Expand Down
26 changes: 24 additions & 2 deletions mdoc/mdoc.Test/CppFullFormatterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ public void MethodSignature_GetEnumeratorGenericIEnumerable()
typeof(MyList1<,>), @"public:
virtual System::Collections::Generic::IEnumerator<A> ^ GetEnumerator() = System::Collections::Generic::IEnumerable<A>::GetEnumerator;",
nameof(MyList1<int, int>.GetEnumerator));

}

[Test]
Expand All @@ -250,7 +249,6 @@ public void MethodSignature_opAddition() =>
static Mono_DocTest::Widget ^ operator +(Mono_DocTest::Widget ^ x1, Mono_DocTest::Widget ^ x2);",
"op_Addition");


[Test]
[Category("Methods")]
[Category("NoSupport")]
Expand All @@ -265,6 +263,30 @@ public void NoSupport_Exception_NestedClassWithSameName()
TestTypeSignature(CSharpTestLib, "Mono.DocTest.Widget/NestedClass", null);
}

[Test]
[Category("Type")]
public void TypeSignature_Widget()
{
TestTypeSignature(CSharpTestLib,
"Mono.DocTest.DocValueType", "public value class Mono::DocTest::DocValueType : Mono::DocTest::IProcess");
}

[Test]
[Category("Type")]
public void TypeSignature_Single()
{
TestTypeSignature(typeof(Single),
"public value class float : IComparable, IComparable<float>, IConvertible, IEquatable<float>, IFormattable");
}

[Test]
[Category("Type")]
public void TypeSignature_Int32()
{
TestTypeSignature(typeof(Int32),
"public value class int : IComparable, IComparable<int>, IConvertible, IEquatable<int>, IFormattable");
}

[Test]
[Category("Methods")]
public void MethodSignature_opExplicit() =>
Expand Down
66 changes: 66 additions & 0 deletions mdoc/mdoc.Test/CppWinRtFormatterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class CppWinRtFormatterTests : BasicFormatterTests<CppWinRtMemberFormatte
private static readonly CppWinRtMemberFormatter CppWinRtMemberFormatter = new CppWinRtMemberFormatter();
protected override CppWinRtMemberFormatter formatter => CppWinRtMemberFormatter;

private string _cppWinRtTestLibName = "../../../../external/Windows/Windows.Foundation.UniversalApiContract.winmd";
private string _cppCxTestLibName = "../../../../external/Test/UwpTestWinRtComponentCpp.winmd";
private const string CSharpTestLib = "../../../../external/Test/CSharpExample.dll";

Expand Down Expand Up @@ -53,6 +54,55 @@ public void TypeSignature_Struct_Class4()
TestTypeSignature(_cppCxTestLibName, "Namespace2.Class4", "struct Class4");
}

[Test]
[Category("Type")]
public void TypeSignature_NumericsMatrix3x2()
{
TestTypeSignature(_cppWinRtTestLibName, "Windows.Foundation.Numerics.Matrix3x2", "struct float3x2");
}

[Test]
[Category("Type")]
public void TypeSignature_NumericsMatrix4x4()
{
TestTypeSignature(_cppWinRtTestLibName, "Windows.Foundation.Numerics.Matrix4x4", "struct float4x4");
}

[Test]
[Category("Type")]
public void TypeSignature_NumericsPlane()
{
TestTypeSignature(_cppWinRtTestLibName, "Windows.Foundation.Numerics.Plane", "struct plane");
}

[Test]
[Category("Type")]
public void TypeSignature_NumericsQuaternion()
{
TestTypeSignature(_cppWinRtTestLibName, "Windows.Foundation.Numerics.Quaternion", "struct quaternion");
}

[Test]
[Category("Type")]
public void TypeSignature_NumericsVector2()
{
TestTypeSignature(_cppWinRtTestLibName, "Windows.Foundation.Numerics.Vector2", "struct float2");
}

[Test]
[Category("Type")]
public void TypeSignature_NumericsVector3()
{
TestTypeSignature(_cppWinRtTestLibName, "Windows.Foundation.Numerics.Vector3", "struct float3");
}

[Test]
[Category("Type")]
public void TypeSignature_NumericsVector4()
{
TestTypeSignature(_cppWinRtTestLibName, "Windows.Foundation.Numerics.Vector4", "struct float4");
}

[Test]
[Category("Type")]
public void TypeSignature_GenericInterface()
Expand Down Expand Up @@ -86,6 +136,22 @@ public void TypeSignature_WebHostHiddenAttribute()
class Widget : Mono_DocTest::IProcess");
}

[Test]
[Category("Type")]
public void TypeSignature_ValueGuid()
{
TestTypeSignature(typeof(Guid),
"struct winrt::guid : IComparable, IComparable<winrt::guid>, IEquatable<winrt::guid>, IFormattable");
}

[Test]
[Category("Type")]
public void TypeSignature_ValueSingle()
{
TestTypeSignature(typeof(Single),
"struct float : IComparable, IComparable<float>, IConvertible, IEquatable<float>, IFormattable");
}

[Test]
[Category("NoSupport")]
public void NoSupport_Delegate()
Expand Down
4 changes: 2 additions & 2 deletions mdoc/mdoc.Test/CppWinRtMembersTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ public void Method_GetPrimesUnordered()
}

[Test]
public void CreateNewGuid()
public void Method_CreateNewGuid()
{
var member = GetMethod(typeof(GuidClass), m => m.Name == "CreateNewGuid");
var sig = formatter.GetDeclaration(member);
Assert.AreEqual(@" static winrt::guid CreateNewGuid();", sig);
}

[Test]
public void ObjectIndentical()
public void Method_ObjectIndentical()
{
var member = GetMethod(typeof(GuidClass), m => m.Name == "ObjectIndentical");
var sig = formatter.GetDeclaration(member);
Expand Down