Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update C# bindings to work with SWIG 3.x #5583

Merged
merged 8 commits into from Oct 11, 2018

Conversation

geographika
Copy link
Member

@geographika geographika commented Apr 14, 2018

See #5575

This initial pull request brings the number of errors when building with SWIG 3.0.12 from 1592 Error(s) to8 Error(s).

The remaining errors are:

[00:02:38]   mapscript.cs(25,58): error CS0234: The type or namespace name 'EntryPoint' does not exist in the namespace 'System.Runtime.InteropServices' (are you missing an assembly reference?) [C:\projects\mapserver\build\mapscript\csharp\mapscript.vcxproj]
[00:02:38]   mapscript.cs(25,4): error CS1729: 'DllImportAttribute' does not contain a constructor that takes 2 arguments [C:\projects\mapserver\build\mapscript\csharp\mapscript.vcxproj]
[00:02:38]   mapscriptPINVOKE.cs(191,10): error CS0111: Type 'mapscriptPINVOKE' already defines a member called '.cctor' with the same parameter types [C:\projects\mapserver\build\mapscript\csharp\mapscript.vcxproj]
[00:02:38]   mapscriptPINVOKE.cs(313,3): error CS0246: The type or namespace name 'ThreadStaticAttribute' could not be found (are you missing a using directive or an assembly reference?) [C:\projects\mapserver\build\mapscript\csharp\mapscript.vcxproj]
[00:02:38]   mapscriptPINVOKE.cs(313,3): error CS0246: The type or namespace name 'ThreadStatic' could not be found (are you missing a using directive or an assembly reference?) [C:\projects\mapserver\build\mapscript\csharp\mapscript.vcxproj]
[00:02:38]   mapscriptPINVOKE.cs(298,58): error CS0234: The type or namespace name 'EntryPoint' does not exist in the namespace 'System.Runtime.InteropServices' (are you missing an assembly reference?) [C:\projects\mapserver\build\mapscript\csharp\mapscript.vcxproj]
[00:02:38]   mapscriptPINVOKE.cs(298,4): error CS1729: 'DllImportAttribute' does not contain a constructor that takes 2 arguments [C:\projects\mapserver\build\mapscript\csharp\mapscript.vcxproj]

@sdlime
Copy link
Member

sdlime commented Jun 6, 2018

@geographika - have you had chance to investigate the AppVeyor issues? I assume that's more relevant to this particular issue. --Steve

@geographika
Copy link
Member Author

geographika commented Jun 12, 2018

@sdlime - the issues relate to using the newer version of SWIG rather than Appveyor, so the C# interface files need changes. I've not yet been able to fix the remaining 8 issues but will have another look.

Travis is passing as the C# bindings aren't built on Linux.

@geographika
Copy link
Member Author

Related pull request in GDAL: OSGeo/gdal#824

@geographika geographika changed the title [WIP] Update C# bindings to work with SWIG 3.x Update C# bindings to work with SWIG 3.x Sep 30, 2018
@geographika
Copy link
Member Author

This pull request is now complete. It does the following:

  • Replaces SWIG 1.3.39 used in the GISInternals Buildkit in Appveyor with the latest version of SWIG 3.0.12
  • This is then used to build the .NET MapScript and Python MapScript

SWIG 1.3.39 was released in 2009 and has issues with generating Python3 MapScript (and possibly PHP).

Nearly all changes to the CSharp MapScript interface files are to fully qualify .NET types. This is due to the following:

SWIG 3 fully qualifies the use of all .NET types. Furthermore, SWIG 3 avoids using directives in generated code. This breaks backwards compatibility with typemaps, pragmas,
etc written for use with SWIG 2 that assume the presence of using System; or using System.Runtime.InteropServices

http://www.swig.org/Doc3.0/CSharp.html#CSharp_introduction_swig2_compatibility

Only after completing the majority of these changes did I discover there is a flag to ignore these and maintain backwards compatibility:

If SWIG2_CSHARP is defined, SWIG 3 generates using directives in the intermediate class, module class, and proxy class code similar to those generated by SWIG 2.

By this stage it was as easy to complete the changes, which may make the code more future proof. .NET MapScript still compiles with SWIG 1.3.39 even with the changes in this pull request.

One further issue was the following needed to be commented out:


%pragma(csharp) imclasscode=%{
  static $imclassname() {	  //static $imclassname() {
  }	  //}

Otherwise the following build error occurred:

 mapscriptPINVOKE.cs(191,10): error CS0111: Type 'mapscriptPINVOKE' already defines a member called '.cctor' with the same parameter types [C:\Installation\release-1911-x64-dev\build\mapscript\csharp\mapscript.vcxproj]

@geographika geographika merged commit d725153 into MapServer:master Oct 11, 2018
@geographika geographika deleted the c-sharp-swig branch October 11, 2018 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants