Skip to content

Commit 24ba59f

Browse files
authored
Merge pull request #544 from mono/develop
🚢 5.8.2
2 parents 5f85066 + 35c9e2b commit 24ba59f

File tree

77 files changed

+2004
-232
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+2004
-232
lines changed

external/Test/mdoc.Test.FSharp.dll

257 KB
Binary file not shown.
21.5 KB
Binary file not shown.

external/Test/readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ The files in this directory are used as test inputs for explicit assembly testin
44
|---|---|
55
|CSharpExample.dll|TBD|
66
|mdoc.Test.Cplusplus.dll|../../mdoc/mdoc.Test.Cplusplus|
7+
|mdoc.Test.NullableReferenceTypes.dll|../../mdoc/mdoc.Test/NullableReferenceTypesTests|
78
|UWPTestComponentCSharp.winmd|../../mdoc/mdoc.Test/UWPTestComponentCSharp|
89
|UwpTestWinRtComponentCpp.dll|../../mdoc/mdoc.Test/UwpTestWinRtComponentCpp|
910
|UwpTestWinRtComponentCpp.winmd|../../mdoc/mdoc.Test/UwpTestWinRtComponentCpp|

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+
public static string MonoVersion = "5.8.2";
77
public const string DocId = "DocId";
88
public const string CppCli = "C++ CLI";
99
public const string CppCx = "C++ CX";

mdoc/Mono.Documentation/MDocUpdater.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3801,7 +3801,7 @@ public static void MakeAttributes(
38013801
XmlElement e = (XmlElement)root.SelectSingleNode("Attributes");
38023802
if (e == null)
38033803
e = root.OwnerDocument.CreateElement("Attributes");
3804-
if (isFirstFramework)
3804+
if (isFirstFramework && typeEntry?.TimesProcessed == 1)
38053805
{
38063806
e.RemoveAll();
38073807
}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
using mdoc.Mono.Documentation.Updater;
2+
using Mono.Cecil;
3+
using Mono.Documentation.Util;
4+
using System;
5+
using System.Collections.ObjectModel;
6+
7+
namespace Mono.Documentation.Updater
8+
{
9+
public class AttributeParserContext : IAttributeParserContext
10+
{
11+
private int nullableAttributeIndex;
12+
private int dynamicAttributeIndex;
13+
private ICustomAttributeProvider provider;
14+
private ReadOnlyCollection<bool?> nullableAttributeFlags;
15+
private ReadOnlyCollection<bool> dynamicAttributeFlags;
16+
17+
private AttributeParserContext(ICustomAttributeProvider provider)
18+
{
19+
this.provider = provider;
20+
21+
ReadDynamicAttribute();
22+
ReadNullableAttribute();
23+
}
24+
25+
private bool ExistsNullableAttribute
26+
{
27+
get
28+
{
29+
return nullableAttributeFlags.Count > 0;
30+
}
31+
}
32+
33+
private bool HasSameNullableValue
34+
{
35+
get
36+
{
37+
return nullableAttributeFlags.Count == 1;
38+
}
39+
}
40+
41+
public static IAttributeParserContext Create(ICustomAttributeProvider provider)
42+
{
43+
return new AttributeParserContext(provider);
44+
}
45+
46+
public void NextDynamicFlag()
47+
{
48+
dynamicAttributeIndex++;
49+
}
50+
51+
public bool IsDynamic()
52+
{
53+
return dynamicAttributeFlags != null && (dynamicAttributeFlags.Count == 0 || dynamicAttributeFlags[dynamicAttributeIndex]);
54+
}
55+
56+
public bool IsNullable()
57+
{
58+
if (ExistsNullableAttribute)
59+
{
60+
if (HasSameNullableValue)
61+
{
62+
return nullableAttributeFlags[0].IsTrue();
63+
}
64+
65+
if (nullableAttributeIndex < nullableAttributeFlags.Count)
66+
{
67+
return nullableAttributeFlags[nullableAttributeIndex++].IsTrue();
68+
}
69+
70+
throw new IndexOutOfRangeException("You are out of range in the nullable attribute values, please call the method for each nullable checking only once.");
71+
}
72+
73+
return false;
74+
}
75+
76+
private void ReadDynamicAttribute()
77+
{
78+
DynamicTypeProvider dynamicTypeProvider = new DynamicTypeProvider(provider);
79+
var dynamicTypeFlags = dynamicTypeProvider.GetDynamicTypeFlags();
80+
if (dynamicTypeFlags != null)
81+
{
82+
dynamicAttributeFlags = new ReadOnlyCollection<bool>(dynamicTypeFlags);
83+
}
84+
}
85+
86+
private void ReadNullableAttribute()
87+
{
88+
NullableReferenceTypeProvider nullableReferenceTypeProvider = new NullableReferenceTypeProvider(provider);
89+
nullableAttributeFlags = new ReadOnlyCollection<bool?>(nullableReferenceTypeProvider.GetNullableReferenceTypeFlags());
90+
}
91+
}
92+
}

mdoc/Mono.Documentation/Updater/DocUtils.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -928,5 +928,22 @@ public static bool IsEiiIgnoredMethod(MethodReference method, MethodReference im
928928

929929
return false;
930930
}
931+
932+
public static TypeDefinition FixUnnamedParameters(TypeDefinition type)
933+
{
934+
foreach (var method in type.Methods)
935+
{
936+
var unnamedParameterIndex = 1;
937+
foreach (var item in method.Parameters)
938+
{
939+
if (string.IsNullOrEmpty(item.Name))
940+
{
941+
item.Name = $"unnamedParam{unnamedParameterIndex++}";
942+
}
943+
}
944+
}
945+
946+
return type;
947+
}
931948
}
932949
}

