After executing the client callback upon receiving a response, clear the
stored callback to prevent a shared_ptr cycle.
Previously, when the callback function was not cleared, if the callback
happened to store the unary_call_result that it was invoked with (like
wait_callback does), there would be a shared_ptr cycle: the callback
would have a shared_ptr to the unary_call_result, which was keeping its
parent client_unary_call_data alive. This client_unary_call_data had a
copy of the callback function, which had a shared_ptr to the
unary_call_result.
This change resets the callback to empty after is has been executed,
breaking the cycle.
Sometimes min/max are function-style macros, which interferes with use
of things like std::numeric_limits::max() and std::min(). An extra set
of parenthesis guards against this.
When using MSVC, even with _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES and
_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT enabled, sometimes the
non-sprint_s overload is chosen when a stack buffer is used (the
array-to-pointer decay and the array-of-size-N template are competing
with each other, and the char* overload wins instead of the template).
To avoid, switch to using std::to_string to format things in the
string_stream that is used to compute exception messages.
When using MSVC, even with _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES and
_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT enabled, sometimes the
non-sprint_s overload is chosen when a stack buffer is used (the
array-to-pointer decay and the array-of-size-N template are competing
with each other, and the char* overload wins instead of the template).
To avoid, switch to using boost::format to format string in tests.
In the required_fields_tests, some unavoidable compiler warnings are
emitted. These are now suppressed at the file level.
* Since we're explicitly testing some exceptional code paths, some
expansions of StaticParser are expected to produce unreachable code.
* Some of the type names for the boost::mpl::list of schema fields in
these tests are too long for MSVC to handle without truncation.
For Windows builds, pass linker flags to enable NX and as much of ASLR
as we can.
* We cannot move the base address above 4GiB, as the GHC runtime
libraries are not compiled to support this.
* The linker used by GHC doesn't support keeping reloc information
when emitting PE32+ executables. This will end up limiting the
effectiveness of ASLR, but we're doing what we can.
Use RapidJSON's iterative parser to handle deeply nested JSON data
without causing a stack overflow.
Added a unit test with a deeply nested JSON array to test this.
Detect overflow errors related to memory allocation and memory access,
specifically in: bond::OutputMemoryStream, bond::blob, and
bond::detail::SimpleArray.
* `isspace` takes ints, not chars, so promote.
* Instead of dealing with a potentially non-null terminated string when
finding a field by ordinal in Simple JSON, attempt to parse the field
ID and then compare the numeric values.
* Indicate that the `die` function never returns so that the analyzer
can tell that we've checked for things like malloc returning null.
* The printf format string for unsigned ints is u, not d.
* Disable the code analysis warning C6326, "constant constant
comparison". A lot of our template functions trigger this when they do
things like: if (T == traits<U>::some_value) { ... } else { ... }
In order to avoid round-tripping problems due to changing local time
zones, the DateTime example now serializes and deserializes DateTime
instances as UTC.
This does mean, that if you have a Local DateTime that you round-trip,
you will get back a UTC DateTime instead. This is better expected
behavior than random time zone offset changes.
Serialization of bonded fields was interacting with the state in the
CompactBinaryWriter because it triggered first-pass again. This fix
prevents the first-pass writer from being returned in the middle of the
second pass.
The previous code in the serialization example created a new
List<double> for the vector<double> field `items`, implying that the
field was not initialized to an empty List<double>.
Since the `items` field is initialized to an empty list, we now just
append to the existing list.
* Deserialize was used as the name for both a struct and a member
function. This causes some versions of G++ to emit errors, so rename
the helper struct. Fixes https://github.com/Microsoft/bond/issues/538
* The Protocols template argument could not be deduced in one place
where bond::SelectProtocolAndApply was called. It is now explicitly
specified.
Also, lay out the CMake commands following the template that `cmake
--help` documents: `cmake [options] <path-to-source>`
Partial fix for https://github.com/Microsoft/bond/issues/535
In some CMakeLists.txt files, codegen was being run on the same .bond
files multiple times. Depending on build scheduling, this could result
in build failures (if the generation were to happen at the same time) or
spurious rebuilds (due to spurious rewrites of the generated files).
Now, .bond files that are shared across targets within the same
directory are generated once and compiled into a static library that is
then linked into all the consumers.
Since we're compiling the .bond files into a static library, we can take
advantage of the _apply.cpp precompilation as well.
InputStream would always try to call Stream.Seek when it needed to skip
over some bytes in the underlying stream, even if the stream didn't
support Seek.
Now, it checks whether the stream can seek. If not, it makes dummy Read
calls to advance the underlying stream.
Regression test added, and all the implementations of IInputStream that
ship with Bond are tested against these tests.
Existing InputStream tests folded into these IInputStreams tests, and
tested against both seekable and non-seekable streams.
Fixes https://github.com/Microsoft/bond/issues/498
Use Newtonsoft's JSON.NET BigInteger support -- when available -- to
handle the full range of uint64 values in the SimpleJson protocol (.NET
4.5 or greater, .NET Standard 1.6 or greater).
Correctly handle issues when deserializing invalid map data in
SimpleJSON protocol, specifically:
* When keys aren't of primitive type
* When there isn't a matching value for evey key
Also:
* Change bond::basic_string_stream operator << to support various forms
of std::basic_string<char>
* Fix ElementNotFoundException to work with wstrings
Reflection.IsBonded now correctly returns true for custom IBonded
implementations. In addition, corrected reversed logic in test utility
code that was likely related to the incorrect predicate.
* Use new version of packages
* Switch solution to use Visual Studio 2015
* Removed Visual Studio 2012/2013 cruft from csproj file.
* Re-sync test files with the core test.
* Fix up some tests that access internal variables that can be accessed
using public properties.
Support for embedding assembly and file version information has been
added to the MSBuild and .NET Core builds.
When building Bond, if the environment variable BOND_CORE_VERSION (or,
for Bond Comm, BOND_COMM_VERSION) is set to a valid NuGet package
version string, the generated assemblies will have versions details
embedded in them as well.
* For developer builds without any version set, the version 0.0.0.1 will
be used.
* For pre-release builds (versions of the form x.y.z-someTag), the
version x.y.z.0 will be used.
* For release builds (version of the form x.y.z), the version x.y.z.100
will be used.
Fixes https://github.com/Microsoft/bond/issues/325
Closes https://github.com/Microsoft/bond/pull/514