From 28c6140c56c8a16f9e562370b0b7451a3b760858 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 11 Jul 2019 12:58:10 +0200 Subject: Allow std::set<> C# typemaps to work for non-nullable types too Notably make them work for primitive types, such as "int". Doing this requires using "object" instead of the actual C# type of the variable to store the current value in the iterator, as we don't currently have a "csnullabletype" typemap that would expand to "T" for nullable types and "T?" for the other ones. This is a bit ugly, but it shouldn't matter much for the generated code and is already done in std::vector<> typemaps. Also add a simple unit test verifying the basic functionality for such vectors. Closes #1568. --- Lib/csharp/std_set.i | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Lib/csharp') diff --git a/Lib/csharp/std_set.i b/Lib/csharp/std_set.i index 1d946e644..82f010aff 100644 --- a/Lib/csharp/std_set.i +++ b/Lib/csharp/std_set.i @@ -192,7 +192,7 @@ class set { private $csclassname collectionRef; private global::System.Collections.Generic.IList<$typemap(cstype, T)> ItemsCollection; private int currentIndex; - private $typemap(cstype, T) currentObject; + private object currentObject; private int currentSize; public $csclassnameEnumerator($csclassname collection) { @@ -212,7 +212,7 @@ class set { throw new global::System.InvalidOperationException("Enumeration finished."); if (currentObject == null) throw new global::System.InvalidOperationException("Collection modified."); - return currentObject; + return ($typemap(cstype, T))currentObject; } } -- cgit v1.2.1