Skip to content

Commit 1f344e6

Browse files
committed
update
1 parent 94e41b7 commit 1f344e6

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

mdoc/Mono.Documentation/MDocUpdater.Member.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ internal static void MakeTypeParameterConstraints(XmlElement root, XmlElement e,
4444
AppendElementText(ce, "ParameterAttribute", "NotNullableValueTypeConstraint");
4545
if ((attrs & GenericParameterAttributes.ReferenceTypeConstraint) != 0)
4646
AppendElementText(ce, "ParameterAttribute", "ReferenceTypeConstraint");
47+
// Check for 'allows ref struct' constraint
48+
if ((attrs & (GenericParameterAttributes)0x0020) != 0) // Assuming 0x1000 is the flag for 'allows ref struct'
49+
AppendElementText(ce, "ParameterAttribute", "AllowsRefStruct");
4750

4851
#if NEW_CECIL
4952
foreach (GenericParameterConstraint c in constraints)

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,9 +314,10 @@ private StringBuilder AppendConstraints (StringBuilder buf, IList<GenericParamet
314314
bool isref = (attrs & GenericParameterAttributes.ReferenceTypeConstraint) != 0;
315315
bool isvt = (attrs & GenericParameterAttributes.NotNullableValueTypeConstraint) != 0;
316316
bool isnew = (attrs & GenericParameterAttributes.DefaultConstructorConstraint) != 0;
317+
bool isAllowsRefStruct = (attrs & (GenericParameterAttributes)0x0020) != 0; // Assuming 0x0020 is the flag for 'allows ref struct'
317318
bool comma = false;
318319

319-
if (!isref && !isvt && !isnew && constraints.Count == 0)
320+
if (!isref && !isvt && !isAllowsRefStruct && !isnew && constraints.Count == 0)
320321
continue;
321322
buf.Append (" where ").Append (genArg.Name).Append (" : ");
322323
if (isref)
@@ -350,6 +351,14 @@ private StringBuilder AppendConstraints (StringBuilder buf, IList<GenericParamet
350351
buf.Append (", ");
351352
buf.Append ("new()");
352353
}
354+
355+
// Handle 'allows ref struct' constraint
356+
if (isAllowsRefStruct)
357+
{
358+
if (comma || constraints.Count > 0 || isref || isvt || isnew)
359+
buf.Append(", ");
360+
buf.Append("allows ref struct");
361+
}
353362
}
354363
return buf;
355364
}

0 commit comments

Comments
 (0)