#4 Reenable mdoc build (#1797360)
Merged 4 years ago by tpokorra. Opened 4 years ago by eclipseo.
rpms/ eclipseo/mono master  into  master

@@ -0,0 +1,41 @@ 

+ From 415b0ca76d1071bc2bb89f8860f4ce831d6a090a Mon Sep 17 00:00:00 2001

+ From: =?UTF-8?q?Robert-Andr=C3=A9=20Mauchin?= <zebob.m@gmail.com>

+ Date: Mon, 3 Feb 2020 23:09:36 +0100

+ Subject: [PATCH] DocumentationEnumerator.cs: Declare iface and ifaceMethod

+  correctly to fix NRE

+ MIME-Version: 1.0

+ Content-Type: text/plain; charset=UTF-8

+ Content-Transfer-Encoding: 8bit

+ 

+ Using TypeReference and MethodReference instead of var to declare them.

+ 

+ Fix #462

+ 

+ Signed-off-by: Robert-André Mauchin <zebob.m@gmail.com>

+ ---

+  mdoc/Mono.Documentation/Updater/DocumentationEnumerator.cs | 4 ++--

+  1 file changed, 2 insertions(+), 2 deletions(-)

+ 

+ diff --git a/mdoc/Mono.Documentation/Updater/DocumentationEnumerator.cs b/mdoc/Mono.Documentation/Updater/DocumentationEnumerator.cs

+ index be22bf0..1917b59 100644

+ --- a/mdoc/Mono.Documentation/Updater/DocumentationEnumerator.cs

+ +++ b/mdoc/Mono.Documentation/Updater/DocumentationEnumerator.cs

+ @@ -341,7 +341,7 @@ namespace Mono.Documentation.Updater

+                              var method = ((PropertyDefinition) mr).GetMethod ?? ((PropertyDefinition) mr).SetMethod;

+                              if (method?.Overrides != null && method.Overrides.Any())

+                              {

+ -                                DocUtils.GetInfoForExplicitlyImplementedMethod(method, out var iface, out var ifaceMethod);

+ +                                DocUtils.GetInfoForExplicitlyImplementedMethod(method, out TypeReference iface, out MethodReference ifaceMethod);

+                                  var newName = DocUtils.GetMemberForProperty(ifaceMethod.Name);

+                                  if (newName == memberName && verifyInterface(mr) && docName.Contains (iface.Name))

+                                      yield return mr;

+ @@ -428,4 +428,4 @@ namespace Mono.Documentation.Updater

+              return count;

+          }

+      }

+ -}

+ \ No newline at end of file

+ +}

+ -- 

+ 2.24.1

+ 

@@ -0,0 +1,89 @@ 

+ From 7d46c195498b06f6fe0562f957f7309140c24a46 Mon Sep 17 00:00:00 2001

+ From: =?UTF-8?q?Robert-Andr=C3=A9=20Mauchin?= <zebob.m@gmail.com>

+ Date: Mon, 3 Feb 2020 20:51:40 +0100

+ Subject: [PATCH] Reenable mdoc.exe build

+ MIME-Version: 1.0

+ Content-Type: text/plain; charset=UTF-8

+ Content-Transfer-Encoding: 8bit

+ 

+ Signed-off-by: Robert-André Mauchin <zebob.m@gmail.com>

+ ---

+  mcs/docs/Makefile       |  4 ----

+  mcs/tools/mdoc/Makefile | 18 ++++++------------

+  2 files changed, 6 insertions(+), 16 deletions(-)

+ 

+ diff --git a/mcs/docs/Makefile b/mcs/docs/Makefile

+ index 92e8f2adbe5..88bddb66268 100644

+ --- a/mcs/docs/Makefile

+ +++ b/mcs/docs/Makefile

+ @@ -38,10 +38,6 @@ DISABLE_MCS_DOCS = yes

+  endif

+  endif

+  

+ -ifdef MCS_MODE

+ -DISABLE_MCS_DOCS = yes

+ -endif

+ -

+  csproj-local test-local run-test-local run-test-ondotnet-local doc-update:

+  

+  clean-local:

+ diff --git a/mcs/tools/mdoc/Makefile b/mcs/tools/mdoc/Makefile

+ index e3c5a321d1a..00820361636 100644

