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:
authorv-susu1 <v-susu@microsoft.com>2021-12-02 09:02:07 +0300
committerGitHub <noreply@github.com>2021-12-02 09:02:07 +0300
commita54aa828dff8f203037e7f341ec3bb28f1222521 (patch)
treea76b0c334d26b4b689616a10fe5593d8168bafdc
parent7c0e36407dbac73203378e1eafd24e140af26565 (diff)
Fix bug 514755 (#588)
* Fix bug 514755 * add test cases to cover bug 514755 * update
-rw-r--r--external/Test/mdoc.Test.NullableReferenceTypes.dllbin22016 -> 23040 bytes
-rw-r--r--mdoc/Mono.Documentation/Updater/Formatters/MemberFormatter.cs5
-rw-r--r--mdoc/mdoc.Test/NullableReferenceTypesTests.cs12
-rw-r--r--mdoc/mdoc.Test/mdoc.Test.NullableReferenceTypes/mdoc.Test.NullableReferenceTypes/GenericMethodParameter.cs24
-rw-r--r--mdoc/mdoc.Test/mdoc.Test.NullableReferenceTypes/mdoc.Test.NullableReferenceTypes/GenericMethodReturnType.cs30
-rw-r--r--mdoc/mdoc.Test/mdoc.Test.NullableReferenceTypes/mdoc.Test.NullableReferenceTypes/GenericType.cs12
6 files changed, 81 insertions, 2 deletions
diff --git a/external/Test/mdoc.Test.NullableReferenceTypes.dll b/external/Test/mdoc.Test.NullableReferenceTypes.dll
index 70e9e573..b35bf231 100644
--- a/external/Test/mdoc.Test.NullableReferenceTypes.dll
+++ b/external/Test/mdoc.Test.NullableReferenceTypes.dll
Binary files differ
diff --git a/mdoc/Mono.Documentation/Updater/Formatters/MemberFormatter.cs b/mdoc/Mono.Documentation/Updater/Formatters/MemberFormatter.cs
index d5f634e1..439d91b5 100644
--- a/mdoc/Mono.Documentation/Updater/Formatters/MemberFormatter.cs
+++ b/mdoc/Mono.Documentation/Updater/Formatters/MemberFormatter.cs
@@ -390,12 +390,13 @@ namespace Mono.Documentation.Updater
return false;
}
- private void AppendGenericTypeParameter (StringBuilder buf, TypeReference type, IAttributeParserContext context, bool useTypeProjection = true)
+ private void AppendGenericTypeParameter(StringBuilder buf, TypeReference type, IAttributeParserContext context, bool useTypeProjection = true)
{
var isNullableType = false;
if (type is GenericInstanceType)
{
- isNullableType = context.IsNullable();
+ // Fix bug https://dev.azure.com/ceapex/Engineering/_workitems/edit/514755?src=WorkItemMention&src-action=artifact_link
+ isNullableType = (type.Name == "Nullable`1" ? true : context.IsNullable());
buf.Append(GetTypeName(type, context));
}
else
diff --git a/mdoc/mdoc.Test/NullableReferenceTypesTests.cs b/mdoc/mdoc.Test/NullableReferenceTypesTests.cs
index fb8af0e4..5a166f47 100644
--- a/mdoc/mdoc.Test/NullableReferenceTypesTests.cs
+++ b/mdoc/mdoc.Test/NullableReferenceTypesTests.cs
@@ -154,6 +154,12 @@ namespace mdoc.Test
[TestCase("FuncGenericNullableValueType", "<T> ({0}) where T : struct", "Func<T?> func")]
[TestCase("NullableFuncGenericNullableValueType", "<T> ({0}) where T : struct", "Func<T?>? func")]
[TestCase("GenericNonNullableAndNullableValueType", "<T1,T2> ({0}) where T2 : struct", "T1 t1, T2? t2")]
+ [TestCase("GenericTypeWithNullableParameters1", " ({0})", "GenericType<string?,int?,bool?> p")]
+ [TestCase("GenericTypeWithNullableParameters2", " ({0})", "GenericType<string?,int,bool> p")]
+ [TestCase("GenericTypeWithNullableParameters3", " ({0})", "GenericType<string,int,bool> p")]
+ [TestCase("GenericTypeWithNullableParameters4", " ({0})", "GenericType<string?,string> p")]
+ [TestCase("GenericTypeWithNullableParameters5", " ({0})", "GenericType<int?,int> p")]
+ [TestCase("GenericTypeWithNullableParameters6", " ({0})", "GenericType<bool?,bool> p")]
public void GenericMethodParameter(string methodName, string otherPartOfMethodSignature, string genericParameter)
{
TestMethodSignature(NullableReferenceTypesAssemblyPath, "mdoc.Test.NullableReferenceTypes.GenericMethodParameter",
@@ -165,6 +171,12 @@ namespace mdoc.Test
[TestCase("T?", "GenericNullableReferenceType", "<T> () where T : class")]
[TestCase("T", "GenericValueType", "<T> () where T : struct")]
[TestCase("T?", "GenericNullableValueType", "<T> () where T : struct")]
+ [TestCase("GenericType<string?,int?,bool?>", "GenericReturnValueWithNullableParameters1", " ()")]
+ [TestCase("GenericType<string?,int,bool>", "GenericReturnValueWithNullableParameters2", " ()")]
+ [TestCase("GenericType<string,int,bool>", "GenericReturnValueWithNullableParameters3", " ()")]
+ [TestCase("GenericType<string?,string>", "GenericReturnValueWithNullableParameters4", " ()")]
+ [TestCase("GenericType<int?,int>", "GenericReturnValueWithNullableParameters5", " ()")]
+ [TestCase("GenericType<bool?,bool>", "GenericReturnValueWithNullableParameters6", " ()")]
public void GenericMethodReturnType(string returnType, string methodName, string otherPartOfMethodSignature)
{
TestMethodSignature(NullableReferenceTypesAssemblyPath, "mdoc.Test.NullableReferenceTypes.GenericMethodReturnType",
diff --git a/mdoc/mdoc.Test/mdoc.Test.NullableReferenceTypes/mdoc.Test.NullableReferenceTypes/GenericMethodParameter.cs b/mdoc/mdoc.Test/mdoc.Test.NullableReferenceTypes/mdoc.Test.NullableReferenceTypes/GenericMethodParameter.cs
index 021404a8..0fe99e9d 100644
--- a/mdoc/mdoc.Test/mdoc.Test.NullableReferenceTypes/mdoc.Test.NullableReferenceTypes/GenericMethodParameter.cs
+++ b/mdoc/mdoc.Test/mdoc.Test.NullableReferenceTypes/mdoc.Test.NullableReferenceTypes/GenericMethodParameter.cs
@@ -63,5 +63,29 @@ namespace mdoc.Test.NullableReferenceTypes
public void GenericNonNullableAndNullableValueType<T1, T2>(T1 t1, T2? t2) where T2 : struct
{
}
+
+ public void GenericTypeWithNullableParameters1(GenericType<string?, int?, bool?> p)
+ {
+ }
+
+ public void GenericTypeWithNullableParameters2(GenericType<string?, int, bool> p)
+ {
+ }
+
+ public void GenericTypeWithNullableParameters3(GenericType<string, int, bool> p)
+ {
+ }
+
+ public void GenericTypeWithNullableParameters4(GenericType<string?, string> p)
+ {
+ }
+
+ public void GenericTypeWithNullableParameters5(GenericType<int?, int> p)
+ {
+ }
+
+ public void GenericTypeWithNullableParameters6(GenericType<bool?, bool> p)
+ {
+ }
}
}
diff --git a/mdoc/mdoc.Test/mdoc.Test.NullableReferenceTypes/mdoc.Test.NullableReferenceTypes/GenericMethodReturnType.cs b/mdoc/mdoc.Test/mdoc.Test.NullableReferenceTypes/mdoc.Test.NullableReferenceTypes/GenericMethodReturnType.cs
index 0794c8c6..0bab3207 100644
--- a/mdoc/mdoc.Test/mdoc.Test.NullableReferenceTypes/mdoc.Test.NullableReferenceTypes/GenericMethodReturnType.cs
+++ b/mdoc/mdoc.Test/mdoc.Test.NullableReferenceTypes/mdoc.Test.NullableReferenceTypes/GenericMethodReturnType.cs
@@ -26,5 +26,35 @@
{
return default;
}
+
+ public GenericType<string?, int?, bool?> GenericReturnValueWithNullableParameters1()
+ {
+ return new GenericType<string?, int?, bool?>();
+ }
+
+ public GenericType<string?, int, bool> GenericReturnValueWithNullableParameters2()
+ {
+ return new GenericType<string?, int, bool>();
+ }
+
+ public GenericType<string, int, bool> GenericReturnValueWithNullableParameters3()
+ {
+ return new GenericType<string, int, bool>();
+ }
+
+ public GenericType<string?, string> GenericReturnValueWithNullableParameters4()
+ {
+ return new GenericType<string?, string>();
+ }
+
+ public GenericType<int?,int> GenericReturnValueWithNullableParameters5()
+ {
+ return new GenericType<int?,int>();
+ }
+
+ public GenericType<bool?, bool> GenericReturnValueWithNullableParameters6()
+ {
+ return new GenericType<bool?, bool>();
+ }
}
}
diff --git a/mdoc/mdoc.Test/mdoc.Test.NullableReferenceTypes/mdoc.Test.NullableReferenceTypes/GenericType.cs b/mdoc/mdoc.Test/mdoc.Test.NullableReferenceTypes/mdoc.Test.NullableReferenceTypes/GenericType.cs
new file mode 100644
index 00000000..78c9ab16
--- /dev/null
+++ b/mdoc/mdoc.Test/mdoc.Test.NullableReferenceTypes/mdoc.Test.NullableReferenceTypes/GenericType.cs
@@ -0,0 +1,12 @@
+using System;
+
+namespace mdoc.Test.NullableReferenceTypes
+{
+ public class GenericType<A, B>
+ {
+ }
+
+ public class GenericType<A, B, C>
+ {
+ }
+}