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:
authorGang Zhang <104287933+gangzhang-ms@users.noreply.github.com>2022-11-08 12:26:19 +0300
committerGitHub <noreply@github.com>2022-11-08 12:26:19 +0300
commitbd84ceee70cdab1a36748c2e8ec5062fb52a63c9 (patch)
tree0c2a15b00edf7c87aa9fa26615660f6fcacc8268
parent215b2a927c9c9848130ee2c9a9eaebff46dedded (diff)
support scoped keyword in method parameters (#655)develop
* support scoped keyword * renaming
-rw-r--r--mdoc/Mono.Documentation/Updater/Formatters/CSharpFullMemberFormatter.cs7
-rw-r--r--mdoc/mdoc.Test/FormatterTests.cs9
-rw-r--r--mdoc/mdoc.Test/SampleClasses/SomeClass.cs8
-rw-r--r--mdoc/mdoc.Test/mdoc.Test.csproj4
4 files changed, 25 insertions, 3 deletions
diff --git a/mdoc/Mono.Documentation/Updater/Formatters/CSharpFullMemberFormatter.cs b/mdoc/Mono.Documentation/Updater/Formatters/CSharpFullMemberFormatter.cs
index ec625447..f83a48a2 100644
--- a/mdoc/Mono.Documentation/Updater/Formatters/CSharpFullMemberFormatter.cs
+++ b/mdoc/Mono.Documentation/Updater/Formatters/CSharpFullMemberFormatter.cs
@@ -608,6 +608,13 @@ namespace Mono.Documentation.Updater.Formatters
TypeReference parameterType = parameter.ParameterType;
var refType = new BitArray(3);
+ if (parameter.HasCustomAttributes)
+ {
+ var isScoped = parameter.CustomAttributes.Any(ca => ca.AttributeType.Name == "LifetimeAnnotationAttribute");
+ if (isScoped)
+ buf.AppendFormat("scoped ");
+ }
+
if (parameterType is RequiredModifierType requiredModifierType)
{
switch(requiredModifierType.ModifierType.FullName)
diff --git a/mdoc/mdoc.Test/FormatterTests.cs b/mdoc/mdoc.Test/FormatterTests.cs
index d306b51a..4c4ca8ca 100644
--- a/mdoc/mdoc.Test/FormatterTests.cs
+++ b/mdoc/mdoc.Test/FormatterTests.cs
@@ -271,6 +271,15 @@ namespace mdoc.Test
Assert.AreEqual(expectedSignature, actualSignature);
}
+ [TestCase(typeof(SomeClass), "TestScopedParams", "public ref T TestScopedParams<T> (scoped in T p1, out T p2, scoped ref T p3);")]
+ public void CSharpScopedParamsTest(Type type, string methodName, string expectedSignature)
+ {
+ var member = GetMethod(type, m => m.Name == methodName);
+ var actualSignature = formatter.GetDeclaration(member);
+ Assert.AreEqual(expectedSignature, actualSignature);
+ }
+
+
[TestCase(typeof(ReadonlyRefClass), "RefProperty", "public ref int RefProperty { get; }")]
[TestCase(typeof(ReadonlyRefClass), "Item", "public ref readonly int this[int index] { get; }")]
[TestCase(typeof(GenericRefClass<>), "RefProperty", "public ref T RefProperty { get; }")]
diff --git a/mdoc/mdoc.Test/SampleClasses/SomeClass.cs b/mdoc/mdoc.Test/SampleClasses/SomeClass.cs
index 615ab8b2..7e7d2dae 100644
--- a/mdoc/mdoc.Test/SampleClasses/SomeClass.cs
+++ b/mdoc/mdoc.Test/SampleClasses/SomeClass.cs
@@ -1,4 +1,5 @@
-using System;
+using Mono.Cecil.Cil;
+using System;
using Windows.Foundation.Metadata;
namespace mdoc.Test.SampleClasses
@@ -98,6 +99,11 @@ namespace mdoc.Test.SampleClasses
{
}
+ public ref T TestScopedParams<T>(scoped in T p1, scoped out T p2, scoped ref T p3)
+ {
+ throw new PlatformNotSupportedException();
+ }
+
public event EventHandler<object> AppMemoryUsageIncreased;
public static event EventHandler<object> StaticEvent;
private static event EventHandler<object> PrivateEvent;
diff --git a/mdoc/mdoc.Test/mdoc.Test.csproj b/mdoc/mdoc.Test/mdoc.Test.csproj
index 0ae687e7..e80ca7dc 100644
--- a/mdoc/mdoc.Test/mdoc.Test.csproj
+++ b/mdoc/mdoc.Test/mdoc.Test.csproj
@@ -8,11 +8,11 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
- <LangVersion>latest</LangVersion>
+ <LangVersion>preview</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutputPath>bin\Release</OutputPath>
- <LangVersion>latest</LangVersion>
+ <LangVersion>preview</LangVersion>
</PropertyGroup>
<PropertyGroup>
<RunPostBuildEvent>Always</RunPostBuildEvent>