+ --- a/mcs/tools/mdoc/Makefile

+ +++ b/mcs/tools/mdoc/Makefile

+ @@ -44,12 +44,6 @@ $(PROGRAM): $(PROGRAM_DEPS)

+  

+  PROGRAM_COMPILE = $(CSCOMPILE)

+  

+ -ifdef MCS_MODE

+ -NO_INSTALL=1

+ -NO_BUILD=1

+ -NO_TEST=1

+ -endif

+ -

+  include ../../build/executable.make

+  

+  MONO = \

+ @@ -63,6 +57,11 @@ DIFF = diff -rupZ

+  DIFF_QUIET = diff --brief -Z

+  endif

+  

+ +ifdef MCS_MODE

+ +DIFF = echo "WARNING: running in mcs mode, tests are specific to roslyn and would fail. Skipping diff check."

+ +DIFF_QUIET = $(DIFF)

+ +endif

+ +

+  dist-local: dist-default dist-tests

+  

+  dist-tests:

+ @@ -360,7 +359,7 @@ check-mdoc-export-msxdoc-update:

+  

+  check-mdoc-export-msxdoc:

+  	$(MONO) $(PROGRAM) export-msxdoc -o - Test/en.expected.importslashdoc \

+ -		| $(DIFF) - Test/msxdoc-expected.importslashdoc.xml

+ +		| $(DIFF_QUIET) - Test/msxdoc-expected.importslashdoc.xml

+  

+  my_abs_top_srcdir = $(shell cd . && pwd)

+  

+ @@ -390,10 +389,6 @@ run-test-local: check-doc-tools

+  

+  run-test-update : check-doc-tools-update

+  

+ -ifdef MCS_MODE

+ -check-doc-tools:

+ -	@echo "WARNING: running in mcs mode, mdoc doesn't compile with mcs. Skipping."

+ -else

+  check-doc-tools:  \

+  	check-monodocer-since \

+  	check-monodocer-importecmadoc \

+ @@ -412,7 +407,6 @@ check-doc-tools:  \

+  	check-monodocer-dropns-multi-withexisting

+  

+  #check-monodocer-dropns-delete

+ -endif

+  

+  check-doc-tools-update: check-monodocer-since-update \

+  	check-monodocer-importecmadoc-update \

+ -- 

+ 2.24.1

+ 

@@ -0,0 +1,301 @@ 

+ From bf5c5a72978a0f9d32c9934e216bfaaf2d1717be Mon Sep 17 00:00:00 2001

+ From: =?UTF-8?q?Robert-Andr=C3=A9=20Mauchin?= <zebob.m@gmail.com>

+ Date: Mon, 3 Feb 2020 18:38:58 +0100

+ Subject: [PATCH] Replace new Csharp features with old ones

+ MIME-Version: 1.0

+ Content-Type: text/plain; charset=UTF-8

+ Content-Transfer-Encoding: 8bit

+ 

+ Replace new Csharp features like switch statements and

+ "is null" to allow mdoc.exe to build with mcs.

+ 

+ Signed-off-by: Robert-André Mauchin <zebob.m@gmail.com>

+ ---

+  mdoc/Mono.Documentation/Updater/DocUtils.cs   | 91 ++++++++++---------

+  .../CppFormatters/CppFullMemberFormatter.cs   | 26 +++---

+  .../Updater/Formatters/FSharpFormatter.cs     | 16 ++--

+  .../Updater/Formatters/JsFormatter.cs         | 27 +++---

+  .../Updater/Formatters/JsMemberFormatter.cs   |  9 +-

+  5 files changed, 85 insertions(+), 84 deletions(-)

+ 

+ diff --git a/mdoc/Mono.Documentation/Updater/DocUtils.cs b/mdoc/Mono.Documentation/Updater/DocUtils.cs

+ index 331ef90..fe2da59 100644

+ --- a/mdoc/Mono.Documentation/Updater/DocUtils.cs

+ +++ b/mdoc/Mono.Documentation/Updater/DocUtils.cs

+ @@ -287,24 +287,24 @@ namespace Mono.Documentation.Updater

+              return inst != null

+                      ? inst.GenericArguments.Count

+                      : type.GenericParameters.Count;

+ -        }

+ +        }

+  

+          class TypeEquality : IEqualityComparer<TypeReference>

