Skip to content

Commit e1cd54c

Browse files
authored
bump mdoc to 5.8.7 (#612)
* bump mdoc to 5.8.7 * mdoc: use //license/@expression, not //licenseUrl * fix in parameter issue * fix issue for microsoft.extensions.logging.console.consoleformatter.write api * Fix issue for system.diagnostics.taglist api * Fix test cases * update * update
1 parent 03ee190 commit e1cd54c

7 files changed

Lines changed: 38 additions & 15 deletions

File tree

mdoc/Consts.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ namespace Mono.Documentation
33
{
44
public static class Consts
55
{
6-
public static string MonoVersion = "5.8.6.1";
6+
public static string MonoVersion = "5.8.7";
77
public const string DocId = "DocId";
88
public const string CppCli = "C++ CLI";
99
public const string CppCx = "C++ CX";

mdoc/Mono.Documentation/Updater/Formatters/CSharpFullMemberFormatter.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -503,19 +503,19 @@ protected override StringBuilder AppendModifiers (StringBuilder buf, MethodDefin
503503
{
504504
string modifiers = String.Empty;
505505
if (method.IsStatic) modifiers += " static";
506-
TypeDefinition declType = (TypeDefinition)method.DeclaringType;
507-
if (declType.IsValueType && DocUtils.HasCustomAttribute(method, Consts.IsReadOnlyAttribute))
508-
{
509-
modifiers += " readonly";
510-
}
511506
if (method.IsVirtual && !method.IsAbstract)
512507
{
513508
if ((method.Attributes & MethodAttributes.NewSlot) != 0) modifiers += " virtual";
514509
else modifiers += " override";
515510
}
511+
TypeDefinition declType = (TypeDefinition)method.DeclaringType;
516512
if (method.IsAbstract && !declType.IsInterface) modifiers += " abstract";
517513
if (method.IsFinal) modifiers += " sealed";
518514
if (modifiers == " virtual sealed") modifiers = "";
515+
if (declType.IsValueType && DocUtils.HasCustomAttribute(method, Consts.IsReadOnlyAttribute))
516+
{
517+
modifiers += buf.Length == 0 ? "readonly" : " readonly";
518+
}
519519

520520
switch (method.Name)
521521
{
@@ -593,13 +593,18 @@ private StringBuilder AppendParameter (StringBuilder buf, ParameterDefinition pa
593593
{
594594
TypeReference parameterType = parameter.ParameterType;
595595

596+
if (parameterType is RequiredModifierType requiredModifierType)
597+
{
598+
parameterType = requiredModifierType.ElementType;
599+
}
600+
596601
if (parameterType is ByReferenceType byReferenceType)
597602
{
598603
if (parameter.IsOut)
599604
{
600605
buf.Append ("out ");
601606
}
602-
else if(parameter.IsIn)
607+
else if(parameter.IsIn && DocUtils.HasCustomAttribute(parameter, Consts.IsReadOnlyAttribute))
603608
{
604609
buf.Append("in ");
605610
}

mdoc/mdoc.Test/FormatterTests.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,11 @@ public void FuncParams()
259259
[TestCase(typeof(ReadonlyRefClass), "Ref", "public ref int Ref ();")]
260260
[TestCase(typeof(ReadonlyRefClass), "ReadonlyRef", "public ref readonly int ReadonlyRef ();")]
261261
[TestCase(typeof(ReadonlyRefClass), "RefInAndOutMethod", "public void RefInAndOutMethod (ref int a, in int b, out int c);")]
262+
[TestCase(typeof(ReadonlyRefClass), "InAttributeMethod", "public void InAttributeMethod (ref int a, in int b, out int c);")]
262263
[TestCase(typeof(GenericRefClass<>), "Ref", "public ref T Ref ();")]
263264
[TestCase(typeof(GenericRefClass<>), "ReadonlyRef", "public ref readonly T ReadonlyRef ();")]
264265
[TestCase(typeof(GenericRefClass<>), "RefInAndOutMethod", "public void RefInAndOutMethod (ref T a, in T b, out T c);")]
266+
[TestCase(typeof(GenericRefClass<>), "InAttributeMethod", "public void InAttributeMethod (ref T a, in T b, out T c);")]
265267
public void CSharpRefReturnMethodTest(Type type, string methodName, string expectedSignature)
266268
{
267269
var member = GetMethod(type, m => m.Name == methodName);
@@ -409,12 +411,13 @@ public void CSharpReadOnlyRefStructTest()
409411
Assert.AreEqual("public readonly ref struct ReadOnlyRefStruct", typeSignature);
410412
}
411413

412-
[Test]
413-
public void CSharpReadOnlyMemberStructTest()
414+
[TestCase("Sum", "public readonly double Sum ();")]
415+
[TestCase("GetNum", "readonly int Struct_Interface_A.GetNum ();")]
416+
public void CSharpReadOnlyMemberStructTest(string methodName, string expectedSignature)
414417
{
415-
var method = GetMethod(typeof(SampleClasses.StructWithReadOnlyMethod), m => m.Name == "Sum");
418+
var method = GetMethod(typeof(SampleClasses.StructWithReadOnlyMethod), m => m.Name.Contains(methodName));
416419
var methodSignature = formatter.GetDeclaration(method);
417-
Assert.AreEqual("public readonly double Sum ();", methodSignature);
420+
Assert.AreEqual(expectedSignature, methodSignature);
418421
}
419422

420423
#region Helper Methods

mdoc/mdoc.Test/SampleClasses/ReadonlyRefClass.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace mdoc.Test.SampleClasses
1+
using System.Runtime.InteropServices;
2+
3+
namespace mdoc.Test.SampleClasses
24
{
35
public class ReadonlyRefClass
46
{
@@ -12,6 +14,8 @@ public class ReadonlyRefClass
1214
public ref readonly int this[int index] => throw null;
1315

1416
public void RefInAndOutMethod(ref int a, in int b, out int c) => throw null;
17+
18+
public void InAttributeMethod([In] ref int a, [In] in int b, [Out] out int c) => throw null;
1519
}
1620

1721
public class GenericRefClass<T>
@@ -25,5 +29,7 @@ public class GenericRefClass<T>
2529
public ref readonly T this[int index] => throw null;
2630

2731
public void RefInAndOutMethod(ref T a, in T b, out T c) => throw null;
32+
33+
public void InAttributeMethod([In] ref T a, [In] in T b, [Out] out T c) => throw null;
2834
}
2935
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace mdoc.Test.SampleClasses
22
{
3-
public struct StructWithReadOnlyMethod
3+
public struct StructWithReadOnlyMethod : Struct_Interface_A
44
{
55
public double X { get; set; }
66
public double Y { get; set; }
@@ -9,5 +9,7 @@ public readonly double Sum()
99
{
1010
return X + Y;
1111
}
12+
13+
readonly int Struct_Interface_A.GetNum() => 1;
1214
}
1315
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace mdoc.Test.SampleClasses
2+
{
3+
public interface Struct_Interface_A
4+
{
5+
int GetNum();
6+
}
7+
}

mdoc/mdoc.nuspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
<package >
33
<metadata>
44
<id>mdoc</id>
5-
<version>5.8.6.1</version>
5+
<version>5.8.7</version>
66
<title>mdoc</title>
77
<authors>Microsoft</authors>
88
<owners>Microsoft</owners>
99
<projectUrl>https://github.com/mono/api-doc-tools</projectUrl>
10-
<licenseUrl>https://github.com/mono/api-doc-tools/blob/main/LICENSE.md</licenseUrl>
10+
<license type="expression">MIT</license>
1111
<requireLicenseAcceptance>true</requireLicenseAcceptance>
1212
<description>.NET API Documentation toolchain</description>
1313
<copyright>© Microsoft Corporation. All rights reserved.</copyright>

0 commit comments

Comments
 (0)