summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp')
-rw-r--r--cpp/src/slice2cs/CsUtil.cpp32
1 files changed, 30 insertions, 2 deletions
diff --git a/cpp/src/slice2cs/CsUtil.cpp b/cpp/src/slice2cs/CsUtil.cpp
index a5c89f5742f..7be2eb5a716 100644
--- a/cpp/src/slice2cs/CsUtil.cpp
+++ b/cpp/src/slice2cs/CsUtil.cpp
@@ -842,7 +842,21 @@ Slice::CsGenerator::writeOptionalMarshalUnmarshalCode(Output &out,
}
else
{
- out << nl << param << " = " << stream << ".readByte(" << tag << ");";
+ //
+ // BUGFIX: with .NET Core reading the byte optional directly in the
+ // result struct can fails unexpectly with optimized builds.
+ //
+ if(param.find(".") != string::npos)
+ {
+ out << sb;
+ out << nl << "var tmp = " << stream << ".readByte(" << tag << ");";
+ out << nl << param << " = tmp;";
+ out << eb;
+ }
+ else
+ {
+ out << nl << param << " = " << stream << ".readByte(" << tag << ");";
+ }
}
break;
}
@@ -854,7 +868,21 @@ Slice::CsGenerator::writeOptionalMarshalUnmarshalCode(Output &out,
}
else
{
- out << nl << param << " = " << stream << ".readBool(" << tag << ");";
+ //
+ // BUGFIX: with .NET Core reading the bool optional directly in the
+ // result struct fails unexpectly with optimized builds.
+ //
+ if(param.find(".") != string::npos)
+ {
+ out << sb;
+ out << nl << "var tmp = " << stream << ".readBool(" << tag << ");";
+ out << nl << param << " = tmp;";
+ out << eb;
+ }
+ else
+ {
+ out << nl << param << " = " << stream << ".readBool(" << tag << ");";
+ }
}
break;
}