+ -        {

+ -            bool IEqualityComparer<TypeReference>.Equals (TypeReference x, TypeReference y)

+ +        {

+ +            bool IEqualityComparer<TypeReference>.Equals (TypeReference x, TypeReference y)

+ +            {

+ +                if (x == null && y == null) return true;

+ +                if (x == null || y == null) return false;

+ +                return x.FullName == y.FullName;

+ +            }

+ +

+ +            int IEqualityComparer<TypeReference>.GetHashCode (TypeReference obj)

+              {

+ -                if (x is null && y is null) return true;

+ -                if (x is null || y is null) return false;

+ -                return x.FullName == y.FullName;

+ -            }

+ -

+ -            int IEqualityComparer<TypeReference>.GetHashCode (TypeReference obj)

+ -            {

+ -                return obj.GetHashCode ();

+ +                return obj.GetHashCode ();

+              }

+          }

+          static TypeEquality typeEqualityComparer = new TypeEquality ();

+ -

+ +

+          public static IEnumerable<TypeReference> GetAllPublicInterfaces (TypeDefinition type)

+          {

+              return GetAllInterfacesFromType (type)

+ @@ -314,7 +314,7 @@ namespace Mono.Documentation.Updater

+  

+          private static IEnumerable<TypeReference> GetAllInterfacesFromType(TypeDefinition type)

+          {

+ -            if (type is null)

+ +            if (type == null)

+                  yield break;

+  

+              foreach(var i in type.Interfaces)

+ @@ -525,26 +525,29 @@ namespace Mono.Documentation.Updater

+              FillUnifiedMemberTypeNames(unifiedTypeNames, memberReference as IGenericParameterProvider);// Fill the member generic parameters unified names as M0, M1....

+              FillUnifiedTypeNames(unifiedTypeNames, memberReference.DeclaringType, genericInterface);// Fill the type generic parameters unified names as T0, T1....

+  

+ -            switch (memberReference)

+ -            {

+ -                case IMethodSignature methodSignature:

+ -                    buf.Append(GetUnifiedTypeName(methodSignature.ReturnType, unifiedTypeNames)).Append(" ");

+ -                    buf.Append(SimplifyName(memberReference.Name)).Append(" ");

+ -                    AppendParameters(buf, methodSignature.Parameters, unifiedTypeNames);

+ -                    break;

+ -                case PropertyDefinition propertyReference:

+ -                    buf.Append(GetUnifiedTypeName(propertyReference.PropertyType, unifiedTypeNames)).Append(" ");

+ -                    if (propertyReference.GetMethod != null)

+ -                        buf.Append("get").Append(" ");

+ -                    if (propertyReference.SetMethod != null)

+ -                        buf.Append("set").Append(" ");

+ -                    buf.Append(SimplifyName(memberReference.Name)).Append(" ");

+ -                    AppendParameters(buf, propertyReference.Parameters, unifiedTypeNames);

+ -                    break;

+ -                case EventDefinition eventReference:

+ -                    buf.Append(GetUnifiedTypeName(eventReference.EventType, unifiedTypeNames)).Append(" ");

+ -                    buf.Append(SimplifyName(memberReference.Name)).Append(" ");

+ -                    break;

+ +            if (memberReference is IMethodSignature)

+ +            {

+ +                IMethodSignature methodSignature = (IMethodSignature)memberReference;

+ +                buf.Append(GetUnifiedTypeName(methodSignature.ReturnType, unifiedTypeNames)).Append(" ");

+ +                buf.Append(SimplifyName(memberReference.Name)).Append(" ");

+ +                AppendParameters(buf, methodSignature.Parameters, unifiedTypeNames);

+ +            }

+ +            if (memberReference is PropertyDefinition)

+ +            {

+ +                PropertyDefinition propertyReference = (PropertyDefinition)memberReference;

+ +                buf.Append(GetUnifiedTypeName(propertyReference.PropertyType, unifiedTypeNames)).Append(" ");

+ +                if (propertyReference.GetMethod != null)

+ +                    buf.Append("get").Append(" ");

+ +                if (propertyReference.SetMethod != null)

+ +                    buf.Append("set").Append(" ");

+ +                buf.Append(SimplifyName(memberReference.Name)).Append(" ");

+ +                AppendParameters(buf, propertyReference.Parameters, unifiedTypeNames);

+ +            }

+ +            if (memberReference is EventDefinition)

+ +            {

+ +                EventDefinition eventReference = (EventDefinition)memberReference;

+ +                buf.Append(GetUnifiedTypeName(eventReference.EventType, unifiedTypeNames)).Append(" ");

+ +                buf.Append(SimplifyName(memberReference.Name)).Append(" ");

+              }

+              

+              var memberUnifiedTypeNames = new Dictionary<string, string>();

+ @@ -666,14 +669,20 @@ namespace Mono.Documentation.Updater

+          /// </summary>

+          private static Collection<MethodReference> GetOverrides(MemberReference memberReference)

+          {

+ -            switch (memberReference)

+ +            if (memberReference is MethodDefinition)

+ +            {

+ +                MethodDefinition methodDefinition = (MethodDefinition)memberReference;

+ +                return methodDefinition.Overrides;

+ +            }

+ +            if (memberReference is PropertyDefinition)

+ +            {

+ +                PropertyDefinition propertyDefinition = (PropertyDefinition)memberReference;

+ +                return (propertyDefinition.GetMethod ?? propertyDefinition.SetMethod)?.Overrides;

+ +            }

+ +            if (memberReference is EventDefinition)

+              {

+ -                case MethodDefinition methodDefinition:

+ -                    return methodDefinition.Overrides;

+ -                case PropertyDefinition propertyDefinition:

+ -                    return (propertyDefinition.GetMethod ?? propertyDefinition.SetMethod)?.Overrides;

+ -                case EventDefinition evendDefinition:

+ -                    return evendDefinition.AddMethod.Overrides;

+ +                EventDefinition evendDefinition = (EventDefinition)memberReference;

+ +                return evendDefinition.AddMethod.Overrides;

+              }

+  

+              return null;

+ @@ -692,4 +701,4 @@ namespace Mono.Documentation.Updater

+              return method.Name.StartsWith("op_", StringComparison.Ordinal);

+          }

+      }

+ -}

+ \ No newline at end of file

+ +}

+ diff --git a/mdoc/Mono.Documentation/Updater/Formatters/CppFormatters/CppFullMemberFormatter.cs b/mdoc/Mono.Documentation/Updater/Formatters/CppFormatters/CppFullMemberFormatter.cs

+ index 7d68c38..6b9bcf6 100644

+ --- a/mdoc/Mono.Documentation/Updater/Formatters/CppFormatters/CppFullMemberFormatter.cs

+ +++ b/mdoc/Mono.Documentation/Updater/Formatters/CppFormatters/CppFullMemberFormatter.cs

+ @@ -1029,20 +1029,16 @@ namespace Mono.Documentation.Updater.Formatters.CppFormatters

+              if (mref.IsDefinition == false)

+                  mref = mref.Resolve() as MemberReference;

+              

+ -            switch (mref)

+ -            {

+ -                case FieldDefinition field:

+ -                    return IsSupportedField(field);

+ -                case MethodDefinition method:

+ -                    return IsSupportedMethod(method);

+ -                case PropertyDefinition property:

+ -                    return IsSupportedProperty(property);

+ -                case EventDefinition @event:

+ -                    return IsSupportedEvent(@event);

+ -                case AttachedPropertyDefinition _:

+ -                case AttachedEventDefinition _:

+ -                    return false;

+ -            }

+ +            if (mref is FieldDefinition)

+ +                return IsSupportedField((FieldDefinition)mref);

+ +            else if (mref is MethodDefinition)

+ +                return IsSupportedMethod((MethodDefinition)mref);

+ +            else if (mref is PropertyDefinition)

+ +                return IsSupportedProperty((PropertyDefinition)mref);

+ +            else if (mref is EventDefinition)

+ +                return IsSupportedEvent((EventDefinition)mref);

+ +            else if (mref is AttachedPropertyDefinition || mref is AttachedEventDefinition)

+ +                return false;

+  

+              throw new NotSupportedException("Unsupported member type: " + mref?.GetType().FullName);

+          }

