diff --git a/mdoc/Consts.cs b/mdoc/Consts.cs index 4dff4b8a4..ac701cbfe 100644 --- a/mdoc/Consts.cs +++ b/mdoc/Consts.cs @@ -3,7 +3,7 @@ namespace Mono.Documentation { public static class Consts { - public static string MonoVersion = "5.9.2.4"; + public static string MonoVersion = "5.9.3"; public const string DocId = "DocId"; public const string CppCli = "C++ CLI"; public const string CppCx = "C++ CX"; diff --git a/mdoc/Mono.Documentation/MDocUpdater.cs b/mdoc/Mono.Documentation/MDocUpdater.cs index 2323f5372..8e373593e 100644 --- a/mdoc/Mono.Documentation/MDocUpdater.cs +++ b/mdoc/Mono.Documentation/MDocUpdater.cs @@ -2411,66 +2411,98 @@ internal static IEnumerable Sort (IEnumerable list) return l; } - private void UpdateMember (DocsNodeInfo info, FrameworkTypeEntry typeEntry, Dictionary> implementedMembers, IEnumerable eiiMenbers) + private void UpdateMember(DocsNodeInfo info, FrameworkTypeEntry typeEntry, Dictionary> implementedMembers, IEnumerable eiiMenbers) { XmlElement me = (XmlElement)info.Node; MemberReference mi = info.Member; - typeEntry.ProcessMember (mi); + typeEntry.ProcessMember(mi); - var memberName = GetMemberName (mi); - me.SetAttribute ("MemberName", memberName); + var memberName = GetMemberName(mi); + me.SetAttribute("MemberName", memberName); - WriteElementText (me, "MemberType", GetMemberType (mi)); + WriteElementText(me, "MemberType", GetMemberType(mi)); + MakeSetMethodName(typeEntry, me, mi); AddImplementedMembers(typeEntry, mi, implementedMembers, me, eiiMenbers); if (!no_assembly_versions) { if (!IsMultiAssembly) - UpdateAssemblyVersions (me, mi, true); + UpdateAssemblyVersions(me, mi, true); else { - var node = AddAssemblyNameToNode (me, mi.Module, mi.DeclaringType.Resolve()); + var node = AddAssemblyNameToNode(me, mi.Module, mi.DeclaringType.Resolve()); if (typeEntry.IsMemberOnFirstFramework(mi)) { node.SelectNodes("AssemblyVersion").Cast().ToList().ForEach(e => e.ParentNode.RemoveChild(e)); } - UpdateAssemblyVersionForAssemblyInfo (node, me, new[] { GetAssemblyVersion (mi.Module.Assembly) }, add: true); + UpdateAssemblyVersionForAssemblyInfo(node, me, new[] { GetAssemblyVersion(mi.Module.Assembly) }, add: true); } } else { - ClearElement (me, "AssemblyInfo"); + ClearElement(me, "AssemblyInfo"); } - MakeMemberAttributes (me, mi, typeEntry); + MakeMemberAttributes(me, mi, typeEntry); - MakeReturnValue (typeEntry, me, mi, MDocUpdater.HasDroppedNamespace (mi)); + MakeReturnValue(typeEntry, me, mi, MDocUpdater.HasDroppedNamespace(mi)); if (mi is MethodReference) { MethodReference mb = (MethodReference)mi; - if (mb.IsGenericMethod ()) - MakeTypeParameters (typeEntry, me, mb.GenericParameters, mi, MDocUpdater.HasDroppedNamespace (mi)); + if (mb.IsGenericMethod()) + MakeTypeParameters(typeEntry, me, mb.GenericParameters, mi, MDocUpdater.HasDroppedNamespace(mi)); } bool fxAlternateTriggered = false; - MakeParameters (me, mi, typeEntry, ref fxAlternateTriggered, MDocUpdater.HasDroppedNamespace (mi)); + MakeParameters(me, mi, typeEntry, ref fxAlternateTriggered, MDocUpdater.HasDroppedNamespace(mi)); string fieldValue; - if (mi is FieldDefinition && GetFieldConstValue ((FieldDefinition)mi, out fieldValue)) - WriteElementText (me, "MemberValue", fieldValue); + if (mi is FieldDefinition && GetFieldConstValue((FieldDefinition)mi, out fieldValue)) + WriteElementText(me, "MemberValue", fieldValue); + + info.Node = WriteElement(me, "Docs"); + MakeDocNode(info, typeEntry.Framework.Importers, typeEntry); - info.Node = WriteElement (me, "Docs"); - MakeDocNode (info, typeEntry.Framework.Importers, typeEntry); - foreach (MemberFormatter f in FormatterManager.MemberFormatters) { - UpdateSignature (f, mi, me, typeEntry, implementedMembers); + UpdateSignature(f, mi, me, typeEntry, implementedMembers); } - OrderMemberNodes (me, me.ChildNodes); - UpdateExtensionMethods (me, info); + OrderMemberNodes(me, me.ChildNodes); + UpdateExtensionMethods(me, info); + } + + public static void MakeSetMethodName(FrameworkTypeEntry typeEntry, XmlElement me, MemberReference mi) + { + if (mi is PropertyDefinition) + { + var setMethodName = ((PropertyDefinition)mi).SetMethod?.Name.Split('.').LastOrDefault(); + if (setMethodName != null && !setMethodName.StartsWith("set")) + { + DocUtils.AddElementWithFx( + typeEntry, + parent: me, + isFirst: typeEntry.IsMemberOnFirstFramework(mi), + isLast: typeEntry.IsMemberOnLastFramework(mi), + allfxstring: new Lazy(() => typeEntry.AllFrameworkStringForMember(mi)), + clear: parent => + { + ClearElement(parent, "SetMethodName"); + }, + findExisting: parent => + { + return parent.SelectSingleNode($"Member/SetMethodName") as XmlElement; + }, + addItem: parent => + { + var newNode = WriteElementText(parent, "SetMethodName", setMethodName, forceNewElement: false); + + return newNode; + }); + } + } } private static void UpdateSignature(MemberFormatter formatter, TypeDefinition type, XmlElement xmlElement, FrameworkTypeEntry typeEntry) @@ -2913,6 +2945,7 @@ static void AddXmlNode (XmlElement[] relevant, Func valueMatch "Metadata", "MemberSignature", "MemberType", + "SetMethodName", "Implements", "AssemblyInfo", "Attributes", diff --git a/mdoc/Resources/monodoc-ecma.xsd b/mdoc/Resources/monodoc-ecma.xsd index c5bc4affc..e133784bc 100644 --- a/mdoc/Resources/monodoc-ecma.xsd +++ b/mdoc/Resources/monodoc-ecma.xsd @@ -89,6 +89,16 @@ add masterdoc support? + + + + + + + + + + @@ -531,6 +541,7 @@ add masterdoc support? + diff --git a/mdoc/mdoc.Test/MDocUpdaterTests.cs b/mdoc/mdoc.Test/MDocUpdaterTests.cs index a0709cd74..313dc468f 100644 --- a/mdoc/mdoc.Test/MDocUpdaterTests.cs +++ b/mdoc/mdoc.Test/MDocUpdaterTests.cs @@ -125,6 +125,32 @@ public void RemoveInvalidAssembliesInfo() // delitem.ParentNode.RemoveChild(child); } + [Test] + public void MakeSetMethodName_Test() + { + List entries = new List(); + FrameworkEntry frameworkEntry = new FrameworkEntry(entries, entries); + frameworkEntry.Name = "winui-2.8"; + FrameworkTypeEntry typeEntry = new FrameworkTypeEntry(frameworkEntry); + + var doc = new XmlDocument(); + doc.LoadXml(XmlConsts.SetMethodName); + + var member = GetType(typeof(mdoc.Test2.EiiImplementClass)).Properties.FirstOrDefault(t => t.FullName == "System.String mdoc.Test2.EiiImplementClass::init()"); + MDocUpdater.MakeSetMethodName(typeEntry, doc.DocumentElement, member); + var node = doc.SelectSingleNode($"Member/SetMethodName"); + Assert.IsNull(node); + + member = GetType(typeof(mdoc.Test2.EiiImplementClass)).Properties.FirstOrDefault(t => t.FullName == "System.String mdoc.Test2.EiiImplementClass::source()"); + member.SetMethod.Name = "put_Source"; + MDocUpdater.MakeSetMethodName(typeEntry, doc.DocumentElement, member); + node = doc.SelectSingleNode($"Member/SetMethodName"); + Assert.IsNotNull(node); + Assert.AreEqual(node.InnerText, member.SetMethod.Name); + Assert.AreEqual(node.Attributes["FrameworkAlternate"].Value, frameworkEntry.Name); + + } + [Test] public void UpdateToRight_MethodInterface_Test() { diff --git a/mdoc/mdoc.Test/SampleClasses/EiiImplementclass.cs b/mdoc/mdoc.Test/SampleClasses/EiiImplementclass.cs index a6e7a8d3f..7eac7c542 100644 --- a/mdoc/mdoc.Test/SampleClasses/EiiImplementclass.cs +++ b/mdoc/mdoc.Test/SampleClasses/EiiImplementclass.cs @@ -15,7 +15,7 @@ public class EiiImplementClass : Interface_A,Interface_B public int no { get; } int Interface_B.no { get; } - + public string GetNo() => "1"; string Interface_A.GetNo() => "7"; @@ -31,5 +31,9 @@ event EventHandler Interface_B.ItemChanged remove { } } + public string source { get; set;} + + public string init { get; init;} + } } diff --git a/mdoc/mdoc.Test/XmlConsts.cs b/mdoc/mdoc.Test/XmlConsts.cs index 3a013aa53..311581ed3 100644 --- a/mdoc/mdoc.Test/XmlConsts.cs +++ b/mdoc/mdoc.Test/XmlConsts.cs @@ -706,5 +706,16 @@ class XmlConsts "; #endregion + + #region + public const string SetMethodName = @" + + + + + + Property + "; + #endregion } } diff --git a/mdoc/mdoc.Test/mdoc.Test.FSharp/Collections.fs b/mdoc/mdoc.Test/mdoc.Test.FSharp/Collections.fs index f2eb12301..3727f526d 100644 --- a/mdoc/mdoc.Test/mdoc.Test.FSharp/Collections.fs +++ b/mdoc/mdoc.Test/mdoc.Test.FSharp/Collections.fs @@ -9,7 +9,7 @@ let f (x:Map) = 0 let f2 (x:seq) = 0 type MDocInterface<'key> = interface -end + end type MDocTestMap<'Key, 'Value> = class interface MDocInterface> diff --git a/mdoc/mdoc.nuspec b/mdoc/mdoc.nuspec index 87cb78a02..ad977e2fa 100644 --- a/mdoc/mdoc.nuspec +++ b/mdoc/mdoc.nuspec @@ -2,7 +2,7 @@ mdoc - 5.9.2.4 + 5.9.3 mdoc Microsoft Microsoft