summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorJose <pepone@users.noreply.github.com>2021-01-08 23:44:50 +0100
committerGitHub <noreply@github.com>2021-01-08 23:44:50 +0100
commit4419db6dc600b41141c23ede1c6895cbc898e819 (patch)
treefbb5b3769febe09a7caeb9e709480401515ba684 /cpp
parentFix Bogus name for metrics Request Id field - Close #906 (diff)
downloadice-4419db6dc600b41141c23ede1c6895cbc898e819.tar.bz2
ice-4419db6dc600b41141c23ede1c6895cbc898e819.tar.xz
ice-4419db6dc600b41141c23ede1c6895cbc898e819.zip
Fix C# marshal/unmarshal of optional data members (#1232)
See #889
Diffstat (limited to 'cpp')
-rw-r--r--cpp/src/slice2cs/Gen.cpp17
-rw-r--r--cpp/test/Ice/optional/AllTests.cpp4
-rw-r--r--cpp/test/Ice/optional/Test.ice2
-rw-r--r--cpp/test/Ice/optional/TestAMD.ice2
-rw-r--r--cpp/test/Ice/optional/TestAMDI.cpp4
-rw-r--r--cpp/test/Ice/optional/TestI.cpp2
6 files changed, 30 insertions, 1 deletions
diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp
index 8f0d9d888d6..cbe3518cb94 100644
--- a/cpp/src/slice2cs/Gen.cpp
+++ b/cpp/src/slice2cs/Gen.cpp
@@ -3004,8 +3004,17 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
_out << nl << "ostr_.startSlice(\"" << scoped << "\", -1, " << (!base ? "true" : "false") << ");";
for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
+ if(!(*q)->optional())
+ {
+ writeMarshalDataMember(*q, fixId((*q)->name(), DotNet::Exception), ns);
+ }
+ }
+
+ for(DataMemberList::const_iterator q = optionalMembers.begin(); q != optionalMembers.end(); ++q)
+ {
writeMarshalDataMember(*q, fixId((*q)->name(), DotNet::Exception), ns);
}
+
_out << nl << "ostr_.endSlice();";
if(base)
{
@@ -3021,6 +3030,14 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
+ if(!(*q)->optional())
+ {
+ writeUnmarshalDataMember(*q, fixId((*q)->name(), DotNet::Exception), ns);
+ }
+ }
+
+ for(DataMemberList::const_iterator q = optionalMembers.begin(); q != optionalMembers.end(); ++q)
+ {
writeUnmarshalDataMember(*q, fixId((*q)->name(), DotNet::Exception), ns);
}
_out << nl << "istr_.endSlice();";
diff --git a/cpp/test/Ice/optional/AllTests.cpp b/cpp/test/Ice/optional/AllTests.cpp
index 369d2228cc6..7d72ce04b69 100644
--- a/cpp/test/Ice/optional/AllTests.cpp
+++ b/cpp/test/Ice/optional/AllTests.cpp
@@ -2074,6 +2074,8 @@ allTests(Test::TestHelper* helper, bool)
test(!ex.o);
test(!ex.ss);
test(!ex.o2);
+ test(ex.d1 == "d1");
+ test(ex.d2 == "d2");
}
catch(const OptionalException&)
{
@@ -2095,6 +2097,8 @@ allTests(Test::TestHelper* helper, bool)
test((*ex.o)->a == 53);
test(ex.ss == string("test2"));
test((*ex.o2)->a == 53);
+ test(ex.d1 == "d1");
+ test(ex.d2 == "d2");
}
catch(const OptionalException&)
{
diff --git a/cpp/test/Ice/optional/Test.ice b/cpp/test/Ice/optional/Test.ice
index 070f8e6a231..66842e6f598 100644
--- a/cpp/test/Ice/optional/Test.ice
+++ b/cpp/test/Ice/optional/Test.ice
@@ -143,8 +143,10 @@ exception OptionalException
exception DerivedException extends OptionalException
{
+ string d1;
optional(600) string ss = "test";
optional(601) OneOptional o2;
+ string d2;
}
exception RequiredException extends OptionalException
diff --git a/cpp/test/Ice/optional/TestAMD.ice b/cpp/test/Ice/optional/TestAMD.ice
index 26ce2f7a6fb..c0393c4faed 100644
--- a/cpp/test/Ice/optional/TestAMD.ice
+++ b/cpp/test/Ice/optional/TestAMD.ice
@@ -143,8 +143,10 @@ exception OptionalException
exception DerivedException extends OptionalException
{
+ string d1;
optional(600) string ss = "test";
optional(601) OneOptional o2;
+ string d2;
}
exception RequiredException extends OptionalException
diff --git a/cpp/test/Ice/optional/TestAMDI.cpp b/cpp/test/Ice/optional/TestAMDI.cpp
index 8375cf90399..05dc7977301 100644
--- a/cpp/test/Ice/optional/TestAMDI.cpp
+++ b/cpp/test/Ice/optional/TestAMDI.cpp
@@ -50,7 +50,7 @@ InitialI::opDerivedExceptionAsync(Ice::optional<int> a, Ice::optional<::std::str
::std::function<void()>,
::std::function<void(::std::exception_ptr)> ex, const Ice::Current&)
{
- ex(make_exception_ptr(DerivedException(false, a, b, o, b, o)));
+ ex(make_exception_ptr(DerivedException(false, a, b, o, "d1", b, o, "d2")));
}
void
@@ -595,6 +595,8 @@ InitialI::opDerivedException_async(const ::Test::AMD_Initial_opDerivedExceptionP
ex.o = o;
ex.ss = b;
ex.o2 = o;
+ ex.d1 = "d1";
+ ex.d2 = "d2";
cb->ice_exception(ex);
}
diff --git a/cpp/test/Ice/optional/TestI.cpp b/cpp/test/Ice/optional/TestI.cpp
index 8e7a1599849..9ba9317d2d4 100644
--- a/cpp/test/Ice/optional/TestI.cpp
+++ b/cpp/test/Ice/optional/TestI.cpp
@@ -65,6 +65,8 @@ InitialI::opDerivedException(ICE_IN(Optional<Int>) a,
ex.o = o;
ex.ss = b;
ex.o2 = o;
+ ex.d1 = "d1";
+ ex.d2 = "d2";
throw ex;
}