From a4febe779909fe257f14fa54967db1629286a2c8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 23 May 2010 22:24:36 +0000 Subject: [PATCH] Fix #2957375 (C#) - SWIGStringHelper and SWIGExceptionHelper not always being initialized before use in .NET 4 as the intermediary class was not marked as beforefieldinit. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12044 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 16 ++++++++++++++++ Lib/csharp/csharphead.swg | 8 ++++++++ 2 files changed, 24 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 53ac43291..9839e13bc 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,22 @@ Version 2.0.0 (in progress) ============================ +2010-05-23: wsfulton + [C#] Fix #2957375 - SWIGStringHelper and SWIGExceptionHelper not always being + initialized before use in .NET 4 as the classes were not marked beforefieldinit. + A static constructor has been added to the intermediary class like this: + + %pragma(csharp) imclasscode=%{ + static $imclassname() { + } + %} + + If you had added your own custom static constructor to the intermediary class in + the same way as above, you will have to modify your approach to use static variable + initialization or define SWIG_CSHARP_NO_IMCLASS_STATIC_CONSTRUCTOR - See csharphead.swg. + + *** POTENTIAL INCOMPATIBILITY *** + 2010-05-23: wsfulton Fix #2408232. Improve shared_ptr and intrusive_ptr wrappers for classes in an inheritance hierarchy. No special treatment is needed for derived classes. diff --git a/Lib/csharp/csharphead.swg b/Lib/csharp/csharphead.swg index 9b144d6a5..a1c56a4b3 100644 --- a/Lib/csharp/csharphead.swg +++ b/Lib/csharp/csharphead.swg @@ -319,6 +319,14 @@ SWIGEXPORT void SWIGSTDCALL SWIGRegisterStringCallback_$module(SWIG_CSharpString %} #endif // SWIG_CSHARP_NO_STRING_HELPER +#if !defined(SWIG_CSHARP_NO_IMCLASS_STATIC_CONSTRUCTOR) +// Ensure the class is not marked beforefieldinit +%pragma(csharp) imclasscode=%{ + static $imclassname() { + } +%} +#endif + %insert(runtime) %{ /* Contract support */