+ @@ -1119,4 +1115,4 @@ namespace Mono.Documentation.Updater.Formatters.CppFormatters

+              return true;

+          }

+      }

+ -}

+ \ No newline at end of file

+ +}

+ diff --git a/mdoc/Mono.Documentation/Updater/Formatters/FSharpFormatter.cs b/mdoc/Mono.Documentation/Updater/Formatters/FSharpFormatter.cs

+ index 236d56f..f91bf9a 100644

+ --- a/mdoc/Mono.Documentation/Updater/Formatters/FSharpFormatter.cs

+ +++ b/mdoc/Mono.Documentation/Updater/Formatters/FSharpFormatter.cs

+ @@ -1029,15 +1029,15 @@ namespace Mono.Documentation.Updater

+                  }

+                  return false;

+              }

+ -            switch (mref)

+ +            if (mref is MethodDefinition)

+              {

+ -                case MethodDefinition method:

+ -                    return !(method.HasCustomAttributes && method.CustomAttributes.Any(

+ -                                 ca => ca.GetDeclaringType() ==

+ -                                       "System.Diagnostics.Contracts.ContractInvariantMethodAttribute"

+ -                                       || ca.GetDeclaringType() ==

+ -                                       Consts.CompilerGeneratedAttribute))

+ -                            && AppendVisibility(new StringBuilder(), method) != null;

+ +                MethodDefinition method = (MethodDefinition)mref;

+ +                return !(method.HasCustomAttributes && method.CustomAttributes.Any(

+ +                              ca => ca.GetDeclaringType() ==

+ +                                    "System.Diagnostics.Contracts.ContractInvariantMethodAttribute"

+ +                                    || ca.GetDeclaringType() ==

+ +                                    Consts.CompilerGeneratedAttribute))

+ +                        && AppendVisibility(new StringBuilder(), method) != null;

+              }

