From 96580221b0356b97afcacbaf037c8d169a6355cf Mon Sep 17 00:00:00 2001 From: Xiao Luo Date: Fri, 22 Jan 2021 11:39:48 +0800 Subject: [PATCH 1/6] Initial commit. --- mdoc/Mono.Documentation/Updater/DocUtils.cs | 17 +++++++++++++++++ .../Updater/DocumentationEnumerator.cs | 2 +- mdoc/mdoc.Test/BasicTests.cs | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/mdoc/Mono.Documentation/Updater/DocUtils.cs b/mdoc/Mono.Documentation/Updater/DocUtils.cs index 718c26c90..8a29d0104 100644 --- a/mdoc/Mono.Documentation/Updater/DocUtils.cs +++ b/mdoc/Mono.Documentation/Updater/DocUtils.cs @@ -928,5 +928,22 @@ public static bool IsEiiIgnoredMethod(MethodReference method, MethodReference im return false; } + + public static TypeDefinition FixUnnamedParameters(TypeDefinition type) + { + foreach (var method in type.Methods) + { + var unnamedParameterIndex = 1; + foreach (var item in method.Parameters) + { + if (string.IsNullOrEmpty(item.Name)) + { + item.Name = $"unnamedParam{unnamedParameterIndex++}"; + } + } + } + + return type; + } } } diff --git a/mdoc/Mono.Documentation/Updater/DocumentationEnumerator.cs b/mdoc/Mono.Documentation/Updater/DocumentationEnumerator.cs index 3be0636f4..9274be3d5 100644 --- a/mdoc/Mono.Documentation/Updater/DocumentationEnumerator.cs +++ b/mdoc/Mono.Documentation/Updater/DocumentationEnumerator.cs @@ -27,7 +27,7 @@ protected IEnumerable GetDocumentationTypes (AssemblyDefinition continue; if (seen != null && seen.Contains (type.FullName)) continue; - yield return type; + yield return DocUtils.FixUnnamedParameters(type); } } diff --git a/mdoc/mdoc.Test/BasicTests.cs b/mdoc/mdoc.Test/BasicTests.cs index adf2d6393..8713d7445 100644 --- a/mdoc/mdoc.Test/BasicTests.cs +++ b/mdoc/mdoc.Test/BasicTests.cs @@ -46,7 +46,7 @@ protected TypeDefinition GetType(string filepath, string classname) throw new Exception($"Test was unable to find type {classname}"); } - var typeDef = testclass.Resolve(); + var typeDef = DocUtils.FixUnnamedParameters(testclass.Resolve()); typesCash.Add(classname, typeDef); return typeDef; } From 91c1531d7fa3114905d5199a7a24a17770c832cf Mon Sep 17 00:00:00 2001 From: Xiao Luo Date: Fri, 22 Jan 2021 17:02:15 +0800 Subject: [PATCH 2/6] Normalize code style. --- mdoc/Mono.Documentation/Updater/DocumentationEnumerator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mdoc/Mono.Documentation/Updater/DocumentationEnumerator.cs b/mdoc/Mono.Documentation/Updater/DocumentationEnumerator.cs index 9274be3d5..90f533eff 100644 --- a/mdoc/Mono.Documentation/Updater/DocumentationEnumerator.cs +++ b/mdoc/Mono.Documentation/Updater/DocumentationEnumerator.cs @@ -27,7 +27,7 @@ protected IEnumerable GetDocumentationTypes (AssemblyDefinition continue; if (seen != null && seen.Contains (type.FullName)) continue; - yield return DocUtils.FixUnnamedParameters(type); + yield return DocUtils.FixUnnamedParameters (type); } } From 2a029932b68fdd8bbb135ec4dd05eb739a64b511 Mon Sep 17 00:00:00 2001 From: Xiao Luo Date: Fri, 22 Jan 2021 17:43:17 +0800 Subject: [PATCH 3/6] Fix bug, named unnamed parameter only work in methods. --- mdoc/Mono.Documentation/Updater/DocUtils.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/mdoc/Mono.Documentation/Updater/DocUtils.cs b/mdoc/Mono.Documentation/Updater/DocUtils.cs index 8a29d0104..cf0bf78a2 100644 --- a/mdoc/Mono.Documentation/Updater/DocUtils.cs +++ b/mdoc/Mono.Documentation/Updater/DocUtils.cs @@ -933,12 +933,15 @@ public static TypeDefinition FixUnnamedParameters(TypeDefinition type) { foreach (var method in type.Methods) { - var unnamedParameterIndex = 1; - foreach (var item in method.Parameters) + if (method is MethodDefinition methodDefinition && !methodDefinition.IsConstructor) { - if (string.IsNullOrEmpty(item.Name)) + var unnamedParameterIndex = 1; + foreach (var item in method.Parameters) { - item.Name = $"unnamedParam{unnamedParameterIndex++}"; + if (string.IsNullOrEmpty(item.Name)) + { + item.Name = $"unnamedParam{unnamedParameterIndex++}"; + } } } } From 98727402be33ff89ecfc4988b8f6065513cf2e63 Mon Sep 17 00:00:00 2001 From: Xiao Luo Date: Fri, 22 Jan 2021 18:48:17 +0800 Subject: [PATCH 4/6] Revert "Fix bug, named unnamed parameter only work in methods." This reverts commit 2a029932b68fdd8bbb135ec4dd05eb739a64b511. --- mdoc/Mono.Documentation/Updater/DocUtils.cs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/mdoc/Mono.Documentation/Updater/DocUtils.cs b/mdoc/Mono.Documentation/Updater/DocUtils.cs index cf0bf78a2..8a29d0104 100644 --- a/mdoc/Mono.Documentation/Updater/DocUtils.cs +++ b/mdoc/Mono.Documentation/Updater/DocUtils.cs @@ -933,15 +933,12 @@ public static TypeDefinition FixUnnamedParameters(TypeDefinition type) { foreach (var method in type.Methods) { - if (method is MethodDefinition methodDefinition && !methodDefinition.IsConstructor) + var unnamedParameterIndex = 1; + foreach (var item in method.Parameters) { - var unnamedParameterIndex = 1; - foreach (var item in method.Parameters) + if (string.IsNullOrEmpty(item.Name)) { - if (string.IsNullOrEmpty(item.Name)) - { - item.Name = $"unnamedParam{unnamedParameterIndex++}"; - } + item.Name = $"unnamedParam{unnamedParameterIndex++}"; } } } From 7b7e71c231e718d568d369c99e6a36b650233e1e Mon Sep 17 00:00:00 2001 From: Xiao Luo Date: Fri, 22 Jan 2021 19:35:47 +0800 Subject: [PATCH 5/6] Update the expected XML of test project of fsharp. --- .../en.expected-fsharp/AbstractClasses+Shape2D.xml | 10 +++++----- mdoc/Test/en.expected-fsharp/Delegates+Delegate1.xml | 6 +++--- mdoc/Test/en.expected-fsharp/Delegates+Delegate10.xml | 10 +++++----- mdoc/Test/en.expected-fsharp/Delegates+Delegate11.xml | 6 +++--- mdoc/Test/en.expected-fsharp/Delegates+Delegate13.xml | 6 +++--- mdoc/Test/en.expected-fsharp/Delegates+Delegate2.xml | 10 +++++----- mdoc/Test/en.expected-fsharp/Delegates+Delegate3.xml | 10 +++++----- mdoc/Test/en.expected-fsharp/Delegates+Delegate4.xml | 6 +++--- mdoc/Test/en.expected-fsharp/Delegates+Delegate5.xml | 6 +++--- mdoc/Test/en.expected-fsharp/Delegates+Delegate6.xml | 6 +++--- mdoc/Test/en.expected-fsharp/Delegates+Delegate7.xml | 6 +++--- mdoc/Test/en.expected-fsharp/Delegates+Delegate8.xml | 6 +++--- mdoc/Test/en.expected-fsharp/Delegates+Delegate9.xml | 6 +++--- mdoc/Test/en.expected-fsharp/Interfaces+Interface0.xml | 10 +++++----- mdoc/Test/en.expected-fsharp/Interfaces+Interface1.xml | 10 +++++----- mdoc/Test/en.expected-fsharp/Interfaces+Interface2.xml | 10 +++++----- mdoc/Test/en.expected-fsharp/Interfaces+Interface3.xml | 10 +++++----- .../SomeNamespace/SomeModule+IVector.xml | 10 +++++----- 18 files changed, 72 insertions(+), 72 deletions(-) diff --git a/mdoc/Test/en.expected-fsharp/AbstractClasses+Shape2D.xml b/mdoc/Test/en.expected-fsharp/AbstractClasses+Shape2D.xml index fa5f3eeed..fc640bb76 100644 --- a/mdoc/Test/en.expected-fsharp/AbstractClasses+Shape2D.xml +++ b/mdoc/Test/en.expected-fsharp/AbstractClasses+Shape2D.xml @@ -131,9 +131,9 @@ - - - + + + Method 1.0.0.0 @@ -142,10 +142,10 @@ System.Void - + - To be added. + To be added. To be added. To be added. diff --git a/mdoc/Test/en.expected-fsharp/Delegates+Delegate1.xml b/mdoc/Test/en.expected-fsharp/Delegates+Delegate1.xml index 35c802963..4c20073f1 100644 --- a/mdoc/Test/en.expected-fsharp/Delegates+Delegate1.xml +++ b/mdoc/Test/en.expected-fsharp/Delegates+Delegate1.xml @@ -1,5 +1,5 @@ - + @@ -20,13 +20,13 @@ - + System.Int32 - To be added. + To be added. To be added. To be added. To be added. diff --git a/mdoc/Test/en.expected-fsharp/Delegates+Delegate10.xml b/mdoc/Test/en.expected-fsharp/Delegates+Delegate10.xml index 588b0bb0f..3bfae7235 100644 --- a/mdoc/Test/en.expected-fsharp/Delegates+Delegate10.xml +++ b/mdoc/Test/en.expected-fsharp/Delegates+Delegate10.xml @@ -1,5 +1,5 @@ - + @@ -20,15 +20,15 @@ - - + + System.Char - To be added. - To be added. + To be added. + To be added. To be added. To be added. To be added. diff --git a/mdoc/Test/en.expected-fsharp/Delegates+Delegate11.xml b/mdoc/Test/en.expected-fsharp/Delegates+Delegate11.xml index 634e03848..e7c9088b8 100644 --- a/mdoc/Test/en.expected-fsharp/Delegates+Delegate11.xml +++ b/mdoc/Test/en.expected-fsharp/Delegates+Delegate11.xml @@ -1,5 +1,5 @@ - + @@ -20,13 +20,13 @@ - + System.Void - To be added. + To be added. To be added. To be added. diff --git a/mdoc/Test/en.expected-fsharp/Delegates+Delegate13.xml b/mdoc/Test/en.expected-fsharp/Delegates+Delegate13.xml index 32171f312..840c239c1 100644 --- a/mdoc/Test/en.expected-fsharp/Delegates+Delegate13.xml +++ b/mdoc/Test/en.expected-fsharp/Delegates+Delegate13.xml @@ -1,5 +1,5 @@ - + @@ -20,13 +20,13 @@ - + System.Double - To be added. + To be added. To be added. To be added. To be added. diff --git a/mdoc/Test/en.expected-fsharp/Delegates+Delegate2.xml b/mdoc/Test/en.expected-fsharp/Delegates+Delegate2.xml index 294962fef..97bb177bd 100644 --- a/mdoc/Test/en.expected-fsharp/Delegates+Delegate2.xml +++ b/mdoc/Test/en.expected-fsharp/Delegates+Delegate2.xml @@ -1,5 +1,5 @@ - + @@ -20,15 +20,15 @@ - - + + System.Int32 - To be added. - To be added. + To be added. + To be added. To be added. To be added. To be added. diff --git a/mdoc/Test/en.expected-fsharp/Delegates+Delegate3.xml b/mdoc/Test/en.expected-fsharp/Delegates+Delegate3.xml index 7277a35db..6ab632ce9 100644 --- a/mdoc/Test/en.expected-fsharp/Delegates+Delegate3.xml +++ b/mdoc/Test/en.expected-fsharp/Delegates+Delegate3.xml @@ -1,5 +1,5 @@ - + @@ -20,15 +20,15 @@ - - + + System.String - To be added. - To be added. + To be added. + To be added. To be added. To be added. To be added. diff --git a/mdoc/Test/en.expected-fsharp/Delegates+Delegate4.xml b/mdoc/Test/en.expected-fsharp/Delegates+Delegate4.xml index 969f28ba0..add42ee28 100644 --- a/mdoc/Test/en.expected-fsharp/Delegates+Delegate4.xml +++ b/mdoc/Test/en.expected-fsharp/Delegates+Delegate4.xml @@ -1,5 +1,5 @@ - + @@ -20,13 +20,13 @@ - + Microsoft.FSharp.Core.FSharpFunc<System.Int32,System.Char> - To be added. + To be added. To be added. To be added. To be added. diff --git a/mdoc/Test/en.expected-fsharp/Delegates+Delegate5.xml b/mdoc/Test/en.expected-fsharp/Delegates+Delegate5.xml index b72d97772..29384c347 100644 --- a/mdoc/Test/en.expected-fsharp/Delegates+Delegate5.xml +++ b/mdoc/Test/en.expected-fsharp/Delegates+Delegate5.xml @@ -1,5 +1,5 @@ - + @@ -20,13 +20,13 @@ - + Microsoft.FSharp.Core.FSharpFunc<System.Int32,Microsoft.FSharp.Core.FSharpFunc<System.Char,System.String>> - To be added. + To be added. To be added. To be added. To be added. diff --git a/mdoc/Test/en.expected-fsharp/Delegates+Delegate6.xml b/mdoc/Test/en.expected-fsharp/Delegates+Delegate6.xml index 241f52d3d..33cc504cd 100644 --- a/mdoc/Test/en.expected-fsharp/Delegates+Delegate6.xml +++ b/mdoc/Test/en.expected-fsharp/Delegates+Delegate6.xml @@ -1,5 +1,5 @@ - + @@ -20,13 +20,13 @@ - + System.Char - To be added. + To be added. To be added. To be added. To be added. diff --git a/mdoc/Test/en.expected-fsharp/Delegates+Delegate7.xml b/mdoc/Test/en.expected-fsharp/Delegates+Delegate7.xml index 5f88bcf9d..fb40e142b 100644 --- a/mdoc/Test/en.expected-fsharp/Delegates+Delegate7.xml +++ b/mdoc/Test/en.expected-fsharp/Delegates+Delegate7.xml @@ -1,5 +1,5 @@ - + @@ -20,13 +20,13 @@ - + System.Double - To be added. + To be added. To be added. To be added. To be added. diff --git a/mdoc/Test/en.expected-fsharp/Delegates+Delegate8.xml b/mdoc/Test/en.expected-fsharp/Delegates+Delegate8.xml index 1f3713a92..158bccc66 100644 --- a/mdoc/Test/en.expected-fsharp/Delegates+Delegate8.xml +++ b/mdoc/Test/en.expected-fsharp/Delegates+Delegate8.xml @@ -1,5 +1,5 @@ - + @@ -20,13 +20,13 @@ - + System.Char - To be added. + To be added. To be added. To be added. To be added. diff --git a/mdoc/Test/en.expected-fsharp/Delegates+Delegate9.xml b/mdoc/Test/en.expected-fsharp/Delegates+Delegate9.xml index 877a09ed6..a5c091ca0 100644 --- a/mdoc/Test/en.expected-fsharp/Delegates+Delegate9.xml +++ b/mdoc/Test/en.expected-fsharp/Delegates+Delegate9.xml @@ -1,5 +1,5 @@ - + @@ -20,13 +20,13 @@ - + System.Char - To be added. + To be added. To be added. To be added. To be added. diff --git a/mdoc/Test/en.expected-fsharp/Interfaces+Interface0.xml b/mdoc/Test/en.expected-fsharp/Interfaces+Interface0.xml index cb47a026d..63dcede20 100644 --- a/mdoc/Test/en.expected-fsharp/Interfaces+Interface0.xml +++ b/mdoc/Test/en.expected-fsharp/Interfaces+Interface0.xml @@ -23,9 +23,9 @@ - - - + + + Method 1.0.0.0 @@ -34,10 +34,10 @@ System.Int32 - + - To be added. + To be added. To be added. To be added. To be added. diff --git a/mdoc/Test/en.expected-fsharp/Interfaces+Interface1.xml b/mdoc/Test/en.expected-fsharp/Interfaces+Interface1.xml index 9ed7d805b..4d946f12d 100644 --- a/mdoc/Test/en.expected-fsharp/Interfaces+Interface1.xml +++ b/mdoc/Test/en.expected-fsharp/Interfaces+Interface1.xml @@ -23,9 +23,9 @@ - - - + + + Method 1.0.0.0 @@ -34,10 +34,10 @@ System.Int32 - + - To be added. + To be added. To be added. To be added. To be added. diff --git a/mdoc/Test/en.expected-fsharp/Interfaces+Interface2.xml b/mdoc/Test/en.expected-fsharp/Interfaces+Interface2.xml index 06023a4fc..73c7d650e 100644 --- a/mdoc/Test/en.expected-fsharp/Interfaces+Interface2.xml +++ b/mdoc/Test/en.expected-fsharp/Interfaces+Interface2.xml @@ -23,9 +23,9 @@ - - - + + + Method 1.0.0.0 @@ -34,10 +34,10 @@ System.Int32 - + - To be added. + To be added. To be added. To be added. To be added. diff --git a/mdoc/Test/en.expected-fsharp/Interfaces+Interface3.xml b/mdoc/Test/en.expected-fsharp/Interfaces+Interface3.xml index 405b44585..079c290ab 100644 --- a/mdoc/Test/en.expected-fsharp/Interfaces+Interface3.xml +++ b/mdoc/Test/en.expected-fsharp/Interfaces+Interface3.xml @@ -30,9 +30,9 @@ - - - + + + Method 1.0.0.0 @@ -41,10 +41,10 @@ System.Int32 - + - To be added. + To be added. To be added. To be added. To be added. diff --git a/mdoc/Test/en.expected-fsharp/SomeNamespace/SomeModule+IVector.xml b/mdoc/Test/en.expected-fsharp/SomeNamespace/SomeModule+IVector.xml index 24013a92f..bac8e4902 100644 --- a/mdoc/Test/en.expected-fsharp/SomeNamespace/SomeModule+IVector.xml +++ b/mdoc/Test/en.expected-fsharp/SomeNamespace/SomeModule+IVector.xml @@ -23,9 +23,9 @@ - - - + + + Method 1.0.0.0 @@ -34,10 +34,10 @@ SomeNamespace.SomeModule+IVector - + - To be added. + To be added. To be added. To be added. To be added. From fbd0e9380738f7fbd01e83e0d5210a80144283bc Mon Sep 17 00:00:00 2001 From: Xiao Luo Date: Fri, 22 Jan 2021 20:05:32 +0800 Subject: [PATCH 6/6] Update the expected XML of test project of fsharp. --- mdoc/Test/en.expected-fsharp/Delegates+Delegate1.xml | 2 +- mdoc/Test/en.expected-fsharp/Delegates+Delegate9.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mdoc/Test/en.expected-fsharp/Delegates+Delegate1.xml b/mdoc/Test/en.expected-fsharp/Delegates+Delegate1.xml index 4c20073f1..5024229de 100644 --- a/mdoc/Test/en.expected-fsharp/Delegates+Delegate1.xml +++ b/mdoc/Test/en.expected-fsharp/Delegates+Delegate1.xml @@ -1,5 +1,5 @@ - + diff --git a/mdoc/Test/en.expected-fsharp/Delegates+Delegate9.xml b/mdoc/Test/en.expected-fsharp/Delegates+Delegate9.xml index a5c091ca0..48b52f5e7 100644 --- a/mdoc/Test/en.expected-fsharp/Delegates+Delegate9.xml +++ b/mdoc/Test/en.expected-fsharp/Delegates+Delegate9.xml @@ -1,5 +1,5 @@ - +