mdoc/Mono.Documentation/Updater/DocumentationEnumerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ protected IEnumerable<TypeDefinition> GetDocumentationTypes (AssemblyDefinition
2727
continue;
2828
if (seen != null && seen.Contains (type.FullName))
2929
continue;
30-
yield return type;
30+
yield return DocUtils.FixUnnamedParameters (type);
3131
}
3232
}
3333

mdoc/Mono.Documentation/Updater/DynamicParserContext.cs

Lines changed: 0 additions & 33 deletions
This file was deleted.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using Mono.Cecil;
2+
using Mono.Documentation.Updater;
3+
using Mono.Documentation.Util;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
7+
namespace mdoc.Mono.Documentation.Updater
8+
{
9+
public class DynamicTypeProvider
10+
{
11+
private const string DynamicAttributeFulleName = "System.Runtime.CompilerServices.DynamicAttribute";
12+
13+
private ICustomAttributeProvider provider;
14+
15+
public DynamicTypeProvider(ICustomAttributeProvider provider)
16+
{
17+
this.provider = provider;
18+
}
19+
20+
public IList<bool> GetDynamicTypeFlags()
21+
{
22+
CustomAttribute dynamicAttribute = FindDynamicAttribute();
23+
if (dynamicAttribute != null)
24+
{
25+
CustomAttributeArgument[] attributeValues = new CustomAttributeArgument[0];
26+
if (dynamicAttribute.ConstructorArguments.Count > 0)
27+
{
28+
attributeValues = (CustomAttributeArgument[])dynamicAttribute.ConstructorArguments[0].Value;
29+
}
30+
31+
return attributeValues.Select(t => (bool)t.Value).ToList();
32+
}
33+
34+
return null;
35+
}
36+
37+
private CustomAttribute FindDynamicAttribute()
38+
{
39+
if (provider.HasCustomAttributes)
40+
{
41+
return provider.CustomAttributes.SafeCast<CustomAttribute>().SingleOrDefault(ca => ca.GetDeclaringType() == DynamicAttributeFulleName);
42+
}
43+
44+
return null;
45+
}
46+
}
47+
}

0 commit comments

Comments
 (0)