+  

+              return true;

+ diff --git a/mdoc/Mono.Documentation/Updater/Formatters/JsFormatter.cs b/mdoc/Mono.Documentation/Updater/Formatters/JsFormatter.cs

+ index f8b2f04..92b8f3c 100644

+ --- a/mdoc/Mono.Documentation/Updater/Formatters/JsFormatter.cs

+ +++ b/mdoc/Mono.Documentation/Updater/Formatters/JsFormatter.cs

+ @@ -68,23 +68,22 @@ namespace mdoc.Mono.Documentation.Updater.Formatters

+  

+          public override bool IsSupported(MemberReference mref)

+          {

+ -            switch (mref)

+ +            if (mref is PropertyDefinition)

+              {

+ -                case PropertyDefinition propertyDefinition:

+ -                    if (!IsPropertySupported(propertyDefinition))

+ -                        return false;

+ -                    break;

+ -                case MethodDefinition methodDefinition:

+ -                    if (!IsMethodSupported(methodDefinition))

+ -                        return false;

+ -                    break;

+ -                case FieldDefinition _:

+ -                    return false;// In WinRT fields can be exposed only by structures.

+ -                case AttachedEventDefinition _:

+ +                PropertyDefinition propertyDefinition = (PropertyDefinition)mref;

+ +                if (!IsPropertySupported(propertyDefinition))

+                      return false;

+ -                case AttachedPropertyDefinition _:

+ +            }

+ +            else if (mref is MethodDefinition)

+ +            {

+ +                MethodDefinition methodDefinition = (MethodDefinition)mref;

+ +                if (!IsMethodSupported(methodDefinition))

+                      return false;

+              }

+ +            else if (mref is FieldDefinition // In WinRT fields can be exposed only by structures.

+ +                || mref is AttachedEventDefinition

+ +                || mref is AttachedPropertyDefinition)

+ +                return false;

+  

+              var member = mref.Resolve();

+              return member != null

+ @@ -169,4 +168,4 @@ namespace mdoc.Mono.Documentation.Updater.Formatters

+              return fullName;

+          }

+      }

+ -}

+ \ No newline at end of file

+ +}

+ diff --git a/mdoc/Mono.Documentation/Updater/Formatters/JsMemberFormatter.cs b/mdoc/Mono.Documentation/Updater/Formatters/JsMemberFormatter.cs

+ index 6bc6995..f6c8af6 100644

+ --- a/mdoc/Mono.Documentation/Updater/Formatters/JsMemberFormatter.cs

+ +++ b/mdoc/Mono.Documentation/Updater/Formatters/JsMemberFormatter.cs

