From bf11d5ee7aa92170bad961d67e6e7c7822490cc7 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 15 Mar 2017 23:10:27 +0100 Subject: [PATCH] Don't hardcode C# type corresponding to size_t in vector typemaps The C# type corresponding to size_t may be changed by redefining its "cstype" type typemap, but this broke compilation of the code using std::vector<> as the typemap generating it assumed that size_t was always represented by uint in C#. Make this work in all cases by explicitly looking up cstype of size_t instead. Notice that it may be quite useful, and even necessary, to map size_t to int as when generating C# assembly for use with COM, via .NET interop, as some COM clients, notably VBA-using ones, including all Microsoft Office applications, don't support unsigned types and can't call methods using or returning uint in C# at all. --- Lib/csharp/std_vector.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/csharp/std_vector.i b/Lib/csharp/std_vector.i index 8cddf4c5d..b0485eba6 100644 --- a/Lib/csharp/std_vector.i +++ b/Lib/csharp/std_vector.i @@ -70,7 +70,7 @@ set { if (value < size()) throw new global::System.ArgumentOutOfRangeException("Capacity"); - reserve((uint)value); + reserve(($typemap(cstype, size_t))value); } }