Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/api-doc-tools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Chen <59190910+JeffInChrist@users.noreply.github.com>2021-04-30 22:23:09 +0300
committerGitHub <noreply@github.com>2021-04-30 22:23:09 +0300
commitb9158aa6bc4e958bbd243a0d4fbf109788c90e87 (patch)
tree800fca43c6d78a9915f398feadc74434466a82e1
parentd3ce3cadd68a78fbb11efe02afb9c160e07391e4 (diff)
Adding the projection of Numerics types in C++/WinRT, C++/CX and fixed an issue of the cppType logic (#550)
https://dev.azure.com/ceapex/Engineering/_workitems/edit/100023
-rw-r--r--mdoc/Mono.Documentation/MDocUpdater.cs1
-rw-r--r--mdoc/Mono.Documentation/Updater/Formatters/CppFormatters/CppCxFullMemberFormatter.cs12
-rw-r--r--mdoc/Mono.Documentation/Updater/Formatters/CppFormatters/CppFullMemberFormatter.cs5
-rw-r--r--mdoc/Mono.Documentation/Updater/Formatters/CppFormatters/CppWinRtFullMemberFormatter.cs17
-rw-r--r--mdoc/mdoc.Test/CppCxFormatterMembersTests.cs20
-rw-r--r--mdoc/mdoc.Test/CppCxFormatterTypesTests.cs66
-rw-r--r--mdoc/mdoc.Test/CppFullFormatterTests.cs26
-rw-r--r--mdoc/mdoc.Test/CppWinRtFormatterTests.cs66
-rw-r--r--mdoc/mdoc.Test/CppWinRtMembersTests.cs4
9 files changed, 189 insertions, 28 deletions
diff --git a/mdoc/Mono.Documentation/MDocUpdater.cs b/mdoc/Mono.Documentation/MDocUpdater.cs
index 44e7e8ab..47b50d40 100644
--- a/mdoc/Mono.Documentation/MDocUpdater.cs
+++ b/mdoc/Mono.Documentation/MDocUpdater.cs
@@ -2454,7 +2454,6 @@ namespace Mono.Documentation
info.Node = WriteElement (me, "Docs");
MakeDocNode (info, typeEntry.Framework.Importers, typeEntry);
-
foreach (MemberFormatter f in FormatterManager.MemberFormatters)
{
diff --git a/mdoc/Mono.Documentation/Updater/Formatters/CppFormatters/CppCxFullMemberFormatter.cs b/mdoc/Mono.Documentation/Updater/Formatters/CppFormatters/CppCxFullMemberFormatter.cs
index 0c158189..9415680f 100644
--- a/mdoc/Mono.Documentation/Updater/Formatters/CppFormatters/CppCxFullMemberFormatter.cs
+++ b/mdoc/Mono.Documentation/Updater/Formatters/CppFormatters/CppCxFullMemberFormatter.cs
@@ -131,6 +131,13 @@ namespace Mono.Documentation.Updater.Formatters.CppFormatters
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)
@@ -202,9 +209,10 @@ namespace Mono.Documentation.Updater.Formatters.CppFormatters
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");
diff --git a/mdoc/Mono.Documentation/Updater/Formatters/CppFormatters/CppFullMemberFormatter.cs b/mdoc/Mono.Documentation/Updater/Formatters/CppFormatters/CppFullMemberFormatter.cs
index 171ca144..7eede39d 100644
--- a/mdoc/Mono.Documentation/Updater/Formatters/CppFormatters/CppFullMemberFormatter.cs
+++ b/mdoc/Mono.Documentation/Updater/Formatters/CppFormatters/CppFullMemberFormatter.cs
@@ -181,9 +181,10 @@ namespace Mono.Documentation.Updater.Formatters.CppFormatters
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");
diff --git a/mdoc/Mono.Documentation/Updater/Formatters/CppFormatters/CppWinRtFullMemberFormatter.cs b/mdoc/Mono.Documentation/Updater/Formatters/CppFormatters/CppWinRtFullMemberFormatter.cs
index d389d818..646e802d 100644
--- a/mdoc/Mono.Documentation/Updater/Formatters/CppFormatters/CppWinRtFullMemberFormatter.cs
+++ b/mdoc/Mono.Documentation/Updater/Formatters/CppFormatters/CppWinRtFullMemberFormatter.cs
@@ -59,20 +59,26 @@ namespace Mono.Documentation.Updater.Formatters.CppFormatters
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)
@@ -205,9 +211,10 @@ namespace Mono.Documentation.Updater.Formatters.CppFormatters
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");
diff --git a/mdoc/mdoc.Test/CppCxFormatterMembersTests.cs b/mdoc/mdoc.Test/CppCxFormatterMembersTests.cs
index 10b0378f..d9fe24cd 100644
--- a/mdoc/mdoc.Test/CppCxFormatterMembersTests.cs
+++ b/mdoc/mdoc.Test/CppCxFormatterMembersTests.cs
@@ -43,30 +43,22 @@ namespace mdoc.Test
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]
diff --git a/mdoc/mdoc.Test/CppCxFormatterTypesTests.cs b/mdoc/mdoc.Test/CppCxFormatterTypesTests.cs
index d8bf6909..2bbd8390 100644
--- a/mdoc/mdoc.Test/CppCxFormatterTypesTests.cs
+++ b/mdoc/mdoc.Test/CppCxFormatterTypesTests.cs
@@ -13,6 +13,7 @@ namespace mdoc.Test
{
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)
@@ -85,9 +86,74 @@ namespace mdoc.Test
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()
{
diff --git a/mdoc/mdoc.Test/CppFullFormatterTests.cs b/mdoc/mdoc.Test/CppFullFormatterTests.cs
index 9cd417d8..1ad39d43 100644
--- a/mdoc/mdoc.Test/CppFullFormatterTests.cs
+++ b/mdoc/mdoc.Test/CppFullFormatterTests.cs
@@ -240,7 +240,6 @@ generic <typename T>
typeof(MyList1<,>), @"public:
virtual System::Collections::Generic::IEnumerator<A> ^ GetEnumerator() = System::Collections::Generic::IEnumerable<A>::GetEnumerator;",
nameof(MyList1<int, int>.GetEnumerator));
-
}
[Test]
@@ -250,7 +249,6 @@ generic <typename T>
static Mono_DocTest::Widget ^ operator +(Mono_DocTest::Widget ^ x1, Mono_DocTest::Widget ^ x2);",
"op_Addition");
-
[Test]
[Category("Methods")]
[Category("NoSupport")]
@@ -266,6 +264,30 @@ generic <typename T>
}
[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() =>
TestMethodSignature(typeof(Widget), @"public:
diff --git a/mdoc/mdoc.Test/CppWinRtFormatterTests.cs b/mdoc/mdoc.Test/CppWinRtFormatterTests.cs
index c17ebec9..65e6a614 100644
--- a/mdoc/mdoc.Test/CppWinRtFormatterTests.cs
+++ b/mdoc/mdoc.Test/CppWinRtFormatterTests.cs
@@ -13,6 +13,7 @@ namespace mdoc.Test
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";
@@ -55,6 +56,55 @@ namespace mdoc.Test
[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()
{
TestTypeSignature(typeof(IFoo<>), @"template <typename T>
@@ -87,6 +137,22 @@ 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()
{
diff --git a/mdoc/mdoc.Test/CppWinRtMembersTests.cs b/mdoc/mdoc.Test/CppWinRtMembersTests.cs
index 3a33e69a..918efc32 100644
--- a/mdoc/mdoc.Test/CppWinRtMembersTests.cs
+++ b/mdoc/mdoc.Test/CppWinRtMembersTests.cs
@@ -41,7 +41,7 @@ namespace mdoc.Test
}
[Test]
- public void CreateNewGuid()
+ public void Method_CreateNewGuid()
{
var member = GetMethod(typeof(GuidClass), m => m.Name == "CreateNewGuid");
var sig = formatter.GetDeclaration(member);
@@ -49,7 +49,7 @@ namespace mdoc.Test
}
[Test]
- public void ObjectIndentical()
+ public void Method_ObjectIndentical()
{
var member = GetMethod(typeof(GuidClass), m => m.Name == "ObjectIndentical");
var sig = formatter.GetDeclaration(member);