+ @@ -58,12 +58,9 @@ namespace mdoc.Mono.Documentation.Updater.Formatters

+  

+          public override bool IsSupported(MemberReference mref)

+          {

+ -            switch (mref)

+ +            if (mref is PropertyDefinition || mref is EventDefinition)

+              {

+ -                case PropertyDefinition _:

+ -                    return false;

+ -                case EventDefinition _:

+ -                    return false;

+ +                return false;

+              }

+              return base.IsSupported(mref);

+          }

+ @@ -82,4 +79,4 @@ namespace mdoc.Mono.Documentation.Updater.Formatters

+              return base.IsSupported(tref);

+          }

+      }

+ -}

+ \ No newline at end of file

+ +}

+ -- 

+ 2.24.1

+ 

file modified
+21 -7
@@ -23,7 +23,7 @@ 

  %global xamarinrelease 161

  Name:           mono

  Version:        6.6.0

- Release:        4%{?dist}

+ Release:        5%{?dist}

  Summary:        Cross-platform, Open Source, .NET development framework

  

  License:        MIT
@@ -49,6 +49,13 @@ 

  Patch7:         mono-5.18.0-reference-assemblies-fix.patch

  Patch8:         mono-5.18.0-sharpziplib-parent-path-traversal.patch

  Patch9:         mono-6.6.0-python3.patch

+ # Fix NRE bug in api-doc-tools: https://github.com/mono/api-doc-tools/pull/464

+ Patch10:        0001-DocumentationEnumerator.cs-Declare-iface-and-ifaceMe.patch

+ # Replace new Csharp features with old to allow mdoc to build

+ # https://github.com/mono/api-doc-tools/pull/463

+ Patch11:        0001-Replace-new-Csharp-features-with-old-ones.patch

+ # Reenable mdoc build. To be upstreamed after Patch 10 and 11

+ Patch12:        0001-Reenable-mdoc.exe-build.patch

  

  BuildRequires:  bison

  BuildRequires:  python%{python3_pkgversion}
@@ -336,6 +343,11 @@ 

  %patch7 -p1

  %patch8 -p1

  %patch9 -p1

+ pushd external/api-doc-tools

+ %patch10 -p1

+ %patch11 -p1

+ popd

+ %patch12 -p1

  

  # don't build mono-helix-client which requires the helix-binaries to build

  sed -i 's|mono-helix-client||g' mcs/tools/Makefile
@@ -460,12 +472,6 @@ 

  rm -rf %{buildroot}/usr/lib/debug/usr/lib64/libmono-native.so*.debug

  rm -rf %{buildroot}/usr/lib/debug/usr/bin/mono-hang-watchdog-*.debug

  

- # remove mdoc bash script, since mdoc.exe is not built with mcs anymore

- rm -f %{buildroot}/usr/bin/mdoc

- rm -f %{buildroot}/usr/bin/mdass*

- rm -f %{buildroot}/usr/bin/mdval*

- rm -f %{buildroot}/usr/bin/monodoc*

- 

  # create a symbolic link so that Fedora packages targetting Framework 4.5 will still build

  cd %{buildroot}/usr/lib/mono && ln -s 4.7.1-api 4.5-api && cd -

  # as requested in bug 1704861; we have had that link in F29 with Mono 4.8 as well.
@@ -901,8 +907,13 @@ 

  %ifnarch  ppc

  %{_prefix}/lib/monodoc

  %endif

+ %mono_bin mdoc

  %{_bindir}/mod

+ %{_bindir}/mdoc

  %{_bindir}/mdoc-*

+ %{_bindir}/mdass*

+ %{_bindir}/mdval*

+ %{_bindir}/monodoc*

  %{_mandir}/man1/md*

  %{_mandir}/man1/monodoc*

  %{_mandir}/man5/mdoc*
@@ -913,6 +924,9 @@ 

  %files complete

  

  %changelog

+ * Mon Feb 03 2020 Robert-André Mauchin <zebob.m@gmail.com> - 6.6.0-5

+ - Reenable mdoc build (#1797360)

+ 

  * Mon Feb 03 2020 Timotheus Pokorra <timotheus.pokorra@solidcharity.com> - 6.6.0-4

  - drop more bash scripts for mdoc, because mdoc does not build with mcs anymore