`bond::maybe` now has better support for rvalue-references and allocator
propagation.
This implementation also avoids default initializing an instance of `T`
when creating an maybe that holds nothing
`bond::maybe` is now implemented in terms of `boost::optional`. We should be
able to `std::optional` with minimal effort when Bond requires a minimum
of C++17.
Additional changes:
* Removed a dangerous implicit conversion operator from `bond::maybe<T>`
to `const T&`. To access a `bond::maybe<T>` value, use
* Added `noexcept` variants of `bond::maybe<T>::value`.
* Added `bond::maybe<T>::emplace` to construct a maybe's value in place.
* Added various rvalue-reference and allocator-aware constructors and
assignment operators.
* Added `bond::maybe<T>::operator==(const T&)` to compare directly to
instances of `T`.
* Improved test coverage of `set_value()`: it was only effectively
constructing a new `T` the first time.
* Added tests for moved-from `bond::maybe` instances.
* Added tests for allocator propagation.
This change has not yet been made, as it breaks the current AppVeyor
build.
Issue https://github.com/Microsoft/bond/issues/845 has been opened to
remind us to bump the minimum version later.
[skip ci]
Drops support for versions of Boost older than two years. Boost 1.61+ or
newer is now required. (Bond will likely continue to work with older
versions of Boost, but we'll no longer actively test against them.)
Using cron jobs, add coverage for all supported versions of Boost with
both Clang and G++.
This is the Travis-side fix for:
* https://github.com/Microsoft/bond/issues/666
* https://github.com/Microsoft/bond/issues/771
On macOS (and likely Linux), when gbc was not found under
BOND_COMPILER_DIRECTORY--typically when it was found on $PATH--the
output directory for the generated C# files ended up having inconsistent
directory separator translation applied to it.
gbc was invoked with an output directory like
`--output-dir="obj/Debug/net45/\."`, which placed the generated files in
a directory *under* `net45` named `\.`. However, when csc was invoked,
it was given generated file paths like `obj/Debug/net45//foo_types.cs`,
which did not exist, causing compilation to fail.
This inconsistency occurred because when the command line for gbc from
$PATH was constructed, none of the elements look like a path, so MSBuild
didn't translate the trailing `\.` added to the output-dir argument:
<_BondCommand>"$(_BondExe)" $(BondCodegenMode) $(_BondImportDirs) --jobs=-2 --namespace=bond=Bond --output-dir="$(BondOutputDirectory)\."</_BondCommand>
The `\.` was added to guard against $(BondOutputDirectory) ending with a
slash and then having CMD treat a string like
`--output-dir="obj\Debug\net45\"` as having an escaped double-quote in
it.
When gbc came from BOND_COMPILER_PATH, it looked like a path, so the
added `\.` got translated to `/.`
As a fix, the codegen targets now use $(_BondOutputDirectoryNormalized),
which always has a trailing slash and always uses forward slashes.
Windows, macOS, and Linux can all handle forward slashes for paths.
Previously, we were just [public signing][1] the .NET Core assemblies.
We intended to fully strong-name sign them, so this commit removes the
"publicSign": true entry from the project files.
[1]: ca61bad288
* Enabled automatic codegen when implicit inclusion is turned on via the
MSBuild property EnableDefaultCompileItems
* Added Visual Studio CPS UI integration so that .bond files appear in
the Visual Studio 2017+ UI.
Fixes https://github.com/Microsoft/bond/issues/636
The change fixes the `bond::value`'s move constructor to actually move
the underlying reader, unless it is a reference type. Also, fixes the
`noexcept` condition for `bond::bonded`'s move constructor that was
missed in 5131a950.
When moving a bonded<> backed by a reference to a reader, the bonded<>
move ctor wasn't building with Clang and newer versions of MSVC. This
fixes that error by not calling std::move on the reference.
The blob and nullable types are not customizable. Also is_blob and
is_nullable traits are not part of container concept.
Closes https://github.com/Microsoft/bond/pull/805
Fixes a race condition when `bond::ext::gRPC::io_manager::shutdown` and
`bond::ext::gRPC::io_manager::wait` are called concurrently. The functions
are not mutually exclusive and the latter destroys the
`grpc::CompletionQueue` which is not necessary.
Fixes https://github.com/Microsoft/bond/issues/744
With this change deserialization will now fail by throwing `bond::CoreException` when `BT_STOP` is encountered while deserializing a base struct.
Fixes https://github.com/Microsoft/bond/issues/742
* This fixes broken C# codegen when a service method has attributes.
* Add both C++ and C# unit test to make sure that service and method
attributes are properly generated and accessible.
Fixes https://github.com/Microsoft/bond/issues/617
When a service contains events or parameter-less methods, the generated
code uses `bond::Void` as the request/result type. To serialize
`bond::Void`, bond_reflection.h needs to be included.
The generated service code now includes bond_reflection.h if any service
contains an event or a parameter-less method.
Fixes https://github.com/Microsoft/bond/issues/735
Currently C++ enum's name-to-value and value-to-name maps use a `std::map`
and are always constructed, even when not used. This change:
- allows the user to provide custom map type (e.g.
`boost::container::flat_map`)
- lazily constructs the map on first access
- changes the default generated conversion functions to use
`std::unordered_map`
C++ codegen now can use std::scoped_allocator_adaptor for strings and
containers when custom allocator is used and the --scoped-alloc flag is
passed to gbc.
Add the ability to generate copy and move constructors with an allocator
argument. This is behind the gbc flag --alloc-ctors, as the generated copy
and move constructors pass the allocator to the constructors for collection
fields, among others. Not all STL implementations in use by users of Bond
provide these C++11 constructors yet for all collection types. In order to
avoid breaking existing code, these constructors are opt-in.
As of C++11, all the standard containers have a constructor that takes just
an allocator. The expectation is that custom containers will also provide
one.
The caller of grpc_byte_buffer_reader_next is responsible for calling
grpc_slice_unref on the slice. However, SerializationTraits::Deserialize
was only calling grpc_slice_unref on the last slice. Now, it is called
on each slice.
Also fixes a potential bug that would call grpc_slice_unref on an
uninitialized slice.
The caller of grpc_byte_buffer_reader_next is responsible for calling
grpc_slice_unref on the slice. However, SerializationTraits::Deserialize
was only calling grpc_slice_unref on the last slice. Now, it is called
on each slice.
Also fixes a potential bug that would call grpc_slice_unref on an
uninitialized slice.
Since Bond now requires a C++11 compiler, many of the feature checks for
C++11 can be removed. Bond still supports MSVC 2013, which has some
limitations in its C++11 support, so checks for it to enable work-arounds
are still present.
* The MSBuild codegen targets now detect --structs=false and skip
automatic compilation of the non-existent `_types.cs` files.
* Added a gRPC example that show how to use a shared type assembly
between a client and service.
* Two cases need to be handeled: $BondOptions contains --grpc for
no-overridden BondCodegen items, the %BondCodegen.Options contains
--grpc. Also --grpc=false needs to be handled in both cases.
* Updated the examples ad tests to no longer include the
generated *_grpc.cs files.
Fixes https://github.com/Microsoft/bond/issues/448
Closes https://github.com/Microsoft/bond/pull/630
- Macro parameters with commas in them, like `std::map<int, std::string>`
need to be surrounded with parenthesis so they are treated as one
parameter instead of as two parameters to the macro.
- Use `always_false` as it is closer to the semantics we want to convey.
- Standardize where the ! is in parenthesized parameters.
- Now the generated type's default ctor is only compiled when it is
actually used. This permits non-default-constructible allocators to be
used. Ideally, the default ctor would be = default, but that doesn't
work with MSVC 2013, so this workaround is needed.
- An additional defaulted `_bond_vc12_ctor_workaround_` parameter is
used as a workaround for a bug in MSVC 2013 which fails to call the
ctor in some cases.
Closes https://github.com/Microsoft/bond/pull/639
* [c#] Include aliased blob in expressions test
* [c#] Cut extra blob conversions in serialization
Aliased blobs were getting converted multiple times during serialization.
Now each blob only gets converted once.
By setting XmlReaderSettings.XmlResolver to null, we can avoid having
XmlReader resolve external XML entities. Attempting to resolve these
external entities can potentially access the network, which is not
something we want to do during deserialization.
This API only exists when targeting the full .NET 4.5 framework, hence
the need for a net45-nonportable version of Bond.dll.
* If a service imported bond.bond or bond_const.bond, an #include of
bond_grpc.h/bond_const_grpc.h was generated, but this header was
missing. Now, when the CMake variable BOND_ENABLE_GRPC is true, these
headers are generated.
* Other minor CMakeLists.txt cleanups.
* An example, demonstrating how to use bond.Box to wrap scalar service
arguments has been added. This also serves to test the fixed headers.
* A helper function bond::make_box has been added to enable creation of
bond::Box<T> instances via type deduction.
If a service use a generic type like bond.Box<T> with a collection type
argument as a parameter/return type, the generated code was missing an
import of System.Collections.Generic. This has been fixed.
An example, demonstrating how to use bond.Box to wrap scalar service
arguments has been added. This also serves to test the fixed codegen.
A helper method Bond.Box.Create() has been added to enable creation of
Bond.Box<T> instances via type deduction.
Fixes https://github.com/Microsoft/bond/issues/623
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.