[mapguide-commits] r8373 - in branches/2.6/MgDev: BuildTools/WebTools/IMake Oem/SWIGEx/Source/Modules

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Wed Oct 1 08:25:05 PDT 2014


Author: jng
Date: 2014-10-01 08:25:05 -0700 (Wed, 01 Oct 2014)
New Revision: 8373

Modified:
   branches/2.6/MgDev/BuildTools/WebTools/IMake/IMake.cpp
   branches/2.6/MgDev/Oem/SWIGEx/Source/Modules/csharp.cxx
Log:
#2453: Fix API documentation not being transferred to .net exceptions. This updates the following tools:

 IMake
   - Ensure the "partial" modifier is applied to all .net proxy classes
 
 SWIGEx
   - Write out attributes to a separate partial class source file instead of the main class source file. This prevents incorrect ordering of attributes and documentation for classes as they are now specified on the same class, but in separate physical files.
   - Write the Serializable attribute using its fully qualified name to avoid having to write namespace import statements on the partial class source file.

Modified: branches/2.6/MgDev/BuildTools/WebTools/IMake/IMake.cpp
===================================================================
--- branches/2.6/MgDev/BuildTools/WebTools/IMake/IMake.cpp	2014-10-01 15:13:01 UTC (rev 8372)
+++ branches/2.6/MgDev/BuildTools/WebTools/IMake/IMake.cpp	2014-10-01 15:25:05 UTC (rev 8373)
@@ -12,7 +12,7 @@
     java
 };
 
-static char version[] = "1.2.2";
+static char version[] = "1.2.3";
 static char EXTERNAL_API_DOCUMENTATION[] = "(NOTE: This API is not officially supported and may be subject to removal in a future release without warning. Use with caution.)";
 
 static string module;
@@ -1113,7 +1113,7 @@
         fprintf(docOutFile, "\n%%typemap(javaclassmodifiers) %s %%{%s public%%}\n", className.c_str(), convertedDoc.c_str());
     } else if(language == csharp) {
         convertedDoc = doxygenToCsharpDoc(commentStr, true); //EXTERNAL_API only applies to class members, so treat this fragment as PUBLISHED_API
-        fprintf(docOutFile, "\n%%typemap(csclassmodifiers) %s %%{%s public%%}\n", className.c_str(), convertedDoc.c_str());
+        fprintf(docOutFile, "\n%%typemap(csclassmodifiers) %s %%{%s public partial%%}\n", className.c_str(), convertedDoc.c_str());
     }
 }
 
@@ -1226,6 +1226,16 @@
             outputClassDoc(className, commentStr);
             commentStr.clear();
             classesWithDocs.insert(className);
+        } else if (language == csharp) {
+            //We need to ensure the partial modifier is applied. However since we (ab)use csclassmodifiers to do this, if there's no class documentation
+            //then it won't apply the required partial modifier. So we need to insert some kind of comment string here, so take this opportunity to 
+            //note that this class has no documentation.
+            std::string cmnt = "///\n";
+            cmnt += "/// \\brief\n";
+            cmnt += "/// TODO: This class has no class documentation (message inserted by IMake.exe)\n";
+            cmnt += "///";
+            outputClassDoc(className, cmnt);
+            classesWithDocs.insert(className);
         }
     }
     for(int i = begin; i <= end; i++)

Modified: branches/2.6/MgDev/Oem/SWIGEx/Source/Modules/csharp.cxx
===================================================================
--- branches/2.6/MgDev/Oem/SWIGEx/Source/Modules/csharp.cxx	2014-10-01 15:13:01 UTC (rev 8372)
+++ branches/2.6/MgDev/Oem/SWIGEx/Source/Modules/csharp.cxx	2014-10-01 15:25:05 UTC (rev 8373)
@@ -1416,6 +1416,10 @@
             "\n",
             NIL);
 
+        // Offload attributes to partial classes so that it doesn't interfere with csclassmodifiers
+        // that could have arbitrary content (ie. Documentation) 
+        String *proxy_partial_class_def = NewString("");
+
         //Emit namespace if one is specified
         if(namespaceName != NULL)
         {
@@ -1425,26 +1429,50 @@
                 "\n",
                 "{\n",
                 NIL);
+
+            //Partial class needs to know about this namespace too
+            Printv(proxy_partial_class_def,
+                "namespace ",
+                namespaceName,
+                "\n",
+                "{\n",
+                NIL);
         }
 
-        //Add attribute
+        //Add attribute (if any) to partial class definition
         if(*Char(attributeTags))
         {
-            Printv(proxy_class_def, 
+            Printv(proxy_partial_class_def, 
                 "[",
                 attributeTags,
                 "]\n",
                 NIL);
         }
 
-        //Add serializable attribute
+        //Add serializable attribute (if any) to partial class definition
         if(isDeserializable)
         {
-            Printv(proxy_class_def,
-                "[Serializable]\n",
+            Printv(proxy_partial_class_def,
+                "[global::System.Serializable]\n",
                 NIL);
         }
 
+        //Write remainder of partial class body
+        Printv(proxy_partial_class_def, "    partial class ", c_classname, " { }\n", NIL);
+        Printv(proxy_partial_class_def, "}\n", NIL);
+
+        //Write the class body to file
+        String *pfilen = NewStringf("%s%s.partial.cs", SWIG_output_directory(), c_classname);
+        File* f_partial = NewFile(pfilen,"w");
+        if(!f_partial) {
+            Printf(stderr, "Unable to create partial proxy class file: %s\n", pfilen);
+            SWIG_exit(EXIT_FAILURE);
+        }
+        Delete(pfilen); pfilen = NULL;
+        Printv(f_partial, proxy_partial_class_def, NIL);
+        Close(f_partial);
+        Delete(proxy_partial_class_def); proxy_partial_class_def = NULL;
+
         Printv(proxy_class_def,
             typemapLookup("csclassmodifiers", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
             " class $csclassname",       // Class name and bases



More information about the mapguide-commits mailing list