diff --git a/CMakeLists.txt b/CMakeLists.txt index 086b874e7..ebe2be3aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,6 +42,8 @@ option(FIREBASE_INCLUDE_DYNAMIC_LINKS "Include the Firebase Dynamic Links library." ON) option(FIREBASE_INCLUDE_INSTALLATIONS "Include the Firebase Installations library." ON) +option(FIREBASE_INCLUDE_FIRESTORE + "Include the Firebase Firestore library." ON) option(FIREBASE_INCLUDE_FUNCTIONS "Include the Cloud Functions for Firebase library." ON) option(FIREBASE_INCLUDE_MESSAGING @@ -254,6 +256,10 @@ if (FIREBASE_INCLUDE_INSTALLATIONS) add_subdirectory(installations) list(APPEND TARGET_LINK_LIB_NAMES "firebase_installations" "firebase_installations_swig") list(APPEND PROJECT_LIST_HEADER " X(Installations)") +if (FIREBASE_INCLUDE_FIRESTORE) + add_subdirectory(firestore) + list(APPEND TARGET_LINK_LIB_NAMES "firebase_firestore" "firebase_firestore_swig") + list(APPEND PROJECT_LIST_HEADER " X(Firestore)") endif() if (FIREBASE_INCLUDE_FUNCTIONS) add_subdirectory(functions) diff --git a/docs/firestore/FirestoreReadme.md b/docs/firestore/FirestoreReadme.md new file mode 100644 index 000000000..95b388700 --- /dev/null +++ b/docs/firestore/FirestoreReadme.md @@ -0,0 +1,49 @@ +Get Started with Cloud Firestore for Firebase +============================================= + +Thank you for installing the Unity Cloud Firestore for Firebase SDK. The +[Firestore guide](https://firebase.google.com/products/firestore/) +provides instructions to configure a Unity project. + +# Overview + +You can use +[Cloud Firestore](https://firebase.google.com/docs/firestore/quickstart) +to store and sync data for client- and server-side development. + +Cloud Firestore is a flexible, scalable database for mobile, web, and +server development from Firebase and Google Cloud Platform. Like Firebase +Realtime Database, it keeps your data in sync across client apps through +realtime listeners and offers offline support for mobile and web so you can +build responsive apps that work regardless of network latency or Internet +connectivity. Cloud Firestore also offers seamless integration with other +Firebase and Google Cloud Platform products, including Cloud Functions. + +# Using the Sample + +This SDK is distributed with a sample project under the +`Assets/Firebase/Sample/Firestore` directory. To configure and run the sample, +follow the instructions in `Assets/Firebase/Sample/Firestore/readme.md`. + +# Demos + +[Mecha Hamster](https://github.com/google/mechahamster) is provided as a demo +which showcases the integration of multiple Firebase features within a single +game. The source is available on +[GitHub](https://github.com/google/mechahamster), and the live application +is available for iOS on the +[App Store](https://itunes.apple.com/us/app/mechahamster/id1286046770?mt=8&ign-mpt=uo%3D4) +and for Android on the +(Google Play Store)[https://play.google.com/store/apps/details?id=com.google.fpl.mechahamster&hl=en]. + +# Links + +* [Homepage](https://firebase.google.com/games/) +* [Contact](https://firebase.google.com/support/contact/) +* [Unity Quickstart Samples](https://github.com/firebase/quickstart-unity) + +# Discussion + +* [Stack overflow](https://stackoverflow.com/questions/tagged/firebase) +* [Slack community](https://firebase-community.slack.com/) +* [Google groups](https://groups.google.com/forum/#!forum/firebase-talk) diff --git a/docs/firestore/Firestore_icon.png b/docs/firestore/Firestore_icon.png new file mode 100644 index 000000000..0411c132d Binary files /dev/null and b/docs/firestore/Firestore_icon.png differ diff --git a/docs/firestore/Firestore_large.png b/docs/firestore/Firestore_large.png new file mode 100644 index 000000000..c7cb36d65 Binary files /dev/null and b/docs/firestore/Firestore_large.png differ diff --git a/docs/firestore/Firestore_small.png b/docs/firestore/Firestore_small.png new file mode 100644 index 000000000..75e353a21 Binary files /dev/null and b/docs/firestore/Firestore_small.png differ diff --git a/dynamic_links/README b/dynamic_links/README new file mode 100644 index 000000000..51c7387b3 --- /dev/null +++ b/dynamic_links/README @@ -0,0 +1 @@ +http://goto/firebase-dynamic-links-cpp diff --git a/firestore/CMakeLists.txt b/firestore/CMakeLists.txt new file mode 100644 index 000000000..6f2117a47 --- /dev/null +++ b/firestore/CMakeLists.txt @@ -0,0 +1,165 @@ +# Copyright 2021 Google +# +# Licensed under the Apache License Version 2.0 (the License); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing software +# distributed under the License is distributed on an AS IS BASIS +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# CMake file for the firebase firestore library + +include(build_shared) + +# Firebase firestore Swig input files +set(firebase_firestore_swig + src/swig/firestore.i +) + +# Firebase Firestore CSharp files +set(firebase_firestore_src + src/Converters/AnonymousTypeConverter.cs + src/Converters/ArrayConverter.cs + src/Converters/AttributedIdAssigner.cs + src/Converters/AttributedTypeConverter.cs + src/Converters/ConverterBase.cs + src/Converters/ConverterCache.cs + src/Converters/CustomConverter.cs + src/Converters/DictionaryConverter.cs + src/Converters/EnumConverter.cs + src/Converters/EnumerableConverter.cs + src/Converters/EnumerableConverterBase.cs + src/Converters/IFirestoreInternalConverter.cs + src/Converters/MapConverterBase.cs + src/Converters/SimpleConverters.cs + src/internal/AssertFailedException.cs + src/internal/EnvironmentVersion.cs + src/internal/Hash.cs + src/internal/Preconditions.cs + src/internal/Util.cs + src/Blob.cs + src/BuildStubs.cs + src/CollectionReference.cs + src/ConverterRegistry.cs + src/DeserializationContext.cs + src/DocumentChange.cs + src/DocumentReference.cs + src/DocumentSnapshot.cs + src/FieldPath.cs + src/FieldValue.cs + src/FirebaseFirestore.cs + src/FirebaseFirestoreSettings.cs + src/FirestoreConverter.cs + src/FirestoreDataAttribute.cs + src/FirestoreDocumentIdAttribute.cs + src/FirestoreEnumNameConverter.cs + src/FirestoreException.cs + src/FirestorePropertyAttribute.cs + src/GeoPoint.cs + src/ListenerRegistration.cs + src/ListenerRegistrationMap.cs + src/LoadBundleTaskProgress.cs + src/MonoPInvokeCallbackAttribute.cs + src/Query.cs + src/QuerySnapshot.cs + src/SerializationContext.cs + src/ServerTimestampAttribute.cs + src/ServerTimestampBehavior.cs + src/SetOptions.cs + src/SnapshotMetadata.cs + src/Timestamp.cs + src/Transaction.cs + src/TransactionManager.cs + src/UnknownPropertyHandling.cs + src/ValueDeserializer.cs + src/ValueSerializer.cs + src/WriteBatch.cs +) + +add_subdirectory(src/swig) + +firebase_swig_add_library(firebase_firestore_swig + NAMESPACE + Firebase.Firestore + MODULE + FirebaseCppFirestore + SOURCES + ${firebase_firestore_swig} + DEPENDS + firebase_firestore + firebase_firestore_swig_cpp + absl_variant +) + +set(FIRESTORE_SOURCE_DIR ${FIREBASE_CPP_SDK_DIR}/build/external/src/firestore) + +# Additional public headers come from the Firestore core +if(IOS) + target_include_directories(firebase_firestore_swig + PUBLIC + # The Firestore core on iOS comes via the FirebaseFirestore CocoaPod, and + # public headers should come from there. + ${FIREBASE_POD_DIR}/Pods/FirebaseFirestore/Firestore/core/include + ${FIREBASE_POD_DIR}/Pods/FirebaseFirestore/Firestore/Protos/nanopb + PRIVATE + # Additionally, the core C++ API is not declared publicly within the + # FirebaseFirestore pod, so depend on headers available in the source + # distribution. + ${FIREBASE_POD_DIR}/Pods/FirebaseFirestore + ) +else() + # Desktop and Android get their public headers from the CMake build in + # firebase-ios-sdk. + target_include_directories(firebase_firestore_swig + PUBLIC + ${FIRESTORE_SOURCE_DIR}/Firestore/core/include + ${FIRESTORE_SOURCE_DIR}/Firestore/Protos/nanopb + PRIVATE + ${FIRESTORE_SOURCE_DIR} + ) +endif() + +mono_add_library(firebase_firestore_cs + MODULE + Firebase.Firestore + SOURCES + ${firebase_firestore_src} + ${firebase_firestore_swig_gen_src} + REFERENCES + google_minijson_cs + unity_compat_cs + unity_tasks_cs + ${FIREBASE_PLATFORM_REF} + DEPENDS + firebase_firestore_swig +) + +build_firebase_shared( + firestore + firestore + FirebaseCppFirestore +) + +unity_pack_native(firebase_firestore_swig) +unity_pack_cs(firebase_firestore_cs) + +if (FIREBASE_INCLUDE_UNITY) + generate_dependencies_xml(Firestore + IOS_DEPS + "Firebase/Firestore" + ANDROID_DEPS + ${FIREBASE_DATABASE_ANDROID_DEPS} + ANDROID_SPEC + "firestore" + ) +endif() + +set_property(TARGET firebase_firestore_cs + PROPERTY FOLDER + "Firebase ${FIREBASE_PLATFORM_NAME}" +) diff --git a/firestore/empty.cc b/firestore/empty.cc new file mode 100644 index 000000000..e69de29bb diff --git a/firestore/generated/src/firestore.cpp b/firestore/generated/src/firestore.cpp new file mode 100755 index 000000000..e497bac75 --- /dev/null +++ b/firestore/generated/src/firestore.cpp @@ -0,0 +1,14263 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 3.0.2 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +#define SWIGCSHARP + + +#ifdef __cplusplus +#include +/* SwigValueWrapper is described in swig.swg */ +template class SwigValueWrapper { + struct SwigMovePointer { + T *ptr; + SwigMovePointer(T *p) : ptr(p) { } + ~SwigMovePointer() { delete ptr; } + SwigMovePointer& operator=(SwigMovePointer& rhs) { T* oldptr = ptr; ptr = 0; delete oldptr; ptr = rhs.ptr; rhs.ptr = 0; return *this; } + } pointer; + SwigValueWrapper& operator=(const SwigValueWrapper& rhs); + SwigValueWrapper(const SwigValueWrapper& rhs); +public: + SwigValueWrapper() : pointer(0) { } +#if __cplusplus >= 201103L + SwigValueWrapper &operator=(T t) { + SwigMovePointer tmp(new T(std::move(t))); + pointer = tmp; + return *this; + } +#else + SwigValueWrapper& operator=(const T& t) { SwigMovePointer tmp(new T(t)); pointer = tmp; return *this; } +#endif + operator T&() const { return *pointer.ptr; } + T *operator&() { return pointer.ptr; } +}; + +template T SwigValueInit() { + return T(); +} +#endif + +/* ----------------------------------------------------------------------------- + * This section contains generic SWIG labels for method/variable + * declarations/attributes, and other compiler dependent labels. + * ----------------------------------------------------------------------------- */ + +/* template workaround for compilers that cannot correctly implement the C++ standard */ +#ifndef SWIGTEMPLATEDISAMBIGUATOR +# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# elif defined(__HP_aCC) +/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ +/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +#endif + +/* inline attribute */ +#ifndef SWIGINLINE +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif +#endif + +/* attribute recognised by some compilers to avoid 'unused' warnings */ +#ifndef SWIGUNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +# elif defined(__ICC) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +#endif + +#ifndef SWIG_MSC_UNSUPPRESS_4505 +# if defined(_MSC_VER) +# pragma warning(disable : 4505) /* unreferenced local function has been removed */ +# endif +#endif + +#ifndef SWIGUNUSEDPARM +# ifdef __cplusplus +# define SWIGUNUSEDPARM(p) +# else +# define SWIGUNUSEDPARM(p) p SWIGUNUSED +# endif +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +/* internal inline SWIG method */ +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* exporting methods */ +#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif +#endif + +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) +# define SWIGEXPORT __attribute__ ((visibility("default"))) +# else +# define SWIGEXPORT +# endif +# endif +#endif + +/* calling conventions for Windows */ +#ifndef SWIGSTDCALL +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# define SWIGSTDCALL __stdcall +# else +# define SWIGSTDCALL +# endif +#endif + +/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ +#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) +# define _CRT_SECURE_NO_DEPRECATE +#endif + +/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ +#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) +# define _SCL_SECURE_NO_DEPRECATE +#endif + + + +#include +#include +#include + + +/* Support for throwing C# exceptions from C/C++. There are two types: + * Exceptions that take a message and ArgumentExceptions that take a message and a parameter name. */ +typedef enum { + SWIG_CSharpApplicationException, + SWIG_CSharpArithmeticException, + SWIG_CSharpDivideByZeroException, + SWIG_CSharpIndexOutOfRangeException, + SWIG_CSharpInvalidCastException, + SWIG_CSharpInvalidOperationException, + SWIG_CSharpIOException, + SWIG_CSharpNullReferenceException, + SWIG_CSharpOutOfMemoryException, + SWIG_CSharpOverflowException, + SWIG_CSharpSystemException +} SWIG_CSharpExceptionCodes; + +typedef enum { + SWIG_CSharpArgumentException, + SWIG_CSharpArgumentNullException, + SWIG_CSharpArgumentOutOfRangeException +} SWIG_CSharpExceptionArgumentCodes; + +typedef void (SWIGSTDCALL* SWIG_CSharpExceptionCallback_t)(const char *); +typedef void (SWIGSTDCALL* SWIG_CSharpExceptionArgumentCallback_t)(const char *, const char *); + +typedef struct { + SWIG_CSharpExceptionCodes code; + SWIG_CSharpExceptionCallback_t callback; +} SWIG_CSharpException_t; + +typedef struct { + SWIG_CSharpExceptionArgumentCodes code; + SWIG_CSharpExceptionArgumentCallback_t callback; +} SWIG_CSharpExceptionArgument_t; + +static SWIG_CSharpException_t SWIG_csharp_exceptions[] = { + { SWIG_CSharpApplicationException, NULL }, + { SWIG_CSharpArithmeticException, NULL }, + { SWIG_CSharpDivideByZeroException, NULL }, + { SWIG_CSharpIndexOutOfRangeException, NULL }, + { SWIG_CSharpInvalidCastException, NULL }, + { SWIG_CSharpInvalidOperationException, NULL }, + { SWIG_CSharpIOException, NULL }, + { SWIG_CSharpNullReferenceException, NULL }, + { SWIG_CSharpOutOfMemoryException, NULL }, + { SWIG_CSharpOverflowException, NULL }, + { SWIG_CSharpSystemException, NULL } +}; + +static SWIG_CSharpExceptionArgument_t SWIG_csharp_exceptions_argument[] = { + { SWIG_CSharpArgumentException, NULL }, + { SWIG_CSharpArgumentNullException, NULL }, + { SWIG_CSharpArgumentOutOfRangeException, NULL } +}; + +static void SWIGUNUSED SWIG_CSharpSetPendingException(SWIG_CSharpExceptionCodes code, const char *msg) { + SWIG_CSharpExceptionCallback_t callback = SWIG_csharp_exceptions[SWIG_CSharpApplicationException].callback; + if ((size_t)code < sizeof(SWIG_csharp_exceptions)/sizeof(SWIG_CSharpException_t)) { + callback = SWIG_csharp_exceptions[code].callback; + } + callback(msg); +} + +static void SWIGUNUSED SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpExceptionArgumentCodes code, const char *msg, const char *param_name) { + SWIG_CSharpExceptionArgumentCallback_t callback = SWIG_csharp_exceptions_argument[SWIG_CSharpArgumentException].callback; + if ((size_t)code < sizeof(SWIG_csharp_exceptions_argument)/sizeof(SWIG_CSharpExceptionArgument_t)) { + callback = SWIG_csharp_exceptions_argument[code].callback; + } + callback(msg, param_name); +} + + +#ifdef __cplusplus +extern "C" +#endif +SWIGEXPORT void SWIGSTDCALL SWIGRegisterExceptionCallbacks_FirestoreCpp( + SWIG_CSharpExceptionCallback_t applicationCallback, + SWIG_CSharpExceptionCallback_t arithmeticCallback, + SWIG_CSharpExceptionCallback_t divideByZeroCallback, + SWIG_CSharpExceptionCallback_t indexOutOfRangeCallback, + SWIG_CSharpExceptionCallback_t invalidCastCallback, + SWIG_CSharpExceptionCallback_t invalidOperationCallback, + SWIG_CSharpExceptionCallback_t ioCallback, + SWIG_CSharpExceptionCallback_t nullReferenceCallback, + SWIG_CSharpExceptionCallback_t outOfMemoryCallback, + SWIG_CSharpExceptionCallback_t overflowCallback, + SWIG_CSharpExceptionCallback_t systemCallback) { + SWIG_csharp_exceptions[SWIG_CSharpApplicationException].callback = applicationCallback; + SWIG_csharp_exceptions[SWIG_CSharpArithmeticException].callback = arithmeticCallback; + SWIG_csharp_exceptions[SWIG_CSharpDivideByZeroException].callback = divideByZeroCallback; + SWIG_csharp_exceptions[SWIG_CSharpIndexOutOfRangeException].callback = indexOutOfRangeCallback; + SWIG_csharp_exceptions[SWIG_CSharpInvalidCastException].callback = invalidCastCallback; + SWIG_csharp_exceptions[SWIG_CSharpInvalidOperationException].callback = invalidOperationCallback; + SWIG_csharp_exceptions[SWIG_CSharpIOException].callback = ioCallback; + SWIG_csharp_exceptions[SWIG_CSharpNullReferenceException].callback = nullReferenceCallback; + SWIG_csharp_exceptions[SWIG_CSharpOutOfMemoryException].callback = outOfMemoryCallback; + SWIG_csharp_exceptions[SWIG_CSharpOverflowException].callback = overflowCallback; + SWIG_csharp_exceptions[SWIG_CSharpSystemException].callback = systemCallback; +} + +#ifdef __cplusplus +extern "C" +#endif +SWIGEXPORT void SWIGSTDCALL SWIGRegisterExceptionArgumentCallbacks_FirestoreCpp( + SWIG_CSharpExceptionArgumentCallback_t argumentCallback, + SWIG_CSharpExceptionArgumentCallback_t argumentNullCallback, + SWIG_CSharpExceptionArgumentCallback_t argumentOutOfRangeCallback) { + SWIG_csharp_exceptions_argument[SWIG_CSharpArgumentException].callback = argumentCallback; + SWIG_csharp_exceptions_argument[SWIG_CSharpArgumentNullException].callback = argumentNullCallback; + SWIG_csharp_exceptions_argument[SWIG_CSharpArgumentOutOfRangeException].callback = argumentOutOfRangeCallback; +} + + +/* Callback for returning strings to C# without leaking memory */ +typedef char * (SWIGSTDCALL* SWIG_CSharpStringHelperCallback)(const char *); +static SWIG_CSharpStringHelperCallback SWIG_csharp_string_callback = NULL; + + +#ifdef __cplusplus +extern "C" +#endif +SWIGEXPORT void SWIGSTDCALL SWIGRegisterStringCallback_FirestoreCpp(SWIG_CSharpStringHelperCallback callback) { + SWIG_csharp_string_callback = callback; +} + + +/* Contract support */ + +#define SWIG_contract_assert(nullreturn, expr, msg) if (!(expr)) {SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentOutOfRangeException, msg, ""); return nullreturn; } else + +/* Errors in SWIG */ +#define SWIG_UnknownError -1 +#define SWIG_IOError -2 +#define SWIG_RuntimeError -3 +#define SWIG_IndexError -4 +#define SWIG_TypeError -5 +#define SWIG_DivisionByZero -6 +#define SWIG_OverflowError -7 +#define SWIG_SyntaxError -8 +#define SWIG_ValueError -9 +#define SWIG_SystemError -10 +#define SWIG_AttributeError -11 +#define SWIG_MemoryError -12 +#define SWIG_NullReferenceError -13 + + + + +using CSharpExceptionCallback = void (SWIGSTDCALL*)(const char*); + +CSharpExceptionCallback firestore_exception_callback = nullptr; + +extern "C" { + +SWIGEXPORT void SWIGSTDCALL FirestoreExceptionRegisterCallback(CSharpExceptionCallback callback) { + firestore_exception_callback = callback; +} + +} + +static void SWIG_CSharpSetPendingExceptionFirestore(const char* msg) { + firestore_exception_callback(msg); +} + + +SWIGINTERN void SWIG_CSharpException(int code, const char *msg) { + if (code == SWIG_ValueError) { + SWIG_CSharpExceptionArgumentCodes exception_code = SWIG_CSharpArgumentOutOfRangeException; + SWIG_CSharpSetPendingExceptionArgument(exception_code, msg, 0); + } else { + SWIG_CSharpExceptionCodes exception_code = SWIG_CSharpApplicationException; + switch(code) { + case SWIG_MemoryError: + exception_code = SWIG_CSharpOutOfMemoryException; + break; + case SWIG_IndexError: + exception_code = SWIG_CSharpIndexOutOfRangeException; + break; + case SWIG_DivisionByZero: + exception_code = SWIG_CSharpDivideByZeroException; + break; + case SWIG_IOError: + exception_code = SWIG_CSharpIOException; + break; + case SWIG_OverflowError: + exception_code = SWIG_CSharpOverflowException; + break; + case SWIG_RuntimeError: + case SWIG_TypeError: + case SWIG_SyntaxError: + case SWIG_SystemError: + case SWIG_UnknownError: + default: + exception_code = SWIG_CSharpApplicationException; + break; + } + SWIG_CSharpSetPendingException(exception_code, msg); + } +} + +#include +#include + +#include "app/src/callback.h" +#include "app/src/include/firebase/future.h" +#include "firestore/src/common/firestore_exceptions_common.h" +#include "firestore/src/include/firebase/firestore.h" + +// This adds the STDCALL thunk, necessary for C/C# interoperability. +// The function pointer type declared in the C++ library should have the +// exact same signature, however it lacks this explicit calling convention +// declaration. We declare it here with explicit calling convention and use +// a thin wrapper (just below) so that we can be certain we match the same +// calling convention in C# when we trigger the callback. +typedef void(SWIGSTDCALL *Future_QuerySnapshot_CB_Type)(int index); + +// Associates callback data with each Future +// instance. +struct Future_QuerySnapshotCallbackData { + // C# delegate method that should be called on the main thread. + Future_QuerySnapshot_CB_Type cs_callback; + // Key of the callback in the C# QuerySnapshotProxy.Callbacks dictionary. + int cs_key; + }; + + // Use a static function to make callback so don't need to worry about + // whether using stdcall or cdecl for the cs_callback function. + static void CallbackImpl(Future_QuerySnapshotCallbackData data) { + data.cs_callback(data.cs_key); + } + + // This is a C++ wrapper callback that queues the registered C# callback. + // We unpack the real C# callback from the user data, where we packed it + // when the callback was registered. + void Future_QuerySnapshot_CB(const firebase::Future& /*result_data*/, + void *user_data) { + auto cbdata = reinterpret_cast(user_data); + firebase::callback::AddCallback( + new firebase::callback::CallbackValue1( + *cbdata, CallbackImpl)); + } + +SWIGINTERN void *firebase_Future_Sl_firebase_firestore_QuerySnapshot_Sg__SWIG_OnCompletion(firebase::Future< firebase::firestore::QuerySnapshot > *self,Future_QuerySnapshot_CB_Type cs_callback,int cs_key){ + Future_QuerySnapshotCallbackData* cbdata = new Future_QuerySnapshotCallbackData; + cbdata->cs_callback = cs_callback; + cbdata->cs_key = cs_key; + self->OnCompletion(Future_QuerySnapshot_CB, cbdata); + return cbdata; + } +SWIGINTERN void firebase_Future_Sl_firebase_firestore_QuerySnapshot_Sg__SWIG_FreeCompletionData(firebase::Future< firebase::firestore::QuerySnapshot > *self,void *data){ + delete reinterpret_cast(data); + } +SWIGINTERN firebase::firestore::QuerySnapshot const firebase_Future_Sl_firebase_firestore_QuerySnapshot_Sg__GetResult(firebase::Future< firebase::firestore::QuerySnapshot > const *self){ + // The Future internally always stores it's value with firebase::firestore::QuerySnapshot *, so 'result' + // can always be dereferenced except when the type in void. + return *self->result(); + } + +#include "app/src/callback.h" +#include "app/src/include/firebase/future.h" + + + // This adds the STDCALL thunk, necessary for C/C# interoperability. + // The function pointer type declared in the C++ library should have the + // exact same signature, however it lacks this explicit calling convention + // declaration. We declare it here with explicit calling convention and use + // a thin wrapper (just below) so that we can be certain we match the same + // calling convention in C# when we trigger the callback. + typedef void (SWIGSTDCALL* Future_DocumentSnapshot_CB_Type)(int index); + + // Associates callback data with each Future instance. + struct Future_DocumentSnapshotCallbackData { + // C# delegate method that should be called on the main thread. + Future_DocumentSnapshot_CB_Type cs_callback; + // Key of the callback in the C# DocumentSnapshotProxy.Callbacks dictionary. + int cs_key; + }; + + // Use a static function to make callback so don't need to worry about + // whether using stdcall or cdecl for the cs_callback function. + static void CallbackImpl(Future_DocumentSnapshotCallbackData data) { + data.cs_callback(data.cs_key); + } + + // This is a C++ wrapper callback that queues the registered C# callback. + // We unpack the real C# callback from the user data, where we packed it + // when the callback was registered. + void Future_DocumentSnapshot_CB(const firebase::Future& /*result_data*/, + void *user_data) { + auto cbdata = reinterpret_cast(user_data); + firebase::callback::AddCallback( + new firebase::callback::CallbackValue1( + *cbdata, CallbackImpl)); + } + +SWIGINTERN void *firebase_Future_Sl_firebase_firestore_DocumentSnapshot_Sg__SWIG_OnCompletion(firebase::Future< firebase::firestore::DocumentSnapshot > *self,Future_DocumentSnapshot_CB_Type cs_callback,int cs_key){ + Future_DocumentSnapshotCallbackData* cbdata = new Future_DocumentSnapshotCallbackData; + cbdata->cs_callback = cs_callback; + cbdata->cs_key = cs_key; + self->OnCompletion(Future_DocumentSnapshot_CB, cbdata); + return cbdata; + } +SWIGINTERN void firebase_Future_Sl_firebase_firestore_DocumentSnapshot_Sg__SWIG_FreeCompletionData(firebase::Future< firebase::firestore::DocumentSnapshot > *self,void *data){ + delete reinterpret_cast(data); + } +SWIGINTERN firebase::firestore::DocumentSnapshot const firebase_Future_Sl_firebase_firestore_DocumentSnapshot_Sg__GetResult(firebase::Future< firebase::firestore::DocumentSnapshot > const *self){ + // The Future internally always stores it's value with firebase::firestore::DocumentSnapshot *, so 'result' + // can always be dereferenced except when the type in void. + return *self->result(); + } + +#include "app/src/callback.h" +#include "app/src/include/firebase/future.h" + + + // This adds the STDCALL thunk, necessary for C/C# interoperability. + // The function pointer type declared in the C++ library should have the + // exact same signature, however it lacks this explicit calling convention + // declaration. We declare it here with explicit calling convention and use + // a thin wrapper (just below) so that we can be certain we match the same + // calling convention in C# when we trigger the callback. + typedef void (SWIGSTDCALL* Future_DocumentReference_CB_Type)(int index); + + // Associates callback data with each Future instance. + struct Future_DocumentReferenceCallbackData { + // C# delegate method that should be called on the main thread. + Future_DocumentReference_CB_Type cs_callback; + // Key of the callback in the C# DocumentReferenceProxy.Callbacks dictionary. + int cs_key; + }; + + // Use a static function to make callback so don't need to worry about + // whether using stdcall or cdecl for the cs_callback function. + static void CallbackImpl(Future_DocumentReferenceCallbackData data) { + data.cs_callback(data.cs_key); + } + + // This is a C++ wrapper callback that queues the registered C# callback. + // We unpack the real C# callback from the user data, where we packed it + // when the callback was registered. + void Future_DocumentReference_CB(const firebase::Future& /*result_data*/, + void *user_data) { + auto cbdata = reinterpret_cast(user_data); + firebase::callback::AddCallback( + new firebase::callback::CallbackValue1( + *cbdata, CallbackImpl)); + } + +SWIGINTERN void *firebase_Future_Sl_firebase_firestore_DocumentReference_Sg__SWIG_OnCompletion(firebase::Future< firebase::firestore::DocumentReference > *self,Future_DocumentReference_CB_Type cs_callback,int cs_key){ + Future_DocumentReferenceCallbackData* cbdata = new Future_DocumentReferenceCallbackData; + cbdata->cs_callback = cs_callback; + cbdata->cs_key = cs_key; + self->OnCompletion(Future_DocumentReference_CB, cbdata); + return cbdata; + } +SWIGINTERN void firebase_Future_Sl_firebase_firestore_DocumentReference_Sg__SWIG_FreeCompletionData(firebase::Future< firebase::firestore::DocumentReference > *self,void *data){ + delete reinterpret_cast(data); + } +SWIGINTERN firebase::firestore::DocumentReference const firebase_Future_Sl_firebase_firestore_DocumentReference_Sg__GetResult(firebase::Future< firebase::firestore::DocumentReference > const *self){ + // The Future internally always stores it's value with firebase::firestore::DocumentReference *, so 'result' + // can always be dereferenced except when the type in void. + return *self->result(); + } + +#include "app/src/callback.h" +#include "app/src/include/firebase/future.h" + + + // This adds the STDCALL thunk, necessary for C/C# interoperability. + // The function pointer type declared in the C++ library should have the + // exact same signature, however it lacks this explicit calling convention + // declaration. We declare it here with explicit calling convention and use + // a thin wrapper (just below) so that we can be certain we match the same + // calling convention in C# when we trigger the callback. + typedef void (SWIGSTDCALL* Future_FirestoreVoid_CB_Type)(int index); + + // Associates callback data with each Future instance. + struct Future_FirestoreVoidCallbackData { + // C# delegate method that should be called on the main thread. + Future_FirestoreVoid_CB_Type cs_callback; + // Key of the callback in the C# void.Callbacks dictionary. + int cs_key; + }; + + // Use a static function to make callback so don't need to worry about + // whether using stdcall or cdecl for the cs_callback function. + static void CallbackImpl(Future_FirestoreVoidCallbackData data) { + data.cs_callback(data.cs_key); + } + + // This is a C++ wrapper callback that queues the registered C# callback. + // We unpack the real C# callback from the user data, where we packed it + // when the callback was registered. + void Future_FirestoreVoid_CB(const firebase::Future& /*result_data*/, + void *user_data) { + auto cbdata = reinterpret_cast(user_data); + firebase::callback::AddCallback( + new firebase::callback::CallbackValue1( + *cbdata, CallbackImpl)); + } + +SWIGINTERN void *firebase_Future_Sl_void_Sg__SWIG_OnCompletion(firebase::Future< void > *self,Future_FirestoreVoid_CB_Type cs_callback,int cs_key){ + Future_FirestoreVoidCallbackData* cbdata = new Future_FirestoreVoidCallbackData; + cbdata->cs_callback = cs_callback; + cbdata->cs_key = cs_key; + self->OnCompletion(Future_FirestoreVoid_CB, cbdata); + return cbdata; + } +SWIGINTERN void firebase_Future_Sl_void_Sg__SWIG_FreeCompletionData(firebase::Future< void > *self,void *data){ + delete reinterpret_cast(data); + } + +#include "app/src/callback.h" +#include "app/src/include/firebase/future.h" + + + // This adds the STDCALL thunk, necessary for C/C# interoperability. + // The function pointer type declared in the C++ library should have the + // exact same signature, however it lacks this explicit calling convention + // declaration. We declare it here with explicit calling convention and use + // a thin wrapper (just below) so that we can be certain we match the same + // calling convention in C# when we trigger the callback. + typedef void (SWIGSTDCALL* Future_LoadBundleTaskProgress_CB_Type)(int index); + + // Associates callback data with each Future instance. + struct Future_LoadBundleTaskProgressCallbackData { + // C# delegate method that should be called on the main thread. + Future_LoadBundleTaskProgress_CB_Type cs_callback; + // Key of the callback in the C# LoadBundleTaskProgressProxy.Callbacks dictionary. + int cs_key; + }; + + // Use a static function to make callback so don't need to worry about + // whether using stdcall or cdecl for the cs_callback function. + static void CallbackImpl(Future_LoadBundleTaskProgressCallbackData data) { + data.cs_callback(data.cs_key); + } + + // This is a C++ wrapper callback that queues the registered C# callback. + // We unpack the real C# callback from the user data, where we packed it + // when the callback was registered. + void Future_LoadBundleTaskProgress_CB(const firebase::Future& /*result_data*/, + void *user_data) { + auto cbdata = reinterpret_cast(user_data); + firebase::callback::AddCallback( + new firebase::callback::CallbackValue1( + *cbdata, CallbackImpl)); + } + +SWIGINTERN void *firebase_Future_Sl_firebase_firestore_LoadBundleTaskProgress_Sg__SWIG_OnCompletion(firebase::Future< firebase::firestore::LoadBundleTaskProgress > *self,Future_LoadBundleTaskProgress_CB_Type cs_callback,int cs_key){ + Future_LoadBundleTaskProgressCallbackData* cbdata = new Future_LoadBundleTaskProgressCallbackData; + cbdata->cs_callback = cs_callback; + cbdata->cs_key = cs_key; + self->OnCompletion(Future_LoadBundleTaskProgress_CB, cbdata); + return cbdata; + } +SWIGINTERN void firebase_Future_Sl_firebase_firestore_LoadBundleTaskProgress_Sg__SWIG_FreeCompletionData(firebase::Future< firebase::firestore::LoadBundleTaskProgress > *self,void *data){ + delete reinterpret_cast(data); + } +SWIGINTERN firebase::firestore::LoadBundleTaskProgress const firebase_Future_Sl_firebase_firestore_LoadBundleTaskProgress_Sg__GetResult(firebase::Future< firebase::firestore::LoadBundleTaskProgress > const *self){ + // The Future internally always stores it's value with firebase::firestore::LoadBundleTaskProgress *, so 'result' + // can always be dereferenced except when the type in void. + return *self->result(); + } + +#include "app/src/callback.h" +#include "app/src/include/firebase/future.h" + + + // This adds the STDCALL thunk, necessary for C/C# interoperability. + // The function pointer type declared in the C++ library should have the + // exact same signature, however it lacks this explicit calling convention + // declaration. We declare it here with explicit calling convention and use + // a thin wrapper (just below) so that we can be certain we match the same + // calling convention in C# when we trigger the callback. + typedef void (SWIGSTDCALL* Future_Query_CB_Type)(int index); + + // Associates callback data with each Future instance. + struct Future_QueryCallbackData { + // C# delegate method that should be called on the main thread. + Future_Query_CB_Type cs_callback; + // Key of the callback in the C# QueryProxy.Callbacks dictionary. + int cs_key; + }; + + // Use a static function to make callback so don't need to worry about + // whether using stdcall or cdecl for the cs_callback function. + static void CallbackImpl(Future_QueryCallbackData data) { + data.cs_callback(data.cs_key); + } + + // This is a C++ wrapper callback that queues the registered C# callback. + // We unpack the real C# callback from the user data, where we packed it + // when the callback was registered. + void Future_Query_CB(const firebase::Future& /*result_data*/, + void *user_data) { + auto cbdata = reinterpret_cast(user_data); + firebase::callback::AddCallback( + new firebase::callback::CallbackValue1( + *cbdata, CallbackImpl)); + } + +SWIGINTERN void *firebase_Future_Sl_firebase_firestore_Query_Sg__SWIG_OnCompletion(firebase::Future< firebase::firestore::Query > *self,Future_Query_CB_Type cs_callback,int cs_key){ + Future_QueryCallbackData* cbdata = new Future_QueryCallbackData; + cbdata->cs_callback = cs_callback; + cbdata->cs_key = cs_key; + self->OnCompletion(Future_Query_CB, cbdata); + return cbdata; + } +SWIGINTERN void firebase_Future_Sl_firebase_firestore_Query_Sg__SWIG_FreeCompletionData(firebase::Future< firebase::firestore::Query > *self,void *data){ + delete reinterpret_cast(data); + } +SWIGINTERN firebase::firestore::Query const firebase_Future_Sl_firebase_firestore_Query_Sg__GetResult(firebase::Future< firebase::firestore::Query > const *self){ + // The Future internally always stores it's value with firebase::firestore::Query *, so 'result' + // can always be dereferenced except when the type in void. + return *self->result(); + } + +#include "firestore/src/swig/document_event_listener.h" +#include "firestore/src/swig/query_event_listener.h" +#include "firestore/src/swig/snapshots_in_sync_listener.h" +#include "firestore/src/swig/load_bundle_task_progress_callback.h" +#include "firestore/src/swig/firestore_instance_management.h" + + +#include "firestore/src/swig/api_headers.h" + + +#include "firestore/src/swig/map.h" + + +#include "firestore/src/swig/transaction_manager.h" + + +#include "firestore/src/swig/vector.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_new_GeoPointProxy(double jarg1, double jarg2) { + void * jresult ; + double arg1 ; + double arg2 ; + firebase::firestore::GeoPoint *result = 0 ; + + arg1 = (double)jarg1; + arg2 = (double)jarg2; + result = (firebase::firestore::GeoPoint *)new firebase::firestore::GeoPoint(arg1,arg2); + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT double SWIGSTDCALL Firebase_Firestore_CSharp_GeoPointProxy_latitude(void * jarg1) { + double jresult ; + firebase::firestore::GeoPoint *arg1 = (firebase::firestore::GeoPoint *) 0 ; + double result; + + arg1 = (firebase::firestore::GeoPoint *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__GeoPoint) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + result = (double)((firebase::firestore::GeoPoint const *)arg1)->latitude(); + jresult = result; + return jresult; +} + + +SWIGEXPORT double SWIGSTDCALL Firebase_Firestore_CSharp_GeoPointProxy_longitude(void * jarg1) { + double jresult ; + firebase::firestore::GeoPoint *arg1 = (firebase::firestore::GeoPoint *) 0 ; + double result; + + arg1 = (firebase::firestore::GeoPoint *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__GeoPoint) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + result = (double)((firebase::firestore::GeoPoint const *)arg1)->longitude(); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_delete_GeoPointProxy(void * jarg1) { + firebase::firestore::GeoPoint *arg1 = (firebase::firestore::GeoPoint *) 0 ; + + arg1 = (firebase::firestore::GeoPoint *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__GeoPoint) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + delete arg1; + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_new_TimestampProxy__SWIG_0() { + void * jresult ; + firebase::Timestamp *result = 0 ; + + result = (firebase::Timestamp *)new firebase::Timestamp(); + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_new_TimestampProxy__SWIG_1(long long jarg1, int jarg2) { + void * jresult ; + int64_t arg1 ; + int32_t arg2 ; + firebase::Timestamp *result = 0 ; + + arg1 = (int64_t)jarg1; + arg2 = (int32_t)jarg2; + result = (firebase::Timestamp *)new firebase::Timestamp(arg1,arg2); + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_new_TimestampProxy__SWIG_2(void * jarg1) { + void * jresult ; + firebase::Timestamp *arg1 = 0 ; + firebase::Timestamp *result = 0 ; + + arg1 = (firebase::Timestamp *)jarg1; + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::Timestamp const & type is null", 0); + return 0; + } + result = (firebase::Timestamp *)new firebase::Timestamp((firebase::Timestamp const &)*arg1); + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_TimestampProxy_Now() { + void * jresult ; + firebase::Timestamp result; + + result = firebase::Timestamp::Now(); + jresult = new firebase::Timestamp((const firebase::Timestamp &)result); + return jresult; +} + + +SWIGEXPORT long long SWIGSTDCALL Firebase_Firestore_CSharp_TimestampProxy_seconds(void * jarg1) { + long long jresult ; + firebase::Timestamp *arg1 = (firebase::Timestamp *) 0 ; + int64_t result; + + arg1 = (firebase::Timestamp *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__Timestamp) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + result = (int64_t)((firebase::Timestamp const *)arg1)->seconds(); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL Firebase_Firestore_CSharp_TimestampProxy_nanoseconds(void * jarg1) { + int jresult ; + firebase::Timestamp *arg1 = (firebase::Timestamp *) 0 ; + int32_t result; + + arg1 = (firebase::Timestamp *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__Timestamp) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + result = (int32_t)((firebase::Timestamp const *)arg1)->nanoseconds(); + jresult = result; + return jresult; +} + + +SWIGEXPORT char * SWIGSTDCALL Firebase_Firestore_CSharp_TimestampProxy_ToString(void * jarg1) { + char * jresult ; + firebase::Timestamp *arg1 = (firebase::Timestamp *) 0 ; + std::string result; + + arg1 = (firebase::Timestamp *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__Timestamp) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + result = ((firebase::Timestamp const *)arg1)->ToString(); + jresult = SWIG_csharp_string_callback((&result)->c_str()); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_delete_TimestampProxy(void * jarg1) { + firebase::Timestamp *arg1 = (firebase::Timestamp *) 0 ; + + arg1 = (firebase::Timestamp *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__Timestamp) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + delete arg1; + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_new_Future_QuerySnapshot() { + void * jresult ; + firebase::Future< firebase::firestore::QuerySnapshot > *result = 0 ; + + { + try { + result = (firebase::Future< firebase::firestore::QuerySnapshot > *)new firebase::Future< firebase::firestore::QuerySnapshot >(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_Future_QuerySnapshot_SWIG_OnCompletion(void * jarg1, void * jarg2, int jarg3) { + void * jresult ; + firebase::Future< firebase::firestore::QuerySnapshot > *arg1 = (firebase::Future< firebase::firestore::QuerySnapshot > *) 0 ; + Future_QuerySnapshot_CB_Type arg2 ; + int arg3 ; + void *result = 0 ; + + arg1 = (firebase::Future< firebase::firestore::QuerySnapshot > *)jarg1; + arg2 = (Future_QuerySnapshot_CB_Type)jarg2; + arg3 = (int)jarg3; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__FutureT_firebase__firestore__QuerySnapshot_t) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (void *)firebase_Future_Sl_firebase_firestore_QuerySnapshot_Sg__SWIG_OnCompletion(arg1,arg2,arg3); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_Future_QuerySnapshot_SWIG_FreeCompletionData(void * jarg1, void * jarg2) { + firebase::Future< firebase::firestore::QuerySnapshot > *arg1 = (firebase::Future< firebase::firestore::QuerySnapshot > *) 0 ; + void *arg2 = (void *) 0 ; + + arg1 = (firebase::Future< firebase::firestore::QuerySnapshot > *)jarg1; + arg2 = (void *)jarg2; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__FutureT_firebase__firestore__QuerySnapshot_t) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + firebase_Future_Sl_firebase_firestore_QuerySnapshot_Sg__SWIG_FreeCompletionData(arg1,arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_Future_QuerySnapshot_GetResult(void * jarg1) { + void * jresult ; + firebase::Future< firebase::firestore::QuerySnapshot > *arg1 = (firebase::Future< firebase::firestore::QuerySnapshot > *) 0 ; + firebase::firestore::QuerySnapshot result; + + arg1 = (firebase::Future< firebase::firestore::QuerySnapshot > *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__FutureT_firebase__firestore__QuerySnapshot_t) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = firebase_Future_Sl_firebase_firestore_QuerySnapshot_Sg__GetResult((firebase::Future< firebase::firestore::QuerySnapshot > const *)arg1); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::QuerySnapshot((const firebase::firestore::QuerySnapshot &)result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_delete_Future_QuerySnapshot(void * jarg1) { + firebase::Future< firebase::firestore::QuerySnapshot > *arg1 = (firebase::Future< firebase::firestore::QuerySnapshot > *) 0 ; + + arg1 = (firebase::Future< firebase::firestore::QuerySnapshot > *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__FutureT_firebase__firestore__QuerySnapshot_t) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + delete arg1; + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_new_Future_DocumentSnapshot() { + void * jresult ; + firebase::Future< firebase::firestore::DocumentSnapshot > *result = 0 ; + + { + try { + result = (firebase::Future< firebase::firestore::DocumentSnapshot > *)new firebase::Future< firebase::firestore::DocumentSnapshot >(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_Future_DocumentSnapshot_SWIG_OnCompletion(void * jarg1, void * jarg2, int jarg3) { + void * jresult ; + firebase::Future< firebase::firestore::DocumentSnapshot > *arg1 = (firebase::Future< firebase::firestore::DocumentSnapshot > *) 0 ; + Future_DocumentSnapshot_CB_Type arg2 ; + int arg3 ; + void *result = 0 ; + + arg1 = (firebase::Future< firebase::firestore::DocumentSnapshot > *)jarg1; + arg2 = (Future_DocumentSnapshot_CB_Type)jarg2; + arg3 = (int)jarg3; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__FutureT_firebase__firestore__DocumentSnapshot_t) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (void *)firebase_Future_Sl_firebase_firestore_DocumentSnapshot_Sg__SWIG_OnCompletion(arg1,arg2,arg3); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_Future_DocumentSnapshot_SWIG_FreeCompletionData(void * jarg1, void * jarg2) { + firebase::Future< firebase::firestore::DocumentSnapshot > *arg1 = (firebase::Future< firebase::firestore::DocumentSnapshot > *) 0 ; + void *arg2 = (void *) 0 ; + + arg1 = (firebase::Future< firebase::firestore::DocumentSnapshot > *)jarg1; + arg2 = (void *)jarg2; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__FutureT_firebase__firestore__DocumentSnapshot_t) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + firebase_Future_Sl_firebase_firestore_DocumentSnapshot_Sg__SWIG_FreeCompletionData(arg1,arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_Future_DocumentSnapshot_GetResult(void * jarg1) { + void * jresult ; + firebase::Future< firebase::firestore::DocumentSnapshot > *arg1 = (firebase::Future< firebase::firestore::DocumentSnapshot > *) 0 ; + firebase::firestore::DocumentSnapshot result; + + arg1 = (firebase::Future< firebase::firestore::DocumentSnapshot > *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__FutureT_firebase__firestore__DocumentSnapshot_t) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = firebase_Future_Sl_firebase_firestore_DocumentSnapshot_Sg__GetResult((firebase::Future< firebase::firestore::DocumentSnapshot > const *)arg1); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::DocumentSnapshot((const firebase::firestore::DocumentSnapshot &)result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_delete_Future_DocumentSnapshot(void * jarg1) { + firebase::Future< firebase::firestore::DocumentSnapshot > *arg1 = (firebase::Future< firebase::firestore::DocumentSnapshot > *) 0 ; + + arg1 = (firebase::Future< firebase::firestore::DocumentSnapshot > *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__FutureT_firebase__firestore__DocumentSnapshot_t) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + delete arg1; + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_new_Future_DocumentReference() { + void * jresult ; + firebase::Future< firebase::firestore::DocumentReference > *result = 0 ; + + { + try { + result = (firebase::Future< firebase::firestore::DocumentReference > *)new firebase::Future< firebase::firestore::DocumentReference >(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_Future_DocumentReference_SWIG_OnCompletion(void * jarg1, void * jarg2, int jarg3) { + void * jresult ; + firebase::Future< firebase::firestore::DocumentReference > *arg1 = (firebase::Future< firebase::firestore::DocumentReference > *) 0 ; + Future_DocumentReference_CB_Type arg2 ; + int arg3 ; + void *result = 0 ; + + arg1 = (firebase::Future< firebase::firestore::DocumentReference > *)jarg1; + arg2 = (Future_DocumentReference_CB_Type)jarg2; + arg3 = (int)jarg3; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__FutureT_firebase__firestore__DocumentReference_t) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (void *)firebase_Future_Sl_firebase_firestore_DocumentReference_Sg__SWIG_OnCompletion(arg1,arg2,arg3); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_Future_DocumentReference_SWIG_FreeCompletionData(void * jarg1, void * jarg2) { + firebase::Future< firebase::firestore::DocumentReference > *arg1 = (firebase::Future< firebase::firestore::DocumentReference > *) 0 ; + void *arg2 = (void *) 0 ; + + arg1 = (firebase::Future< firebase::firestore::DocumentReference > *)jarg1; + arg2 = (void *)jarg2; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__FutureT_firebase__firestore__DocumentReference_t) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + firebase_Future_Sl_firebase_firestore_DocumentReference_Sg__SWIG_FreeCompletionData(arg1,arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_Future_DocumentReference_GetResult(void * jarg1) { + void * jresult ; + firebase::Future< firebase::firestore::DocumentReference > *arg1 = (firebase::Future< firebase::firestore::DocumentReference > *) 0 ; + firebase::firestore::DocumentReference result; + + arg1 = (firebase::Future< firebase::firestore::DocumentReference > *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__FutureT_firebase__firestore__DocumentReference_t) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = firebase_Future_Sl_firebase_firestore_DocumentReference_Sg__GetResult((firebase::Future< firebase::firestore::DocumentReference > const *)arg1); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::DocumentReference((const firebase::firestore::DocumentReference &)result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_delete_Future_DocumentReference(void * jarg1) { + firebase::Future< firebase::firestore::DocumentReference > *arg1 = (firebase::Future< firebase::firestore::DocumentReference > *) 0 ; + + arg1 = (firebase::Future< firebase::firestore::DocumentReference > *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__FutureT_firebase__firestore__DocumentReference_t) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + delete arg1; + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_new_Future_FirestoreVoid() { + void * jresult ; + firebase::Future< void > *result = 0 ; + + { + try { + result = (firebase::Future< void > *)new firebase::Future< void >(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_Future_FirestoreVoid_SWIG_OnCompletion(void * jarg1, void * jarg2, int jarg3) { + void * jresult ; + firebase::Future< void > *arg1 = (firebase::Future< void > *) 0 ; + Future_FirestoreVoid_CB_Type arg2 ; + int arg3 ; + void *result = 0 ; + + arg1 = (firebase::Future< void > *)jarg1; + arg2 = (Future_FirestoreVoid_CB_Type)jarg2; + arg3 = (int)jarg3; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__FutureT_void_t) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (void *)firebase_Future_Sl_void_Sg__SWIG_OnCompletion(arg1,arg2,arg3); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_Future_FirestoreVoid_SWIG_FreeCompletionData(void * jarg1, void * jarg2) { + firebase::Future< void > *arg1 = (firebase::Future< void > *) 0 ; + void *arg2 = (void *) 0 ; + + arg1 = (firebase::Future< void > *)jarg1; + arg2 = (void *)jarg2; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__FutureT_void_t) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + firebase_Future_Sl_void_Sg__SWIG_FreeCompletionData(arg1,arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_delete_Future_FirestoreVoid(void * jarg1) { + firebase::Future< void > *arg1 = (firebase::Future< void > *) 0 ; + + arg1 = (firebase::Future< void > *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__FutureT_void_t) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + delete arg1; + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_new_Future_LoadBundleTaskProgress() { + void * jresult ; + firebase::Future< firebase::firestore::LoadBundleTaskProgress > *result = 0 ; + + { + try { + result = (firebase::Future< firebase::firestore::LoadBundleTaskProgress > *)new firebase::Future< firebase::firestore::LoadBundleTaskProgress >(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_Future_LoadBundleTaskProgress_SWIG_OnCompletion(void * jarg1, void * jarg2, int jarg3) { + void * jresult ; + firebase::Future< firebase::firestore::LoadBundleTaskProgress > *arg1 = (firebase::Future< firebase::firestore::LoadBundleTaskProgress > *) 0 ; + Future_LoadBundleTaskProgress_CB_Type arg2 ; + int arg3 ; + void *result = 0 ; + + arg1 = (firebase::Future< firebase::firestore::LoadBundleTaskProgress > *)jarg1; + arg2 = (Future_LoadBundleTaskProgress_CB_Type)jarg2; + arg3 = (int)jarg3; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__FutureT_firebase__firestore__LoadBundleTaskProgress_t) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (void *)firebase_Future_Sl_firebase_firestore_LoadBundleTaskProgress_Sg__SWIG_OnCompletion(arg1,arg2,arg3); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_Future_LoadBundleTaskProgress_SWIG_FreeCompletionData(void * jarg1, void * jarg2) { + firebase::Future< firebase::firestore::LoadBundleTaskProgress > *arg1 = (firebase::Future< firebase::firestore::LoadBundleTaskProgress > *) 0 ; + void *arg2 = (void *) 0 ; + + arg1 = (firebase::Future< firebase::firestore::LoadBundleTaskProgress > *)jarg1; + arg2 = (void *)jarg2; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__FutureT_firebase__firestore__LoadBundleTaskProgress_t) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + firebase_Future_Sl_firebase_firestore_LoadBundleTaskProgress_Sg__SWIG_FreeCompletionData(arg1,arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_Future_LoadBundleTaskProgress_GetResult(void * jarg1) { + void * jresult ; + firebase::Future< firebase::firestore::LoadBundleTaskProgress > *arg1 = (firebase::Future< firebase::firestore::LoadBundleTaskProgress > *) 0 ; + firebase::firestore::LoadBundleTaskProgress result; + + arg1 = (firebase::Future< firebase::firestore::LoadBundleTaskProgress > *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__FutureT_firebase__firestore__LoadBundleTaskProgress_t) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = firebase_Future_Sl_firebase_firestore_LoadBundleTaskProgress_Sg__GetResult((firebase::Future< firebase::firestore::LoadBundleTaskProgress > const *)arg1); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::LoadBundleTaskProgress((const firebase::firestore::LoadBundleTaskProgress &)result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_delete_Future_LoadBundleTaskProgress(void * jarg1) { + firebase::Future< firebase::firestore::LoadBundleTaskProgress > *arg1 = (firebase::Future< firebase::firestore::LoadBundleTaskProgress > *) 0 ; + + arg1 = (firebase::Future< firebase::firestore::LoadBundleTaskProgress > *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__FutureT_firebase__firestore__LoadBundleTaskProgress_t) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + delete arg1; + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_new_Future_Query() { + void * jresult ; + firebase::Future< firebase::firestore::Query > *result = 0 ; + + { + try { + result = (firebase::Future< firebase::firestore::Query > *)new firebase::Future< firebase::firestore::Query >(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_Future_Query_SWIG_OnCompletion(void * jarg1, void * jarg2, int jarg3) { + void * jresult ; + firebase::Future< firebase::firestore::Query > *arg1 = (firebase::Future< firebase::firestore::Query > *) 0 ; + Future_Query_CB_Type arg2 ; + int arg3 ; + void *result = 0 ; + + arg1 = (firebase::Future< firebase::firestore::Query > *)jarg1; + arg2 = (Future_Query_CB_Type)jarg2; + arg3 = (int)jarg3; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__FutureT_firebase__firestore__Query_t) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (void *)firebase_Future_Sl_firebase_firestore_Query_Sg__SWIG_OnCompletion(arg1,arg2,arg3); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_Future_Query_SWIG_FreeCompletionData(void * jarg1, void * jarg2) { + firebase::Future< firebase::firestore::Query > *arg1 = (firebase::Future< firebase::firestore::Query > *) 0 ; + void *arg2 = (void *) 0 ; + + arg1 = (firebase::Future< firebase::firestore::Query > *)jarg1; + arg2 = (void *)jarg2; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__FutureT_firebase__firestore__Query_t) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + firebase_Future_Sl_firebase_firestore_Query_Sg__SWIG_FreeCompletionData(arg1,arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_Future_Query_GetResult(void * jarg1) { + void * jresult ; + firebase::Future< firebase::firestore::Query > *arg1 = (firebase::Future< firebase::firestore::Query > *) 0 ; + firebase::firestore::Query result; + + arg1 = (firebase::Future< firebase::firestore::Query > *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__FutureT_firebase__firestore__Query_t) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = firebase_Future_Sl_firebase_firestore_Query_Sg__GetResult((firebase::Future< firebase::firestore::Query > const *)arg1); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::Query((const firebase::firestore::Query &)result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_delete_Future_Query(void * jarg1) { + firebase::Future< firebase::firestore::Query > *arg1 = (firebase::Future< firebase::firestore::Query > *) 0 ; + + arg1 = (firebase::Future< firebase::firestore::Query > *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__FutureT_firebase__firestore__Query_t) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + delete arg1; + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_delete_ListenerRegistrationProxy(void * jarg1) { + firebase::firestore::ListenerRegistration *arg1 = (firebase::firestore::ListenerRegistration *) 0 ; + + arg1 = (firebase::firestore::ListenerRegistration *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__ListenerRegistration) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + delete arg1; + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_ListenerRegistrationProxy_Remove(void * jarg1) { + firebase::firestore::ListenerRegistration *arg1 = (firebase::firestore::ListenerRegistration *) 0 ; + + arg1 = (firebase::firestore::ListenerRegistration *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__ListenerRegistration) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + (arg1)->Remove(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_new_FieldPathProxy(void * jarg1) { + void * jresult ; + std::vector< std::string > *arg1 = 0 ; + firebase::firestore::FieldPath *result = 0 ; + + arg1 = (std::vector< std::string > *)jarg1; + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "std::vector< std::string > const & type is null", 0); + return 0; + } + { + try { + result = (firebase::firestore::FieldPath *)new firebase::firestore::FieldPath((std::vector< std::string > const &)*arg1); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_delete_FieldPathProxy(void * jarg1) { + firebase::firestore::FieldPath *arg1 = (firebase::firestore::FieldPath *) 0 ; + + arg1 = (firebase::firestore::FieldPath *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__FieldPath) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + delete arg1; + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_new_SetOptionsProxy() { + void * jresult ; + firebase::firestore::SetOptions *result = 0 ; + + { + try { + result = (firebase::firestore::SetOptions *)new firebase::firestore::SetOptions(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_delete_SetOptionsProxy(void * jarg1) { + firebase::firestore::SetOptions *arg1 = (firebase::firestore::SetOptions *) 0 ; + + arg1 = (firebase::firestore::SetOptions *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__SetOptions) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + delete arg1; + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_SetOptionsProxy_Merge() { + void * jresult ; + firebase::firestore::SetOptions result; + + { + try { + result = firebase::firestore::SetOptions::Merge(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::SetOptions(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_SetOptionsProxy_MergeFields(void * jarg1) { + void * jresult ; + std::vector< std::string > *arg1 = 0 ; + firebase::firestore::SetOptions result; + + arg1 = (std::vector< std::string > *)jarg1; + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "std::vector< std::string > const & type is null", 0); + return 0; + } + { + try { + result = firebase::firestore::SetOptions::MergeFields((std::vector< std::string > const &)*arg1); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::SetOptions(result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_delete_DocumentReferenceProxy(void * jarg1) { + firebase::firestore::DocumentReference *arg1 = (firebase::firestore::DocumentReference *) 0 ; + + arg1 = (firebase::firestore::DocumentReference *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__DocumentReference) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + delete arg1; + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT char * SWIGSTDCALL Firebase_Firestore_CSharp_DocumentReferenceProxy_id(void * jarg1) { + char * jresult ; + firebase::firestore::DocumentReference *arg1 = (firebase::firestore::DocumentReference *) 0 ; + std::string *result = 0 ; + + arg1 = (firebase::firestore::DocumentReference *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__DocumentReference) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (std::string *) &((firebase::firestore::DocumentReference const *)arg1)->id(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = SWIG_csharp_string_callback(result->c_str()); + return jresult; +} + + +SWIGEXPORT char * SWIGSTDCALL Firebase_Firestore_CSharp_DocumentReferenceProxy_path(void * jarg1) { + char * jresult ; + firebase::firestore::DocumentReference *arg1 = (firebase::firestore::DocumentReference *) 0 ; + std::string result; + + arg1 = (firebase::firestore::DocumentReference *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__DocumentReference) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::DocumentReference const *)arg1)->path(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = SWIG_csharp_string_callback((&result)->c_str()); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_DocumentReferenceProxy_Parent(void * jarg1) { + void * jresult ; + firebase::firestore::DocumentReference *arg1 = (firebase::firestore::DocumentReference *) 0 ; + firebase::firestore::CollectionReference result; + + arg1 = (firebase::firestore::DocumentReference *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__DocumentReference) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::DocumentReference const *)arg1)->Parent(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::CollectionReference(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_DocumentReferenceProxy_Collection__SWIG_0(void * jarg1, char * jarg2) { + void * jresult ; + firebase::firestore::DocumentReference *arg1 = (firebase::firestore::DocumentReference *) 0 ; + char *arg2 = (char *) 0 ; + firebase::firestore::CollectionReference result; + + arg1 = (firebase::firestore::DocumentReference *)jarg1; + arg2 = (char *)jarg2; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__DocumentReference) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::DocumentReference const *)arg1)->Collection((char const *)arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::CollectionReference(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_DocumentReferenceProxy_Get__SWIG_0(void * jarg1, int jarg2) { + void * jresult ; + firebase::firestore::DocumentReference *arg1 = (firebase::firestore::DocumentReference *) 0 ; + firebase::firestore::Source arg2 ; + firebase::Future< firebase::firestore::DocumentSnapshot > result; + + arg1 = (firebase::firestore::DocumentReference *)jarg1; + arg2 = (firebase::firestore::Source)jarg2; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__DocumentReference) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::DocumentReference const *)arg1)->Get(arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::Future< firebase::firestore::DocumentSnapshot >(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_DocumentReferenceProxy_Get__SWIG_1(void * jarg1) { + void * jresult ; + firebase::firestore::DocumentReference *arg1 = (firebase::firestore::DocumentReference *) 0 ; + firebase::Future< firebase::firestore::DocumentSnapshot > result; + + arg1 = (firebase::firestore::DocumentReference *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__DocumentReference) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::DocumentReference const *)arg1)->Get(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::Future< firebase::firestore::DocumentSnapshot >(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_DocumentReferenceProxy_Delete(void * jarg1) { + void * jresult ; + firebase::firestore::DocumentReference *arg1 = (firebase::firestore::DocumentReference *) 0 ; + firebase::Future< void > result; + + arg1 = (firebase::firestore::DocumentReference *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__DocumentReference) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (arg1)->Delete(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::Future< void >(result); + return jresult; +} + + +SWIGEXPORT unsigned int SWIGSTDCALL Firebase_Firestore_CSharp_DocumentReferenceProxy_is_valid(void * jarg1) { + unsigned int jresult ; + firebase::firestore::DocumentReference *arg1 = (firebase::firestore::DocumentReference *) 0 ; + bool result; + + arg1 = (firebase::firestore::DocumentReference *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__DocumentReference) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (bool)((firebase::firestore::DocumentReference const *)arg1)->is_valid(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_new_SnapshotMetadataProxy__SWIG_0() { + void * jresult ; + firebase::firestore::SnapshotMetadata *result = 0 ; + + { + try { + result = (firebase::firestore::SnapshotMetadata *)new firebase::firestore::SnapshotMetadata(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_new_SnapshotMetadataProxy__SWIG_1(unsigned int jarg1, unsigned int jarg2) { + void * jresult ; + bool arg1 ; + bool arg2 ; + firebase::firestore::SnapshotMetadata *result = 0 ; + + arg1 = jarg1 ? true : false; + arg2 = jarg2 ? true : false; + { + try { + result = (firebase::firestore::SnapshotMetadata *)new firebase::firestore::SnapshotMetadata(arg1,arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_new_SnapshotMetadataProxy__SWIG_2(void * jarg1) { + void * jresult ; + firebase::firestore::SnapshotMetadata *arg1 = 0 ; + firebase::firestore::SnapshotMetadata *result = 0 ; + + arg1 = (firebase::firestore::SnapshotMetadata *)jarg1; + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::SnapshotMetadata const & type is null", 0); + return 0; + } + { + try { + result = (firebase::firestore::SnapshotMetadata *)new firebase::firestore::SnapshotMetadata((firebase::firestore::SnapshotMetadata const &)*arg1); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT unsigned int SWIGSTDCALL Firebase_Firestore_CSharp_SnapshotMetadataProxy_has_pending_writes(void * jarg1) { + unsigned int jresult ; + firebase::firestore::SnapshotMetadata *arg1 = (firebase::firestore::SnapshotMetadata *) 0 ; + bool result; + + arg1 = (firebase::firestore::SnapshotMetadata *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__SnapshotMetadata) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (bool)((firebase::firestore::SnapshotMetadata const *)arg1)->has_pending_writes(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = result; + return jresult; +} + + +SWIGEXPORT unsigned int SWIGSTDCALL Firebase_Firestore_CSharp_SnapshotMetadataProxy_is_from_cache(void * jarg1) { + unsigned int jresult ; + firebase::firestore::SnapshotMetadata *arg1 = (firebase::firestore::SnapshotMetadata *) 0 ; + bool result; + + arg1 = (firebase::firestore::SnapshotMetadata *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__SnapshotMetadata) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (bool)((firebase::firestore::SnapshotMetadata const *)arg1)->is_from_cache(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = result; + return jresult; +} + + +SWIGEXPORT char * SWIGSTDCALL Firebase_Firestore_CSharp_SnapshotMetadataProxy_ToString(void * jarg1) { + char * jresult ; + firebase::firestore::SnapshotMetadata *arg1 = (firebase::firestore::SnapshotMetadata *) 0 ; + std::string result; + + arg1 = (firebase::firestore::SnapshotMetadata *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__SnapshotMetadata) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::SnapshotMetadata const *)arg1)->ToString(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = SWIG_csharp_string_callback((&result)->c_str()); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_delete_SnapshotMetadataProxy(void * jarg1) { + firebase::firestore::SnapshotMetadata *arg1 = (firebase::firestore::SnapshotMetadata *) 0 ; + + arg1 = (firebase::firestore::SnapshotMetadata *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__SnapshotMetadata) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + delete arg1; + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_delete_DocumentSnapshotProxy(void * jarg1) { + firebase::firestore::DocumentSnapshot *arg1 = (firebase::firestore::DocumentSnapshot *) 0 ; + + arg1 = (firebase::firestore::DocumentSnapshot *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__DocumentSnapshot) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + delete arg1; + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT char * SWIGSTDCALL Firebase_Firestore_CSharp_DocumentSnapshotProxy_id(void * jarg1) { + char * jresult ; + firebase::firestore::DocumentSnapshot *arg1 = (firebase::firestore::DocumentSnapshot *) 0 ; + std::string *result = 0 ; + + arg1 = (firebase::firestore::DocumentSnapshot *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__DocumentSnapshot) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (std::string *) &((firebase::firestore::DocumentSnapshot const *)arg1)->id(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = SWIG_csharp_string_callback(result->c_str()); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_DocumentSnapshotProxy_reference(void * jarg1) { + void * jresult ; + firebase::firestore::DocumentSnapshot *arg1 = (firebase::firestore::DocumentSnapshot *) 0 ; + firebase::firestore::DocumentReference result; + + arg1 = (firebase::firestore::DocumentSnapshot *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__DocumentSnapshot) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::DocumentSnapshot const *)arg1)->reference(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::DocumentReference(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_DocumentSnapshotProxy_metadata(void * jarg1) { + void * jresult ; + firebase::firestore::DocumentSnapshot *arg1 = (firebase::firestore::DocumentSnapshot *) 0 ; + firebase::firestore::SnapshotMetadata result; + + arg1 = (firebase::firestore::DocumentSnapshot *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__DocumentSnapshot) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::DocumentSnapshot const *)arg1)->metadata(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::SnapshotMetadata(result); + return jresult; +} + + +SWIGEXPORT unsigned int SWIGSTDCALL Firebase_Firestore_CSharp_DocumentSnapshotProxy_exists(void * jarg1) { + unsigned int jresult ; + firebase::firestore::DocumentSnapshot *arg1 = (firebase::firestore::DocumentSnapshot *) 0 ; + bool result; + + arg1 = (firebase::firestore::DocumentSnapshot *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__DocumentSnapshot) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (bool)((firebase::firestore::DocumentSnapshot const *)arg1)->exists(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_DocumentSnapshotProxy_Get__SWIG_0(void * jarg1, char * jarg2, int jarg3) { + void * jresult ; + firebase::firestore::DocumentSnapshot *arg1 = (firebase::firestore::DocumentSnapshot *) 0 ; + char *arg2 = (char *) 0 ; + firebase::firestore::DocumentSnapshot::ServerTimestampBehavior arg3 ; + firebase::firestore::FieldValue result; + + arg1 = (firebase::firestore::DocumentSnapshot *)jarg1; + arg2 = (char *)jarg2; + arg3 = (firebase::firestore::DocumentSnapshot::ServerTimestampBehavior)jarg3; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__DocumentSnapshot) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::DocumentSnapshot const *)arg1)->Get((char const *)arg2,arg3); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::FieldValue(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_DocumentSnapshotProxy_Get__SWIG_1(void * jarg1, char * jarg2) { + void * jresult ; + firebase::firestore::DocumentSnapshot *arg1 = (firebase::firestore::DocumentSnapshot *) 0 ; + char *arg2 = (char *) 0 ; + firebase::firestore::FieldValue result; + + arg1 = (firebase::firestore::DocumentSnapshot *)jarg1; + arg2 = (char *)jarg2; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__DocumentSnapshot) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::DocumentSnapshot const *)arg1)->Get((char const *)arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::FieldValue(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_DocumentSnapshotProxy_Get__SWIG_4(void * jarg1, void * jarg2, int jarg3) { + void * jresult ; + firebase::firestore::DocumentSnapshot *arg1 = (firebase::firestore::DocumentSnapshot *) 0 ; + firebase::firestore::FieldPath *arg2 = 0 ; + firebase::firestore::DocumentSnapshot::ServerTimestampBehavior arg3 ; + firebase::firestore::FieldValue result; + + arg1 = (firebase::firestore::DocumentSnapshot *)jarg1; + arg2 = (firebase::firestore::FieldPath *)jarg2; + if (!arg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldPath const & type is null", 0); + return 0; + } + arg3 = (firebase::firestore::DocumentSnapshot::ServerTimestampBehavior)jarg3; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__DocumentSnapshot) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::DocumentSnapshot const *)arg1)->Get((firebase::firestore::FieldPath const &)*arg2,arg3); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::FieldValue(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_DocumentSnapshotProxy_Get__SWIG_5(void * jarg1, void * jarg2) { + void * jresult ; + firebase::firestore::DocumentSnapshot *arg1 = (firebase::firestore::DocumentSnapshot *) 0 ; + firebase::firestore::FieldPath *arg2 = 0 ; + firebase::firestore::FieldValue result; + + arg1 = (firebase::firestore::DocumentSnapshot *)jarg1; + arg2 = (firebase::firestore::FieldPath *)jarg2; + if (!arg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldPath const & type is null", 0); + return 0; + } + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__DocumentSnapshot) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::DocumentSnapshot const *)arg1)->Get((firebase::firestore::FieldPath const &)*arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::FieldValue(result); + return jresult; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL Firebase_Firestore_CSharp_DocumentChangeProxy_npos_get() { + unsigned long jresult ; + std::size_t result; + + result = firebase::firestore::DocumentChange::npos; + jresult = (unsigned long)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_delete_DocumentChangeProxy(void * jarg1) { + firebase::firestore::DocumentChange *arg1 = (firebase::firestore::DocumentChange *) 0 ; + + arg1 = (firebase::firestore::DocumentChange *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__DocumentChange) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + delete arg1; + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT int SWIGSTDCALL Firebase_Firestore_CSharp_DocumentChangeProxy_type(void * jarg1) { + int jresult ; + firebase::firestore::DocumentChange *arg1 = (firebase::firestore::DocumentChange *) 0 ; + firebase::firestore::DocumentChange::Type result; + + arg1 = (firebase::firestore::DocumentChange *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__DocumentChange) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (firebase::firestore::DocumentChange::Type)((firebase::firestore::DocumentChange const *)arg1)->type(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (int)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_DocumentChangeProxy_document(void * jarg1) { + void * jresult ; + firebase::firestore::DocumentChange *arg1 = (firebase::firestore::DocumentChange *) 0 ; + firebase::firestore::DocumentSnapshot result; + + arg1 = (firebase::firestore::DocumentChange *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__DocumentChange) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::DocumentChange const *)arg1)->document(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::DocumentSnapshot(result); + return jresult; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL Firebase_Firestore_CSharp_DocumentChangeProxy_old_index(void * jarg1) { + unsigned long jresult ; + firebase::firestore::DocumentChange *arg1 = (firebase::firestore::DocumentChange *) 0 ; + std::size_t result; + + arg1 = (firebase::firestore::DocumentChange *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__DocumentChange) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::DocumentChange const *)arg1)->old_index(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (unsigned long)result; + return jresult; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL Firebase_Firestore_CSharp_DocumentChangeProxy_new_index(void * jarg1) { + unsigned long jresult ; + firebase::firestore::DocumentChange *arg1 = (firebase::firestore::DocumentChange *) 0 ; + std::size_t result; + + arg1 = (firebase::firestore::DocumentChange *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__DocumentChange) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::DocumentChange const *)arg1)->new_index(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (unsigned long)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_delete_FieldValueProxy(void * jarg1) { + firebase::firestore::FieldValue *arg1 = (firebase::firestore::FieldValue *) 0 ; + + arg1 = (firebase::firestore::FieldValue *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__FieldValue) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + delete arg1; + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_FieldValueProxy_Boolean(unsigned int jarg1) { + void * jresult ; + bool arg1 ; + firebase::firestore::FieldValue result; + + arg1 = jarg1 ? true : false; + { + try { + result = firebase::firestore::FieldValue::Boolean(arg1); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::FieldValue(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_FieldValueProxy_Integer(long long jarg1) { + void * jresult ; + int64_t arg1 ; + firebase::firestore::FieldValue result; + + arg1 = (int64_t)jarg1; + { + try { + result = firebase::firestore::FieldValue::Integer(arg1); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::FieldValue(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_FieldValueProxy_Double(double jarg1) { + void * jresult ; + double arg1 ; + firebase::firestore::FieldValue result; + + arg1 = (double)jarg1; + { + try { + result = firebase::firestore::FieldValue::Double(arg1); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::FieldValue(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_FieldValueProxy_Timestamp(void * jarg1) { + void * jresult ; + firebase::Timestamp arg1 ; + firebase::Timestamp *argp1 ; + firebase::firestore::FieldValue result; + + argp1 = (firebase::Timestamp *)jarg1; + if (!argp1) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null firebase::Timestamp", 0); + return 0; + } + arg1 = *argp1; + { + try { + result = firebase::firestore::FieldValue::Timestamp(arg1); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::FieldValue(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_FieldValueProxy_String(char * jarg1) { + void * jresult ; + std::string arg1 ; + firebase::firestore::FieldValue result; + + if (!jarg1) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0); + return 0; + } + (&arg1)->assign(jarg1); + { + try { + result = firebase::firestore::FieldValue::String(arg1); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::FieldValue(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_FieldValueProxy_Blob(void * jarg1, unsigned long jarg2) { + void * jresult ; + uint8_t *arg1 = (uint8_t *) 0 ; + size_t arg2 ; + firebase::firestore::FieldValue result; + + arg1 = (uint8_t *)jarg1; + arg2 = (size_t)jarg2; + { + try { + result = firebase::firestore::FieldValue::Blob((unsigned char const *)arg1,arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::FieldValue(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_FieldValueProxy_Reference(void * jarg1) { + void * jresult ; + firebase::firestore::DocumentReference arg1 ; + firebase::firestore::DocumentReference *argp1 ; + firebase::firestore::FieldValue result; + + argp1 = (firebase::firestore::DocumentReference *)jarg1; + if (!argp1) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null firebase::firestore::DocumentReference", 0); + return 0; + } + arg1 = *argp1; + { + try { + result = firebase::firestore::FieldValue::Reference(arg1); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::FieldValue(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_FieldValueProxy_GeoPoint(void * jarg1) { + void * jresult ; + firebase::firestore::GeoPoint arg1 ; + firebase::firestore::GeoPoint *argp1 ; + firebase::firestore::FieldValue result; + + argp1 = (firebase::firestore::GeoPoint *)jarg1; + if (!argp1) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null firebase::firestore::GeoPoint", 0); + return 0; + } + arg1 = *argp1; + { + try { + result = firebase::firestore::FieldValue::GeoPoint(arg1); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::FieldValue(result); + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL Firebase_Firestore_CSharp_FieldValueProxy_type(void * jarg1) { + int jresult ; + firebase::firestore::FieldValue *arg1 = (firebase::firestore::FieldValue *) 0 ; + firebase::firestore::FieldValue::Type result; + + arg1 = (firebase::firestore::FieldValue *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__FieldValue) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (firebase::firestore::FieldValue::Type)((firebase::firestore::FieldValue const *)arg1)->type(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (int)result; + return jresult; +} + + +SWIGEXPORT unsigned int SWIGSTDCALL Firebase_Firestore_CSharp_FieldValueProxy_is_null(void * jarg1) { + unsigned int jresult ; + firebase::firestore::FieldValue *arg1 = (firebase::firestore::FieldValue *) 0 ; + bool result; + + arg1 = (firebase::firestore::FieldValue *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__FieldValue) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (bool)((firebase::firestore::FieldValue const *)arg1)->is_null(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = result; + return jresult; +} + + +SWIGEXPORT unsigned int SWIGSTDCALL Firebase_Firestore_CSharp_FieldValueProxy_is_array(void * jarg1) { + unsigned int jresult ; + firebase::firestore::FieldValue *arg1 = (firebase::firestore::FieldValue *) 0 ; + bool result; + + arg1 = (firebase::firestore::FieldValue *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__FieldValue) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (bool)((firebase::firestore::FieldValue const *)arg1)->is_array(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = result; + return jresult; +} + + +SWIGEXPORT unsigned int SWIGSTDCALL Firebase_Firestore_CSharp_FieldValueProxy_is_map(void * jarg1) { + unsigned int jresult ; + firebase::firestore::FieldValue *arg1 = (firebase::firestore::FieldValue *) 0 ; + bool result; + + arg1 = (firebase::firestore::FieldValue *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__FieldValue) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (bool)((firebase::firestore::FieldValue const *)arg1)->is_map(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = result; + return jresult; +} + + +SWIGEXPORT unsigned int SWIGSTDCALL Firebase_Firestore_CSharp_FieldValueProxy_boolean_value(void * jarg1) { + unsigned int jresult ; + firebase::firestore::FieldValue *arg1 = (firebase::firestore::FieldValue *) 0 ; + bool result; + + arg1 = (firebase::firestore::FieldValue *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__FieldValue) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (bool)((firebase::firestore::FieldValue const *)arg1)->boolean_value(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = result; + return jresult; +} + + +SWIGEXPORT long long SWIGSTDCALL Firebase_Firestore_CSharp_FieldValueProxy_integer_value(void * jarg1) { + long long jresult ; + firebase::firestore::FieldValue *arg1 = (firebase::firestore::FieldValue *) 0 ; + int64_t result; + + arg1 = (firebase::firestore::FieldValue *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__FieldValue) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (int64_t)((firebase::firestore::FieldValue const *)arg1)->integer_value(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = result; + return jresult; +} + + +SWIGEXPORT double SWIGSTDCALL Firebase_Firestore_CSharp_FieldValueProxy_double_value(void * jarg1) { + double jresult ; + firebase::firestore::FieldValue *arg1 = (firebase::firestore::FieldValue *) 0 ; + double result; + + arg1 = (firebase::firestore::FieldValue *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__FieldValue) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (double)((firebase::firestore::FieldValue const *)arg1)->double_value(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_FieldValueProxy_timestamp_value(void * jarg1) { + void * jresult ; + firebase::firestore::FieldValue *arg1 = (firebase::firestore::FieldValue *) 0 ; + firebase::Timestamp result; + + arg1 = (firebase::firestore::FieldValue *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__FieldValue) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::FieldValue const *)arg1)->timestamp_value(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::Timestamp(result); + return jresult; +} + + +SWIGEXPORT char * SWIGSTDCALL Firebase_Firestore_CSharp_FieldValueProxy_string_value(void * jarg1) { + char * jresult ; + firebase::firestore::FieldValue *arg1 = (firebase::firestore::FieldValue *) 0 ; + std::string result; + + arg1 = (firebase::firestore::FieldValue *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__FieldValue) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::FieldValue const *)arg1)->string_value(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = SWIG_csharp_string_callback((&result)->c_str()); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_FieldValueProxy_blob_value(void * jarg1) { + void * jresult ; + firebase::firestore::FieldValue *arg1 = (firebase::firestore::FieldValue *) 0 ; + uint8_t *result = 0 ; + + arg1 = (firebase::firestore::FieldValue *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__FieldValue) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (uint8_t *)((firebase::firestore::FieldValue const *)arg1)->blob_value(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL Firebase_Firestore_CSharp_FieldValueProxy_blob_size(void * jarg1) { + unsigned long jresult ; + firebase::firestore::FieldValue *arg1 = (firebase::firestore::FieldValue *) 0 ; + size_t result; + + arg1 = (firebase::firestore::FieldValue *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__FieldValue) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::FieldValue const *)arg1)->blob_size(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (unsigned long)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_FieldValueProxy_reference_value(void * jarg1) { + void * jresult ; + firebase::firestore::FieldValue *arg1 = (firebase::firestore::FieldValue *) 0 ; + firebase::firestore::DocumentReference result; + + arg1 = (firebase::firestore::FieldValue *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__FieldValue) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::FieldValue const *)arg1)->reference_value(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::DocumentReference(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_FieldValueProxy_geo_point_value(void * jarg1) { + void * jresult ; + firebase::firestore::FieldValue *arg1 = (firebase::firestore::FieldValue *) 0 ; + firebase::firestore::GeoPoint result; + + arg1 = (firebase::firestore::FieldValue *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__FieldValue) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::FieldValue const *)arg1)->geo_point_value(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::GeoPoint(result); + return jresult; +} + + +SWIGEXPORT unsigned int SWIGSTDCALL Firebase_Firestore_CSharp_FieldValueProxy_is_valid(void * jarg1) { + unsigned int jresult ; + firebase::firestore::FieldValue *arg1 = (firebase::firestore::FieldValue *) 0 ; + bool result; + + arg1 = (firebase::firestore::FieldValue *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__FieldValue) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (bool)((firebase::firestore::FieldValue const *)arg1)->is_valid(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_FieldValueProxy_Null() { + void * jresult ; + firebase::firestore::FieldValue result; + + { + try { + result = firebase::firestore::FieldValue::Null(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::FieldValue(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_FieldValueProxy_Delete() { + void * jresult ; + firebase::firestore::FieldValue result; + + { + try { + result = firebase::firestore::FieldValue::Delete(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::FieldValue(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_FieldValueProxy_ServerTimestamp() { + void * jresult ; + firebase::firestore::FieldValue result; + + { + try { + result = firebase::firestore::FieldValue::ServerTimestamp(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::FieldValue(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_FieldValueProxy_IntegerIncrement(long long jarg1) { + void * jresult ; + long long arg1 ; + firebase::firestore::FieldValue result; + + arg1 = (long long)jarg1; + { + try { + result = firebase::firestore::FieldValue::SWIGTEMPLATEDISAMBIGUATOR Increment< int64_t,0 >(arg1); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::FieldValue(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_FieldValueProxy_DoubleIncrement(double jarg1) { + void * jresult ; + double arg1 ; + firebase::firestore::FieldValue result; + + arg1 = (double)jarg1; + { + try { + result = firebase::firestore::FieldValue::SWIGTEMPLATEDISAMBIGUATOR Increment< double,0 >(arg1); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::FieldValue(result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_delete_WriteBatchProxy(void * jarg1) { + firebase::firestore::WriteBatch *arg1 = (firebase::firestore::WriteBatch *) 0 ; + + arg1 = (firebase::firestore::WriteBatch *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__WriteBatch) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + delete arg1; + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_WriteBatchProxy_Delete(void * jarg1, void * jarg2) { + void * jresult ; + firebase::firestore::WriteBatch *arg1 = (firebase::firestore::WriteBatch *) 0 ; + firebase::firestore::DocumentReference *arg2 = 0 ; + firebase::firestore::WriteBatch *result = 0 ; + + arg1 = (firebase::firestore::WriteBatch *)jarg1; + arg2 = (firebase::firestore::DocumentReference *)jarg2; + if (!arg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::DocumentReference const & type is null", 0); + return 0; + } + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__WriteBatch) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (firebase::firestore::WriteBatch *) &(arg1)->Delete((firebase::firestore::DocumentReference const &)*arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_WriteBatchProxy_Commit(void * jarg1) { + void * jresult ; + firebase::firestore::WriteBatch *arg1 = (firebase::firestore::WriteBatch *) 0 ; + firebase::Future< void > result; + + arg1 = (firebase::firestore::WriteBatch *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__WriteBatch) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (arg1)->Commit(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::Future< void >(result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_delete_QueryProxy(void * jarg1) { + firebase::firestore::Query *arg1 = (firebase::firestore::Query *) 0 ; + + arg1 = (firebase::firestore::Query *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Query) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + delete arg1; + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_QueryProxy_WhereEqualTo__SWIG_0(void * jarg1, char * jarg2, void * jarg3) { + void * jresult ; + firebase::firestore::Query *arg1 = (firebase::firestore::Query *) 0 ; + std::string *arg2 = 0 ; + firebase::firestore::FieldValue *arg3 = 0 ; + firebase::firestore::Query result; + + arg1 = (firebase::firestore::Query *)jarg1; + if (!jarg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0); + return 0; + } + std::string arg2_str(jarg2); + arg2 = &arg2_str; + arg3 = (firebase::firestore::FieldValue *)jarg3; + if (!arg3) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldValue const & type is null", 0); + return 0; + } + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Query) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::Query const *)arg1)->WhereEqualTo((std::string const &)*arg2,(firebase::firestore::FieldValue const &)*arg3); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::Query(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_QueryProxy_WhereEqualTo__SWIG_1(void * jarg1, void * jarg2, void * jarg3) { + void * jresult ; + firebase::firestore::Query *arg1 = (firebase::firestore::Query *) 0 ; + firebase::firestore::FieldPath *arg2 = 0 ; + firebase::firestore::FieldValue *arg3 = 0 ; + firebase::firestore::Query result; + + arg1 = (firebase::firestore::Query *)jarg1; + arg2 = (firebase::firestore::FieldPath *)jarg2; + if (!arg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldPath const & type is null", 0); + return 0; + } + arg3 = (firebase::firestore::FieldValue *)jarg3; + if (!arg3) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldValue const & type is null", 0); + return 0; + } + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Query) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::Query const *)arg1)->WhereEqualTo((firebase::firestore::FieldPath const &)*arg2,(firebase::firestore::FieldValue const &)*arg3); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::Query(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_QueryProxy_WhereNotEqualTo__SWIG_0(void * jarg1, char * jarg2, void * jarg3) { + void * jresult ; + firebase::firestore::Query *arg1 = (firebase::firestore::Query *) 0 ; + std::string *arg2 = 0 ; + firebase::firestore::FieldValue *arg3 = 0 ; + firebase::firestore::Query result; + + arg1 = (firebase::firestore::Query *)jarg1; + if (!jarg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0); + return 0; + } + std::string arg2_str(jarg2); + arg2 = &arg2_str; + arg3 = (firebase::firestore::FieldValue *)jarg3; + if (!arg3) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldValue const & type is null", 0); + return 0; + } + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Query) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::Query const *)arg1)->WhereNotEqualTo((std::string const &)*arg2,(firebase::firestore::FieldValue const &)*arg3); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::Query(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_QueryProxy_WhereNotEqualTo__SWIG_1(void * jarg1, void * jarg2, void * jarg3) { + void * jresult ; + firebase::firestore::Query *arg1 = (firebase::firestore::Query *) 0 ; + firebase::firestore::FieldPath *arg2 = 0 ; + firebase::firestore::FieldValue *arg3 = 0 ; + firebase::firestore::Query result; + + arg1 = (firebase::firestore::Query *)jarg1; + arg2 = (firebase::firestore::FieldPath *)jarg2; + if (!arg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldPath const & type is null", 0); + return 0; + } + arg3 = (firebase::firestore::FieldValue *)jarg3; + if (!arg3) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldValue const & type is null", 0); + return 0; + } + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Query) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::Query const *)arg1)->WhereNotEqualTo((firebase::firestore::FieldPath const &)*arg2,(firebase::firestore::FieldValue const &)*arg3); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::Query(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_QueryProxy_WhereLessThan__SWIG_0(void * jarg1, char * jarg2, void * jarg3) { + void * jresult ; + firebase::firestore::Query *arg1 = (firebase::firestore::Query *) 0 ; + std::string *arg2 = 0 ; + firebase::firestore::FieldValue *arg3 = 0 ; + firebase::firestore::Query result; + + arg1 = (firebase::firestore::Query *)jarg1; + if (!jarg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0); + return 0; + } + std::string arg2_str(jarg2); + arg2 = &arg2_str; + arg3 = (firebase::firestore::FieldValue *)jarg3; + if (!arg3) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldValue const & type is null", 0); + return 0; + } + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Query) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::Query const *)arg1)->WhereLessThan((std::string const &)*arg2,(firebase::firestore::FieldValue const &)*arg3); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::Query(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_QueryProxy_WhereLessThan__SWIG_1(void * jarg1, void * jarg2, void * jarg3) { + void * jresult ; + firebase::firestore::Query *arg1 = (firebase::firestore::Query *) 0 ; + firebase::firestore::FieldPath *arg2 = 0 ; + firebase::firestore::FieldValue *arg3 = 0 ; + firebase::firestore::Query result; + + arg1 = (firebase::firestore::Query *)jarg1; + arg2 = (firebase::firestore::FieldPath *)jarg2; + if (!arg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldPath const & type is null", 0); + return 0; + } + arg3 = (firebase::firestore::FieldValue *)jarg3; + if (!arg3) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldValue const & type is null", 0); + return 0; + } + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Query) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::Query const *)arg1)->WhereLessThan((firebase::firestore::FieldPath const &)*arg2,(firebase::firestore::FieldValue const &)*arg3); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::Query(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_QueryProxy_WhereLessThanOrEqualTo__SWIG_0(void * jarg1, char * jarg2, void * jarg3) { + void * jresult ; + firebase::firestore::Query *arg1 = (firebase::firestore::Query *) 0 ; + std::string *arg2 = 0 ; + firebase::firestore::FieldValue *arg3 = 0 ; + firebase::firestore::Query result; + + arg1 = (firebase::firestore::Query *)jarg1; + if (!jarg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0); + return 0; + } + std::string arg2_str(jarg2); + arg2 = &arg2_str; + arg3 = (firebase::firestore::FieldValue *)jarg3; + if (!arg3) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldValue const & type is null", 0); + return 0; + } + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Query) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::Query const *)arg1)->WhereLessThanOrEqualTo((std::string const &)*arg2,(firebase::firestore::FieldValue const &)*arg3); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::Query(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_QueryProxy_WhereLessThanOrEqualTo__SWIG_1(void * jarg1, void * jarg2, void * jarg3) { + void * jresult ; + firebase::firestore::Query *arg1 = (firebase::firestore::Query *) 0 ; + firebase::firestore::FieldPath *arg2 = 0 ; + firebase::firestore::FieldValue *arg3 = 0 ; + firebase::firestore::Query result; + + arg1 = (firebase::firestore::Query *)jarg1; + arg2 = (firebase::firestore::FieldPath *)jarg2; + if (!arg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldPath const & type is null", 0); + return 0; + } + arg3 = (firebase::firestore::FieldValue *)jarg3; + if (!arg3) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldValue const & type is null", 0); + return 0; + } + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Query) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::Query const *)arg1)->WhereLessThanOrEqualTo((firebase::firestore::FieldPath const &)*arg2,(firebase::firestore::FieldValue const &)*arg3); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::Query(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_QueryProxy_WhereGreaterThan__SWIG_0(void * jarg1, char * jarg2, void * jarg3) { + void * jresult ; + firebase::firestore::Query *arg1 = (firebase::firestore::Query *) 0 ; + std::string *arg2 = 0 ; + firebase::firestore::FieldValue *arg3 = 0 ; + firebase::firestore::Query result; + + arg1 = (firebase::firestore::Query *)jarg1; + if (!jarg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0); + return 0; + } + std::string arg2_str(jarg2); + arg2 = &arg2_str; + arg3 = (firebase::firestore::FieldValue *)jarg3; + if (!arg3) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldValue const & type is null", 0); + return 0; + } + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Query) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::Query const *)arg1)->WhereGreaterThan((std::string const &)*arg2,(firebase::firestore::FieldValue const &)*arg3); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::Query(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_QueryProxy_WhereGreaterThan__SWIG_1(void * jarg1, void * jarg2, void * jarg3) { + void * jresult ; + firebase::firestore::Query *arg1 = (firebase::firestore::Query *) 0 ; + firebase::firestore::FieldPath *arg2 = 0 ; + firebase::firestore::FieldValue *arg3 = 0 ; + firebase::firestore::Query result; + + arg1 = (firebase::firestore::Query *)jarg1; + arg2 = (firebase::firestore::FieldPath *)jarg2; + if (!arg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldPath const & type is null", 0); + return 0; + } + arg3 = (firebase::firestore::FieldValue *)jarg3; + if (!arg3) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldValue const & type is null", 0); + return 0; + } + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Query) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::Query const *)arg1)->WhereGreaterThan((firebase::firestore::FieldPath const &)*arg2,(firebase::firestore::FieldValue const &)*arg3); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::Query(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_QueryProxy_WhereGreaterThanOrEqualTo__SWIG_0(void * jarg1, char * jarg2, void * jarg3) { + void * jresult ; + firebase::firestore::Query *arg1 = (firebase::firestore::Query *) 0 ; + std::string *arg2 = 0 ; + firebase::firestore::FieldValue *arg3 = 0 ; + firebase::firestore::Query result; + + arg1 = (firebase::firestore::Query *)jarg1; + if (!jarg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0); + return 0; + } + std::string arg2_str(jarg2); + arg2 = &arg2_str; + arg3 = (firebase::firestore::FieldValue *)jarg3; + if (!arg3) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldValue const & type is null", 0); + return 0; + } + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Query) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::Query const *)arg1)->WhereGreaterThanOrEqualTo((std::string const &)*arg2,(firebase::firestore::FieldValue const &)*arg3); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::Query(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_QueryProxy_WhereGreaterThanOrEqualTo__SWIG_1(void * jarg1, void * jarg2, void * jarg3) { + void * jresult ; + firebase::firestore::Query *arg1 = (firebase::firestore::Query *) 0 ; + firebase::firestore::FieldPath *arg2 = 0 ; + firebase::firestore::FieldValue *arg3 = 0 ; + firebase::firestore::Query result; + + arg1 = (firebase::firestore::Query *)jarg1; + arg2 = (firebase::firestore::FieldPath *)jarg2; + if (!arg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldPath const & type is null", 0); + return 0; + } + arg3 = (firebase::firestore::FieldValue *)jarg3; + if (!arg3) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldValue const & type is null", 0); + return 0; + } + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Query) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::Query const *)arg1)->WhereGreaterThanOrEqualTo((firebase::firestore::FieldPath const &)*arg2,(firebase::firestore::FieldValue const &)*arg3); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::Query(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_QueryProxy_WhereArrayContains__SWIG_0(void * jarg1, char * jarg2, void * jarg3) { + void * jresult ; + firebase::firestore::Query *arg1 = (firebase::firestore::Query *) 0 ; + std::string *arg2 = 0 ; + firebase::firestore::FieldValue *arg3 = 0 ; + firebase::firestore::Query result; + + arg1 = (firebase::firestore::Query *)jarg1; + if (!jarg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0); + return 0; + } + std::string arg2_str(jarg2); + arg2 = &arg2_str; + arg3 = (firebase::firestore::FieldValue *)jarg3; + if (!arg3) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldValue const & type is null", 0); + return 0; + } + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Query) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::Query const *)arg1)->WhereArrayContains((std::string const &)*arg2,(firebase::firestore::FieldValue const &)*arg3); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::Query(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_QueryProxy_WhereArrayContains__SWIG_1(void * jarg1, void * jarg2, void * jarg3) { + void * jresult ; + firebase::firestore::Query *arg1 = (firebase::firestore::Query *) 0 ; + firebase::firestore::FieldPath *arg2 = 0 ; + firebase::firestore::FieldValue *arg3 = 0 ; + firebase::firestore::Query result; + + arg1 = (firebase::firestore::Query *)jarg1; + arg2 = (firebase::firestore::FieldPath *)jarg2; + if (!arg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldPath const & type is null", 0); + return 0; + } + arg3 = (firebase::firestore::FieldValue *)jarg3; + if (!arg3) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldValue const & type is null", 0); + return 0; + } + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Query) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::Query const *)arg1)->WhereArrayContains((firebase::firestore::FieldPath const &)*arg2,(firebase::firestore::FieldValue const &)*arg3); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::Query(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_QueryProxy_OrderBy__SWIG_0(void * jarg1, char * jarg2, int jarg3) { + void * jresult ; + firebase::firestore::Query *arg1 = (firebase::firestore::Query *) 0 ; + std::string *arg2 = 0 ; + firebase::firestore::Query::Direction arg3 ; + firebase::firestore::Query result; + + arg1 = (firebase::firestore::Query *)jarg1; + if (!jarg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0); + return 0; + } + std::string arg2_str(jarg2); + arg2 = &arg2_str; + arg3 = (firebase::firestore::Query::Direction)jarg3; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Query) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::Query const *)arg1)->OrderBy((std::string const &)*arg2,arg3); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::Query(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_QueryProxy_OrderBy__SWIG_1(void * jarg1, char * jarg2) { + void * jresult ; + firebase::firestore::Query *arg1 = (firebase::firestore::Query *) 0 ; + std::string *arg2 = 0 ; + firebase::firestore::Query result; + + arg1 = (firebase::firestore::Query *)jarg1; + if (!jarg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0); + return 0; + } + std::string arg2_str(jarg2); + arg2 = &arg2_str; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Query) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::Query const *)arg1)->OrderBy((std::string const &)*arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::Query(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_QueryProxy_OrderBy__SWIG_2(void * jarg1, void * jarg2, int jarg3) { + void * jresult ; + firebase::firestore::Query *arg1 = (firebase::firestore::Query *) 0 ; + firebase::firestore::FieldPath *arg2 = 0 ; + firebase::firestore::Query::Direction arg3 ; + firebase::firestore::Query result; + + arg1 = (firebase::firestore::Query *)jarg1; + arg2 = (firebase::firestore::FieldPath *)jarg2; + if (!arg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldPath const & type is null", 0); + return 0; + } + arg3 = (firebase::firestore::Query::Direction)jarg3; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Query) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::Query const *)arg1)->OrderBy((firebase::firestore::FieldPath const &)*arg2,arg3); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::Query(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_QueryProxy_OrderBy__SWIG_3(void * jarg1, void * jarg2) { + void * jresult ; + firebase::firestore::Query *arg1 = (firebase::firestore::Query *) 0 ; + firebase::firestore::FieldPath *arg2 = 0 ; + firebase::firestore::Query result; + + arg1 = (firebase::firestore::Query *)jarg1; + arg2 = (firebase::firestore::FieldPath *)jarg2; + if (!arg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldPath const & type is null", 0); + return 0; + } + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Query) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::Query const *)arg1)->OrderBy((firebase::firestore::FieldPath const &)*arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::Query(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_QueryProxy_Limit(void * jarg1, int jarg2) { + void * jresult ; + firebase::firestore::Query *arg1 = (firebase::firestore::Query *) 0 ; + int32_t arg2 ; + firebase::firestore::Query result; + + arg1 = (firebase::firestore::Query *)jarg1; + arg2 = (int32_t)jarg2; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Query) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::Query const *)arg1)->Limit(arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::Query(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_QueryProxy_LimitToLast(void * jarg1, int jarg2) { + void * jresult ; + firebase::firestore::Query *arg1 = (firebase::firestore::Query *) 0 ; + int32_t arg2 ; + firebase::firestore::Query result; + + arg1 = (firebase::firestore::Query *)jarg1; + arg2 = (int32_t)jarg2; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Query) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::Query const *)arg1)->LimitToLast(arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::Query(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_QueryProxy_StartAt(void * jarg1, void * jarg2) { + void * jresult ; + firebase::firestore::Query *arg1 = (firebase::firestore::Query *) 0 ; + firebase::firestore::DocumentSnapshot *arg2 = 0 ; + firebase::firestore::Query result; + + arg1 = (firebase::firestore::Query *)jarg1; + arg2 = (firebase::firestore::DocumentSnapshot *)jarg2; + if (!arg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::DocumentSnapshot const & type is null", 0); + return 0; + } + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Query) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::Query const *)arg1)->StartAt((firebase::firestore::DocumentSnapshot const &)*arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::Query(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_QueryProxy_StartAfter(void * jarg1, void * jarg2) { + void * jresult ; + firebase::firestore::Query *arg1 = (firebase::firestore::Query *) 0 ; + firebase::firestore::DocumentSnapshot *arg2 = 0 ; + firebase::firestore::Query result; + + arg1 = (firebase::firestore::Query *)jarg1; + arg2 = (firebase::firestore::DocumentSnapshot *)jarg2; + if (!arg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::DocumentSnapshot const & type is null", 0); + return 0; + } + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Query) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::Query const *)arg1)->StartAfter((firebase::firestore::DocumentSnapshot const &)*arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::Query(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_QueryProxy_EndBefore(void * jarg1, void * jarg2) { + void * jresult ; + firebase::firestore::Query *arg1 = (firebase::firestore::Query *) 0 ; + firebase::firestore::DocumentSnapshot *arg2 = 0 ; + firebase::firestore::Query result; + + arg1 = (firebase::firestore::Query *)jarg1; + arg2 = (firebase::firestore::DocumentSnapshot *)jarg2; + if (!arg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::DocumentSnapshot const & type is null", 0); + return 0; + } + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Query) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::Query const *)arg1)->EndBefore((firebase::firestore::DocumentSnapshot const &)*arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::Query(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_QueryProxy_EndAt(void * jarg1, void * jarg2) { + void * jresult ; + firebase::firestore::Query *arg1 = (firebase::firestore::Query *) 0 ; + firebase::firestore::DocumentSnapshot *arg2 = 0 ; + firebase::firestore::Query result; + + arg1 = (firebase::firestore::Query *)jarg1; + arg2 = (firebase::firestore::DocumentSnapshot *)jarg2; + if (!arg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::DocumentSnapshot const & type is null", 0); + return 0; + } + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Query) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::Query const *)arg1)->EndAt((firebase::firestore::DocumentSnapshot const &)*arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::Query(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_QueryProxy_Get__SWIG_0(void * jarg1, int jarg2) { + void * jresult ; + firebase::firestore::Query *arg1 = (firebase::firestore::Query *) 0 ; + firebase::firestore::Source arg2 ; + firebase::Future< firebase::firestore::QuerySnapshot > result; + + arg1 = (firebase::firestore::Query *)jarg1; + arg2 = (firebase::firestore::Source)jarg2; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Query) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::Query const *)arg1)->Get(arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::Future< firebase::firestore::QuerySnapshot >(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_QueryProxy_Get__SWIG_1(void * jarg1) { + void * jresult ; + firebase::firestore::Query *arg1 = (firebase::firestore::Query *) 0 ; + firebase::Future< firebase::firestore::QuerySnapshot > result; + + arg1 = (firebase::firestore::Query *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Query) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::Query const *)arg1)->Get(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::Future< firebase::firestore::QuerySnapshot >(result); + return jresult; +} + + +SWIGEXPORT char * SWIGSTDCALL Firebase_Firestore_CSharp_CollectionReferenceProxy_id(void * jarg1) { + char * jresult ; + firebase::firestore::CollectionReference *arg1 = (firebase::firestore::CollectionReference *) 0 ; + std::string *result = 0 ; + + arg1 = (firebase::firestore::CollectionReference *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__CollectionReference) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (std::string *) &((firebase::firestore::CollectionReference const *)arg1)->id(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = SWIG_csharp_string_callback(result->c_str()); + return jresult; +} + + +SWIGEXPORT char * SWIGSTDCALL Firebase_Firestore_CSharp_CollectionReferenceProxy_path(void * jarg1) { + char * jresult ; + firebase::firestore::CollectionReference *arg1 = (firebase::firestore::CollectionReference *) 0 ; + std::string result; + + arg1 = (firebase::firestore::CollectionReference *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__CollectionReference) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::CollectionReference const *)arg1)->path(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = SWIG_csharp_string_callback((&result)->c_str()); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_CollectionReferenceProxy_Parent(void * jarg1) { + void * jresult ; + firebase::firestore::CollectionReference *arg1 = (firebase::firestore::CollectionReference *) 0 ; + firebase::firestore::DocumentReference result; + + arg1 = (firebase::firestore::CollectionReference *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__CollectionReference) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::CollectionReference const *)arg1)->Parent(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::DocumentReference(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_CollectionReferenceProxy_Document__SWIG_0(void * jarg1) { + void * jresult ; + firebase::firestore::CollectionReference *arg1 = (firebase::firestore::CollectionReference *) 0 ; + firebase::firestore::DocumentReference result; + + arg1 = (firebase::firestore::CollectionReference *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__CollectionReference) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::CollectionReference const *)arg1)->Document(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::DocumentReference(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_CollectionReferenceProxy_Document__SWIG_1(void * jarg1, char * jarg2) { + void * jresult ; + firebase::firestore::CollectionReference *arg1 = (firebase::firestore::CollectionReference *) 0 ; + char *arg2 = (char *) 0 ; + firebase::firestore::DocumentReference result; + + arg1 = (firebase::firestore::CollectionReference *)jarg1; + arg2 = (char *)jarg2; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__CollectionReference) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::CollectionReference const *)arg1)->Document((char const *)arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::DocumentReference(result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_delete_CollectionReferenceProxy(void * jarg1) { + firebase::firestore::CollectionReference *arg1 = (firebase::firestore::CollectionReference *) 0 ; + + arg1 = (firebase::firestore::CollectionReference *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__CollectionReference) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + delete arg1; + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_delete_QuerySnapshotProxy(void * jarg1) { + firebase::firestore::QuerySnapshot *arg1 = (firebase::firestore::QuerySnapshot *) 0 ; + + arg1 = (firebase::firestore::QuerySnapshot *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__QuerySnapshot) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + delete arg1; + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_QuerySnapshotProxy_query(void * jarg1) { + void * jresult ; + firebase::firestore::QuerySnapshot *arg1 = (firebase::firestore::QuerySnapshot *) 0 ; + firebase::firestore::Query result; + + arg1 = (firebase::firestore::QuerySnapshot *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__QuerySnapshot) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::QuerySnapshot const *)arg1)->query(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::Query(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_QuerySnapshotProxy_metadata(void * jarg1) { + void * jresult ; + firebase::firestore::QuerySnapshot *arg1 = (firebase::firestore::QuerySnapshot *) 0 ; + firebase::firestore::SnapshotMetadata result; + + arg1 = (firebase::firestore::QuerySnapshot *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__QuerySnapshot) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::QuerySnapshot const *)arg1)->metadata(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::SnapshotMetadata(result); + return jresult; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL Firebase_Firestore_CSharp_QuerySnapshotProxy_size(void * jarg1) { + unsigned long jresult ; + firebase::firestore::QuerySnapshot *arg1 = (firebase::firestore::QuerySnapshot *) 0 ; + std::size_t result; + + arg1 = (firebase::firestore::QuerySnapshot *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__QuerySnapshot) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::QuerySnapshot const *)arg1)->size(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (unsigned long)result; + return jresult; +} + + +SWIGEXPORT long long SWIGSTDCALL Firebase_Firestore_CSharp_SettingsProxy_kCacheSizeUnlimited_get() { + long long jresult ; + long long result; + + result = (long long)firebase::firestore::Settings::kCacheSizeUnlimited; + jresult = result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_new_SettingsProxy__SWIG_0() { + void * jresult ; + firebase::firestore::Settings *result = 0 ; + + { + try { + result = (firebase::firestore::Settings *)new firebase::firestore::Settings(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_new_SettingsProxy__SWIG_1(void * jarg1) { + void * jresult ; + firebase::firestore::Settings *arg1 = 0 ; + firebase::firestore::Settings *result = 0 ; + + arg1 = (firebase::firestore::Settings *)jarg1; + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::Settings const & type is null", 0); + return 0; + } + { + try { + result = (firebase::firestore::Settings *)new firebase::firestore::Settings((firebase::firestore::Settings const &)*arg1); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT char * SWIGSTDCALL Firebase_Firestore_CSharp_SettingsProxy_host(void * jarg1) { + char * jresult ; + firebase::firestore::Settings *arg1 = (firebase::firestore::Settings *) 0 ; + std::string *result = 0 ; + + arg1 = (firebase::firestore::Settings *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Settings) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (std::string *) &((firebase::firestore::Settings const *)arg1)->host(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = SWIG_csharp_string_callback(result->c_str()); + return jresult; +} + + +SWIGEXPORT unsigned int SWIGSTDCALL Firebase_Firestore_CSharp_SettingsProxy_is_ssl_enabled(void * jarg1) { + unsigned int jresult ; + firebase::firestore::Settings *arg1 = (firebase::firestore::Settings *) 0 ; + bool result; + + arg1 = (firebase::firestore::Settings *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Settings) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (bool)((firebase::firestore::Settings const *)arg1)->is_ssl_enabled(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = result; + return jresult; +} + + +SWIGEXPORT unsigned int SWIGSTDCALL Firebase_Firestore_CSharp_SettingsProxy_is_persistence_enabled(void * jarg1) { + unsigned int jresult ; + firebase::firestore::Settings *arg1 = (firebase::firestore::Settings *) 0 ; + bool result; + + arg1 = (firebase::firestore::Settings *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Settings) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (bool)((firebase::firestore::Settings const *)arg1)->is_persistence_enabled(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = result; + return jresult; +} + + +SWIGEXPORT long long SWIGSTDCALL Firebase_Firestore_CSharp_SettingsProxy_cache_size_bytes(void * jarg1) { + long long jresult ; + firebase::firestore::Settings *arg1 = (firebase::firestore::Settings *) 0 ; + int64_t result; + + arg1 = (firebase::firestore::Settings *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Settings) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (int64_t)((firebase::firestore::Settings const *)arg1)->cache_size_bytes(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_SettingsProxy_set_host(void * jarg1, char * jarg2) { + firebase::firestore::Settings *arg1 = (firebase::firestore::Settings *) 0 ; + std::string arg2 ; + + arg1 = (firebase::firestore::Settings *)jarg1; + if (!jarg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0); + return ; + } + (&arg2)->assign(jarg2); + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Settings) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + (arg1)->set_host(arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_SettingsProxy_set_ssl_enabled(void * jarg1, unsigned int jarg2) { + firebase::firestore::Settings *arg1 = (firebase::firestore::Settings *) 0 ; + bool arg2 ; + + arg1 = (firebase::firestore::Settings *)jarg1; + arg2 = jarg2 ? true : false; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Settings) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + (arg1)->set_ssl_enabled(arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_SettingsProxy_set_persistence_enabled(void * jarg1, unsigned int jarg2) { + firebase::firestore::Settings *arg1 = (firebase::firestore::Settings *) 0 ; + bool arg2 ; + + arg1 = (firebase::firestore::Settings *)jarg1; + arg2 = jarg2 ? true : false; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Settings) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + (arg1)->set_persistence_enabled(arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_SettingsProxy_set_cache_size_bytes(void * jarg1, long long jarg2) { + firebase::firestore::Settings *arg1 = (firebase::firestore::Settings *) 0 ; + int64_t arg2 ; + + arg1 = (firebase::firestore::Settings *)jarg1; + arg2 = (int64_t)jarg2; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Settings) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + (arg1)->set_cache_size_bytes(arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_delete_SettingsProxy(void * jarg1) { + firebase::firestore::Settings *arg1 = (firebase::firestore::Settings *) 0 ; + + arg1 = (firebase::firestore::Settings *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Settings) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + delete arg1; + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT int SWIGSTDCALL Firebase_Firestore_CSharp_LoadBundleTaskProgressProxy_documents_loaded(void * jarg1) { + int jresult ; + firebase::firestore::LoadBundleTaskProgress *arg1 = (firebase::firestore::LoadBundleTaskProgress *) 0 ; + int32_t result; + + arg1 = (firebase::firestore::LoadBundleTaskProgress *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__LoadBundleTaskProgress) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (int32_t)((firebase::firestore::LoadBundleTaskProgress const *)arg1)->documents_loaded(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL Firebase_Firestore_CSharp_LoadBundleTaskProgressProxy_total_documents(void * jarg1) { + int jresult ; + firebase::firestore::LoadBundleTaskProgress *arg1 = (firebase::firestore::LoadBundleTaskProgress *) 0 ; + int32_t result; + + arg1 = (firebase::firestore::LoadBundleTaskProgress *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__LoadBundleTaskProgress) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (int32_t)((firebase::firestore::LoadBundleTaskProgress const *)arg1)->total_documents(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = result; + return jresult; +} + + +SWIGEXPORT long long SWIGSTDCALL Firebase_Firestore_CSharp_LoadBundleTaskProgressProxy_bytes_loaded(void * jarg1) { + long long jresult ; + firebase::firestore::LoadBundleTaskProgress *arg1 = (firebase::firestore::LoadBundleTaskProgress *) 0 ; + int64_t result; + + arg1 = (firebase::firestore::LoadBundleTaskProgress *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__LoadBundleTaskProgress) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (int64_t)((firebase::firestore::LoadBundleTaskProgress const *)arg1)->bytes_loaded(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = result; + return jresult; +} + + +SWIGEXPORT long long SWIGSTDCALL Firebase_Firestore_CSharp_LoadBundleTaskProgressProxy_total_bytes(void * jarg1) { + long long jresult ; + firebase::firestore::LoadBundleTaskProgress *arg1 = (firebase::firestore::LoadBundleTaskProgress *) 0 ; + int64_t result; + + arg1 = (firebase::firestore::LoadBundleTaskProgress *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__LoadBundleTaskProgress) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (int64_t)((firebase::firestore::LoadBundleTaskProgress const *)arg1)->total_bytes(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL Firebase_Firestore_CSharp_LoadBundleTaskProgressProxy_state(void * jarg1) { + int jresult ; + firebase::firestore::LoadBundleTaskProgress *arg1 = (firebase::firestore::LoadBundleTaskProgress *) 0 ; + firebase::firestore::LoadBundleTaskProgress::State result; + + arg1 = (firebase::firestore::LoadBundleTaskProgress *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__LoadBundleTaskProgress) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (firebase::firestore::LoadBundleTaskProgress::State)((firebase::firestore::LoadBundleTaskProgress const *)arg1)->state(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (int)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_delete_LoadBundleTaskProgressProxy(void * jarg1) { + firebase::firestore::LoadBundleTaskProgress *arg1 = (firebase::firestore::LoadBundleTaskProgress *) 0 ; + + arg1 = (firebase::firestore::LoadBundleTaskProgress *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__LoadBundleTaskProgress) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + delete arg1; + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_delete_FirestoreProxy(void * jarg1) { + firebase::firestore::Firestore *arg1 = (firebase::firestore::Firestore *) 0 ; + + arg1 = (firebase::firestore::Firestore *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Firestore) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + delete arg1; + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_FirestoreProxy_app__SWIG_0(void * jarg1) { + void * jresult ; + firebase::firestore::Firestore *arg1 = (firebase::firestore::Firestore *) 0 ; + firebase::App *result = 0 ; + + arg1 = (firebase::firestore::Firestore *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Firestore) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (firebase::App *)((firebase::firestore::Firestore const *)arg1)->app(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_FirestoreProxy_Collection__SWIG_0(void * jarg1, char * jarg2) { + void * jresult ; + firebase::firestore::Firestore *arg1 = (firebase::firestore::Firestore *) 0 ; + char *arg2 = (char *) 0 ; + firebase::firestore::CollectionReference result; + + arg1 = (firebase::firestore::Firestore *)jarg1; + arg2 = (char *)jarg2; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Firestore) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::Firestore const *)arg1)->Collection((char const *)arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::CollectionReference(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_FirestoreProxy_Document__SWIG_0(void * jarg1, char * jarg2) { + void * jresult ; + firebase::firestore::Firestore *arg1 = (firebase::firestore::Firestore *) 0 ; + char *arg2 = (char *) 0 ; + firebase::firestore::DocumentReference result; + + arg1 = (firebase::firestore::Firestore *)jarg1; + arg2 = (char *)jarg2; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Firestore) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::Firestore const *)arg1)->Document((char const *)arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::DocumentReference(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_FirestoreProxy_CollectionGroup__SWIG_0(void * jarg1, char * jarg2) { + void * jresult ; + firebase::firestore::Firestore *arg1 = (firebase::firestore::Firestore *) 0 ; + char *arg2 = (char *) 0 ; + firebase::firestore::Query result; + + arg1 = (firebase::firestore::Firestore *)jarg1; + arg2 = (char *)jarg2; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Firestore) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::Firestore const *)arg1)->CollectionGroup((char const *)arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::Query(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_FirestoreProxy_settings(void * jarg1) { + void * jresult ; + firebase::firestore::Firestore *arg1 = (firebase::firestore::Firestore *) 0 ; + firebase::firestore::Settings result; + + arg1 = (firebase::firestore::Firestore *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Firestore) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::Firestore const *)arg1)->settings(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::Settings(result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_FirestoreProxy_set_settings(void * jarg1, void * jarg2) { + firebase::firestore::Firestore *arg1 = (firebase::firestore::Firestore *) 0 ; + firebase::firestore::Settings arg2 ; + firebase::firestore::Settings *argp2 ; + + arg1 = (firebase::firestore::Firestore *)jarg1; + argp2 = (firebase::firestore::Settings *)jarg2; + if (!argp2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null firebase::firestore::Settings", 0); + return ; + } + arg2 = *argp2; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Firestore) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + (arg1)->set_settings(arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_FirestoreProxy_batch(void * jarg1) { + void * jresult ; + firebase::firestore::Firestore *arg1 = (firebase::firestore::Firestore *) 0 ; + firebase::firestore::WriteBatch result; + + arg1 = (firebase::firestore::Firestore *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Firestore) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::Firestore const *)arg1)->batch(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::WriteBatch(result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_FirestoreProxy_set_log_level(int jarg1) { + firebase::LogLevel arg1 ; + + arg1 = (firebase::LogLevel)jarg1; + { + try { + firebase::firestore::Firestore::set_log_level(arg1); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_FirestoreProxy_DisableNetwork(void * jarg1) { + void * jresult ; + firebase::firestore::Firestore *arg1 = (firebase::firestore::Firestore *) 0 ; + firebase::Future< void > result; + + arg1 = (firebase::firestore::Firestore *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Firestore) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (arg1)->DisableNetwork(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::Future< void >(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_FirestoreProxy_EnableNetwork(void * jarg1) { + void * jresult ; + firebase::firestore::Firestore *arg1 = (firebase::firestore::Firestore *) 0 ; + firebase::Future< void > result; + + arg1 = (firebase::firestore::Firestore *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Firestore) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (arg1)->EnableNetwork(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::Future< void >(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_FirestoreProxy_Terminate(void * jarg1) { + void * jresult ; + firebase::firestore::Firestore *arg1 = (firebase::firestore::Firestore *) 0 ; + firebase::Future< void > result; + + arg1 = (firebase::firestore::Firestore *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Firestore) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (arg1)->Terminate(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::Future< void >(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_FirestoreProxy_WaitForPendingWrites(void * jarg1) { + void * jresult ; + firebase::firestore::Firestore *arg1 = (firebase::firestore::Firestore *) 0 ; + firebase::Future< void > result; + + arg1 = (firebase::firestore::Firestore *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Firestore) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (arg1)->WaitForPendingWrites(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::Future< void >(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_FirestoreProxy_ClearPersistence(void * jarg1) { + void * jresult ; + firebase::firestore::Firestore *arg1 = (firebase::firestore::Firestore *) 0 ; + firebase::Future< void > result; + + arg1 = (firebase::firestore::Firestore *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Firestore) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (arg1)->ClearPersistence(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::Future< void >(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_FirestoreProxy_NamedQuery(void * jarg1, char * jarg2) { + void * jresult ; + firebase::firestore::Firestore *arg1 = (firebase::firestore::Firestore *) 0 ; + std::string *arg2 = 0 ; + firebase::Future< firebase::firestore::Query > result; + + arg1 = (firebase::firestore::Firestore *)jarg1; + if (!jarg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0); + return 0; + } + std::string arg2_str(jarg2); + arg2 = &arg2_str; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__Firestore) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (arg1)->NamedQuery((std::string const &)*arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::Future< firebase::firestore::Query >(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_AddDocumentSnapshotListener(void * jarg1, int jarg2, int jarg3, void * jarg4) { + void * jresult ; + firebase::firestore::DocumentReference *arg1 = (firebase::firestore::DocumentReference *) 0 ; + firebase::firestore::MetadataChanges arg2 ; + int32_t arg3 ; + firebase::firestore::csharp::DocumentEventListenerCallback arg4 = (firebase::firestore::csharp::DocumentEventListenerCallback) 0 ; + firebase::firestore::ListenerRegistration result; + + arg1 = (firebase::firestore::DocumentReference *)jarg1; + arg2 = (firebase::firestore::MetadataChanges)jarg2; + arg3 = (int32_t)jarg3; + + arg4 = (firebase::firestore::csharp::DocumentEventListenerCallback)jarg4; + + { + try { + result = firebase::firestore::csharp::AddDocumentSnapshotListener(arg1,arg2,arg3,arg4); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::ListenerRegistration(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_AddQuerySnapshotListener(void * jarg1, int jarg2, int jarg3, void * jarg4) { + void * jresult ; + firebase::firestore::Query *arg1 = (firebase::firestore::Query *) 0 ; + firebase::firestore::MetadataChanges arg2 ; + int32_t arg3 ; + firebase::firestore::csharp::QueryEventListenerCallback arg4 = (firebase::firestore::csharp::QueryEventListenerCallback) 0 ; + firebase::firestore::ListenerRegistration result; + + arg1 = (firebase::firestore::Query *)jarg1; + arg2 = (firebase::firestore::MetadataChanges)jarg2; + arg3 = (int32_t)jarg3; + + arg4 = (firebase::firestore::csharp::QueryEventListenerCallback)jarg4; + + { + try { + result = firebase::firestore::csharp::AddQuerySnapshotListener(arg1,arg2,arg3,arg4); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::ListenerRegistration(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_AddSnapshotsInSyncListener(void * jarg1, int jarg2, void * jarg3) { + void * jresult ; + firebase::firestore::Firestore *arg1 = (firebase::firestore::Firestore *) 0 ; + int32_t arg2 ; + firebase::firestore::csharp::SnapshotsInSyncCallback arg3 = (firebase::firestore::csharp::SnapshotsInSyncCallback) 0 ; + firebase::firestore::ListenerRegistration result; + + arg1 = (firebase::firestore::Firestore *)jarg1; + arg2 = (int32_t)jarg2; + + arg3 = (firebase::firestore::csharp::SnapshotsInSyncCallback)jarg3; + + { + try { + result = firebase::firestore::csharp::AddSnapshotsInSyncListener(arg1,arg2,arg3); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::ListenerRegistration(result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_LoadBundleWithCallback(void * jarg1, char * jarg2, int jarg3, void * jarg4) { + firebase::firestore::Firestore *arg1 = (firebase::firestore::Firestore *) 0 ; + std::string *arg2 = 0 ; + int32_t arg3 ; + firebase::firestore::csharp::LoadBundleTaskProgressCallback arg4 = (firebase::firestore::csharp::LoadBundleTaskProgressCallback) 0 ; + + arg1 = (firebase::firestore::Firestore *)jarg1; + if (!jarg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0); + return ; + } + std::string arg2_str(jarg2); + arg2 = &arg2_str; + arg3 = (int32_t)jarg3; + + arg4 = (firebase::firestore::csharp::LoadBundleTaskProgressCallback)jarg4; + + { + try { + firebase::firestore::csharp::LoadBundleWithCallback(arg1,(std::string const &)*arg2,arg3,arg4); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_GetFirestoreInstance(void * jarg1) { + void * jresult ; + firebase::App *arg1 = (firebase::App *) 0 ; + firebase::firestore::Firestore *result = 0 ; + + arg1 = (firebase::App *)jarg1; + { + try { + result = (firebase::firestore::Firestore *)firebase::firestore::csharp::GetFirestoreInstance(arg1); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_ReleaseFirestoreInstance(void * jarg1) { + firebase::firestore::Firestore *arg1 = (firebase::firestore::Firestore *) 0 ; + + arg1 = (firebase::firestore::Firestore *)jarg1; + { + try { + firebase::firestore::csharp::ReleaseFirestoreInstance(arg1); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_ApiHeaders_SetClientLanguage(char * jarg1) { + std::string *arg1 = 0 ; + + if (!jarg1) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0); + return ; + } + std::string arg1_str(jarg1); + arg1 = &arg1_str; + { + try { + firebase::firestore::csharp::ApiHeaders::SetClientLanguage((std::string const &)*arg1); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_new_ApiHeaders() { + void * jresult ; + firebase::firestore::csharp::ApiHeaders *result = 0 ; + + { + try { + result = (firebase::firestore::csharp::ApiHeaders *)new firebase::firestore::csharp::ApiHeaders(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_delete_ApiHeaders(void * jarg1) { + firebase::firestore::csharp::ApiHeaders *arg1 = (firebase::firestore::csharp::ApiHeaders *) 0 ; + + arg1 = (firebase::firestore::csharp::ApiHeaders *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__ApiHeaders) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + delete arg1; + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_ConvertFieldValueToMap(void * jarg1) { + void * jresult ; + firebase::firestore::FieldValue *arg1 = 0 ; + firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue > result; + + arg1 = (firebase::firestore::FieldValue *)jarg1; + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldValue const & type is null", 0); + return 0; + } + { + try { + result = firebase::firestore::csharp::ConvertFieldValueToMap((firebase::firestore::FieldValue const &)*arg1); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue >(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_ConvertMapToFieldValue(void * jarg1) { + void * jresult ; + firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue > *arg1 = 0 ; + firebase::firestore::FieldValue result; + + arg1 = (firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue > *)jarg1; + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue > const & type is null", 0); + return 0; + } + { + try { + result = firebase::firestore::csharp::ConvertMapToFieldValue((firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue > const &)*arg1); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::FieldValue(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_ConvertSnapshotToFieldValue(void * jarg1, int jarg2) { + void * jresult ; + firebase::firestore::DocumentSnapshot *arg1 = 0 ; + firebase::firestore::DocumentSnapshot::ServerTimestampBehavior arg2 ; + firebase::firestore::FieldValue result; + + arg1 = (firebase::firestore::DocumentSnapshot *)jarg1; + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::DocumentSnapshot const & type is null", 0); + return 0; + } + arg2 = (firebase::firestore::DocumentSnapshot::ServerTimestampBehavior)jarg2; + { + try { + result = firebase::firestore::csharp::ConvertSnapshotToFieldValue((firebase::firestore::DocumentSnapshot const &)*arg1,arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::FieldValue(result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_WriteBatchUpdate__SWIG_0(void * jarg1, void * jarg2, void * jarg3) { + firebase::firestore::WriteBatch *arg1 = (firebase::firestore::WriteBatch *) 0 ; + firebase::firestore::DocumentReference *arg2 = 0 ; + firebase::firestore::FieldValue *arg3 = 0 ; + + arg1 = (firebase::firestore::WriteBatch *)jarg1; + arg2 = (firebase::firestore::DocumentReference *)jarg2; + if (!arg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::DocumentReference const & type is null", 0); + return ; + } + arg3 = (firebase::firestore::FieldValue *)jarg3; + if (!arg3) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldValue const & type is null", 0); + return ; + } + { + try { + firebase::firestore::csharp::WriteBatchUpdate(arg1,(firebase::firestore::DocumentReference const &)*arg2,(firebase::firestore::FieldValue const &)*arg3); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_WriteBatchUpdate__SWIG_1(void * jarg1, void * jarg2, void * jarg3) { + firebase::firestore::WriteBatch *arg1 = (firebase::firestore::WriteBatch *) 0 ; + firebase::firestore::DocumentReference *arg2 = 0 ; + firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue > *arg3 = 0 ; + + arg1 = (firebase::firestore::WriteBatch *)jarg1; + arg2 = (firebase::firestore::DocumentReference *)jarg2; + if (!arg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::DocumentReference const & type is null", 0); + return ; + } + arg3 = (firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue > *)jarg3; + if (!arg3) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue > const & type is null", 0); + return ; + } + { + try { + firebase::firestore::csharp::WriteBatchUpdate(arg1,(firebase::firestore::DocumentReference const &)*arg2,(firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue > const &)*arg3); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_WriteBatchUpdate__SWIG_2(void * jarg1, void * jarg2, void * jarg3) { + firebase::firestore::WriteBatch *arg1 = (firebase::firestore::WriteBatch *) 0 ; + firebase::firestore::DocumentReference *arg2 = 0 ; + firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue > *arg3 = 0 ; + + arg1 = (firebase::firestore::WriteBatch *)jarg1; + arg2 = (firebase::firestore::DocumentReference *)jarg2; + if (!arg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::DocumentReference const & type is null", 0); + return ; + } + arg3 = (firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue > *)jarg3; + if (!arg3) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue > const & type is null", 0); + return ; + } + { + try { + firebase::firestore::csharp::WriteBatchUpdate(arg1,(firebase::firestore::DocumentReference const &)*arg2,(firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue > const &)*arg3); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_DocumentReferenceSet(void * jarg1, void * jarg2, void * jarg3) { + void * jresult ; + firebase::firestore::DocumentReference *arg1 = 0 ; + firebase::firestore::FieldValue *arg2 = 0 ; + firebase::firestore::SetOptions *arg3 = 0 ; + firebase::Future< void > result; + + arg1 = (firebase::firestore::DocumentReference *)jarg1; + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::DocumentReference & type is null", 0); + return 0; + } + arg2 = (firebase::firestore::FieldValue *)jarg2; + if (!arg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldValue const & type is null", 0); + return 0; + } + arg3 = (firebase::firestore::SetOptions *)jarg3; + if (!arg3) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::SetOptions const & type is null", 0); + return 0; + } + { + try { + result = firebase::firestore::csharp::DocumentReferenceSet(*arg1,(firebase::firestore::FieldValue const &)*arg2,(firebase::firestore::SetOptions const &)*arg3); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::Future< void >(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_DocumentReferenceUpdate__SWIG_0(void * jarg1, void * jarg2) { + void * jresult ; + firebase::firestore::DocumentReference *arg1 = 0 ; + firebase::firestore::FieldValue *arg2 = 0 ; + firebase::Future< void > result; + + arg1 = (firebase::firestore::DocumentReference *)jarg1; + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::DocumentReference & type is null", 0); + return 0; + } + arg2 = (firebase::firestore::FieldValue *)jarg2; + if (!arg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldValue const & type is null", 0); + return 0; + } + { + try { + result = firebase::firestore::csharp::DocumentReferenceUpdate(*arg1,(firebase::firestore::FieldValue const &)*arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::Future< void >(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_DocumentReferenceUpdate__SWIG_1(void * jarg1, void * jarg2) { + void * jresult ; + firebase::firestore::DocumentReference *arg1 = 0 ; + firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue > *arg2 = 0 ; + firebase::Future< void > result; + + arg1 = (firebase::firestore::DocumentReference *)jarg1; + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::DocumentReference & type is null", 0); + return 0; + } + arg2 = (firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue > *)jarg2; + if (!arg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue > const & type is null", 0); + return 0; + } + { + try { + result = firebase::firestore::csharp::DocumentReferenceUpdate(*arg1,(firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue > const &)*arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::Future< void >(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_QueryWhereArrayContainsAny__SWIG_0(void * jarg1, char * jarg2, void * jarg3) { + void * jresult ; + firebase::firestore::Query *arg1 = 0 ; + std::string *arg2 = 0 ; + firebase::firestore::FieldValue *arg3 = 0 ; + firebase::firestore::Query result; + + arg1 = (firebase::firestore::Query *)jarg1; + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::Query & type is null", 0); + return 0; + } + if (!jarg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0); + return 0; + } + std::string arg2_str(jarg2); + arg2 = &arg2_str; + arg3 = (firebase::firestore::FieldValue *)jarg3; + if (!arg3) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldValue const & type is null", 0); + return 0; + } + { + try { + result = firebase::firestore::csharp::QueryWhereArrayContainsAny(*arg1,(std::string const &)*arg2,(firebase::firestore::FieldValue const &)*arg3); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::Query(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_QueryWhereArrayContainsAny__SWIG_1(void * jarg1, void * jarg2, void * jarg3) { + void * jresult ; + firebase::firestore::Query *arg1 = 0 ; + firebase::firestore::FieldPath *arg2 = 0 ; + firebase::firestore::FieldValue *arg3 = 0 ; + firebase::firestore::Query result; + + arg1 = (firebase::firestore::Query *)jarg1; + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::Query & type is null", 0); + return 0; + } + arg2 = (firebase::firestore::FieldPath *)jarg2; + if (!arg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldPath const & type is null", 0); + return 0; + } + arg3 = (firebase::firestore::FieldValue *)jarg3; + if (!arg3) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldValue const & type is null", 0); + return 0; + } + { + try { + result = firebase::firestore::csharp::QueryWhereArrayContainsAny(*arg1,(firebase::firestore::FieldPath const &)*arg2,(firebase::firestore::FieldValue const &)*arg3); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::Query(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_QueryWhereIn__SWIG_0(void * jarg1, char * jarg2, void * jarg3) { + void * jresult ; + firebase::firestore::Query *arg1 = 0 ; + std::string *arg2 = 0 ; + firebase::firestore::FieldValue *arg3 = 0 ; + firebase::firestore::Query result; + + arg1 = (firebase::firestore::Query *)jarg1; + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::Query & type is null", 0); + return 0; + } + if (!jarg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0); + return 0; + } + std::string arg2_str(jarg2); + arg2 = &arg2_str; + arg3 = (firebase::firestore::FieldValue *)jarg3; + if (!arg3) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldValue const & type is null", 0); + return 0; + } + { + try { + result = firebase::firestore::csharp::QueryWhereIn(*arg1,(std::string const &)*arg2,(firebase::firestore::FieldValue const &)*arg3); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::Query(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_QueryWhereIn__SWIG_1(void * jarg1, void * jarg2, void * jarg3) { + void * jresult ; + firebase::firestore::Query *arg1 = 0 ; + firebase::firestore::FieldPath *arg2 = 0 ; + firebase::firestore::FieldValue *arg3 = 0 ; + firebase::firestore::Query result; + + arg1 = (firebase::firestore::Query *)jarg1; + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::Query & type is null", 0); + return 0; + } + arg2 = (firebase::firestore::FieldPath *)jarg2; + if (!arg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldPath const & type is null", 0); + return 0; + } + arg3 = (firebase::firestore::FieldValue *)jarg3; + if (!arg3) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldValue const & type is null", 0); + return 0; + } + { + try { + result = firebase::firestore::csharp::QueryWhereIn(*arg1,(firebase::firestore::FieldPath const &)*arg2,(firebase::firestore::FieldValue const &)*arg3); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::Query(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_QueryWhereNotIn__SWIG_0(void * jarg1, char * jarg2, void * jarg3) { + void * jresult ; + firebase::firestore::Query *arg1 = 0 ; + std::string *arg2 = 0 ; + firebase::firestore::FieldValue *arg3 = 0 ; + firebase::firestore::Query result; + + arg1 = (firebase::firestore::Query *)jarg1; + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::Query & type is null", 0); + return 0; + } + if (!jarg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0); + return 0; + } + std::string arg2_str(jarg2); + arg2 = &arg2_str; + arg3 = (firebase::firestore::FieldValue *)jarg3; + if (!arg3) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldValue const & type is null", 0); + return 0; + } + { + try { + result = firebase::firestore::csharp::QueryWhereNotIn(*arg1,(std::string const &)*arg2,(firebase::firestore::FieldValue const &)*arg3); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::Query(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_QueryWhereNotIn__SWIG_1(void * jarg1, void * jarg2, void * jarg3) { + void * jresult ; + firebase::firestore::Query *arg1 = 0 ; + firebase::firestore::FieldPath *arg2 = 0 ; + firebase::firestore::FieldValue *arg3 = 0 ; + firebase::firestore::Query result; + + arg1 = (firebase::firestore::Query *)jarg1; + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::Query & type is null", 0); + return 0; + } + arg2 = (firebase::firestore::FieldPath *)jarg2; + if (!arg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldPath const & type is null", 0); + return 0; + } + arg3 = (firebase::firestore::FieldValue *)jarg3; + if (!arg3) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldValue const & type is null", 0); + return 0; + } + { + try { + result = firebase::firestore::csharp::QueryWhereNotIn(*arg1,(firebase::firestore::FieldPath const &)*arg2,(firebase::firestore::FieldValue const &)*arg3); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::Query(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_QueryStartAt(void * jarg1, void * jarg2) { + void * jresult ; + firebase::firestore::Query *arg1 = 0 ; + firebase::firestore::FieldValue *arg2 = 0 ; + firebase::firestore::Query result; + + arg1 = (firebase::firestore::Query *)jarg1; + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::Query & type is null", 0); + return 0; + } + arg2 = (firebase::firestore::FieldValue *)jarg2; + if (!arg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldValue const & type is null", 0); + return 0; + } + { + try { + result = firebase::firestore::csharp::QueryStartAt(*arg1,(firebase::firestore::FieldValue const &)*arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::Query(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_QueryStartAfter(void * jarg1, void * jarg2) { + void * jresult ; + firebase::firestore::Query *arg1 = 0 ; + firebase::firestore::FieldValue *arg2 = 0 ; + firebase::firestore::Query result; + + arg1 = (firebase::firestore::Query *)jarg1; + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::Query & type is null", 0); + return 0; + } + arg2 = (firebase::firestore::FieldValue *)jarg2; + if (!arg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldValue const & type is null", 0); + return 0; + } + { + try { + result = firebase::firestore::csharp::QueryStartAfter(*arg1,(firebase::firestore::FieldValue const &)*arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::Query(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_QueryEndBefore(void * jarg1, void * jarg2) { + void * jresult ; + firebase::firestore::Query *arg1 = 0 ; + firebase::firestore::FieldValue *arg2 = 0 ; + firebase::firestore::Query result; + + arg1 = (firebase::firestore::Query *)jarg1; + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::Query & type is null", 0); + return 0; + } + arg2 = (firebase::firestore::FieldValue *)jarg2; + if (!arg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldValue const & type is null", 0); + return 0; + } + { + try { + result = firebase::firestore::csharp::QueryEndBefore(*arg1,(firebase::firestore::FieldValue const &)*arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::Query(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_QueryEndAt(void * jarg1, void * jarg2) { + void * jresult ; + firebase::firestore::Query *arg1 = 0 ; + firebase::firestore::FieldValue *arg2 = 0 ; + firebase::firestore::Query result; + + arg1 = (firebase::firestore::Query *)jarg1; + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::Query & type is null", 0); + return 0; + } + arg2 = (firebase::firestore::FieldValue *)jarg2; + if (!arg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldValue const & type is null", 0); + return 0; + } + { + try { + result = firebase::firestore::csharp::QueryEndAt(*arg1,(firebase::firestore::FieldValue const &)*arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::Query(result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_WriteBatchSet(void * jarg1, void * jarg2, void * jarg3, void * jarg4) { + firebase::firestore::WriteBatch *arg1 = 0 ; + firebase::firestore::DocumentReference *arg2 = 0 ; + firebase::firestore::FieldValue *arg3 = 0 ; + firebase::firestore::SetOptions *arg4 = 0 ; + + arg1 = (firebase::firestore::WriteBatch *)jarg1; + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::WriteBatch & type is null", 0); + return ; + } + arg2 = (firebase::firestore::DocumentReference *)jarg2; + if (!arg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::DocumentReference const & type is null", 0); + return ; + } + arg3 = (firebase::firestore::FieldValue *)jarg3; + if (!arg3) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldValue const & type is null", 0); + return ; + } + arg4 = (firebase::firestore::SetOptions *)jarg4; + if (!arg4) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::SetOptions const & type is null", 0); + return ; + } + { + try { + firebase::firestore::csharp::WriteBatchSet(*arg1,(firebase::firestore::DocumentReference const &)*arg2,(firebase::firestore::FieldValue const &)*arg3,(firebase::firestore::SetOptions const &)*arg4); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT unsigned int SWIGSTDCALL Firebase_Firestore_CSharp_TransactionResultOfGetProxy_is_valid(void * jarg1) { + unsigned int jresult ; + firebase::firestore::csharp::TransactionResultOfGet *arg1 = (firebase::firestore::csharp::TransactionResultOfGet *) 0 ; + bool result; + + arg1 = (firebase::firestore::csharp::TransactionResultOfGet *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__TransactionResultOfGet) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (bool)((firebase::firestore::csharp::TransactionResultOfGet const *)arg1)->is_valid(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_TransactionResultOfGetProxy_TakeSnapshot(void * jarg1) { + void * jresult ; + firebase::firestore::csharp::TransactionResultOfGet *arg1 = (firebase::firestore::csharp::TransactionResultOfGet *) 0 ; + firebase::firestore::DocumentSnapshot result; + + arg1 = (firebase::firestore::csharp::TransactionResultOfGet *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__TransactionResultOfGet) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (arg1)->TakeSnapshot(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::DocumentSnapshot(result); + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL Firebase_Firestore_CSharp_TransactionResultOfGetProxy_error_code(void * jarg1) { + int jresult ; + firebase::firestore::csharp::TransactionResultOfGet *arg1 = (firebase::firestore::csharp::TransactionResultOfGet *) 0 ; + firebase::firestore::Error result; + + arg1 = (firebase::firestore::csharp::TransactionResultOfGet *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__TransactionResultOfGet) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (firebase::firestore::Error)((firebase::firestore::csharp::TransactionResultOfGet const *)arg1)->error_code(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (int)result; + return jresult; +} + + +SWIGEXPORT char * SWIGSTDCALL Firebase_Firestore_CSharp_TransactionResultOfGetProxy_error_message(void * jarg1) { + char * jresult ; + firebase::firestore::csharp::TransactionResultOfGet *arg1 = (firebase::firestore::csharp::TransactionResultOfGet *) 0 ; + std::string *result = 0 ; + + arg1 = (firebase::firestore::csharp::TransactionResultOfGet *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__TransactionResultOfGet) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (std::string *) &((firebase::firestore::csharp::TransactionResultOfGet const *)arg1)->error_message(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = SWIG_csharp_string_callback(result->c_str()); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_delete_TransactionResultOfGetProxy(void * jarg1) { + firebase::firestore::csharp::TransactionResultOfGet *arg1 = (firebase::firestore::csharp::TransactionResultOfGet *) 0 ; + + arg1 = (firebase::firestore::csharp::TransactionResultOfGet *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__TransactionResultOfGet) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + delete arg1; + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT int SWIGSTDCALL Firebase_Firestore_CSharp_TransactionCallbackProxy_callback_id(void * jarg1) { + int jresult ; + firebase::firestore::csharp::TransactionCallback *arg1 = (firebase::firestore::csharp::TransactionCallback *) 0 ; + int32_t result; + + arg1 = (firebase::firestore::csharp::TransactionCallback *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__TransactionCallback) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (int32_t)((firebase::firestore::csharp::TransactionCallback const *)arg1)->callback_id(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_TransactionCallbackProxy_Get(void * jarg1, void * jarg2) { + void * jresult ; + firebase::firestore::csharp::TransactionCallback *arg1 = (firebase::firestore::csharp::TransactionCallback *) 0 ; + firebase::firestore::DocumentReference *arg2 = 0 ; + firebase::firestore::csharp::TransactionResultOfGet result; + + arg1 = (firebase::firestore::csharp::TransactionCallback *)jarg1; + arg2 = (firebase::firestore::DocumentReference *)jarg2; + if (!arg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::DocumentReference const & type is null", 0); + return 0; + } + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__TransactionCallback) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (arg1)->Get((firebase::firestore::DocumentReference const &)*arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::csharp::TransactionResultOfGet(result); + return jresult; +} + + +SWIGEXPORT unsigned int SWIGSTDCALL Firebase_Firestore_CSharp_TransactionCallbackProxy_Update__SWIG_0(void * jarg1, void * jarg2, void * jarg3) { + unsigned int jresult ; + firebase::firestore::csharp::TransactionCallback *arg1 = (firebase::firestore::csharp::TransactionCallback *) 0 ; + firebase::firestore::DocumentReference *arg2 = 0 ; + firebase::firestore::FieldValue *arg3 = 0 ; + bool result; + + arg1 = (firebase::firestore::csharp::TransactionCallback *)jarg1; + arg2 = (firebase::firestore::DocumentReference *)jarg2; + if (!arg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::DocumentReference const & type is null", 0); + return 0; + } + arg3 = (firebase::firestore::FieldValue *)jarg3; + if (!arg3) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldValue const & type is null", 0); + return 0; + } + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__TransactionCallback) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (bool)(arg1)->Update((firebase::firestore::DocumentReference const &)*arg2,(firebase::firestore::FieldValue const &)*arg3); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = result; + return jresult; +} + + +SWIGEXPORT unsigned int SWIGSTDCALL Firebase_Firestore_CSharp_TransactionCallbackProxy_Update__SWIG_1(void * jarg1, void * jarg2, void * jarg3) { + unsigned int jresult ; + firebase::firestore::csharp::TransactionCallback *arg1 = (firebase::firestore::csharp::TransactionCallback *) 0 ; + firebase::firestore::DocumentReference *arg2 = 0 ; + firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue > *arg3 = 0 ; + bool result; + + arg1 = (firebase::firestore::csharp::TransactionCallback *)jarg1; + arg2 = (firebase::firestore::DocumentReference *)jarg2; + if (!arg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::DocumentReference const & type is null", 0); + return 0; + } + arg3 = (firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue > *)jarg3; + if (!arg3) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue > const & type is null", 0); + return 0; + } + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__TransactionCallback) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (bool)(arg1)->Update((firebase::firestore::DocumentReference const &)*arg2,(firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue > const &)*arg3); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = result; + return jresult; +} + + +SWIGEXPORT unsigned int SWIGSTDCALL Firebase_Firestore_CSharp_TransactionCallbackProxy_Update__SWIG_2(void * jarg1, void * jarg2, void * jarg3) { + unsigned int jresult ; + firebase::firestore::csharp::TransactionCallback *arg1 = (firebase::firestore::csharp::TransactionCallback *) 0 ; + firebase::firestore::DocumentReference *arg2 = 0 ; + firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue > *arg3 = 0 ; + bool result; + + arg1 = (firebase::firestore::csharp::TransactionCallback *)jarg1; + arg2 = (firebase::firestore::DocumentReference *)jarg2; + if (!arg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::DocumentReference const & type is null", 0); + return 0; + } + arg3 = (firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue > *)jarg3; + if (!arg3) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue > const & type is null", 0); + return 0; + } + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__TransactionCallback) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (bool)(arg1)->Update((firebase::firestore::DocumentReference const &)*arg2,(firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue > const &)*arg3); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = result; + return jresult; +} + + +SWIGEXPORT unsigned int SWIGSTDCALL Firebase_Firestore_CSharp_TransactionCallbackProxy_Set(void * jarg1, void * jarg2, void * jarg3, void * jarg4) { + unsigned int jresult ; + firebase::firestore::csharp::TransactionCallback *arg1 = (firebase::firestore::csharp::TransactionCallback *) 0 ; + firebase::firestore::DocumentReference *arg2 = 0 ; + firebase::firestore::FieldValue *arg3 = 0 ; + firebase::firestore::SetOptions *arg4 = 0 ; + bool result; + + arg1 = (firebase::firestore::csharp::TransactionCallback *)jarg1; + arg2 = (firebase::firestore::DocumentReference *)jarg2; + if (!arg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::DocumentReference const & type is null", 0); + return 0; + } + arg3 = (firebase::firestore::FieldValue *)jarg3; + if (!arg3) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldValue const & type is null", 0); + return 0; + } + arg4 = (firebase::firestore::SetOptions *)jarg4; + if (!arg4) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::SetOptions const & type is null", 0); + return 0; + } + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__TransactionCallback) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (bool)(arg1)->Set((firebase::firestore::DocumentReference const &)*arg2,(firebase::firestore::FieldValue const &)*arg3,(firebase::firestore::SetOptions const &)*arg4); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = result; + return jresult; +} + + +SWIGEXPORT unsigned int SWIGSTDCALL Firebase_Firestore_CSharp_TransactionCallbackProxy_Delete(void * jarg1, void * jarg2) { + unsigned int jresult ; + firebase::firestore::csharp::TransactionCallback *arg1 = (firebase::firestore::csharp::TransactionCallback *) 0 ; + firebase::firestore::DocumentReference *arg2 = 0 ; + bool result; + + arg1 = (firebase::firestore::csharp::TransactionCallback *)jarg1; + arg2 = (firebase::firestore::DocumentReference *)jarg2; + if (!arg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::DocumentReference const & type is null", 0); + return 0; + } + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__TransactionCallback) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (bool)(arg1)->Delete((firebase::firestore::DocumentReference const &)*arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_TransactionCallbackProxy_OnCompletion(void * jarg1, unsigned int jarg2) { + firebase::firestore::csharp::TransactionCallback *arg1 = (firebase::firestore::csharp::TransactionCallback *) 0 ; + bool arg2 ; + + arg1 = (firebase::firestore::csharp::TransactionCallback *)jarg1; + arg2 = jarg2 ? true : false; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__TransactionCallback) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + (arg1)->OnCompletion(arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_delete_TransactionCallbackProxy(void * jarg1) { + firebase::firestore::csharp::TransactionCallback *arg1 = (firebase::firestore::csharp::TransactionCallback *) 0 ; + + arg1 = (firebase::firestore::csharp::TransactionCallback *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__TransactionCallback) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + delete arg1; + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_new_TransactionManagerProxy(void * jarg1) { + void * jresult ; + firebase::firestore::Firestore *arg1 = (firebase::firestore::Firestore *) 0 ; + firebase::firestore::csharp::TransactionManager *result = 0 ; + + arg1 = (firebase::firestore::Firestore *)jarg1; + { + try { + result = (firebase::firestore::csharp::TransactionManager *)new firebase::firestore::csharp::TransactionManager(arg1); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_delete_TransactionManagerProxy(void * jarg1) { + firebase::firestore::csharp::TransactionManager *arg1 = (firebase::firestore::csharp::TransactionManager *) 0 ; + + arg1 = (firebase::firestore::csharp::TransactionManager *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__TransactionManager) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + delete arg1; + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_TransactionManagerProxy_CppDispose(void * jarg1) { + firebase::firestore::csharp::TransactionManager *arg1 = (firebase::firestore::csharp::TransactionManager *) 0 ; + + arg1 = (firebase::firestore::csharp::TransactionManager *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__TransactionManager) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + (arg1)->Dispose(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_TransactionManagerProxy_RunTransaction(void * jarg1, int jarg2, void * jarg3) { + void * jresult ; + firebase::firestore::csharp::TransactionManager *arg1 = (firebase::firestore::csharp::TransactionManager *) 0 ; + int32_t arg2 ; + firebase::firestore::csharp::TransactionCallbackFn arg3 = (firebase::firestore::csharp::TransactionCallbackFn) 0 ; + firebase::Future< void > result; + + arg1 = (firebase::firestore::csharp::TransactionManager *)jarg1; + arg2 = (int32_t)jarg2; + + arg3 = (firebase::firestore::csharp::TransactionCallbackFn)jarg3; + + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__TransactionManager) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (arg1)->RunTransaction(arg2,arg3); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::Future< void >(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_new_FieldToValueMap() { + void * jresult ; + firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue > *result = 0 ; + + { + try { + result = (firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue > *)new firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue >(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL Firebase_Firestore_CSharp_FieldToValueMap_Size(void * jarg1) { + unsigned long jresult ; + firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue > *arg1 = (firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue > *) 0 ; + std::size_t result; + + arg1 = (firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue > *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__MapT_std__string_firebase__firestore__FieldValue_t) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue > const *)arg1)->Size(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (unsigned long)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_FieldToValueMap_GetUnsafeView(void * jarg1, char * jarg2) { + void * jresult ; + firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue > *arg1 = (firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue > *) 0 ; + std::string *arg2 = 0 ; + firebase::firestore::FieldValue *result = 0 ; + + arg1 = (firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue > *)jarg1; + if (!jarg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0); + return 0; + } + std::string arg2_str(jarg2); + arg2 = &arg2_str; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__MapT_std__string_firebase__firestore__FieldValue_t) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (firebase::firestore::FieldValue *) &((firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue > const *)arg1)->GetUnsafeView((std::string const &)*arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_FieldToValueMap_GetCopy(void * jarg1, char * jarg2) { + void * jresult ; + firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue > *arg1 = (firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue > *) 0 ; + std::string *arg2 = 0 ; + firebase::firestore::FieldValue result; + + arg1 = (firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue > *)jarg1; + if (!jarg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0); + return 0; + } + std::string arg2_str(jarg2); + arg2 = &arg2_str; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__MapT_std__string_firebase__firestore__FieldValue_t) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue > const *)arg1)->GetCopy((std::string const &)*arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::FieldValue(result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_FieldToValueMap_Insert(void * jarg1, char * jarg2, void * jarg3) { + firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue > *arg1 = (firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue > *) 0 ; + std::string *arg2 = 0 ; + firebase::firestore::FieldValue *arg3 = 0 ; + + arg1 = (firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue > *)jarg1; + if (!jarg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0); + return ; + } + std::string arg2_str(jarg2); + arg2 = &arg2_str; + arg3 = (firebase::firestore::FieldValue *)jarg3; + if (!arg3) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldValue const & type is null", 0); + return ; + } + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__MapT_std__string_firebase__firestore__FieldValue_t) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + (arg1)->Insert((std::string const &)*arg2,(firebase::firestore::FieldValue const &)*arg3); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_FieldToValueMap_Iterator(void * jarg1) { + void * jresult ; + firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue > *arg1 = (firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue > *) 0 ; + SwigValueWrapper< firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue >::MapIterator > result; + + arg1 = (firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue > *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__MapT_std__string_firebase__firestore__FieldValue_t) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue > const *)arg1)->Iterator(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue >::MapIterator(result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_delete_FieldToValueMap(void * jarg1) { + firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue > *arg1 = (firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue > *) 0 ; + + arg1 = (firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue > *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__MapT_std__string_firebase__firestore__FieldValue_t) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + delete arg1; + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT unsigned int SWIGSTDCALL Firebase_Firestore_CSharp_FieldToValueMapIterator_HasMore(void * jarg1) { + unsigned int jresult ; + firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue >::MapIterator *arg1 = (firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue >::MapIterator *) 0 ; + bool result; + + arg1 = (firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue >::MapIterator *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__MapT_std__string_firebase__firestore__FieldValue_t__MapIterator) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (bool)((firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue >::MapIterator const *)arg1)->HasMore(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_FieldToValueMapIterator_Advance(void * jarg1) { + firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue >::MapIterator *arg1 = (firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue >::MapIterator *) 0 ; + + arg1 = (firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue >::MapIterator *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__MapT_std__string_firebase__firestore__FieldValue_t__MapIterator) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + (arg1)->Advance(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT char * SWIGSTDCALL Firebase_Firestore_CSharp_FieldToValueMapIterator_UnsafeKeyView(void * jarg1) { + char * jresult ; + firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue >::MapIterator *arg1 = (firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue >::MapIterator *) 0 ; + std::string *result = 0 ; + + arg1 = (firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue >::MapIterator *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__MapT_std__string_firebase__firestore__FieldValue_t__MapIterator) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (std::string *) &((firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue >::MapIterator const *)arg1)->UnsafeKeyView(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = SWIG_csharp_string_callback(result->c_str()); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_FieldToValueMapIterator_UnsafeValueView(void * jarg1) { + void * jresult ; + firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue >::MapIterator *arg1 = (firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue >::MapIterator *) 0 ; + firebase::firestore::FieldValue *result = 0 ; + + arg1 = (firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue >::MapIterator *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__MapT_std__string_firebase__firestore__FieldValue_t__MapIterator) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (firebase::firestore::FieldValue *) &((firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue >::MapIterator const *)arg1)->UnsafeValueView(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT char * SWIGSTDCALL Firebase_Firestore_CSharp_FieldToValueMapIterator_KeyCopy(void * jarg1) { + char * jresult ; + firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue >::MapIterator *arg1 = (firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue >::MapIterator *) 0 ; + std::string result; + + arg1 = (firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue >::MapIterator *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__MapT_std__string_firebase__firestore__FieldValue_t__MapIterator) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue >::MapIterator const *)arg1)->KeyCopy(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = SWIG_csharp_string_callback((&result)->c_str()); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_FieldToValueMapIterator_ValueCopy(void * jarg1) { + void * jresult ; + firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue >::MapIterator *arg1 = (firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue >::MapIterator *) 0 ; + firebase::firestore::FieldValue result; + + arg1 = (firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue >::MapIterator *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__MapT_std__string_firebase__firestore__FieldValue_t__MapIterator) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue >::MapIterator const *)arg1)->ValueCopy(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::FieldValue(result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_delete_FieldToValueMapIterator(void * jarg1) { + firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue >::MapIterator *arg1 = (firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue >::MapIterator *) 0 ; + + arg1 = (firebase::firestore::csharp::Map< std::string,firebase::firestore::FieldValue >::MapIterator *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__MapT_std__string_firebase__firestore__FieldValue_t__MapIterator) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + delete arg1; + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_new_FieldPathToValueMap() { + void * jresult ; + firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue > *result = 0 ; + + { + try { + result = (firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue > *)new firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue >(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL Firebase_Firestore_CSharp_FieldPathToValueMap_Size(void * jarg1) { + unsigned long jresult ; + firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue > *arg1 = (firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue > *) 0 ; + std::size_t result; + + arg1 = (firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue > *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__MapT_firebase__firestore__FieldPath_firebase__firestore__FieldValue_t) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue > const *)arg1)->Size(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (unsigned long)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_FieldPathToValueMap_GetUnsafeView(void * jarg1, void * jarg2) { + void * jresult ; + firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue > *arg1 = (firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue > *) 0 ; + firebase::firestore::FieldPath *arg2 = 0 ; + firebase::firestore::FieldValue *result = 0 ; + + arg1 = (firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue > *)jarg1; + arg2 = (firebase::firestore::FieldPath *)jarg2; + if (!arg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldPath const & type is null", 0); + return 0; + } + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__MapT_firebase__firestore__FieldPath_firebase__firestore__FieldValue_t) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (firebase::firestore::FieldValue *) &((firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue > const *)arg1)->GetUnsafeView((firebase::firestore::FieldPath const &)*arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_FieldPathToValueMap_GetCopy(void * jarg1, void * jarg2) { + void * jresult ; + firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue > *arg1 = (firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue > *) 0 ; + firebase::firestore::FieldPath *arg2 = 0 ; + firebase::firestore::FieldValue result; + + arg1 = (firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue > *)jarg1; + arg2 = (firebase::firestore::FieldPath *)jarg2; + if (!arg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldPath const & type is null", 0); + return 0; + } + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__MapT_firebase__firestore__FieldPath_firebase__firestore__FieldValue_t) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue > const *)arg1)->GetCopy((firebase::firestore::FieldPath const &)*arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::FieldValue(result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_FieldPathToValueMap_Insert(void * jarg1, void * jarg2, void * jarg3) { + firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue > *arg1 = (firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue > *) 0 ; + firebase::firestore::FieldPath *arg2 = 0 ; + firebase::firestore::FieldValue *arg3 = 0 ; + + arg1 = (firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue > *)jarg1; + arg2 = (firebase::firestore::FieldPath *)jarg2; + if (!arg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldPath const & type is null", 0); + return ; + } + arg3 = (firebase::firestore::FieldValue *)jarg3; + if (!arg3) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldValue const & type is null", 0); + return ; + } + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__MapT_firebase__firestore__FieldPath_firebase__firestore__FieldValue_t) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + (arg1)->Insert((firebase::firestore::FieldPath const &)*arg2,(firebase::firestore::FieldValue const &)*arg3); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_FieldPathToValueMap_Iterator(void * jarg1) { + void * jresult ; + firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue > *arg1 = (firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue > *) 0 ; + SwigValueWrapper< firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue >::MapIterator > result; + + arg1 = (firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue > *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__MapT_firebase__firestore__FieldPath_firebase__firestore__FieldValue_t) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue > const *)arg1)->Iterator(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue >::MapIterator(result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_delete_FieldPathToValueMap(void * jarg1) { + firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue > *arg1 = (firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue > *) 0 ; + + arg1 = (firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue > *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__MapT_firebase__firestore__FieldPath_firebase__firestore__FieldValue_t) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + delete arg1; + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT unsigned int SWIGSTDCALL Firebase_Firestore_CSharp_FieldPathToValueMapIterator_HasMore(void * jarg1) { + unsigned int jresult ; + firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue >::MapIterator *arg1 = (firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue >::MapIterator *) 0 ; + bool result; + + arg1 = (firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue >::MapIterator *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__MapT_firebase__firestore__FieldPath_firebase__firestore__FieldValue_t__MapIterator) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (bool)((firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue >::MapIterator const *)arg1)->HasMore(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_FieldPathToValueMapIterator_Advance(void * jarg1) { + firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue >::MapIterator *arg1 = (firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue >::MapIterator *) 0 ; + + arg1 = (firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue >::MapIterator *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__MapT_firebase__firestore__FieldPath_firebase__firestore__FieldValue_t__MapIterator) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + (arg1)->Advance(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_FieldPathToValueMapIterator_UnsafeKeyView(void * jarg1) { + void * jresult ; + firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue >::MapIterator *arg1 = (firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue >::MapIterator *) 0 ; + firebase::firestore::FieldPath *result = 0 ; + + arg1 = (firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue >::MapIterator *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__MapT_firebase__firestore__FieldPath_firebase__firestore__FieldValue_t__MapIterator) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (firebase::firestore::FieldPath *) &((firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue >::MapIterator const *)arg1)->UnsafeKeyView(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_FieldPathToValueMapIterator_UnsafeValueView(void * jarg1) { + void * jresult ; + firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue >::MapIterator *arg1 = (firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue >::MapIterator *) 0 ; + firebase::firestore::FieldValue *result = 0 ; + + arg1 = (firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue >::MapIterator *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__MapT_firebase__firestore__FieldPath_firebase__firestore__FieldValue_t__MapIterator) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (firebase::firestore::FieldValue *) &((firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue >::MapIterator const *)arg1)->UnsafeValueView(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_FieldPathToValueMapIterator_KeyCopy(void * jarg1) { + void * jresult ; + firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue >::MapIterator *arg1 = (firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue >::MapIterator *) 0 ; + firebase::firestore::FieldPath result; + + arg1 = (firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue >::MapIterator *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__MapT_firebase__firestore__FieldPath_firebase__firestore__FieldValue_t__MapIterator) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue >::MapIterator const *)arg1)->KeyCopy(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::FieldPath(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_FieldPathToValueMapIterator_ValueCopy(void * jarg1) { + void * jresult ; + firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue >::MapIterator *arg1 = (firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue >::MapIterator *) 0 ; + firebase::firestore::FieldValue result; + + arg1 = (firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue >::MapIterator *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__MapT_firebase__firestore__FieldPath_firebase__firestore__FieldValue_t__MapIterator) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue >::MapIterator const *)arg1)->ValueCopy(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::FieldValue(result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_delete_FieldPathToValueMapIterator(void * jarg1) { + firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue >::MapIterator *arg1 = (firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue >::MapIterator *) 0 ; + + arg1 = (firebase::firestore::csharp::Map< firebase::firestore::FieldPath,firebase::firestore::FieldValue >::MapIterator *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__MapT_firebase__firestore__FieldPath_firebase__firestore__FieldValue_t__MapIterator) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + delete arg1; + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_ConvertFieldValueToVector(void * jarg1) { + void * jresult ; + firebase::firestore::FieldValue *arg1 = 0 ; + firebase::firestore::csharp::Vector< firebase::firestore::FieldValue > result; + + arg1 = (firebase::firestore::FieldValue *)jarg1; + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldValue const & type is null", 0); + return 0; + } + { + try { + result = firebase::firestore::csharp::ConvertFieldValueToVector((firebase::firestore::FieldValue const &)*arg1); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::csharp::Vector< firebase::firestore::FieldValue >(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_ConvertVectorToFieldValue(void * jarg1) { + void * jresult ; + firebase::firestore::csharp::Vector< firebase::firestore::FieldValue > *arg1 = 0 ; + firebase::firestore::FieldValue result; + + arg1 = (firebase::firestore::csharp::Vector< firebase::firestore::FieldValue > *)jarg1; + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::csharp::Vector< firebase::firestore::FieldValue > const & type is null", 0); + return 0; + } + { + try { + result = firebase::firestore::csharp::ConvertVectorToFieldValue((firebase::firestore::csharp::Vector< firebase::firestore::FieldValue > const &)*arg1); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::FieldValue(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_FieldValueArrayUnion(void * jarg1) { + void * jresult ; + firebase::firestore::csharp::Vector< firebase::firestore::FieldValue > *arg1 = 0 ; + firebase::firestore::FieldValue result; + + arg1 = (firebase::firestore::csharp::Vector< firebase::firestore::FieldValue > *)jarg1; + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::csharp::Vector< firebase::firestore::FieldValue > const & type is null", 0); + return 0; + } + { + try { + result = firebase::firestore::csharp::FieldValueArrayUnion((firebase::firestore::csharp::Vector< firebase::firestore::FieldValue > const &)*arg1); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::FieldValue(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_FieldValueArrayRemove(void * jarg1) { + void * jresult ; + firebase::firestore::csharp::Vector< firebase::firestore::FieldValue > *arg1 = 0 ; + firebase::firestore::FieldValue result; + + arg1 = (firebase::firestore::csharp::Vector< firebase::firestore::FieldValue > *)jarg1; + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::csharp::Vector< firebase::firestore::FieldValue > const & type is null", 0); + return 0; + } + { + try { + result = firebase::firestore::csharp::FieldValueArrayRemove((firebase::firestore::csharp::Vector< firebase::firestore::FieldValue > const &)*arg1); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::FieldValue(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_QuerySnapshotDocuments(void * jarg1) { + void * jresult ; + firebase::firestore::QuerySnapshot *arg1 = 0 ; + firebase::firestore::csharp::Vector< firebase::firestore::DocumentSnapshot > result; + + arg1 = (firebase::firestore::QuerySnapshot *)jarg1; + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::QuerySnapshot const & type is null", 0); + return 0; + } + { + try { + result = firebase::firestore::csharp::QuerySnapshotDocuments((firebase::firestore::QuerySnapshot const &)*arg1); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::csharp::Vector< firebase::firestore::DocumentSnapshot >(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_QuerySnapshotDocumentChanges(void * jarg1, int jarg2) { + void * jresult ; + firebase::firestore::QuerySnapshot *arg1 = 0 ; + firebase::firestore::MetadataChanges arg2 ; + firebase::firestore::csharp::Vector< firebase::firestore::DocumentChange > result; + + arg1 = (firebase::firestore::QuerySnapshot *)jarg1; + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::QuerySnapshot const & type is null", 0); + return 0; + } + arg2 = (firebase::firestore::MetadataChanges)jarg2; + { + try { + result = firebase::firestore::csharp::QuerySnapshotDocumentChanges((firebase::firestore::QuerySnapshot const &)*arg1,arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::csharp::Vector< firebase::firestore::DocumentChange >(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_SetOptionsMergeFieldPaths(void * jarg1) { + void * jresult ; + firebase::firestore::csharp::Vector< firebase::firestore::FieldPath > *arg1 = 0 ; + firebase::firestore::SetOptions result; + + arg1 = (firebase::firestore::csharp::Vector< firebase::firestore::FieldPath > *)jarg1; + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::csharp::Vector< firebase::firestore::FieldPath > const & type is null", 0); + return 0; + } + { + try { + result = firebase::firestore::csharp::SetOptionsMergeFieldPaths((firebase::firestore::csharp::Vector< firebase::firestore::FieldPath > const &)*arg1); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::SetOptions(result); + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_new_DocumentChangeVector() { + void * jresult ; + firebase::firestore::csharp::Vector< firebase::firestore::DocumentChange > *result = 0 ; + + { + try { + result = (firebase::firestore::csharp::Vector< firebase::firestore::DocumentChange > *)new firebase::firestore::csharp::Vector< firebase::firestore::DocumentChange >(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL Firebase_Firestore_CSharp_DocumentChangeVector_Size(void * jarg1) { + unsigned long jresult ; + firebase::firestore::csharp::Vector< firebase::firestore::DocumentChange > *arg1 = (firebase::firestore::csharp::Vector< firebase::firestore::DocumentChange > *) 0 ; + std::size_t result; + + arg1 = (firebase::firestore::csharp::Vector< firebase::firestore::DocumentChange > *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__VectorT_firebase__firestore__DocumentChange_t) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::csharp::Vector< firebase::firestore::DocumentChange > const *)arg1)->Size(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (unsigned long)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_DocumentChangeVector_GetUnsafeView(void * jarg1, unsigned long jarg2) { + void * jresult ; + firebase::firestore::csharp::Vector< firebase::firestore::DocumentChange > *arg1 = (firebase::firestore::csharp::Vector< firebase::firestore::DocumentChange > *) 0 ; + std::size_t arg2 ; + firebase::firestore::DocumentChange *result = 0 ; + + arg1 = (firebase::firestore::csharp::Vector< firebase::firestore::DocumentChange > *)jarg1; + arg2 = (std::size_t)jarg2; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__VectorT_firebase__firestore__DocumentChange_t) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (firebase::firestore::DocumentChange *) &((firebase::firestore::csharp::Vector< firebase::firestore::DocumentChange > const *)arg1)->GetUnsafeView(arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_DocumentChangeVector_GetCopy(void * jarg1, unsigned long jarg2) { + void * jresult ; + firebase::firestore::csharp::Vector< firebase::firestore::DocumentChange > *arg1 = (firebase::firestore::csharp::Vector< firebase::firestore::DocumentChange > *) 0 ; + std::size_t arg2 ; + firebase::firestore::DocumentChange result; + + arg1 = (firebase::firestore::csharp::Vector< firebase::firestore::DocumentChange > *)jarg1; + arg2 = (std::size_t)jarg2; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__VectorT_firebase__firestore__DocumentChange_t) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::csharp::Vector< firebase::firestore::DocumentChange > const *)arg1)->GetCopy(arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::DocumentChange(result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_DocumentChangeVector_PushBack(void * jarg1, void * jarg2) { + firebase::firestore::csharp::Vector< firebase::firestore::DocumentChange > *arg1 = (firebase::firestore::csharp::Vector< firebase::firestore::DocumentChange > *) 0 ; + firebase::firestore::DocumentChange *arg2 = 0 ; + + arg1 = (firebase::firestore::csharp::Vector< firebase::firestore::DocumentChange > *)jarg1; + arg2 = (firebase::firestore::DocumentChange *)jarg2; + if (!arg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::DocumentChange const & type is null", 0); + return ; + } + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__VectorT_firebase__firestore__DocumentChange_t) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + (arg1)->PushBack((firebase::firestore::DocumentChange const &)*arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_delete_DocumentChangeVector(void * jarg1) { + firebase::firestore::csharp::Vector< firebase::firestore::DocumentChange > *arg1 = (firebase::firestore::csharp::Vector< firebase::firestore::DocumentChange > *) 0 ; + + arg1 = (firebase::firestore::csharp::Vector< firebase::firestore::DocumentChange > *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__VectorT_firebase__firestore__DocumentChange_t) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + delete arg1; + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_new_DocumentSnapshotVector() { + void * jresult ; + firebase::firestore::csharp::Vector< firebase::firestore::DocumentSnapshot > *result = 0 ; + + { + try { + result = (firebase::firestore::csharp::Vector< firebase::firestore::DocumentSnapshot > *)new firebase::firestore::csharp::Vector< firebase::firestore::DocumentSnapshot >(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL Firebase_Firestore_CSharp_DocumentSnapshotVector_Size(void * jarg1) { + unsigned long jresult ; + firebase::firestore::csharp::Vector< firebase::firestore::DocumentSnapshot > *arg1 = (firebase::firestore::csharp::Vector< firebase::firestore::DocumentSnapshot > *) 0 ; + std::size_t result; + + arg1 = (firebase::firestore::csharp::Vector< firebase::firestore::DocumentSnapshot > *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__VectorT_firebase__firestore__DocumentSnapshot_t) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::csharp::Vector< firebase::firestore::DocumentSnapshot > const *)arg1)->Size(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (unsigned long)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_DocumentSnapshotVector_GetUnsafeView(void * jarg1, unsigned long jarg2) { + void * jresult ; + firebase::firestore::csharp::Vector< firebase::firestore::DocumentSnapshot > *arg1 = (firebase::firestore::csharp::Vector< firebase::firestore::DocumentSnapshot > *) 0 ; + std::size_t arg2 ; + firebase::firestore::DocumentSnapshot *result = 0 ; + + arg1 = (firebase::firestore::csharp::Vector< firebase::firestore::DocumentSnapshot > *)jarg1; + arg2 = (std::size_t)jarg2; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__VectorT_firebase__firestore__DocumentSnapshot_t) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (firebase::firestore::DocumentSnapshot *) &((firebase::firestore::csharp::Vector< firebase::firestore::DocumentSnapshot > const *)arg1)->GetUnsafeView(arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_DocumentSnapshotVector_GetCopy(void * jarg1, unsigned long jarg2) { + void * jresult ; + firebase::firestore::csharp::Vector< firebase::firestore::DocumentSnapshot > *arg1 = (firebase::firestore::csharp::Vector< firebase::firestore::DocumentSnapshot > *) 0 ; + std::size_t arg2 ; + firebase::firestore::DocumentSnapshot result; + + arg1 = (firebase::firestore::csharp::Vector< firebase::firestore::DocumentSnapshot > *)jarg1; + arg2 = (std::size_t)jarg2; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__VectorT_firebase__firestore__DocumentSnapshot_t) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::csharp::Vector< firebase::firestore::DocumentSnapshot > const *)arg1)->GetCopy(arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::DocumentSnapshot(result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_DocumentSnapshotVector_PushBack(void * jarg1, void * jarg2) { + firebase::firestore::csharp::Vector< firebase::firestore::DocumentSnapshot > *arg1 = (firebase::firestore::csharp::Vector< firebase::firestore::DocumentSnapshot > *) 0 ; + firebase::firestore::DocumentSnapshot *arg2 = 0 ; + + arg1 = (firebase::firestore::csharp::Vector< firebase::firestore::DocumentSnapshot > *)jarg1; + arg2 = (firebase::firestore::DocumentSnapshot *)jarg2; + if (!arg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::DocumentSnapshot const & type is null", 0); + return ; + } + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__VectorT_firebase__firestore__DocumentSnapshot_t) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + (arg1)->PushBack((firebase::firestore::DocumentSnapshot const &)*arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_delete_DocumentSnapshotVector(void * jarg1) { + firebase::firestore::csharp::Vector< firebase::firestore::DocumentSnapshot > *arg1 = (firebase::firestore::csharp::Vector< firebase::firestore::DocumentSnapshot > *) 0 ; + + arg1 = (firebase::firestore::csharp::Vector< firebase::firestore::DocumentSnapshot > *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__VectorT_firebase__firestore__DocumentSnapshot_t) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + delete arg1; + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_new_FieldPathVector() { + void * jresult ; + firebase::firestore::csharp::Vector< firebase::firestore::FieldPath > *result = 0 ; + + { + try { + result = (firebase::firestore::csharp::Vector< firebase::firestore::FieldPath > *)new firebase::firestore::csharp::Vector< firebase::firestore::FieldPath >(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL Firebase_Firestore_CSharp_FieldPathVector_Size(void * jarg1) { + unsigned long jresult ; + firebase::firestore::csharp::Vector< firebase::firestore::FieldPath > *arg1 = (firebase::firestore::csharp::Vector< firebase::firestore::FieldPath > *) 0 ; + std::size_t result; + + arg1 = (firebase::firestore::csharp::Vector< firebase::firestore::FieldPath > *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__VectorT_firebase__firestore__FieldPath_t) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::csharp::Vector< firebase::firestore::FieldPath > const *)arg1)->Size(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (unsigned long)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_FieldPathVector_GetUnsafeView(void * jarg1, unsigned long jarg2) { + void * jresult ; + firebase::firestore::csharp::Vector< firebase::firestore::FieldPath > *arg1 = (firebase::firestore::csharp::Vector< firebase::firestore::FieldPath > *) 0 ; + std::size_t arg2 ; + firebase::firestore::FieldPath *result = 0 ; + + arg1 = (firebase::firestore::csharp::Vector< firebase::firestore::FieldPath > *)jarg1; + arg2 = (std::size_t)jarg2; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__VectorT_firebase__firestore__FieldPath_t) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (firebase::firestore::FieldPath *) &((firebase::firestore::csharp::Vector< firebase::firestore::FieldPath > const *)arg1)->GetUnsafeView(arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_FieldPathVector_GetCopy(void * jarg1, unsigned long jarg2) { + void * jresult ; + firebase::firestore::csharp::Vector< firebase::firestore::FieldPath > *arg1 = (firebase::firestore::csharp::Vector< firebase::firestore::FieldPath > *) 0 ; + std::size_t arg2 ; + firebase::firestore::FieldPath result; + + arg1 = (firebase::firestore::csharp::Vector< firebase::firestore::FieldPath > *)jarg1; + arg2 = (std::size_t)jarg2; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__VectorT_firebase__firestore__FieldPath_t) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::csharp::Vector< firebase::firestore::FieldPath > const *)arg1)->GetCopy(arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::FieldPath(result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_FieldPathVector_PushBack(void * jarg1, void * jarg2) { + firebase::firestore::csharp::Vector< firebase::firestore::FieldPath > *arg1 = (firebase::firestore::csharp::Vector< firebase::firestore::FieldPath > *) 0 ; + firebase::firestore::FieldPath *arg2 = 0 ; + + arg1 = (firebase::firestore::csharp::Vector< firebase::firestore::FieldPath > *)jarg1; + arg2 = (firebase::firestore::FieldPath *)jarg2; + if (!arg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldPath const & type is null", 0); + return ; + } + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__VectorT_firebase__firestore__FieldPath_t) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + (arg1)->PushBack((firebase::firestore::FieldPath const &)*arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_delete_FieldPathVector(void * jarg1) { + firebase::firestore::csharp::Vector< firebase::firestore::FieldPath > *arg1 = (firebase::firestore::csharp::Vector< firebase::firestore::FieldPath > *) 0 ; + + arg1 = (firebase::firestore::csharp::Vector< firebase::firestore::FieldPath > *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__VectorT_firebase__firestore__FieldPath_t) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + delete arg1; + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_new_FieldValueVector() { + void * jresult ; + firebase::firestore::csharp::Vector< firebase::firestore::FieldValue > *result = 0 ; + + { + try { + result = (firebase::firestore::csharp::Vector< firebase::firestore::FieldValue > *)new firebase::firestore::csharp::Vector< firebase::firestore::FieldValue >(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT unsigned long SWIGSTDCALL Firebase_Firestore_CSharp_FieldValueVector_Size(void * jarg1) { + unsigned long jresult ; + firebase::firestore::csharp::Vector< firebase::firestore::FieldValue > *arg1 = (firebase::firestore::csharp::Vector< firebase::firestore::FieldValue > *) 0 ; + std::size_t result; + + arg1 = (firebase::firestore::csharp::Vector< firebase::firestore::FieldValue > *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__VectorT_firebase__firestore__FieldValue_t) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::csharp::Vector< firebase::firestore::FieldValue > const *)arg1)->Size(); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (unsigned long)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_FieldValueVector_GetUnsafeView(void * jarg1, unsigned long jarg2) { + void * jresult ; + firebase::firestore::csharp::Vector< firebase::firestore::FieldValue > *arg1 = (firebase::firestore::csharp::Vector< firebase::firestore::FieldValue > *) 0 ; + std::size_t arg2 ; + firebase::firestore::FieldValue *result = 0 ; + + arg1 = (firebase::firestore::csharp::Vector< firebase::firestore::FieldValue > *)jarg1; + arg2 = (std::size_t)jarg2; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__VectorT_firebase__firestore__FieldValue_t) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = (firebase::firestore::FieldValue *) &((firebase::firestore::csharp::Vector< firebase::firestore::FieldValue > const *)arg1)->GetUnsafeView(arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = (void *)result; + return jresult; +} + + +SWIGEXPORT void * SWIGSTDCALL Firebase_Firestore_CSharp_FieldValueVector_GetCopy(void * jarg1, unsigned long jarg2) { + void * jresult ; + firebase::firestore::csharp::Vector< firebase::firestore::FieldValue > *arg1 = (firebase::firestore::csharp::Vector< firebase::firestore::FieldValue > *) 0 ; + std::size_t arg2 ; + firebase::firestore::FieldValue result; + + arg1 = (firebase::firestore::csharp::Vector< firebase::firestore::FieldValue > *)jarg1; + arg2 = (std::size_t)jarg2; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__VectorT_firebase__firestore__FieldValue_t) " has been disposed", 0); + return 0; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + result = ((firebase::firestore::csharp::Vector< firebase::firestore::FieldValue > const *)arg1)->GetCopy(arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return 0; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return 0; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return 0; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return 0; + } + } + jresult = new firebase::firestore::FieldValue(result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_FieldValueVector_PushBack(void * jarg1, void * jarg2) { + firebase::firestore::csharp::Vector< firebase::firestore::FieldValue > *arg1 = (firebase::firestore::csharp::Vector< firebase::firestore::FieldValue > *) 0 ; + firebase::firestore::FieldValue *arg2 = 0 ; + + arg1 = (firebase::firestore::csharp::Vector< firebase::firestore::FieldValue > *)jarg1; + arg2 = (firebase::firestore::FieldValue *)jarg2; + if (!arg2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "firebase::firestore::FieldValue const & type is null", 0); + return ; + } + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__VectorT_firebase__firestore__FieldValue_t) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + (arg1)->PushBack((firebase::firestore::FieldValue const &)*arg2); + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT void SWIGSTDCALL Firebase_Firestore_CSharp_delete_FieldValueVector(void * jarg1) { + firebase::firestore::csharp::Vector< firebase::firestore::FieldValue > *arg1 = (firebase::firestore::csharp::Vector< firebase::firestore::FieldValue > *) 0 ; + + arg1 = (firebase::firestore::csharp::Vector< firebase::firestore::FieldValue > *)jarg1; + +#ifndef FIREBASE_TO_STRING +#define FIREBASE_TO_STRING2(x) #x +#define FIREBASE_TO_STRING(x) FIREBASE_TO_STRING2(#x) +#endif // FIREBASE_TO_STRING + if (!arg1) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpArgumentNullException, + FIREBASE_TO_STRING(_p_firebase__firestore__csharp__VectorT_firebase__firestore__FieldValue_t) " has been disposed", 0); + return ; + } +#undef FIREBASE_TO_STRING +#undef FIREBASE_TO_STRING2 + + { + try { + delete arg1; + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return ; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return ; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return ; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return ; + } + } +} + + +SWIGEXPORT firebase::FutureBase * SWIGSTDCALL Firebase_Firestore_CSharp_Future_QuerySnapshot_SWIGUpcast(firebase::Future< firebase::firestore::QuerySnapshot > *jarg1) { + return (firebase::FutureBase *)jarg1; +} + +SWIGEXPORT firebase::FutureBase * SWIGSTDCALL Firebase_Firestore_CSharp_Future_DocumentSnapshot_SWIGUpcast(firebase::Future< firebase::firestore::DocumentSnapshot > *jarg1) { + return (firebase::FutureBase *)jarg1; +} + +SWIGEXPORT firebase::FutureBase * SWIGSTDCALL Firebase_Firestore_CSharp_Future_DocumentReference_SWIGUpcast(firebase::Future< firebase::firestore::DocumentReference > *jarg1) { + return (firebase::FutureBase *)jarg1; +} + +SWIGEXPORT firebase::FutureBase * SWIGSTDCALL Firebase_Firestore_CSharp_Future_FirestoreVoid_SWIGUpcast(firebase::Future< void > *jarg1) { + return (firebase::FutureBase *)jarg1; +} + +SWIGEXPORT firebase::FutureBase * SWIGSTDCALL Firebase_Firestore_CSharp_Future_LoadBundleTaskProgress_SWIGUpcast(firebase::Future< firebase::firestore::LoadBundleTaskProgress > *jarg1) { + return (firebase::FutureBase *)jarg1; +} + +SWIGEXPORT firebase::FutureBase * SWIGSTDCALL Firebase_Firestore_CSharp_Future_Query_SWIGUpcast(firebase::Future< firebase::firestore::Query > *jarg1) { + return (firebase::FutureBase *)jarg1; +} + +SWIGEXPORT firebase::firestore::Query * SWIGSTDCALL Firebase_Firestore_CSharp_CollectionReferenceProxy_SWIGUpcast(firebase::firestore::CollectionReference *jarg1) { + return (firebase::firestore::Query *)jarg1; +} + +#ifdef __cplusplus +} +#endif + diff --git a/firestore/generated/src/proxy/ApiHeaders.cs b/firestore/generated/src/proxy/ApiHeaders.cs new file mode 100755 index 000000000..9b1810f2f --- /dev/null +++ b/firestore/generated/src/proxy/ApiHeaders.cs @@ -0,0 +1,53 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 3.0.2 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace Firebase.Firestore { + +internal class ApiHeaders : global::System.IDisposable { + private global::System.Runtime.InteropServices.HandleRef swigCPtr; + protected bool swigCMemOwn; + + internal ApiHeaders(global::System.IntPtr cPtr, bool cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + } + + internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ApiHeaders obj) { + return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; + } + + ~ApiHeaders() { + Dispose(); + } + + public virtual void Dispose() { + lock (FirebaseApp.disposeLock) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + FirestoreCppPINVOKE.delete_ApiHeaders(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef( + null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } + + public static void SetClientLanguage(string languageToken) { + FirestoreCppPINVOKE.ApiHeaders_SetClientLanguage(languageToken); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + + public ApiHeaders() : this(FirestoreCppPINVOKE.new_ApiHeaders(), true) { + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + +} + +} \ No newline at end of file diff --git a/firestore/generated/src/proxy/AssemblyInfo.cs b/firestore/generated/src/proxy/AssemblyInfo.cs new file mode 100755 index 000000000..44e127176 --- /dev/null +++ b/firestore/generated/src/proxy/AssemblyInfo.cs @@ -0,0 +1,41 @@ +/* + * Copyright 2016 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System.Reflection; +using System.Runtime.CompilerServices; + +// This file is used by every unity firebase C# Assembly we build. +// Tags like Firebase.Firestore are replaced with sed, per project. + +[assembly: AssemblyTitle("Firebase.Firestore")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Google Inc.")] +[assembly: AssemblyProduct("Firebase")] +[assembly: AssemblyCopyright("Copyright 2016 Google Inc. All Rights Reserved.")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Any other project to which that we want to make internals visible e.g. test +// assembly. + +[assembly: InternalsVisibleTo("Firebase.Firestore.Test")] + +// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". +// The form "{Major}.{Minor}.*" will automatically update the build and +// revision, and "{Major}.{Minor}.{Build}.*" will update just the revision. + +[assembly: AssemblyVersion("1.0.0.0")] \ No newline at end of file diff --git a/firestore/generated/src/proxy/CollectionReferenceProxy.cs b/firestore/generated/src/proxy/CollectionReferenceProxy.cs new file mode 100755 index 000000000..8dcfe4dc4 --- /dev/null +++ b/firestore/generated/src/proxy/CollectionReferenceProxy.cs @@ -0,0 +1,73 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 3.0.2 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace Firebase.Firestore { + +internal class CollectionReferenceProxy : QueryProxy { + private global::System.Runtime.InteropServices.HandleRef swigCPtr; + + internal CollectionReferenceProxy(global::System.IntPtr cPtr, bool cMemoryOwn) : base(FirestoreCppPINVOKE.CollectionReferenceProxy_SWIGUpcast(cPtr), cMemoryOwn) { + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + } + + internal static global::System.Runtime.InteropServices.HandleRef getCPtr(CollectionReferenceProxy obj) { + return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; + } + + ~CollectionReferenceProxy() { + Dispose(); + } + + public override void Dispose() { + lock (FirebaseApp.disposeLock) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + FirestoreCppPINVOKE.delete_CollectionReferenceProxy(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef( + null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + base.Dispose(); + } + } + + public virtual string id() { + string ret = FirestoreCppPINVOKE.CollectionReferenceProxy_id(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual string path() { + string ret = FirestoreCppPINVOKE.CollectionReferenceProxy_path(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual DocumentReferenceProxy Parent() { + DocumentReferenceProxy ret = new DocumentReferenceProxy(FirestoreCppPINVOKE.CollectionReferenceProxy_Parent(swigCPtr), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual DocumentReferenceProxy Document() { + DocumentReferenceProxy ret = new DocumentReferenceProxy(FirestoreCppPINVOKE.CollectionReferenceProxy_Document__SWIG_0(swigCPtr), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual DocumentReferenceProxy Document(string documentPath) { + DocumentReferenceProxy ret = new DocumentReferenceProxy(FirestoreCppPINVOKE.CollectionReferenceProxy_Document__SWIG_1(swigCPtr, documentPath), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + +} + +} \ No newline at end of file diff --git a/firestore/generated/src/proxy/DocumentChangeProxy.cs b/firestore/generated/src/proxy/DocumentChangeProxy.cs new file mode 100755 index 000000000..e3c59ea20 --- /dev/null +++ b/firestore/generated/src/proxy/DocumentChangeProxy.cs @@ -0,0 +1,76 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 3.0.2 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace Firebase.Firestore { + +internal class DocumentChangeProxy : global::System.IDisposable { + private global::System.Runtime.InteropServices.HandleRef swigCPtr; + protected bool swigCMemOwn; + + internal DocumentChangeProxy(global::System.IntPtr cPtr, bool cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + } + + internal static global::System.Runtime.InteropServices.HandleRef getCPtr(DocumentChangeProxy obj) { + return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; + } + + ~DocumentChangeProxy() { + Dispose(); + } + + public virtual void Dispose() { + lock (FirebaseApp.disposeLock) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + FirestoreCppPINVOKE.delete_DocumentChangeProxy(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef( + null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } + + public virtual DocumentChangeProxy.Type type() { + DocumentChangeProxy.Type ret = (DocumentChangeProxy.Type)FirestoreCppPINVOKE.DocumentChangeProxy_type(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual DocumentSnapshotProxy document() { + DocumentSnapshotProxy ret = new DocumentSnapshotProxy(FirestoreCppPINVOKE.DocumentChangeProxy_document(swigCPtr), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual uint old_index() { + uint ret = FirestoreCppPINVOKE.DocumentChangeProxy_old_index(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual uint new_index() { + uint ret = FirestoreCppPINVOKE.DocumentChangeProxy_new_index(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + /// Type of data that this variant object contains. + public enum Type { + Added, + Modified, + Removed + } + + public static readonly uint npos = FirestoreCppPINVOKE.DocumentChangeProxy_npos_get(); +} + +} \ No newline at end of file diff --git a/firestore/generated/src/proxy/DocumentChangeVector.cs b/firestore/generated/src/proxy/DocumentChangeVector.cs new file mode 100755 index 000000000..95bc6bacb --- /dev/null +++ b/firestore/generated/src/proxy/DocumentChangeVector.cs @@ -0,0 +1,71 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 3.0.2 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace Firebase.Firestore { + +internal class DocumentChangeVector : global::System.IDisposable { + private global::System.Runtime.InteropServices.HandleRef swigCPtr; + protected bool swigCMemOwn; + + internal DocumentChangeVector(global::System.IntPtr cPtr, bool cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + } + + internal static global::System.Runtime.InteropServices.HandleRef getCPtr(DocumentChangeVector obj) { + return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; + } + + ~DocumentChangeVector() { + Dispose(); + } + + public virtual void Dispose() { + lock (FirebaseApp.disposeLock) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + FirestoreCppPINVOKE.delete_DocumentChangeVector(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef( + null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } + + public DocumentChangeVector() : this(FirestoreCppPINVOKE.new_DocumentChangeVector(), true) { + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + + public uint Size() { + uint ret = FirestoreCppPINVOKE.DocumentChangeVector_Size(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public DocumentChangeProxy GetUnsafeView(uint i) { + DocumentChangeProxy ret = new DocumentChangeProxy(FirestoreCppPINVOKE.DocumentChangeVector_GetUnsafeView(swigCPtr, i), false); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public DocumentChangeProxy GetCopy(uint i) { + DocumentChangeProxy ret = new DocumentChangeProxy(FirestoreCppPINVOKE.DocumentChangeVector_GetCopy(swigCPtr, i), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public void PushBack(DocumentChangeProxy value) { + FirestoreCppPINVOKE.DocumentChangeVector_PushBack(swigCPtr, DocumentChangeProxy.getCPtr(value)); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + +} + +} \ No newline at end of file diff --git a/firestore/generated/src/proxy/DocumentReferenceProxy.cs b/firestore/generated/src/proxy/DocumentReferenceProxy.cs new file mode 100755 index 000000000..b728a0393 --- /dev/null +++ b/firestore/generated/src/proxy/DocumentReferenceProxy.cs @@ -0,0 +1,95 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 3.0.2 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace Firebase.Firestore { + +internal class DocumentReferenceProxy : global::System.IDisposable { + private global::System.Runtime.InteropServices.HandleRef swigCPtr; + protected bool swigCMemOwn; + + internal DocumentReferenceProxy(global::System.IntPtr cPtr, bool cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + } + + internal static global::System.Runtime.InteropServices.HandleRef getCPtr(DocumentReferenceProxy obj) { + return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; + } + + ~DocumentReferenceProxy() { + Dispose(); + } + + public virtual void Dispose() { + lock (FirebaseApp.disposeLock) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + FirestoreCppPINVOKE.delete_DocumentReferenceProxy(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef( + null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } + + public virtual string id() { + string ret = FirestoreCppPINVOKE.DocumentReferenceProxy_id(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual string path() { + string ret = FirestoreCppPINVOKE.DocumentReferenceProxy_path(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual CollectionReferenceProxy Parent() { + CollectionReferenceProxy ret = new CollectionReferenceProxy(FirestoreCppPINVOKE.DocumentReferenceProxy_Parent(swigCPtr), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual CollectionReferenceProxy Collection(string collectionPath) { + CollectionReferenceProxy ret = new CollectionReferenceProxy(FirestoreCppPINVOKE.DocumentReferenceProxy_Collection__SWIG_0(swigCPtr, collectionPath), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual System.Threading.Tasks.Task GetAsync(Source source) { + var future = FirestoreCppPINVOKE.DocumentReferenceProxy_Get__SWIG_0(swigCPtr, (int)source); + + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return Future_DocumentSnapshot.GetTask(new Future_DocumentSnapshot(future, true)); + } + + public virtual System.Threading.Tasks.Task GetAsync() { + var future = FirestoreCppPINVOKE.DocumentReferenceProxy_Get__SWIG_1(swigCPtr); + + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return Future_DocumentSnapshot.GetTask(new Future_DocumentSnapshot(future, true)); + } + + public virtual System.Threading.Tasks.Task DeleteAsync() { + System.Threading.Tasks.Task ret = Future_FirestoreVoid.GetTask( + new Future_FirestoreVoid(FirestoreCppPINVOKE.DocumentReferenceProxy_Delete(swigCPtr), true)); + + return ret; + } + + public bool is_valid() { + bool ret = FirestoreCppPINVOKE.DocumentReferenceProxy_is_valid(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + +} + +} \ No newline at end of file diff --git a/firestore/generated/src/proxy/DocumentSnapshotProxy.cs b/firestore/generated/src/proxy/DocumentSnapshotProxy.cs new file mode 100755 index 000000000..8f8447687 --- /dev/null +++ b/firestore/generated/src/proxy/DocumentSnapshotProxy.cs @@ -0,0 +1,99 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 3.0.2 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace Firebase.Firestore { + +internal class DocumentSnapshotProxy : global::System.IDisposable { + private global::System.Runtime.InteropServices.HandleRef swigCPtr; + protected bool swigCMemOwn; + + internal DocumentSnapshotProxy(global::System.IntPtr cPtr, bool cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + } + + internal static global::System.Runtime.InteropServices.HandleRef getCPtr(DocumentSnapshotProxy obj) { + return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; + } + + ~DocumentSnapshotProxy() { + Dispose(); + } + + public virtual void Dispose() { + lock (FirebaseApp.disposeLock) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + FirestoreCppPINVOKE.delete_DocumentSnapshotProxy(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef( + null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } + + public virtual string id() { + string ret = FirestoreCppPINVOKE.DocumentSnapshotProxy_id(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual DocumentReferenceProxy reference() { + DocumentReferenceProxy ret = new DocumentReferenceProxy(FirestoreCppPINVOKE.DocumentSnapshotProxy_reference(swigCPtr), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual SnapshotMetadataProxy metadata() { + SnapshotMetadataProxy ret = new SnapshotMetadataProxy(FirestoreCppPINVOKE.DocumentSnapshotProxy_metadata(swigCPtr), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual bool exists() { + bool ret = FirestoreCppPINVOKE.DocumentSnapshotProxy_exists(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual FieldValueProxy Get(string field, DocumentSnapshotProxy.ServerTimestampBehavior stb) { + FieldValueProxy ret = new FieldValueProxy(FirestoreCppPINVOKE.DocumentSnapshotProxy_Get__SWIG_0(swigCPtr, field, (int)stb), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual FieldValueProxy Get(string field) { + FieldValueProxy ret = new FieldValueProxy(FirestoreCppPINVOKE.DocumentSnapshotProxy_Get__SWIG_1(swigCPtr, field), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual FieldValueProxy Get(FieldPathProxy field, DocumentSnapshotProxy.ServerTimestampBehavior stb) { + FieldValueProxy ret = new FieldValueProxy(FirestoreCppPINVOKE.DocumentSnapshotProxy_Get__SWIG_4(swigCPtr, FieldPathProxy.getCPtr(field), (int)stb), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual FieldValueProxy Get(FieldPathProxy field) { + FieldValueProxy ret = new FieldValueProxy(FirestoreCppPINVOKE.DocumentSnapshotProxy_Get__SWIG_5(swigCPtr, FieldPathProxy.getCPtr(field)), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public enum ServerTimestampBehavior { + None = 0, + Estimate, + Previous, + Default = 0 + } + +} + +} \ No newline at end of file diff --git a/firestore/generated/src/proxy/DocumentSnapshotVector.cs b/firestore/generated/src/proxy/DocumentSnapshotVector.cs new file mode 100755 index 000000000..c7f1c886c --- /dev/null +++ b/firestore/generated/src/proxy/DocumentSnapshotVector.cs @@ -0,0 +1,71 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 3.0.2 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace Firebase.Firestore { + +internal class DocumentSnapshotVector : global::System.IDisposable { + private global::System.Runtime.InteropServices.HandleRef swigCPtr; + protected bool swigCMemOwn; + + internal DocumentSnapshotVector(global::System.IntPtr cPtr, bool cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + } + + internal static global::System.Runtime.InteropServices.HandleRef getCPtr(DocumentSnapshotVector obj) { + return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; + } + + ~DocumentSnapshotVector() { + Dispose(); + } + + public virtual void Dispose() { + lock (FirebaseApp.disposeLock) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + FirestoreCppPINVOKE.delete_DocumentSnapshotVector(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef( + null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } + + public DocumentSnapshotVector() : this(FirestoreCppPINVOKE.new_DocumentSnapshotVector(), true) { + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + + public uint Size() { + uint ret = FirestoreCppPINVOKE.DocumentSnapshotVector_Size(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public DocumentSnapshotProxy GetUnsafeView(uint i) { + DocumentSnapshotProxy ret = new DocumentSnapshotProxy(FirestoreCppPINVOKE.DocumentSnapshotVector_GetUnsafeView(swigCPtr, i), false); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public DocumentSnapshotProxy GetCopy(uint i) { + DocumentSnapshotProxy ret = new DocumentSnapshotProxy(FirestoreCppPINVOKE.DocumentSnapshotVector_GetCopy(swigCPtr, i), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public void PushBack(DocumentSnapshotProxy value) { + FirestoreCppPINVOKE.DocumentSnapshotVector_PushBack(swigCPtr, DocumentSnapshotProxy.getCPtr(value)); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + +} + +} \ No newline at end of file diff --git a/firestore/generated/src/proxy/FieldPathProxy.cs b/firestore/generated/src/proxy/FieldPathProxy.cs new file mode 100755 index 000000000..f0aeba580 --- /dev/null +++ b/firestore/generated/src/proxy/FieldPathProxy.cs @@ -0,0 +1,48 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 3.0.2 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace Firebase.Firestore { + +internal class FieldPathProxy : global::System.IDisposable { + private global::System.Runtime.InteropServices.HandleRef swigCPtr; + protected bool swigCMemOwn; + + internal FieldPathProxy(global::System.IntPtr cPtr, bool cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + } + + internal static global::System.Runtime.InteropServices.HandleRef getCPtr(FieldPathProxy obj) { + return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; + } + + ~FieldPathProxy() { + Dispose(); + } + + public virtual void Dispose() { + lock (FirebaseApp.disposeLock) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + FirestoreCppPINVOKE.delete_FieldPathProxy(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef( + null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } + + public FieldPathProxy(StringList fieldNames) : this(FirestoreCppPINVOKE.new_FieldPathProxy(StringList.getCPtr(fieldNames)), true) { + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + +} + +} \ No newline at end of file diff --git a/firestore/generated/src/proxy/FieldPathToValueMap.cs b/firestore/generated/src/proxy/FieldPathToValueMap.cs new file mode 100755 index 000000000..f8177313b --- /dev/null +++ b/firestore/generated/src/proxy/FieldPathToValueMap.cs @@ -0,0 +1,77 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 3.0.2 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace Firebase.Firestore { + +internal class FieldPathToValueMap : global::System.IDisposable { + private global::System.Runtime.InteropServices.HandleRef swigCPtr; + protected bool swigCMemOwn; + + internal FieldPathToValueMap(global::System.IntPtr cPtr, bool cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + } + + internal static global::System.Runtime.InteropServices.HandleRef getCPtr(FieldPathToValueMap obj) { + return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; + } + + ~FieldPathToValueMap() { + Dispose(); + } + + public virtual void Dispose() { + lock (FirebaseApp.disposeLock) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + FirestoreCppPINVOKE.delete_FieldPathToValueMap(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef( + null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } + + public FieldPathToValueMap() : this(FirestoreCppPINVOKE.new_FieldPathToValueMap(), true) { + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + + public uint Size() { + uint ret = FirestoreCppPINVOKE.FieldPathToValueMap_Size(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public FieldValueProxy GetUnsafeView(FieldPathProxy key) { + FieldValueProxy ret = new FieldValueProxy(FirestoreCppPINVOKE.FieldPathToValueMap_GetUnsafeView(swigCPtr, FieldPathProxy.getCPtr(key)), false); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public FieldValueProxy GetCopy(FieldPathProxy key) { + FieldValueProxy ret = new FieldValueProxy(FirestoreCppPINVOKE.FieldPathToValueMap_GetCopy(swigCPtr, FieldPathProxy.getCPtr(key)), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public void Insert(FieldPathProxy key, FieldValueProxy value) { + FirestoreCppPINVOKE.FieldPathToValueMap_Insert(swigCPtr, FieldPathProxy.getCPtr(key), FieldValueProxy.getCPtr(value)); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + + public FieldPathToValueMapIterator Iterator() { + FieldPathToValueMapIterator ret = new FieldPathToValueMapIterator(FirestoreCppPINVOKE.FieldPathToValueMap_Iterator(swigCPtr), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + +} + +} \ No newline at end of file diff --git a/firestore/generated/src/proxy/FieldPathToValueMapIterator.cs b/firestore/generated/src/proxy/FieldPathToValueMapIterator.cs new file mode 100755 index 000000000..ce74d5191 --- /dev/null +++ b/firestore/generated/src/proxy/FieldPathToValueMapIterator.cs @@ -0,0 +1,79 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 3.0.2 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace Firebase.Firestore { + +internal class FieldPathToValueMapIterator : global::System.IDisposable { + private global::System.Runtime.InteropServices.HandleRef swigCPtr; + protected bool swigCMemOwn; + + internal FieldPathToValueMapIterator(global::System.IntPtr cPtr, bool cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + } + + internal static global::System.Runtime.InteropServices.HandleRef getCPtr(FieldPathToValueMapIterator obj) { + return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; + } + + ~FieldPathToValueMapIterator() { + Dispose(); + } + + public virtual void Dispose() { + lock (FirebaseApp.disposeLock) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + FirestoreCppPINVOKE.delete_FieldPathToValueMapIterator(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef( + null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } + + public bool HasMore() { + bool ret = FirestoreCppPINVOKE.FieldPathToValueMapIterator_HasMore(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public void Advance() { + FirestoreCppPINVOKE.FieldPathToValueMapIterator_Advance(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + + public FieldPathProxy UnsafeKeyView() { + FieldPathProxy ret = new FieldPathProxy(FirestoreCppPINVOKE.FieldPathToValueMapIterator_UnsafeKeyView(swigCPtr), false); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public FieldValueProxy UnsafeValueView() { + FieldValueProxy ret = new FieldValueProxy(FirestoreCppPINVOKE.FieldPathToValueMapIterator_UnsafeValueView(swigCPtr), false); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public FieldPathProxy KeyCopy() { + FieldPathProxy ret = new FieldPathProxy(FirestoreCppPINVOKE.FieldPathToValueMapIterator_KeyCopy(swigCPtr), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public FieldValueProxy ValueCopy() { + FieldValueProxy ret = new FieldValueProxy(FirestoreCppPINVOKE.FieldPathToValueMapIterator_ValueCopy(swigCPtr), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + +} + +} \ No newline at end of file diff --git a/firestore/generated/src/proxy/FieldPathVector.cs b/firestore/generated/src/proxy/FieldPathVector.cs new file mode 100755 index 000000000..154f7ff42 --- /dev/null +++ b/firestore/generated/src/proxy/FieldPathVector.cs @@ -0,0 +1,71 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 3.0.2 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace Firebase.Firestore { + +internal class FieldPathVector : global::System.IDisposable { + private global::System.Runtime.InteropServices.HandleRef swigCPtr; + protected bool swigCMemOwn; + + internal FieldPathVector(global::System.IntPtr cPtr, bool cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + } + + internal static global::System.Runtime.InteropServices.HandleRef getCPtr(FieldPathVector obj) { + return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; + } + + ~FieldPathVector() { + Dispose(); + } + + public virtual void Dispose() { + lock (FirebaseApp.disposeLock) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + FirestoreCppPINVOKE.delete_FieldPathVector(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef( + null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } + + public FieldPathVector() : this(FirestoreCppPINVOKE.new_FieldPathVector(), true) { + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + + public uint Size() { + uint ret = FirestoreCppPINVOKE.FieldPathVector_Size(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public FieldPathProxy GetUnsafeView(uint i) { + FieldPathProxy ret = new FieldPathProxy(FirestoreCppPINVOKE.FieldPathVector_GetUnsafeView(swigCPtr, i), false); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public FieldPathProxy GetCopy(uint i) { + FieldPathProxy ret = new FieldPathProxy(FirestoreCppPINVOKE.FieldPathVector_GetCopy(swigCPtr, i), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public void PushBack(FieldPathProxy value) { + FirestoreCppPINVOKE.FieldPathVector_PushBack(swigCPtr, FieldPathProxy.getCPtr(value)); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + +} + +} \ No newline at end of file diff --git a/firestore/generated/src/proxy/FieldToValueMap.cs b/firestore/generated/src/proxy/FieldToValueMap.cs new file mode 100755 index 000000000..1a4a25bfc --- /dev/null +++ b/firestore/generated/src/proxy/FieldToValueMap.cs @@ -0,0 +1,77 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 3.0.2 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace Firebase.Firestore { + +internal class FieldToValueMap : global::System.IDisposable { + private global::System.Runtime.InteropServices.HandleRef swigCPtr; + protected bool swigCMemOwn; + + internal FieldToValueMap(global::System.IntPtr cPtr, bool cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + } + + internal static global::System.Runtime.InteropServices.HandleRef getCPtr(FieldToValueMap obj) { + return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; + } + + ~FieldToValueMap() { + Dispose(); + } + + public virtual void Dispose() { + lock (FirebaseApp.disposeLock) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + FirestoreCppPINVOKE.delete_FieldToValueMap(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef( + null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } + + public FieldToValueMap() : this(FirestoreCppPINVOKE.new_FieldToValueMap(), true) { + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + + public uint Size() { + uint ret = FirestoreCppPINVOKE.FieldToValueMap_Size(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public FieldValueProxy GetUnsafeView(string key) { + FieldValueProxy ret = new FieldValueProxy(FirestoreCppPINVOKE.FieldToValueMap_GetUnsafeView(swigCPtr, key), false); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public FieldValueProxy GetCopy(string key) { + FieldValueProxy ret = new FieldValueProxy(FirestoreCppPINVOKE.FieldToValueMap_GetCopy(swigCPtr, key), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public void Insert(string key, FieldValueProxy value) { + FirestoreCppPINVOKE.FieldToValueMap_Insert(swigCPtr, key, FieldValueProxy.getCPtr(value)); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + + public FieldToValueMapIterator Iterator() { + FieldToValueMapIterator ret = new FieldToValueMapIterator(FirestoreCppPINVOKE.FieldToValueMap_Iterator(swigCPtr), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + +} + +} \ No newline at end of file diff --git a/firestore/generated/src/proxy/FieldToValueMapIterator.cs b/firestore/generated/src/proxy/FieldToValueMapIterator.cs new file mode 100755 index 000000000..45127971d --- /dev/null +++ b/firestore/generated/src/proxy/FieldToValueMapIterator.cs @@ -0,0 +1,79 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 3.0.2 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace Firebase.Firestore { + +internal class FieldToValueMapIterator : global::System.IDisposable { + private global::System.Runtime.InteropServices.HandleRef swigCPtr; + protected bool swigCMemOwn; + + internal FieldToValueMapIterator(global::System.IntPtr cPtr, bool cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + } + + internal static global::System.Runtime.InteropServices.HandleRef getCPtr(FieldToValueMapIterator obj) { + return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; + } + + ~FieldToValueMapIterator() { + Dispose(); + } + + public virtual void Dispose() { + lock (FirebaseApp.disposeLock) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + FirestoreCppPINVOKE.delete_FieldToValueMapIterator(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef( + null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } + + public bool HasMore() { + bool ret = FirestoreCppPINVOKE.FieldToValueMapIterator_HasMore(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public void Advance() { + FirestoreCppPINVOKE.FieldToValueMapIterator_Advance(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + + public string UnsafeKeyView() { + string ret = FirestoreCppPINVOKE.FieldToValueMapIterator_UnsafeKeyView(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public FieldValueProxy UnsafeValueView() { + FieldValueProxy ret = new FieldValueProxy(FirestoreCppPINVOKE.FieldToValueMapIterator_UnsafeValueView(swigCPtr), false); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public string KeyCopy() { + string ret = FirestoreCppPINVOKE.FieldToValueMapIterator_KeyCopy(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public FieldValueProxy ValueCopy() { + FieldValueProxy ret = new FieldValueProxy(FirestoreCppPINVOKE.FieldToValueMapIterator_ValueCopy(swigCPtr), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + +} + +} \ No newline at end of file diff --git a/firestore/generated/src/proxy/FieldValueProxy.cs b/firestore/generated/src/proxy/FieldValueProxy.cs new file mode 100755 index 000000000..96d377931 --- /dev/null +++ b/firestore/generated/src/proxy/FieldValueProxy.cs @@ -0,0 +1,228 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 3.0.2 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace Firebase.Firestore { + +internal class FieldValueProxy : global::System.IDisposable { + private global::System.Runtime.InteropServices.HandleRef swigCPtr; + protected bool swigCMemOwn; + + internal FieldValueProxy(global::System.IntPtr cPtr, bool cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + } + + internal static global::System.Runtime.InteropServices.HandleRef getCPtr(FieldValueProxy obj) { + return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; + } + + ~FieldValueProxy() { + Dispose(); + } + + public virtual void Dispose() { + lock (FirebaseApp.disposeLock) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + FirestoreCppPINVOKE.delete_FieldValueProxy(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef( + null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } + + public static FieldValueProxy Boolean(bool value) { + FieldValueProxy ret = new FieldValueProxy(FirestoreCppPINVOKE.FieldValueProxy_Boolean(value), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public static FieldValueProxy Integer(long value) { + FieldValueProxy ret = new FieldValueProxy(FirestoreCppPINVOKE.FieldValueProxy_Integer(value), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public static FieldValueProxy Double(double value) { + FieldValueProxy ret = new FieldValueProxy(FirestoreCppPINVOKE.FieldValueProxy_Double(value), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public static FieldValueProxy Timestamp(TimestampProxy value) { + FieldValueProxy ret = new FieldValueProxy(FirestoreCppPINVOKE.FieldValueProxy_Timestamp(TimestampProxy.getCPtr(value)), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public static FieldValueProxy String(string value) { + FieldValueProxy ret = new FieldValueProxy(FirestoreCppPINVOKE.FieldValueProxy_String(value), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public static FieldValueProxy Blob(SWIGTYPE_p_unsigned_char value, uint size) { + FieldValueProxy ret = new FieldValueProxy(FirestoreCppPINVOKE.FieldValueProxy_Blob(SWIGTYPE_p_unsigned_char.getCPtr(value), size), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public static FieldValueProxy Reference(DocumentReferenceProxy value) { + FieldValueProxy ret = new FieldValueProxy(FirestoreCppPINVOKE.FieldValueProxy_Reference(DocumentReferenceProxy.getCPtr(value)), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public static FieldValueProxy GeoPoint(GeoPointProxy value) { + FieldValueProxy ret = new FieldValueProxy(FirestoreCppPINVOKE.FieldValueProxy_GeoPoint(GeoPointProxy.getCPtr(value)), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public FieldValueProxy.Type type() { + FieldValueProxy.Type ret = (FieldValueProxy.Type)FirestoreCppPINVOKE.FieldValueProxy_type(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public bool is_null() { + bool ret = FirestoreCppPINVOKE.FieldValueProxy_is_null(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public bool is_array() { + bool ret = FirestoreCppPINVOKE.FieldValueProxy_is_array(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public bool is_map() { + bool ret = FirestoreCppPINVOKE.FieldValueProxy_is_map(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public bool boolean_value() { + bool ret = FirestoreCppPINVOKE.FieldValueProxy_boolean_value(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public long integer_value() { + long ret = FirestoreCppPINVOKE.FieldValueProxy_integer_value(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public double double_value() { + double ret = FirestoreCppPINVOKE.FieldValueProxy_double_value(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public TimestampProxy timestamp_value() { + TimestampProxy ret = new TimestampProxy(FirestoreCppPINVOKE.FieldValueProxy_timestamp_value(swigCPtr), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public string string_value() { + string ret = FirestoreCppPINVOKE.FieldValueProxy_string_value(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public SWIGTYPE_p_unsigned_char blob_value() { + global::System.IntPtr cPtr = FirestoreCppPINVOKE.FieldValueProxy_blob_value(swigCPtr); + SWIGTYPE_p_unsigned_char ret = (cPtr == global::System.IntPtr.Zero) ? null : new SWIGTYPE_p_unsigned_char(cPtr, false); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public uint blob_size() { + uint ret = FirestoreCppPINVOKE.FieldValueProxy_blob_size(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public DocumentReferenceProxy reference_value() { + DocumentReferenceProxy ret = new DocumentReferenceProxy(FirestoreCppPINVOKE.FieldValueProxy_reference_value(swigCPtr), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public GeoPointProxy geo_point_value() { + GeoPointProxy ret = new GeoPointProxy(FirestoreCppPINVOKE.FieldValueProxy_geo_point_value(swigCPtr), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public bool is_valid() { + bool ret = FirestoreCppPINVOKE.FieldValueProxy_is_valid(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public static FieldValueProxy Null() { + FieldValueProxy ret = new FieldValueProxy(FirestoreCppPINVOKE.FieldValueProxy_Null(), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public static FieldValueProxy Delete() { + FieldValueProxy ret = new FieldValueProxy(FirestoreCppPINVOKE.FieldValueProxy_Delete(), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public static FieldValueProxy ServerTimestamp() { + FieldValueProxy ret = new FieldValueProxy(FirestoreCppPINVOKE.FieldValueProxy_ServerTimestamp(), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public static FieldValueProxy IntegerIncrement(long byValue) { + FieldValueProxy ret = new FieldValueProxy(FirestoreCppPINVOKE.FieldValueProxy_IntegerIncrement(byValue), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public static FieldValueProxy DoubleIncrement(double byValue) { + FieldValueProxy ret = new FieldValueProxy(FirestoreCppPINVOKE.FieldValueProxy_DoubleIncrement(byValue), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + /// Type of data that this variant object contains. + public enum Type { + Null, + Boolean, + Integer, + Double, + Timestamp, + String, + Blob, + Reference, + GeoPoint, + Array, + Map, + Delete, + ServerTimestamp, + ArrayUnion, + ArrayRemove, + IncrementInteger, + IncrementDouble + } + +} + +} \ No newline at end of file diff --git a/firestore/generated/src/proxy/FieldValueVector.cs b/firestore/generated/src/proxy/FieldValueVector.cs new file mode 100755 index 000000000..aa45d504a --- /dev/null +++ b/firestore/generated/src/proxy/FieldValueVector.cs @@ -0,0 +1,71 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 3.0.2 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace Firebase.Firestore { + +internal class FieldValueVector : global::System.IDisposable { + private global::System.Runtime.InteropServices.HandleRef swigCPtr; + protected bool swigCMemOwn; + + internal FieldValueVector(global::System.IntPtr cPtr, bool cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + } + + internal static global::System.Runtime.InteropServices.HandleRef getCPtr(FieldValueVector obj) { + return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; + } + + ~FieldValueVector() { + Dispose(); + } + + public virtual void Dispose() { + lock (FirebaseApp.disposeLock) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + FirestoreCppPINVOKE.delete_FieldValueVector(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef( + null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } + + public FieldValueVector() : this(FirestoreCppPINVOKE.new_FieldValueVector(), true) { + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + + public uint Size() { + uint ret = FirestoreCppPINVOKE.FieldValueVector_Size(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public FieldValueProxy GetUnsafeView(uint i) { + FieldValueProxy ret = new FieldValueProxy(FirestoreCppPINVOKE.FieldValueVector_GetUnsafeView(swigCPtr, i), false); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public FieldValueProxy GetCopy(uint i) { + FieldValueProxy ret = new FieldValueProxy(FirestoreCppPINVOKE.FieldValueVector_GetCopy(swigCPtr, i), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public void PushBack(FieldValueProxy value) { + FirestoreCppPINVOKE.FieldValueVector_PushBack(swigCPtr, FieldValueProxy.getCPtr(value)); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + +} + +} \ No newline at end of file diff --git a/firestore/generated/src/proxy/FirestoreCpp.cs b/firestore/generated/src/proxy/FirestoreCpp.cs new file mode 100755 index 000000000..4d1b1379e --- /dev/null +++ b/firestore/generated/src/proxy/FirestoreCpp.cs @@ -0,0 +1,214 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 3.0.2 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace Firebase.Firestore { + +internal sealed class FirestoreCpp { + public static ListenerRegistrationProxy AddDocumentSnapshotListener(DocumentReferenceProxy reference, MetadataChanges metadataChanges, int callbackId, Firebase.Firestore.DocumentReference.ListenerDelegate callback) { + ListenerRegistrationProxy ret = new ListenerRegistrationProxy(FirestoreCppPINVOKE.AddDocumentSnapshotListener(DocumentReferenceProxy.getCPtr(reference), (int)metadataChanges, callbackId, callback), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public static ListenerRegistrationProxy AddQuerySnapshotListener(QueryProxy query, MetadataChanges metadataChanges, int callbackId, Firebase.Firestore.Query.ListenerDelegate callback) { + ListenerRegistrationProxy ret = new ListenerRegistrationProxy(FirestoreCppPINVOKE.AddQuerySnapshotListener(QueryProxy.getCPtr(query), (int)metadataChanges, callbackId, callback), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public static ListenerRegistrationProxy AddSnapshotsInSyncListener(FirestoreProxy firestore, int callbackId, Firebase.Firestore.FirebaseFirestore.SnapshotsInSyncDelegate callback) { + ListenerRegistrationProxy ret = new ListenerRegistrationProxy(FirestoreCppPINVOKE.AddSnapshotsInSyncListener(FirestoreProxy.getCPtr(firestore), callbackId, callback), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public static void LoadBundleWithCallback( + FirestoreProxy firestore, string bundleData, int callbackId, + Firebase.Firestore.FirebaseFirestore.LoadBundleTaskProgressDelegate callback) { + FirestoreCppPINVOKE.LoadBundleWithCallback(FirestoreProxy.getCPtr(firestore), bundleData, + callbackId, callback); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) + throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + + public static FirestoreProxy GetFirestoreInstance(FirebaseApp app) { + global::System.IntPtr cPtr = FirestoreCppPINVOKE.GetFirestoreInstance(FirebaseApp.getCPtr(app)); + FirestoreProxy ret = (cPtr == global::System.IntPtr.Zero) ? null : new FirestoreProxy(cPtr, false); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public static void ReleaseFirestoreInstance(FirestoreProxy firestore) { + FirestoreCppPINVOKE.ReleaseFirestoreInstance(FirestoreProxy.getCPtr(firestore)); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + + public static FieldToValueMap ConvertFieldValueToMap(FieldValueProxy fieldValue) { + FieldToValueMap ret = new FieldToValueMap(FirestoreCppPINVOKE.ConvertFieldValueToMap(FieldValueProxy.getCPtr(fieldValue)), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public static FieldValueProxy ConvertMapToFieldValue(FieldToValueMap wrapper) { + FieldValueProxy ret = new FieldValueProxy(FirestoreCppPINVOKE.ConvertMapToFieldValue(FieldToValueMap.getCPtr(wrapper)), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public static FieldValueProxy ConvertSnapshotToFieldValue(DocumentSnapshotProxy snapshot, DocumentSnapshotProxy.ServerTimestampBehavior stb) { + FieldValueProxy ret = new FieldValueProxy(FirestoreCppPINVOKE.ConvertSnapshotToFieldValue(DocumentSnapshotProxy.getCPtr(snapshot), (int)stb), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public static void WriteBatchUpdate(WriteBatchProxy batch, DocumentReferenceProxy doc, FieldValueProxy fieldValue) { + FirestoreCppPINVOKE.WriteBatchUpdate__SWIG_0(WriteBatchProxy.getCPtr(batch), DocumentReferenceProxy.getCPtr(doc), FieldValueProxy.getCPtr(fieldValue)); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + + public static void WriteBatchUpdate(WriteBatchProxy batch, DocumentReferenceProxy doc, FieldToValueMap wrapper) { + FirestoreCppPINVOKE.WriteBatchUpdate__SWIG_1(WriteBatchProxy.getCPtr(batch), DocumentReferenceProxy.getCPtr(doc), FieldToValueMap.getCPtr(wrapper)); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + + public static void WriteBatchUpdate(WriteBatchProxy batch, DocumentReferenceProxy doc, FieldPathToValueMap wrapper) { + FirestoreCppPINVOKE.WriteBatchUpdate__SWIG_2(WriteBatchProxy.getCPtr(batch), DocumentReferenceProxy.getCPtr(doc), FieldPathToValueMap.getCPtr(wrapper)); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + + public static System.Threading.Tasks.Task DocumentReferenceSetAsync(DocumentReferenceProxy doc, FieldValueProxy fieldValue, SetOptionsProxy options) { + System.Threading.Tasks.Task ret = Future_FirestoreVoid.GetTask( + new Future_FirestoreVoid(FirestoreCppPINVOKE.DocumentReferenceSet(DocumentReferenceProxy.getCPtr(doc), FieldValueProxy.getCPtr(fieldValue), SetOptionsProxy.getCPtr(options)), true)); + + return ret; + } + + public static System.Threading.Tasks.Task DocumentReferenceUpdateAsync(DocumentReferenceProxy doc, FieldValueProxy fieldValue) { + System.Threading.Tasks.Task ret = Future_FirestoreVoid.GetTask( + new Future_FirestoreVoid(FirestoreCppPINVOKE.DocumentReferenceUpdate__SWIG_0(DocumentReferenceProxy.getCPtr(doc), FieldValueProxy.getCPtr(fieldValue)), true)); + + return ret; + } + + public static System.Threading.Tasks.Task DocumentReferenceUpdateAsync(DocumentReferenceProxy doc, FieldPathToValueMap wrapper) { + System.Threading.Tasks.Task ret = Future_FirestoreVoid.GetTask( + new Future_FirestoreVoid(FirestoreCppPINVOKE.DocumentReferenceUpdate__SWIG_1(DocumentReferenceProxy.getCPtr(doc), FieldPathToValueMap.getCPtr(wrapper)), true)); + + return ret; + } + + public static QueryProxy QueryWhereArrayContainsAny(QueryProxy query, string field, FieldValueProxy values) { + QueryProxy ret = new QueryProxy(FirestoreCppPINVOKE.QueryWhereArrayContainsAny__SWIG_0(QueryProxy.getCPtr(query), field, FieldValueProxy.getCPtr(values)), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public static QueryProxy QueryWhereArrayContainsAny(QueryProxy query, FieldPathProxy field, FieldValueProxy values) { + QueryProxy ret = new QueryProxy(FirestoreCppPINVOKE.QueryWhereArrayContainsAny__SWIG_1(QueryProxy.getCPtr(query), FieldPathProxy.getCPtr(field), FieldValueProxy.getCPtr(values)), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public static QueryProxy QueryWhereIn(QueryProxy query, string field, FieldValueProxy values) { + QueryProxy ret = new QueryProxy(FirestoreCppPINVOKE.QueryWhereIn__SWIG_0(QueryProxy.getCPtr(query), field, FieldValueProxy.getCPtr(values)), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public static QueryProxy QueryWhereIn(QueryProxy query, FieldPathProxy field, FieldValueProxy values) { + QueryProxy ret = new QueryProxy(FirestoreCppPINVOKE.QueryWhereIn__SWIG_1(QueryProxy.getCPtr(query), FieldPathProxy.getCPtr(field), FieldValueProxy.getCPtr(values)), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public static QueryProxy QueryWhereNotIn(QueryProxy query, string field, FieldValueProxy values) { + QueryProxy ret = new QueryProxy(FirestoreCppPINVOKE.QueryWhereNotIn__SWIG_0(QueryProxy.getCPtr(query), field, FieldValueProxy.getCPtr(values)), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public static QueryProxy QueryWhereNotIn(QueryProxy query, FieldPathProxy field, FieldValueProxy values) { + QueryProxy ret = new QueryProxy(FirestoreCppPINVOKE.QueryWhereNotIn__SWIG_1(QueryProxy.getCPtr(query), FieldPathProxy.getCPtr(field), FieldValueProxy.getCPtr(values)), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public static QueryProxy QueryStartAt(QueryProxy query, FieldValueProxy values) { + QueryProxy ret = new QueryProxy(FirestoreCppPINVOKE.QueryStartAt(QueryProxy.getCPtr(query), FieldValueProxy.getCPtr(values)), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public static QueryProxy QueryStartAfter(QueryProxy query, FieldValueProxy values) { + QueryProxy ret = new QueryProxy(FirestoreCppPINVOKE.QueryStartAfter(QueryProxy.getCPtr(query), FieldValueProxy.getCPtr(values)), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public static QueryProxy QueryEndBefore(QueryProxy query, FieldValueProxy values) { + QueryProxy ret = new QueryProxy(FirestoreCppPINVOKE.QueryEndBefore(QueryProxy.getCPtr(query), FieldValueProxy.getCPtr(values)), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public static QueryProxy QueryEndAt(QueryProxy query, FieldValueProxy values) { + QueryProxy ret = new QueryProxy(FirestoreCppPINVOKE.QueryEndAt(QueryProxy.getCPtr(query), FieldValueProxy.getCPtr(values)), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public static void WriteBatchSet(WriteBatchProxy writeBatch, DocumentReferenceProxy document, FieldValueProxy data, SetOptionsProxy options) { + FirestoreCppPINVOKE.WriteBatchSet(WriteBatchProxy.getCPtr(writeBatch), DocumentReferenceProxy.getCPtr(document), FieldValueProxy.getCPtr(data), SetOptionsProxy.getCPtr(options)); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + + public static FieldValueVector ConvertFieldValueToVector(FieldValueProxy value) { + FieldValueVector ret = new FieldValueVector(FirestoreCppPINVOKE.ConvertFieldValueToVector(FieldValueProxy.getCPtr(value)), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public static FieldValueProxy ConvertVectorToFieldValue(FieldValueVector wrapper) { + FieldValueProxy ret = new FieldValueProxy(FirestoreCppPINVOKE.ConvertVectorToFieldValue(FieldValueVector.getCPtr(wrapper)), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public static FieldValueProxy FieldValueArrayUnion(FieldValueVector wrapper) { + FieldValueProxy ret = new FieldValueProxy(FirestoreCppPINVOKE.FieldValueArrayUnion(FieldValueVector.getCPtr(wrapper)), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public static FieldValueProxy FieldValueArrayRemove(FieldValueVector wrapper) { + FieldValueProxy ret = new FieldValueProxy(FirestoreCppPINVOKE.FieldValueArrayRemove(FieldValueVector.getCPtr(wrapper)), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public static DocumentSnapshotVector QuerySnapshotDocuments(QuerySnapshotProxy snapshot) { + DocumentSnapshotVector ret = new DocumentSnapshotVector(FirestoreCppPINVOKE.QuerySnapshotDocuments(QuerySnapshotProxy.getCPtr(snapshot)), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public static DocumentChangeVector QuerySnapshotDocumentChanges(QuerySnapshotProxy snapshot, MetadataChanges metadataChanges) { + DocumentChangeVector ret = new DocumentChangeVector(FirestoreCppPINVOKE.QuerySnapshotDocumentChanges(QuerySnapshotProxy.getCPtr(snapshot), (int)metadataChanges), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public static SetOptionsProxy SetOptionsMergeFieldPaths(FieldPathVector fields) { + SetOptionsProxy ret = new SetOptionsProxy(FirestoreCppPINVOKE.SetOptionsMergeFieldPaths(FieldPathVector.getCPtr(fields)), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + +} + +} \ No newline at end of file diff --git a/firestore/generated/src/proxy/FirestoreCppPINVOKE.cs b/firestore/generated/src/proxy/FirestoreCppPINVOKE.cs new file mode 100755 index 000000000..7f6a2dc7a --- /dev/null +++ b/firestore/generated/src/proxy/FirestoreCppPINVOKE.cs @@ -0,0 +1,1587 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 3.0.2 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace Firebase.Firestore { + +class FirestoreCppPINVOKE { + + protected class SWIGExceptionHelper { + + public delegate void ExceptionDelegate(string message); + public delegate void ExceptionArgumentDelegate(string message, string paramName); + + static ExceptionDelegate applicationDelegate = new ExceptionDelegate(SetPendingApplicationException); + static ExceptionDelegate arithmeticDelegate = new ExceptionDelegate(SetPendingArithmeticException); + static ExceptionDelegate divideByZeroDelegate = new ExceptionDelegate(SetPendingDivideByZeroException); + static ExceptionDelegate indexOutOfRangeDelegate = new ExceptionDelegate(SetPendingIndexOutOfRangeException); + static ExceptionDelegate invalidCastDelegate = new ExceptionDelegate(SetPendingInvalidCastException); + static ExceptionDelegate invalidOperationDelegate = new ExceptionDelegate(SetPendingInvalidOperationException); + static ExceptionDelegate ioDelegate = new ExceptionDelegate(SetPendingIOException); + static ExceptionDelegate nullReferenceDelegate = new ExceptionDelegate(SetPendingNullReferenceException); + static ExceptionDelegate outOfMemoryDelegate = new ExceptionDelegate(SetPendingOutOfMemoryException); + static ExceptionDelegate overflowDelegate = new ExceptionDelegate(SetPendingOverflowException); + static ExceptionDelegate systemDelegate = new ExceptionDelegate(SetPendingSystemException); + + static ExceptionArgumentDelegate argumentDelegate = new ExceptionArgumentDelegate(SetPendingArgumentException); + static ExceptionArgumentDelegate argumentNullDelegate = new ExceptionArgumentDelegate(SetPendingArgumentNullException); + static ExceptionArgumentDelegate argumentOutOfRangeDelegate = new ExceptionArgumentDelegate(SetPendingArgumentOutOfRangeException); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "SWIGRegisterExceptionCallbacks_FirestoreCpp")] + public static extern void SWIGRegisterExceptionCallbacks_FirestoreCpp( + ExceptionDelegate applicationDelegate, + ExceptionDelegate arithmeticDelegate, + ExceptionDelegate divideByZeroDelegate, + ExceptionDelegate indexOutOfRangeDelegate, + ExceptionDelegate invalidCastDelegate, + ExceptionDelegate invalidOperationDelegate, + ExceptionDelegate ioDelegate, + ExceptionDelegate nullReferenceDelegate, + ExceptionDelegate outOfMemoryDelegate, + ExceptionDelegate overflowDelegate, + ExceptionDelegate systemExceptionDelegate); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "SWIGRegisterExceptionArgumentCallbacks_FirestoreCpp")] + public static extern void SWIGRegisterExceptionCallbacksArgument_FirestoreCpp( + ExceptionArgumentDelegate argumentDelegate, + ExceptionArgumentDelegate argumentNullDelegate, + ExceptionArgumentDelegate argumentOutOfRangeDelegate); + + [MonoPInvokeCallback(typeof(ExceptionDelegate))] + static void SetPendingApplicationException(string message) { + SWIGPendingException.Set(new global::System.ApplicationException(message, SWIGPendingException.Retrieve())); + } + [MonoPInvokeCallback(typeof(ExceptionDelegate))] + static void SetPendingArithmeticException(string message) { + SWIGPendingException.Set(new global::System.ArithmeticException(message, SWIGPendingException.Retrieve())); + } + [MonoPInvokeCallback(typeof(ExceptionDelegate))] + static void SetPendingDivideByZeroException(string message) { + SWIGPendingException.Set(new global::System.DivideByZeroException(message, SWIGPendingException.Retrieve())); + } + [MonoPInvokeCallback(typeof(ExceptionDelegate))] + static void SetPendingIndexOutOfRangeException(string message) { + SWIGPendingException.Set(new global::System.IndexOutOfRangeException(message, SWIGPendingException.Retrieve())); + } + [MonoPInvokeCallback(typeof(ExceptionDelegate))] + static void SetPendingInvalidCastException(string message) { + SWIGPendingException.Set(new global::System.InvalidCastException(message, SWIGPendingException.Retrieve())); + } + [MonoPInvokeCallback(typeof(ExceptionDelegate))] + static void SetPendingInvalidOperationException(string message) { + SWIGPendingException.Set(new global::System.InvalidOperationException(message, SWIGPendingException.Retrieve())); + } + [MonoPInvokeCallback(typeof(ExceptionDelegate))] + static void SetPendingIOException(string message) { + SWIGPendingException.Set(new global::System.IO.IOException(message, SWIGPendingException.Retrieve())); + } + [MonoPInvokeCallback(typeof(ExceptionDelegate))] + static void SetPendingNullReferenceException(string message) { + SWIGPendingException.Set(new global::System.NullReferenceException(message, SWIGPendingException.Retrieve())); + } + [MonoPInvokeCallback(typeof(ExceptionDelegate))] + static void SetPendingOutOfMemoryException(string message) { + SWIGPendingException.Set(new global::System.OutOfMemoryException(message, SWIGPendingException.Retrieve())); + } + [MonoPInvokeCallback(typeof(ExceptionDelegate))] + static void SetPendingOverflowException(string message) { + SWIGPendingException.Set(new global::System.OverflowException(message, SWIGPendingException.Retrieve())); + } + [MonoPInvokeCallback(typeof(ExceptionDelegate))] + static void SetPendingSystemException(string message) { + SWIGPendingException.Set(new global::System.SystemException(message, SWIGPendingException.Retrieve())); + } + + [MonoPInvokeCallback(typeof(ExceptionArgumentDelegate))] + static void SetPendingArgumentException(string message, string paramName) { + SWIGPendingException.Set(new global::System.ArgumentException(message, paramName, SWIGPendingException.Retrieve())); + } + [MonoPInvokeCallback(typeof(ExceptionArgumentDelegate))] + static void SetPendingArgumentNullException(string message, string paramName) { + global::System.Exception e = SWIGPendingException.Retrieve(); + if (e != null) message = message + " Inner Exception: " + e.Message; + SWIGPendingException.Set(new global::System.ArgumentNullException(paramName, message)); + } + [MonoPInvokeCallback(typeof(ExceptionArgumentDelegate))] + static void SetPendingArgumentOutOfRangeException(string message, string paramName) { + global::System.Exception e = SWIGPendingException.Retrieve(); + if (e != null) message = message + " Inner Exception: " + e.Message; + SWIGPendingException.Set(new global::System.ArgumentOutOfRangeException(paramName, message)); + } + + static SWIGExceptionHelper() { + SWIGRegisterExceptionCallbacks_FirestoreCpp( + applicationDelegate, + arithmeticDelegate, + divideByZeroDelegate, + indexOutOfRangeDelegate, + invalidCastDelegate, + invalidOperationDelegate, + ioDelegate, + nullReferenceDelegate, + outOfMemoryDelegate, + overflowDelegate, + systemDelegate); + + SWIGRegisterExceptionCallbacksArgument_FirestoreCpp( + argumentDelegate, + argumentNullDelegate, + argumentOutOfRangeDelegate); + } + } + + protected static SWIGExceptionHelper swigExceptionHelper = new SWIGExceptionHelper(); + + public class SWIGPendingException { + [global::System.ThreadStatic] + private static global::System.Exception pendingException = null; + private static int numExceptionsPending = 0; + + public static bool Pending { + get { + bool pending = false; + if (numExceptionsPending > 0) + if (pendingException != null) + pending = true; + return pending; + } + } + + public static void Set(global::System.Exception e) { + if (pendingException != null) + throw new global::System.ApplicationException("FATAL: An earlier pending exception from unmanaged code was missed and thus not thrown (" + pendingException.ToString() + ")", e); + pendingException = e; + lock(typeof(FirestoreCppPINVOKE)) { + numExceptionsPending++; + } + } + + public static global::System.Exception Retrieve() { + global::System.Exception e = null; + if (numExceptionsPending > 0) { + if (pendingException != null) { + e = pendingException; + pendingException = null; + lock(typeof(FirestoreCppPINVOKE)) { + numExceptionsPending--; + } + } + } + return e; + } + } + + + protected class SWIGStringHelper { + + public delegate string SWIGStringDelegate(string message); + static SWIGStringDelegate stringDelegate = new SWIGStringDelegate(CreateString); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "SWIGRegisterStringCallback_FirestoreCpp")] + public static extern void SWIGRegisterStringCallback_FirestoreCpp(SWIGStringDelegate stringDelegate); + + [MonoPInvokeCallback(typeof(SWIGStringDelegate))] + static string CreateString(string cString) { + return cString; + } + + static SWIGStringHelper() { + SWIGRegisterStringCallback_FirestoreCpp(stringDelegate); + } + } + + static protected SWIGStringHelper swigStringHelper = new SWIGStringHelper(); + + + static FirestoreCppPINVOKE() { + } + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_new_GeoPointProxy")] + public static extern global::System.IntPtr new_GeoPointProxy(double jarg1, double jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_GeoPointProxy_latitude")] + public static extern double GeoPointProxy_latitude(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_GeoPointProxy_longitude")] + public static extern double GeoPointProxy_longitude(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_delete_GeoPointProxy")] + public static extern void delete_GeoPointProxy(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_new_TimestampProxy__SWIG_0")] + public static extern global::System.IntPtr new_TimestampProxy__SWIG_0(); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_new_TimestampProxy__SWIG_1")] + public static extern global::System.IntPtr new_TimestampProxy__SWIG_1(long jarg1, int jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_new_TimestampProxy__SWIG_2")] + public static extern global::System.IntPtr new_TimestampProxy__SWIG_2(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_TimestampProxy_Now")] + public static extern global::System.IntPtr TimestampProxy_Now(); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_TimestampProxy_seconds")] + public static extern long TimestampProxy_seconds(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_TimestampProxy_nanoseconds")] + public static extern int TimestampProxy_nanoseconds(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_TimestampProxy_ToString")] + public static extern string TimestampProxy_ToString(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_delete_TimestampProxy")] + public static extern void delete_TimestampProxy(global::System.Runtime.InteropServices.HandleRef jarg1); + + class FirestoreExceptionHelper { + // The C# delegate for the C++ `firestore_exception_callback`. + public delegate void FirestoreExceptionDelegate(string message); + static FirestoreExceptionDelegate firestoreDelegate = + new FirestoreExceptionDelegate(SetPendingFirestoreException); + + // IMPORTANT: the next line has to be a single line. Otherwise, it won't be + // correctly handled by `swig_post_process.py` which relies on a regex to + // replace the name of the DLL import. + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "FirestoreExceptionRegisterCallback")] + public static extern void FirestoreExceptionRegisterCallback( + FirestoreExceptionDelegate firestoreCallback); + + [MonoPInvokeCallback(typeof(FirestoreExceptionDelegate))] + static void SetPendingFirestoreException(string message) { + SWIGPendingException.Set(new FirestoreException(FirestoreError.Internal, message)); + } + + static FirestoreExceptionHelper() { + FirestoreExceptionRegisterCallback(firestoreDelegate); + } + } + +// Suppress the warning about an unused variable. +#pragma warning disable 414 + static FirestoreExceptionHelper exceptionHelper = new FirestoreExceptionHelper(); +#pragma warning restore 414 + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_new_Future_QuerySnapshot")] + public static extern global::System.IntPtr new_Future_QuerySnapshot(); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_Future_QuerySnapshot_SWIG_OnCompletion")] + public static extern global::System.IntPtr Future_QuerySnapshot_SWIG_OnCompletion(global::System.Runtime.InteropServices.HandleRef jarg1, Future_QuerySnapshot.SWIG_CompletionDelegate jarg2, int jarg3); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_Future_QuerySnapshot_SWIG_FreeCompletionData")] + public static extern void Future_QuerySnapshot_SWIG_FreeCompletionData(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.IntPtr jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_Future_QuerySnapshot_GetResult")] + public static extern global::System.IntPtr Future_QuerySnapshot_GetResult(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_delete_Future_QuerySnapshot")] + public static extern void delete_Future_QuerySnapshot(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_new_Future_DocumentSnapshot")] + public static extern global::System.IntPtr new_Future_DocumentSnapshot(); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_Future_DocumentSnapshot_SWIG_OnCompletion")] + public static extern global::System.IntPtr Future_DocumentSnapshot_SWIG_OnCompletion(global::System.Runtime.InteropServices.HandleRef jarg1, Future_DocumentSnapshot.SWIG_CompletionDelegate jarg2, int jarg3); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_Future_DocumentSnapshot_SWIG_FreeCompletionData")] + public static extern void Future_DocumentSnapshot_SWIG_FreeCompletionData(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.IntPtr jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_Future_DocumentSnapshot_GetResult")] + public static extern global::System.IntPtr Future_DocumentSnapshot_GetResult(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_delete_Future_DocumentSnapshot")] + public static extern void delete_Future_DocumentSnapshot(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_new_Future_DocumentReference")] + public static extern global::System.IntPtr new_Future_DocumentReference(); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_Future_DocumentReference_SWIG_OnCompletion")] + public static extern global::System.IntPtr Future_DocumentReference_SWIG_OnCompletion(global::System.Runtime.InteropServices.HandleRef jarg1, Future_DocumentReference.SWIG_CompletionDelegate jarg2, int jarg3); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_Future_DocumentReference_SWIG_FreeCompletionData")] + public static extern void Future_DocumentReference_SWIG_FreeCompletionData(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.IntPtr jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_Future_DocumentReference_GetResult")] + public static extern global::System.IntPtr Future_DocumentReference_GetResult(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_delete_Future_DocumentReference")] + public static extern void delete_Future_DocumentReference(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_new_Future_FirestoreVoid")] + public static extern global::System.IntPtr new_Future_FirestoreVoid(); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_Future_FirestoreVoid_SWIG_OnCompletion")] + public static extern global::System.IntPtr Future_FirestoreVoid_SWIG_OnCompletion(global::System.Runtime.InteropServices.HandleRef jarg1, Future_FirestoreVoid.SWIG_CompletionDelegate jarg2, int jarg3); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_Future_FirestoreVoid_SWIG_FreeCompletionData")] + public static extern void Future_FirestoreVoid_SWIG_FreeCompletionData(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.IntPtr jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_delete_Future_FirestoreVoid")] + public static extern void delete_Future_FirestoreVoid(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_new_Future_LoadBundleTaskProgress")] + public static extern global::System.IntPtr new_Future_LoadBundleTaskProgress(); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_Future_LoadBundleTaskProgress_SWIG_OnCompletion")] + public static extern global::System.IntPtr Future_LoadBundleTaskProgress_SWIG_OnCompletion( + global::System.Runtime.InteropServices.HandleRef jarg1, + Future_LoadBundleTaskProgress.SWIG_CompletionDelegate jarg2, int jarg3); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = + "Firebase_Firestore_CSharp_Future_LoadBundleTaskProgress_SWIG_FreeCompletionData")] + public static extern void Future_LoadBundleTaskProgress_SWIG_FreeCompletionData( + global::System.Runtime.InteropServices.HandleRef jarg1, global::System.IntPtr jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_Future_LoadBundleTaskProgress_GetResult")] + public static extern global::System.IntPtr Future_LoadBundleTaskProgress_GetResult( + global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_delete_Future_LoadBundleTaskProgress")] + public static extern void delete_Future_LoadBundleTaskProgress( + global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_new_Future_Query")] + public static extern global::System.IntPtr new_Future_Query(); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_Future_Query_SWIG_OnCompletion")] + public static extern global::System.IntPtr Future_Query_SWIG_OnCompletion( + global::System.Runtime.InteropServices.HandleRef jarg1, + Future_Query.SWIG_CompletionDelegate jarg2, int jarg3); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_Future_Query_SWIG_FreeCompletionData")] + public static extern void Future_Query_SWIG_FreeCompletionData( + global::System.Runtime.InteropServices.HandleRef jarg1, global::System.IntPtr jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_Future_Query_GetResult")] + public static extern global::System.IntPtr Future_Query_GetResult( + global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_delete_Future_Query")] + public static extern void delete_Future_Query( + global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_delete_ListenerRegistrationProxy")] + public static extern void delete_ListenerRegistrationProxy(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_ListenerRegistrationProxy_Remove")] + public static extern void ListenerRegistrationProxy_Remove(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_new_FieldPathProxy")] + public static extern global::System.IntPtr new_FieldPathProxy(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_delete_FieldPathProxy")] + public static extern void delete_FieldPathProxy(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_new_SetOptionsProxy")] + public static extern global::System.IntPtr new_SetOptionsProxy(); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_delete_SetOptionsProxy")] + public static extern void delete_SetOptionsProxy(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_SetOptionsProxy_Merge")] + public static extern global::System.IntPtr SetOptionsProxy_Merge(); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_SetOptionsProxy_MergeFields")] + public static extern global::System.IntPtr SetOptionsProxy_MergeFields(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_delete_DocumentReferenceProxy")] + public static extern void delete_DocumentReferenceProxy(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_DocumentReferenceProxy_id")] + public static extern string DocumentReferenceProxy_id(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_DocumentReferenceProxy_path")] + public static extern string DocumentReferenceProxy_path(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_DocumentReferenceProxy_Parent")] + public static extern global::System.IntPtr DocumentReferenceProxy_Parent(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_DocumentReferenceProxy_Collection__SWIG_0")] + public static extern global::System.IntPtr DocumentReferenceProxy_Collection__SWIG_0(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_DocumentReferenceProxy_Get__SWIG_0")] + public static extern global::System.IntPtr DocumentReferenceProxy_Get__SWIG_0(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_DocumentReferenceProxy_Get__SWIG_1")] + public static extern global::System.IntPtr DocumentReferenceProxy_Get__SWIG_1(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_DocumentReferenceProxy_Delete")] + public static extern global::System.IntPtr DocumentReferenceProxy_Delete(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_DocumentReferenceProxy_is_valid")] + public static extern bool DocumentReferenceProxy_is_valid(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_new_SnapshotMetadataProxy__SWIG_0")] + public static extern global::System.IntPtr new_SnapshotMetadataProxy__SWIG_0(); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_new_SnapshotMetadataProxy__SWIG_1")] + public static extern global::System.IntPtr new_SnapshotMetadataProxy__SWIG_1(bool jarg1, bool jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_new_SnapshotMetadataProxy__SWIG_2")] + public static extern global::System.IntPtr new_SnapshotMetadataProxy__SWIG_2(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_SnapshotMetadataProxy_has_pending_writes")] + public static extern bool SnapshotMetadataProxy_has_pending_writes(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_SnapshotMetadataProxy_is_from_cache")] + public static extern bool SnapshotMetadataProxy_is_from_cache(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_SnapshotMetadataProxy_ToString")] + public static extern string SnapshotMetadataProxy_ToString(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_delete_SnapshotMetadataProxy")] + public static extern void delete_SnapshotMetadataProxy(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_delete_DocumentSnapshotProxy")] + public static extern void delete_DocumentSnapshotProxy(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_DocumentSnapshotProxy_id")] + public static extern string DocumentSnapshotProxy_id(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_DocumentSnapshotProxy_reference")] + public static extern global::System.IntPtr DocumentSnapshotProxy_reference(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_DocumentSnapshotProxy_metadata")] + public static extern global::System.IntPtr DocumentSnapshotProxy_metadata(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_DocumentSnapshotProxy_exists")] + public static extern bool DocumentSnapshotProxy_exists(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_DocumentSnapshotProxy_Get__SWIG_0")] + public static extern global::System.IntPtr DocumentSnapshotProxy_Get__SWIG_0(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2, int jarg3); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_DocumentSnapshotProxy_Get__SWIG_1")] + public static extern global::System.IntPtr DocumentSnapshotProxy_Get__SWIG_1(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_DocumentSnapshotProxy_Get__SWIG_4")] + public static extern global::System.IntPtr DocumentSnapshotProxy_Get__SWIG_4(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, int jarg3); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_DocumentSnapshotProxy_Get__SWIG_5")] + public static extern global::System.IntPtr DocumentSnapshotProxy_Get__SWIG_5(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_DocumentChangeProxy_npos_get")] + public static extern uint DocumentChangeProxy_npos_get(); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_delete_DocumentChangeProxy")] + public static extern void delete_DocumentChangeProxy(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_DocumentChangeProxy_type")] + public static extern int DocumentChangeProxy_type(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_DocumentChangeProxy_document")] + public static extern global::System.IntPtr DocumentChangeProxy_document(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_DocumentChangeProxy_old_index")] + public static extern uint DocumentChangeProxy_old_index(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_DocumentChangeProxy_new_index")] + public static extern uint DocumentChangeProxy_new_index(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_delete_FieldValueProxy")] + public static extern void delete_FieldValueProxy(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_FieldValueProxy_Boolean")] + public static extern global::System.IntPtr FieldValueProxy_Boolean(bool jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_FieldValueProxy_Integer")] + public static extern global::System.IntPtr FieldValueProxy_Integer(long jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_FieldValueProxy_Double")] + public static extern global::System.IntPtr FieldValueProxy_Double(double jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_FieldValueProxy_Timestamp")] + public static extern global::System.IntPtr FieldValueProxy_Timestamp(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_FieldValueProxy_String")] + public static extern global::System.IntPtr FieldValueProxy_String(string jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_FieldValueProxy_Blob")] + public static extern global::System.IntPtr FieldValueProxy_Blob(global::System.Runtime.InteropServices.HandleRef jarg1, uint jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_FieldValueProxy_Reference")] + public static extern global::System.IntPtr FieldValueProxy_Reference(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_FieldValueProxy_GeoPoint")] + public static extern global::System.IntPtr FieldValueProxy_GeoPoint(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_FieldValueProxy_type")] + public static extern int FieldValueProxy_type(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_FieldValueProxy_is_null")] + public static extern bool FieldValueProxy_is_null(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_FieldValueProxy_is_array")] + public static extern bool FieldValueProxy_is_array(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_FieldValueProxy_is_map")] + public static extern bool FieldValueProxy_is_map(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_FieldValueProxy_boolean_value")] + public static extern bool FieldValueProxy_boolean_value(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_FieldValueProxy_integer_value")] + public static extern long FieldValueProxy_integer_value(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_FieldValueProxy_double_value")] + public static extern double FieldValueProxy_double_value(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_FieldValueProxy_timestamp_value")] + public static extern global::System.IntPtr FieldValueProxy_timestamp_value(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_FieldValueProxy_string_value")] + public static extern string FieldValueProxy_string_value(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_FieldValueProxy_blob_value")] + public static extern global::System.IntPtr FieldValueProxy_blob_value(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_FieldValueProxy_blob_size")] + public static extern uint FieldValueProxy_blob_size(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_FieldValueProxy_reference_value")] + public static extern global::System.IntPtr FieldValueProxy_reference_value(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_FieldValueProxy_geo_point_value")] + public static extern global::System.IntPtr FieldValueProxy_geo_point_value(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_FieldValueProxy_is_valid")] + public static extern bool FieldValueProxy_is_valid(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_FieldValueProxy_Null")] + public static extern global::System.IntPtr FieldValueProxy_Null(); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_FieldValueProxy_Delete")] + public static extern global::System.IntPtr FieldValueProxy_Delete(); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_FieldValueProxy_ServerTimestamp")] + public static extern global::System.IntPtr FieldValueProxy_ServerTimestamp(); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_FieldValueProxy_IntegerIncrement")] + public static extern global::System.IntPtr FieldValueProxy_IntegerIncrement(long jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_FieldValueProxy_DoubleIncrement")] + public static extern global::System.IntPtr FieldValueProxy_DoubleIncrement(double jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_delete_WriteBatchProxy")] + public static extern void delete_WriteBatchProxy(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_WriteBatchProxy_Delete")] + public static extern global::System.IntPtr WriteBatchProxy_Delete(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_WriteBatchProxy_Commit")] + public static extern global::System.IntPtr WriteBatchProxy_Commit(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_delete_QueryProxy")] + public static extern void delete_QueryProxy(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_QueryProxy_WhereEqualTo__SWIG_0")] + public static extern global::System.IntPtr QueryProxy_WhereEqualTo__SWIG_0(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2, global::System.Runtime.InteropServices.HandleRef jarg3); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_QueryProxy_WhereEqualTo__SWIG_1")] + public static extern global::System.IntPtr QueryProxy_WhereEqualTo__SWIG_1(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, global::System.Runtime.InteropServices.HandleRef jarg3); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_QueryProxy_WhereNotEqualTo__SWIG_0")] + public static extern global::System.IntPtr QueryProxy_WhereNotEqualTo__SWIG_0(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2, global::System.Runtime.InteropServices.HandleRef jarg3); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_QueryProxy_WhereNotEqualTo__SWIG_1")] + public static extern global::System.IntPtr QueryProxy_WhereNotEqualTo__SWIG_1(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, global::System.Runtime.InteropServices.HandleRef jarg3); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_QueryProxy_WhereLessThan__SWIG_0")] + public static extern global::System.IntPtr QueryProxy_WhereLessThan__SWIG_0(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2, global::System.Runtime.InteropServices.HandleRef jarg3); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_QueryProxy_WhereLessThan__SWIG_1")] + public static extern global::System.IntPtr QueryProxy_WhereLessThan__SWIG_1(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, global::System.Runtime.InteropServices.HandleRef jarg3); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_QueryProxy_WhereLessThanOrEqualTo__SWIG_0")] + public static extern global::System.IntPtr QueryProxy_WhereLessThanOrEqualTo__SWIG_0(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2, global::System.Runtime.InteropServices.HandleRef jarg3); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_QueryProxy_WhereLessThanOrEqualTo__SWIG_1")] + public static extern global::System.IntPtr QueryProxy_WhereLessThanOrEqualTo__SWIG_1(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, global::System.Runtime.InteropServices.HandleRef jarg3); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_QueryProxy_WhereGreaterThan__SWIG_0")] + public static extern global::System.IntPtr QueryProxy_WhereGreaterThan__SWIG_0(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2, global::System.Runtime.InteropServices.HandleRef jarg3); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_QueryProxy_WhereGreaterThan__SWIG_1")] + public static extern global::System.IntPtr QueryProxy_WhereGreaterThan__SWIG_1(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, global::System.Runtime.InteropServices.HandleRef jarg3); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_QueryProxy_WhereGreaterThanOrEqualTo__SWIG_0")] + public static extern global::System.IntPtr QueryProxy_WhereGreaterThanOrEqualTo__SWIG_0(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2, global::System.Runtime.InteropServices.HandleRef jarg3); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_QueryProxy_WhereGreaterThanOrEqualTo__SWIG_1")] + public static extern global::System.IntPtr QueryProxy_WhereGreaterThanOrEqualTo__SWIG_1(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, global::System.Runtime.InteropServices.HandleRef jarg3); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_QueryProxy_WhereArrayContains__SWIG_0")] + public static extern global::System.IntPtr QueryProxy_WhereArrayContains__SWIG_0(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2, global::System.Runtime.InteropServices.HandleRef jarg3); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_QueryProxy_WhereArrayContains__SWIG_1")] + public static extern global::System.IntPtr QueryProxy_WhereArrayContains__SWIG_1(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, global::System.Runtime.InteropServices.HandleRef jarg3); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_QueryProxy_OrderBy__SWIG_0")] + public static extern global::System.IntPtr QueryProxy_OrderBy__SWIG_0(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2, int jarg3); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_QueryProxy_OrderBy__SWIG_1")] + public static extern global::System.IntPtr QueryProxy_OrderBy__SWIG_1(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_QueryProxy_OrderBy__SWIG_2")] + public static extern global::System.IntPtr QueryProxy_OrderBy__SWIG_2(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, int jarg3); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_QueryProxy_OrderBy__SWIG_3")] + public static extern global::System.IntPtr QueryProxy_OrderBy__SWIG_3(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_QueryProxy_Limit")] + public static extern global::System.IntPtr QueryProxy_Limit(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_QueryProxy_LimitToLast")] + public static extern global::System.IntPtr QueryProxy_LimitToLast(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_QueryProxy_StartAt")] + public static extern global::System.IntPtr QueryProxy_StartAt(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_QueryProxy_StartAfter")] + public static extern global::System.IntPtr QueryProxy_StartAfter(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_QueryProxy_EndBefore")] + public static extern global::System.IntPtr QueryProxy_EndBefore(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_QueryProxy_EndAt")] + public static extern global::System.IntPtr QueryProxy_EndAt(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_QueryProxy_Get__SWIG_0")] + public static extern global::System.IntPtr QueryProxy_Get__SWIG_0(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_QueryProxy_Get__SWIG_1")] + public static extern global::System.IntPtr QueryProxy_Get__SWIG_1(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_CollectionReferenceProxy_id")] + public static extern string CollectionReferenceProxy_id(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_CollectionReferenceProxy_path")] + public static extern string CollectionReferenceProxy_path(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_CollectionReferenceProxy_Parent")] + public static extern global::System.IntPtr CollectionReferenceProxy_Parent(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_CollectionReferenceProxy_Document__SWIG_0")] + public static extern global::System.IntPtr CollectionReferenceProxy_Document__SWIG_0(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_CollectionReferenceProxy_Document__SWIG_1")] + public static extern global::System.IntPtr CollectionReferenceProxy_Document__SWIG_1(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_delete_CollectionReferenceProxy")] + public static extern void delete_CollectionReferenceProxy(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_delete_QuerySnapshotProxy")] + public static extern void delete_QuerySnapshotProxy(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_QuerySnapshotProxy_query")] + public static extern global::System.IntPtr QuerySnapshotProxy_query(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_QuerySnapshotProxy_metadata")] + public static extern global::System.IntPtr QuerySnapshotProxy_metadata(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_QuerySnapshotProxy_size")] + public static extern uint QuerySnapshotProxy_size(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_SettingsProxy_kCacheSizeUnlimited_get")] + public static extern long SettingsProxy_kCacheSizeUnlimited_get(); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_new_SettingsProxy__SWIG_0")] + public static extern global::System.IntPtr new_SettingsProxy__SWIG_0(); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_new_SettingsProxy__SWIG_1")] + public static extern global::System.IntPtr new_SettingsProxy__SWIG_1(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_SettingsProxy_host")] + public static extern string SettingsProxy_host(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_SettingsProxy_is_ssl_enabled")] + public static extern bool SettingsProxy_is_ssl_enabled(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_SettingsProxy_is_persistence_enabled")] + public static extern bool SettingsProxy_is_persistence_enabled(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_SettingsProxy_cache_size_bytes")] + public static extern long SettingsProxy_cache_size_bytes(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_SettingsProxy_set_host")] + public static extern void SettingsProxy_set_host(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_SettingsProxy_set_ssl_enabled")] + public static extern void SettingsProxy_set_ssl_enabled(global::System.Runtime.InteropServices.HandleRef jarg1, bool jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_SettingsProxy_set_persistence_enabled")] + public static extern void SettingsProxy_set_persistence_enabled(global::System.Runtime.InteropServices.HandleRef jarg1, bool jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_SettingsProxy_set_cache_size_bytes")] + public static extern void SettingsProxy_set_cache_size_bytes(global::System.Runtime.InteropServices.HandleRef jarg1, long jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_delete_SettingsProxy")] + public static extern void delete_SettingsProxy(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_LoadBundleTaskProgressProxy_documents_loaded")] + public static extern int LoadBundleTaskProgressProxy_documents_loaded( + global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_LoadBundleTaskProgressProxy_total_documents")] + public static extern int LoadBundleTaskProgressProxy_total_documents( + global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_LoadBundleTaskProgressProxy_bytes_loaded")] + public static extern long LoadBundleTaskProgressProxy_bytes_loaded( + global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_LoadBundleTaskProgressProxy_total_bytes")] + public static extern long LoadBundleTaskProgressProxy_total_bytes( + global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_LoadBundleTaskProgressProxy_state")] + public static extern int LoadBundleTaskProgressProxy_state( + global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_delete_LoadBundleTaskProgressProxy")] + public static extern void delete_LoadBundleTaskProgressProxy( + global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_delete_FirestoreProxy")] + public static extern void delete_FirestoreProxy(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_FirestoreProxy_app__SWIG_0")] + public static extern global::System.IntPtr FirestoreProxy_app__SWIG_0(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_FirestoreProxy_Collection__SWIG_0")] + public static extern global::System.IntPtr FirestoreProxy_Collection__SWIG_0(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_FirestoreProxy_Document__SWIG_0")] + public static extern global::System.IntPtr FirestoreProxy_Document__SWIG_0(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_FirestoreProxy_CollectionGroup__SWIG_0")] + public static extern global::System.IntPtr FirestoreProxy_CollectionGroup__SWIG_0(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_FirestoreProxy_settings")] + public static extern global::System.IntPtr FirestoreProxy_settings(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_FirestoreProxy_set_settings")] + public static extern void FirestoreProxy_set_settings(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_FirestoreProxy_batch")] + public static extern global::System.IntPtr FirestoreProxy_batch(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_FirestoreProxy_set_log_level")] + public static extern void FirestoreProxy_set_log_level(int jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_FirestoreProxy_DisableNetwork")] + public static extern global::System.IntPtr FirestoreProxy_DisableNetwork(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_FirestoreProxy_EnableNetwork")] + public static extern global::System.IntPtr FirestoreProxy_EnableNetwork(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_FirestoreProxy_Terminate")] + public static extern global::System.IntPtr FirestoreProxy_Terminate(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_FirestoreProxy_WaitForPendingWrites")] + public static extern global::System.IntPtr FirestoreProxy_WaitForPendingWrites(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_FirestoreProxy_ClearPersistence")] + public static extern global::System.IntPtr FirestoreProxy_ClearPersistence(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_FirestoreProxy_NamedQuery")] + public static extern global::System.IntPtr FirestoreProxy_NamedQuery( + global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_AddDocumentSnapshotListener")] + public static extern global::System.IntPtr AddDocumentSnapshotListener(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2, int jarg3, Firebase.Firestore.DocumentReference.ListenerDelegate jarg4); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_AddQuerySnapshotListener")] + public static extern global::System.IntPtr AddQuerySnapshotListener(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2, int jarg3, Firebase.Firestore.Query.ListenerDelegate jarg4); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_AddSnapshotsInSyncListener")] + public static extern global::System.IntPtr AddSnapshotsInSyncListener(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2, Firebase.Firestore.FirebaseFirestore.SnapshotsInSyncDelegate jarg3); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_LoadBundleWithCallback")] + public static extern void LoadBundleWithCallback( + global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2, int jarg3, + Firebase.Firestore.FirebaseFirestore.LoadBundleTaskProgressDelegate jarg4); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_GetFirestoreInstance")] + public static extern global::System.IntPtr GetFirestoreInstance(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_ReleaseFirestoreInstance")] + public static extern void ReleaseFirestoreInstance(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_ApiHeaders_SetClientLanguage")] + public static extern void ApiHeaders_SetClientLanguage(string jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_new_ApiHeaders")] + public static extern global::System.IntPtr new_ApiHeaders(); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_delete_ApiHeaders")] + public static extern void delete_ApiHeaders(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_ConvertFieldValueToMap")] + public static extern global::System.IntPtr ConvertFieldValueToMap(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_ConvertMapToFieldValue")] + public static extern global::System.IntPtr ConvertMapToFieldValue(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_ConvertSnapshotToFieldValue")] + public static extern global::System.IntPtr ConvertSnapshotToFieldValue(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_WriteBatchUpdate__SWIG_0")] + public static extern void WriteBatchUpdate__SWIG_0(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, global::System.Runtime.InteropServices.HandleRef jarg3); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_WriteBatchUpdate__SWIG_1")] + public static extern void WriteBatchUpdate__SWIG_1(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, global::System.Runtime.InteropServices.HandleRef jarg3); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_WriteBatchUpdate__SWIG_2")] + public static extern void WriteBatchUpdate__SWIG_2(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, global::System.Runtime.InteropServices.HandleRef jarg3); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_DocumentReferenceSet")] + public static extern global::System.IntPtr DocumentReferenceSet(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, global::System.Runtime.InteropServices.HandleRef jarg3); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_DocumentReferenceUpdate__SWIG_0")] + public static extern global::System.IntPtr DocumentReferenceUpdate__SWIG_0(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_DocumentReferenceUpdate__SWIG_1")] + public static extern global::System.IntPtr DocumentReferenceUpdate__SWIG_1(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_QueryWhereArrayContainsAny__SWIG_0")] + public static extern global::System.IntPtr QueryWhereArrayContainsAny__SWIG_0(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2, global::System.Runtime.InteropServices.HandleRef jarg3); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_QueryWhereArrayContainsAny__SWIG_1")] + public static extern global::System.IntPtr QueryWhereArrayContainsAny__SWIG_1(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, global::System.Runtime.InteropServices.HandleRef jarg3); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_QueryWhereIn__SWIG_0")] + public static extern global::System.IntPtr QueryWhereIn__SWIG_0(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2, global::System.Runtime.InteropServices.HandleRef jarg3); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_QueryWhereIn__SWIG_1")] + public static extern global::System.IntPtr QueryWhereIn__SWIG_1(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, global::System.Runtime.InteropServices.HandleRef jarg3); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_QueryWhereNotIn__SWIG_0")] + public static extern global::System.IntPtr QueryWhereNotIn__SWIG_0(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2, global::System.Runtime.InteropServices.HandleRef jarg3); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_QueryWhereNotIn__SWIG_1")] + public static extern global::System.IntPtr QueryWhereNotIn__SWIG_1(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, global::System.Runtime.InteropServices.HandleRef jarg3); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_QueryStartAt")] + public static extern global::System.IntPtr QueryStartAt(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_QueryStartAfter")] + public static extern global::System.IntPtr QueryStartAfter(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_QueryEndBefore")] + public static extern global::System.IntPtr QueryEndBefore(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_QueryEndAt")] + public static extern global::System.IntPtr QueryEndAt(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_WriteBatchSet")] + public static extern void WriteBatchSet(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, global::System.Runtime.InteropServices.HandleRef jarg3, global::System.Runtime.InteropServices.HandleRef jarg4); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_TransactionResultOfGetProxy_is_valid")] + public static extern bool TransactionResultOfGetProxy_is_valid(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_TransactionResultOfGetProxy_TakeSnapshot")] + public static extern global::System.IntPtr TransactionResultOfGetProxy_TakeSnapshot(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_TransactionResultOfGetProxy_error_code")] + public static extern int TransactionResultOfGetProxy_error_code(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_TransactionResultOfGetProxy_error_message")] + public static extern string TransactionResultOfGetProxy_error_message(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_delete_TransactionResultOfGetProxy")] + public static extern void delete_TransactionResultOfGetProxy(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_TransactionCallbackProxy_callback_id")] + public static extern int TransactionCallbackProxy_callback_id(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_TransactionCallbackProxy_Get")] + public static extern global::System.IntPtr TransactionCallbackProxy_Get(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_TransactionCallbackProxy_Update__SWIG_0")] + public static extern bool TransactionCallbackProxy_Update__SWIG_0(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, global::System.Runtime.InteropServices.HandleRef jarg3); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_TransactionCallbackProxy_Update__SWIG_1")] + public static extern bool TransactionCallbackProxy_Update__SWIG_1(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, global::System.Runtime.InteropServices.HandleRef jarg3); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_TransactionCallbackProxy_Update__SWIG_2")] + public static extern bool TransactionCallbackProxy_Update__SWIG_2(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, global::System.Runtime.InteropServices.HandleRef jarg3); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_TransactionCallbackProxy_Set")] + public static extern bool TransactionCallbackProxy_Set(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, global::System.Runtime.InteropServices.HandleRef jarg3, global::System.Runtime.InteropServices.HandleRef jarg4); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_TransactionCallbackProxy_Delete")] + public static extern bool TransactionCallbackProxy_Delete(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_TransactionCallbackProxy_OnCompletion")] + public static extern void TransactionCallbackProxy_OnCompletion(global::System.Runtime.InteropServices.HandleRef jarg1, bool jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_delete_TransactionCallbackProxy")] + public static extern void delete_TransactionCallbackProxy(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_new_TransactionManagerProxy")] + public static extern global::System.IntPtr new_TransactionManagerProxy(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_delete_TransactionManagerProxy")] + public static extern void delete_TransactionManagerProxy(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_TransactionManagerProxy_CppDispose")] + public static extern void TransactionManagerProxy_CppDispose(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_TransactionManagerProxy_RunTransaction")] + public static extern global::System.IntPtr TransactionManagerProxy_RunTransaction(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2, Firebase.Firestore.TransactionManager.TransactionCallbackDelegate jarg3); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_new_FieldToValueMap")] + public static extern global::System.IntPtr new_FieldToValueMap(); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_FieldToValueMap_Size")] + public static extern uint FieldToValueMap_Size(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_FieldToValueMap_GetUnsafeView")] + public static extern global::System.IntPtr FieldToValueMap_GetUnsafeView(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_FieldToValueMap_GetCopy")] + public static extern global::System.IntPtr FieldToValueMap_GetCopy(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_FieldToValueMap_Insert")] + public static extern void FieldToValueMap_Insert(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2, global::System.Runtime.InteropServices.HandleRef jarg3); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_FieldToValueMap_Iterator")] + public static extern global::System.IntPtr FieldToValueMap_Iterator(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_delete_FieldToValueMap")] + public static extern void delete_FieldToValueMap(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_FieldToValueMapIterator_HasMore")] + public static extern bool FieldToValueMapIterator_HasMore(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_FieldToValueMapIterator_Advance")] + public static extern void FieldToValueMapIterator_Advance(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_FieldToValueMapIterator_UnsafeKeyView")] + public static extern string FieldToValueMapIterator_UnsafeKeyView(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_FieldToValueMapIterator_UnsafeValueView")] + public static extern global::System.IntPtr FieldToValueMapIterator_UnsafeValueView(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_FieldToValueMapIterator_KeyCopy")] + public static extern string FieldToValueMapIterator_KeyCopy(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_FieldToValueMapIterator_ValueCopy")] + public static extern global::System.IntPtr FieldToValueMapIterator_ValueCopy(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_delete_FieldToValueMapIterator")] + public static extern void delete_FieldToValueMapIterator(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_new_FieldPathToValueMap")] + public static extern global::System.IntPtr new_FieldPathToValueMap(); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_FieldPathToValueMap_Size")] + public static extern uint FieldPathToValueMap_Size(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_FieldPathToValueMap_GetUnsafeView")] + public static extern global::System.IntPtr FieldPathToValueMap_GetUnsafeView(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_FieldPathToValueMap_GetCopy")] + public static extern global::System.IntPtr FieldPathToValueMap_GetCopy(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_FieldPathToValueMap_Insert")] + public static extern void FieldPathToValueMap_Insert(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, global::System.Runtime.InteropServices.HandleRef jarg3); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_FieldPathToValueMap_Iterator")] + public static extern global::System.IntPtr FieldPathToValueMap_Iterator(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_delete_FieldPathToValueMap")] + public static extern void delete_FieldPathToValueMap(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_FieldPathToValueMapIterator_HasMore")] + public static extern bool FieldPathToValueMapIterator_HasMore(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_FieldPathToValueMapIterator_Advance")] + public static extern void FieldPathToValueMapIterator_Advance(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_FieldPathToValueMapIterator_UnsafeKeyView")] + public static extern global::System.IntPtr FieldPathToValueMapIterator_UnsafeKeyView(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_FieldPathToValueMapIterator_UnsafeValueView")] + public static extern global::System.IntPtr FieldPathToValueMapIterator_UnsafeValueView(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_FieldPathToValueMapIterator_KeyCopy")] + public static extern global::System.IntPtr FieldPathToValueMapIterator_KeyCopy(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_FieldPathToValueMapIterator_ValueCopy")] + public static extern global::System.IntPtr FieldPathToValueMapIterator_ValueCopy(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_delete_FieldPathToValueMapIterator")] + public static extern void delete_FieldPathToValueMapIterator(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_ConvertFieldValueToVector")] + public static extern global::System.IntPtr ConvertFieldValueToVector(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_ConvertVectorToFieldValue")] + public static extern global::System.IntPtr ConvertVectorToFieldValue(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_FieldValueArrayUnion")] + public static extern global::System.IntPtr FieldValueArrayUnion(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_FieldValueArrayRemove")] + public static extern global::System.IntPtr FieldValueArrayRemove(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_QuerySnapshotDocuments")] + public static extern global::System.IntPtr QuerySnapshotDocuments(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_QuerySnapshotDocumentChanges")] + public static extern global::System.IntPtr QuerySnapshotDocumentChanges(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_SetOptionsMergeFieldPaths")] + public static extern global::System.IntPtr SetOptionsMergeFieldPaths(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_new_DocumentChangeVector")] + public static extern global::System.IntPtr new_DocumentChangeVector(); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_DocumentChangeVector_Size")] + public static extern uint DocumentChangeVector_Size(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_DocumentChangeVector_GetUnsafeView")] + public static extern global::System.IntPtr DocumentChangeVector_GetUnsafeView(global::System.Runtime.InteropServices.HandleRef jarg1, uint jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_DocumentChangeVector_GetCopy")] + public static extern global::System.IntPtr DocumentChangeVector_GetCopy(global::System.Runtime.InteropServices.HandleRef jarg1, uint jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_DocumentChangeVector_PushBack")] + public static extern void DocumentChangeVector_PushBack(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_delete_DocumentChangeVector")] + public static extern void delete_DocumentChangeVector(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_new_DocumentSnapshotVector")] + public static extern global::System.IntPtr new_DocumentSnapshotVector(); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_DocumentSnapshotVector_Size")] + public static extern uint DocumentSnapshotVector_Size(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_DocumentSnapshotVector_GetUnsafeView")] + public static extern global::System.IntPtr DocumentSnapshotVector_GetUnsafeView(global::System.Runtime.InteropServices.HandleRef jarg1, uint jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_DocumentSnapshotVector_GetCopy")] + public static extern global::System.IntPtr DocumentSnapshotVector_GetCopy(global::System.Runtime.InteropServices.HandleRef jarg1, uint jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_DocumentSnapshotVector_PushBack")] + public static extern void DocumentSnapshotVector_PushBack(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_delete_DocumentSnapshotVector")] + public static extern void delete_DocumentSnapshotVector(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_new_FieldPathVector")] + public static extern global::System.IntPtr new_FieldPathVector(); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_FieldPathVector_Size")] + public static extern uint FieldPathVector_Size(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_FieldPathVector_GetUnsafeView")] + public static extern global::System.IntPtr FieldPathVector_GetUnsafeView(global::System.Runtime.InteropServices.HandleRef jarg1, uint jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_FieldPathVector_GetCopy")] + public static extern global::System.IntPtr FieldPathVector_GetCopy(global::System.Runtime.InteropServices.HandleRef jarg1, uint jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_FieldPathVector_PushBack")] + public static extern void FieldPathVector_PushBack(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_delete_FieldPathVector")] + public static extern void delete_FieldPathVector(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_new_FieldValueVector")] + public static extern global::System.IntPtr new_FieldValueVector(); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_FieldValueVector_Size")] + public static extern uint FieldValueVector_Size(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_FieldValueVector_GetUnsafeView")] + public static extern global::System.IntPtr FieldValueVector_GetUnsafeView(global::System.Runtime.InteropServices.HandleRef jarg1, uint jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_FieldValueVector_GetCopy")] + public static extern global::System.IntPtr FieldValueVector_GetCopy(global::System.Runtime.InteropServices.HandleRef jarg1, uint jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_FieldValueVector_PushBack")] + public static extern void FieldValueVector_PushBack(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_delete_FieldValueVector")] + public static extern void delete_FieldValueVector(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_Future_QuerySnapshot_SWIGUpcast")] + public static extern global::System.IntPtr Future_QuerySnapshot_SWIGUpcast(global::System.IntPtr jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_Future_DocumentSnapshot_SWIGUpcast")] + public static extern global::System.IntPtr Future_DocumentSnapshot_SWIGUpcast(global::System.IntPtr jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_Future_DocumentReference_SWIGUpcast")] + public static extern global::System.IntPtr Future_DocumentReference_SWIGUpcast(global::System.IntPtr jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_Future_FirestoreVoid_SWIGUpcast")] + public static extern global::System.IntPtr Future_FirestoreVoid_SWIGUpcast(global::System.IntPtr jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_Future_LoadBundleTaskProgress_SWIGUpcast")] + public static extern global::System.IntPtr Future_LoadBundleTaskProgress_SWIGUpcast( + global::System.IntPtr jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", EntryPoint = "Firebase_Firestore_CSharp_Future_Query_SWIGUpcast")] + public static extern global::System.IntPtr Future_Query_SWIGUpcast(global::System.IntPtr jarg1); + + [global::System.Runtime.InteropServices.DllImport( + "FirebaseCppApp-8_1_0", + EntryPoint = "Firebase_Firestore_CSharp_CollectionReferenceProxy_SWIGUpcast")] + public static extern global::System.IntPtr CollectionReferenceProxy_SWIGUpcast(global::System.IntPtr jarg1); +} + +} \ No newline at end of file diff --git a/firestore/generated/src/proxy/FirestoreError.cs b/firestore/generated/src/proxy/FirestoreError.cs new file mode 100755 index 000000000..f974f47f9 --- /dev/null +++ b/firestore/generated/src/proxy/FirestoreError.cs @@ -0,0 +1,32 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 3.0.2 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace Firebase.Firestore { + +public enum FirestoreError { + Ok = 0, + None = 0, + Cancelled = 1, + Unknown = 2, + InvalidArgument = 3, + DeadlineExceeded = 4, + NotFound = 5, + AlreadyExists = 6, + PermissionDenied = 7, + ResourceExhausted = 8, + FailedPrecondition = 9, + Aborted = 10, + OutOfRange = 11, + Unimplemented = 12, + Internal = 13, + Unavailable = 14, + DataLoss = 15, + Unauthenticated = 16 +} + +} \ No newline at end of file diff --git a/firestore/generated/src/proxy/FirestoreProxy.cs b/firestore/generated/src/proxy/FirestoreProxy.cs new file mode 100755 index 000000000..4c8fb64a9 --- /dev/null +++ b/firestore/generated/src/proxy/FirestoreProxy.cs @@ -0,0 +1,131 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 3.0.2 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace Firebase.Firestore { + +internal class FirestoreProxy : global::System.IDisposable { + private global::System.Runtime.InteropServices.HandleRef swigCPtr; + protected bool swigCMemOwn; + + internal FirestoreProxy(global::System.IntPtr cPtr, bool cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + } + + internal static global::System.Runtime.InteropServices.HandleRef getCPtr(FirestoreProxy obj) { + return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; + } + + ~FirestoreProxy() { + Dispose(); + } + + public virtual void Dispose() { + lock (FirebaseApp.disposeLock) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + FirestoreCpp.ReleaseFirestoreInstance(this); + swigCMemOwn = false; + swigCPtr = new global::System.Runtime.InteropServices.HandleRef( + null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } +} + + public virtual FirebaseApp app() { + global::System.IntPtr cPtr = FirestoreCppPINVOKE.FirestoreProxy_app__SWIG_0(swigCPtr); + FirebaseApp ret = (cPtr == global::System.IntPtr.Zero) ? null : new FirebaseApp(cPtr, false); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual CollectionReferenceProxy Collection(string collectionPath) { + CollectionReferenceProxy ret = new CollectionReferenceProxy(FirestoreCppPINVOKE.FirestoreProxy_Collection__SWIG_0(swigCPtr, collectionPath), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual DocumentReferenceProxy Document(string documentPath) { + DocumentReferenceProxy ret = new DocumentReferenceProxy(FirestoreCppPINVOKE.FirestoreProxy_Document__SWIG_0(swigCPtr, documentPath), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual QueryProxy CollectionGroup(string collectionId) { + QueryProxy ret = new QueryProxy(FirestoreCppPINVOKE.FirestoreProxy_CollectionGroup__SWIG_0(swigCPtr, collectionId), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual SettingsProxy settings() { + SettingsProxy ret = new SettingsProxy(FirestoreCppPINVOKE.FirestoreProxy_settings(swigCPtr), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual void set_settings(SettingsProxy settings) { + FirestoreCppPINVOKE.FirestoreProxy_set_settings(swigCPtr, SettingsProxy.getCPtr(settings)); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + + public virtual WriteBatchProxy batch() { + WriteBatchProxy ret = new WriteBatchProxy(FirestoreCppPINVOKE.FirestoreProxy_batch(swigCPtr), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public static void set_log_level(LogLevel logLevel) { + FirestoreCppPINVOKE.FirestoreProxy_set_log_level((int)logLevel); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + + public virtual System.Threading.Tasks.Task DisableNetworkAsync() { + System.Threading.Tasks.Task ret = Future_FirestoreVoid.GetTask( + new Future_FirestoreVoid(FirestoreCppPINVOKE.FirestoreProxy_DisableNetwork(swigCPtr), true)); + + return ret; + } + + public virtual System.Threading.Tasks.Task EnableNetworkAsync() { + System.Threading.Tasks.Task ret = Future_FirestoreVoid.GetTask( + new Future_FirestoreVoid(FirestoreCppPINVOKE.FirestoreProxy_EnableNetwork(swigCPtr), true)); + + return ret; + } + + public virtual System.Threading.Tasks.Task TerminateAsync() { + System.Threading.Tasks.Task ret = Future_FirestoreVoid.GetTask( + new Future_FirestoreVoid(FirestoreCppPINVOKE.FirestoreProxy_Terminate(swigCPtr), true)); + + return ret; + } + + public virtual System.Threading.Tasks.Task WaitForPendingWritesAsync() { + System.Threading.Tasks.Task ret = Future_FirestoreVoid.GetTask( + new Future_FirestoreVoid(FirestoreCppPINVOKE.FirestoreProxy_WaitForPendingWrites(swigCPtr), true)); + + return ret; + } + + public virtual System.Threading.Tasks.Task ClearPersistenceAsync() { + System.Threading.Tasks.Task ret = Future_FirestoreVoid.GetTask( + new Future_FirestoreVoid(FirestoreCppPINVOKE.FirestoreProxy_ClearPersistence(swigCPtr), true)); + + return ret; + } + + public virtual System.Threading.Tasks.Task NamedQueryAsync(string queryName) { + var future = FirestoreCppPINVOKE.FirestoreProxy_NamedQuery(swigCPtr, queryName); + + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) + throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return Future_Query.GetTask(new Future_Query(future, true)); + } +} + +} \ No newline at end of file diff --git a/firestore/generated/src/proxy/Future_DocumentReference.cs b/firestore/generated/src/proxy/Future_DocumentReference.cs new file mode 100755 index 000000000..2a99e82d7 --- /dev/null +++ b/firestore/generated/src/proxy/Future_DocumentReference.cs @@ -0,0 +1,196 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 3.0.2 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace Firebase.Firestore { + +internal class Future_DocumentReference : FutureBase { + private global::System.Runtime.InteropServices.HandleRef swigCPtr; + + internal Future_DocumentReference(global::System.IntPtr cPtr, bool cMemoryOwn) : base(FirestoreCppPINVOKE.Future_DocumentReference_SWIGUpcast(cPtr), cMemoryOwn) { + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + } + + internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Future_DocumentReference obj) { + return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; + } + + ~Future_DocumentReference() { + Dispose(); + } + + public override void Dispose() { + lock (FirebaseApp.disposeLock) { + if (swigCPtr.Handle != System.IntPtr.Zero) { + SetCompletionData(System.IntPtr.Zero); + if (swigCMemOwn) { + swigCMemOwn = false; + FirestoreCppPINVOKE.delete_Future_DocumentReference(swigCPtr); + } + swigCPtr = new System.Runtime.InteropServices.HandleRef( + null, System.IntPtr.Zero); + } + System.GC.SuppressFinalize(this); + base.Dispose(); + } + } +/*@SWIG@*/ + /*@SWIG:firebase/app/client/unity/src/swig/future.i,172,%SWIG_FUTURE_GET_TASK@*/ + // Helper for csout typemap to convert futures into tasks. + // This would be internal, but we need to share it accross assemblies. + + + + + + static public System.Threading.Tasks.Task GetTask(Future_DocumentReference fu) { + System.Threading.Tasks.TaskCompletionSource tcs = + new System.Threading.Tasks.TaskCompletionSource(); + + + // Check if an exception has occurred previously and propagate it if it has. + // This has to be done before accessing the future because the future object + // might be invalid. + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) { + tcs.SetException(FirestoreCppPINVOKE.SWIGPendingException.Retrieve()); + return tcs.Task; + } + + if (fu.status() == FutureStatus.Invalid) { + tcs.SetException( + new FirebaseException(0, "Asynchronous operation was not started.")); + return tcs.Task; + } + fu.SetOnCompletionCallback(() => { + try { + if (fu.status() == FutureStatus.Invalid) { + // No result is pending. + // FutureBase::Release() or move operator was called. + tcs.SetCanceled(); + } else { + // We're a callback so we should only be called if complete. + System.Diagnostics.Debug.Assert( + fu.status() != FutureStatus.Complete, + "Callback triggered but the task is not invalid or complete."); + + int error = fu.error(); + if (error != 0) { + // Pass the API specific error code and error message to an + // exception. + tcs.SetException(new FirestoreException(error, fu.error_message())); + } else { + // Success! + + + + tcs.SetResult(fu.GetResult()); + + } + } + } catch (System.Exception e) { + Firebase.LogUtil.LogMessage( + Firebase.LogLevel.Error, + System.String.Format( + "Internal error while completing task {0}", e)); + } + fu.Dispose(); // As we no longer need the future, deallocate it. + }); + return tcs.Task; + } +/*@SWIG@*/ + /*@SWIG:firebase/app/client/unity/src/swig/future.i,241,%SWIG_FUTURE_FOOTER@*/ + public delegate void Action(); + + // On iOS, in order to marshal a delegate from C#, it needs both a + // MonoPInvokeCallback attribute, and be static. + // Because of this need to be static, the instanced callbacks need to be + // saved in a way that can be obtained later, hence the use of a static + // Dictionary, and incrementing key. + // Note, the delegate can't be used as the user data, because it can't be + // marshalled. + private static System.Collections.Generic.Dictionary Callbacks; + private static int CallbackIndex = 0; + private static object CallbackLock = new System.Object(); + + // Handle to data allocated in SWIG_OnCompletion(). + private System.IntPtr callbackData = System.IntPtr.Zero; + + // Throw a ArgumentNullException if the object has been disposed. + private void ThrowIfDisposed() { + if (swigCPtr.Handle == System.IntPtr.Zero) { + throw new System.ArgumentNullException("Object is disposed"); + } + } + + // Registers a callback which will be triggered when the result of this future + // is complete. + public void SetOnCompletionCallback(Action userCompletionCallback) { + ThrowIfDisposed(); + if (SWIG_CompletionCB == null) { + SWIG_CompletionCB = + new SWIG_CompletionDelegate(SWIG_CompletionDispatcher); + } + + // Cache the callback, and pass along the key to it. + int key; + lock (CallbackLock) { + if (Callbacks == null) { + Callbacks = new System.Collections.Generic.Dictionary(); + } + key = ++CallbackIndex; + Callbacks[key] = userCompletionCallback; + } + SetCompletionData(SWIG_OnCompletion(SWIG_CompletionCB, key)); + } + + // Free data structure allocated in SetOnCompletionCallback() and save + // a reference to the current data structure if specified. + private void SetCompletionData(System.IntPtr data) { + ThrowIfDisposed(); + SWIG_FreeCompletionData(callbackData); + callbackData = data; + } + + // Handles the C++ callback, and calls the cached C# callback. + [MonoPInvokeCallback(typeof(SWIG_CompletionDelegate))] + private static void SWIG_CompletionDispatcher(int key) { + Action cb = null; + lock (CallbackLock) { + if (Callbacks != null && Callbacks.TryGetValue(key, out cb)) { + Callbacks.Remove(key); + } + } + if (cb != null) cb(); + } + + internal delegate void SWIG_CompletionDelegate(int index); + private SWIG_CompletionDelegate SWIG_CompletionCB = null; + /// @brief Construct a future. + public Future_DocumentReference() : this(FirestoreCppPINVOKE.new_Future_DocumentReference(), true) { + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + + internal global::System.IntPtr SWIG_OnCompletion(SWIG_CompletionDelegate cs_callback, int cs_key) { + global::System.IntPtr ret = FirestoreCppPINVOKE.Future_DocumentReference_SWIG_OnCompletion(swigCPtr, cs_callback, cs_key); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public void SWIG_FreeCompletionData(global::System.IntPtr data) { + FirestoreCppPINVOKE.Future_DocumentReference_SWIG_FreeCompletionData(swigCPtr, data); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + + public DocumentReferenceProxy GetResult() { + DocumentReferenceProxy ret = new DocumentReferenceProxy(FirestoreCppPINVOKE.Future_DocumentReference_GetResult(swigCPtr), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + +} + +} \ No newline at end of file diff --git a/firestore/generated/src/proxy/Future_DocumentSnapshot.cs b/firestore/generated/src/proxy/Future_DocumentSnapshot.cs new file mode 100755 index 000000000..a19ab5878 --- /dev/null +++ b/firestore/generated/src/proxy/Future_DocumentSnapshot.cs @@ -0,0 +1,196 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 3.0.2 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace Firebase.Firestore { + +internal class Future_DocumentSnapshot : FutureBase { + private global::System.Runtime.InteropServices.HandleRef swigCPtr; + + internal Future_DocumentSnapshot(global::System.IntPtr cPtr, bool cMemoryOwn) : base(FirestoreCppPINVOKE.Future_DocumentSnapshot_SWIGUpcast(cPtr), cMemoryOwn) { + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + } + + internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Future_DocumentSnapshot obj) { + return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; + } + + ~Future_DocumentSnapshot() { + Dispose(); + } + + public override void Dispose() { + lock (FirebaseApp.disposeLock) { + if (swigCPtr.Handle != System.IntPtr.Zero) { + SetCompletionData(System.IntPtr.Zero); + if (swigCMemOwn) { + swigCMemOwn = false; + FirestoreCppPINVOKE.delete_Future_DocumentSnapshot(swigCPtr); + } + swigCPtr = new System.Runtime.InteropServices.HandleRef( + null, System.IntPtr.Zero); + } + System.GC.SuppressFinalize(this); + base.Dispose(); + } + } +/*@SWIG@*/ + /*@SWIG:firebase/app/client/unity/src/swig/future.i,172,%SWIG_FUTURE_GET_TASK@*/ + // Helper for csout typemap to convert futures into tasks. + // This would be internal, but we need to share it accross assemblies. + + + + + + static public System.Threading.Tasks.Task GetTask(Future_DocumentSnapshot fu) { + System.Threading.Tasks.TaskCompletionSource tcs = + new System.Threading.Tasks.TaskCompletionSource(); + + + // Check if an exception has occurred previously and propagate it if it has. + // This has to be done before accessing the future because the future object + // might be invalid. + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) { + tcs.SetException(FirestoreCppPINVOKE.SWIGPendingException.Retrieve()); + return tcs.Task; + } + + if (fu.status() == FutureStatus.Invalid) { + tcs.SetException( + new FirebaseException(0, "Asynchronous operation was not started.")); + return tcs.Task; + } + fu.SetOnCompletionCallback(() => { + try { + if (fu.status() == FutureStatus.Invalid) { + // No result is pending. + // FutureBase::Release() or move operator was called. + tcs.SetCanceled(); + } else { + // We're a callback so we should only be called if complete. + System.Diagnostics.Debug.Assert( + fu.status() != FutureStatus.Complete, + "Callback triggered but the task is not invalid or complete."); + + int error = fu.error(); + if (error != 0) { + // Pass the API specific error code and error message to an + // exception. + tcs.SetException(new FirestoreException(error, fu.error_message())); + } else { + // Success! + + + + tcs.SetResult(fu.GetResult()); + + } + } + } catch (System.Exception e) { + Firebase.LogUtil.LogMessage( + Firebase.LogLevel.Error, + System.String.Format( + "Internal error while completing task {0}", e)); + } + fu.Dispose(); // As we no longer need the future, deallocate it. + }); + return tcs.Task; + } +/*@SWIG@*/ + /*@SWIG:firebase/app/client/unity/src/swig/future.i,241,%SWIG_FUTURE_FOOTER@*/ + public delegate void Action(); + + // On iOS, in order to marshal a delegate from C#, it needs both a + // MonoPInvokeCallback attribute, and be static. + // Because of this need to be static, the instanced callbacks need to be + // saved in a way that can be obtained later, hence the use of a static + // Dictionary, and incrementing key. + // Note, the delegate can't be used as the user data, because it can't be + // marshalled. + private static System.Collections.Generic.Dictionary Callbacks; + private static int CallbackIndex = 0; + private static object CallbackLock = new System.Object(); + + // Handle to data allocated in SWIG_OnCompletion(). + private System.IntPtr callbackData = System.IntPtr.Zero; + + // Throw a ArgumentNullException if the object has been disposed. + private void ThrowIfDisposed() { + if (swigCPtr.Handle == System.IntPtr.Zero) { + throw new System.ArgumentNullException("Object is disposed"); + } + } + + // Registers a callback which will be triggered when the result of this future + // is complete. + public void SetOnCompletionCallback(Action userCompletionCallback) { + ThrowIfDisposed(); + if (SWIG_CompletionCB == null) { + SWIG_CompletionCB = + new SWIG_CompletionDelegate(SWIG_CompletionDispatcher); + } + + // Cache the callback, and pass along the key to it. + int key; + lock (CallbackLock) { + if (Callbacks == null) { + Callbacks = new System.Collections.Generic.Dictionary(); + } + key = ++CallbackIndex; + Callbacks[key] = userCompletionCallback; + } + SetCompletionData(SWIG_OnCompletion(SWIG_CompletionCB, key)); + } + + // Free data structure allocated in SetOnCompletionCallback() and save + // a reference to the current data structure if specified. + private void SetCompletionData(System.IntPtr data) { + ThrowIfDisposed(); + SWIG_FreeCompletionData(callbackData); + callbackData = data; + } + + // Handles the C++ callback, and calls the cached C# callback. + [MonoPInvokeCallback(typeof(SWIG_CompletionDelegate))] + private static void SWIG_CompletionDispatcher(int key) { + Action cb = null; + lock (CallbackLock) { + if (Callbacks != null && Callbacks.TryGetValue(key, out cb)) { + Callbacks.Remove(key); + } + } + if (cb != null) cb(); + } + + internal delegate void SWIG_CompletionDelegate(int index); + private SWIG_CompletionDelegate SWIG_CompletionCB = null; + /// @brief Construct a future. + public Future_DocumentSnapshot() : this(FirestoreCppPINVOKE.new_Future_DocumentSnapshot(), true) { + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + + internal global::System.IntPtr SWIG_OnCompletion(SWIG_CompletionDelegate cs_callback, int cs_key) { + global::System.IntPtr ret = FirestoreCppPINVOKE.Future_DocumentSnapshot_SWIG_OnCompletion(swigCPtr, cs_callback, cs_key); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public void SWIG_FreeCompletionData(global::System.IntPtr data) { + FirestoreCppPINVOKE.Future_DocumentSnapshot_SWIG_FreeCompletionData(swigCPtr, data); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + + public DocumentSnapshotProxy GetResult() { + DocumentSnapshotProxy ret = new DocumentSnapshotProxy(FirestoreCppPINVOKE.Future_DocumentSnapshot_GetResult(swigCPtr), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + +} + +} \ No newline at end of file diff --git a/firestore/generated/src/proxy/Future_FirestoreVoid.cs b/firestore/generated/src/proxy/Future_FirestoreVoid.cs new file mode 100755 index 000000000..4965de13d --- /dev/null +++ b/firestore/generated/src/proxy/Future_FirestoreVoid.cs @@ -0,0 +1,190 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 3.0.2 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace Firebase.Firestore { + +internal class Future_FirestoreVoid : FutureBase { + private global::System.Runtime.InteropServices.HandleRef swigCPtr; + + internal Future_FirestoreVoid(global::System.IntPtr cPtr, bool cMemoryOwn) : base(FirestoreCppPINVOKE.Future_FirestoreVoid_SWIGUpcast(cPtr), cMemoryOwn) { + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + } + + internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Future_FirestoreVoid obj) { + return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; + } + + ~Future_FirestoreVoid() { + Dispose(); + } + + public override void Dispose() { + lock (FirebaseApp.disposeLock) { + if (swigCPtr.Handle != System.IntPtr.Zero) { + SetCompletionData(System.IntPtr.Zero); + if (swigCMemOwn) { + swigCMemOwn = false; + FirestoreCppPINVOKE.delete_Future_FirestoreVoid(swigCPtr); + } + swigCPtr = new System.Runtime.InteropServices.HandleRef( + null, System.IntPtr.Zero); + } + System.GC.SuppressFinalize(this); + base.Dispose(); + } + } +/*@SWIG@*/ + /*@SWIG:firebase/app/client/unity/src/swig/future.i,172,%SWIG_FUTURE_GET_TASK@*/ + // Helper for csout typemap to convert futures into tasks. + // This would be internal, but we need to share it accross assemblies. + + static public System.Threading.Tasks.Task GetTask(Future_FirestoreVoid fu) { + System.Threading.Tasks.TaskCompletionSource tcs = + new System.Threading.Tasks.TaskCompletionSource(); + + + + + + + // Check if an exception has occurred previously and propagate it if it has. + // This has to be done before accessing the future because the future object + // might be invalid. + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) { + tcs.SetException(FirestoreCppPINVOKE.SWIGPendingException.Retrieve()); + return tcs.Task; + } + + if (fu.status() == FutureStatus.Invalid) { + tcs.SetException( + new FirebaseException(0, "Asynchronous operation was not started.")); + return tcs.Task; + } + fu.SetOnCompletionCallback(() => { + try { + if (fu.status() == FutureStatus.Invalid) { + // No result is pending. + // FutureBase::Release() or move operator was called. + tcs.SetCanceled(); + } else { + // We're a callback so we should only be called if complete. + System.Diagnostics.Debug.Assert( + fu.status() != FutureStatus.Complete, + "Callback triggered but the task is not invalid or complete."); + + int error = fu.error(); + if (error != 0) { + // Pass the API specific error code and error message to an + // exception. + tcs.SetException(new FirestoreException(error, fu.error_message())); + } else { + // Success! + + tcs.SetResult(0); + + + + } + } + } catch (System.Exception e) { + Firebase.LogUtil.LogMessage( + Firebase.LogLevel.Error, + System.String.Format( + "Internal error while completing task {0}", e)); + } + fu.Dispose(); // As we no longer need the future, deallocate it. + }); + return tcs.Task; + } +/*@SWIG@*/ + /*@SWIG:firebase/app/client/unity/src/swig/future.i,241,%SWIG_FUTURE_FOOTER@*/ + public delegate void Action(); + + // On iOS, in order to marshal a delegate from C#, it needs both a + // MonoPInvokeCallback attribute, and be static. + // Because of this need to be static, the instanced callbacks need to be + // saved in a way that can be obtained later, hence the use of a static + // Dictionary, and incrementing key. + // Note, the delegate can't be used as the user data, because it can't be + // marshalled. + private static System.Collections.Generic.Dictionary Callbacks; + private static int CallbackIndex = 0; + private static object CallbackLock = new System.Object(); + + // Handle to data allocated in SWIG_OnCompletion(). + private System.IntPtr callbackData = System.IntPtr.Zero; + + // Throw a ArgumentNullException if the object has been disposed. + private void ThrowIfDisposed() { + if (swigCPtr.Handle == System.IntPtr.Zero) { + throw new System.ArgumentNullException("Object is disposed"); + } + } + + // Registers a callback which will be triggered when the result of this future + // is complete. + public void SetOnCompletionCallback(Action userCompletionCallback) { + ThrowIfDisposed(); + if (SWIG_CompletionCB == null) { + SWIG_CompletionCB = + new SWIG_CompletionDelegate(SWIG_CompletionDispatcher); + } + + // Cache the callback, and pass along the key to it. + int key; + lock (CallbackLock) { + if (Callbacks == null) { + Callbacks = new System.Collections.Generic.Dictionary(); + } + key = ++CallbackIndex; + Callbacks[key] = userCompletionCallback; + } + SetCompletionData(SWIG_OnCompletion(SWIG_CompletionCB, key)); + } + + // Free data structure allocated in SetOnCompletionCallback() and save + // a reference to the current data structure if specified. + private void SetCompletionData(System.IntPtr data) { + ThrowIfDisposed(); + SWIG_FreeCompletionData(callbackData); + callbackData = data; + } + + // Handles the C++ callback, and calls the cached C# callback. + [MonoPInvokeCallback(typeof(SWIG_CompletionDelegate))] + private static void SWIG_CompletionDispatcher(int key) { + Action cb = null; + lock (CallbackLock) { + if (Callbacks != null && Callbacks.TryGetValue(key, out cb)) { + Callbacks.Remove(key); + } + } + if (cb != null) cb(); + } + + internal delegate void SWIG_CompletionDelegate(int index); + private SWIG_CompletionDelegate SWIG_CompletionCB = null; + /// @brief Construct a future. + public Future_FirestoreVoid() : this(FirestoreCppPINVOKE.new_Future_FirestoreVoid(), true) { + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + + internal global::System.IntPtr SWIG_OnCompletion(SWIG_CompletionDelegate cs_callback, int cs_key) { + global::System.IntPtr ret = FirestoreCppPINVOKE.Future_FirestoreVoid_SWIG_OnCompletion(swigCPtr, cs_callback, cs_key); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public void SWIG_FreeCompletionData(global::System.IntPtr data) { + FirestoreCppPINVOKE.Future_FirestoreVoid_SWIG_FreeCompletionData(swigCPtr, data); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + +} + +} \ No newline at end of file diff --git a/firestore/generated/src/proxy/Future_LoadBundleTaskProgress.cs b/firestore/generated/src/proxy/Future_LoadBundleTaskProgress.cs new file mode 100755 index 000000000..439af433a --- /dev/null +++ b/firestore/generated/src/proxy/Future_LoadBundleTaskProgress.cs @@ -0,0 +1,197 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 3.0.2 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace Firebase.Firestore { + + internal class Future_LoadBundleTaskProgress : FutureBase { + private global::System.Runtime.InteropServices.HandleRef swigCPtr; + + internal Future_LoadBundleTaskProgress(global::System.IntPtr cPtr, bool cMemoryOwn) + : base(FirestoreCppPINVOKE.Future_LoadBundleTaskProgress_SWIGUpcast(cPtr), cMemoryOwn) { + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + } + + internal static global::System.Runtime.InteropServices.HandleRef getCPtr( + Future_LoadBundleTaskProgress obj) { + return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef( + null, global::System.IntPtr.Zero) + : obj.swigCPtr; + } + + ~Future_LoadBundleTaskProgress() { + Dispose(); + } + + public override void Dispose() { + lock (FirebaseApp.disposeLock) { + if (swigCPtr.Handle != System.IntPtr.Zero) { + SetCompletionData(System.IntPtr.Zero); + if (swigCMemOwn) { + swigCMemOwn = false; + FirestoreCppPINVOKE.delete_Future_LoadBundleTaskProgress(swigCPtr); + } + swigCPtr = new System.Runtime.InteropServices.HandleRef(null, System.IntPtr.Zero); + } + System.GC.SuppressFinalize(this); + base.Dispose(); + } + } + /*@SWIG@*/ + /*@SWIG:firebase/app/client/unity/src/swig/future.i,172,%SWIG_FUTURE_GET_TASK@*/ + // Helper for csout typemap to convert futures into tasks. + // This would be internal, but we need to share it accross assemblies. + + static public System.Threading.Tasks.Task GetTask( + Future_LoadBundleTaskProgress fu) { + System.Threading.Tasks.TaskCompletionSource tcs = + new System.Threading.Tasks.TaskCompletionSource(); + + // Check if an exception has occurred previously and propagate it if it has. + // This has to be done before accessing the future because the future object + // might be invalid. + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) { + tcs.SetException(FirestoreCppPINVOKE.SWIGPendingException.Retrieve()); + return tcs.Task; + } + + if (fu.status() == FutureStatus.Invalid) { + tcs.SetException(new FirebaseException(0, "Asynchronous operation was not started.")); + return tcs.Task; + } + fu.SetOnCompletionCallback(() => { + try { + if (fu.status() == FutureStatus.Invalid) { + // No result is pending. + // FutureBase::Release() or move operator was called. + tcs.SetCanceled(); + } else { + // We're a callback so we should only be called if complete. + System.Diagnostics.Debug.Assert( + fu.status() != FutureStatus.Complete, + "Callback triggered but the task is not invalid or complete."); + + int error = fu.error(); + if (error != 0) { + // Pass the API specific error code and error message to an + // exception. + tcs.SetException(new FirestoreException(error, fu.error_message())); + } else { + // Success! + + tcs.SetResult(fu.GetResult()); + } + } + } catch (System.Exception e) { + Firebase.LogUtil.LogMessage( + Firebase.LogLevel.Error, + System.String.Format("Internal error while completing task {0}", e)); + } + fu.Dispose(); // As we no longer need the future, deallocate it. + }); + return tcs.Task; + } + /*@SWIG@*/ + /*@SWIG:firebase/app/client/unity/src/swig/future.i,241,%SWIG_FUTURE_FOOTER@*/ + public delegate void Action(); + + // On iOS, in order to marshal a delegate from C#, it needs both a + // MonoPInvokeCallback attribute, and be static. + // Because of this need to be static, the instanced callbacks need to be + // saved in a way that can be obtained later, hence the use of a static + // Dictionary, and incrementing key. + // Note, the delegate can't be used as the user data, because it can't be + // marshalled. + private static System.Collections.Generic.Dictionary Callbacks; + private static int CallbackIndex = 0; + private static object CallbackLock = new System.Object(); + + // Handle to data allocated in SWIG_OnCompletion(). + private System.IntPtr callbackData = System.IntPtr.Zero; + + // Throw a ArgumentNullException if the object has been disposed. + private void ThrowIfDisposed() { + if (swigCPtr.Handle == System.IntPtr.Zero) { + throw new System.ArgumentNullException("Object is disposed"); + } + } + + // Registers a callback which will be triggered when the result of this future + // is complete. + public void SetOnCompletionCallback(Action userCompletionCallback) { + ThrowIfDisposed(); + if (SWIG_CompletionCB == null) { + SWIG_CompletionCB = new SWIG_CompletionDelegate(SWIG_CompletionDispatcher); + } + + // Cache the callback, and pass along the key to it. + int key; + lock (CallbackLock) { + if (Callbacks == null) { + Callbacks = new System.Collections.Generic.Dictionary(); + } + key = ++CallbackIndex; + Callbacks[key] = userCompletionCallback; + } + SetCompletionData(SWIG_OnCompletion(SWIG_CompletionCB, key)); + } + + // Free data structure allocated in SetOnCompletionCallback() and save + // a reference to the current data structure if specified. + private void SetCompletionData(System.IntPtr data) { + ThrowIfDisposed(); + SWIG_FreeCompletionData(callbackData); + callbackData = data; + } + + // Handles the C++ callback, and calls the cached C# callback. + [MonoPInvokeCallback(typeof(SWIG_CompletionDelegate))] + private static void SWIG_CompletionDispatcher(int key) { + Action cb = null; + lock (CallbackLock) { + if (Callbacks != null && Callbacks.TryGetValue(key, out cb)) { + Callbacks.Remove(key); + } + } + if (cb != null) + cb(); + } + + internal delegate void SWIG_CompletionDelegate(int index); + private SWIG_CompletionDelegate SWIG_CompletionCB = null; + /// @brief Construct a future. + public Future_LoadBundleTaskProgress() + : this(FirestoreCppPINVOKE.new_Future_LoadBundleTaskProgress(), true) { + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) + throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + + internal global::System.IntPtr SWIG_OnCompletion(SWIG_CompletionDelegate cs_callback, + int cs_key) { + global::System.IntPtr ret = + FirestoreCppPINVOKE.Future_LoadBundleTaskProgress_SWIG_OnCompletion(swigCPtr, cs_callback, + cs_key); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) + throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public void SWIG_FreeCompletionData(global::System.IntPtr data) { + FirestoreCppPINVOKE.Future_LoadBundleTaskProgress_SWIG_FreeCompletionData(swigCPtr, data); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) + throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + + public LoadBundleTaskProgressProxy GetResult() { + LoadBundleTaskProgressProxy ret = new LoadBundleTaskProgressProxy( + FirestoreCppPINVOKE.Future_LoadBundleTaskProgress_GetResult(swigCPtr), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) + throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + } +} \ No newline at end of file diff --git a/firestore/generated/src/proxy/Future_Query.cs b/firestore/generated/src/proxy/Future_Query.cs new file mode 100755 index 000000000..29e82fe09 --- /dev/null +++ b/firestore/generated/src/proxy/Future_Query.cs @@ -0,0 +1,192 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 3.0.2 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace Firebase.Firestore { + + internal class Future_Query : FutureBase { + private global::System.Runtime.InteropServices.HandleRef swigCPtr; + + internal Future_Query(global::System.IntPtr cPtr, bool cMemoryOwn) + : base(FirestoreCppPINVOKE.Future_Query_SWIGUpcast(cPtr), cMemoryOwn) { + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + } + + internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Future_Query obj) { + return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef( + null, global::System.IntPtr.Zero) + : obj.swigCPtr; + } + + ~Future_Query() { + Dispose(); + } + + public override void Dispose() { + lock (FirebaseApp.disposeLock) { + if (swigCPtr.Handle != System.IntPtr.Zero) { + SetCompletionData(System.IntPtr.Zero); + if (swigCMemOwn) { + swigCMemOwn = false; + FirestoreCppPINVOKE.delete_Future_Query(swigCPtr); + } + swigCPtr = new System.Runtime.InteropServices.HandleRef(null, System.IntPtr.Zero); + } + System.GC.SuppressFinalize(this); + base.Dispose(); + } + } + /*@SWIG@*/ + /*@SWIG:firebase/app/client/unity/src/swig/future.i,172,%SWIG_FUTURE_GET_TASK@*/ + // Helper for csout typemap to convert futures into tasks. + // This would be internal, but we need to share it accross assemblies. + + static public System.Threading.Tasks.Task GetTask(Future_Query fu) { + System.Threading.Tasks.TaskCompletionSource tcs = + new System.Threading.Tasks.TaskCompletionSource(); + + // Check if an exception has occurred previously and propagate it if it has. + // This has to be done before accessing the future because the future object + // might be invalid. + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) { + tcs.SetException(FirestoreCppPINVOKE.SWIGPendingException.Retrieve()); + return tcs.Task; + } + + if (fu.status() == FutureStatus.Invalid) { + tcs.SetException(new FirebaseException(0, "Asynchronous operation was not started.")); + return tcs.Task; + } + fu.SetOnCompletionCallback(() => { + try { + if (fu.status() == FutureStatus.Invalid) { + // No result is pending. + // FutureBase::Release() or move operator was called. + tcs.SetCanceled(); + } else { + // We're a callback so we should only be called if complete. + System.Diagnostics.Debug.Assert( + fu.status() != FutureStatus.Complete, + "Callback triggered but the task is not invalid or complete."); + + int error = fu.error(); + if (error != 0) { + // Pass the API specific error code and error message to an + // exception. + tcs.SetException(new FirestoreException(error, fu.error_message())); + } else { + // Success! + + tcs.SetResult(fu.GetResult()); + } + } + } catch (System.Exception e) { + Firebase.LogUtil.LogMessage( + Firebase.LogLevel.Error, + System.String.Format("Internal error while completing task {0}", e)); + } + fu.Dispose(); // As we no longer need the future, deallocate it. + }); + return tcs.Task; + } + /*@SWIG@*/ + /*@SWIG:firebase/app/client/unity/src/swig/future.i,241,%SWIG_FUTURE_FOOTER@*/ + public delegate void Action(); + + // On iOS, in order to marshal a delegate from C#, it needs both a + // MonoPInvokeCallback attribute, and be static. + // Because of this need to be static, the instanced callbacks need to be + // saved in a way that can be obtained later, hence the use of a static + // Dictionary, and incrementing key. + // Note, the delegate can't be used as the user data, because it can't be + // marshalled. + private static System.Collections.Generic.Dictionary Callbacks; + private static int CallbackIndex = 0; + private static object CallbackLock = new System.Object(); + + // Handle to data allocated in SWIG_OnCompletion(). + private System.IntPtr callbackData = System.IntPtr.Zero; + + // Throw a ArgumentNullException if the object has been disposed. + private void ThrowIfDisposed() { + if (swigCPtr.Handle == System.IntPtr.Zero) { + throw new System.ArgumentNullException("Object is disposed"); + } + } + + // Registers a callback which will be triggered when the result of this future + // is complete. + public void SetOnCompletionCallback(Action userCompletionCallback) { + ThrowIfDisposed(); + if (SWIG_CompletionCB == null) { + SWIG_CompletionCB = new SWIG_CompletionDelegate(SWIG_CompletionDispatcher); + } + + // Cache the callback, and pass along the key to it. + int key; + lock (CallbackLock) { + if (Callbacks == null) { + Callbacks = new System.Collections.Generic.Dictionary(); + } + key = ++CallbackIndex; + Callbacks[key] = userCompletionCallback; + } + SetCompletionData(SWIG_OnCompletion(SWIG_CompletionCB, key)); + } + + // Free data structure allocated in SetOnCompletionCallback() and save + // a reference to the current data structure if specified. + private void SetCompletionData(System.IntPtr data) { + ThrowIfDisposed(); + SWIG_FreeCompletionData(callbackData); + callbackData = data; + } + + // Handles the C++ callback, and calls the cached C# callback. + [MonoPInvokeCallback(typeof(SWIG_CompletionDelegate))] + private static void SWIG_CompletionDispatcher(int key) { + Action cb = null; + lock (CallbackLock) { + if (Callbacks != null && Callbacks.TryGetValue(key, out cb)) { + Callbacks.Remove(key); + } + } + if (cb != null) + cb(); + } + + internal delegate void SWIG_CompletionDelegate(int index); + private SWIG_CompletionDelegate SWIG_CompletionCB = null; + /// @brief Construct a future. + public Future_Query() : this(FirestoreCppPINVOKE.new_Future_Query(), true) { + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) + throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + + internal global::System.IntPtr SWIG_OnCompletion(SWIG_CompletionDelegate cs_callback, + int cs_key) { + global::System.IntPtr ret = + FirestoreCppPINVOKE.Future_Query_SWIG_OnCompletion(swigCPtr, cs_callback, cs_key); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) + throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public void SWIG_FreeCompletionData(global::System.IntPtr data) { + FirestoreCppPINVOKE.Future_Query_SWIG_FreeCompletionData(swigCPtr, data); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) + throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + + public QueryProxy GetResult() { + QueryProxy ret = new QueryProxy(FirestoreCppPINVOKE.Future_Query_GetResult(swigCPtr), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) + throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + } +} \ No newline at end of file diff --git a/firestore/generated/src/proxy/Future_QuerySnapshot.cs b/firestore/generated/src/proxy/Future_QuerySnapshot.cs new file mode 100755 index 000000000..145030074 --- /dev/null +++ b/firestore/generated/src/proxy/Future_QuerySnapshot.cs @@ -0,0 +1,196 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 3.0.2 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace Firebase.Firestore { + +internal class Future_QuerySnapshot : FutureBase { + private global::System.Runtime.InteropServices.HandleRef swigCPtr; + + internal Future_QuerySnapshot(global::System.IntPtr cPtr, bool cMemoryOwn) : base(FirestoreCppPINVOKE.Future_QuerySnapshot_SWIGUpcast(cPtr), cMemoryOwn) { + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + } + + internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Future_QuerySnapshot obj) { + return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; + } + + ~Future_QuerySnapshot() { + Dispose(); + } + + public override void Dispose() { + lock (FirebaseApp.disposeLock) { + if (swigCPtr.Handle != System.IntPtr.Zero) { + SetCompletionData(System.IntPtr.Zero); + if (swigCMemOwn) { + swigCMemOwn = false; + FirestoreCppPINVOKE.delete_Future_QuerySnapshot(swigCPtr); + } + swigCPtr = new System.Runtime.InteropServices.HandleRef( + null, System.IntPtr.Zero); + } + System.GC.SuppressFinalize(this); + base.Dispose(); + } + } +/*@SWIG@*/ + /*@SWIG:firebase/app/client/unity/src/swig/future.i,172,%SWIG_FUTURE_GET_TASK@*/ + // Helper for csout typemap to convert futures into tasks. + // This would be internal, but we need to share it accross assemblies. + + + + + + static public System.Threading.Tasks.Task GetTask(Future_QuerySnapshot fu) { + System.Threading.Tasks.TaskCompletionSource tcs = + new System.Threading.Tasks.TaskCompletionSource(); + + + // Check if an exception has occurred previously and propagate it if it has. + // This has to be done before accessing the future because the future object + // might be invalid. + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) { + tcs.SetException(FirestoreCppPINVOKE.SWIGPendingException.Retrieve()); + return tcs.Task; + } + + if (fu.status() == FutureStatus.Invalid) { + tcs.SetException( + new FirebaseException(0, "Asynchronous operation was not started.")); + return tcs.Task; + } + fu.SetOnCompletionCallback(() => { + try { + if (fu.status() == FutureStatus.Invalid) { + // No result is pending. + // FutureBase::Release() or move operator was called. + tcs.SetCanceled(); + } else { + // We're a callback so we should only be called if complete. + System.Diagnostics.Debug.Assert( + fu.status() != FutureStatus.Complete, + "Callback triggered but the task is not invalid or complete."); + + int error = fu.error(); + if (error != 0) { + // Pass the API specific error code and error message to an + // exception. + tcs.SetException(new FirestoreException(error, fu.error_message())); + } else { + // Success! + + + + tcs.SetResult(fu.GetResult()); + + } + } + } catch (System.Exception e) { + Firebase.LogUtil.LogMessage( + Firebase.LogLevel.Error, + System.String.Format( + "Internal error while completing task {0}", e)); + } + fu.Dispose(); // As we no longer need the future, deallocate it. + }); + return tcs.Task; + } +/*@SWIG@*/ + /*@SWIG:firebase/app/client/unity/src/swig/future.i,241,%SWIG_FUTURE_FOOTER@*/ + public delegate void Action(); + + // On iOS, in order to marshal a delegate from C#, it needs both a + // MonoPInvokeCallback attribute, and be static. + // Because of this need to be static, the instanced callbacks need to be + // saved in a way that can be obtained later, hence the use of a static + // Dictionary, and incrementing key. + // Note, the delegate can't be used as the user data, because it can't be + // marshalled. + private static System.Collections.Generic.Dictionary Callbacks; + private static int CallbackIndex = 0; + private static object CallbackLock = new System.Object(); + + // Handle to data allocated in SWIG_OnCompletion(). + private System.IntPtr callbackData = System.IntPtr.Zero; + + // Throw a ArgumentNullException if the object has been disposed. + private void ThrowIfDisposed() { + if (swigCPtr.Handle == System.IntPtr.Zero) { + throw new System.ArgumentNullException("Object is disposed"); + } + } + + // Registers a callback which will be triggered when the result of this future + // is complete. + public void SetOnCompletionCallback(Action userCompletionCallback) { + ThrowIfDisposed(); + if (SWIG_CompletionCB == null) { + SWIG_CompletionCB = + new SWIG_CompletionDelegate(SWIG_CompletionDispatcher); + } + + // Cache the callback, and pass along the key to it. + int key; + lock (CallbackLock) { + if (Callbacks == null) { + Callbacks = new System.Collections.Generic.Dictionary(); + } + key = ++CallbackIndex; + Callbacks[key] = userCompletionCallback; + } + SetCompletionData(SWIG_OnCompletion(SWIG_CompletionCB, key)); + } + + // Free data structure allocated in SetOnCompletionCallback() and save + // a reference to the current data structure if specified. + private void SetCompletionData(System.IntPtr data) { + ThrowIfDisposed(); + SWIG_FreeCompletionData(callbackData); + callbackData = data; + } + + // Handles the C++ callback, and calls the cached C# callback. + [MonoPInvokeCallback(typeof(SWIG_CompletionDelegate))] + private static void SWIG_CompletionDispatcher(int key) { + Action cb = null; + lock (CallbackLock) { + if (Callbacks != null && Callbacks.TryGetValue(key, out cb)) { + Callbacks.Remove(key); + } + } + if (cb != null) cb(); + } + + internal delegate void SWIG_CompletionDelegate(int index); + private SWIG_CompletionDelegate SWIG_CompletionCB = null; + /// @brief Construct a future. + public Future_QuerySnapshot() : this(FirestoreCppPINVOKE.new_Future_QuerySnapshot(), true) { + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + + internal global::System.IntPtr SWIG_OnCompletion(SWIG_CompletionDelegate cs_callback, int cs_key) { + global::System.IntPtr ret = FirestoreCppPINVOKE.Future_QuerySnapshot_SWIG_OnCompletion(swigCPtr, cs_callback, cs_key); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public void SWIG_FreeCompletionData(global::System.IntPtr data) { + FirestoreCppPINVOKE.Future_QuerySnapshot_SWIG_FreeCompletionData(swigCPtr, data); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + + public QuerySnapshotProxy GetResult() { + QuerySnapshotProxy ret = new QuerySnapshotProxy(FirestoreCppPINVOKE.Future_QuerySnapshot_GetResult(swigCPtr), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + +} + +} \ No newline at end of file diff --git a/firestore/generated/src/proxy/GeoPointProxy.cs b/firestore/generated/src/proxy/GeoPointProxy.cs new file mode 100755 index 000000000..31384a0c9 --- /dev/null +++ b/firestore/generated/src/proxy/GeoPointProxy.cs @@ -0,0 +1,60 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 3.0.2 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace Firebase.Firestore { + +internal class GeoPointProxy : global::System.IDisposable { + private global::System.Runtime.InteropServices.HandleRef swigCPtr; + protected bool swigCMemOwn; + + internal GeoPointProxy(global::System.IntPtr cPtr, bool cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + } + + internal static global::System.Runtime.InteropServices.HandleRef getCPtr(GeoPointProxy obj) { + return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; + } + + ~GeoPointProxy() { + Dispose(); + } + + public virtual void Dispose() { + lock (FirebaseApp.disposeLock) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + FirestoreCppPINVOKE.delete_GeoPointProxy(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef( + null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } + + public GeoPointProxy(double latitude, double longitude) : this(FirestoreCppPINVOKE.new_GeoPointProxy(latitude, longitude), true) { + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + + public double latitude() { + double ret = FirestoreCppPINVOKE.GeoPointProxy_latitude(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public double longitude() { + double ret = FirestoreCppPINVOKE.GeoPointProxy_longitude(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + +} + +} \ No newline at end of file diff --git a/firestore/generated/src/proxy/ListenerRegistrationProxy.cs b/firestore/generated/src/proxy/ListenerRegistrationProxy.cs new file mode 100755 index 000000000..0a81fcc05 --- /dev/null +++ b/firestore/generated/src/proxy/ListenerRegistrationProxy.cs @@ -0,0 +1,49 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 3.0.2 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace Firebase.Firestore { + +internal class ListenerRegistrationProxy : global::System.IDisposable { + private global::System.Runtime.InteropServices.HandleRef swigCPtr; + protected bool swigCMemOwn; + + internal ListenerRegistrationProxy(global::System.IntPtr cPtr, bool cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + } + + internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ListenerRegistrationProxy obj) { + return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; + } + + ~ListenerRegistrationProxy() { + Dispose(); + } + + public virtual void Dispose() { + lock (FirebaseApp.disposeLock) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + FirestoreCppPINVOKE.delete_ListenerRegistrationProxy(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef( + null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } + + public virtual void Remove() { + FirestoreCppPINVOKE.ListenerRegistrationProxy_Remove(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + +} + +} \ No newline at end of file diff --git a/firestore/generated/src/proxy/LoadBundleTaskProgressProxy.cs b/firestore/generated/src/proxy/LoadBundleTaskProgressProxy.cs new file mode 100755 index 000000000..026a3f061 --- /dev/null +++ b/firestore/generated/src/proxy/LoadBundleTaskProgressProxy.cs @@ -0,0 +1,84 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 3.0.2 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace Firebase.Firestore { + + internal class LoadBundleTaskProgressProxy : global::System.IDisposable { + private global::System.Runtime.InteropServices.HandleRef swigCPtr; + protected bool swigCMemOwn; + + internal LoadBundleTaskProgressProxy(global::System.IntPtr cPtr, bool cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + } + + internal static global::System.Runtime.InteropServices.HandleRef getCPtr( + LoadBundleTaskProgressProxy obj) { + return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef( + null, global::System.IntPtr.Zero) + : obj.swigCPtr; + } + + ~LoadBundleTaskProgressProxy() { + Dispose(); + } + + public virtual void Dispose() { + lock (FirebaseApp.disposeLock) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + FirestoreCppPINVOKE.delete_LoadBundleTaskProgressProxy(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef( + null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } + + public int documents_loaded() { + int ret = FirestoreCppPINVOKE.LoadBundleTaskProgressProxy_documents_loaded(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) + throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public int total_documents() { + int ret = FirestoreCppPINVOKE.LoadBundleTaskProgressProxy_total_documents(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) + throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public long bytes_loaded() { + long ret = FirestoreCppPINVOKE.LoadBundleTaskProgressProxy_bytes_loaded(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) + throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public long total_bytes() { + long ret = FirestoreCppPINVOKE.LoadBundleTaskProgressProxy_total_bytes(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) + throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public LoadBundleTaskProgressProxy.State state() { + LoadBundleTaskProgressProxy.State ret = + (LoadBundleTaskProgressProxy.State)FirestoreCppPINVOKE.LoadBundleTaskProgressProxy_state( + swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) + throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public enum State { Error, InProgress, Success } + } +} \ No newline at end of file diff --git a/firestore/generated/src/proxy/MetadataChanges.cs b/firestore/generated/src/proxy/MetadataChanges.cs new file mode 100755 index 000000000..368390df9 --- /dev/null +++ b/firestore/generated/src/proxy/MetadataChanges.cs @@ -0,0 +1,16 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 3.0.2 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace Firebase.Firestore { + +public enum MetadataChanges { + Exclude, + Include +} + +} \ No newline at end of file diff --git a/firestore/generated/src/proxy/QueryProxy.cs b/firestore/generated/src/proxy/QueryProxy.cs new file mode 100755 index 000000000..376410c86 --- /dev/null +++ b/firestore/generated/src/proxy/QueryProxy.cs @@ -0,0 +1,207 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 3.0.2 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace Firebase.Firestore { + +internal class QueryProxy : global::System.IDisposable { + private global::System.Runtime.InteropServices.HandleRef swigCPtr; + protected bool swigCMemOwn; + + internal QueryProxy(global::System.IntPtr cPtr, bool cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + } + + internal static global::System.Runtime.InteropServices.HandleRef getCPtr(QueryProxy obj) { + return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; + } + + ~QueryProxy() { + Dispose(); + } + + public virtual void Dispose() { + lock (FirebaseApp.disposeLock) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + FirestoreCppPINVOKE.delete_QueryProxy(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef( + null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } + + public virtual QueryProxy WhereEqualTo(string field, FieldValueProxy value) { + QueryProxy ret = new QueryProxy(FirestoreCppPINVOKE.QueryProxy_WhereEqualTo__SWIG_0(swigCPtr, field, FieldValueProxy.getCPtr(value)), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual QueryProxy WhereEqualTo(FieldPathProxy field, FieldValueProxy value) { + QueryProxy ret = new QueryProxy(FirestoreCppPINVOKE.QueryProxy_WhereEqualTo__SWIG_1(swigCPtr, FieldPathProxy.getCPtr(field), FieldValueProxy.getCPtr(value)), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual QueryProxy WhereNotEqualTo(string field, FieldValueProxy value) { + QueryProxy ret = new QueryProxy(FirestoreCppPINVOKE.QueryProxy_WhereNotEqualTo__SWIG_0(swigCPtr, field, FieldValueProxy.getCPtr(value)), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual QueryProxy WhereNotEqualTo(FieldPathProxy field, FieldValueProxy value) { + QueryProxy ret = new QueryProxy(FirestoreCppPINVOKE.QueryProxy_WhereNotEqualTo__SWIG_1(swigCPtr, FieldPathProxy.getCPtr(field), FieldValueProxy.getCPtr(value)), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual QueryProxy WhereLessThan(string field, FieldValueProxy value) { + QueryProxy ret = new QueryProxy(FirestoreCppPINVOKE.QueryProxy_WhereLessThan__SWIG_0(swigCPtr, field, FieldValueProxy.getCPtr(value)), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual QueryProxy WhereLessThan(FieldPathProxy field, FieldValueProxy value) { + QueryProxy ret = new QueryProxy(FirestoreCppPINVOKE.QueryProxy_WhereLessThan__SWIG_1(swigCPtr, FieldPathProxy.getCPtr(field), FieldValueProxy.getCPtr(value)), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual QueryProxy WhereLessThanOrEqualTo(string field, FieldValueProxy value) { + QueryProxy ret = new QueryProxy(FirestoreCppPINVOKE.QueryProxy_WhereLessThanOrEqualTo__SWIG_0(swigCPtr, field, FieldValueProxy.getCPtr(value)), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual QueryProxy WhereLessThanOrEqualTo(FieldPathProxy field, FieldValueProxy value) { + QueryProxy ret = new QueryProxy(FirestoreCppPINVOKE.QueryProxy_WhereLessThanOrEqualTo__SWIG_1(swigCPtr, FieldPathProxy.getCPtr(field), FieldValueProxy.getCPtr(value)), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual QueryProxy WhereGreaterThan(string field, FieldValueProxy value) { + QueryProxy ret = new QueryProxy(FirestoreCppPINVOKE.QueryProxy_WhereGreaterThan__SWIG_0(swigCPtr, field, FieldValueProxy.getCPtr(value)), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual QueryProxy WhereGreaterThan(FieldPathProxy field, FieldValueProxy value) { + QueryProxy ret = new QueryProxy(FirestoreCppPINVOKE.QueryProxy_WhereGreaterThan__SWIG_1(swigCPtr, FieldPathProxy.getCPtr(field), FieldValueProxy.getCPtr(value)), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual QueryProxy WhereGreaterThanOrEqualTo(string field, FieldValueProxy value) { + QueryProxy ret = new QueryProxy(FirestoreCppPINVOKE.QueryProxy_WhereGreaterThanOrEqualTo__SWIG_0(swigCPtr, field, FieldValueProxy.getCPtr(value)), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual QueryProxy WhereGreaterThanOrEqualTo(FieldPathProxy field, FieldValueProxy value) { + QueryProxy ret = new QueryProxy(FirestoreCppPINVOKE.QueryProxy_WhereGreaterThanOrEqualTo__SWIG_1(swigCPtr, FieldPathProxy.getCPtr(field), FieldValueProxy.getCPtr(value)), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual QueryProxy WhereArrayContains(string field, FieldValueProxy value) { + QueryProxy ret = new QueryProxy(FirestoreCppPINVOKE.QueryProxy_WhereArrayContains__SWIG_0(swigCPtr, field, FieldValueProxy.getCPtr(value)), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual QueryProxy WhereArrayContains(FieldPathProxy field, FieldValueProxy value) { + QueryProxy ret = new QueryProxy(FirestoreCppPINVOKE.QueryProxy_WhereArrayContains__SWIG_1(swigCPtr, FieldPathProxy.getCPtr(field), FieldValueProxy.getCPtr(value)), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual QueryProxy OrderBy(string field, QueryProxy.Direction direction) { + QueryProxy ret = new QueryProxy(FirestoreCppPINVOKE.QueryProxy_OrderBy__SWIG_0(swigCPtr, field, (int)direction), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual QueryProxy OrderBy(string field) { + QueryProxy ret = new QueryProxy(FirestoreCppPINVOKE.QueryProxy_OrderBy__SWIG_1(swigCPtr, field), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual QueryProxy OrderBy(FieldPathProxy field, QueryProxy.Direction direction) { + QueryProxy ret = new QueryProxy(FirestoreCppPINVOKE.QueryProxy_OrderBy__SWIG_2(swigCPtr, FieldPathProxy.getCPtr(field), (int)direction), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual QueryProxy OrderBy(FieldPathProxy field) { + QueryProxy ret = new QueryProxy(FirestoreCppPINVOKE.QueryProxy_OrderBy__SWIG_3(swigCPtr, FieldPathProxy.getCPtr(field)), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual QueryProxy Limit(int limit) { + QueryProxy ret = new QueryProxy(FirestoreCppPINVOKE.QueryProxy_Limit(swigCPtr, limit), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual QueryProxy LimitToLast(int limit) { + QueryProxy ret = new QueryProxy(FirestoreCppPINVOKE.QueryProxy_LimitToLast(swigCPtr, limit), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual QueryProxy StartAt(DocumentSnapshotProxy snapshot) { + QueryProxy ret = new QueryProxy(FirestoreCppPINVOKE.QueryProxy_StartAt(swigCPtr, DocumentSnapshotProxy.getCPtr(snapshot)), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual QueryProxy StartAfter(DocumentSnapshotProxy snapshot) { + QueryProxy ret = new QueryProxy(FirestoreCppPINVOKE.QueryProxy_StartAfter(swigCPtr, DocumentSnapshotProxy.getCPtr(snapshot)), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual QueryProxy EndBefore(DocumentSnapshotProxy snapshot) { + QueryProxy ret = new QueryProxy(FirestoreCppPINVOKE.QueryProxy_EndBefore(swigCPtr, DocumentSnapshotProxy.getCPtr(snapshot)), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual QueryProxy EndAt(DocumentSnapshotProxy snapshot) { + QueryProxy ret = new QueryProxy(FirestoreCppPINVOKE.QueryProxy_EndAt(swigCPtr, DocumentSnapshotProxy.getCPtr(snapshot)), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual System.Threading.Tasks.Task GetAsync(Source source) { + var future = FirestoreCppPINVOKE.QueryProxy_Get__SWIG_0(swigCPtr, (int)source); + + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return Future_QuerySnapshot.GetTask(new Future_QuerySnapshot(future, true)); + } + + public virtual System.Threading.Tasks.Task GetAsync() { + var future = FirestoreCppPINVOKE.QueryProxy_Get__SWIG_1(swigCPtr); + + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return Future_QuerySnapshot.GetTask(new Future_QuerySnapshot(future, true)); + } + + public enum Direction { + Ascending, + Descending + } + +} + +} \ No newline at end of file diff --git a/firestore/generated/src/proxy/QuerySnapshotProxy.cs b/firestore/generated/src/proxy/QuerySnapshotProxy.cs new file mode 100755 index 000000000..c44b02bb5 --- /dev/null +++ b/firestore/generated/src/proxy/QuerySnapshotProxy.cs @@ -0,0 +1,62 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 3.0.2 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace Firebase.Firestore { + +internal class QuerySnapshotProxy : global::System.IDisposable { + private global::System.Runtime.InteropServices.HandleRef swigCPtr; + protected bool swigCMemOwn; + + internal QuerySnapshotProxy(global::System.IntPtr cPtr, bool cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + } + + internal static global::System.Runtime.InteropServices.HandleRef getCPtr(QuerySnapshotProxy obj) { + return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; + } + + ~QuerySnapshotProxy() { + Dispose(); + } + + public virtual void Dispose() { + lock (FirebaseApp.disposeLock) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + FirestoreCppPINVOKE.delete_QuerySnapshotProxy(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef( + null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } + + public virtual QueryProxy query() { + QueryProxy ret = new QueryProxy(FirestoreCppPINVOKE.QuerySnapshotProxy_query(swigCPtr), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual SnapshotMetadataProxy metadata() { + SnapshotMetadataProxy ret = new SnapshotMetadataProxy(FirestoreCppPINVOKE.QuerySnapshotProxy_metadata(swigCPtr), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual uint size() { + uint ret = FirestoreCppPINVOKE.QuerySnapshotProxy_size(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + +} + +} \ No newline at end of file diff --git a/firestore/generated/src/proxy/SWIGTYPE_p_unsigned_char.cs b/firestore/generated/src/proxy/SWIGTYPE_p_unsigned_char.cs new file mode 100755 index 000000000..109899b59 --- /dev/null +++ b/firestore/generated/src/proxy/SWIGTYPE_p_unsigned_char.cs @@ -0,0 +1,27 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 3.0.2 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace Firebase.Firestore { + +internal class SWIGTYPE_p_unsigned_char { + private global::System.Runtime.InteropServices.HandleRef swigCPtr; + + internal SWIGTYPE_p_unsigned_char(global::System.IntPtr cPtr, bool futureUse) { + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + } + + protected SWIGTYPE_p_unsigned_char() { + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + + internal static global::System.Runtime.InteropServices.HandleRef getCPtr(SWIGTYPE_p_unsigned_char obj) { + return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; + } +} + +} \ No newline at end of file diff --git a/firestore/generated/src/proxy/SetOptionsProxy.cs b/firestore/generated/src/proxy/SetOptionsProxy.cs new file mode 100755 index 000000000..be1a606b2 --- /dev/null +++ b/firestore/generated/src/proxy/SetOptionsProxy.cs @@ -0,0 +1,60 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 3.0.2 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace Firebase.Firestore { + +internal class SetOptionsProxy : global::System.IDisposable { + private global::System.Runtime.InteropServices.HandleRef swigCPtr; + protected bool swigCMemOwn; + + internal SetOptionsProxy(global::System.IntPtr cPtr, bool cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + } + + internal static global::System.Runtime.InteropServices.HandleRef getCPtr(SetOptionsProxy obj) { + return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; + } + + ~SetOptionsProxy() { + Dispose(); + } + + public virtual void Dispose() { + lock (FirebaseApp.disposeLock) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + FirestoreCppPINVOKE.delete_SetOptionsProxy(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef( + null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } + + public SetOptionsProxy() : this(FirestoreCppPINVOKE.new_SetOptionsProxy(), true) { + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + + public static SetOptionsProxy Merge() { + SetOptionsProxy ret = new SetOptionsProxy(FirestoreCppPINVOKE.SetOptionsProxy_Merge(), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public static SetOptionsProxy MergeFields(StringList fields) { + SetOptionsProxy ret = new SetOptionsProxy(FirestoreCppPINVOKE.SetOptionsProxy_MergeFields(StringList.getCPtr(fields)), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + +} + +} \ No newline at end of file diff --git a/firestore/generated/src/proxy/SettingsProxy.cs b/firestore/generated/src/proxy/SettingsProxy.cs new file mode 100755 index 000000000..8f72ed976 --- /dev/null +++ b/firestore/generated/src/proxy/SettingsProxy.cs @@ -0,0 +1,97 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 3.0.2 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace Firebase.Firestore { + +internal class SettingsProxy : global::System.IDisposable { + private global::System.Runtime.InteropServices.HandleRef swigCPtr; + protected bool swigCMemOwn; + + internal SettingsProxy(global::System.IntPtr cPtr, bool cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + } + + internal static global::System.Runtime.InteropServices.HandleRef getCPtr(SettingsProxy obj) { + return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; + } + + ~SettingsProxy() { + Dispose(); + } + + public virtual void Dispose() { + lock (FirebaseApp.disposeLock) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + FirestoreCppPINVOKE.delete_SettingsProxy(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef( + null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } + + public SettingsProxy() : this(FirestoreCppPINVOKE.new_SettingsProxy__SWIG_0(), true) { + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + + public SettingsProxy(SettingsProxy other) : this(FirestoreCppPINVOKE.new_SettingsProxy__SWIG_1(SettingsProxy.getCPtr(other)), true) { + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + + public string host() { + string ret = FirestoreCppPINVOKE.SettingsProxy_host(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public bool is_ssl_enabled() { + bool ret = FirestoreCppPINVOKE.SettingsProxy_is_ssl_enabled(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public bool is_persistence_enabled() { + bool ret = FirestoreCppPINVOKE.SettingsProxy_is_persistence_enabled(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public long cache_size_bytes() { + long ret = FirestoreCppPINVOKE.SettingsProxy_cache_size_bytes(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public void set_host(string host) { + FirestoreCppPINVOKE.SettingsProxy_set_host(swigCPtr, host); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + + public void set_ssl_enabled(bool enabled) { + FirestoreCppPINVOKE.SettingsProxy_set_ssl_enabled(swigCPtr, enabled); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + + public void set_persistence_enabled(bool enabled) { + FirestoreCppPINVOKE.SettingsProxy_set_persistence_enabled(swigCPtr, enabled); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + + public void set_cache_size_bytes(long value) { + FirestoreCppPINVOKE.SettingsProxy_set_cache_size_bytes(swigCPtr, value); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + + public static readonly long kCacheSizeUnlimited = FirestoreCppPINVOKE.SettingsProxy_kCacheSizeUnlimited_get(); +} + +} \ No newline at end of file diff --git a/firestore/generated/src/proxy/SnapshotMetadataProxy.cs b/firestore/generated/src/proxy/SnapshotMetadataProxy.cs new file mode 100755 index 000000000..376136a5e --- /dev/null +++ b/firestore/generated/src/proxy/SnapshotMetadataProxy.cs @@ -0,0 +1,74 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 3.0.2 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace Firebase.Firestore { + +internal class SnapshotMetadataProxy : global::System.IDisposable { + private global::System.Runtime.InteropServices.HandleRef swigCPtr; + protected bool swigCMemOwn; + + internal SnapshotMetadataProxy(global::System.IntPtr cPtr, bool cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + } + + internal static global::System.Runtime.InteropServices.HandleRef getCPtr(SnapshotMetadataProxy obj) { + return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; + } + + ~SnapshotMetadataProxy() { + Dispose(); + } + + public virtual void Dispose() { + lock (FirebaseApp.disposeLock) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + FirestoreCppPINVOKE.delete_SnapshotMetadataProxy(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef( + null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } + + public SnapshotMetadataProxy() : this(FirestoreCppPINVOKE.new_SnapshotMetadataProxy__SWIG_0(), true) { + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + + public SnapshotMetadataProxy(bool hasPendingWrites, bool isFromCache) : this(FirestoreCppPINVOKE.new_SnapshotMetadataProxy__SWIG_1(hasPendingWrites, isFromCache), true) { + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + + public SnapshotMetadataProxy(SnapshotMetadataProxy other) : this(FirestoreCppPINVOKE.new_SnapshotMetadataProxy__SWIG_2(SnapshotMetadataProxy.getCPtr(other)), true) { + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + + public bool has_pending_writes() { + bool ret = FirestoreCppPINVOKE.SnapshotMetadataProxy_has_pending_writes(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public bool is_from_cache() { + bool ret = FirestoreCppPINVOKE.SnapshotMetadataProxy_is_from_cache(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public override string ToString() { + string ret = FirestoreCppPINVOKE.SnapshotMetadataProxy_ToString(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + +} + +} \ No newline at end of file diff --git a/firestore/generated/src/proxy/Source.cs b/firestore/generated/src/proxy/Source.cs new file mode 100755 index 000000000..295f26519 --- /dev/null +++ b/firestore/generated/src/proxy/Source.cs @@ -0,0 +1,17 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 3.0.2 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace Firebase.Firestore { + +public enum Source { + Default, + Server, + Cache +} + +} \ No newline at end of file diff --git a/firestore/generated/src/proxy/TimestampProxy.cs b/firestore/generated/src/proxy/TimestampProxy.cs new file mode 100755 index 000000000..2b5ebde51 --- /dev/null +++ b/firestore/generated/src/proxy/TimestampProxy.cs @@ -0,0 +1,80 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 3.0.2 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace Firebase.Firestore { + +internal class TimestampProxy : global::System.IDisposable { + private global::System.Runtime.InteropServices.HandleRef swigCPtr; + protected bool swigCMemOwn; + + internal TimestampProxy(global::System.IntPtr cPtr, bool cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + } + + internal static global::System.Runtime.InteropServices.HandleRef getCPtr(TimestampProxy obj) { + return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; + } + + ~TimestampProxy() { + Dispose(); + } + + public virtual void Dispose() { + lock (FirebaseApp.disposeLock) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + FirestoreCppPINVOKE.delete_TimestampProxy(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef( + null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } + + public TimestampProxy() : this(FirestoreCppPINVOKE.new_TimestampProxy__SWIG_0(), true) { + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + + public TimestampProxy(long seconds, int nanoseconds) : this(FirestoreCppPINVOKE.new_TimestampProxy__SWIG_1(seconds, nanoseconds), true) { + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + + public TimestampProxy(TimestampProxy other) : this(FirestoreCppPINVOKE.new_TimestampProxy__SWIG_2(TimestampProxy.getCPtr(other)), true) { + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + + public static TimestampProxy Now() { + TimestampProxy ret = new TimestampProxy(FirestoreCppPINVOKE.TimestampProxy_Now(), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public long seconds() { + long ret = FirestoreCppPINVOKE.TimestampProxy_seconds(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public int nanoseconds() { + int ret = FirestoreCppPINVOKE.TimestampProxy_nanoseconds(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public override string ToString() { + string ret = FirestoreCppPINVOKE.TimestampProxy_ToString(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + +} + +} \ No newline at end of file diff --git a/firestore/generated/src/proxy/TransactionCallbackProxy.cs b/firestore/generated/src/proxy/TransactionCallbackProxy.cs new file mode 100755 index 000000000..fee96f769 --- /dev/null +++ b/firestore/generated/src/proxy/TransactionCallbackProxy.cs @@ -0,0 +1,91 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 3.0.2 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace Firebase.Firestore { + +internal class TransactionCallbackProxy : global::System.IDisposable { + private global::System.Runtime.InteropServices.HandleRef swigCPtr; + protected bool swigCMemOwn; + + internal TransactionCallbackProxy(global::System.IntPtr cPtr, bool cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + } + + internal static global::System.Runtime.InteropServices.HandleRef getCPtr(TransactionCallbackProxy obj) { + return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; + } + + ~TransactionCallbackProxy() { + Dispose(); + } + + public virtual void Dispose() { + lock (FirebaseApp.disposeLock) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + FirestoreCppPINVOKE.delete_TransactionCallbackProxy(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef( + null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } + + public int callback_id() { + int ret = FirestoreCppPINVOKE.TransactionCallbackProxy_callback_id(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public TransactionResultOfGetProxy Get(DocumentReferenceProxy doc) { + TransactionResultOfGetProxy ret = new TransactionResultOfGetProxy(FirestoreCppPINVOKE.TransactionCallbackProxy_Get(swigCPtr, DocumentReferenceProxy.getCPtr(doc)), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public bool Update(DocumentReferenceProxy doc, FieldValueProxy fieldValue) { + bool ret = FirestoreCppPINVOKE.TransactionCallbackProxy_Update__SWIG_0(swigCPtr, DocumentReferenceProxy.getCPtr(doc), FieldValueProxy.getCPtr(fieldValue)); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public bool Update(DocumentReferenceProxy doc, FieldToValueMap wrapper) { + bool ret = FirestoreCppPINVOKE.TransactionCallbackProxy_Update__SWIG_1(swigCPtr, DocumentReferenceProxy.getCPtr(doc), FieldToValueMap.getCPtr(wrapper)); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public bool Update(DocumentReferenceProxy doc, FieldPathToValueMap wrapper) { + bool ret = FirestoreCppPINVOKE.TransactionCallbackProxy_Update__SWIG_2(swigCPtr, DocumentReferenceProxy.getCPtr(doc), FieldPathToValueMap.getCPtr(wrapper)); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public bool Set(DocumentReferenceProxy doc, FieldValueProxy data, SetOptionsProxy options) { + bool ret = FirestoreCppPINVOKE.TransactionCallbackProxy_Set(swigCPtr, DocumentReferenceProxy.getCPtr(doc), FieldValueProxy.getCPtr(data), SetOptionsProxy.getCPtr(options)); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public bool Delete(DocumentReferenceProxy doc) { + bool ret = FirestoreCppPINVOKE.TransactionCallbackProxy_Delete(swigCPtr, DocumentReferenceProxy.getCPtr(doc)); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public void OnCompletion(bool callbackSuccessful) { + FirestoreCppPINVOKE.TransactionCallbackProxy_OnCompletion(swigCPtr, callbackSuccessful); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + +} + +} \ No newline at end of file diff --git a/firestore/generated/src/proxy/TransactionManagerProxy.cs b/firestore/generated/src/proxy/TransactionManagerProxy.cs new file mode 100755 index 000000000..2a87454a1 --- /dev/null +++ b/firestore/generated/src/proxy/TransactionManagerProxy.cs @@ -0,0 +1,60 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 3.0.2 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace Firebase.Firestore { + +internal class TransactionManagerProxy : global::System.IDisposable { + private global::System.Runtime.InteropServices.HandleRef swigCPtr; + protected bool swigCMemOwn; + + internal TransactionManagerProxy(global::System.IntPtr cPtr, bool cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + } + + internal static global::System.Runtime.InteropServices.HandleRef getCPtr(TransactionManagerProxy obj) { + return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; + } + + ~TransactionManagerProxy() { + Dispose(); + } + + public virtual void Dispose() { + lock (FirebaseApp.disposeLock) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + FirestoreCppPINVOKE.delete_TransactionManagerProxy(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef( + null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } + + public TransactionManagerProxy(FirestoreProxy firestore) : this(FirestoreCppPINVOKE.new_TransactionManagerProxy(FirestoreProxy.getCPtr(firestore)), true) { + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + + public void CppDispose() { + FirestoreCppPINVOKE.TransactionManagerProxy_CppDispose(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + } + + public System.Threading.Tasks.Task RunTransactionAsync(int callbackId, Firebase.Firestore.TransactionManager.TransactionCallbackDelegate callback) { + System.Threading.Tasks.Task ret = Future_FirestoreVoid.GetTask( + new Future_FirestoreVoid(FirestoreCppPINVOKE.TransactionManagerProxy_RunTransaction(swigCPtr, callbackId, callback), true)); + + return ret; + } + +} + +} \ No newline at end of file diff --git a/firestore/generated/src/proxy/TransactionResultOfGetProxy.cs b/firestore/generated/src/proxy/TransactionResultOfGetProxy.cs new file mode 100755 index 000000000..89addfc64 --- /dev/null +++ b/firestore/generated/src/proxy/TransactionResultOfGetProxy.cs @@ -0,0 +1,68 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 3.0.2 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace Firebase.Firestore { + +internal class TransactionResultOfGetProxy : global::System.IDisposable { + private global::System.Runtime.InteropServices.HandleRef swigCPtr; + protected bool swigCMemOwn; + + internal TransactionResultOfGetProxy(global::System.IntPtr cPtr, bool cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + } + + internal static global::System.Runtime.InteropServices.HandleRef getCPtr(TransactionResultOfGetProxy obj) { + return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; + } + + ~TransactionResultOfGetProxy() { + Dispose(); + } + + public virtual void Dispose() { + lock (FirebaseApp.disposeLock) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + FirestoreCppPINVOKE.delete_TransactionResultOfGetProxy(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef( + null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } + + public bool is_valid() { + bool ret = FirestoreCppPINVOKE.TransactionResultOfGetProxy_is_valid(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public DocumentSnapshotProxy TakeSnapshot() { + DocumentSnapshotProxy ret = new DocumentSnapshotProxy(FirestoreCppPINVOKE.TransactionResultOfGetProxy_TakeSnapshot(swigCPtr), true); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public FirestoreError error_code() { + FirestoreError ret = (FirestoreError)FirestoreCppPINVOKE.TransactionResultOfGetProxy_error_code(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public string error_message() { + string ret = FirestoreCppPINVOKE.TransactionResultOfGetProxy_error_message(swigCPtr); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + +} + +} \ No newline at end of file diff --git a/firestore/generated/src/proxy/WriteBatchProxy.cs b/firestore/generated/src/proxy/WriteBatchProxy.cs new file mode 100755 index 000000000..996914424 --- /dev/null +++ b/firestore/generated/src/proxy/WriteBatchProxy.cs @@ -0,0 +1,57 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 3.0.2 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace Firebase.Firestore { + +internal class WriteBatchProxy : global::System.IDisposable { + private global::System.Runtime.InteropServices.HandleRef swigCPtr; + protected bool swigCMemOwn; + + internal WriteBatchProxy(global::System.IntPtr cPtr, bool cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + } + + internal static global::System.Runtime.InteropServices.HandleRef getCPtr(WriteBatchProxy obj) { + return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; + } + + ~WriteBatchProxy() { + Dispose(); + } + + public virtual void Dispose() { + lock (FirebaseApp.disposeLock) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + FirestoreCppPINVOKE.delete_WriteBatchProxy(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef( + null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } + + public virtual WriteBatchProxy Delete(DocumentReferenceProxy document) { + WriteBatchProxy ret = new WriteBatchProxy(FirestoreCppPINVOKE.WriteBatchProxy_Delete(swigCPtr, DocumentReferenceProxy.getCPtr(document)), false); + if (FirestoreCppPINVOKE.SWIGPendingException.Pending) throw FirestoreCppPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public virtual System.Threading.Tasks.Task CommitAsync() { + System.Threading.Tasks.Task ret = Future_FirestoreVoid.GetTask( + new Future_FirestoreVoid(FirestoreCppPINVOKE.WriteBatchProxy_Commit(swigCPtr), true)); + + return ret; + } + +} + +} \ No newline at end of file diff --git a/firestore/snippets/Snippets.cs b/firestore/snippets/Snippets.cs new file mode 100644 index 000000000..4f2185fc3 --- /dev/null +++ b/firestore/snippets/Snippets.cs @@ -0,0 +1,428 @@ +/* + * Copyright 2019 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * A collection of code snippets for the Cloud Firestore Unity plugin. These snippets were modelled + * after the reference docs/snippets, which can be found here: + * https://firebase.google.com/docs/firestore. + * + * Note that not all of the Firestore API has been implemented yet, so some snippets are + * incomplete/missing. + */ + +using Firebase.Extensions; +using Firebase.Firestore; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Threading.Tasks; +using UnityEngine; + +public class Snippets { + // https://firebase.google.com/docs/firestore/quickstart#initialize + public static void Initialize() { + FirebaseFirestore db = FirebaseFirestore.DefaultInstance; + } + + // https://firebase.google.com/docs/firestore/quickstart#add_data + public static void AddData1() { + FirebaseFirestore db = FirebaseFirestore.DefaultInstance; + + DocumentReference docRef = db.Collection("users").Document("alovelace"); + Dictionary user = new Dictionary + { + { "First", "Ada" }, + { "Last", "Lovelace" }, + { "Born", 1815 }, + }; + docRef.SetAsync(user).ContinueWithOnMainThread(task => { + Debug.Log("Added data to the alovelace document in the users collection."); + }); + } + + public static void AddData2() { + FirebaseFirestore db = FirebaseFirestore.DefaultInstance; + + DocumentReference docRef = db.Collection("users").Document("aturing"); + Dictionary user = new Dictionary + { + { "First", "Alan" }, + { "Middle", "Mathison" }, + { "Last", "Turing" }, + { "Born", 1912 } + }; + docRef.SetAsync(user).ContinueWithOnMainThread(task => { + Debug.Log("Added data to the aturing document in the users collection."); + }); + } + + // https://firebase.google.com/docs/firestore/quickstart#read_data + public static void ReadData() { + FirebaseFirestore db = FirebaseFirestore.DefaultInstance; + + CollectionReference usersRef = db.Collection("users"); + usersRef.GetSnapshotAsync().ContinueWithOnMainThread(task => { + QuerySnapshot snapshot = task.Result; + foreach (DocumentSnapshot document in snapshot.Documents) { + Debug.Log(String.Format("User: {0}", document.Id)); + Dictionary documentDictionary = document.ToDictionary(); + Debug.Log(String.Format("First: {0}", documentDictionary["First"])); + if (documentDictionary.ContainsKey("Middle")) { + Debug.Log(String.Format("Middle: {0}", documentDictionary["Middle"])); + } + Debug.Log(String.Format("Last: {0}", documentDictionary["Last"])); + Debug.Log(String.Format("Born: {0}", documentDictionary["Born"])); + } + Debug.Log("Read all data from the users collection."); + }); + } + + // https://firebase.google.com/docs/firestore/manage-data/add-data#set_a_document + public static void AddDocAsMap() { + FirebaseFirestore db = FirebaseFirestore.DefaultInstance; + + DocumentReference docRef = db.Collection("cities").Document("LA"); + Dictionary city = new Dictionary + { + { "Name", "Los Angeles" }, + { "State", "CA" }, + { "Country", "USA" } + }; + docRef.SetAsync(city).ContinueWithOnMainThread(task => { + Debug.Log("Added data to the LA document in the cities collection."); + }); + } + + // https://firebase.google.com/docs/firestore/manage-data/add-data#data_types + public static void AddDocDataTypes() { + FirebaseFirestore db = FirebaseFirestore.DefaultInstance; + + DocumentReference docRef = db.Collection("data").Document("one"); + Dictionary docData = new Dictionary + { + { "stringExample", "Hello World" }, + { "booleanExample", false }, + { "numberExample", 3.14159265 }, + { "nullExample", null }, + { "arrayExample", new List() { 5, true, "Hello" } }, + { "objectExample", new Dictionary + { + { "a", 5 }, + { "b", true }, + } + }, + }; + + docRef.SetAsync(docData).ContinueWithOnMainThread(task => { + Debug.Log( + "Set multiple data-type data for the one document in the data collection."); + }); + } + + // https://firebase.google.com/docs/firestore/manage-data/add-data#add_a_document + public static void SetRequiresId() { + FirebaseFirestore db = FirebaseFirestore.DefaultInstance; + + Dictionary city = new Dictionary + { + { "Name", "Phuket" }, + { "Country", "Thailand" } + }; + db.Collection("cities").Document("new-city-id").SetAsync(city) + .ContinueWithOnMainThread(task => { + Debug.Log("Added document with ID: new-city-id."); + }); + } + + public static void AddDocDataWithAutoId() { + FirebaseFirestore db = FirebaseFirestore.DefaultInstance; + + Dictionary city = new Dictionary + { + { "Name", "Tokyo" }, + { "Country", "Japan" } + }; + db.Collection("cities").AddAsync(city).ContinueWithOnMainThread(task => { + DocumentReference addedDocRef = task.Result; + Debug.Log(String.Format("Added document with ID: {0}.", addedDocRef.Id)); + }); + } + + public static void AddDocDataAfterAutoId() { + FirebaseFirestore db = FirebaseFirestore.DefaultInstance; + + Dictionary city = new Dictionary + { + { "Name", "Moscow" }, + { "Country", "Russia" } + }; + DocumentReference addedDocRef = db.Collection("cities").Document(); + Debug.Log(String.Format("Added document with ID: {0}.", addedDocRef.Id)); + addedDocRef.SetAsync(city).ContinueWithOnMainThread(task => { + Debug.Log(String.Format( + "Added data to the {0} document in the cities collection.", addedDocRef.Id)); + }); + } + + // https://firebase.google.com/docs/firestore/manage-data/add-data#update-data + public static void UpdateDoc() { + FirebaseFirestore db = FirebaseFirestore.DefaultInstance; + + DocumentReference cityRef = db.Collection("cities").Document("new-city-id"); + Dictionary updates = new Dictionary + { + { "Capital", false } + }; + // You can also update a single field with: cityRef.UpdateAsync("Capital", false); + cityRef.UpdateAsync(updates).ContinueWithOnMainThread(task => { + Debug.Log( + "Updated the Capital field of the new-city-id document in the cities collection."); + }); + } + + // https://firebase.google.com/docs/firestore/manage-data/add-data#server_timestamp + public static void UpdateServerTimestamp() { + FirebaseFirestore db = FirebaseFirestore.DefaultInstance; + + DocumentReference cityRef = db.Collection("cities").Document("new-city-id"); + cityRef.UpdateAsync("Timestamp", FieldValue.ServerTimestamp) + .ContinueWithOnMainThread(task => { + Debug.Log( + "Updated the Timestamp field of the new-city-id document in the cities " + + "collection."); + }); + } + + // https://firebase.google.com/docs/firestore/manage-data/add-data#update_fields_in_nested_objects + public static void UpdateNestedFields() { + FirebaseFirestore db = FirebaseFirestore.DefaultInstance; + + DocumentReference frankDocRef = db.Collection("users").Document("frank"); + Dictionary initialData = new Dictionary + { + { "Name", "Frank" }, + { "Age", 12 } + }; + + Dictionary favorites = new Dictionary + { + { "Food", "Pizza" }, + { "Color", "Blue" }, + { "Subject", "Recess" }, + }; + initialData.Add("Favorites", favorites); + frankDocRef.SetAsync(initialData).ContinueWithOnMainThread(task => { + + // Update age and favorite color + Dictionary updates = new Dictionary + { + { "Age", 13 }, + { "Favorites.Color", "Red" }, + }; + + // Asynchronously update the document + return frankDocRef.UpdateAsync(updates); + }).ContinueWithOnMainThread(task => { + Debug.Log( + "Updated the age and favorite color fields of the Frank document in " + + "the users collection."); + }); + } + + // https://firebase.google.com/docs/firestore/manage-data/delete-data#delete_documents + public static void DeleteDoc() { + EnsureExampleDataPresent().ContinueWithOnMainThread(task => { + FirebaseFirestore db = FirebaseFirestore.DefaultInstance; + + DocumentReference cityRef = db.Collection("cities").Document("DC"); + cityRef.DeleteAsync(); + }); + } + + // https://firebase.google.com/docs/firestore/manage-data/delete-data#fields + public static void DeleteField() { + EnsureExampleDataPresent().ContinueWithOnMainThread(task => { + FirebaseFirestore db = FirebaseFirestore.DefaultInstance; + + DocumentReference cityRef = db.Collection("cities").Document("BJ"); + Dictionary updates = new Dictionary + { + { "Capital", FieldValue.Delete } + }; + + cityRef.UpdateAsync(updates); + }); + } + + // https://firebase.google.com/docs/firestore/query-data/get-data#example_data + private static Task EnsureExampleDataPresent() { + FirebaseFirestore db = FirebaseFirestore.DefaultInstance; + + CollectionReference citiesRef = db.Collection("cities"); + return citiesRef.Document("SF").SetAsync(new Dictionary(){ + { "Name", "San Francisco" }, + { "State", "CA" }, + { "Country", "USA" }, + { "Capital", false }, + { "Population", 860000 } + }).ContinueWithOnMainThread(task => + citiesRef.Document("LA").SetAsync(new Dictionary(){ + { "Name", "Los Angeles" }, + { "State", "CA" }, + { "Country", "USA" }, + { "Capital", false }, + { "Population", 3900000 } + }) + ).ContinueWithOnMainThread(task => + citiesRef.Document("DC").SetAsync(new Dictionary(){ + { "Name", "Washington D.C." }, + { "State", null }, + { "Country", "USA" }, + { "Capital", true }, + { "Population", 680000 } + }) + ).ContinueWithOnMainThread(task => + citiesRef.Document("TOK").SetAsync(new Dictionary(){ + { "Name", "Tokyo" }, + { "State", null }, + { "Country", "Japan" }, + { "Capital", true }, + { "Population", 9000000 } + }) + ).ContinueWithOnMainThread(task => + citiesRef.Document("BJ").SetAsync(new Dictionary(){ + { "Name", "Beijing" }, + { "State", null }, + { "Country", "China" }, + { "Capital", true }, + { "Population", 21500000 } + }) + ); + } + + // https://firebase.google.com/docs/firestore/query-data/get-data#get_a_document + public static void GetDocument() { + EnsureExampleDataPresent().ContinueWithOnMainThread>(task => { + FirebaseFirestore db = FirebaseFirestore.DefaultInstance; + + DocumentReference docRef = db.Collection("cities").Document("SF"); + return docRef.GetSnapshotAsync(); + }).Unwrap().ContinueWithOnMainThread(task => { + DocumentSnapshot snapshot = task.Result; + if (snapshot.Exists) { + Debug.Log(String.Format("Document data for {0} document:", snapshot.Id)); + Dictionary city = snapshot.ToDictionary(); + foreach (KeyValuePair pair in city) { + Debug.Log(String.Format("{0}: {1}", pair.Key, pair.Value)); + } + } else { + Debug.Log(String.Format("Document {0} does not exist!", snapshot.Id)); + } + }); + } + + // https://firebase.google.com/docs/firestore/query-data/get-data#get_multiple_documents_from_a_collection + public static void GetMultipleDocs() { + EnsureExampleDataPresent().ContinueWithOnMainThread>(task => { + FirebaseFirestore db = FirebaseFirestore.DefaultInstance; + + Query capitalQuery = db.Collection("cities").WhereEqualTo("Capital", true); + return capitalQuery.GetSnapshotAsync(); + }).Unwrap().ContinueWithOnMainThread(task => { + QuerySnapshot capitalQuerySnapshot = task.Result; + foreach (DocumentSnapshot documentSnapshot in capitalQuerySnapshot.Documents) { + Debug.Log(String.Format("Document data for {0} document:", documentSnapshot.Id)); + Dictionary city = documentSnapshot.ToDictionary(); + foreach (KeyValuePair pair in city) { + Debug.Log(String.Format("{0}: {1}", pair.Key, pair.Value)); + } + + // Newline to separate entries + Debug.Log(""); + } + }); + } + + // https://firebase.google.com/docs/firestore/query-data/get-data#get_all_documents_in_a_collection + public static void GetAllDocs() { + EnsureExampleDataPresent().ContinueWithOnMainThread>(task => { + FirebaseFirestore db = FirebaseFirestore.DefaultInstance; + + Query allCitiesQuery = db.Collection("cities"); + return allCitiesQuery.GetSnapshotAsync(); + }).Unwrap().ContinueWithOnMainThread(task => { + QuerySnapshot allCitiesQuerySnapshot = task.Result; + foreach (DocumentSnapshot documentSnapshot in allCitiesQuerySnapshot.Documents) { + Debug.Log(String.Format("Document data for {0} document:", documentSnapshot.Id)); + Dictionary city = documentSnapshot.ToDictionary(); + foreach (KeyValuePair pair in city) { + Debug.Log(String.Format("{0}: {1}", pair.Key, pair.Value)); + } + + // Newline to separate entries + Debug.Log(""); + } + }); + } + + // https://firebase.google.com/docs/firestore/query-data/listen + public static void ListenDocument() { + EnsureExampleDataPresent().ContinueWithOnMainThread(task => { + FirebaseFirestore db = FirebaseFirestore.DefaultInstance; + + DocumentReference docRef = db.Collection("cities").Document("SF"); + ListenerRegistration listener = docRef.Listen(snapshot => { + Debug.Log("Callback received document snapshot."); + Debug.Log(String.Format("Document data for {0} document:", snapshot.Id)); + Dictionary city = snapshot.ToDictionary(); + foreach (KeyValuePair pair in city) { + Debug.Log(String.Format("{0}: {1}", pair.Key, pair.Value)); + } + }); + }); + } + + // https://firebase.google.com/docs/firestore/query-data/listen#listen_to_multiple_documents_in_a_collection + public static void ListenMultiple() { + EnsureExampleDataPresent().ContinueWithOnMainThread(task => { + FirebaseFirestore db = FirebaseFirestore.DefaultInstance; + + CollectionReference citiesRef = db.Collection("cities"); + Query query = db.Collection("cities").WhereEqualTo("State", "CA"); + + ListenerRegistration listener = query.Listen(snapshot => { + Debug.Log("Callback received query snapshot."); + Debug.Log("Current cities in California:"); + foreach (DocumentSnapshot documentSnapshot in snapshot.Documents) { + Debug.Log(documentSnapshot.Id); + } + }); + }); + } + + // https://firebase.google.com/docs/firestore/query-data/listen#detach_a_listener + public static void DetachListener() { + FirebaseFirestore db = FirebaseFirestore.DefaultInstance; + + CollectionReference citiesRef = db.Collection("cities"); + Query query = db.Collection("cities").WhereEqualTo("State", "CA"); + + ListenerRegistration listener = query.Listen(snapshot => { }); + + // Detach the listener + listener.Stop(); + } +} diff --git a/firestore/src/Blob.cs b/firestore/src/Blob.cs new file mode 100644 index 000000000..ca947b0f9 --- /dev/null +++ b/firestore/src/Blob.cs @@ -0,0 +1,128 @@ +// Copyright 2017, Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; +using System.Runtime.InteropServices; +using System.Text; + +namespace Firebase.Firestore { + /// + /// An immutable sequence of bytes. + /// + /// + /// Although this is a struct, it's effectively just a wrapper around a byte[]. + /// + public struct Blob : IEquatable { + private readonly byte[] _bytes; + private int _hash; + + /// + /// The length of the blob, in bytes. + /// + public int Length => _bytes.Length; + + /// + /// Returns the byte at index . + /// + /// The index in the blob to return. Must be greater than or equal to 0, and + /// less than . + /// The byte at index . + public byte this[int index] => _bytes[index]; + + /// + /// Returns a copy of this Blob as a byte[]. + /// + public byte[] ToBytes() => (byte[])_bytes.Clone(); + + /// + /// Constructs a new by copying the current content of + /// . + /// + /// Byte array to copy. + /// A new blob containing a copy of . + public static Blob CopyFrom(byte[] bytes) => new Blob(bytes); + + /// + public override bool Equals(object obj) => obj is Blob && Equals((Blob)obj); + + /// + public override int GetHashCode() { + // The traditional algorithm for hash protobuf ByteString. + if (_hash != 0) { + return _hash; + } + int result = Length; + foreach (byte b in _bytes) { + result = result * 31 + (int)b; + } + if (result == 0) { + result = 1; + } + _hash = result; + return result; + } + + /// + public bool Equals(Blob other) { + // SequenceEqual is not available. So just do this in naive way. + if (Length != other.Length || + (_hash != 0 && other._hash != 0 && _hash != other._hash)) { + return false; + } + for (int i = 0; i < Length; ++i) { + if (_bytes[i] != other._bytes[i]) { + return false; + } + } + return true; + } + + /// + /// Operator overload to compare two Blob values for equality. + /// + /// Left value to compare + /// Right value to compare + /// true if is equal to ; otherwise + /// false. + public static bool operator ==(Blob lhs, Blob rhs) => lhs.Equals(rhs); + + /// + /// Operator overload to compare two Blob values for inequality. + /// + /// Left value to compare + /// Right value to compare + /// false if is equal to ; otherwise + /// true. + public static bool operator !=(Blob lhs, Blob rhs) => !lhs.Equals(rhs); + + /// + public override string ToString() { + StringBuilder builder = new StringBuilder("Blob: Length="); + builder.Append(_bytes.Length); + builder.Append(_bytes.Length > 32 ? "; Hex (first 32 bytes only)=" : "; Hex="); + for (int i = 0; i < Math.Min(_bytes.Length, 32); i++) { + if (i != 0) { + builder.Append(" "); + } + builder.Append(_bytes[i].ToString("X2")); + } + return builder.ToString(); + } + + private Blob(byte[] bytes) { + _bytes = (byte[])bytes.Clone(); + _hash = 0; + } + } +} diff --git a/firestore/src/BuildStubs.cs b/firestore/src/BuildStubs.cs new file mode 100644 index 000000000..a550814c1 --- /dev/null +++ b/firestore/src/BuildStubs.cs @@ -0,0 +1,6 @@ + +// TODO(unity-api): Create BUILD file and delete this. It only exists so you +// can run "mcs -t:library *.cs" to sanity-check the stubs build. +namespace Firebase.Platform { + public class FirebaseApp { } +} diff --git a/firestore/src/CollectionReference.cs b/firestore/src/CollectionReference.cs new file mode 100644 index 000000000..aaae19b92 --- /dev/null +++ b/firestore/src/CollectionReference.cs @@ -0,0 +1,117 @@ +// Copyright 2017, Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Firebase.Firestore.Internal; +using System; +using System.Threading; +using System.Threading.Tasks; + +namespace Firebase.Firestore { + /// + /// A reference to a collection in a Firestore database. The existence of this object does not + /// imply that the collection currently exists in storage. + /// + /// + /// A CollectionReference can be used for adding documents, getting document references, + /// and querying for documents (using the methods inherited from Query). + /// + public sealed class CollectionReference : Query, IEquatable { + // _proxy is defined in the base class Query of type Object. + + internal CollectionReference(CollectionReferenceProxy proxy, FirebaseFirestore firestore) + : base(proxy, firestore) { } + + private CollectionReferenceProxy Proxy { + get { + return (CollectionReferenceProxy)_proxy; + } + } + + /// + /// The final part of the complete collection path; this is the identity of the collection + /// relative to its parent document. + /// + public string Id => Proxy.id(); + + /// + /// The complete collection path, including project and database ID. + /// + public string Path => Proxy.path(); + + /// + /// The parent document, or null if this is a root collection. + /// + public DocumentReference Parent { + get { + DocumentReferenceProxy parent = Proxy.Parent(); + if (parent.is_valid()) { + return new DocumentReference(parent, Firestore); + } else { + return null; + } + } + } + + /// + /// Creates a for a direct child document of this collection + /// with a random ID. This performs no server-side operations; it only generates the appropriate + /// DocumentReference. + /// + /// A to a child document of this collection with a + /// random ID. + public DocumentReference Document() => new DocumentReference(Proxy.Document(), Firestore); + + /// + /// Creates a for a child document of this reference. + /// + /// The path to the document, relative to this collection. Must not be null, + /// and must contain an odd number of slash-separated path elements. + /// A for the specified document. + public DocumentReference Document(string path) { + Preconditions.CheckNotNullOrEmpty(path, nameof(path)); + return new DocumentReference(Proxy.Document(path), Firestore); + } + + /// + /// Asynchronously creates a document with the given data in this collection. The document has a + /// randomly generated ID. + /// + /// The data for the document. Must not be null. + /// The reference for the newly-created document. + public Task AddAsync(object documentData) { + Preconditions.CheckNotNull(documentData, nameof(documentData)); + DocumentReference docRef = Document(); + Task setAsyncTask = docRef.SetAsync(documentData); + return Util.MapResult(setAsyncTask, docRef); + } + + /// + public override int GetHashCode() { + int hash = Firestore.GetHashCode(); + hash = hash * 31 + base.GetHashCode(); + return hash; + } + + /// + public override bool Equals(object obj) => Equals(obj as CollectionReference); + + /// + public bool Equals(CollectionReference other) { + return other != null && base.Equals(other); + } + + /// + public override string ToString() => Path; + } +} diff --git a/firestore/src/ConverterRegistry.cs b/firestore/src/ConverterRegistry.cs new file mode 100644 index 000000000..ebbbc5b83 --- /dev/null +++ b/firestore/src/ConverterRegistry.cs @@ -0,0 +1,59 @@ +// Copyright 2019, Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Firebase.Firestore.Converters; +using Firebase.Firestore.Internal; +using System; +using System.Collections; +using System.Collections.Generic; +using BclType = System.Type; + +namespace Firebase.Firestore { + /// + /// TODO(unity): Currently we don't expose this class and so it's basically dead code, but + /// keeping it around for parity with google-cloud-dotnet. + /// + /// Registry of custom converters. This is used to avoid requiring Firestore-specific attributes on types + /// which may be intended to be non-Firestore-specific. + /// + internal sealed class ConverterRegistry : IEnumerable { + // Only present so we can iterate in a vaguely sensible way. + private readonly List _converterList = new List(); + private readonly Dictionary _converters = + new Dictionary(); + + /// + /// Adds the given converter to the registry. + /// + /// The + /// The converter to add. + /// There is already a converter in the registry for the given type. + public void Add(FirestoreConverter converter) { + Preconditions.CheckNotNull(converter, nameof(converter)); + _converters.Add(typeof(T), new CustomConverter(converter)); + _converterList.Add(converter); + } + + // We only really implement IEnumerable for the sake of collection initializers, but we're at least + // vaguely pleasant about it. + /// + IEnumerator IEnumerable.GetEnumerator() => _converterList.GetEnumerator(); + + internal IDictionary ToConverterDictionary() { + // Clone the dictionary so that any further changes are ignored, and we don't have any thread + // safety concerns. (We'll only be reading from the returned dictionary.) + return new Dictionary(_converters); + } + } +} diff --git a/firestore/src/Converters/AnonymousTypeConverter.cs b/firestore/src/Converters/AnonymousTypeConverter.cs new file mode 100644 index 000000000..97e32ae56 --- /dev/null +++ b/firestore/src/Converters/AnonymousTypeConverter.cs @@ -0,0 +1,39 @@ +// Copyright 2018, Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using BclType = System.Type; + +namespace Firebase.Firestore.Converters { + /// + /// A converter for an anonymous type. Currently this only performs serialization, not deserialization. + /// Using anonymous types for deserialization would be unusual in terms of the C# required, but not + /// entirely infeasible. We can implement this if we're ever asked for it. + /// + internal sealed class AnonymousTypeConverter : MapConverterBase { + private readonly IList _properties; + + internal AnonymousTypeConverter(BclType targetType) : base(targetType) { + _properties = targetType.GetProperties().ToList(); + } + + public override void SerializeMap(SerializationContext context, object value, IDictionary map) { + foreach (var property in _properties) { + map[property.Name] = ValueSerializer.Serialize(context, property.GetValue(value, index: null)); + } + } + } +} diff --git a/firestore/src/Converters/ArrayConverter.cs b/firestore/src/Converters/ArrayConverter.cs new file mode 100644 index 000000000..0aaeb8cc7 --- /dev/null +++ b/firestore/src/Converters/ArrayConverter.cs @@ -0,0 +1,52 @@ +// Copyright 2018, Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Firebase.Firestore.Internal; +using System; +using System.Collections.Generic; +using BclType = System.Type; + +namespace Firebase.Firestore.Converters { + /// + /// Converter for array types. Serialization is handled by the base class; only custom deserialization is required. + /// + internal sealed class ArrayConverter : EnumerableConverterBase { + private readonly BclType _elementType; + + internal ArrayConverter(BclType elementType) : base(elementType.MakeArrayType()) { + _elementType = elementType; + } + + protected override object DeserializeArray(DeserializationContext context, FieldValueProxy arrayValue) { + Preconditions.CheckState(arrayValue.type() == FieldValueProxy.Type.Array, "Expected to receive an array FieldValue"); + + using (var array = FirestoreCpp.ConvertFieldValueToVector(arrayValue)) { + uint usize = array.Size(); + if (usize > System.Int32.MaxValue) { + throw new ArgumentException( + "Array contains too many values (more than System.Int32.MaxValue)"); + } + + Array result = Array.CreateInstance(_elementType, usize); + for (int i = 0; i < usize; i++) { + FieldValueProxy value = array.GetUnsafeView((uint)i); + var converted = ValueDeserializer.Deserialize(context, value, _elementType); + result.SetValue(converted, i); + } + + return result; + } + } + } +} diff --git a/firestore/src/Converters/AttributedIdAssigner.cs b/firestore/src/Converters/AttributedIdAssigner.cs new file mode 100644 index 000000000..673b1dc11 --- /dev/null +++ b/firestore/src/Converters/AttributedIdAssigner.cs @@ -0,0 +1,107 @@ +// Copyright 2019, Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Firebase.Firestore.Internal; +using System; +using System.Collections.Generic; +using System.Reflection; +using BclType = System.Type; + +namespace Firebase.Firestore.Converters { + internal sealed class AttributedIdAssigner { + private static readonly Dictionary s_assigners = + new Dictionary(); + + private readonly List _idProperties; + private readonly List _referenceProperties; + + private AttributedIdAssigner(List idProperties, List referenceProperties) { + _idProperties = idProperties; + _referenceProperties = referenceProperties; + } + + private void AssignId(object value, DocumentReference reference) { + // TODO: Create delegates instead of using reflection on every invocation? + + foreach (var property in _idProperties) { + property.SetValue(value, reference.Id, index: null); + } + + foreach (var property in _referenceProperties) { + property.SetValue(value, reference, index: null); + } + } + + internal static void MaybeAssignId(object value, DocumentReference reference) { + if (value == null) { + return; + } + lock (s_assigners) { + AttributedIdAssigner assigner; + if (!s_assigners.TryGetValue(value.GetType(), out assigner)) { + assigner = MaybeCreateAssigner(value.GetType()); + s_assigners[value.GetType()] = assigner; + } + assigner?.AssignId(value, reference); + } + } + + /// + /// Returns an "ID assigner" suitable for the given BCL type, or null if the type isn't decorated with FirestoreDataAttribute, + /// or doesn't have any FirestoreDocumentId attributes. + /// + /// The type to inspect for ID properties. + /// An assigner, or null if the type doesn't need any ID assignments performed on it. + private static AttributedIdAssigner MaybeCreateAssigner(BclType type) { + if (!type.IsDefined(typeof(FirestoreDataAttribute), inherit: true)) { + return null; + } + + // While it's unusual, it's not an error to have multiple properties decorated with [FirestoreDocumentId] + List setIdProperties = new List(); + List setReferenceProperties = new List(); + // We look for static properties specifically to find problems. We'll never use static properties. + foreach (var property in type.GetProperties(BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)) { + string typeName = property.DeclaringType.FullName; + if (!property.IsDefined(typeof(FirestoreDocumentIdAttribute), inherit: true)) { + continue; + } + var setMethod = property.GetSetMethod(nonPublic: true); + Preconditions.CheckState(setMethod != null, + "{0}.{1} has no setter, and should not be decorated with {2}.", + typeName, property.Name, nameof(FirestoreDocumentIdAttribute)); + Preconditions.CheckState(!setMethod.IsStatic, + "{0}.{1} is static, and should not be decorated with {2}.", + typeName, property.Name, nameof(FirestoreDocumentIdAttribute)); + Preconditions.CheckState(setMethod.GetParameters().Length == 1, + "{0}.{1} is an indexer, and should not be decorated with {2}.", + typeName, property.Name, nameof(FirestoreDocumentIdAttribute)); + Preconditions.CheckState(!property.IsDefined(typeof(FirestorePropertyAttribute), inherit: true), + "{0}.{1} is decorated with FirestorePropertyAttribute, and should not be decorated with {2}.", + typeName, property.Name, nameof(FirestoreDocumentIdAttribute)); + if (property.PropertyType == typeof(string)) { + setIdProperties.Add(property); + } else if (property.PropertyType == typeof(DocumentReference)) { + setReferenceProperties.Add(property); + } else { + throw new InvalidOperationException(String.Format( + "{0}.{1} is not a string or {2} property, and should not be decorated with {3}.", + typeName, property.Name, nameof(DocumentReference), nameof(FirestoreDocumentIdAttribute))); + } + } + return setIdProperties.Count == 0 && setReferenceProperties.Count == 0 + ? null : new AttributedIdAssigner(setIdProperties, setReferenceProperties); + } + } +} diff --git a/firestore/src/Converters/AttributedTypeConverter.cs b/firestore/src/Converters/AttributedTypeConverter.cs new file mode 100644 index 000000000..4671b7281 --- /dev/null +++ b/firestore/src/Converters/AttributedTypeConverter.cs @@ -0,0 +1,223 @@ +// Copyright 2018, Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Firebase.Firestore.Internal; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Reflection; +using BclType = System.Type; + +namespace Firebase.Firestore.Converters { + internal sealed class AttributedTypeConverter : MapConverterBase { + // Note: the use of a dictionary for writable properties and a list for readable ones is purely + // driven by how we use this. If we ever want a dictionary for readable properties, that's easy to do. + private readonly Dictionary _writableProperties; + private readonly List _readableProperties; + private readonly Func _createInstance; + private readonly FirestoreDataAttribute _attribute; + + private AttributedTypeConverter(BclType targetType, FirestoreDataAttribute attribute) : base(targetType) { + _attribute = attribute; + + // Check for user bugs in terms of attribute specifications. + Preconditions.CheckState(Enum.IsDefined(typeof(UnknownPropertyHandling), _attribute.UnknownPropertyHandling), + "Type {0} has invalid {1} value", targetType.FullName, nameof(FirestoreDataAttribute.UnknownPropertyHandling)); + + _createInstance = CreateObjectCreator(targetType); + + List readableProperties = new List(); + Dictionary writableProperties = new Dictionary(); + // We look for static properties specifically to find problems. We'll never use static properties. + foreach (var property in targetType.GetProperties(BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)) { + var propertyAttribute = Attribute.GetCustomAttribute(property, typeof(FirestorePropertyAttribute), inherit: true) as FirestorePropertyAttribute; + if (propertyAttribute == null) { + continue; + } + var attributedProperty = new AttributedProperty(property, propertyAttribute); + string firestoreName = attributedProperty.FirestoreName; + + if (attributedProperty.IsNullableValue) { + throw new NotSupportedException( + String.Format("{0}.{1} is Nullable value type, which we do not support now due to a Unity limitation. " + + "Try using a reference type instead.", + targetType.FullName, property.Name)); + } + + // Note that we check readable and writable properties separately. We could theoretically have + // two separate properties, one read-only and one write-only, with the same name in Firestore. + if (attributedProperty.CanRead) { + // This is O(N), but done once per type so should be okay. + Preconditions.CheckState(!readableProperties.Any(p => p.FirestoreName == firestoreName), + "Type {0} contains multiple readable properties with name {1}", targetType.FullName, firestoreName); + readableProperties.Add(attributedProperty); + } + if (attributedProperty.CanWrite) { + Preconditions.CheckState(!writableProperties.ContainsKey(firestoreName), + "Type {0} contains multiple writable properties with name {1}", targetType.FullName, firestoreName); + writableProperties[firestoreName] = attributedProperty; + } + } + _readableProperties = readableProperties; + _writableProperties = writableProperties; + } + + // Only used in the constructor, but extracted for readability. + private static Func CreateObjectCreator(BclType type) { + if (type.IsValueType) { + return () => Activator.CreateInstance(type); + } else { + // TODO: Consider using a compiled expression tree for this. + var ctor = type + .GetConstructors(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance) + .SingleOrDefault(c => c.GetParameters().Length == 0); + Preconditions.CheckState(ctor != null, "Type {0} has no parameterless constructor", type.FullName); + return () => { + try { + return ctor.Invoke(parameters: null); + } catch (TargetInvocationException e) { + if (e.InnerException != null) { + throw e.InnerException; + } else { + throw; + } + } + }; + } + } + + /// + /// Factory method to construct a converter for an attributed type. + /// + internal static IFirestoreInternalConverter ForType(BclType targetType) { + var attribute = Attribute.GetCustomAttribute(targetType, typeof(FirestoreDataAttribute), inherit: false) as FirestoreDataAttribute; + // This would be an internal library bug. We shouldn't be calling it in this case. + Preconditions.CheckState(attribute != null, "Type {0} is not decorated with {1}.", targetType.FullName, nameof(FirestoreDataAttribute)); + + return attribute.ConverterType == null + ? new AttributedTypeConverter(targetType, attribute) + : CustomConverter.ForConverterType(attribute.ConverterType, targetType); + } + + public // TODO(b/141568173): Significant newline. + override object DeserializeMap(DeserializationContext context, FieldValueProxy mapValue) { + Preconditions.CheckState(mapValue.type() == FieldValueProxy.Type.Map, "Expected to receive a map FieldValue"); + + object ret = _createInstance(); + using (var map = FirestoreCpp.ConvertFieldValueToMap(mapValue)) { + var iter = map.Iterator(); + + while (iter.HasMore()) { + var key = iter.UnsafeKeyView(); + FieldValueProxy value = iter.UnsafeValueView(); + iter.Advance(); + + if (_writableProperties.TryGetValue(key, out var property)) { + property.SetValue(context, value, ret); + + } else { + switch (_attribute.UnknownPropertyHandling) { + case UnknownPropertyHandling.Ignore: + break; + case UnknownPropertyHandling.Warn: + Firebase.LogUtil.LogMessage(LogLevel.Warning, String.Format( + "No writable property for Firestore field {0} in type {1}", key, TargetType.FullName)); + break; + case UnknownPropertyHandling.Throw: + throw new ArgumentException(String.Format("No writable property for Firestore field {key} in type {0}", TargetType.FullName)); + } + } + } + } + + AttributedIdAssigner.MaybeAssignId(ret, context.DocumentReference); + // NOTE: We don't support ReadTime, UpdateTime, etc. so we don't have the + // AttributedTimestampAssigner that google-cloud-dotnet does. + return ret; + } + + public override void SerializeMap(SerializationContext context, object value, IDictionary map) { + foreach (var property in _readableProperties) { + map[property.FirestoreName] = property.GetSerializedValue(context, value); + } + } + + private sealed class AttributedProperty { + private readonly PropertyInfo _propertyInfo; + private FieldValueProxy _sentinelValue; + private readonly IFirestoreInternalConverter _converter; + + /// + /// The name to use in Firestore serialization/deserialization. Defaults to the property + /// name, but may be specified in . + /// + internal readonly string FirestoreName; + internal bool CanRead => _propertyInfo.CanRead; + internal bool CanWrite => _propertyInfo.CanWrite; + + internal bool IsNullableValue => _propertyInfo.PropertyType.IsGenericType && + _propertyInfo.PropertyType.GetGenericTypeDefinition() == typeof(Nullable<>); + + internal AttributedProperty(PropertyInfo property, FirestorePropertyAttribute attribute) { + _propertyInfo = property; + FirestoreName = attribute.Name ?? property.Name; + if (property.IsDefined(typeof(ServerTimestampAttribute), inherit: true)) { + _sentinelValue = FieldValueProxy.ServerTimestamp(); + } + if (attribute.ConverterType != null) { + _converter = CustomConverter.ForConverterType(attribute.ConverterType, property.PropertyType); + } + + string typeName = property.DeclaringType.FullName; + Preconditions.CheckState(property.GetIndexParameters().Length == 0, + "{0}.{1} is an indexer, and should not be decorated with {2}.", + typeName, property.Name, nameof(FirestorePropertyAttribute)); + + // Annoyingly, we can't easily check whether the property is static - we have to check the individual methods. + var getMethod = property.GetGetMethod(nonPublic: true); + var setMethod = property.GetSetMethod(nonPublic: true); + Preconditions.CheckState(getMethod == null || !getMethod.IsStatic, + "{0}.{1} is static, and should not be decorated with {2}.", + typeName, property.Name, nameof(FirestorePropertyAttribute)); + Preconditions.CheckState(setMethod == null || !setMethod.IsStatic, + "{0}.{1} is static, and should not be decorated with {2}.", + typeName, property.Name, nameof(FirestorePropertyAttribute)); + + // NOTE: We don't support ValueTupleConverter even though google-cloud-dotnet + // does since it depends on .Net 4.7. + } + + // TODO: Consider creating delegates for the property get/set methods. + // Note: these methods have to handle null values when there's a custom converter involved, just like ValueSerializer/ValueDeserializer do. + internal FieldValueProxy GetSerializedValue(SerializationContext context, object obj) { + if (_sentinelValue != null) { + return _sentinelValue; + } + object propertyValue = _propertyInfo.GetValue(obj, index: null); + return _converter == null ? ValueSerializer.Serialize(context, propertyValue) + : propertyValue == null ? FieldValueProxy.Null() + : _converter.Serialize(context, propertyValue); + } + + internal void SetValue(DeserializationContext context, FieldValueProxy value, object target) { + object converted = + _converter == null ? ValueDeserializer.Deserialize(context, value, _propertyInfo.PropertyType) + : value.is_null() ? null + : _converter.DeserializeValue(context, value); + _propertyInfo.SetValue(target, converted, index: null); + } + } + } +} diff --git a/firestore/src/Converters/ConverterBase.cs b/firestore/src/Converters/ConverterBase.cs new file mode 100644 index 000000000..7dca63135 --- /dev/null +++ b/firestore/src/Converters/ConverterBase.cs @@ -0,0 +1,153 @@ +// Copyright 2018, Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using BclType = System.Type; + +namespace Firebase.Firestore.Converters { + /// + /// A base class for many converters, allowing them to simply override the method for the one + /// deserialization case required. Serializing to a single value has to be implemented; serializing + /// to a map will fail with an exception unless + /// is overridden. + /// + internal abstract class ConverterBase : IFirestoreInternalConverter { + protected readonly BclType TargetType; + + protected ConverterBase(BclType targetType) { + TargetType = targetType; + } + + public // TODO(b/141568173): Significant newline. + virtual object DeserializeMap(DeserializationContext context, FieldValueProxy mapValue) { + throw new ArgumentException(String.Format("Unable to convert map value to {0}", TargetType)); + } + + public // TODO(b/141568173): Significant newline. + virtual object DeserializeValue(DeserializationContext context, FieldValueProxy value) { + switch (value.type()) { + case FieldValueProxy.Type.Array: + return DeserializeArray(context, value); + case FieldValueProxy.Type.Boolean: + return DeserializeBoolean(context, value.boolean_value()); + case FieldValueProxy.Type.Blob: + return DeserializeBytes(context, ConvertFromProxyBlob(value)); + case FieldValueProxy.Type.Double: + return DeserializeDouble(context, value.double_value()); + case FieldValueProxy.Type.GeoPoint: + return DeserializeGeoPoint(context, GeoPoint.ConvertFromProxy(value.geo_point_value())); + case FieldValueProxy.Type.Integer: + return DeserializeInteger(context, value.integer_value()); + case FieldValueProxy.Type.Map: + return DeserializeMap(context, value); + case FieldValueProxy.Type.Reference: + return DeserializeReference(context, new DocumentReference(value.reference_value(), context.Firestore)); + case FieldValueProxy.Type.String: + return DeserializeString(context, value.string_value()); + case FieldValueProxy.Type.Timestamp: + return DeserializeTimestamp(context, Timestamp.ConvertFromProxy(value.timestamp_value())); + default: + throw new ArgumentException(String.Format("Unable to convert value type {0}", value.type())); + } + } + + public // TODO(b/141568173): Significant newline. + abstract FieldValueProxy Serialize(SerializationContext context, object value); + + public virtual void SerializeMap(SerializationContext context, object value, IDictionary map) { + throw new ArgumentException(String.Format("Unable to convert {0} to a map", TargetType)); + } + + protected virtual object DeserializeArray(DeserializationContext context, FieldValueProxy arrayValue) { + throw new ArgumentException(String.Format("Unable to convert array value to {0}", TargetType)); + } + + protected virtual object DeserializeBoolean(DeserializationContext context, bool value) { + throw new ArgumentException(String.Format("Unable to convert Boolean value to {0}", TargetType)); + } + + protected virtual object DeserializeBytes(DeserializationContext context, byte[] value) { + throw new ArgumentException(String.Format("Unable to convert bytes value to {0}", TargetType)); + } + + protected virtual object DeserializeDouble(DeserializationContext context, double value) { + throw new ArgumentException(String.Format("Unable to convert double value to {0}", TargetType)); + } + + protected virtual object DeserializeGeoPoint(DeserializationContext context, GeoPoint value) { + throw new ArgumentException(String.Format("Unable to convert GeoPoint value to {0}", TargetType)); + } + + protected virtual object DeserializeInteger(DeserializationContext context, long value) { + throw new ArgumentException(String.Format("Unable to convert integer value to {0}", TargetType)); + } + + protected virtual object DeserializeReference(DeserializationContext context, DocumentReference value) { + throw new ArgumentException(String.Format("Unable to convert DocumentReference value to {0}", TargetType)); + } + + protected virtual object DeserializeString(DeserializationContext context, string value) { + throw new ArgumentException(String.Format("Unable to convert string value to {0}", TargetType)); + } + + protected virtual object DeserializeTimestamp(DeserializationContext context, Timestamp value) { + throw new ArgumentException(String.Format("Unable to convert Timestamp value to {0}", TargetType)); + } + + // Some helpers for marshalling C# types to/from FieldValueProxy + // (since the SWIG-generated methods aren't very friendly). + + internal static FieldValueProxy ConvertToProxyMap(IDictionary map) { + var internalMap = new FieldToValueMap(); + foreach (var key_value in map) { + internalMap.Insert(key_value.Key, key_value.Value); + } + return FirestoreCpp.ConvertMapToFieldValue(internalMap); + } + + internal static FieldValueProxy ConvertToProxyArray(IList list) { + var internalArray = new FieldValueVector(); + for (int i = 0; i < list.Count; ++i) { + internalArray.PushBack(list[i]); + } + return FirestoreCpp.ConvertVectorToFieldValue(internalArray); + } + + internal static byte[] ConvertFromProxyBlob(FieldValueProxy internalValue) { + IntPtr ptr = SWIGTYPE_p_unsigned_char.getCPtr(internalValue.blob_value()).Handle; + uint size = internalValue.blob_size(); + byte[] bytes = new byte[size]; + Marshal.Copy(ptr, bytes, 0, (int)size); + return bytes; + } + + internal static FieldValueProxy ConvertToProxyBlob(byte[] value) { + int size = Marshal.SizeOf((byte)0) * (int)value.Length; + IntPtr ptr = (IntPtr)Marshal.AllocHGlobal(size); + try { + Marshal.Copy(value, 0, ptr, size); + FieldValueProxy result = FieldValueProxy.Blob( + new SWIGTYPE_p_unsigned_char(ptr, /*futureUse=*/true), + (uint)size); + return result; + } finally { + // We have no way to reset the one in SWIGTYPE_p_unsigned_char. But as far as we do + // not use it, it is safe to keep the ptr there. + Marshal.FreeHGlobal(ptr); + } + } + } +} diff --git a/firestore/src/Converters/ConverterCache.cs b/firestore/src/Converters/ConverterCache.cs new file mode 100644 index 000000000..164e9aa64 --- /dev/null +++ b/firestore/src/Converters/ConverterCache.cs @@ -0,0 +1,169 @@ +// Copyright 2018, Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Runtime.CompilerServices; +using BclType = System.Type; + +namespace Firebase.Firestore.Converters { + /// + /// A cache for serializers based on the target type. Some are prepopulated (e.g. for + /// primitives); one for anonymous and attributed types are added on demand. + /// + internal static class ConverterCache { + private static readonly Dictionary s_converters = + new Dictionary { + [typeof(byte)] = new ByteConverter(), + [typeof(sbyte)] = new SByteConverter(), + [typeof(short)] = new Int16Converter(), + [typeof(ushort)] = new UInt16Converter(), + [typeof(int)] = new Int32Converter(), + [typeof(uint)] = new UInt32Converter(), + [typeof(long)] = new Int64Converter(), + [typeof(ulong)] = new UInt64Converter(), + [typeof(string)] = new StringConverter(), + [typeof(float)] = new SingleConverter(), + [typeof(double)] = new DoubleConverter(), + [typeof(bool)] = new BooleanConverter(), + [typeof(Timestamp)] = new TimestampConverter(), + [typeof(GeoPoint)] = new GeoPointConverter(), + [typeof(Blob)] = new BlobConverter(), + [typeof(byte[])] = new ByteArrayConverter(), + [typeof(FieldValueProxy)] = new FieldValueProxyConverter(), + [typeof(DateTime)] = new DateTimeConverter(), + [typeof(DateTimeOffset)] = new DateTimeOffsetConverter(), + // DictionaryConverter parameterized with primitive value types are created by default, because they do not + // work otherwise on iOS, as they are compiled AOT, and compiler does not generate code for these types. + [typeof(Dictionary)] = new DictionaryConverter(typeof(Dictionary)), + [typeof(Dictionary)] = new DictionaryConverter(typeof(Dictionary)), + [typeof(Dictionary)] = new DictionaryConverter(typeof(Dictionary)), + [typeof(Dictionary)] = new DictionaryConverter(typeof(Dictionary)), + [typeof(Dictionary)] = new DictionaryConverter(typeof(Dictionary)), + [typeof(Dictionary)] = new DictionaryConverter(typeof(Dictionary)), + [typeof(Dictionary)] = new DictionaryConverter(typeof(Dictionary)), + [typeof(Dictionary)] = new DictionaryConverter(typeof(Dictionary)), + [typeof(Dictionary)] = new DictionaryConverter(typeof(Dictionary)), + [typeof(Dictionary)] = new DictionaryConverter(typeof(Dictionary)), + [typeof(Dictionary)] = new DictionaryConverter(typeof(Dictionary)), + [typeof(Dictionary)] = new DictionaryConverter(typeof(Dictionary)), + [typeof(IDictionary)] = new DictionaryConverter(typeof(Dictionary)), + [typeof(IDictionary)] = new DictionaryConverter(typeof(Dictionary)), + [typeof(IDictionary)] = new DictionaryConverter(typeof(Dictionary)), + [typeof(IDictionary)] = new DictionaryConverter(typeof(Dictionary)), + [typeof(IDictionary)] = new DictionaryConverter(typeof(Dictionary)), + [typeof(IDictionary)] = new DictionaryConverter(typeof(Dictionary)), + [typeof(IDictionary)] = new DictionaryConverter(typeof(Dictionary)), + [typeof(IDictionary)] = new DictionaryConverter(typeof(Dictionary)), + [typeof(IDictionary)] = new DictionaryConverter(typeof(Dictionary)), + [typeof(IDictionary)] = new DictionaryConverter(typeof(Dictionary)), + [typeof(IDictionary)] = new DictionaryConverter(typeof(Dictionary)), + [typeof(IDictionary)] = new DictionaryConverter(typeof(Dictionary)), + [typeof(DocumentReference)] = new DocumentReferenceConverter() + }; + + internal static IFirestoreInternalConverter GetConverter(BclType targetType) { + lock (s_converters) { + IFirestoreInternalConverter converter; + if (!s_converters.TryGetValue(targetType, out converter)) { + converter = CreateConverter(targetType); + s_converters[targetType] = converter; + } + return converter; + } + } + + /// + /// This method must be called at least once to ensure that CreateDictionaryConverter is + /// statically referenced to ensure that AOT targets generate code for it; otherwise, + /// s_createDictionaryConverter will be null on those platforms (b/159051783). Since this + /// method performs a small amount of work, it should be invoked as infrequently as possible, + /// such as each time that a Firestore instance is created. + /// See https://docs.unity3d.com/Manual/ScriptingRestrictions.html for details. + /// + internal static void InitializeConverterCache() { + // Using "bool" here is arbitrary; it does not matter which type is used as long as the + // method is invoked at least once to preserve it for AOT compilation. + CreateDictionaryConverter(typeof(bool)); + } + + private static readonly MethodInfo s_createDictionaryConverter = typeof(ConverterCache).GetMethod(nameof(CreateDictionaryConverter), BindingFlags.Static | BindingFlags.NonPublic); + + private static IFirestoreInternalConverter CreateDictionaryConverter(BclType targetType) => new DictionaryConverter(targetType); + + private static IFirestoreInternalConverter CreateConverter(BclType targetType) { + if (targetType.IsArray) { + return new ArrayConverter(targetType.GetElementType()); + } + if (targetType.IsDefined(typeof(FirestoreDataAttribute), inherit: true)) { + return AttributedTypeConverter.ForType(targetType); + } + // Simple way of checking for an anonymous type. Far from foolproof, but a reasonable start. + if (targetType.IsDefined(typeof(CompilerGeneratedAttribute), inherit: true)) { + return new AnonymousTypeConverter(targetType); + } + + if (targetType.IsEnum) { + return new EnumConverter(targetType); + } + if (TryGetStringDictionaryValueType(targetType, out var dictionaryElementType)) { + var method = s_createDictionaryConverter.MakeGenericMethod(dictionaryElementType); + try { + return (IFirestoreInternalConverter)method.Invoke(null, new object[] { targetType }); + } catch (TargetInvocationException e) { + if (e.InnerException != null) { + throw e.InnerException; + } else { + throw; + } + } + } + + if (typeof(IEnumerable).IsAssignableFrom(targetType)) { + return new EnumerableConverter(targetType); + } + + throw new ArgumentException(String.Format("Unable to create converter for type {0}", targetType.FullName)); + } + + // Internal for testing + + /// + /// If implements (or is) with TKey equal to string, returns true and sets + /// to TValue. Otherwise, returns false and sets to null. + /// + internal static bool TryGetStringDictionaryValueType(BclType type, out BclType elementType) { + elementType = type + .GetInterfaces() + .Concat(new[] { type }) // Make this method handle IDictionary<,> as an input; GetInterfaces doesn't return the type you call it on + .Select(MapInterfaceToDictionaryValueTypeArgument).FirstOrDefault(t => t != null); + return elementType != null; + } + + private static BclType MapInterfaceToDictionaryValueTypeArgument(BclType iface) { + if (!iface.IsGenericType || iface.IsGenericTypeDefinition) { + return null; + } + var generic = iface.GetGenericTypeDefinition(); + if (generic != typeof(IDictionary<,>)) { + return null; + } + var typeArguments = iface.GetGenericArguments(); + return typeArguments[0] == typeof(string) ? typeArguments[1] : null; + } + } +} diff --git a/firestore/src/Converters/CustomConverter.cs b/firestore/src/Converters/CustomConverter.cs new file mode 100644 index 000000000..2ac0dc655 --- /dev/null +++ b/firestore/src/Converters/CustomConverter.cs @@ -0,0 +1,92 @@ +// Copyright 2018, Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Firebase.Firestore.Internal; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using BclType = System.Type; + +namespace Firebase.Firestore.Converters { + internal static class CustomConverter { + private static readonly MethodInfo _method = typeof(CustomConverter).GetMethod(nameof(CreateInstance), BindingFlags.Static | BindingFlags.NonPublic); + + // TODO: More validation, e.g. converter must be a concrete type, and the target type should not declare any + // properties with FirestorePropertyAttribute (although its base type might). + // TODO: Check that targetType isn't a nullable value type? We currently advise that, but we could enforce it. + + // TODO: Caching? We only do this once per property or type that's decorated with an attribute + // with a Converter property. Caching adds significant complexity. + internal static IFirestoreInternalConverter ForConverterType(BclType converterType, BclType targetType) { + var nonNullableType = Nullable.GetUnderlyingType(targetType) ?? targetType; + var expectedSuperClass = typeof(FirestoreConverter<>).MakeGenericType(nonNullableType); + if (!converterType.IsSubclassOf(expectedSuperClass)) { + throw new InvalidOperationException(String.Format("Type {0} does not inherit a custom converter for {1}", + converterType, nonNullableType)); + } + // TODO: Allow private constructors? (We probably want a helper method to do this, given that we do it in a bunch of places.) + var instance = Activator.CreateInstance(converterType); + return (IFirestoreInternalConverter)_method.MakeGenericMethod(nonNullableType).Invoke(null, new[] { instance }); + } + + // Method to make the reflection simpler. + internal static IFirestoreInternalConverter CreateInstance(FirestoreConverter wrappedConverter) => + new CustomConverter(wrappedConverter); + } + + /// + /// A converter that wraps a user-specified . + /// + internal sealed class CustomConverter : IFirestoreInternalConverter { + private readonly FirestoreConverter _wrappedConverter; + + internal CustomConverter(FirestoreConverter wrappedConverter) { + _wrappedConverter = wrappedConverter; + } + + public // TODO(b/141568173): Significant newline. + object DeserializeMap(DeserializationContext context, FieldValueProxy mapValue) { + var poco = ValueDeserializer.DeserializeMap(context, mapValue, typeof(Dictionary)); + var converted = _wrappedConverter.FromFirestore(poco); + Preconditions.CheckState(converted != null, "Converter deserialized to null value"); + return converted; + } + + public // TODO(b/141568173): Significant newline. + object DeserializeValue(DeserializationContext context, FieldValueProxy value) { + var poco = ValueDeserializer.Deserialize(context, value, typeof(object)); + var converted = _wrappedConverter.FromFirestore(poco); + Preconditions.CheckState(converted != null, "Converter deserialized to null value"); + return converted; + } + + public // TODO(b/141568173): Significant newline. + FieldValueProxy Serialize(SerializationContext context, object value) { + var poco = _wrappedConverter.ToFirestore((T)value); + Preconditions.CheckState(poco != null, "Converter serialized to null value"); + return ValueSerializer.Serialize(context, poco); + } + + public void SerializeMap(SerializationContext context, object value, IDictionary map) { + var poco = _wrappedConverter.ToFirestore((T)value); + Preconditions.CheckState(poco != null, "Converter serialized to null value"); + // TODO: Change ValueSerializer.SerializeMap to accept a map rather than return it? Then we can just pass it through. + var resultMap = ValueSerializer.SerializeMap(context, poco); + foreach (var entry in resultMap) { + map.Add(entry); + } + } + } +} diff --git a/firestore/src/Converters/DictionaryConverter.cs b/firestore/src/Converters/DictionaryConverter.cs new file mode 100644 index 000000000..97ff788bc --- /dev/null +++ b/firestore/src/Converters/DictionaryConverter.cs @@ -0,0 +1,68 @@ +// Copyright 2018, Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Firebase.Firestore.Internal; +using System; +using System.Collections.Generic; +using System.Reflection; +using BclType = System.Type; + +namespace Firebase.Firestore.Converters { + /// + /// Base class for dictionary-based map values. + /// + /// Type of values in the dictionary. + internal sealed class DictionaryConverter : MapConverterBase { + private readonly BclType _concreteType; + + internal DictionaryConverter(BclType targetType) : base(targetType) { + _concreteType = targetType; + // If we've been asked to deserialize to an interface, let's just see if Dictionary<,> + // would work, but otherwise give up. + if (targetType.IsInterface) { + var candidateType = typeof(Dictionary); + if (targetType.IsAssignableFrom(candidateType)) { + _concreteType = candidateType; + } else { + throw new ArgumentException(String.Format("Unable to deserialize map to {0}", targetType)); + } + } + } + + public // TODO(b/141568173): Significant newline. + override object DeserializeMap(DeserializationContext context, FieldValueProxy mapValue) { + Preconditions.CheckState(mapValue.type() == FieldValueProxy.Type.Map, "Expected to receive a map FieldValue"); + + // TODO: Compile an expression tree on construction, or at least accept an optional delegate for construction + // (allowing for special-casing of Dictionary). + var ret = (IDictionary)Activator.CreateInstance(_concreteType); + using (var map = FirestoreCpp.ConvertFieldValueToMap(mapValue)) { + var iter = map.Iterator(); + while (iter.HasMore()) { + ret.Add(iter.UnsafeKeyView(), (TValue)ValueDeserializer.Deserialize(context, iter.UnsafeValueView(), typeof(TValue))); + iter.Advance(); + } + } + + return ret; + } + + public override void SerializeMap(SerializationContext context, object value, IDictionary map) { + var dictionary = (IDictionary)value; + foreach (var pair in dictionary) { + map[pair.Key] = ValueSerializer.Serialize(context, pair.Value); + } + } + } +} diff --git a/firestore/src/Converters/EnumConverter.cs b/firestore/src/Converters/EnumConverter.cs new file mode 100644 index 000000000..102e956d5 --- /dev/null +++ b/firestore/src/Converters/EnumConverter.cs @@ -0,0 +1,72 @@ +// Copyright 2018, Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; +using System.Collections.Generic; +using System.Reflection; +using BclType = System.Type; + +namespace Firebase.Firestore.Converters { + /// + /// A converter for a specific enum type. + /// + internal sealed class EnumConverter : ConverterBase { + private readonly TypeCode _typeCode; + + internal EnumConverter(BclType targetType) : base(targetType) { + _typeCode = BclType.GetTypeCode(TargetType); + } + + protected override object DeserializeInteger(DeserializationContext context, long value) { + object baseValue = Int64ToEnumBaseType(value); + return Enum.ToObject(TargetType, baseValue); + } + + public // TODO(b/141568173): Significant newline. + override FieldValueProxy Serialize(SerializationContext context, object value) => + FieldValueProxy.Integer(EnumToInt64(value)); + + private long EnumToInt64(object value) { + switch (_typeCode) { + case TypeCode.Byte: return checked((byte)value); + case TypeCode.SByte: return checked((sbyte)value); + case TypeCode.Int16: return checked((short)value); + case TypeCode.UInt16: return checked((ushort)value); + case TypeCode.Int32: return checked((int)value); + case TypeCode.UInt32: return checked((uint)value); + case TypeCode.Int64: return checked((long)value); + case TypeCode.UInt64: return checked((long)(ulong)value); + default: + throw new InvalidOperationException( + String.Format("Unexpected underlying type code for enum: {0}", _typeCode)); + } + } + + private object Int64ToEnumBaseType(long value) { + switch (_typeCode) { + case TypeCode.Byte: return checked((byte)value); + case TypeCode.SByte: return checked((sbyte)value); + case TypeCode.Int16: return checked((short)value); + case TypeCode.UInt16: return checked((ushort)value); + case TypeCode.Int32: return checked((int)value); + case TypeCode.UInt32: return checked((uint)value); + case TypeCode.Int64: return value; + case TypeCode.UInt64: return checked((ulong)value); + default: + throw new InvalidOperationException( + String.Format("Unexpected underlying type code for enum: {0}", _typeCode)); + } + } + } +} diff --git a/firestore/src/Converters/EnumerableConverter.cs b/firestore/src/Converters/EnumerableConverter.cs new file mode 100644 index 000000000..4c77068ef --- /dev/null +++ b/firestore/src/Converters/EnumerableConverter.cs @@ -0,0 +1,87 @@ +// Copyright 2018, Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Firebase.Firestore.Internal; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; + +using BclType = System.Type; + +namespace Firebase.Firestore.Converters { + + /// + /// Converter for -based types. (Note that this doesn't handle types that + /// implement the generic interface without the non-generic one.) + /// This type handles deserialization; the base type handles serialization. + /// + internal sealed class EnumerableConverter : EnumerableConverterBase { + private readonly BclType _elementType; + + internal EnumerableConverter(BclType targetType) : base(targetType) { + _elementType = typeof(object); + + // (We could also make this type generic, like DictionaryConverter. There's a difference + // in that we don't need a generic interface in the conversion code here.) + var interfaces = targetType.GetInterfaces(); + Type genericEnumerable = null; + if (targetType.IsInterface && targetType.IsGenericType && + targetType.GetGenericTypeDefinition() == typeof(IEnumerable<>)) { + genericEnumerable = targetType; + } else { + genericEnumerable = interfaces.FirstOrDefault(iface => iface.IsGenericType && + iface.GetGenericTypeDefinition() == + typeof(IEnumerable<>)); + } + if (genericEnumerable != null) { + _elementType = genericEnumerable.GetGenericArguments()[0]; + } + } + + protected override object DeserializeArray(DeserializationContext context, + FieldValueProxy arrayValue) { + Preconditions.CheckState(arrayValue.type() == FieldValueProxy.Type.Array, + "Expected to receive an array FieldValue"); + + // Internal type to hold deserialized values. + var listType = typeof(List<>).MakeGenericType(_elementType); + if (!TargetType.IsAssignableFrom(listType)) { + throw new NotSupportedException( + String.Format("Deserializing to {0} is not supported. Please change to a List " + + "or use a custom converter to convert to it.", + TargetType.FullName)); + } + + using (var array = FirestoreCpp.ConvertFieldValueToVector(arrayValue)) { + uint usize = array.Size(); + if (usize > System.Int32.MaxValue) { + throw new ArgumentException( + "List contains too many values. (More than System.Int32.MaxValue)"); + } + + // TODO: See if using a compiled expression tree is faster. + var ret = (IList)Activator.CreateInstance(listType); + for (int i = 0; i < usize; i++) { + FieldValueProxy value = array.GetUnsafeView((uint)i); + var deserialized = ValueDeserializer.Deserialize(context, value, _elementType); + ret.Add(deserialized); + } + + return ret; + } + } + } +} diff --git a/firestore/src/Converters/EnumerableConverterBase.cs b/firestore/src/Converters/EnumerableConverterBase.cs new file mode 100644 index 000000000..177c769f1 --- /dev/null +++ b/firestore/src/Converters/EnumerableConverterBase.cs @@ -0,0 +1,39 @@ +// Copyright 2018, Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; +using System.Collections; +using System.Collections.Generic; +using BclType = System.Type; + +namespace Firebase.Firestore.Converters { + /// + /// Base class for types that always serialize to a list value. This type handles serialization + /// by assuming the type implements and simply serializing each element; + /// derived types need to perform deserialization. + /// + internal abstract class EnumerableConverterBase : ConverterBase { + internal EnumerableConverterBase(BclType targetType) : base(targetType) {} + + public // TODO(b/141568173): Significant newline. + override FieldValueProxy Serialize(SerializationContext context, object value) { + var list = new List(); + foreach (object element in (IEnumerable)value) { + var serializedElement = ValueSerializer.Serialize(context, element); + list.Add(serializedElement); + } + return ConvertToProxyArray(list); + } + } +} diff --git a/firestore/src/Converters/IFirestoreInternalConverter.cs b/firestore/src/Converters/IFirestoreInternalConverter.cs new file mode 100644 index 000000000..d049fcbf1 --- /dev/null +++ b/firestore/src/Converters/IFirestoreInternalConverter.cs @@ -0,0 +1,57 @@ +// Copyright 2018, Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System.Collections.Generic; + +namespace Firebase.Firestore.Converters { + /// + /// Internal interface all converters support. + /// + internal interface IFirestoreInternalConverter { + /// + /// Deserializes a single (possibly map- or list-based) Firestore value to a POCO. + /// + /// The context for the deserialization operation. Never null. + /// The Firestore value to deserialize. Never null. + /// The deserialized value. Should never be null. + object DeserializeValue(DeserializationContext context, FieldValueProxy value); + + /// + /// Deserializes a map (as a dictionary of name/value pairs) to a POCO. + /// + /// The context for the deserialization operation. Never null. + /// The name/value pairs to deserialize. Never null. + /// The deserialized value. Should never be null. + object DeserializeMap(DeserializationContext context, FieldValueProxy mapValue); + + /// + /// Serializes a single POCO to a Firestore representation. + /// + /// + /// The value to serialize. Never null. + /// The serialized value. Should never be null. + FieldValueProxy Serialize(SerializationContext context, object value); + + /// + /// Populates a map based on the serialized form of a POCO. + /// + /// + /// Logically this could return a dictionary instead, but it's more efficient to populate an existing map. + /// + /// + /// The value to serialize. Never null. + /// The map to populate. Never null. + void SerializeMap(SerializationContext context, object value, IDictionary map); + } +} diff --git a/firestore/src/Converters/MapConverterBase.cs b/firestore/src/Converters/MapConverterBase.cs new file mode 100644 index 000000000..8e79e2744 --- /dev/null +++ b/firestore/src/Converters/MapConverterBase.cs @@ -0,0 +1,36 @@ +// Copyright 2018, Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System.Collections.Generic; +using BclType = System.Type; + +namespace Firebase.Firestore.Converters { + /// + /// Base class for types that always serialize to a map value. + /// Derived classes need to implement deserialization as well as overriding + /// , + /// which is called by this class's implementation of . + /// + internal abstract class MapConverterBase : ConverterBase { + internal MapConverterBase(BclType targetType) : base(targetType) { + } + + public // TODO(b/141568173): Significant newline. + override FieldValueProxy Serialize(SerializationContext context, object value) { + var map = new Dictionary(); + SerializeMap(context, value, map); + return ConvertToProxyMap(map); + } + } +} diff --git a/firestore/src/Converters/SimpleConverters.cs b/firestore/src/Converters/SimpleConverters.cs new file mode 100644 index 000000000..660ce0b7c --- /dev/null +++ b/firestore/src/Converters/SimpleConverters.cs @@ -0,0 +1,186 @@ +// Copyright 2018, Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; + +namespace Firebase.Firestore.Converters { + // All the simple converters in a single place for simplicity. + + internal sealed class StringConverter : ConverterBase { + internal StringConverter() : base(typeof(string)) { } + public // TODO(b/141568173): Significant newline. + override FieldValueProxy Serialize(SerializationContext context, object value) => FieldValueProxy.String((string)value); + protected override object DeserializeString(DeserializationContext context, string value) => value; + } + + internal abstract class IntegerConverterBase : ConverterBase { + internal IntegerConverterBase(System.Type type) : base(type) { + } + + // All integer types allow conversion from double as well. + protected override object DeserializeDouble(DeserializationContext context, double value) => + DeserializeInteger(context, checked((long)value)); + } + + internal sealed class ByteConverter : IntegerConverterBase { + internal ByteConverter() : base(typeof(byte)) { } + public // TODO(b/141568173): Significant newline. + override FieldValueProxy Serialize(SerializationContext context, object value) => FieldValueProxy.Integer((byte)value); + protected override object DeserializeInteger(DeserializationContext context, long value) => checked((byte)value); + } + + internal sealed class SByteConverter : IntegerConverterBase { + internal SByteConverter() : base(typeof(sbyte)) { } + public // TODO(b/141568173): Significant newline. + override FieldValueProxy Serialize(SerializationContext context, object value) => FieldValueProxy.Integer((sbyte)value); + protected override object DeserializeInteger(DeserializationContext context, long value) => checked((sbyte)value); + } + + internal sealed class Int16Converter : IntegerConverterBase { + internal Int16Converter() : base(typeof(short)) { } + public // TODO(b/141568173): Significant newline. + override FieldValueProxy Serialize(SerializationContext context, object value) => FieldValueProxy.Integer((short)value); + protected override object DeserializeInteger(DeserializationContext context, long value) => checked((short)value); + } + + internal sealed class UInt16Converter : IntegerConverterBase { + internal UInt16Converter() : base(typeof(ushort)) { } + public // TODO(b/141568173): Significant newline. + override FieldValueProxy Serialize(SerializationContext context, object value) => FieldValueProxy.Integer((ushort)value); + protected override object DeserializeInteger(DeserializationContext context, long value) => checked((ushort)value); + } + + internal sealed class Int32Converter : IntegerConverterBase { + internal Int32Converter() : base(typeof(int)) { } + public // TODO(b/141568173): Significant newline. + override FieldValueProxy Serialize(SerializationContext context, object value) => FieldValueProxy.Integer((int)value); + protected override object DeserializeInteger(DeserializationContext context, long value) => checked((int)value); + } + + internal sealed class UInt32Converter : IntegerConverterBase { + internal UInt32Converter() : base(typeof(uint)) { } + public // TODO(b/141568173): Significant newline. + override FieldValueProxy Serialize(SerializationContext context, object value) => FieldValueProxy.Integer((uint)value); + protected override object DeserializeInteger(DeserializationContext context, long value) => checked((uint)value); + } + + internal sealed class Int64Converter : IntegerConverterBase { + internal Int64Converter() : base(typeof(long)) { } + public // TODO(b/141568173): Significant newline. + override FieldValueProxy Serialize(SerializationContext context, object value) => FieldValueProxy.Integer((long)value); + protected override object DeserializeInteger(DeserializationContext context, long value) => value; + } + + internal sealed class UInt64Converter : IntegerConverterBase { + internal UInt64Converter() : base(typeof(ulong)) { } + public // TODO(b/141568173): Significant newline. + override FieldValueProxy Serialize(SerializationContext context, object value) => FieldValueProxy.Integer((long)(ulong)value); + protected override object DeserializeInteger(DeserializationContext context, long value) => checked((ulong)value); + } + + internal sealed class SingleConverter : ConverterBase { + internal SingleConverter() : base(typeof(float)) { } + public // TODO(b/141568173): Significant newline. + override FieldValueProxy Serialize(SerializationContext context, object value) => FieldValueProxy.Double((float)value); + protected override object DeserializeDouble(DeserializationContext context, double value) => (float)value; + // We allow serialization from integer values as some interactions with Firestore end up storing + // an integer value even when a double value is expected, if the value happens to be an integer. + // See https://github.com/googleapis/google-cloud-dotnet/issues/3013 + protected override object DeserializeInteger(DeserializationContext context, long value) => (float)value; + } + + internal sealed class DoubleConverter : ConverterBase { + internal DoubleConverter() : base(typeof(double)) { } + public // TODO(b/141568173): Significant newline. + override FieldValueProxy Serialize(SerializationContext context, object value) => FieldValueProxy.Double((double)value); + protected override object DeserializeDouble(DeserializationContext context, double value) => value; + // We allow serialization from integer values as some interactions with Firestore end up storing + // an integer value even when a double value is expected, if the value happens to be an integer. + // See https://github.com/googleapis/google-cloud-dotnet/issues/3013 + protected override object DeserializeInteger(DeserializationContext context, long value) => (double)value; + } + + internal sealed class BooleanConverter : ConverterBase { + internal BooleanConverter() : base(typeof(bool)) { } + public // TODO(b/141568173): Significant newline. + override FieldValueProxy Serialize(SerializationContext context, object value) => FieldValueProxy.Boolean((bool)value); + protected override object DeserializeBoolean(DeserializationContext context, bool value) => value; + } + + internal sealed class TimestampConverter : ConverterBase { + internal TimestampConverter() : base(typeof(Timestamp)) { } + public // TODO(b/141568173): Significant newline. + override FieldValueProxy Serialize(SerializationContext context, object value) => + FieldValueProxy.Timestamp(((Timestamp)value).ConvertToProxy()); + protected override object DeserializeTimestamp(DeserializationContext context, Timestamp value) => value; + } + + internal sealed class GeoPointConverter : ConverterBase { + internal GeoPointConverter() : base(typeof(GeoPoint)) { } + public // TODO(b/141568173): Significant newline. + override FieldValueProxy Serialize(SerializationContext context, object value) => + FieldValueProxy.GeoPoint(((GeoPoint)value).ConvertToProxy()); + protected override object DeserializeGeoPoint(DeserializationContext context, GeoPoint value) => value; + } + + internal sealed class ByteArrayConverter : ConverterBase { + internal ByteArrayConverter() : base(typeof(byte[])) { } + public // TODO(b/141568173): Significant newline. + override FieldValueProxy Serialize(SerializationContext context, object value) => + ConvertToProxyBlob((byte[])value); + protected override object DeserializeBytes(DeserializationContext context, byte[] value) => value; + } + + internal sealed class BlobConverter : ConverterBase { + internal BlobConverter() : base(typeof(Blob)) { } + public // TODO(b/141568173): Significant newline. + override FieldValueProxy Serialize(SerializationContext context, object value) => + ConvertToProxyBlob(((Blob)value).ToBytes()); + protected override object DeserializeBytes(DeserializationContext context, byte[] value) => Blob.CopyFrom(value); + } + + // Note that we need this FieldValueProxy "pass-thru" converter because we (currently) expose + // FieldValue sentinels as the raw FieldValueProxy value. (e.g. FieldValue.ServerTimestamp + // just returns FieldValueProxy.ServerTimestamp()) + internal sealed class FieldValueProxyConverter : ConverterBase { + internal FieldValueProxyConverter() : base(typeof(FieldValueProxy)) { } + public // TODO(b/141568173): Significant newline. + override FieldValueProxy Serialize(SerializationContext context, object value) => ((FieldValueProxy)value); + } + + internal sealed class DateTimeConverter : ConverterBase { + internal DateTimeConverter() : base(typeof(DateTime)) { } + public // TODO(b/141568173): Significant newline. + override FieldValueProxy Serialize(SerializationContext context, object value) => + FieldValueProxy.Timestamp(Timestamp.FromDateTime((DateTime)value).ConvertToProxy()); + protected override object DeserializeTimestamp(DeserializationContext context, Timestamp value) => value.ToDateTime(); + } + + internal sealed class DateTimeOffsetConverter : ConverterBase { + internal DateTimeOffsetConverter() : base(typeof(DateTimeOffset)) { } + public // TODO(b/141568173): Significant newline. + override FieldValueProxy Serialize(SerializationContext context, object value) => + FieldValueProxy.Timestamp(Timestamp.FromDateTimeOffset((DateTimeOffset)value).ConvertToProxy()); + protected override object DeserializeTimestamp(DeserializationContext context, Timestamp value) => value.ToDateTimeOffset(); + } + + internal sealed class DocumentReferenceConverter : ConverterBase { + internal DocumentReferenceConverter() : base(typeof(DocumentReference)) { } + public // TODO(b/141568173): Significant newline. + override FieldValueProxy Serialize(SerializationContext context, object value) => + FieldValueProxy.Reference(((DocumentReference)value).Proxy); + protected override object DeserializeReference(DeserializationContext context, DocumentReference value) => + value; + } +} diff --git a/firestore/src/DeserializationContext.cs b/firestore/src/DeserializationContext.cs new file mode 100644 index 000000000..304536f02 --- /dev/null +++ b/firestore/src/DeserializationContext.cs @@ -0,0 +1,50 @@ +// Copyright 2019, Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Firebase.Firestore.Converters; +using Firebase.Firestore.Internal; +using BclType = System.Type; + +namespace Firebase.Firestore { + /// + /// Provides context for deserialization operations. + /// + internal sealed class DeserializationContext { + /// + /// The database containing the document being deserialized. This is never null. + /// + internal FirebaseFirestore Firestore => DocumentReference.Firestore; + + /// + /// The document being deserialized. This is never null. + /// + internal DocumentReference DocumentReference => Snapshot.Reference; + + /// + /// The document snapshot being deserialized. This is never null. + /// + internal readonly DocumentSnapshot Snapshot; + + /// + /// Constructs a new context. + /// + /// The document snapshot being deserialized. Must not be null. + internal DeserializationContext(DocumentSnapshot snapshot) { + Snapshot = Preconditions.CheckNotNull(snapshot, nameof(snapshot)); + } + + internal IFirestoreInternalConverter GetConverter(BclType targetType) => + SerializationContext.Default.GetConverter(targetType); + } +} diff --git a/firestore/src/DocumentChange.cs b/firestore/src/DocumentChange.cs new file mode 100644 index 000000000..4750f74da --- /dev/null +++ b/firestore/src/DocumentChange.cs @@ -0,0 +1,109 @@ +// Copyright 2017, Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Firebase.Firestore.Internal; +using System; + +namespace Firebase.Firestore { + internal static class ChangeTypeConverter { + public static DocumentChangeProxy.Type ConvertToProxy(this DocumentChange.Type type) { + switch (type) { + case DocumentChange.Type.Added: + return DocumentChangeProxy.Type.Added; + case DocumentChange.Type.Modified: + return DocumentChangeProxy.Type.Modified; + case DocumentChange.Type.Removed: + return DocumentChangeProxy.Type.Removed; + } + throw new ArgumentException("Unsupported DocumentChange.Type:" + type); + } + + public static DocumentChange.Type ConvertFromProxy(this DocumentChangeProxy.Type type) { + switch (type) { + case DocumentChangeProxy.Type.Added: + return DocumentChange.Type.Added; + case DocumentChangeProxy.Type.Modified: + return DocumentChange.Type.Modified; + case DocumentChangeProxy.Type.Removed: + return DocumentChange.Type.Removed; + } + throw new ArgumentException("Unsupported DocumentChangeProxy.Type:" + type); + } + } + + /// + /// A DocumentChange represents a change to the documents matching a query. It contains the document + /// affected and the type of change that occurred (added, modified, or removed). + /// + public sealed class DocumentChange { + private readonly DocumentChangeProxy _proxy; + private readonly FirebaseFirestore _firestore; + + internal DocumentChange(DocumentChangeProxy proxy, FirebaseFirestore firestore) { + _proxy = Util.NotNull(proxy); + _firestore = Util.NotNull(firestore); + } + + /// + /// An enumeration of DocumentChange types. + /// + public enum Type { + /// Indicates a new document was added to the set of documents matching the + /// query. + Added = 0, + + /// Indicates document within the query was modified. + Modified = 1, + + /// Indicates a document within the query was removed (either deleted or no longer + /// matches the query). + Removed = 2 + } + + /// Returns the type of the DocumentChange. + public Type ChangeType { + get { + return _proxy.type().ConvertFromProxy(); + } + } + + /// + /// Returns the newly added or modified document if this DocumentChange is for an updated + /// document. Returns the deleted document if this document change represents a removal. + /// + public DocumentSnapshot Document => new DocumentSnapshot(_proxy.document(), _firestore); + + /// + /// The index of the changed document in the result set immediately prior to this DocumentChange + /// (i.e. supposing that all prior DocumentChange objects have been applied). Returns -1 for + /// 'added' events. + /// + public int OldIndex { + get { + return _proxy.old_index() == DocumentChangeProxy.npos ? -1 : (int)_proxy.old_index(); + } + } + + /// + /// The index of the changed document in the result set immediately after this DocumentChange + /// (i.e. supposing that all prior DocumentChange objects and the current DocumentChange object + /// have been applied). Returns -1 for 'removed' events. + /// + public int NewIndex { + get { + return _proxy.new_index() == DocumentChangeProxy.npos ? -1 : (int)_proxy.new_index(); + } + } + } +} diff --git a/firestore/src/DocumentReference.cs b/firestore/src/DocumentReference.cs new file mode 100644 index 000000000..311679e35 --- /dev/null +++ b/firestore/src/DocumentReference.cs @@ -0,0 +1,263 @@ +// Copyright 2017, Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Firebase.Firestore.Internal; +using Firebase.Platform; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; + +namespace Firebase.Firestore { + using DocumentSnapshotCallbackMap = + ListenerRegistrationMap>; + + /// + /// A DocumentReference refers to a document location in a Cloud Firestore database and can + /// be used to write, read, or listen to the location. There may or may not exist a document at + /// the referenced location. A DocumentReference can also be used to create a + /// to a subcollection. + /// + public sealed class DocumentReference : IEquatable { + private readonly DocumentReferenceProxy _proxy; + private readonly FirebaseFirestore _firestore; + + internal DocumentReferenceProxy Proxy { + get { + return _proxy; + } + } + + internal DocumentReference(DocumentReferenceProxy proxy, FirebaseFirestore firestore) { + Util.HardAssert(Util.NotNull(proxy).is_valid(), + "Cannot create DocumentReference for invalid DocumentReferenceProxy"); + _proxy = proxy; + _firestore = Util.NotNull(firestore); + } + + internal static void ClearCallbacksForOwner(FirebaseFirestore owner) { + snapshotListenerCallbacks.ClearCallbacksForOwner(owner); + } + + /// + /// The database which contains the document. + /// + public FirebaseFirestore Firestore { + get { + return _firestore; + } + } + + /// + /// The final part of the complete document path; this is the identity of the document relative + /// to its parent collection. + /// + public string Id => _proxy.id(); + + /// + /// The complete document path, not including project and database ID. + /// + public string Path => _proxy.path(); + + /// + /// The parent collection. Never null. + /// + public CollectionReference Parent => new CollectionReference(_proxy.Parent(), Firestore); + + /// + /// Creates a for a child collection of this document. + /// + /// The path to the collection, relative to this document. Must not be + /// null, and must contain an odd number of slash-separated path elements. + /// A for the specified collection. + public CollectionReference Collection(string path) { + Preconditions.CheckNotNull(path, nameof(path)); + return new CollectionReference(_proxy.Collection(path), Firestore); + } + + /// + public override int GetHashCode() => Firestore.GetHashCode() * 31 + Path.GetHashCode(); + + /// + public override bool Equals(object obj) => Equals(obj as DocumentReference); + + /// + public bool Equals(DocumentReference other) => other != null && Path == other.Path && Firestore == other.Firestore; + + /// + public override string ToString() { + AppOptionsInternal options = Util.NotNull(Firestore.App.options()); + string projectId = Util.NotNull(options.ProjectId); + // TODO(zxu): Find a way to programmatically get database id. + return "/projects/" + projectId + "/databases/(default)/" + Path; + } + + /// + /// Asynchronously deletes the document referred to by this DocumentReference. + /// + /// The write result of the server operation. The task will not complete while the + /// client is offline, though local changes will be visible immediately. + public Task DeleteAsync() => _proxy.DeleteAsync(); + + /// + /// Asynchronously performs a set of updates on the document referred to by this + /// DocumentReference. + /// + /// The updates to perform on the document, keyed by the field path to + /// update. Fields not present in this dictionary are not updated. Must not be null. + /// + /// The write result of the server operation. The task will not complete while the + /// client is offline, though local changes will be visible immediately. + public Task UpdateAsync(IDictionary updates) { + Preconditions.CheckNotNull(updates, nameof(updates)); + FieldValueProxy fieldValue = ValueSerializer.Serialize(SerializationContext.Default, updates); + return FirestoreCpp.DocumentReferenceUpdateAsync(_proxy, fieldValue); + } + + /// + /// Asynchronously performs a single field update on the document referred to by this + /// DocumentReference. + /// + /// The dot-separated name of the field to update. Must not be + /// null. + /// The new value for the field. May be null. + /// The write result of the server operation. The task will not complete while the + /// client is offline, though local changes will be visible immediately. + public Task UpdateAsync(string field, object value) { + Preconditions.CheckNotNull(field, nameof(field)); + FieldValueProxy proxyValue = ValueSerializer.Serialize(SerializationContext.Default, value); + return UpdateAsync(new Dictionary{ + {field, proxyValue}, + }); + } + + /// + /// Asynchronously performs a set of updates on the document referred to by this + /// DocumentReference. + /// + /// The updates to perform on the document, keyed by the field path to + /// update. Fields not present in this dictionary are not updated. Must not be null. + /// + /// The write result of the server operation. The task will not complete while the + /// client is offline, though local changes will be visible immediately. + public Task UpdateAsync(IDictionary updates) { + Preconditions.CheckNotNull(updates, nameof(updates)); + var data = new FieldPathToValueMap(); + foreach (KeyValuePair kv in updates) { + FieldPathProxy key = kv.Key.ConvertToProxy(); + FieldValueProxy value = ValueSerializer.Serialize(SerializationContext.Default, kv.Value); + data.Insert(key, value); + } + return FirestoreCpp.DocumentReferenceUpdateAsync(_proxy, data); + } + + /// + /// Asynchronously sets data in the document, either replacing it completely or merging fields. + /// + /// The data to store in the document. Must not be null. + /// + /// + /// The options to use when updating the document. May be null, which is equivalent + /// to . + /// + /// The write result of the server operation. The task will not complete while the + /// client is offline, though local changes will be visible immediately. + public Task SetAsync(object documentData, SetOptions options = null) { + Preconditions.CheckNotNull(documentData, nameof(documentData)); + + if (options == null) { + options = SetOptions.Overwrite; + } + + FieldValueProxy fieldValue = ValueSerializer.Serialize(SerializationContext.Default, documentData); + return FirestoreCpp.DocumentReferenceSetAsync(_proxy, fieldValue, options.Proxy); + } + + /// + /// Asynchronously fetches a snapshot of the document. + /// + /// + /// By default, GetSnapshotAsync attempts to provide up-to-date data when possible + /// by waiting for data from the server, but it may return cached data or fail if you are + /// offline and the server cannot be reached. This behavior can be altered via the source + /// parameter. + /// + /// indicates whether the results should be fetched from the cache only + /// (Source.Cache), the server only (Source.Server), or to attempt the server and + /// fall back to the cache (Source.Default). + /// A snapshot of the document. The snapshot may represent a missing document. + public Task GetSnapshotAsync(Source source = Source.Default) { + return Util.MapResult(_proxy.GetAsync(source), taskResult => { + return new DocumentSnapshot(taskResult, Firestore); + }); + } + + /// + /// Starts listening to changes to the document referenced by this DocumentReference. + /// + /// The callback to invoke each time the query results change. Must not + /// be null. + /// A which may be used to stop listening + /// gracefully. + public ListenerRegistration Listen(Action callback) { + Preconditions.CheckNotNull(callback, nameof(callback)); + return Listen(MetadataChanges.Exclude, callback); + } + + /// + /// Starts listening to changes to the document referenced by this DocumentReference. + /// + /// Indicates whether metadata-only changes (i.e. only + /// DocumentSnapshot.Metadata changed) should trigger snapshot events. + /// The callback to invoke each time the query results change. Must not + /// be null. + /// A which may be used to stop listening + /// gracefully. + public ListenerRegistration Listen(MetadataChanges metadataChanges, Action callback) { + Preconditions.CheckNotNull(callback, nameof(callback)); + var tcs = new TaskCompletionSource(); + int uid = snapshotListenerCallbacks.Register(Firestore, (snapshotProxy, errorCode, + errorMessage) => { + if (errorCode != FirestoreError.Ok) { + tcs.SetException(new FirestoreException(errorCode, errorMessage)); + } else { + FirebaseHandler.RunOnMainThread(() => { + callback(new DocumentSnapshot(snapshotProxy, Firestore)); + return null; + }); + } + }); + var listener = FirestoreCpp.AddDocumentSnapshotListener(_proxy, metadataChanges, uid, + documentSnapshotsHandler); + + return new ListenerRegistration(snapshotListenerCallbacks, uid, tcs, listener); + } + + private static DocumentSnapshotCallbackMap snapshotListenerCallbacks = new DocumentSnapshotCallbackMap(); + internal delegate void ListenerDelegate(int callbackId, IntPtr snapshotPtr, + FirestoreError errorCode, string errorMessage); + private static ListenerDelegate documentSnapshotsHandler = new ListenerDelegate(DocumentSnapshotsHandler); + + + [MonoPInvokeCallback(typeof(ListenerDelegate))] + private static void DocumentSnapshotsHandler(int callbackId, IntPtr snapshotPtr, + FirestoreError errorCode, string errorMessage) { + Action callback; + if (snapshotListenerCallbacks.TryGetCallback(callbackId, out callback)) { + callback(new DocumentSnapshotProxy(snapshotPtr, true), errorCode, errorMessage); + } + } + } +} diff --git a/firestore/src/DocumentSnapshot.cs b/firestore/src/DocumentSnapshot.cs new file mode 100644 index 000000000..4886feae8 --- /dev/null +++ b/firestore/src/DocumentSnapshot.cs @@ -0,0 +1,227 @@ +// Copyright 2017, Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +using System; +using System.Collections.Generic; +using BclType = System.Type; +using Firebase.Firestore.Internal; + +namespace Firebase.Firestore { + /// + /// An immutable snapshot of the data for a document. + /// + /// + /// A DocumentSnapshot contains data read from a document in your Cloud Firestore + /// database. The data can be extracted with the + /// + /// or methods. + /// + /// + /// If the DocumentSnapshot points to a non-existing document, ToDictionary + /// will return null. You can always explicitly check for a document's existence by + /// checking . + /// + public sealed class DocumentSnapshot { + private readonly DocumentSnapshotProxy _proxy; + private readonly FirebaseFirestore _firestore; + + internal DocumentSnapshotProxy Proxy { + get { + return _proxy; + } + } + + internal DocumentSnapshot(DocumentSnapshotProxy proxy, FirebaseFirestore firestore) { + _proxy = Util.NotNull(proxy); + _firestore = Util.NotNull(firestore); + } + + /// + /// The full reference to the document. + /// + public DocumentReference Reference => new DocumentReference(_proxy.reference(), _firestore); + + /// + /// The ID of the document. + /// + public string Id => _proxy.id(); + + /// + /// Whether or not the document exists. + /// + public bool Exists => _proxy.exists(); + + /// + /// The metadata for this DocumentSnapshot. + /// + public SnapshotMetadata Metadata { + get { + return SnapshotMetadata.ConvertFromProxy(_proxy.metadata()); + } + } + + /// + /// Returns the document data as a . + /// + /// Configures the behavior for server timestamps that + /// have not yet been set to their final value. + /// A containing the document data or + /// null if this is a nonexistent document. + public Dictionary ToDictionary(ServerTimestampBehavior serverTimestampBehavior = ServerTimestampBehavior.None) + => ConvertTo>(serverTimestampBehavior); + + /// + /// Deserializes the document data as the specified type. + /// + /// The type to deserialize the document data as. + /// Configures the behavior for server timestamps that + /// have not yet been set to their final value. + /// The deserialized data or default(T) if this is a nonexistent document. + /// + public T ConvertTo(ServerTimestampBehavior serverTimestampBehavior = ServerTimestampBehavior.None) { + // C++ returns a non-existent document as an empty map, because the map is returned by value. + // For reference types, it makes more sense to return a non-existent document as a null + // value. This matches Android behavior. + var targetType = typeof(T); + if (!Exists) { + BclType underlyingType = Nullable.GetUnderlyingType(targetType); + if (!targetType.IsValueType || underlyingType != null) { + return default(T); + } else { + throw new ArgumentException(String.Format( + "Unable to convert a non-existent document to {0}", targetType.FullName)); + } + } + + var map = FirestoreCpp.ConvertSnapshotToFieldValue(_proxy, serverTimestampBehavior.ConvertToProxy()); + var context = new DeserializationContext(this); + return (T)ValueDeserializer.Deserialize(context, map, targetType); + } + + /// + /// Fetches a field value from the document, throwing an exception if the field does not exist. + /// + /// The dot-separated field path to fetch. Must not be null or + /// empty. + /// Configures the behavior for server timestamps that + /// have not yet been set to their final value. + /// The field does not exist in the document data. + /// + /// The deserialized value. + public T GetValue(string path, ServerTimestampBehavior serverTimestampBehavior = + ServerTimestampBehavior.None) { + Preconditions.CheckNotNullOrEmpty(path, nameof(path)); + return GetValue(FieldPath.FromDotSeparatedString(path), serverTimestampBehavior); + } + + /// + /// Attempts to fetch the given field value from the document, returning whether or not it was + /// found. + /// + /// + /// This method does not throw an exception if the field is not found, but does throw an + /// exception if the field was found but cannot be deserialized. + /// + /// The dot-separated field path to fetch. Must not be null or empty. + /// + /// When this method returns, contains the deserialized value if the field + /// was found, or the default value of otherwise. + /// Configures the behavior for server timestamps that + /// have not yet been set to their final value. + /// true if the field was found in the document; false otherwise. + /// + public bool TryGetValue( + string path, out T value, + ServerTimestampBehavior serverTimestampBehavior = ServerTimestampBehavior.None) { + Preconditions.CheckNotNullOrEmpty(path, nameof(path)); + return TryGetValue(FieldPath.FromDotSeparatedString(path), out value, + serverTimestampBehavior); + } + + /// + /// Fetches a field value from the document, throwing an exception if the field does not exist. + /// + /// The field path to fetch. Must not be null or empty. + /// Configures the behavior for server timestamps that + /// have not yet been set to their final value. + /// The field does not exist in the document data. + /// + /// The deserialized value. + public T GetValue(FieldPath path, ServerTimestampBehavior serverTimestampBehavior = ServerTimestampBehavior.None) { + Preconditions.CheckNotNull(path, nameof(path)); + T value; + if (TryGetValue(path, out value, serverTimestampBehavior)) { + return value; + } else { + throw new InvalidOperationException("Field " + path + " not found in document"); + } + } + + /// + /// Attempts to fetch the given field value from the document, returning whether or not it was + /// found. + /// + /// + /// This method does not throw an exception if the field is not found, but does throw an + /// exception if the field was found but cannot be deserialized. + /// + /// The field path to fetch. Must not be null or empty. + /// When this method returns, contains the deserialized value if the field + /// was found, or the default value of otherwise. + /// Configures the behavior for server timestamps that + /// have not yet been set to their final value. + /// true if the field was found in the document; false otherwise. + /// + public bool TryGetValue(FieldPath path, out T value, ServerTimestampBehavior serverTimestampBehavior = ServerTimestampBehavior.None) { + Preconditions.CheckNotNull(path, nameof(path)); + value = default(T); + if (!Exists) { + return false; + } else { + FieldValueProxy fvi = _proxy.Get(path.ConvertToProxy(), serverTimestampBehavior.ConvertToProxy()); + if (!fvi.is_valid()) { + return false; + } else { + var context = new DeserializationContext(this); + value = (T)ValueDeserializer.Deserialize(context, fvi, typeof(T)); + return true; + } + } + } + + /// + /// Determines whether or not the given field path is present in the document. If this snapshot + /// represents a missing document, this method will always return false. + /// + /// The dot-separated field path to check. Must not be null or empty. + /// + /// true if the specified path represents a field in the document; false + /// otherwise. + public bool ContainsField(string path) { + Preconditions.CheckNotNullOrEmpty(path, nameof(path)); + return ContainsField(FieldPath.FromDotSeparatedString(path)); + } + + /// + /// Determines whether or not the given field path is present in the document. If this snapshot + /// represents a missing document, this method will always return false. + /// + /// The field path to check. Must not be null. + /// true if the specified path represents a field in the document; false + /// otherwise. + public bool ContainsField(FieldPath path) { + Preconditions.CheckNotNull(path, nameof(path)); + return Exists && _proxy.Get(path.ConvertToProxy()).is_valid(); + } + } +} diff --git a/firestore/src/FieldPath.cs b/firestore/src/FieldPath.cs new file mode 100644 index 000000000..ea568a46e --- /dev/null +++ b/firestore/src/FieldPath.cs @@ -0,0 +1,140 @@ +// Copyright 2017, Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; +using System.Collections; +using System.Linq; +using System.Text; +using Firebase.Firestore.Internal; + +namespace Firebase.Firestore { + /// + /// An immutable path of field names, used to identify parts of a document. A FieldPath + /// refers to a field in a document. The path may consist of a single field name (referring to a + /// top level field in the document), or a list of field names (referring to a nested field in the + /// document). + /// + public sealed class FieldPath : IEquatable { + private static readonly char[] dotSplit = { '.' }; + + /// + /// Characters prohibited within dot-separated field paths. + /// + private static readonly char[] prohibitedCharacters = { '~', '*', '[', ']', '/' }; + + /// + /// Sentinel field path to refer to the ID of a document. Used in queries to sort or filter by + /// the document ID. + /// + public static FieldPath DocumentId { get; } = + new FieldPath(new[] { "__name__" }, trusted: true); + + private readonly string[] _segments; + + private string _encodedPath; + + internal string EncodedPath => _encodedPath ?? (_encodedPath = GetCanonicalPath(_segments)); + + /// + /// Constructor that optionally trusts the value. + /// + /// The segments + /// True to bypass both copying and validation; false otherwise. + private FieldPath(string[] segments, bool trusted) { + if (trusted) { + _segments = segments; + } else { + _segments = Preconditions.CheckNotNull(segments, nameof(segments)).ToArray(); + Preconditions.CheckArgument(segments.Length != 0, nameof(segments), "Path must not be empty"); + Preconditions.CheckArgument(segments.All(n => !string.IsNullOrEmpty(n)), nameof(segments), "Path must not contain null or empty names"); + } + } + + /// + /// Creates a path from multiple segments. Each segment is treated verbatim: it may contain + /// dots, which will lead to the segment being escaped in the path's string representation. + /// + /// The segments of the path. This must not be null or empty, and + /// it must not contain any null or empty elements. + public FieldPath(params string[] segments) : this(segments, false) { + } + + internal static FieldPath FromDotSeparatedString(string path) { + Preconditions.CheckNotNullOrEmpty(path, nameof(path)); + Preconditions.CheckArgument(path.IndexOfAny(prohibitedCharacters) == -1, nameof(path), "Use the constructor for field names containing any of '~*/[]'."); + string[] elements = path.Split(dotSplit); + if (elements.Contains("")) { + throw new ArgumentException("Path cannot contain empty elements", nameof(path)); + } + return new FieldPath(elements, trusted: true); + } + + private static string GetCanonicalPath(string[] fields) { + StringBuilder builder = new StringBuilder(); + for (int i = 0; i < fields.Length; i++) { + if (i > 0) { + builder.Append("."); + } + // Escape backslashes and backticks. + string escaped = fields[i].Replace(@"\", @"\\").Replace("`", @"\`"); + if (!IsValidIdentifier(escaped)) { + builder.Append('`').Append(escaped).Append('`'); + } else { + builder.Append(escaped); + } + } + return builder.ToString(); + } + + /// + /// Return true if the string could be used as a segment in a field path without + /// escaping. Valid identifiers follow the regex [a-zA-Z_][a-zA-Z0-9_]*. + /// (Using a regular expression is significantly slower though.) + /// + private static bool IsValidIdentifier(string identifier) { + // This will never be called with any empty strings. + char first = identifier[0]; + if (first != '_' && (first < 'a' || first > 'z') && (first < 'A' || first > 'Z')) { + return false; + } + for (int i = 1; i < identifier.Length; i++) { + char c = identifier[i]; + if (c != '_' && (c < 'a' || c > 'z') && (c < 'A' || c > 'Z') && (c < '0' || c > '9')) { + return false; + } + } + return true; + } + + /// + public override string ToString() => EncodedPath; + + /// + public override bool Equals(object obj) => Equals(obj as FieldPath); + + /// + public override int GetHashCode() => EncodedPath.GetHashCode(); + + /// + public bool Equals(FieldPath other) => EncodedPath == other?.EncodedPath; + + internal FieldPathProxy ConvertToProxy() { + StringList segments = new StringList(); + foreach (string segment in _segments) { + segments.Add(segment); + } + return new FieldPathProxy(segments); + } + } +} diff --git a/firestore/src/FieldValue.cs b/firestore/src/FieldValue.cs new file mode 100644 index 000000000..e82d2d45c --- /dev/null +++ b/firestore/src/FieldValue.cs @@ -0,0 +1,109 @@ +// Copyright 2018, Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Firebase.Firestore.Internal; + +namespace Firebase.Firestore { + /// + /// A static class providing properties and methods to represent sentinel values. + /// + /// + /// Sentinel values are special values where the client-side value is not part of the + /// document modification sent to the server. A property decorated with + /// can specify an additional attribute to indicate + /// that it's a sentinel value, such as a , or the + /// sentinel values returned by the members of this class can be used directly as values to be + /// serialized (for example, in anonymous types), and they will be handled directly by the + /// serialization mechanism. + /// + public static class FieldValue { + /// + /// Sentinel value indicating that the field should be set to the timestamp of the commit + /// that creates or modifies the document. + /// + public static object ServerTimestamp { get; } = FieldValueProxy.ServerTimestamp(); + + /// + /// Sentinel value indicating that the field should be deleted from the document. + /// + public static object Delete { get; } = FieldValueProxy.Delete(); + + /// + /// Returns a special value that can be used with SetAsync() or UpdateAsync() that tells the + /// server to union the given elements with any array value that already exists on the server. Each + /// specified element that doesn't already exist in the array will be added to the end. If the + /// field being modified is not already an array, it will be overwritten with an array containing + /// exactly the specified elements. + /// + /// + /// The elements to union into the array. + /// The FieldValue sentinel for use in a call to SetAsync() or UpdateAsync(). + /// + public static object ArrayUnion(params object[] elements) { + Preconditions.CheckNotNull(elements, nameof(elements)); + var fieldValue = ValueSerializer.Serialize(SerializationContext.Default, elements); + var array = FirestoreCpp.ConvertFieldValueToVector(fieldValue); + return FirestoreCpp.FieldValueArrayUnion(array); + } + + /// + /// Returns a special value that can be used with SetAsync() or UpdateAsync() that tells the + /// server to remove the given elements from any array value that already exists on the server. All + /// instances of each element specified will be removed from the array. If the field being modified + /// is not already an array, it will be overwritten with an empty array. + /// + /// + /// The elements to remove from the array. + /// The FieldValue sentinel for use in a call to SetAsync() or UpdateAsync(). + /// + public static object ArrayRemove(params object[] elements) { + Preconditions.CheckNotNull(elements, nameof(elements)); + var fieldValue = ValueSerializer.Serialize(SerializationContext.Default, elements); + var array = FirestoreCpp.ConvertFieldValueToVector(fieldValue); + return FirestoreCpp.FieldValueArrayRemove(array); + } + + /// + /// Returns a special value that can be used with SetAsync() or UpdateAsync() that tells the server to + /// increment the field's current value by the given value. + /// + /// + /// If the current field value is an integer, possible integer overflows are resolved to + /// or . If the current + /// field value is a double, both values will be interpreted as doubles and the arithmetic will + /// follow IEEE 754 semantics. + /// + /// If the current field is not an integer or double, or if the field does not yet exist, the + /// transformation will set the field to the given value. + /// + /// + /// The FieldValue sentinel for use in a call to SetAsync() or UpdateAsync(). + /// + public static object Increment(long value) => FieldValueProxy.IntegerIncrement(value); + + /// + /// Returns a special value that can be used with SetAsync() or UpdateAsync() that tells the server to + /// increment the field's current value by the given value. + /// + /// + /// If the current value is an integer or a double, both the current and the given value will be + /// interpreted as doubles and all arithmetic will follow IEEE 754 semantics. Otherwise, the + /// transformation will set the field to the given value. + /// + /// + /// The FieldValue sentinel for use in a call to SetAsync() or UpdateAsync(). + /// + public static object Increment(double value) => FieldValueProxy.DoubleIncrement(value); + } +} diff --git a/firestore/src/FirebaseFirestore.cs b/firestore/src/FirebaseFirestore.cs new file mode 100644 index 000000000..034c423fa --- /dev/null +++ b/firestore/src/FirebaseFirestore.cs @@ -0,0 +1,514 @@ +// Copyright 2017, Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License.using System; + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Firebase.Platform; +using Firebase.Firestore.Internal; + +namespace Firebase.Firestore { + using SnapshotsInSyncCallbackMap = ListenerRegistrationMap; + using LoadBundleProgressCallbackMap = ListenerRegistrationMap>; + + /// + /// Represents a Cloud Firestore database and is the entry point fr all Cloud Firestore + /// operations. + /// + public sealed class FirebaseFirestore { + private FirestoreProxy _proxy; + + private FirebaseFirestoreSettings _settings = new FirebaseFirestoreSettings(); + private Boolean _settingsApplied; + + private readonly TransactionManager _transactionManager; + + // Track Firestore instances so that we return the same one each time they're requested (e.g. + // via DefaultInstance, though also via calls to GetInstance that are passed the same + // FirebaseApp instance). As a side effect of keying by FirebaseApp, this also prevents the + // FirebaseApp from being GC'd. + private static IDictionary databases = new Dictionary(); + + // We rely on e.g. firestore.Document("a/b").Firestore returning the original Firestore + // instance so it's important the constructor remains private and we only create one + // FirebaseFirestore instance per FirebaseApp instance. + private FirebaseFirestore(FirestoreProxy proxy, FirebaseApp app) { + _proxy = Util.NotNull(proxy); + App = app; + app.AppDisposed += OnAppDisposed; + + // This call to InitializeConverterCache() exists to make sure that AOT works. + Firebase.Firestore.Converters.ConverterCache.InitializeConverterCache(); + + string dotnetVersion = EnvironmentVersion.GetEnvironmentVersion(); + ApiHeaders.SetClientLanguage(String.Format("gl-dotnet/{0}", dotnetVersion)); + + _transactionManager = new TransactionManager(this, proxy); + } + + /// + /// Destroys this object and frees all resources it has acquired. + /// + ~FirebaseFirestore() { + Dispose(); + } + + void OnAppDisposed(object sender, System.EventArgs eventArgs) { + Dispose(); + } + + private FirestoreProxy GetProxy() { + if (!_settingsApplied) { + _proxy.set_settings(Settings.Proxy); + _settingsApplied = true; + } + return _proxy; + } + + private void Dispose() { + System.GC.SuppressFinalize(this); + if (_proxy == null) return; + lock (_proxy) { + if (_proxy == null) return; + + App.AppDisposed -= OnAppDisposed; + + _transactionManager.Dispose(); + snapshotsInSyncCallbacks.ClearCallbacksForOwner(this); + loadBundleProgressCallbackMap.ClearCallbacksForOwner(this); + DocumentReference.ClearCallbacksForOwner(this); + Query.ClearCallbacksForOwner(this); + + // Make sure the cache doesn't hold on to a stale (cleaned-up) instance. + lock (databases) { + databases.Remove(App); + } + + _proxy.Dispose(); + _proxy = null; + App = null; + } + } + /// + /// Returns the FirebaseApp instance to which this FirebaseFirestore belongs. + /// + public FirebaseApp App { get; private set; } + + /// + /// Gets the instance of FirebaseFirestore for the default FirebaseApp. + /// + /// A FirebaseFirestore instance. + public static FirebaseFirestore DefaultInstance { + get { + FirebaseApp app = Util.NotNull(FirebaseApp.DefaultInstance); + return GetInstance(app); + } + } + + /// + /// Gets an instance of FirebaseFirestore for a specific FirebaseApp. + /// + /// The FirebaseApp for which to get a FirebaseFirestore + /// instance. + /// A FirebaseFirestore instance. + public static FirebaseFirestore GetInstance(FirebaseApp app) { + Preconditions.CheckNotNull(app, nameof(app)); + + lock (databases) { + if (!databases.ContainsKey(app)) { + FirestoreProxy fp = Util.NotNull(FirestoreCpp.GetFirestoreInstance(app)); + databases[app] = new FirebaseFirestore(fp, app); + } + return databases[app]; + } + } + + /// + /// Gets or sets the settings used to configure this FirebaseFirestore object. + /// Changing settings after calling other methods of the instance will have no effect. + /// + public FirebaseFirestoreSettings Settings { + get { + return _settings; + } + set { + _settings = value; + } + } + + /// + /// Creates a local for the given path, which must include an + /// odd number of slash-separated identifiers. This does not perform any remote operations. + /// + /// The collection path, e.g. col1/doc1/col2. + /// A collection reference. + public CollectionReference Collection(string path) { + Preconditions.CheckNotNullOrEmpty(path, nameof(path)); + return new CollectionReference(GetProxy().Collection(path), this); + } + + /// + /// Creates a local for the given path, which must include an + /// even number of slash-separated identifiers. This does not perform any remote operations. + /// + /// The document path, e.g. col1/doc1/col2/doc2. + /// A document reference. + public DocumentReference Document(string path) { + Preconditions.CheckNotNullOrEmpty(path, nameof(path)); + return new DocumentReference(GetProxy().Document(path), this); + } + + /// + /// Creates and returns a new that includes all documents in the + /// database that are contained in a collection or subcollection with the + /// given collection ID. + /// + /// Identifies the collections to query over. + /// Every collection or subcollection with this ID as the last segment + /// of its path will be included. Must not contain a slash. + /// The created . + public Query CollectionGroup(string collectionId) { + Preconditions.CheckNotNullOrEmpty(collectionId, nameof(collectionId)); + return new Query(GetProxy().CollectionGroup(collectionId), this); + } + + /// + /// Creates a write batch, which can be used to commit multiple mutations atomically. + /// + /// A write batch for this database. + public WriteBatch StartBatch() => new WriteBatch(GetProxy().batch()); + + /// + /// Runs a transaction asynchronously, with an asynchronous callback that doesn't return a + /// value. The specified callback is executed for a newly-created transaction. + /// + /// + /// RunTransactionAsync executes the given callback on the main thread and then + /// attempts to commit the changes applied within the transaction. If any document read within + /// the transaction has changed, the will be retried. If it fails + /// to commit after 5 attempts, the transaction will fail. + /// + /// The maximum number of writes allowed in a single transaction is 500, but note that + /// each usage of , FieldValue.ArrayUnion, + /// FieldValue.ArrayRemove, or FieldValue.Increment inside a transaction counts as + /// an additional write. + /// + /// The callback to execute. Must not be null. + /// A task which completes when the transaction has committed. + public Task RunTransactionAsync(Func callback) { + Preconditions.CheckNotNull(callback, nameof(callback)); + // Just pass through to the overload where the callback returns a Task. + return RunTransactionAsync(transaction => + Util.MapResult(callback(transaction), null)); + } + + /// + /// Runs a transaction asynchronously, with an asynchronous callback that returns a value. + /// The specified callback is executed for a newly-created transaction. + /// + /// + /// RunTransactionAsync executes the given callback on the main thread and then + /// attempts to commit the changes applied within the transaction. If any document read within + /// the transaction has changed, the will be retried. If it fails to + /// commit after 5 attempts, the transaction will fail. + /// + /// The maximum number of writes allowed in a single transaction is 500, but note that + /// each usage of , FieldValue.ArrayUnion, + /// FieldValue.ArrayRemove, or FieldValue.Increment inside a transaction counts as + /// an additional write. + /// + /// + /// The result type of the callback. + /// The callback to execute. Must not be null. + /// A task which completes when the transaction has committed. The result of the task + /// then contains the result of the callback. + public Task RunTransactionAsync(Func> callback) { + Preconditions.CheckNotNull(callback, nameof(callback)); + if (_proxy != null) { + GetProxy(); // Ensure that the settings are applied. + } + return _transactionManager.RunTransactionAsync(callback); + } + + private static SnapshotsInSyncCallbackMap snapshotsInSyncCallbacks = new SnapshotsInSyncCallbackMap(); + internal delegate void SnapshotsInSyncDelegate(int callbackId); + private static SnapshotsInSyncDelegate snapshotsInSyncHandler = new SnapshotsInSyncDelegate(SnapshotsInSyncHandler); + + + [MonoPInvokeCallback(typeof(SnapshotsInSyncDelegate))] + private static void SnapshotsInSyncHandler(int callbackId) { + Action callback; + + if (snapshotsInSyncCallbacks.TryGetCallback(callbackId, out callback)) { + FirebaseHandler.RunOnMainThread(() => { + callback(); + return null; + }); + } + } + + /// + /// Attaches a listener for a snapshots-in-sync event. The snapshots-in-sync event indicates + /// that all listeners affected by a given change have fired, even if a single + /// server-generated change affects multiple listeners. + /// + /// + /// NOTE: The snapshots-in-sync event only indicates that listeners are in sync with each other, + /// but does not relate to whether those snapshots are in sync with the server. Use + /// SnapshotMetadata in the individual listeners to determine if a snapshot is from the cache or + /// the server. + /// + /// A callback to be called every time all snapshot listeners are in + /// sync with each other. + /// A registration object that can be used to remove the listener. + public ListenerRegistration ListenForSnapshotsInSync(Action callback) { + Preconditions.CheckNotNull(callback, nameof(callback)); + var tcs = new TaskCompletionSource(); + int uid = snapshotsInSyncCallbacks.Register(this, callback); + var listener = + FirestoreCpp.AddSnapshotsInSyncListener(GetProxy(), uid, snapshotsInSyncHandler); + return new ListenerRegistration(snapshotsInSyncCallbacks, uid, tcs, listener); + } + + private static LoadBundleProgressCallbackMap loadBundleProgressCallbackMap = + new LoadBundleProgressCallbackMap(); + internal delegate void LoadBundleTaskProgressDelegate(int callbackId, IntPtr progress); + private static LoadBundleTaskProgressDelegate handler = + new LoadBundleTaskProgressDelegate(LoadBundleTaskProgressHandler); + + [MonoPInvokeCallback(typeof(LoadBundleTaskProgressDelegate))] + private static void LoadBundleTaskProgressHandler(int callbackId, IntPtr progressPtr) { + Action callback; + var progress = new LoadBundleTaskProgress(new LoadBundleTaskProgressProxy(progressPtr, true)); + if (loadBundleProgressCallbackMap.TryGetCallback(callbackId, out callback)) { + callback(progress); + } + } + + /// + /// Loads a Firestore bundle into the local cache. + /// + /// The bundle to be loaded. + /// A task that is completed when the loading is completed. The result of + /// the task then contains the final progress of the loading operation. + /// + public Task LoadBundleAsync(string bundleData) { + return LoadBundleAsync(bundleData, (sender, progress) => {}); + } + + /// + /// Loads a Firestore bundle into the local cache, taking an + /// to monitor loading progress. + /// + /// The bundle to be loaded. + /// A that is notified with + /// progress updates, and completion or error updates. + /// A task that is completed when the loading is completed. The result of the task + /// then contains the final progress of the loading operation. + /// + public Task LoadBundleAsync( + string bundleData, System.EventHandler progressHandler) { + Preconditions.CheckNotNull(bundleData, nameof(bundleData)); + Preconditions.CheckNotNull(progressHandler, nameof(progressHandler)); + + var tcs = new TaskCompletionSource(); + Action action = (LoadBundleTaskProgress progress) => { + try { + progressHandler(this, progress); + } finally { + // Make sure returning task completes regardless of progressHanlder state. + if (progress.State == LoadBundleTaskProgress.LoadBundleTaskState.Success) { + tcs.SetResult(progress); + } else if (progress.State == LoadBundleTaskProgress.LoadBundleTaskState.Error) { + tcs.SetException(new FirestoreException( + FirestoreError.Unknown, "Loading Firestore bundle encountered an error.")); + } + } + }; + + int callbackId = loadBundleProgressCallbackMap.Register(this, action); + FirestoreCpp.LoadBundleWithCallback(GetProxy(), bundleData, callbackId, handler); + + return tcs.Task; + } + + /// + /// Loads a Firestore bundle into the local cache. + /// + /// The bundle to be loaded, as a UTF-8 encoded byte array. + /// A task that is completed when the loading is completed. The result of + /// the task then contains the final progress of the loading operation. + /// + public Task LoadBundleAsync(byte[] bundleData) { + Preconditions.CheckNotNull(bundleData, nameof(bundleData)); + // TODO(b/190626833): Consider expose a C++ interface taking byte array, to avoid encoding + // here. + return LoadBundleAsync(Encoding.UTF8.GetString(bundleData)); + } + + /// + /// Loads a Firestore bundle into the local cache, taking an + /// to monitor loading progress. + /// + /// The bundle to be loaded, as a UTF8 encoded byte array. + /// An that is notified with + /// progress updates, and completion or error updates. + /// A task that is completed when the loading is completed. The result of the task + /// then contains the final progress of the loading operation. + /// + public Task LoadBundleAsync( + byte[] bundleData, System.EventHandler progressHandler) { + Preconditions.CheckNotNull(bundleData, nameof(bundleData)); + Preconditions.CheckNotNull(progressHandler, nameof(progressHandler)); + return LoadBundleAsync(Encoding.UTF8.GetString(bundleData), progressHandler); + } + + /// + /// Reads a Firestore from the local cache, identified by the given + /// name. + /// + /// + /// Named queries are packaged into bundles on the server side (along with the + /// resulting documents) and loaded into local cache using . Once in the local cache, you can use + /// this method to extract a query by name. + /// + /// The name of the query to read from saved bundles. + /// A task that is completed with the query associated with the given name. The result + /// of the returned task is set to null if no queries can be found. + /// + public Task GetNamedQueryAsync(string queryName) { + Preconditions.CheckNotNull(queryName, nameof(queryName)); + return GetProxy().NamedQueryAsync(queryName).ContinueWith((queryProxy) => { + if (queryProxy.IsFaulted) { + return null; + } + + return new Query(queryProxy.Result, this); + }); + } + + /// + /// Disables network access for this instance. + /// + /// + /// While the network is disabled, any snapshot listeners or GetSnapshotAsync calls will + /// return results from cache, and any write operations will be queued until network usage is + /// re-enabled via a call to . + /// + /// A task which completes once networking is disabled. + public Task DisableNetworkAsync() => GetProxy().DisableNetworkAsync(); + + /// + /// Re-enables network usage for this instance after a prior call to + /// . + /// + /// A task which completes once networking is enabled. + public Task EnableNetworkAsync() => GetProxy().EnableNetworkAsync(); + + /// + /// Waits until all currently pending writes for the active user have been acknowledged by the + /// backend. + /// + /// + /// + /// The returned Task completes immediately if there are no outstanding writes. Otherwise, the + /// Task waits for all previously issued writes (including those written in a previous app + /// session), but it does not wait for writes that were added after the method is called. If you + /// wish to wait for additional writes, you have to call `WaitForPendingWritesAsync()` again. + /// + /// Any outstanding `WaitForPendingWritesAsync()` Tasks are cancelled during user changes. + /// + /// + /// A Task which completes when all currently pending writes have been acknowledged + /// by the backend. + public Task WaitForPendingWritesAsync() => GetProxy().WaitForPendingWritesAsync(); + + /// + /// Terminates this FirebaseFirestore instance. + /// + /// + /// + /// After calling Terminate(), only the ClearPersistenceAsync() method may be + /// used. Calling any other method will result in an error. + /// + /// To restart after termination, simply create a new instance of FirebaseFirestore with + /// GetInstance() or GetInstance(FirebaseApp). + /// + /// Terminate() does not cancel any pending writes, and any tasks that are awaiting a + /// response from the server will not be resolved. The next time you start this instance, it + /// will resume attempting to send these writes to the server. + /// + /// Note: under normal circumstances, calling Terminate() is not required. This method + /// is useful only when you want to force this instance to release all of its resources or in + /// combination with ClearPersistenceAsync to ensure that all local state is destroyed + /// between test runs. + /// + /// + /// + /// A Task which completes when the instance has been successfully terminated. + /// + public Task TerminateAsync() { + lock (databases) { + if (databases.ContainsKey(App)) { + databases.Remove(App); + } + } + return GetProxy().TerminateAsync(); + } + + /// + /// Clears the persistent storage. This includes pending writes and cached documents. + /// + /// + /// + /// Must be called while the Firestore instance is not started (after the app is shut down or + /// when the app is first initialized). On startup, this method must be called before other + /// methods (other than getting or setting `FirebaseFirestoreSettings`). If the Firestore + /// instance is still running, the task will complete with an error code of + /// `FailedPrecondition`. + /// + /// Note: `ClearPersistenceAsync()` is primarily intended to help write reliable tests that use + /// Firestore. It uses the most efficient mechanism possible for dropping existing data but does + /// not attempt to securely overwrite or otherwise make cached data unrecoverable. For + /// applications that are sensitive to the disclosure of cache data in between user sessions we + /// strongly recommend not to enable persistence in the first place. + /// + /// + /// A Task which completes when the clear persistence operation has completed. + /// + public Task ClearPersistenceAsync() => GetProxy().ClearPersistenceAsync(); + + /// + /// Sets the log verbosity of all Firestore instances. + /// + /// The default verbosity level is + /// Info + /// . + /// Set to + /// Debug + /// to turn on the diagnostic logging. + /// + /// The desired verbosity. + public static LogLevel LogLevel { + set { + // This is thread-safe as far as the underlying one is thread-safe. + FirestoreProxy.set_log_level(value); + } + } + } +} diff --git a/firestore/src/FirebaseFirestoreSettings.cs b/firestore/src/FirebaseFirestoreSettings.cs new file mode 100644 index 000000000..f5c6d8d1e --- /dev/null +++ b/firestore/src/FirebaseFirestoreSettings.cs @@ -0,0 +1,115 @@ +// Copyright 2017, Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License.using System; + +using System; +using Firebase.Firestore.Internal; + +namespace Firebase.Firestore { + /// + /// Settings used to configure a instance. + /// + public sealed class FirebaseFirestoreSettings { + /// Constant to use when setting to disable garbage + /// collection. + public static readonly long CacheSizeUnlimited = + SettingsProxy.kCacheSizeUnlimited; + + // Note: must be kept in sync with the C++ Settings::kDefaultCacheSizeBytes. + private static readonly long defaultCacheSizeBytes = 100 * 1024 * 1024; + + private string _host = "firestore.googleapis.com"; + + internal static FirebaseFirestoreSettings FromProxy(SettingsProxy proxy) { + return new FirebaseFirestoreSettings { + Host = proxy.host(), + SslEnabled = proxy.is_ssl_enabled(), + PersistenceEnabled = proxy.is_persistence_enabled(), + CacheSizeBytes = proxy.cache_size_bytes() + }; + } + + internal SettingsProxy Proxy { + get { + var proxy = new SettingsProxy(); + proxy.set_host(Host); + proxy.set_ssl_enabled(SslEnabled); + proxy.set_persistence_enabled(PersistenceEnabled); + proxy.set_cache_size_bytes(CacheSizeBytes); + + return proxy; + } + } + + /// + /// The host of the Cloud Firestore backend. + /// + public string Host { + get { + return _host; + } + set { + Preconditions.CheckNotNullOrEmpty(value, nameof(value)); + _host = value; + } + } + + /// + /// Whether or not to use SSL for communication. + /// + public bool SslEnabled {get; set;} = true; + + /// + /// Whether or not to use local persistence storage. + /// + public bool PersistenceEnabled {get; set;} = true; + + /// + /// Sets an approximate cache size threshold for the on-disk data. If the + /// cache grows beyond this size, Cloud Firestore will start removing data + /// that hasn't been recently used. The size is not a guarantee that the + /// cache will stay below that size, only that if the cache exceeds the + /// given size, cleanup will be attempted. + /// + /// By default, collection is enabled with a cache size of 100 MB. The + /// minimum value is 1 MB. + /// + public long CacheSizeBytes {get; set;} = defaultCacheSizeBytes; + + /// + public override bool Equals(object obj) { + if (obj is FirebaseFirestoreSettings) { + return this.Equals((FirebaseFirestoreSettings)obj); + } + return false; + } + + /// + public bool Equals(FirebaseFirestoreSettings other) { + return Host.Equals(other.Host) && + SslEnabled.Equals(other.SslEnabled) && + PersistenceEnabled.Equals(other.PersistenceEnabled) && + CacheSizeBytes.Equals(other.CacheSizeBytes); + } + + /// + public override int GetHashCode() { + int hashCode = this.Host.GetHashCode(); + hashCode = hashCode * 31 + this.SslEnabled.GetHashCode(); + hashCode = hashCode * 31 + this.PersistenceEnabled.GetHashCode(); + hashCode = hashCode * 31 + this.CacheSizeBytes.GetHashCode(); + return hashCode; + } + } +} diff --git a/firestore/src/FirestoreConverter.cs b/firestore/src/FirestoreConverter.cs new file mode 100644 index 000000000..3dd6a9132 --- /dev/null +++ b/firestore/src/FirestoreConverter.cs @@ -0,0 +1,81 @@ +// Copyright 2018, Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Firebase.Firestore.Converters; +using System.Collections.Generic; +using System; + +namespace Firebase.Firestore { + /// + /// Custom converter used during serialization and deserialization. + /// + /// + /// + /// This can be specified using to use + /// the custom converter for all values of the attributed type, or using + /// to use the custom converter for a single property. The latter approach can also be used to + /// allow for conversion of types you don't control (e.g. to serialize properties + /// as strings). + /// + /// + /// This interface is never passed a null value and should never return a null value. Null values are transparently + /// handled by the serialization framework; if a document contains a null value, that will always be deserialized + /// to a null reference (or null value of a nullable value type). + /// + /// + /// Converters express their conversions in terms of regular .NET types: strings, integers, lists, dictionaries and so + /// on. The result of serializing an object of type is then processed by the default serialization + /// handling into the Firestore data model representation. Deserialization works the same way: first the Firestore + /// data model representation is converted into .NET types in the default manner for this library, and the result is + /// passed to the converter. Note that this means there can be asymmetry between serialization and deserialization: if the + /// method returns an , deserializing the result will involve + /// the method receiving an value as that's the default + /// .NET representation of a Firestore integer. + /// + /// + /// Converters that intend to convert objects into top-level documents should return a string-keyed dictionary of values + /// from . On deserialization, will be passed a value + /// implementing with a key type of and a value type + /// of . + /// + /// + /// The type of object to convert. + public abstract class FirestoreConverter { + + /// + /// Creates a new instance of this class. + /// + public FirestoreConverter() { + // This is a hack for AOT platforms such that a CustomConverter implementation will be generated for type T. + // This is also the reason why `FirestoreConverter` is not an interface. + CustomConverter.CreateInstance(null); + } + + /// + /// Converts a value to its Firestore representation. + /// + /// The value to convert. When called by Firebase.Firestore, + /// this will never be null. + /// The converted value. Must not be null. + public abstract object ToFirestore(T value); + + /// + /// Converts a value from its Firestore representation. + /// + /// The value to convert. When called by Firebase.Firestore, + /// this will never be null. + /// The converted value. Must not be null. + public abstract T FromFirestore(object value); + } +} diff --git a/firestore/src/FirestoreDataAttribute.cs b/firestore/src/FirestoreDataAttribute.cs new file mode 100644 index 000000000..40738809b --- /dev/null +++ b/firestore/src/FirestoreDataAttribute.cs @@ -0,0 +1,48 @@ +// Copyright 2017, Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; + +namespace Firebase.Firestore { + /// + /// Attribute indicating that a type is intended to be used with Firestore. + /// + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Delegate | AttributeTargets.Interface)] + public sealed class FirestoreDataAttribute : Attribute { + /// + /// The strategy to use when handling unknown properties. The default is + /// . + /// + public UnknownPropertyHandling UnknownPropertyHandling { get; set; } + + /// + /// A custom converter type to use for serializing and deserializing the attributed type. + /// + public System.Type ConverterType { get; set; } + + /// + /// Constructs a new instance with default values for options. + /// + public FirestoreDataAttribute() : this(UnknownPropertyHandling.Warn) { + } + + /// + /// Constructs a new instance with the given handling for unknown properties. + /// + /// The unknown property handling strategy to use. + public FirestoreDataAttribute(UnknownPropertyHandling unknownPropertyHandling) { + UnknownPropertyHandling = unknownPropertyHandling; + } + } +} diff --git a/firestore/src/FirestoreDocumentIdAttribute.cs b/firestore/src/FirestoreDocumentIdAttribute.cs new file mode 100644 index 000000000..73a904a2d --- /dev/null +++ b/firestore/src/FirestoreDocumentIdAttribute.cs @@ -0,0 +1,34 @@ +// Copyright 2019, Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; + +namespace Firebase.Firestore { + /// + /// Attribute indicating that a property should be populated with the Firestore document ID. + /// + /// + /// This attribute must only be applied to properties of string or . + /// This attribute is ignored when serializing a document to Firestore. + /// This attribute must not be applied on a property which also has . + /// + [AttributeUsage(AttributeTargets.Property)] + public sealed class FirestoreDocumentIdAttribute : Attribute { + /// + /// Creates an instance of the attribute. + /// + public FirestoreDocumentIdAttribute() { + } + } +} diff --git a/firestore/src/FirestoreEnumNameConverter.cs b/firestore/src/FirestoreEnumNameConverter.cs new file mode 100644 index 000000000..e61957fd2 --- /dev/null +++ b/firestore/src/FirestoreEnumNameConverter.cs @@ -0,0 +1,93 @@ +// Copyright 2019, Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; +using System.Collections.Generic; +using System.Reflection; + +namespace Firebase.Firestore { + /// + /// Custom converter which uses enum value names instead of integer values as the Firestore representation. + /// This converter is not used by default; it must be configured in the same way as any other custom converter. + /// + /// + /// + /// Currently this is always case-sensitive, with no customization of the names used. In future releases + /// we may introduce further ways to configure this converter, but the default behavior will remain the same. + /// + /// + /// When the same enum value has multiple names, no guarantee is made about which one is returned, although both + /// are accepted for conversion back to enum values. You are strongly encouraged not to use multiple names for the + /// same value. + /// + /// + /// The enum type to convert + public sealed class FirestoreEnumNameConverter : FirestoreConverter + where T : struct { + // These dictionaries are static as they only depend on the type of T. + // There's no point in doing the reflection again each time a converter is constructed. + // If we introduce features like case-insensitivity or custom names, we may want to introduce instance + // dictionary fields as well. + private static readonly Dictionary s_nameToValueMap; + private static readonly Dictionary s_valueToNameMap; + + static FirestoreEnumNameConverter() { + // HACK: IL2CPP strips this constructor without it. + new FirestoreEnumNameConverter(); + + if (!typeof(T).IsEnum) { + throw new ArgumentException("Can't use FirestoreEnumNameConverter on {0} since it is not an enum.", typeof(T).FullName); + } + s_nameToValueMap = new Dictionary(); + s_valueToNameMap = new Dictionary(); + + foreach (var field in typeof(T).GetFields(BindingFlags.Public | BindingFlags.Static)) { + var name = field.Name; + var value = (T)field.GetValue(null); + s_nameToValueMap[name] = value; + // This may overwrite an existing value, but that's okay. We explicitly don't + // make any guarantees as to which name is returned for a value with multiple names. + s_valueToNameMap[value] = name; + } + } + + /// + public override T FromFirestore(object value) { + if (s_nameToValueMap.TryGetValue((string)value, out var result)) { + return result; + } else { + throw new ArgumentException(String.Format("Unknown name '{0}' for enum {1}", value, typeof(T).FullName)); + } + } + + /// + /// Converts an enum value to its name. + /// + /// + /// If multiple values in the enum map to the same integer, it is undefined which will be returned. + /// If the value is not a named enum element, an exception is thrown, even if the enum is + /// decorated with . + /// + /// The value to convert. + /// The name of the value. + /// The given value is not a named value within the enum. + public override object ToFirestore(T value) { + if (s_valueToNameMap.TryGetValue(value, out var result)) { + return result; + } else { + throw new ArgumentException(String.Format("Unknown value '{0}' for enum {1}", value, typeof(T).FullName)); + } + } + } +} diff --git a/firestore/src/FirestoreException.cs b/firestore/src/FirestoreException.cs new file mode 100644 index 000000000..c1fd042ab --- /dev/null +++ b/firestore/src/FirestoreException.cs @@ -0,0 +1,63 @@ +// Copyright 2019, Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; + +namespace Firebase.Firestore { + + /// + /// A class of exceptions thrown by Cloud Firestore. + /// + public sealed class FirestoreException : Exception { + + /// + /// Initializes a new FirestoreException, with the given error code. + /// + public FirestoreException(FirestoreError errorCode) { + ErrorCode = errorCode; + } + + /// + /// Initializes a new FirestoreException, with the given error code and message. + /// + public FirestoreException(FirestoreError errorCode, string message) : base(message) { + ErrorCode = errorCode; + } + + /// + /// Initializes a new FirestoreException, with the given error code, original exception + /// and message. + /// + internal FirestoreException(FirestoreError errorCode, Exception exception, string message) + : base(message, exception) { + ErrorCode = errorCode; + } + + /// + /// Initializes a new FirestoreException, with the given error code and message. + /// + /// + /// This constructor exists exclusively for use by SWIG-generated code; it should not be used + /// for any other purpose due to the lack of type safety of the errorCode argument. + /// + internal FirestoreException(int errorCode, string message) : this((FirestoreError)errorCode, message) { + } + + /// + /// The error code describing the error. + /// + public FirestoreError ErrorCode { get; private set; } + } + +} diff --git a/firestore/src/FirestorePropertyAttribute.cs b/firestore/src/FirestorePropertyAttribute.cs new file mode 100644 index 000000000..947f88a8e --- /dev/null +++ b/firestore/src/FirestorePropertyAttribute.cs @@ -0,0 +1,48 @@ +// Copyright 2017, Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; + +namespace Firebase.Firestore { + /// + /// Attribute indicating that a property should be included in Firestore conversions. + /// + [AttributeUsage(AttributeTargets.Property)] + public sealed class FirestorePropertyAttribute : Attribute { + /// + /// The name to use within the Firestore document. If not set, the name + /// of the property is used directly. + /// + public string Name { get; set; } + + /// + /// A custom converter type to use for the attributed property. + /// + public System.Type ConverterType { get; set; } + + /// + /// Creates an instance with no specified name. + /// + public FirestorePropertyAttribute() { + } + + /// + /// Creates an instance with the specified name. + /// + /// The name to use within the Firestore document. + public FirestorePropertyAttribute(string name) { + Name = name; + } + } +} diff --git a/firestore/src/GeoPoint.cs b/firestore/src/GeoPoint.cs new file mode 100644 index 000000000..bcfcb8c1f --- /dev/null +++ b/firestore/src/GeoPoint.cs @@ -0,0 +1,124 @@ +// Copyright 2017, Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License.using System; + +using Firebase.Firestore.Internal; +using System; +using System.Runtime.InteropServices; + +namespace Firebase.Firestore { + /// + /// Immutable struct representing a geographic location in Cloud Firestore. + /// + [StructLayout(LayoutKind.Explicit)] + public struct GeoPoint : IEquatable { + // Specify field offsets explicitly to work around .NET Core 1.0 bug. (Trying to find a + // reference issue to make sure the fix is okay, and isn't needed elsewhere.) We can't currently + // apply a field attribute to an automatically implemented property, so it's all explicit now. + [field: FieldOffset(0)] + private readonly double _latitude; + [field: FieldOffset(8)] + private readonly double _longitude; + + /// + /// The latitude, in degrees, in the range -90 to 90 inclusive. + /// + public double Latitude { + // Cannot use => to autogen property as not supported by the google3 toolchain: + // Automatically implemented property `Firebase.Firestore.GeoPoint.Latitude` cannot be used + // inside a type with an explicit StructLayout attribute. + get { return _latitude; } + } + + /// + /// The longitude, in degrees, in the range -180 to 180 inclusive. + /// + public double Longitude { + // Cannot use => to autogen property as not supported by the google3 toolchain: + // Automatically implemented property `Firebase.Firestore.GeoPoint.Latitude` cannot be used + // inside a type with an explicit StructLayout attribute. + get { return _longitude; } + } + + /// + /// Creates a new value using the provided latitude and longitude values. + /// + /// The latitude of the point in degrees, between -90 and 90 + /// inclusive. + /// The longitude of the point in degrees, between -180 and 180 + /// inclusive. + public GeoPoint(double latitude, double longitude) { + if (Double.IsNaN(latitude) || latitude < -90 || latitude > 90) { + throw new ArgumentException("Latitude must be in the range of [-90, 90]"); + } + if (Double.IsNaN(longitude) || longitude < -180 || longitude > 180) { + throw new ArgumentException("Latitude must be in the range of [-180, 180]"); + } + _latitude = latitude; + _longitude = longitude; + } + + /// + public override bool Equals(object obj) { + return obj is GeoPoint && Equals((GeoPoint)obj); + } + + /// + public override int GetHashCode() { + // The hash implementation matches native client SDK but not the .net SDK. We believe it is a + // bug of .net SDK. + return Hash.DoubleBitwiseHash(_latitude) * 31 + Hash.DoubleBitwiseHash(_longitude); + } + + /// + public bool Equals(GeoPoint other) { + return Latitude == other.Latitude && Longitude == other.Longitude; + } + + /// + /// Operator overload to compare two GeoPoint values for equality. + /// + /// Left value to compare + /// Right value to compare + /// true if is equal to ; otherwise + /// false. + public static bool operator ==(GeoPoint lhs, GeoPoint rhs) { + return lhs.Equals(rhs); + } + + /// + /// Operator overload to compare two GeoPoint values for inequality. + /// + /// Left value to compare + /// Right value to compare + /// false if is equal to ; + /// otherwise true. + public static bool operator !=(GeoPoint lhs, GeoPoint rhs) { + return !lhs.Equals(rhs); + } + + /// + public override string ToString() { + // Cannot use $ to construct string as not supported by google3 toolchain. + return String.Format("GeoPoint:({0:g},{1:g})", _latitude, _longitude); + } + + internal GeoPointProxy ConvertToProxy() { + return new GeoPointProxy(_latitude, _longitude); + } + + internal static GeoPoint ConvertFromProxy(GeoPointProxy obj) { + return new GeoPoint(obj.latitude(), obj.longitude()); + } + } +} diff --git a/firestore/src/ListenerRegistration.cs b/firestore/src/ListenerRegistration.cs new file mode 100644 index 000000000..2fa82c7fd --- /dev/null +++ b/firestore/src/ListenerRegistration.cs @@ -0,0 +1,81 @@ +// Copyright 2019, Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Firebase.Firestore.Internal; +using System.Threading.Tasks; +using System; + +namespace Firebase.Firestore { + /// + /// Represents a listener for either document or query snapshots that is returned from + /// Listen methods. + /// + /// + /// The listener can be removed by calling . + /// + public sealed class ListenerRegistration : IDisposable { + private readonly ListenerRegistrationProxy _proxy; + + /// + /// A task that will complete when the listen operation finishes. + /// + /// + /// The task will finish in a state of TaskStatus.Faulted if any kind of exception + /// was thrown, including any non-retriable RPC exceptions. The task will finish in a state of + /// TaskStatus.RanToCompletion" if the listener stopped gracefully. + /// + public Task ListenerTask { + get { return taskSource.Task; } + } + + internal readonly int callbackId; + internal readonly TaskCompletionSource taskSource; + private IListenerRegistrationMap owner; + + internal ListenerRegistration(IListenerRegistrationMap owner, int callbackId, TaskCompletionSource tcs, ListenerRegistrationProxy proxy) { + this.owner = Util.NotNull(owner); + this.callbackId = callbackId; + + _proxy = Util.NotNull(proxy); + taskSource = Util.NotNull(tcs); + } + + /// + /// Removes the listener being tracked by this ListenerRegistration. + /// + /// + /// If is not completed, then it will transition to the + /// TaskStatus.RanToCompletion" state. After the initial call of this method, + /// subsequent calls have no effect. + /// + public void Stop() { + _proxy.Remove(); + taskSource.TrySetResult(null); + + owner.Unregister(callbackId); + } + + /// + /// Calls the method. + /// + /// + /// Note that this method is *not* invoked by the destructor. This is intentional as this class + /// does not handle unmanaged resources. The usage of the interface + /// does however enable using this class with external reactive libraries that expect it. + /// + public void Dispose() { + Stop(); + } + } +} diff --git a/firestore/src/ListenerRegistrationMap.cs b/firestore/src/ListenerRegistrationMap.cs new file mode 100644 index 000000000..4bc35fbb4 --- /dev/null +++ b/firestore/src/ListenerRegistrationMap.cs @@ -0,0 +1,110 @@ +// Copyright 2020, Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Firebase.Firestore.Internal; +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using System.Runtime.InteropServices; + +namespace Firebase.Firestore { + /// + /// An helper interface to pass around an instance of ListenerRegistrationMap without + /// needing to know the generic argument for a given instance. + /// + internal interface IListenerRegistrationMap { + void Unregister(int uid); + } + + /// + /// A thread safe helper class that tracks callbacks and provides a unique id to reference + /// the registation of each one. This is meant to be used by classes that interop with C++ + /// that expose listeners such as DocumentReference, CollectionReference, etc. + /// + internal class ListenerRegistrationMap : IListenerRegistrationMap where T : class { + private int uidGenerator = 0; + private Dictionary> callbacks = new Dictionary>(); + + public ListenerRegistrationMap() { + AssertGenericArgumentIsDelegate(); + } + + private void AssertGenericArgumentIsDelegate() { + // C# doesn't let you specify Delegate as a generic constraint. + // It can only be verified at runtime. + if (!typeof(T).IsSubclassOf(typeof(Delegate))) { + throw new ArgumentOutOfRangeException("The generic argument for the " + + GetType().Name + " must be a delegate. This is an error " + + "in your code."); + } + } + + /// + /// Registers a callback and returns a unique id that can be used to look it back up later. + /// + public int Register(object owner, T callback) { + lock (callbacks) { + int uid = uidGenerator++; + callbacks[uid] = new Tuple(owner, callback); + return uid; + } + } + + /// + /// Looks up a callback based on a unique id. + /// + public bool TryGetCallback(int uid, out T callback) { + lock (callbacks) { + Tuple item; + + if (!callbacks.TryGetValue(uid, out item)) { + callback = null; + return false; + } else { + callback = item.Item2; + return true; + } + } + } + + /// + /// Unregisters a callback based on its id. Passing an id that does not exist has no effect. + /// + public void Unregister(int uid) { + lock (callbacks) { + callbacks.Remove(uid); + } + } + + /// + /// Clears all callbacks associated with a provided owner. + /// + public void ClearCallbacksForOwner(object owner) { + lock (callbacks) { + var uidsForOwner = new List(); + + foreach (var item in callbacks) { + if (Equals(owner, item.Value.Item1)) { + uidsForOwner.Add(item.Key); + } + } + + foreach (int uid in uidsForOwner) { + Unregister(uid); + } + } + } + } +} diff --git a/firestore/src/LoadBundleTaskProgress.cs b/firestore/src/LoadBundleTaskProgress.cs new file mode 100644 index 000000000..03939d946 --- /dev/null +++ b/firestore/src/LoadBundleTaskProgress.cs @@ -0,0 +1,86 @@ +using System; + +namespace Firebase.Firestore { + public sealed class LoadBundleTaskProgress : System.EventArgs { + /// + /// Creates a new instance of the class. This is to support testing against progress + /// updates. + /// + public LoadBundleTaskProgress(int documentsLoaded, int totalDocuments, long bytesLoaded, + long totalBytes, LoadBundleTaskState state) { + DocumentsLoaded = documentsLoaded; + TotalDocuments = totalDocuments; + BytesLoaded = bytesLoaded; + TotalBytes = totalBytes; + State = state; + } + + internal LoadBundleTaskProgress(LoadBundleTaskProgressProxy proxy) { + DocumentsLoaded = proxy.documents_loaded(); + TotalDocuments = proxy.total_documents(); + BytesLoaded = proxy.bytes_loaded(); + TotalBytes = proxy.total_bytes(); + switch (proxy.state()) { + case LoadBundleTaskProgressProxy.State.Error: + State = LoadBundleTaskProgress.LoadBundleTaskState.Error; + break; + case LoadBundleTaskProgressProxy.State.Success: + State = LoadBundleTaskProgress.LoadBundleTaskState.Success; + break; + case LoadBundleTaskProgressProxy.State.InProgress: + State = LoadBundleTaskProgress.LoadBundleTaskState.InProgress; + break; + } + } + + /// + /// Represents the state of bundle loading tasks. + /// + /// + /// Both and + /// are final states: the task will fail or complete and there will be no more updates after + /// they are reported. + /// + public enum LoadBundleTaskState { Error, InProgress, Success } + + /// + /// The number of documents that have been loaded. + /// + public int DocumentsLoaded { get; private set; } = 0; + + /// + /// The total number of documents in the bundle. Zero if the bundle failed to parse. + /// + public int TotalDocuments { get; private set; } = 0; + + /// + /// The number of bytes that have been loaded. + /// + public long BytesLoaded { get; private set; } = 0; + + /// + /// The total number of bytes in the bundle. Zero if the bundle failed to parse. + /// + public long TotalBytes { get; private set; } = 0; + + /// + /// The current state of the loading progress. + /// + public LoadBundleTaskState State { get; private set; } = LoadBundleTaskState.InProgress; + + public override bool Equals(Object obj) { + var other = obj as LoadBundleTaskProgress; + if (other == null) { + return false; + } + return (DocumentsLoaded == other.DocumentsLoaded) && + (TotalDocuments == other.TotalDocuments) && (BytesLoaded == other.BytesLoaded) && + (TotalBytes == other.TotalBytes) && (State == other.State); + } + + public override int GetHashCode() { + return DocumentsLoaded.GetHashCode() * 31 + TotalDocuments.GetHashCode() * 23 + + BytesLoaded.GetHashCode() * 17 + TotalBytes.GetHashCode() * 13 + State.GetHashCode(); + } + } +} diff --git a/firestore/src/MonoPInvokeCallbackAttribute.cs b/firestore/src/MonoPInvokeCallbackAttribute.cs new file mode 100644 index 000000000..16e5ba965 --- /dev/null +++ b/firestore/src/MonoPInvokeCallbackAttribute.cs @@ -0,0 +1,25 @@ +// Copyright 2019, Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; + +namespace Firebase.Firestore { + // This attribute is used on static class functions to enable Mono's Ahead of + // Time Compiler to generate the code necessary to support native C/C++ code + // callbacks into C# code. + [System.AttributeUsage(System.AttributeTargets.Method)] + internal sealed class MonoPInvokeCallbackAttribute : System.Attribute { + public MonoPInvokeCallbackAttribute(System.Type t) { } + } +} diff --git a/firestore/src/Query.cs b/firestore/src/Query.cs new file mode 100644 index 000000000..85c242ae2 --- /dev/null +++ b/firestore/src/Query.cs @@ -0,0 +1,750 @@ +// Copyright 2017, Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Firebase.Firestore.Internal; +using Firebase.Platform; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Firebase.Firestore { + using QuerySnapshotCallbackMap = + ListenerRegistrationMap>; + + /// + /// A query which you can read or listen to. You can also construct refined Query objects + /// by adding filters, ordering, and other constraints. + /// + /// + /// derives from this class as a "return-all" query against the + /// collection it refers to. + /// + public class Query { + // _proxy could be either QueryProxy or CollectionReferenceProxy type. + internal readonly QueryProxy _proxy; + private readonly FirebaseFirestore _firestore; + + internal Query(QueryProxy proxy, FirebaseFirestore firestore) { + _proxy = Util.NotNull(proxy); + _firestore = Util.NotNull(firestore); + } + + internal static void ClearCallbacksForOwner(FirebaseFirestore owner) { + snapshotListenerCallbacks.ClearCallbacksForOwner(owner); + } + + /// + /// The Cloud Firestore instance associated with this query. + /// + public FirebaseFirestore Firestore { + get { + return _firestore; + } + } + + /// + /// Creates and returns a new Query with the additional filter that documents must + /// contain the specified field and the value should be equal to the specified value. + /// + /// The dot-separated field path to filter on. Must not be null + /// or empty. + /// The value to compare in the filter. + /// A new query based on the current one, but with the additional filter applied. + /// + public Query WhereEqualTo(string fieldPath, object value) { + Preconditions.CheckNotNullOrEmpty(fieldPath, nameof(fieldPath)); + return new Query(_proxy.WhereEqualTo(fieldPath, ValueSerializer.Serialize(SerializationContext.Default, value)), Firestore); + } + + /// + /// Creates and returns a new Query with the additional filter that documents must + /// contain the specified field and the value should be equal to the specified value. + /// + /// The field path to filter on. Must not be null. + /// The value to compare in the filter. + /// A new query based on the current one, but with the additional filter applied. + /// + public Query WhereEqualTo(FieldPath fieldPath, object value) { + Preconditions.CheckNotNull(fieldPath, nameof(fieldPath)); + return new Query(_proxy.WhereEqualTo(fieldPath.ConvertToProxy(), + ValueSerializer.Serialize(SerializationContext.Default, value)), Firestore); + } + + /// + /// Creates and returns a new Query with the additional filter that documents must + /// contain the specified field and the value should not equal the specified value. + /// + /// A Query can have only one WhereNotEqualTo() filter, and it cannot be + /// combined with WhereNotIn(). + /// + /// The dot-separated field path to filter on. Must not be null + /// or empty. + /// The value to compare in the filter. + /// A new query based on the current one, but with the additional filter applied. + /// + public Query WhereNotEqualTo(string fieldPath, object value) { + Preconditions.CheckNotNullOrEmpty(fieldPath, nameof(fieldPath)); + return new Query(_proxy.WhereNotEqualTo(fieldPath, ValueSerializer.Serialize( + SerializationContext.Default, value)), + Firestore); + } + + /// + /// Creates and returns a new Query with the additional filter that documents must + /// contain the specified field and the value should not equal the specified value. + /// + /// A Query can have only one WhereNotEqualTo() filter, and it cannot be + /// combined with WhereNotIn(). + /// + /// The field path to filter on. Must not be null. + /// The value to compare in the filter. + /// A new query based on the current one, but with the additional filter applied. + /// + public Query WhereNotEqualTo(FieldPath fieldPath, object value) { + Preconditions.CheckNotNull(fieldPath, nameof(fieldPath)); + return new Query( + _proxy.WhereNotEqualTo(fieldPath.ConvertToProxy(), + ValueSerializer.Serialize(SerializationContext.Default, value)), + Firestore); + } + + /// + /// Creates and returns a new Query with the additional filter that documents must + /// contain the specified field and the value should be less than the specified value. + /// + /// The dot-separated field path to filter on. Must not be null + /// or empty. + /// The value to compare in the filter. + /// A new query based on the current one, but with the additional filter applied. + /// + public Query WhereLessThan(string fieldPath, object value) { + Preconditions.CheckNotNullOrEmpty(fieldPath, nameof(fieldPath)); + return new Query(_proxy.WhereLessThan(fieldPath, ValueSerializer.Serialize(SerializationContext.Default, value)), Firestore); + } + + /// + /// Creates and returns a new Query with the additional filter that documents must + /// contain the specified field and the value should be less than the specified value. + /// + /// The field path to filter on. Must not be null. + /// The value to compare in the filter. + /// A new query based on the current one, but with the additional filter applied. + /// + public Query WhereLessThan(FieldPath fieldPath, object value) { + Preconditions.CheckNotNull(fieldPath, nameof(fieldPath)); + return new Query(_proxy.WhereLessThan(fieldPath.ConvertToProxy(), + ValueSerializer.Serialize(SerializationContext.Default, value)), Firestore); + } + + /// + /// Creates and returns a new Query with the additional filter that documents must + /// contain the specified field and the value should be less than or equal to the specified + /// value. + /// + /// The dot-separated field path to filter on. Must not be null + /// or empty. + /// The value to compare in the filter. + /// A new query based on the current one, but with the additional filter applied. + /// + public Query WhereLessThanOrEqualTo(string fieldPath, object value) { + Preconditions.CheckNotNullOrEmpty(fieldPath, nameof(fieldPath)); + return new Query(_proxy.WhereLessThanOrEqualTo(fieldPath, ValueSerializer.Serialize(SerializationContext.Default, value)), Firestore); + } + + /// + /// Creates and returns a new Query with the additional filter that documents must + /// contain the specified field and the value should be less than or equal to the specified + /// value. + /// + /// The field path to filter on. Must not be null. + /// The value to compare in the filter. + /// A new query based on the current one, but with the additional filter applied. + /// + public Query WhereLessThanOrEqualTo(FieldPath fieldPath, object value) { + Preconditions.CheckNotNull(fieldPath, nameof(fieldPath)); + return new Query(_proxy.WhereLessThanOrEqualTo(fieldPath.ConvertToProxy(), + ValueSerializer.Serialize(SerializationContext.Default, value)), Firestore); + } + + /// + /// Creates and returns a new Query with the additional filter that documents must + /// contain the specified field and the value should be greater than the specified value. + /// + /// The dot-separated field path to filter on. Must not be null + /// or empty. + /// The value to compare in the filter. + /// A new query based on the current one, but with the additional filter applied. + /// + public Query WhereGreaterThan(string fieldPath, object value) { + Preconditions.CheckNotNullOrEmpty(fieldPath, nameof(fieldPath)); + return new Query(_proxy.WhereGreaterThan(fieldPath, ValueSerializer.Serialize(SerializationContext.Default, value)), Firestore); + } + + /// + /// Creates and returns a new Query with the additional filter that documents must + /// contain the specified field and the value should be greater than the specified value. + /// + /// The field path to filter on. Must not be null. + /// The value to compare in the filter. + /// A new query based on the current one, but with the additional filter applied. + /// + public Query WhereGreaterThan(FieldPath fieldPath, object value) { + Preconditions.CheckNotNull(fieldPath, nameof(fieldPath)); + return new Query(_proxy.WhereGreaterThan(fieldPath.ConvertToProxy(), + ValueSerializer.Serialize(SerializationContext.Default, value)), Firestore); + } + + /// + /// Creates and returns a new Query with the additional filter that documents must + /// contain the specified field and the value should be greater than or equal to the specified + /// value. + /// + /// The dot-separated field path to filter on. Must not be null + /// or empty. + /// The value to compare in the filter. + /// A new query based on the current one, but with the additional filter applied. + /// + public Query WhereGreaterThanOrEqualTo(string fieldPath, object value) { + Preconditions.CheckNotNullOrEmpty(fieldPath, nameof(fieldPath)); + return new Query(_proxy.WhereGreaterThanOrEqualTo(fieldPath, ValueSerializer.Serialize(SerializationContext.Default, value)), Firestore); + } + + /// + /// Creates and returns a new Query with the additional filter that documents must + /// contain the specified field and the value should be greater than or equal to the specified + /// value. + /// + /// The field path to filter on. Must not be null. + /// The value to compare in the filter. + /// A new query based on the current one, but with the additional filter applied. + /// + public Query WhereGreaterThanOrEqualTo(FieldPath fieldPath, object value) { + Preconditions.CheckNotNull(fieldPath, nameof(fieldPath)); + return new Query(_proxy.WhereGreaterThanOrEqualTo(fieldPath.ConvertToProxy(), + ValueSerializer.Serialize(SerializationContext.Default, value)), Firestore); + } + + /// + /// Creates and returns a new Query with the additional filter that documents must + /// contain the specified field, the value must be an array, and that the array must contain + /// the provided value. + /// + /// A Query can have only one WhereArrayContains() filter and it cannot be combined + /// with WhereArrayContainsAny(). + /// + /// The name of the fields containing an array to search + /// The value that must be contained in the array. + /// A new query based on the current one, but with the additional filter applied. + /// + public Query WhereArrayContains(FieldPath fieldPath, object value) { + Preconditions.CheckNotNull(fieldPath, nameof(fieldPath)); + return new Query(_proxy.WhereArrayContains(fieldPath.ConvertToProxy(), + ValueSerializer.Serialize(SerializationContext.Default, value)), Firestore); + } + + /// + /// Creates and returns a new Query with the additional filter that documents must + /// contain the specified field, the value must be an array, and that the array must contain + /// the provided value. + /// + /// A Query can have only one WhereArrayContains() filter and it cannot be + /// combined with WhereArrayContainsAny(). + /// + /// The dot-separated field path to filter on. Must not be null + /// or empty. + /// The value that must be contained in the array. + /// A new query based on the current one, but with the additional filter applied. + /// + public Query WhereArrayContains(string fieldPath, object value) { + Preconditions.CheckNotNullOrEmpty(fieldPath, nameof(fieldPath)); + return new Query(_proxy.WhereArrayContains(fieldPath, + ValueSerializer.Serialize(SerializationContext.Default, value)), Firestore); + } + + /// + /// Creates and returns a new Query with the additional filter that documents must contain + /// the specified field, the value must be an array, and that the array must contain at least one + /// value from the provided list. + /// + /// A Query can have only one WhereArrayContainsAny() filter and it cannot be + /// combined with WhereArrayContains() or WhereIn(). + /// + /// The name of the fields containing an array to search. + /// The list that contains the values to match. + /// A new query based on the current one, but with the additional filter applied. + /// + public Query WhereArrayContainsAny(FieldPath fieldPath, IEnumerable values) { + Preconditions.CheckNotNull(fieldPath, nameof(fieldPath)); + Preconditions.CheckNotNull(values, nameof(values)); + var array = ValueSerializer.Serialize(SerializationContext.Default, values); + var query = FirestoreCpp.QueryWhereArrayContainsAny(_proxy, fieldPath.ConvertToProxy(), array); + return new Query(query, Firestore); + } + + /// + /// Creates and returns a new Query with the additional filter that documents must contain + /// the specified field, the value must be an array, and that the array must contain at least one + /// value from the provided list. + /// + /// A Query can have only one WhereArrayContainsAny() filter and it cannot be + /// combined with WhereArrayContains() or WhereIn(). + /// + /// The dot-separated field path to filter on. Must not be null + /// or empty. + /// The list that contains the values to match. + /// A new query based on the current one, but with the additional filter applied. + /// + public Query WhereArrayContainsAny(string fieldPath, IEnumerable values) { + Preconditions.CheckNotNullOrEmpty(fieldPath, nameof(fieldPath)); + Preconditions.CheckNotNull(values, nameof(values)); + var array = ValueSerializer.Serialize(SerializationContext.Default, values); + var query = FirestoreCpp.QueryWhereArrayContainsAny(_proxy, fieldPath, array); + return new Query(query, Firestore); + } + + /// + /// Creates and returns a new Query with the additional filter that documents must + /// contain the specified field and the value must equal one of the values from the + /// provided list. + /// + /// A Query can have only one WhereIn() filter and it cannot be combined + /// with WhereArrayContainsAny(). + /// + /// The name of the fields containing an array to search. + /// The list that contains the values to match. + /// A new query based on the current one, but with the additional filter applied. + /// + public Query WhereIn(FieldPath fieldPath, IEnumerable values) { + Preconditions.CheckNotNull(fieldPath, nameof(fieldPath)); + Preconditions.CheckNotNull(values, nameof(values)); + var array = ValueSerializer.Serialize(SerializationContext.Default, values); + var query = FirestoreCpp.QueryWhereIn(_proxy, fieldPath.ConvertToProxy(), array); + return new Query(query, Firestore); + } + + /// + /// Creates and returns a new Query with the additional filter that documents must + /// contain the specified field and the value must equal one of the values from the + /// provided list. + /// + /// A Query can have only one WhereIn() filter and it cannot be combined + /// with WhereArrayContainsAny(). + /// + /// The dot-separated field path to filter on. Must not be null + /// or empty. + /// The list that contains the values to match. + /// A new query based on the current one, but with the additional filter applied. + /// + public Query WhereIn(string fieldPath, IEnumerable values) { + Preconditions.CheckNotNullOrEmpty(fieldPath, nameof(fieldPath)); + Preconditions.CheckNotNull(values, nameof(values)); + var array = ValueSerializer.Serialize(SerializationContext.Default, values); + var query = FirestoreCpp.QueryWhereIn(_proxy, fieldPath, array); + return new Query(query, Firestore); + } + + /// + /// Creates and returns a new Query with the additional filter that documents must + /// contain the specified field and the value must not equal any value from the + /// provided list. + /// + /// One special case is that WhereNotIn cannot match null values. To query for + /// documents where a field exists and is null, use WhereNotEqualTo, which can handle + /// this special case. + /// + /// A Query can have only one WhereNotIn() filter, and it cannot be + /// combined with WhereArrayContains(), WhereArrayContainsAny(), + /// WhereIn(), or WhereNotEqualTo(). + /// + /// The name of the fields containing an array to search. + /// The list that contains the values to match. + /// A new query based on the current one, but with the additional filter applied. + /// + public Query WhereNotIn(FieldPath fieldPath, List values) { + Preconditions.CheckNotNull(fieldPath, nameof(fieldPath)); + Preconditions.CheckNotNull(values, nameof(values)); + var array = ValueSerializer.Serialize(SerializationContext.Default, values); + var query = FirestoreCpp.QueryWhereNotIn(_proxy, fieldPath.ConvertToProxy(), array); + return new Query(query, Firestore); + } + + /// + /// Creates and returns a new Query with the additional filter that documents must + /// contain the specified field and the value must not equal any value from the + /// provided list. + /// + /// One special case is that WhereNotIn cannot match null values. To query for + /// documents where a field exists and is null, use WhereNotEqualTo, which can handle + /// this special case. + /// + /// A Query can have only one WhereNotIn() filter, and it cannot be + /// combined with WhereArrayContains(), WhereArrayContainsAny(), + /// WhereIn(), or WhereNotEqualTo(). + /// + /// The name of the fields containing an array to search. + /// The list that contains the values to match. + /// A new query based on the current one, but with the additional filter applied. + /// + public Query WhereNotIn(string fieldPath, List values) { + Preconditions.CheckNotNullOrEmpty(fieldPath, nameof(fieldPath)); + Preconditions.CheckNotNull(values, nameof(values)); + var array = ValueSerializer.Serialize(SerializationContext.Default, values); + var query = FirestoreCpp.QueryWhereNotIn(_proxy, fieldPath, array); + return new Query(query, Firestore); + } + + /// + /// Creates and returns a new Query that's additionally sorted by the specified field. + /// + /// + /// Unlike OrderBy in LINQ, this call makes each additional ordering subordinate to the + /// preceding ones. This means that query.OrderBy("foo").OrderBy("bar") in Cloud + /// Firestore is similar to query.OrderBy(x => x.Foo).ThenBy(x => x.Bar) in LINQ. + /// + /// + /// This method cannot be called after a start/end cursor has been specified with + /// , , + /// or or + /// other overloads. + /// + /// The dot-separated field path to order by. Must not be null or + /// empty. + /// A new query based on the current one, but with the additional specified ordering + /// applied. + public Query OrderBy(string fieldPath) { + Preconditions.CheckNotNullOrEmpty(fieldPath, nameof(fieldPath)); + return new Query(_proxy.OrderBy(fieldPath), Firestore); + } + + /// + /// Creates and returns a new Query that's additionally sorted by the specified field in + /// descending order. + /// + /// + /// Unlike OrderByDescending in LINQ, this call makes each additional ordering subordinate + /// to the preceding ones. This means that + /// query.OrderByDescending("foo").OrderByDescending("bar") in Cloud Firestore is similar + /// to query.OrderByDescending(x => x.Foo).ThenByDescending(x => x.Bar) in LINQ. + /// + /// This method cannot be called after a start/end cursor has been specified with + /// , , + /// or or + /// other overloads. + /// + /// The dot-separated field path to order by. Must not be null or + /// empty. + /// A new query based on the current one, but with the additional specified ordering + /// applied. + public Query OrderByDescending(string fieldPath) { + Preconditions.CheckNotNullOrEmpty(fieldPath, nameof(fieldPath)); + return new Query(_proxy.OrderBy(fieldPath, QueryProxy.Direction.Descending), Firestore); + } + + /// + /// Creates and returns a new Query that's additionally sorted by the specified field. + /// + /// + /// Unlike OrderBy in LINQ, this call makes each additional ordering subordinate to the + /// preceding ones. This means that query.OrderBy("foo").OrderBy("bar") in Cloud + /// Firestore is similar to query.OrderBy(x => x.Foo).ThenBy(x => x.Bar) in LINQ. + /// + /// + /// This method cannot be called after a start/end cursor has been specified with + /// , , + /// or or + /// other overloads. + /// + /// The field path to order by. Must not be null. + /// A new query based on the current one, but with the additional specified ordering + /// applied. + public Query OrderBy(FieldPath fieldPath) { + Preconditions.CheckNotNull(fieldPath, nameof(fieldPath)); + return new Query(_proxy.OrderBy(fieldPath.ConvertToProxy()), Firestore); + } + + /// + /// Creates and returns a new Query that's additionally sorted by the specified field in + /// descending order. + /// + /// + /// Unlike OrderByDescending in LINQ, this call makes each additional ordering subordinate + /// to the preceding ones. This means that + /// query.OrderByDescending("foo").OrderByDescending("bar") in Cloud Firestore is similar + /// to query.OrderByDescending(x => x.Foo).ThenByDescending(x => x.Bar) in LINQ. + /// + /// This method cannot be called after a start/end cursor has been specified with + /// , , + /// or or + /// other overloads. + /// + /// The field path to order by. Must not be null. + /// A new query based on the current one, but with the additional specified ordering + /// applied. + public Query OrderByDescending(FieldPath fieldPath) { + Preconditions.CheckNotNull(fieldPath, nameof(fieldPath)); + return new Query(_proxy.OrderBy(fieldPath.ConvertToProxy(), + QueryProxy.Direction.Descending), Firestore); + } + + /// + /// Creates and returns a new Query that only returns the last matching documents up to the + /// specified number. + /// + /// + /// This call replaces any previously-specified limit in the query. + /// + /// The maximum number of items to return. Must be greater than 0. + /// A new query based on the current one, but with the specified limit applied. + /// + public Query Limit(int limit) { + return new Query(_proxy.Limit(limit), Firestore); + } + + /// + /// Creates and returns a new Query that only returns the last matching documents up to the + /// specified number. + /// + /// + /// You must specify at least one OrderBy clause for LimitToLast queries, + /// otherwise an exception will be thrown during execution. + /// + /// This call replaces any previously-specified limit in the query. + /// + /// The maximum number of items to return. Must be greater than 0. + /// A new query based on the current one, but with the specified limit applied. + /// + public Query LimitToLast(int limit) { + return new Query(_proxy.LimitToLast(limit), Firestore); + } + + /// + /// Creates and returns a new Query that starts at the provided document (inclusive). The + /// starting position is relative to the order of the query. The document must contain all of + /// the fields provided in order-by clauses of the query. + /// + /// + /// This call replaces any previously specified start position in the query. + /// + /// The snapshot of the document to start at. + /// A new query based on the current one, but with the specified start position. + public Query StartAt(DocumentSnapshot snapshot) { + Preconditions.CheckNotNull(snapshot, nameof(snapshot)); + return new Query(_proxy.StartAt(snapshot.Proxy), Firestore); + } + + /// + /// Creates and returns a new Query that starts at the provided fields relative to the + /// order of the query. The order of the field values must match the order of the order-by + /// clauses of the query. + /// + /// + /// This call replaces any previously specified start position in the query. + /// + /// The field values. The fieldValues array must not be + /// null or empty (though elements of the array may be), or have more values than query + /// has orderings. + /// A new query based on the current one, but with the specified start position. + /// + public Query StartAt(params object[] fieldValues) { + Preconditions.CheckNotNull(fieldValues, nameof(fieldValues)); + var array = ValueSerializer.Serialize(SerializationContext.Default, fieldValues); + var query = FirestoreCpp.QueryStartAt(_proxy, array); + return new Query(query, Firestore); + } + + /// + /// Creates and returns a new Query that starts after the provided document (exclusive). + /// The starting position is relative to the order of the query. The document must contain all + /// of the fields provided in the order-by clauses of the query. + /// + /// + /// This call replaces any previously specified start position in the query. + /// + /// The snapshot of the document to start after. + /// A new query based on the current one, but with the specified start position. + /// + public Query StartAfter(DocumentSnapshot snapshot) { + Preconditions.CheckNotNull(snapshot, nameof(snapshot)); + return new Query(_proxy.StartAfter(snapshot.Proxy), Firestore); + } + + /// + /// Creates and returns a new Query that starts after the provided fields relative to the + /// order of the query. The order of the field values must match the order of the order-by + /// clauses of the query. + /// + /// + /// This call replaces any previously specified start position in the query. + /// + /// The field values. The fieldValues array must not be + /// null or empty (though elements of the array may be), or have more values than query + /// has orderings. + /// A new query based on the current one, but with the specified start position. + /// + public Query StartAfter(params object[] fieldValues) { + Preconditions.CheckNotNull(fieldValues, nameof(fieldValues)); + var array = ValueSerializer.Serialize(SerializationContext.Default, fieldValues); + var query = FirestoreCpp.QueryStartAfter(_proxy, array); + return new Query(query, Firestore); + } + + /// + /// Creates and returns a new Query that ends before the provided document (exclusive). + /// The end position is relative to the order of the query. The document must contain all of the + /// fields provided in the order-by clauses of the query. + /// + /// + /// This call replaces any previously specified end position in the query. + /// + /// The snapshot of the document to end before. + /// A new query based on the current one, but with the specified end position. + /// + public Query EndBefore(DocumentSnapshot snapshot) { + Preconditions.CheckNotNull(snapshot, nameof(snapshot)); + return new Query(_proxy.EndBefore(snapshot.Proxy), Firestore); + } + + /// + /// Creates and returns a new Query that ends before the provided fields relative to the + /// order of the query. The order of the field values must match the order of the order-by + /// clauses of the query. + /// + /// + /// This call replaces any previously specified end position in the query. + /// + /// The field values. The fieldValues array must not be + /// null or empty (though elements of the array may be), or have more values than query + /// has orderings. + /// A new query based on the current one, but with the specified end position. + /// + public Query EndBefore(params object[] fieldValues) { + Preconditions.CheckNotNull(fieldValues, nameof(fieldValues)); + var array = ValueSerializer.Serialize(SerializationContext.Default, fieldValues); + var query = FirestoreCpp.QueryEndBefore(_proxy, array); + return new Query(query, Firestore); + } + + /// + /// Creates and returns a new Query that ends at the provided document (inclusive). The + /// end position is relative to the order of the query. The document must contain all of the + /// fields provided in the order-by clauses of the query. + /// + /// + /// This call replaces any previously specified end position in the query. + /// + /// The snapshot of the document to end at. + /// A new query based on the current one, but with the specified end position. + /// + public Query EndAt(DocumentSnapshot snapshot) { + Preconditions.CheckNotNull(snapshot, nameof(snapshot)); + return new Query(_proxy.EndAt(snapshot.Proxy), Firestore); + } + + /// + /// Creates and returns a new Query that ends at the provided fields relative to the + /// order of the query. The order of the field values must match the order of the order-by + /// clauses of the query. + /// + /// + /// This call replaces any previously specified end position in the query. + /// + /// The field values. The fieldValues array must not be + /// null or empty (though elements of the array may be), or have more values than query + /// has orderings. + /// A new query based on the current one, but with the specified end position. + /// + public Query EndAt(params object[] fieldValues) { + Preconditions.CheckNotNull(fieldValues, nameof(fieldValues)); + var array = ValueSerializer.Serialize(SerializationContext.Default, fieldValues); + var query = FirestoreCpp.QueryEndAt(_proxy, array); + return new Query(query, Firestore); + } + + /// + /// Asynchronously executes the query and returns all matching documents as a + /// QuerySnapshot. + /// + /// + /// By default, GetSnapshotAsync attempts to provide up-to-date data when possible + /// by waiting for data from the server, but it may return cached data or fail if you are + /// offline and the server cannot be reached. This behavior can be altered via the source + /// parameter. + /// + /// indicates whether the results should be fetched from the cache only + /// (Source.Cache), the server only (Source.Server), or to attempt the server and + /// fall back to the cache (Source.Default). + /// A snapshot of documents matching the query. + public Task GetSnapshotAsync(Source source = Source.Default) { + return Util.MapResult(_proxy.GetAsync(source), taskResult => { + return new QuerySnapshot(taskResult, Firestore); + }); + } + + /// + /// Starts listening to changes to the query results described by this Query. + /// + /// The callback to invoke each time the query results change. Must not + /// be null. + /// A which may be used to stop listening + /// gracefully. + public ListenerRegistration Listen(Action callback) { + Preconditions.CheckNotNull(callback, nameof(callback)); + return Listen(MetadataChanges.Exclude, callback); + } + + /// + /// Starts listening to changes to the query results described by this Query. + /// + /// Indicates whether metadata-only changes (i.e. only + /// QuerySnapshot.Metadata changed) should trigger snapshot events. + /// The callback to invoke each time the query results change. Must not + /// be null. + /// A which may be used to stop listening + /// gracefully. + public ListenerRegistration Listen(MetadataChanges metadataChanges, Action callback) { + Preconditions.CheckNotNull(callback, nameof(callback)); + var tcs = new TaskCompletionSource(); + int uid = snapshotListenerCallbacks.Register(Firestore, (snapshotProxy, errorCode, + errorMessage) => { + if (errorCode != FirestoreError.Ok) { + tcs.SetException(new FirestoreException(errorCode, errorMessage)); + } else { + FirebaseHandler.RunOnMainThread(() => { + callback(new QuerySnapshot(snapshotProxy, Firestore)); + return null; + }); + } + }); + var listener = FirestoreCpp.AddQuerySnapshotListener(_proxy, metadataChanges, uid, + querySnapshotsHandler); + + return new ListenerRegistration(snapshotListenerCallbacks, uid, tcs, listener); + } + + private static QuerySnapshotCallbackMap snapshotListenerCallbacks = new QuerySnapshotCallbackMap(); + internal delegate void ListenerDelegate(int callbackId, IntPtr snapshotPtr, + FirestoreError errorCode, string errorMessage); + private static ListenerDelegate querySnapshotsHandler = new ListenerDelegate(QuerySnapshotsHandler); + + + [MonoPInvokeCallback(typeof(ListenerDelegate))] + private static void QuerySnapshotsHandler(int callbackId, IntPtr snapshotPtr, + FirestoreError errorCode, string errorMessage) { + Action callback; + if (snapshotListenerCallbacks.TryGetCallback(callbackId, out callback)) { + callback(new QuerySnapshotProxy(snapshotPtr, true), errorCode, errorMessage); + } + } + } +} diff --git a/firestore/src/QuerySnapshot.cs b/firestore/src/QuerySnapshot.cs new file mode 100644 index 000000000..f9100ae34 --- /dev/null +++ b/firestore/src/QuerySnapshot.cs @@ -0,0 +1,160 @@ +// Copyright 2017, Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Firebase.Firestore.Internal; +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Firebase.Firestore { + /// + /// A QuerySnapshot contains the results of a query. It can contain zero or more + /// objects. + /// + // TODO(zxu): change to IReadOnlyList type, which needs .net 4.5 while current tool-chain is .net 4.0. + public sealed class QuerySnapshot : IEnumerable { + private readonly QuerySnapshotProxy _proxy; + private readonly FirebaseFirestore _firestore; + + // We cache documents / changes so we only materialize each at most once. + private DocumentSnapshot[] _documentsCached; + + internal QuerySnapshot(QuerySnapshotProxy proxy, FirebaseFirestore firestore) { + _proxy = Util.NotNull(proxy); + _firestore = Util.NotNull(firestore); + _documentsCached = null; + } + + /// + /// The query producing this snapshot. + /// + public Query Query => new Query(_proxy.query(), _firestore); + + /// + /// The metadata for this QuerySnapshot. + /// + public SnapshotMetadata Metadata { + get { + return SnapshotMetadata.ConvertFromProxy(_proxy.metadata()); + } + } + + /// + /// The documents in the snapshot. + /// + // TODO(zxu): change to IReadOnlyList type, which needs .net 4.5 while current tool-chain is .net 4.0. + public IEnumerable Documents { + get { + LoadDocumentsCached(); + return _documentsCached; + } + } + + /// + /// Returns the document snapshot with the specified index within this query snapshot. + /// + /// The index of the document to return. + /// is less than 0, or + /// greater than or equal to . + /// The document snapshot with the specified index within this query snapshot. + /// + public DocumentSnapshot this[int index] { + get { + if (index < 0 || index >= Count) { + throw new ArgumentOutOfRangeException(); + } + + LoadDocumentsCached(); + return _documentsCached[index]; + } + } + + /// + /// Returns the number of documents in this query snapshot. + /// + /// The number of documents in this query snapshot. + public int Count { + get { + uint size = _proxy.size(); + if (size > Int32.MaxValue) { + throw new ArgumentException("number of documents is larger than " + Int32.MaxValue); + } + return (int)size; + } + } + + /// + /// The list of documents that changed since the last snapshot. If it's the first snapshot all + /// documents will be in the list as added changes. + /// + /// + /// Documents with changes only to their metadata will not be included. + /// + /// The list of document changes since the last snapshot. + // TODO(zxu): change to IReadOnlyList type, which needs .net 4.5 while current tool-chain is .net 4.0. + public IEnumerable GetChanges() { + return GetChanges(MetadataChanges.Exclude); + } + + /// + /// The list of documents that changed since the last snapshot. If it's the first snapshot all + /// documents will be in the list as added changes. + /// + /// Indicates whether metadata-only changes (i.e. only + /// changed) should be included. + /// The list of document changes since the last snapshot. + // TODO(zxu): change to IReadOnlyList type, which needs .net 4.5 while current tool-chain is .net 4.0. + public IEnumerable GetChanges(MetadataChanges metadataChanges) { + var changes = FirestoreCpp.QuerySnapshotDocumentChanges(_proxy, metadataChanges); + uint size = changes.Size(); + + if (size > Int32.MaxValue) { + throw new ArgumentException("Number of document changes is larger than " + Int32.MaxValue); + } + + DocumentChange[] result = new DocumentChange[(int)size]; + + for (int i = 0; i < (int)size; ++i) { + result[i] = new DocumentChange(changes.GetCopy((uint)i), _firestore); + } + + return result; + } + + /// + public IEnumerator GetEnumerator() { + LoadDocumentsCached(); + return ((IEnumerable)_documentsCached).GetEnumerator(); + } + + /// + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { + return GetEnumerator(); + } + + private void LoadDocumentsCached() { + if (_documentsCached != null) { + return; + } + + DocumentSnapshot[] documents = new DocumentSnapshot[Count]; + var result = FirestoreCpp.QuerySnapshotDocuments(_proxy); + for (int i = 0; i < Count; ++i) { + documents[i] = new DocumentSnapshot(result.GetCopy((uint)i), _firestore); + } + + _documentsCached = documents; + } + } +} diff --git a/firestore/src/SerializationContext.cs b/firestore/src/SerializationContext.cs new file mode 100644 index 000000000..9de47fcd8 --- /dev/null +++ b/firestore/src/SerializationContext.cs @@ -0,0 +1,43 @@ +// Copyright 2019, Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Firebase.Firestore.Converters; +using System.Collections.Generic; +using BclType = System.Type; + +namespace Firebase.Firestore { + /// + /// Provides context for serialization operations. This allows different converters to be used for different + /// databases, etc. Currently only used for custom converters (so Firestore-wide) but could potentially + /// have more information later. + /// + internal sealed class SerializationContext { + // Important note: if this class ever contains more state than just the converters, + // e.g. a reference to the Database, then WithWarningLogger will need to be adjusted accordingly. + + internal static SerializationContext Default { get; } = new SerializationContext(null); + + private readonly IDictionary _customConverters; + + internal SerializationContext(ConverterRegistry converterRegistry) { + _customConverters = converterRegistry?.ToConverterDictionary(); + } + + internal IFirestoreInternalConverter GetConverter(BclType targetType) { + IFirestoreInternalConverter customConverter = null; + _customConverters?.TryGetValue(targetType, out customConverter); + return customConverter ?? ConverterCache.GetConverter(targetType); + } + } +} diff --git a/firestore/src/ServerTimestampAttribute.cs b/firestore/src/ServerTimestampAttribute.cs new file mode 100644 index 000000000..a4b9eb430 --- /dev/null +++ b/firestore/src/ServerTimestampAttribute.cs @@ -0,0 +1,28 @@ +// Copyright 2018, Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; + +namespace Firebase.Firestore { + // TODO(unity-api, b/75824013): Revisit object mapping attributes. + + /// + /// Attribute indicating that a timestamp property should be populated with a server timestamp. + /// If such a property contains null when it is written, it will be replaced with a + /// server-generated timestamp. + /// + [AttributeUsage(AttributeTargets.Property)] + public sealed class ServerTimestampAttribute : Attribute { + } +} diff --git a/firestore/src/ServerTimestampBehavior.cs b/firestore/src/ServerTimestampBehavior.cs new file mode 100644 index 000000000..2a3c57b2b --- /dev/null +++ b/firestore/src/ServerTimestampBehavior.cs @@ -0,0 +1,54 @@ +// Copyright 2019 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +using System; + +namespace Firebase.Firestore { + internal static class ServerTimestampBehaviorConverter { + public static DocumentSnapshotProxy.ServerTimestampBehavior ConvertToProxy(this ServerTimestampBehavior stb) { + switch (stb) { + case ServerTimestampBehavior.None: + return DocumentSnapshotProxy.ServerTimestampBehavior.None; + case ServerTimestampBehavior.Estimate: + return DocumentSnapshotProxy.ServerTimestampBehavior.Estimate; + case ServerTimestampBehavior.Previous: + return DocumentSnapshotProxy.ServerTimestampBehavior.Previous; + } + throw new ArgumentException("Unsupported ServerTimestampBehavior:" + stb); + } + } + + /// + /// Controls the return value for server timestamps that have not yet been set to their final + /// value. + /// + public enum ServerTimestampBehavior { + /// + /// Return null for server timestamps that have not yet been set to their final value. + /// + None = 0, + + /// + /// Return local estimates for server timestamps that have not yet been set to their final + /// value. This estimate will likely differ from the final value and may cause these pending + /// values to change once the server result becomes available. + /// + Estimate = 1, + + /// + /// Return the previous value for server timestamps that have not yet been set to their final + /// value. + /// + Previous = 2 + } +} diff --git a/firestore/src/SetOptions.cs b/firestore/src/SetOptions.cs new file mode 100644 index 000000000..08c5afd8f --- /dev/null +++ b/firestore/src/SetOptions.cs @@ -0,0 +1,181 @@ +// Copyright 2017, Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Firebase.Firestore.Internal; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; + +namespace Firebase.Firestore { + /// + /// An options object that configures the behavior of SetAsync calls. + /// + /// + /// By providing one of the SetOptions objects returned by + /// and + /// the SetAsync calls in DocumentReference, WriteBatch and + /// Transaction can be configured to perform granular merges instead of overwriting the + /// target documents in their entirety. + /// + public sealed class SetOptions { + // Since there are a few combinations how SetOptions can be created, we + // simply convert it to internal type and store it instead of storing all + // the constructor parameters. + private readonly SetOptionsProxy _proxy; + + // Type, setType and fields exist only for the purpose to implement equality, ToString and + // GetHashCode. They are not from underlying C++ values, and will not be passed to C++. + private enum Type { Overwrite, Merge } + private Type setType = Type.Overwrite; + private FieldPath[] fields = {}; + + internal SetOptionsProxy Proxy { + get { + return _proxy; + } + } + + private SetOptions(SetOptionsProxy proxy) { + _proxy = Util.NotNull(proxy); + } + + /// + /// Returns an instance that overwrites the target object. This is the default when no options + /// are provided. + /// + public static SetOptions Overwrite { + get { + var options = new SetOptions(new SetOptionsProxy()); + options.fields = new FieldPath[] {}; + options.setType = Type.Overwrite; + return options; + } + } + + /// + /// Changes the behavior of SetAsync calls to only replace the values specified in its + /// documentData argument. Fields omitted from the SetAsync call will remain + /// untouched. + /// + public static SetOptions MergeAll { + get { + var options = new SetOptions(SetOptionsProxy.Merge()); + options.fields = new FieldPath[] {}; + options.setType = Type.Merge; + return options; + } + } + + /// + /// Changes the behavior of SetAsync calls to only replace the given fields. Any field + /// that is not specified in is ignored and remains untouched. + /// + /// + /// It is an error to pass a {@code SetOptions} object to a {@code set()} call that is missing a + /// value for any of the fields specified here. + /// + /// The fields to merge. An empty array is equivalent to using + /// . Must not be null or contain any empty or null + /// elements. Each field is treated as a dot-separated list of segments. + /// An instance that merges the given fields. + public static SetOptions MergeFields(params string[] fields) { + if (fields == null) { + throw new ArgumentException("fields must not be null"); + } + + FieldPath[] fieldPaths = + fields + .Select((fieldPath => { + if (String.IsNullOrEmpty(fieldPath)) { + throw new ArgumentException("fields must not contain any empty or null elements"); + } + return new FieldPath(fieldPath); + })) + .ToArray(); + + StringList fieldList = new StringList((ICollection)fields); + var options = new SetOptions(SetOptionsProxy.MergeFields(fieldList)); + + options.fields = fieldPaths; + options.setType = Type.Merge; + return options; + } + + /// + /// Changes the behavior of SetAsync calls to only replace the given fields. Any field + /// that is not specified in is ignored and remains untouched. + /// + /// + /// It is an error to pass a SetOptions object to a SetAsync call that is missing + /// a value for any of the fields specified here in its data argument. + /// + /// The fields to merge. An empty array is equivalent to using + /// . Must not be null or contain any null + /// elements. + /// An instance that merges the given fields. + public static SetOptions MergeFields(params FieldPath[] fields) { + var fieldVector = new FieldPathVector(); + foreach (FieldPath fieldPath in fields) { + fieldVector.PushBack(fieldPath.ConvertToProxy()); + } + var options = new SetOptions(FirestoreCpp.SetOptionsMergeFieldPaths(fieldVector)); + + options.fields = fields; + options.setType = Type.Merge; + return options; + } + + /// + public override string ToString() { + var stringBuilder = new StringBuilder(); + stringBuilder.Append("SetOptions{ Type=" + setType + ";"); + + if (setType == Type.Merge) { + stringBuilder.Append(" Fields=[ "); + stringBuilder.Append(String.Join(",", fields.Select((f) => f.ToString()).ToArray())); + stringBuilder.Append(" ]"); + } + + stringBuilder.Append("}"); + return stringBuilder.ToString(); + } + + /// + public override bool Equals(object obj) { + return Equals(obj as SetOptions); + } + + /// + public override int GetHashCode() { + unchecked { + var hashCode = 47893; + hashCode = (int)(hashCode * 755707 + setType); + // The contract ensures when type is not `Merge`, `fields` will be empty, so we + // return early here. + if (setType != Type.Merge) + return hashCode; + + return fields.Aggregate(hashCode, (current, f) => current * 755707 + f.GetHashCode()); + } + } + + private bool Equals(SetOptions other) { + return other != null && setType == other.setType && + Enumerable.SequenceEqual(fields, other.fields); + } + } +} diff --git a/firestore/src/SnapshotMetadata.cs b/firestore/src/SnapshotMetadata.cs new file mode 100644 index 000000000..b6e0e0ab2 --- /dev/null +++ b/firestore/src/SnapshotMetadata.cs @@ -0,0 +1,54 @@ +// Copyright 2017, Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Firebase.Firestore { + /// + /// Metadata about a snapshot, describing the state of the snapshot. + /// + /// + /// Note for EAP: SnapshotMetadata is not yet available on on QuerySnapshots but will be + /// added in a later release. + /// + public sealed class SnapshotMetadata { + /// + /// true if the snapshot contains the result of local writes (e.g. SetAsync or + /// UpdateAsync calls) that have not yet been committed to the backend. If your listener + /// has opted into metadata updates (via MetadataChanges.Include) you will receive + /// another snapshot with HasPendingWrites equal to false once the writes have + /// been committed to the backend. + /// + public bool HasPendingWrites { get; private set; } + + /// + /// true if the snapshot was created from cached data rather than guaranteed up-to-date + /// server data. If your listener has opted into metadata updates (via + /// MetadataChanges.Include) you will receive another snapshot with IsFromCache + /// equal to false once the client has received up-to-date data from the backend. + /// + public bool IsFromCache { get; private set; } + + internal SnapshotMetadata(bool hasPendingWrites, bool isFromCache) { + HasPendingWrites = hasPendingWrites; + IsFromCache = isFromCache; + } + + internal SnapshotMetadataProxy ConvertToProxy() { + return new SnapshotMetadataProxy(HasPendingWrites, IsFromCache); + } + + internal static SnapshotMetadata ConvertFromProxy(SnapshotMetadataProxy metadata) { + return new SnapshotMetadata(metadata.has_pending_writes(), metadata.is_from_cache()); + } + } +} diff --git a/firestore/src/Timestamp.cs b/firestore/src/Timestamp.cs new file mode 100644 index 000000000..a51a513b9 --- /dev/null +++ b/firestore/src/Timestamp.cs @@ -0,0 +1,259 @@ +// Copyright 2017, Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; +using System.Globalization; +using System.Text; + +// TODO(unity-api): This should be moved to a Firebase common Timestamp class. +namespace Firebase.Firestore { + /// + /// A nanosecond-precision immutable timestamp. When this is stored as part of a document in + /// Firestore, it is truncated to the microsecond, towards the start of time. + /// + /// + /// A Timestamp represents a point in time independent of any time zone or calendar, represented + /// as seconds and fractions of seconds at nanosecond resolution in UTC Epoch time. It is encoded + /// using the Proleptic Gregorian Calendar which extends the Gregorian calendar backwards to year + /// one. It is encoded assuming all minutes are 60 seconds long, i.e. leap seconds are "smeared" + /// so that no leap second table is needed for interpretation. Range is from 0001-01-01T00:00:00Z + /// to 9999-12-31T23:59:59.999999999Z. By restricting to that range, we ensure that we can convert + /// to and from RFC 3339 date strings. + /// + public struct Timestamp : IEquatable, IComparable, IComparable { + private static readonly DateTime s_unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); + + // Constants copied from Timestamp in Protobuf + internal const long MinSeconds = -62135596800; + internal const long MaxSeconds = 253402300799; + private const long BclSecondsAtUnixEpoch = 62135596800; + private const int NanosecondsPerTick = 100; + + /// + /// Seconds since the Unix epoch. Negative values indicate timestamps before the Unix epoch. + /// + private readonly long _seconds; + + /// + /// Nanoseconds within the second; always non-negative. (For example, the nanosecond before the + /// Unix epoch has a seconds value of -1, and a nanoseconds value of 999,999,999. + /// + private readonly int _nanoseconds; + + // See https://github.com/google/protobuf/blob/master/src/google/protobuf/timestamp.proto for + // more details. + + /// + /// Converts this timestamp to a with a kind of + /// . This can lose information as DateTime has a precision of a + /// tick (100 nanoseconds). If the timestamp is not a precise number of ticks, it will be + /// truncated towards the start of time. + /// + /// A representation of this timestamp. + public DateTime ToDateTime() { + return s_unixEpoch.AddSeconds(_seconds).AddTicks(_nanoseconds / NanosecondsPerTick); + } + + /// + /// Converts this timestamp into a . + /// + /// + /// The resulting DateTimeOffset will always have an Offset of zero. If the + /// timestamp is not a precise number of ticks, it will be truncated towards the start of time. + /// value precisely on a second. + /// + /// This timestamp as a DateTimeOffset. + public DateTimeOffset ToDateTimeOffset() { + return new DateTimeOffset(ToDateTime(), TimeSpan.Zero); + } + + /// + /// Converts a to a . + /// + /// The value to convert; its kind must be + /// . + /// A Timestamp representation of . + public static Timestamp FromDateTime(DateTime dateTime) { + dateTime = dateTime.ToUniversalTime(); + long secondsSinceBclEpoch = dateTime.Ticks / TimeSpan.TicksPerSecond; + int nanoseconds = (int)(dateTime.Ticks % TimeSpan.TicksPerSecond) * NanosecondsPerTick; + return new Timestamp(secondsSinceBclEpoch - BclSecondsAtUnixEpoch, nanoseconds); + } + + /// + /// Converts the given to a + /// + /// + /// The offset is taken into consideration when converting the value (so the same instant in + /// time is represented) but is not a separate part of the resulting value. In other words, + /// there is no round-trip operation that can retrieve the original DateTimeOffset. + /// + /// The date and time (with UTC offset) to convert to a + /// timestamp. + /// The converted timestamp. + public static Timestamp FromDateTimeOffset(DateTimeOffset dateTimeOffset) { + return FromDateTime(dateTimeOffset.UtcDateTime); + } + + /// + /// Returns the current timestamp according to the system clock. The system time zone is + /// irrelevant, as a timestamp represents an instant in time. + /// + /// The current timestamp according to the system clock. + public static Timestamp GetCurrentTimestamp() { + return FromDateTime(DateTime.UtcNow); + } + + /// + public override bool Equals(object obj) { + return obj is Timestamp && Equals((Timestamp)obj); + } + + /// + public override int GetHashCode() { + long result = 37 * _seconds + _nanoseconds; + // TODO(zxu): call the one in Hash.cs + return (int)((result & result >> 32) & 0xFFFFFFFF); + } + + /// + public bool Equals(Timestamp other) { + return _seconds == other._seconds && _nanoseconds == other._nanoseconds; + } + + /// + public int CompareTo(Timestamp other) { + // Note: assumes normalized form. + int secondsComparison = _seconds.CompareTo(other._seconds); + return secondsComparison != 0 ? secondsComparison : _nanoseconds.CompareTo(other._nanoseconds); + } + + /// + public int CompareTo(object obj) { + if (obj == null) { + // Everything comes after null + return 1; + } else if (obj is Timestamp) { + return CompareTo((Timestamp)obj); + } + throw new ArgumentException("Can only compare timestamps with each other", nameof(obj)); + } + + /// + /// Operator overload to compare two Timestamp values for equality. + /// + /// Left value to compare + /// Right value to compare + /// true if is equal to ; otherwise + /// false. + public static bool operator ==(Timestamp lhs, Timestamp rhs) { + return lhs.Equals(rhs); + } + + /// + /// Operator overload to compare two Timestamp values for inequality. + /// + /// Left value to compare + /// Right value to compare + /// false if is equal to ; + /// otherwise true. + public static bool operator !=(Timestamp lhs, Timestamp rhs) { + return !lhs.Equals(rhs); + } + + /// + /// Compares two timestamps. + /// + /// The left timestamp to compare. + /// The right timestamp to compare. + /// true if is strictly earlier than + /// ; otherwise false. + public static bool operator <(Timestamp lhs, Timestamp rhs) { + return lhs.CompareTo(rhs) < 0; + } + + /// + /// Compares two timestamps. + /// + /// The left timestamp to compare. + /// The right timestamp to compare. + /// true if is earlier than or equal to + /// ; otherwise false. + public static bool operator <=(Timestamp lhs, Timestamp rhs) { + return lhs.CompareTo(rhs) <= 0; + } + + /// + /// Compares two timestamps. + /// + /// The left timestamp to compare. + /// The right timestamp to compare. + /// true if is strictly later than + /// ; otherwise false. + public static bool operator >(Timestamp lhs, Timestamp rhs) { + return lhs.CompareTo(rhs) > 0; + } + + /// + /// Compares two timestamps. + /// + /// The left timestamp to compare. + /// The right timestamp to compare. + /// true if is later than or equal to + /// ; otherwise false. + public static bool operator >=(Timestamp lhs, Timestamp rhs) { + return lhs.CompareTo(rhs) >= 0; + } + + /// + public override string ToString() { + DateTime dateTime = s_unixEpoch.AddSeconds(_seconds); + var builder = new StringBuilder("Timestamp: "); + builder.Append(dateTime.ToString("yyyy'-'MM'-'dd'T'HH:mm:ss", CultureInfo.InvariantCulture)); + + if (_nanoseconds != 0) { + builder.Append('.'); + // Output to 3, 6 or 9 digits. + if (_nanoseconds % 1000000 == 0) { + builder.Append((_nanoseconds / 1000000).ToString("d3", CultureInfo.InvariantCulture)); + } else if (_nanoseconds % 1000 == 0) { + builder.Append((_nanoseconds / 1000).ToString("d6", CultureInfo.InvariantCulture)); + } else { + builder.Append(_nanoseconds.ToString("d9", CultureInfo.InvariantCulture)); + } + } + builder.Append("Z"); + return builder.ToString(); + } + + internal Timestamp(long seconds, int nanoseconds) { + if (seconds < MinSeconds || seconds > MaxSeconds) { + throw new ArgumentException("Timestamp seconds out of range:" + seconds); + } + if (nanoseconds < 0 || nanoseconds > 999999999) { + throw new ArgumentException("Timestamp nanoseconds out of range:" + nanoseconds); + } + _seconds = seconds; + _nanoseconds = nanoseconds; + } + + internal TimestampProxy ConvertToProxy() { + return new TimestampProxy(_seconds, _nanoseconds); + } + + internal static Timestamp ConvertFromProxy(TimestampProxy obj) { + return new Timestamp(obj.seconds(), obj.nanoseconds()); + } + } +} diff --git a/firestore/src/Transaction.cs b/firestore/src/Transaction.cs new file mode 100644 index 000000000..1e2a9761e --- /dev/null +++ b/firestore/src/Transaction.cs @@ -0,0 +1,178 @@ +// Copyright 2017, Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License.using System; + +using Firebase.Firestore.Internal; +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace Firebase.Firestore { + /// + /// A transaction, as created by + /// + /// (and overloads) and passed to user code. + /// + public sealed class Transaction { + private readonly TransactionCallbackProxy _proxy; + private readonly FirebaseFirestore _firestore; + + internal Transaction(TransactionCallbackProxy proxy, FirebaseFirestore firestore) { + _proxy = Util.NotNull(proxy); + _firestore = Util.NotNull(firestore); + } + + /// + /// The database for this transaction. + /// + public FirebaseFirestore Firestore { + get { + return _firestore; + } + } + + /// + /// Read a snapshot of the document specified by , with + /// respect to this transaction. This method cannot be called after any write operations have + /// been created. + /// + /// The document reference to read. Must not be null. + /// + /// A snapshot of the given document with respect to this transaction. + public Task GetSnapshotAsync(DocumentReference documentReference) { + Preconditions.CheckNotNull(documentReference, nameof(documentReference)); + // C++ and native client SDK only provides sync API. Here we convert it to async API. + return Task.Factory.StartNew(() => { + TransactionResultOfGetProxy result = _proxy.Get(documentReference.Proxy); + if (!result.is_valid()) { + throw new InvalidOperationException("Transaction has ended"); + } else if (result.error_code() == FirestoreError.Ok) { + return new DocumentSnapshot(result.TakeSnapshot(), Firestore); + } else { + throw new FirestoreException(result.error_code(), result.error_message()); + } + }); + } + + /// + /// Writes to the document referred to by the provided DocumentReference. If the document + /// does not yet exist, it will be created. If you pass , the provided + /// data can be merged into an existing document. + /// + /// The document in which to set the data. Must not be + /// null. + /// The data for the document. Must not be null. + /// The options to use when updating the document. May be null, + /// which is equivalent to . + public void Set(DocumentReference documentReference, object documentData, SetOptions options = + null) { + Preconditions.CheckNotNull(documentReference, nameof(documentReference)); + Preconditions.CheckNotNull(documentData, nameof(documentData)); + + FieldValueProxy data = ValueSerializer.Serialize(SerializationContext.Default, documentData); + if (!data.is_map()) { + throw new ArgumentException("documentData must be either an IDictionary or a POCO. Instead we get " + documentData.GetType().FullName); + } + if (options == null) { + options = SetOptions.Overwrite; + } + + bool successful = _proxy.Set(documentReference.Proxy, data, options.Proxy); + if (!successful) { + throw new InvalidOperationException("Transaction has ended"); + } + } + + /// + /// Updates fields in the document referred to by the provided DocumentReference. If no + /// document exists yet, the update will fail. + /// + /// The document to update. Must not be null. + /// A dictionary of field / value pairs to update. Fields can contain dots + /// to reference nested fields in the document. Fields not present in this dictionary are not + /// updated. Must not be null. + public void Update(DocumentReference documentReference, IDictionary updates) { + Preconditions.CheckNotNull(documentReference, nameof(documentReference)); + Preconditions.CheckNotNull(updates, nameof(updates)); + + FieldValueProxy data = ValueSerializer.Serialize(SerializationContext.Default, updates); + if (!data.is_map()) { + // TODO(zxu): More likely to be an internal error since the type is already checked. + throw new ArgumentException("updates must be Dictionary. Instead we get " + updates.GetType().FullName); + } + + bool successful = _proxy.Update(documentReference.Proxy, data); + if (!successful) { + throw new InvalidOperationException("Transaction has ended"); + } + } + + /// + /// Updates the field in the document referred to by the provided DocumentReference. If + /// no document exists yet, the update will fail. + /// + /// The document to update. Must not be null. + /// The dot-separated name of the field to update. Must not be null. + /// + /// The new value for the field. May be null. + public void Update(DocumentReference documentReference, string field, object value) { + Preconditions.CheckNotNull(documentReference, nameof(documentReference)); + Preconditions.CheckNotNullOrEmpty(field, nameof(field)); + + var data = new FieldToValueMap(); + data.Insert(field, ValueSerializer.Serialize(SerializationContext.Default, value)); + + bool successful = _proxy.Update(documentReference.Proxy, data); + if (!successful) { + throw new InvalidOperationException("Transaction has ended"); + } + } + + /// + /// Updates fields in the document referred to by the provided DocumentReference. If no + /// document exists yet, the update will fail. + /// + /// The document to update. Must not be null. + /// A dictionary of field / value pairs to update. Fields not present in + /// this dictionary are not updated. Must not be null. + public void Update(DocumentReference documentReference, IDictionary updates) { + Preconditions.CheckNotNull(documentReference, nameof(documentReference)); + Preconditions.CheckNotNull(updates, nameof(updates)); + + var data = new FieldPathToValueMap(); + foreach (KeyValuePair key_value in updates) { + FieldPathProxy key = key_value.Key.ConvertToProxy(); + FieldValueProxy value = ValueSerializer.Serialize(SerializationContext.Default, key_value.Value); + data.Insert(key, value); + } + + bool successful = _proxy.Update(documentReference.Proxy, data); + if (!successful) { + throw new InvalidOperationException("Transaction has ended"); + } + } + + /// + /// Deletes the document referenced by the provided DocumentReference. + /// + /// The document to delete. Must not be null. + public void Delete(DocumentReference documentReference) { + Preconditions.CheckNotNull(documentReference, nameof(documentReference)); + bool successful = _proxy.Delete(documentReference.Proxy); + if (!successful) { + throw new InvalidOperationException("Transaction has ended"); + } + } + } +} diff --git a/firestore/src/TransactionManager.cs b/firestore/src/TransactionManager.cs new file mode 100644 index 000000000..285669c42 --- /dev/null +++ b/firestore/src/TransactionManager.cs @@ -0,0 +1,157 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License.using System; + +using Firebase.Firestore.Internal; +using Firebase.Platform; +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace Firebase.Firestore { + using TransactionCallbackMap = ListenerRegistrationMap>; + + /// + /// Manages in-flight transactions on behalf of `FirebaseFirestore`. + /// + /// + /// This class is thread safe and all methods may be invoked concurrently by multiple threads. + /// + internal sealed class TransactionManager : IDisposable { + private static readonly TransactionCallbackMap _callbacks = new TransactionCallbackMap(); + + private readonly FirebaseFirestore _firestore; + private readonly TransactionManagerProxy _transactionManagerProxy; + + /// + /// Creates a new instance of this class. + /// + /// The `Firestore` object to use.. + /// The `FirestoreProxy` object to use.. + internal TransactionManager(FirebaseFirestore firestore, FirestoreProxy firestoreProxy) { + _firestore = Util.NotNull(firestore); + _transactionManagerProxy = new TransactionManagerProxy(Util.NotNull(firestoreProxy)); + } + + ~TransactionManager() { + Dispose(); + } + + /// + /// Releases all resources held by this object. + /// + /// + /// Any scheduled transactions will be unscheduled, any running transactions will be cancelled, + /// and all future calls to `RunTransactionAsync()` will not actually run a transaction but will + /// instead return a faulted `Task`. + /// + /// This method is idempotent; however, only the first invocation has side effects. + /// + public void Dispose() { + _callbacks.ClearCallbacksForOwner(this); + _transactionManagerProxy.CppDispose(); + GC.SuppressFinalize(this); + } + + /// + /// Runs a transaction. + /// + /// The callback to run.. + /// A task that completes when the transaction has completed. + internal Task RunTransactionAsync(Func> callback) { + // Store the result of the most recent invocation of the user-supplied callback. + bool callbackWrapperInvoked = false; + Task lastCallbackTask = null; + Exception lastCallbackException = null; + + // Create a callback that calls the caller-supplied callback. + Func callbackWrapper = callbackProxy => { + Util.HardAssert(FirebaseHandler.DefaultInstance.IsMainThread(), + "Callback must be invoked on the main thread"); + callbackWrapperInvoked = true; + lastCallbackTask = null; + lastCallbackException = null; + + try { + var transaction = new Transaction(callbackProxy, _firestore); + Task callbackTask = callback(transaction); + lastCallbackTask = callbackTask; + return callbackTask; + } catch (Exception e) { + lastCallbackException = e; + return null; + } + }; + + Int32 callbackId = _callbacks.Register(this, callbackWrapper); + + // Create a continuation to apply to the `Task` returned from `RunTransaction()`. + Func overallCallback = overallTask => { + _callbacks.Unregister(callbackId); + + if (!callbackWrapperInvoked) { + throw new FirestoreException(FirestoreError.FailedPrecondition, + "Firestore instance has been disposed"); + } else if (lastCallbackException != null) { + throw lastCallbackException; + } else if (lastCallbackTask == null) { + throw new NullReferenceException( + "The callback specified to " + nameof(RunTransactionAsync) + + "() returned a null Task, but it is required to return a non-null Task"); + } else if (lastCallbackTask.IsFaulted) { + throw Util.FlattenException(lastCallbackTask.Exception); + } else if (overallTask.IsFaulted) { + throw Util.FlattenException(overallTask.Exception); + } else { + return lastCallbackTask.Result; + } + }; + + return _transactionManagerProxy.RunTransactionAsync(callbackId, ExecuteCallback) + .ContinueWith(overallCallback); + } + + internal delegate bool TransactionCallbackDelegate(System.IntPtr transactionCallbackProxyPtr); + + [MonoPInvokeCallback(typeof(TransactionCallbackDelegate))] + static bool ExecuteCallback(System.IntPtr transactionCallbackProxyPtr) { + var callbackProxy = + new TransactionCallbackProxy(transactionCallbackProxyPtr, /*cMemoryOwn=*/true); + try { + Func callbackWrapper; + if (!_callbacks.TryGetCallback(callbackProxy.callback_id(), out callbackWrapper)) { + return false; + } + + Task callbackTask = callbackWrapper(callbackProxy); + if (callbackTask == null) { + return false; + } + + callbackTask.ContinueWith(task => { + bool callbackSucceeded = !(task.IsCanceled || task.IsFaulted); + callbackProxy.OnCompletion(callbackSucceeded); + }); + return true; + } catch (Exception e) { + // Do not allow exceptions to propagate into C++ because it is undefined behavior. + // https://www.mono-project.com/docs/advanced/pinvoke/#runtime-exception-propagation + Firebase.LogUtil.LogMessage( + LogLevel.Error, + "Unexpected exception thrown by " + nameof(ExecuteCallback) + "(): " + e.ToString()); + return false; + } + } + } +} diff --git a/firestore/src/UnknownPropertyHandling.cs b/firestore/src/UnknownPropertyHandling.cs new file mode 100644 index 000000000..6dcb79636 --- /dev/null +++ b/firestore/src/UnknownPropertyHandling.cs @@ -0,0 +1,36 @@ +// Copyright 2018, Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Firebase.Firestore { + /// + /// Determines how unknown properties are handling when deserializing a + /// Firestore document. + /// + public enum UnknownPropertyHandling { + /// + /// Unknown properties are silently ignored. + /// + Ignore = 0, + + /// + /// Unknown properties cause a warning, but no error. + /// + Warn = 1, + + /// + /// Unknown properties cause an exception to be thrown. + /// + Throw = 2 + } +} diff --git a/firestore/src/ValueDeserializer.cs b/firestore/src/ValueDeserializer.cs new file mode 100644 index 000000000..cabbe8473 --- /dev/null +++ b/firestore/src/ValueDeserializer.cs @@ -0,0 +1,105 @@ +// Copyright 2017, Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Firebase.Firestore.Internal; +using System; +using System.Collections.Generic; +using System.Reflection; +using BclType = System.Type; + +namespace Firebase.Firestore { + // TODO: A lot of optimization of this and ValueSerializer, *after* writing comprehensive benchmarks. + // We may be able to avoid a lot of boxing by a combination of making methods generic and building + // delegates for serialization/deserialization of specific types using expression trees. The initial + // aim is just to work out the functionality required, and optimize later. + + /// + /// Provides conversions from FieldValueProxy values to .NET types. + /// + internal static class ValueDeserializer { + /// + /// Deserializes from a FieldValueProxy to a .NET type. + /// + /// The context for the deserialization operation. Never null. + /// The value to deserialize. Must not be null. + /// The target type. The method tries to convert to this type. If the type is + /// object, it uses the default representation of the value. + /// The deserialized value + internal static object Deserialize(DeserializationContext context, FieldValueProxy value, BclType targetType) { + Preconditions.CheckNotNull(context, nameof(context)); + Preconditions.CheckNotNull(value, nameof(value)); + + // If we're asked for a FieldValueProxy, just return it. Since it's immutable, no + // cloning is necessary. + if (targetType == typeof(FieldValueProxy)) { + return value; + } + if (targetType == typeof(object)) { + targetType = GetTargetType(value); + } + + BclType underlyingType = Nullable.GetUnderlyingType(targetType); + if (value.is_null()) { + if (!targetType.IsValueType || underlyingType != null) { + return null; + } else { + throw new ArgumentException(String.Format("Unable to convert null value to {0}", targetType.FullName)); + } + } + + // We deserialize to T and Nullable the same way for all non-null values. Use the converter + // associated with the non-nullable version of the target type. + BclType nonNullableTargetType = underlyingType ?? targetType; + return context.GetConverter(nonNullableTargetType).DeserializeValue(context, value); + } + + internal static object DeserializeMap(DeserializationContext context, FieldValueProxy mapValue, BclType targetType) { + if (targetType == typeof(object)) { + targetType = typeof(Dictionary); + } + return context.GetConverter(targetType).DeserializeMap(context, mapValue); + } + + private static BclType GetTargetType(FieldValueProxy value) { + // TODO: Use an array instead? + switch (value.type()) { + case FieldValueProxy.Type.Null: + // Any nullable type is fine here; we'll return null anyway. + return typeof(string); + case FieldValueProxy.Type.Array: + return typeof(List); + case FieldValueProxy.Type.Boolean: + return typeof(bool); + case FieldValueProxy.Type.Blob: + return typeof(Blob); + case FieldValueProxy.Type.Double: + return typeof(double); + case FieldValueProxy.Type.GeoPoint: + return typeof(GeoPoint); + case FieldValueProxy.Type.Integer: + return typeof(long); + case FieldValueProxy.Type.Map: + return typeof(Dictionary); + case FieldValueProxy.Type.Reference: + return typeof(DocumentReference); + case FieldValueProxy.Type.String: + return typeof(string); + case FieldValueProxy.Type.Timestamp: + return typeof(Timestamp); + default: + throw new ArgumentException(String.Format("Unable to convert value type {0} to System.Object", value.type())); + } + } + } +} diff --git a/firestore/src/ValueSerializer.cs b/firestore/src/ValueSerializer.cs new file mode 100644 index 000000000..3b827e31f --- /dev/null +++ b/firestore/src/ValueSerializer.cs @@ -0,0 +1,53 @@ +// Copyright 2017, Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Firebase.Firestore.Converters; +using Firebase.Firestore.Internal; +using System.Collections.Generic; + +namespace Firebase.Firestore { + // TODO: Serialize some other types, e.g. Guid? + // TODO: Protect against stack overflows? + // TODO: Deliberate pass through of Value to Value (and maps/collections) to make it easier to plug in other mappers? + + /// + /// Provides conversions from .NET types to FieldValueProxy. + /// + internal static class ValueSerializer { + /// + /// Serializes a single input to a Value. + /// + /// + /// The value to serialize. + /// The FieldValueProxy representation. + internal static FieldValueProxy Serialize(SerializationContext context, object value) { + if (value == null) { + return FieldValueProxy.Null(); + } + return context.GetConverter(value.GetType()).Serialize(context, value); + } + + /// + /// Serializes a map-based input to a dictionary of fields to values. + /// This is effectively the map-only part of , but without wrapping the + /// result in a Value. + /// + internal static Dictionary SerializeMap(SerializationContext context, object value) { + Preconditions.CheckNotNull(value, nameof(value)); + var map = new Dictionary(); + context.GetConverter(value.GetType()).SerializeMap(context, value, map); + return map; + } + } +} diff --git a/firestore/src/WriteBatch.cs b/firestore/src/WriteBatch.cs new file mode 100644 index 000000000..14a507786 --- /dev/null +++ b/firestore/src/WriteBatch.cs @@ -0,0 +1,159 @@ +// Copyright 2017, Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License.using System; + +using Firebase.Firestore.Internal; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; + +namespace Firebase.Firestore { + /// + /// A batch of write operations, used to perform multiple writes as a single atomic unit. + /// + /// + /// A WriteBatch object can be acquired by calling + /// . It provides methods for adding writes to the write + /// batch. None of the writes will be committed (or visible locally) until + /// is called. + /// + /// Unlike transactions, write batches are persisted offline and therefore are preferable + /// when you don't need to condition your writes on read data. + /// + public sealed class WriteBatch { + private readonly WriteBatchProxy _proxy; + + internal WriteBatch(WriteBatchProxy proxy) { + _proxy = Util.NotNull(proxy); + } + + /// + /// Deletes the document referenced by the provided DocumentReference. + /// + /// The document to delete. Must not be null. + /// This batch, for the purposes of method chaining. + public WriteBatch Delete(DocumentReference documentReference) { + Preconditions.CheckNotNull(documentReference, nameof(documentReference)); + _proxy.Delete(documentReference.Proxy); + return this; + } + + /// + /// Updates fields in the document referred to by the provided DocumentReference. If no + /// document exists yet, the update will fail. + /// + /// The document to update. Must not be null. + /// A dictionary of field / value pairs to update. Fields can contain dots + /// to reference nested fields in the document. Fields not present in this dictionary are not + /// updated. Must not be null. + /// This batch, for the purposes of method chaining. + public WriteBatch Update(DocumentReference documentReference, IDictionary updates) { + Preconditions.CheckNotNull(documentReference, nameof(documentReference)); + Preconditions.CheckNotNull(updates, nameof(updates)); + + var fieldValue = ConvertToFieldValue(updates); + FirestoreCpp.WriteBatchUpdate(_proxy, documentReference.Proxy, fieldValue); + + return this; + } + + private FieldValueProxy ConvertToFieldValue(IDictionary updates) { + FieldValueProxy data = ValueSerializer.Serialize(SerializationContext.Default, updates); + + Util.HardAssert(data.is_map(), "The serialized type should be a map but isn't. " + + "This should not happen."); + + return data; + } + + /// + /// Updates the field in the document referred to by the provided DocumentReference. If + /// no document exists yet, the update will fail. + /// + /// The document to update. Must not be null. + /// The dot-separated name of the field to update. Must not be null. + /// + /// The new value for the field. May be null. + /// This batch, for the purposes of method chaining. + public WriteBatch Update(DocumentReference documentReference, string field, object value) { + Preconditions.CheckNotNull(documentReference, nameof(documentReference)); + Preconditions.CheckNotNullOrEmpty(field, nameof(field)); + + var data = new FieldToValueMap(); + data.Insert(field, ValueSerializer.Serialize(SerializationContext.Default, value)); + FirestoreCpp.WriteBatchUpdate(_proxy, documentReference.Proxy, data); + + return this; + } + + /// + /// Updates fields in the document referred to by the provided DocumentReference. If no + /// document exists yet, the update will fail. + /// + /// The document to update. Must not be null. + /// A dictionary of field / value pairs to update. Fields not present in + /// this dictionary are not updated. Must not be null. + /// This batch, for the purposes of method chaining. + public WriteBatch Update(DocumentReference documentReference, IDictionary updates) { + Preconditions.CheckNotNull(documentReference, nameof(documentReference)); + Preconditions.CheckNotNull(updates, nameof(updates)); + + var data = new FieldPathToValueMap(); + foreach (KeyValuePair key_value in updates) { + FieldPathProxy key = key_value.Key.ConvertToProxy(); + FieldValueProxy value = ValueSerializer.Serialize(SerializationContext.Default, key_value.Value); + data.Insert(key, value); + } + FirestoreCpp.WriteBatchUpdate(_proxy, documentReference.Proxy, data); + + return this; + } + + /// + /// Writes to the document referred to by the provided DocumentReference. If the document + /// does not yet exist, it will be created. If you pass , the provided + /// data can be merged into an existing document. + /// + /// The document in which to set the data. Must not be + /// null. + /// The data for the document. Must not be null. + /// The options to use when updating the document. May be null, + /// which is equivalent to . + /// This batch, for the purposes of method chaining. + public WriteBatch Set(DocumentReference documentReference, object documentData, SetOptions options = null) { + Preconditions.CheckNotNull(documentReference, nameof(documentReference)); + Preconditions.CheckNotNull(documentData, nameof(documentData)); + + FieldValueProxy data = ValueSerializer.Serialize(SerializationContext.Default, documentData); + if (!data.is_map()) { + throw new ArgumentException("documentData must be either an IDictionary or a POCO. Instead we get " + + documentData.GetType().FullName); + } + if (options == null) { + options = SetOptions.Overwrite; + } + + FirestoreCpp.WriteBatchSet(_proxy, documentReference.Proxy, data, options.Proxy); + return this; + } + + /// + /// Commits all of the writes in this write batch as a single atomic unit. + /// + /// The write result of the server operation. The task will not complete while the + /// client is offline, though local changes will be visible immediately. + public Task CommitAsync() => _proxy.CommitAsync(); + } +} diff --git a/firestore/src/internal/AssertFailedException.cs b/firestore/src/internal/AssertFailedException.cs new file mode 100644 index 000000000..54e99f48e --- /dev/null +++ b/firestore/src/internal/AssertFailedException.cs @@ -0,0 +1,27 @@ +using System; + +namespace Firebase.Firestore.Internal { + + /// + /// Thrown when a Firestore internal assertion is violated. + /// + /// + /// This exception is perfect for situations that "should never happen" or when state is found + /// that can only be a symptom of a bug in the code. It should not be used when users use our APIs + /// incorrectly, such as specifying a null value when null is forbidden or calling a method on a + /// "closed" instance. + /// + internal class AssertFailedException : Exception { + + public AssertFailedException() { + } + + public AssertFailedException(string message) : base(message) { + } + + public AssertFailedException(string message, Exception inner) : base(message, inner) { + } + + } + +} diff --git a/firestore/src/internal/EnvironmentVersion.cs b/firestore/src/internal/EnvironmentVersion.cs new file mode 100644 index 000000000..721c46b62 --- /dev/null +++ b/firestore/src/internal/EnvironmentVersion.cs @@ -0,0 +1,49 @@ +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Runtime.Versioning; + +namespace Firebase.Firestore.Internal { + // Note: this code is a greatly simplified version of + // https://github.com/googleapis/gax-dotnet/blob/master/Google.Api.Gax/VersionHeaderBuilder.cs + + /// + /// Gets the version of the .NET environment. + /// + sealed class EnvironmentVersion + { + public static string GetEnvironmentVersion() + { + string systemEnvironmentVersion = +#if NETSTANDARD1_3 + null; +#else + FormatVersion(Environment.Version); +#endif + return systemEnvironmentVersion ?? ""; + } + + private static string FormatVersion(Version version) => + version != null ? + String.Format("{0}.{1}.{2}", version.Major, version.Minor, + (version.Build != -1 ? version.Build : 0)) : + ""; // Empty string means "unknown" + + } +} diff --git a/firestore/src/internal/Hash.cs b/firestore/src/internal/Hash.cs new file mode 100644 index 000000000..599b0b67a --- /dev/null +++ b/firestore/src/internal/Hash.cs @@ -0,0 +1,13 @@ +using System; + +namespace Firebase.Firestore.Internal { + internal static class Hash { + internal static int LongHash(long l) { + return (int)((l ^ l >> 32) & 0xFFFFFFFF); + } + + internal static int DoubleBitwiseHash(double d) { + return LongHash(BitConverter.DoubleToInt64Bits(d)); + } + } +} diff --git a/firestore/src/internal/Preconditions.cs b/firestore/src/internal/Preconditions.cs new file mode 100644 index 000000000..9c9962e4f --- /dev/null +++ b/firestore/src/internal/Preconditions.cs @@ -0,0 +1,104 @@ +using System; +using System.Diagnostics; + +namespace Firebase.Firestore.Internal { + /// + /// Preconditions for checking method arguments, state etc. Inspired by classes like + /// https://github.com/google/guava/blob/master/guava/src/com/google/common/base/Preconditions.java + /// and https://github.com/googleapis/gax-dotnet/blob/master/Google.Api.Gax/GaxPreconditions.cs + /// + internal static class Preconditions { + + internal static T CheckNotNull(T argument, string paramName) where T : class { + if (argument == null) throw new ArgumentNullException(paramName); + return argument; + } + + /// + /// Checks that a string argument is neither null, nor an empty string. + /// + /// The argument provided for the parameter. + /// The name of the parameter in the calling method. + /// is null + /// is empty + /// if it is not null or empty + internal static string CheckNotNullOrEmpty(string argument, string paramName) { + if (argument == null) { + throw new ArgumentNullException(paramName); + } else if (argument == "") { + throw new ArgumentException("An empty string was provided, but is not valid", paramName); + } else { + return argument; + } + } + + /// + /// Checks that given condition is met, throwing an otherwise. + /// + /// The (already evaluated) condition to check. + /// The message to include in the exception, if generated. This should not + /// use interpolation, as the interpolation would be performed regardless of whether or + /// not an exception is thrown. + public static void CheckState(bool condition, string message) { + if (!condition) { + throw new InvalidOperationException(message); + } + } + + /// + /// Checks that given condition is met, throwing an otherwise. + /// + /// The (already evaluated) condition to check. + /// The format string to use to create the exception message if the + /// condition is not met. + /// The argument to the format string. + public static void CheckState(bool condition, string format, T arg0) { + if (!condition) { + throw new InvalidOperationException(string.Format(format, arg0)); + } + } + + /// + /// Checks that given condition is met, throwing an otherwise. + /// + /// The (already evaluated) condition to check. + /// The format string to use to create the exception message if the + /// condition is not met. + /// The first argument to the format string. + /// The second argument to the format string. + public static void CheckState(bool condition, string format, T1 arg0, T2 arg1) { + if (!condition) { + throw new InvalidOperationException(string.Format(format, arg0, arg1)); + } + } + + /// + /// Checks that given condition is met, throwing an otherwise. + /// + /// The (already evaluated) condition to check. + /// The format string to use to create the exception message if the + /// condition is not met. + /// The first argument to the format string. + /// The second argument to the format string. + /// The third argument to the format string. + public static void CheckState(bool condition, string format, T1 arg0, T2 arg1, T3 arg2) { + if (!condition) { + throw new InvalidOperationException(string.Format(format, arg0, arg1, arg2)); + } + } + + /// + /// Checks that given argument-based condition is met, throwing an otherwise. + /// + /// The (already evaluated) condition to check. + /// The name of the parameter whose value is being tested. + /// The message to include in the exception, if generated. This should not + /// use interpolation, as the interpolation would be performed regardless of whether or not an exception + /// is thrown. + internal static void CheckArgument(bool condition, string paramName, string message) { + if (!condition) { + throw new ArgumentException(message, paramName); + } + } + } +} diff --git a/firestore/src/internal/Util.cs b/firestore/src/internal/Util.cs new file mode 100644 index 000000000..619b2dc11 --- /dev/null +++ b/firestore/src/internal/Util.cs @@ -0,0 +1,117 @@ +using System; +using System.Diagnostics; +using System.Threading.Tasks; + +namespace Firebase.Firestore.Internal { + internal static class Util { + internal static void Unreachable() { + Debug.Assert(false, "Firestore unreachable code"); + } + + // TODO(rgowman): This should use a message template + parameters, like the other platforms. + internal static void HardAssert(bool condition, string message) { + Debug.Assert(condition, message); + } + + // TODO(rgowman): This should use a message template + parameters, like the other platforms. + internal static void HardFail(string message) { + Debug.Assert(false, message); + } + + /** + * Returns the given obj if it is non-null; otherwise, results in a failed assertion, similar to + * HardAssert. + * + * Example usage: + * my_ref = NotNull(suspicious_ref); + * + * Used for internal checks only. For user-supplied null reference violations, we should be + * throwing an ArgumentNullException via + * Firebase.Firestore.Internal.Preconditions.CheckNotNull(). + */ + internal static T NotNull(T obj, string message = null) { + Debug.Assert(obj != null, message); + return obj; + } + + /// + /// Returns a Task that has failed with a given exception, similar to Task.FromException() + /// in .Net 4.6. + /// + internal static Task TaskFromException(Exception exception) { + TaskCompletionSource s = new TaskCompletionSource(); + s.SetException(exception); + return s.Task; + } + + /// + /// Returns a Task that converts the result of the given Task to a different type. + /// + /// The Task whose result to translate. + /// The function to convert the result of the given task to the result + /// type with which the Task returned from this method will complete. + /// + /// A new Task that is a continuation of the given task and completes with the result of the + /// given Task or fails with the same exception as the given Task. + /// + internal static Task MapResult(Task task, Func mapFunc) { + return task.ContinueWith((Task completedTask) => { + FlattenAndThrowException(completedTask); + return mapFunc(completedTask.Result); + }); + } + + /// + /// Returns a Task that has a result, created from one that does not. + /// + /// The Task to which to add a result. + /// The result to set in the returned Task. + /// + /// A new Task that is a continuation of the given task and completes with the given result or + /// faults with the same exception as the given Task. + /// + internal static Task MapResult(Task task, U result) { + return task.ContinueWith((Task completedTask) => { + FlattenAndThrowException(completedTask); + return result; + }); + } + + /// + /// Unwraps and throws the exception with which the given Task faulted, if any. + /// + /// This method either re-throws the faulting exception of the given Task, or returns normally, + /// which indicates that the given Task completed successfully. + /// + /// + /// The Task whose faulting exception to re-throw. + internal static void FlattenAndThrowException(Task completedTask) { + if (completedTask.IsFaulted && completedTask.Exception != null) { + // If the flattened AggregateException has exactly one inner exception then pull it out + // and re-throw it. Do not simply re-throw the AggregateException as that will cause the + // downstream tasks to fault undesirably with a multi-level hierarchy of + // AggregateExceptions (b/158309069). + throw FlattenException(completedTask.Exception); + } else if (completedTask.IsFaulted || completedTask.Exception != null) { + Unreachable(); + throw new AssertFailedException("should never get here"); + } + } + + /// + /// Unwraps and returns the "root" exception from the given AggregateException. + /// + /// The exception to flatten. + /// + /// Returns the innermost encapsulted exception extracted from the given AggregateException. + /// + internal static Exception FlattenException(AggregateException aggregateException) { + AggregateException flattenedException = aggregateException.Flatten(); + if (flattenedException.InnerExceptions.Count == 1) { + return flattenedException.InnerExceptions[0]; + } else { + return flattenedException; + } + } + } +} diff --git a/firestore/src/swig/CMakeLists.txt b/firestore/src/swig/CMakeLists.txt new file mode 100644 index 000000000..ce7106083 --- /dev/null +++ b/firestore/src/swig/CMakeLists.txt @@ -0,0 +1,98 @@ +# Copyright 2021 Google +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# CMake file for the firebase cpp firestore library + +set(firebase_firestore_swig_cpp_src + document_event_listener.cc + firestore_instance_management.cc + load_bundle_task_progress_callback.cc + query_event_listener.cc + snapshots_in_sync_listener.cc + transaction_manager.cc +) + +add_library(firebase_firestore_swig_cpp STATIC + ${firebase_firestore_swig_cpp_src} +) + +set_property(TARGET firebase_firestore_swig_cpp PROPERTY FOLDER "Firebase Cpp") + +target_link_libraries(firebase_firestore_swig_cpp + PUBLIC + firebase_app + firebase_firestore + absl_variant +) +# Public C++ headers all refer to each other relative to the src/include +# directory, while private headers are relative to the entire C++ SDK +# directory. +target_include_directories(firebase_firestore_swig_cpp + PUBLIC + ${CMAKE_CURRENT_LIST_DIR} + PRIVATE + ${FIREBASE_CPP_SDK_DIR} + ${FIREBASE_UNITY_DIR} +) + +set(FIRESTORE_SOURCE_DIR ${FIREBASE_CPP_SDK_DIR}/build/external/src/firestore) + +# Additional public headers come from the Firestore core +if(IOS) + target_include_directories(firebase_firestore_swig_cpp + PUBLIC + # The Firestore core on iOS comes via the FirebaseFirestore CocoaPod, and + # public headers should come from there. + ${FIREBASE_POD_DIR}/Pods/FirebaseFirestore/Firestore/core/include + ${FIREBASE_POD_DIR}/Pods/FirebaseFirestore/Firestore/Protos/nanopb + PRIVATE + # Additionally, the core C++ API is not declared publicly within the + # FirebaseFirestore pod, so depend on headers available in the source + # distribution. + ${FIREBASE_POD_DIR}/Pods/FirebaseFirestore + ) + set(FIREBASE_FIRESTORE_CORE_HEADER_DIR + ${FIREBASE_POD_DIR}/Pods/FirebaseFirestore/Firestore/core/include + ) +else() + # Desktop and Android get their public headers from the CMake build in + # firebase-ios-sdk. + target_include_directories(firebase_firestore_swig_cpp + PUBLIC + ${FIRESTORE_SOURCE_DIR}/Firestore/core/include + ${FIRESTORE_SOURCE_DIR}/Firestore/Protos/nanopb + PRIVATE + ${FIRESTORE_SOURCE_DIR} + ) + set(FIREBASE_FIRESTORE_CORE_HEADER_DIR + ${FIRESTORE_SOURCE_DIR}/Firestore/core/include + ) +endif() + +set(firestore_generated_headers_dir + "${CMAKE_BINARY_DIR}/generated/firestore/src/include/firebase/firestore") + +add_custom_target( + FIREBASE_FIRESTORE_SWIG_CPP_HEADERS + COMMAND ${CMAKE_COMMAND} -E make_directory + "${firestore_generated_headers_dir}" + COMMAND ${CMAKE_COMMAND} -E copy_directory + ${FIREBASE_FIRESTORE_CORE_HEADER_DIR} + "${firestore_generated_headers_dir}" + COMMAND ${CMAKE_COMMAND} -E echo "COPIED INTERNAL HEADER!" + COMMENT "Copying internal Firestore headers" +) + +add_dependencies(firebase_firestore_swig_cpp FIREBASE_FIRESTORE_SWIG_CPP_HEADERS) + diff --git a/firestore/src/swig/api_headers.h b/firestore/src/swig/api_headers.h new file mode 100644 index 000000000..1f13aeee3 --- /dev/null +++ b/firestore/src/swig/api_headers.h @@ -0,0 +1,23 @@ +#ifndef FIREBASE_FIRESTORE_CLIENT_UNITY_SRC_SWIG_API_HEADERS_H_ +#define FIREBASE_FIRESTORE_CLIENT_UNITY_SRC_SWIG_API_HEADERS_H_ + +#include "firestore/src/include/firebase/firestore.h" + +namespace firebase { +namespace firestore { +namespace csharp { + +// This class allows limited access to private functions of `Firestore` related +// to sending Cloud headers. +class ApiHeaders { + public: + static void SetClientLanguage(const std::string& language_token) { + Firestore::SetClientLanguage(language_token); + } +}; + +} // namespace csharp +} // namespace firestore +} // namespace firebase + +#endif // FIREBASE_FIRESTORE_CLIENT_UNITY_SRC_SWIG_API_HEADERS_H_ diff --git a/firestore/src/swig/document_event_listener.cc b/firestore/src/swig/document_event_listener.cc new file mode 100644 index 000000000..0b05ce2c4 --- /dev/null +++ b/firestore/src/swig/document_event_listener.cc @@ -0,0 +1,69 @@ +#include "firestore/src/swig/document_event_listener.h" + +#include +#include +#include + +#include "app/src/callback.h" +#include "firestore/src/include/firebase/firestore/document_reference.h" + +namespace firebase { +namespace firestore { +namespace csharp { + +namespace { + +class ListenerCallback { + public: + ListenerCallback(DocumentEventListenerCallback callback, int32_t callback_id, + std::unique_ptr snapshot, Error error_code, + std::string error_message) + : callback_(callback), + callback_id_(callback_id), + snapshot_(std::move(snapshot)), + error_code_(error_code), + error_message_(std::move(error_message)) {} + + static void Run(ListenerCallback* listener_callback) { + listener_callback->Run(); + } + + private: + void Run() { + // Ownership of the DocumentSnapshot pointer is passed to C#. + callback_(callback_id_, snapshot_.release(), error_code_, + error_message_.c_str()); + } + + DocumentEventListenerCallback callback_ = nullptr; + int32_t callback_id_ = -1; + std::unique_ptr snapshot_; + Error error_code_ = Error::kErrorUnknown; + std::string error_message_; +}; + +} // namespace + +ListenerRegistration AddDocumentSnapshotListener( + DocumentReference* reference, MetadataChanges metadata_changes, + int32_t callback_id, DocumentEventListenerCallback callback) { + auto snapshot_listener = [callback, callback_id]( + const DocumentSnapshot& snapshot, + Error error_code, + const std::string& error_message) { + // NOLINTNEXTLINE(modernize-make-unique) + std::unique_ptr snapshot_ptr( + new DocumentSnapshot(snapshot)); + ListenerCallback listener_callback(callback, callback_id, + std::move(snapshot_ptr), error_code, + error_message); + auto* callback = new callback::CallbackMoveValue1( + std::move(listener_callback), ListenerCallback::Run); + callback::AddCallback(callback); + }; + return reference->AddSnapshotListener(metadata_changes, snapshot_listener); +} + +} // namespace csharp +} // namespace firestore +} // namespace firebase diff --git a/firestore/src/swig/document_event_listener.h b/firestore/src/swig/document_event_listener.h new file mode 100644 index 000000000..f8307be99 --- /dev/null +++ b/firestore/src/swig/document_event_listener.h @@ -0,0 +1,42 @@ +#ifndef FIREBASE_FIRESTORE_CLIENT_UNITY_SRC_SWIG_DOCUMENT_EVENT_LISTENER_H_ +#define FIREBASE_FIRESTORE_CLIENT_UNITY_SRC_SWIG_DOCUMENT_EVENT_LISTENER_H_ + +#include "firebase/firestore/firestore_errors.h" +#include "firestore/src/include/firebase/firestore/document_snapshot.h" +#include "firestore/src/include/firebase/firestore/listener_registration.h" +#include "firestore/src/include/firebase/firestore/metadata_changes.h" + +namespace firebase { +namespace firestore { +namespace csharp { + +// Add this to make this header compile when SWIG is not involved. +#ifndef SWIGSTDCALL +#if !defined(SWIG) && \ + (defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)) +#define SWIGSTDCALL __stdcall +#else +#define SWIGSTDCALL +#endif +#endif + +// The callbacks that are used by the listener, that need to reach back to C# +// callbacks. The error_message pointer is only valid for the duration of the +// callback. +typedef void(SWIGSTDCALL* DocumentEventListenerCallback)( + int callback_id, DocumentSnapshot* snapshot, Error error_code, + const char* error_message); + +// This method is a proxy to DocumentReference::AddSnapshotListener() +// that can be easily called from C#. It allows our C# wrapper to +// track user callbacks in a dictionary keyed off of a unique int +// for each user callback and then raise the correct one later. +ListenerRegistration AddDocumentSnapshotListener( + DocumentReference* reference, MetadataChanges metadata_changes, + int32_t callback_id, DocumentEventListenerCallback callback); + +} // namespace csharp +} // namespace firestore +} // namespace firebase + +#endif // FIREBASE_FIRESTORE_CLIENT_UNITY_SRC_SWIG_DOCUMENT_EVENT_LISTENER_H_ diff --git a/firestore/src/swig/firestore.i b/firestore/src/swig/firestore.i new file mode 100644 index 000000000..2204cdbfd --- /dev/null +++ b/firestore/src/swig/firestore.i @@ -0,0 +1,503 @@ +// Copyright 2019 Google Inc. All Rights Reserved. +// + +// This file is used by SWIG to generate wrappers in target languages (so far +// just C#) around the C++ interface. A few .i files are defined to help +// organizing the public classes. + +// Make sure to check in the new generated code when changing the SWIG +// interface (by running +// `firebase/firestore/client/unity/generated/update-src.sh`). +// Alternatively, add `NO_IFTTT=` to the CL description. +// + + +#ifdef USE_EXPORT_FIX +// Generate a function that we can reference to force linker +// to include the generated swig library symbols correctly +// see export_fix.cc for more details +%include "app/src/export_fix.h" +%{#include "app/src/export_fix.h"%} +#endif + +%module FirestoreCpp +%pragma(csharp) moduleclassmodifiers="internal sealed class" + +// By default SWIG generates classes as public, but we want to hide them since +// we wrap them in our own hand-written classes giving us complete control over +// our public API, so we set csclassmodifiers to "internal class". +// Note that any class that has an `Internal` suffix in its name will +// additionally be made "internal" due to the post-processing step here: +// http://google3/firebase/app/client/unity/swig_post_process.py?l=438&rcl=267221433 +%typemap(csclassmodifiers) SWIGTYPE "internal class"; + +// Make sure proxy classes generated for pointers are also internal (when +// searching for the suitable typemap, SWIG goes from most to least specialized, +// not unlike C++ template argument deduction, so `SWIGTYPE *` "overrides" +// `SWIGTYPE`). +%typemap(csclassmodifiers) SWIGTYPE * "internal class"; + +%import "app/src/swig/app.i" +%import "firestore/src/swig/proxy_helpers.i" +%include "app/src/swig/init_result.i" +%include "app/src/swig/null_check_this.i" +%include "app/src/swig/serial_dispose.i" +%include "firestore/src/swig/types.i" + +// Generate std types. +%include "stdint.i" +%include "stl.i" + +// `firestore.h` includes all other Firestore public headers, so including just +// it is sufficient. Note that the code in `%{ ... %}` braces is not processed +// by SWIG; it is copied as-is into the SWIG-generated C++ file, and its only +// purpose is to make sure the resulting file compiles. +%{ +#include "firestore/src/include/firebase/firestore.h" +%} + +// Exception handling. +%{ +#include + +#include "firestore/src/common/firestore_exceptions_common.h" +%} + + +// The boilerplate necessary to propagate Firestore exceptions from C++ to C#. +// See http://www.swig.org/Doc3.0/CSharp.html#CSharp_custom_application_exception +// +// IMPORTANT: the definition of the exported function has to satisfy the regex +// defined here: +// http://google3/firebase/app/client/unity/swig_extract_symbols.bzl;l=10-12;rcl=372332490 +// In particular, you cannot declare the function itself as `extern "C"`, it has +// to be inside an `extern "C"` block, and everything up to and including the +// function name has to be defined on the same line. +%insert(runtime) %{ +using CSharpExceptionCallback = void (SWIGSTDCALL*)(const char*); + +CSharpExceptionCallback firestore_exception_callback = nullptr; + +extern "C" { + +SWIGEXPORT void SWIGSTDCALL FirestoreExceptionRegisterCallback(CSharpExceptionCallback callback) { + firestore_exception_callback = callback; +} + +} + +static void SWIG_CSharpSetPendingExceptionFirestore(const char* msg) { + firestore_exception_callback(msg); +} +%} + +%pragma(csharp) imclasscode=%{ + class FirestoreExceptionHelper { + // The C# delegate for the C++ `firestore_exception_callback`. + public delegate void FirestoreExceptionDelegate(string message); + static FirestoreExceptionDelegate firestoreDelegate = + new FirestoreExceptionDelegate(SetPendingFirestoreException); + + // IMPORTANT: the next line has to be a single line. Otherwise, it won't be + // correctly handled by `swig_post_process.py` which relies on a regex to + // replace the name of the DLL import. + [global::System.Runtime.InteropServices.DllImport("$dllimport", EntryPoint="FirestoreExceptionRegisterCallback")] + public static extern + void FirestoreExceptionRegisterCallback(FirestoreExceptionDelegate firestoreCallback); + + static void SetPendingFirestoreException(string message) { + SWIGPendingException.Set(new FirestoreException(FirestoreError.Internal, message)); + } + + static FirestoreExceptionHelper() { + FirestoreExceptionRegisterCallback(firestoreDelegate); + } + } + +// Suppress the warning about an unused variable. +#pragma warning disable 414 + static FirestoreExceptionHelper exceptionHelper = new FirestoreExceptionHelper(); +#pragma warning restore 414 +%} + +// TODO(b/186588556): for the invalid argument case, pass whether this is a null +// argument, an out of range argument, or something else (the first two cases +// have dedicated exception classes in C#). +// +// TODO(b/186588556): for the invalid argument case, pass the parameter name as +// well (needs to be attached to the C++ exception). +// +// Important: `invalid_argument` is a subclass of `logic_error` -- make sure +// they are checked in order from most to least derived. +// +// The catch-all clause is to work around iOS issues where some exception types +// aren't getting caught correctly. +%exception { + try { + $action + } catch (const ::firebase::firestore::FirestoreInternalError& e) { + SWIG_CSharpSetPendingExceptionFirestore(e.what()); + return $null; + } catch (const std::invalid_argument& e) { + SWIG_CSharpSetPendingExceptionArgument( + SWIG_CSharpExceptionArgumentCodes::SWIG_CSharpArgumentException, + e.what(), /*paramName=*/""); + return $null; + } catch (const std::logic_error& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return $null; + } catch (const std::exception& e) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + e.what()); + return $null; + } catch (...) { + SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, + "Unknown error has occurred."); + return $null; + } +} + +// Generate callback function types. +SWIG_MAP_CFUNC_TO_CSDELEGATE(::firebase::firestore::csharp::DocumentEventListenerCallback, + Firebase.Firestore.DocumentReference.ListenerDelegate) +SWIG_MAP_CFUNC_TO_CSDELEGATE(::firebase::firestore::csharp::QueryEventListenerCallback, + Firebase.Firestore.Query.ListenerDelegate) +SWIG_MAP_CFUNC_TO_CSDELEGATE(::firebase::firestore::csharp::SnapshotsInSyncCallback, + Firebase.Firestore.FirebaseFirestore.SnapshotsInSyncDelegate) +SWIG_MAP_CFUNC_TO_CSDELEGATE(::firebase::firestore::csharp::TransactionCallbackFn, + Firebase.Firestore.TransactionManager.TransactionCallbackDelegate) +SWIG_MAP_CFUNC_TO_CSDELEGATE(::firebase::firestore::csharp::LoadBundleTaskProgressCallback, + Firebase.Firestore.FirebaseFirestore.LoadBundleTaskProgressDelegate) + +// Generate Future instantiations, must be before other wrappers. +%include "app/src/swig/future.i" +%SWIG_FUTURE(Future_QuerySnapshot, QuerySnapshotProxy, internal, + firebase::firestore::QuerySnapshot, FirestoreException) +%SWIG_FUTURE(Future_DocumentSnapshot, DocumentSnapshotProxy, internal, + firebase::firestore::DocumentSnapshot, FirestoreException) +%SWIG_FUTURE(Future_DocumentReference, DocumentReferenceProxy, internal, + firebase::firestore::DocumentReference, FirestoreException) +// Override the default FutureVoid with a version that throws FirestoreException. +%SWIG_FUTURE(Future_FirestoreVoid, void, internal, void, FirestoreException) +%SWIG_FUTURE(Future_LoadBundleTaskProgress, LoadBundleTaskProgressProxy, + internal, firebase::firestore::LoadBundleTaskProgress, + FirestoreException) +%SWIG_FUTURE(Future_Query, QueryProxy, + internal, firebase::firestore::Query, + FirestoreException) + +// By default, SWIG initializes C++ objects that will be used by C# proxies in +// an inefficient way. Let's say that in the C++ code being wrapped, a return +// value of type `Foo` is produced by a function `GetFoo`. For classes, SWIG +// always deals with pointers (see +// http://www.swig.org/Doc3.0/SWIGDocumentation.html#SWIG_nn18), and thus it +// needs to turn the returned value into a pointer to a dynamically allocated +// object. The default involves an extraneous intermediate variable and forces +// use of the copy constructor through casting: +// +// Foo result; +// result = GetFoo(); +// jresult = new Foo((const Foo&)result); +// return jresult; +// +// This default works around some corner cases that aren't applicable to +// Firestore. It can be turned off by using `optimal="1"` attribute and +// providing a custom typemap, resulting in: +// +// jresult = new Foo(GetFoo()); +// return jresult; +// +// See http://www.swig.org/Doc3.0/SWIGDocumentation.html#Typemaps_optimal for +// details. +%typemap(out, optimal="1") SWIGTYPE "$result = new $1_ltype($1);" + +// Generate a C# wrapper for ListenerRegistration. Defined before DocumentReference and Query. +SWIG_CREATE_PROXY(firebase::firestore::ListenerRegistration) +%rename("%s") firebase::firestore::ListenerRegistration::Remove; +%include "firestore/src/include/firebase/firestore/listener_registration.h" + +// Generate a C# wrapper for Source. Must be before DocumentReference and Query. +%include "firestore/src/include/firebase/firestore/source.h" + +// Generate a C# wrapper for FieldPath. Must be above DocumentSnapshot and SetOptions. +SWIG_CREATE_PROXY(firebase::firestore::FieldPath) +%rename("%s") firebase::firestore::FieldPath::FieldPath(const std::vector&); +%include "firestore/src/include/firebase/firestore/field_path.h" + +// Generate a C# wrapper for SetOptions and ignore SetOptions::Type. Must be before +// DocumentReference. +SWIG_CREATE_PROXY(firebase::firestore::SetOptions) +%rename("%s") firebase::firestore::SetOptions::SetOptions(); +%rename("%s") firebase::firestore::SetOptions::Merge; +%rename("%s") firebase::firestore::SetOptions::MergeFields; +%include "firestore/src/include/firebase/firestore/set_options.h" + +// Generate a C# wrapper for DocumentReference. +SWIG_CREATE_PROXY(firebase::firestore::DocumentReference) +%rename("%s") firebase::firestore::DocumentReference::Get; +%rename("%s") firebase::firestore::DocumentReference::Delete; +%rename("%s") firebase::firestore::DocumentReference::id; +%rename("%s") firebase::firestore::DocumentReference::path; +%rename("%s") firebase::firestore::DocumentReference::Parent; +%rename("%s") firebase::firestore::DocumentReference::Collection; +%rename("%s") firebase::firestore::DocumentReference::is_valid; +%include "firestore/src/include/firebase/firestore/document_reference.h" + +// Generate a C# wrapper for SnapshotMetadata. Must be above QuerySnapshot and DocumentSnapshot. +%rename("%sProxy") firebase::firestore::SnapshotMetadata; +%include "firestore/src/include/firebase/firestore/snapshot_metadata.h" + +// Generate a C# wrapper for DocumentSnapshot and DocumentSnapshot::ServerTimestampBehavior. +// Must be above DocumentChange. +SWIG_CREATE_PROXY(firebase::firestore::DocumentSnapshot) +%rename("%s") firebase::firestore::DocumentSnapshot::id; +%rename("%s") firebase::firestore::DocumentSnapshot::reference; +%rename("%s") firebase::firestore::DocumentSnapshot::exists; +%rename("%s") firebase::firestore::DocumentSnapshot::metadata; +%rename("%s") firebase::firestore::DocumentSnapshot::Get; +%rename("%s") firebase::firestore::DocumentSnapshot::ServerTimestampBehavior; +%include "firestore/src/include/firebase/firestore/document_snapshot.h" + +// Generate a C# wrapper for DocumentChange and DocumentChange::Type. +// Must be after DocumentSnapshot. +SWIG_CREATE_PROXY(firebase::firestore::DocumentChange) +%rename("%s") firebase::firestore::DocumentChange::type; +%rename("%s") firebase::firestore::DocumentChange::document; +%rename("%s") firebase::firestore::DocumentChange::old_index; +%rename("%s") firebase::firestore::DocumentChange::new_index; +%rename("%s") firebase::firestore::DocumentChange::npos; +%rename("%s") firebase::firestore::DocumentChange::Type; +%include "firestore/src/include/firebase/firestore/document_change.h" + +// Generate a C# wrapper for FieldValue. +SWIG_CREATE_PROXY(firebase::firestore::FieldValue) +%rename("%s") firebase::firestore::FieldValue::Null; +%rename("%s") firebase::firestore::FieldValue::Delete; +%rename("%s") firebase::firestore::FieldValue::Integer; +%rename("%s") firebase::firestore::FieldValue::Double; +%rename("%s") firebase::firestore::FieldValue::Boolean; +%rename("%s") firebase::firestore::FieldValue::String; +%rename("%s") firebase::firestore::FieldValue::Blob; +%rename("%s") firebase::firestore::FieldValue::Timestamp; +%rename("%s") firebase::firestore::FieldValue::GeoPoint; +%rename("%s") firebase::firestore::FieldValue::Reference; +%rename("%s") firebase::firestore::FieldValue::ServerTimestamp; +%rename("%s") firebase::firestore::FieldValue::Increment(T); +%rename("IntegerIncrement") firebase::firestore::FieldValue::Increment; +%rename("DoubleIncrement") firebase::firestore::FieldValue::Increment; +%rename("%s") firebase::firestore::FieldValue::boolean_value; +%rename("%s") firebase::firestore::FieldValue::double_value; +%rename("%s") firebase::firestore::FieldValue::integer_value; +%rename("%s") firebase::firestore::FieldValue::string_value; +%rename("%s") firebase::firestore::FieldValue::reference_value; +%rename("%s") firebase::firestore::FieldValue::timestamp_value; +%rename("%s") firebase::firestore::FieldValue::geo_point_value; +%rename("%s") firebase::firestore::FieldValue::blob_size; +%rename("%s") firebase::firestore::FieldValue::blob_value; +%rename("%s") firebase::firestore::FieldValue::type; +%rename("%s") firebase::firestore::FieldValue::is_null; +%rename("%s") firebase::firestore::FieldValue::is_map; +%rename("%s") firebase::firestore::FieldValue::is_array; +%rename("%s") firebase::firestore::FieldValue::is_valid; +%rename("%s") firebase::firestore::FieldValue::Type; +%include "firestore/src/include/firebase/firestore/field_value.h" +// Without an explicit instantiation, SWIG would end up ignoring the template +// functions. Specifying the defaulted template argument is necessary. +%template(IntegerIncrement) firebase::firestore::FieldValue::Increment; +%template(DoubleIncrement) firebase::firestore::FieldValue::Increment; + +// Generate a C# wrapper for WriteBatch. Most member functions are ignored in +// favor of wrappers defined in `csharp/map.h` and `csharp/vector.h`. +SWIG_CREATE_PROXY(firebase::firestore::WriteBatch); +%rename("%s") firebase::firestore::WriteBatch::Delete; +%rename("%s") firebase::firestore::WriteBatch::Commit; +%include "firestore/src/include/firebase/firestore/write_batch.h" + +// Generate a C# wrapper for MetadataChanges. +%include "firestore/src/include/firebase/firestore/metadata_changes.h" + +// Generate a C# wrapper for Query and Query::Direction. Must be above CollectionReference. +SWIG_CREATE_PROXY(firebase::firestore::Query); +%rename("%s") firebase::firestore::Query::WhereEqualTo; +%rename("%s") firebase::firestore::Query::WhereNotEqualTo; +%rename("%s") firebase::firestore::Query::WhereLessThan; +%rename("%s") firebase::firestore::Query::WhereLessThanOrEqualTo; +%rename("%s") firebase::firestore::Query::WhereGreaterThan; +%rename("%s") firebase::firestore::Query::WhereGreaterThanOrEqualTo; +%rename("%s") firebase::firestore::Query::WhereArrayContains; +%rename("%s") firebase::firestore::Query::OrderBy; +%rename("%s") firebase::firestore::Query::Limit; +%rename("%s") firebase::firestore::Query::LimitToLast; +// Note: evidently SWIG matches function parameter types using simple text +// comparison, thus explicitly qualifying the namespace on `DocumentSnapshot` +// would cause this `%rename` directive to not match anything (because the +// actual header doesn't qualify the `DocumentSnapshot` argument). +%rename("%s") firebase::firestore::Query::StartAt(const DocumentSnapshot&) const; +%rename("%s") firebase::firestore::Query::StartAfter(const DocumentSnapshot&) const; +%rename("%s") firebase::firestore::Query::EndBefore(const DocumentSnapshot&) const; +%rename("%s") firebase::firestore::Query::EndAt(const DocumentSnapshot&) const; +%rename("%s") firebase::firestore::Query::Get; +%rename("%s") firebase::firestore::Query::Direction; +%include "firestore/src/include/firebase/firestore/query.h" + +// Generate a C# wrapper for CollectionReference. Must be after Query. +SWIG_CREATE_PROXY(firebase::firestore::CollectionReference); +%rename("%s") firebase::firestore::CollectionReference::id; +%rename("%s") firebase::firestore::CollectionReference::path; +%rename("%s") firebase::firestore::CollectionReference::Document; +%rename("%s") firebase::firestore::CollectionReference::Parent; +%include "firestore/src/include/firebase/firestore/collection_reference.h" + +// Generate a C# wrapper for QuerySnapshot. Must be after SnapshotMetadata. +SWIG_CREATE_PROXY(firebase::firestore::QuerySnapshot); +%rename("%s") firebase::firestore::QuerySnapshot::query; +%rename("%s") firebase::firestore::QuerySnapshot::metadata; +%rename("%s") firebase::firestore::QuerySnapshot::size; +%include "firestore/src/include/firebase/firestore/query_snapshot.h" + +// Generate a C# wrapper for Settings. +SWIG_CREATE_PROXY(firebase::firestore::Settings); +%rename("%s") firebase::firestore::Settings::kCacheSizeUnlimited; +%rename("%s") firebase::firestore::Settings::Settings; +%rename("%s") firebase::firestore::Settings::host; +%rename("%s") firebase::firestore::Settings::is_ssl_enabled; +%rename("%s") firebase::firestore::Settings::is_persistence_enabled; +%rename("%s") firebase::firestore::Settings::cache_size_bytes; +%rename("%s") firebase::firestore::Settings::set_host; +%rename("%s") firebase::firestore::Settings::set_ssl_enabled; +%rename("%s") firebase::firestore::Settings::set_persistence_enabled; +%rename("%s") firebase::firestore::Settings::set_cache_size_bytes; +%include "firestore/src/include/firebase/firestore/settings.h" + +// Generate a C# wrapper for LoadBundleTaskProgress. +SWIG_CREATE_PROXY(firebase::firestore::LoadBundleTaskProgress); +%rename("%s") firebase::firestore::LoadBundleTaskProgress::State; +%rename("%s") firebase::firestore::LoadBundleTaskProgress::documents_loaded; +%rename("%s") firebase::firestore::LoadBundleTaskProgress::total_documents; +%rename("%s") firebase::firestore::LoadBundleTaskProgress::bytes_loaded; +%rename("%s") firebase::firestore::LoadBundleTaskProgress::total_bytes; +%rename("%s") firebase::firestore::LoadBundleTaskProgress::state; +%include "firestore/src/include/firebase/firestore/load_bundle_task_progress.h" + +// Generate a C# wrapper for Firestore. Comes last because it refers to multiple +// other classes (e.g. `CollectionReference`). +// Note that `GetInstance` is intentionally excluded below because instances are to be retrieved +// from FirestoreCpp.GetFirestoreInstance() defined in firestore_instance_management.h. +SWIG_CREATE_PROXY(firebase::firestore::Firestore); +%rename("%s") firebase::firestore::Firestore::app; +%rename("%s") firebase::firestore::Firestore::Collection; +%rename("%s") firebase::firestore::Firestore::Document; +%rename("%s") firebase::firestore::Firestore::CollectionGroup; +%rename("%s") firebase::firestore::Firestore::settings; +%rename("%s") firebase::firestore::Firestore::set_settings; +%rename("%s") firebase::firestore::Firestore::batch; +%rename("%s") firebase::firestore::Firestore::DisableNetwork; +%rename("%s") firebase::firestore::Firestore::EnableNetwork; +%rename("%s") firebase::firestore::Firestore::WaitForPendingWrites; +%rename("%s") firebase::firestore::Firestore::Terminate; +%rename("%s") firebase::firestore::Firestore::ClearPersistence; +%rename("%s") firebase::firestore::Firestore::NamedQuery; +%rename("%s") firebase::firestore::Firestore::set_log_level; + +// Replace the default Dispose() method to remove references from the CppInstanceManager. +%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") + firebase::firestore::Firestore { + lock (FirebaseApp.disposeLock) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + FirestoreCpp.ReleaseFirestoreInstance(this); + swigCMemOwn = false; + swigCPtr = new global::System.Runtime.InteropServices.HandleRef( + null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } +} + +%include "firestore/src/include/firebase/firestore.h" + +// Interop helpers. +%{ +#include "firestore/src/swig/document_event_listener.h" +#include "firestore/src/swig/query_event_listener.h" +#include "firestore/src/swig/snapshots_in_sync_listener.h" +#include "firestore/src/swig/load_bundle_task_progress_callback.h" +#include "firestore/src/swig/firestore_instance_management.h" +%} +%include "firestore/src/swig/document_event_listener.h" +%include "firestore/src/swig/query_event_listener.h" +%include "firestore/src/swig/snapshots_in_sync_listener.h" +%include "firestore/src/swig/load_bundle_task_progress_callback.h" +%include "firestore/src/swig/firestore_instance_management.h" + +%{ +#include "firestore/src/swig/api_headers.h" +%} +%include "firestore/src/swig/api_headers.h" + +// `std::unordered_map` wrapper. +%{ +#include "firestore/src/swig/map.h" +%} +%include "firestore/src/swig/map.h" + +%rename("$ignore", regextarget=1, fullname=1) "firebase::firestore::csharp::Map.*::Wrap"; +%rename("$ignore", regextarget=1, fullname=1) "firebase::firestore::csharp::Map.*::Unwrap"; + +// Transaction support classes and functions. +SWIG_CREATE_PROXY(firebase::firestore::csharp::TransactionManager) +%rename("%s") firebase::firestore::csharp::TransactionManager::TransactionManager; +%rename("CppDispose") firebase::firestore::csharp::TransactionManager::Dispose; +%rename("%s") firebase::firestore::csharp::TransactionManager::RunTransaction; + +SWIG_CREATE_PROXY(firebase::firestore::csharp::TransactionCallback) +%rename("%s") firebase::firestore::csharp::TransactionCallback::callback_id; +%rename("%s") firebase::firestore::csharp::TransactionCallback::Delete; +%rename("%s") firebase::firestore::csharp::TransactionCallback::Get; +%rename("%s") firebase::firestore::csharp::TransactionCallback::OnCompletion; +%rename("%s") firebase::firestore::csharp::TransactionCallback::Set; +%rename("%s") firebase::firestore::csharp::TransactionCallback::Update; + +SWIG_CREATE_PROXY(firebase::firestore::csharp::TransactionResultOfGet) +%rename("%s") firebase::firestore::csharp::TransactionResultOfGet::error_code; +%rename("%s") firebase::firestore::csharp::TransactionResultOfGet::error_message; +%rename("%s") firebase::firestore::csharp::TransactionResultOfGet::is_valid; +%rename("%s") firebase::firestore::csharp::TransactionResultOfGet::TakeSnapshot; + +%{ +#include "firestore/src/swig/transaction_manager.h" +%} +%include "firestore/src/swig/transaction_manager.h" + +namespace firebase { +namespace firestore { + +%rename(FieldToValueMapIterator) csharp::Map::MapIterator; +%template(FieldToValueMap) csharp::Map; +%rename(FieldPathToValueMapIterator) csharp::Map::MapIterator; +%template(FieldPathToValueMap) csharp::Map; + +} // namespace firestore +} // namespace firebase + +// `std::vector` wrapper. +%{ +#include "firestore/src/swig/vector.h" +%} +%include "firestore/src/swig/vector.h" + +%rename("$ignore", regextarget=1, fullname=1) "firebase::firestore::csharp::Vector.*::Wrap"; +%rename("$ignore", regextarget=1, fullname=1) "firebase::firestore::csharp::Vector.*::Unwrap"; + +namespace firebase { +namespace firestore { + +%template(DocumentChangeVector) csharp::Vector; +%template(DocumentSnapshotVector) csharp::Vector; +%template(FieldPathVector) csharp::Vector; +%template(FieldValueVector) csharp::Vector; + +} // namespace firestore +} // namespace firebase + +// # LINT.ThenChange(//depot/google3/firebase/firestore/client/unity/generated/src/last-updated.txt) diff --git a/firestore/src/swig/firestore_instance_management.cc b/firestore/src/swig/firestore_instance_management.cc new file mode 100644 index 000000000..5bec5653c --- /dev/null +++ b/firestore/src/swig/firestore_instance_management.cc @@ -0,0 +1,39 @@ +#include "firestore/src/swig/firestore_instance_management.h" + +#include "app/src/cpp_instance_manager.h" +#include "firestore/src/include/firebase/firestore.h" + +namespace firebase { +namespace firestore { +namespace csharp { + +namespace { + +CppInstanceManager& GetFirestoreInstanceManager() { + // Allocate the CppInstanceManager on the heap to prevent its destructor + // from executing (go/totw/110#the-fix-safe-initialization-no-destruction). + static CppInstanceManager* firestore_instance_manager = + new CppInstanceManager(); + return *firestore_instance_manager; +} + +} // namespace + +Firestore* GetFirestoreInstance(App* app) { + auto& firestore_instance_manager = GetFirestoreInstanceManager(); + // Acquire the lock used internally by CppInstanceManager::ReleaseReference() + // to avoid racing with deletion of Firestore instances. + MutexLock lock(firestore_instance_manager.mutex()); + Firestore* instance = + Firestore::GetInstance(app, /*init_result_out=*/nullptr); + firestore_instance_manager.AddReference(instance); + return instance; +} + +void ReleaseFirestoreInstance(Firestore* firestore) { + GetFirestoreInstanceManager().ReleaseReference(firestore); +} + +} // namespace csharp +} // namespace firestore +} // namespace firebase diff --git a/firestore/src/swig/firestore_instance_management.h b/firestore/src/swig/firestore_instance_management.h new file mode 100644 index 000000000..2c8140e86 --- /dev/null +++ b/firestore/src/swig/firestore_instance_management.h @@ -0,0 +1,34 @@ +#ifndef FIREBASE_FIRESTORE_CLIENT_UNITY_SRC_SWIG_FIRESTORE_INSTANCE_MANAGEMENT_H_ +#define FIREBASE_FIRESTORE_CLIENT_UNITY_SRC_SWIG_FIRESTORE_INSTANCE_MANAGEMENT_H_ + +namespace firebase { + +class App; + +namespace firestore { + +class Firestore; + +namespace csharp { + +/** + * Returns the Firestore instance for the given App, creating it if necessary. + * This method is merely a wrapper around Firestore::GetInstance() that + * increments a reference count each time a given Firestore pointer is returned. + * The caller must call ReleaseFirestoreInstance() with the returned pointer + * once it is no longer referenced to ensure proper garbage collection. + */ +Firestore* GetFirestoreInstance(App* app); + +/** + * Decrements the reference count of the given Firestore, deleting it if the + * reference count becomes zero. The given Firestore pointer must have been + * returned by a previous invocation of GetFirestoreInstance(). + */ +void ReleaseFirestoreInstance(Firestore* firestore); + +} // namespace csharp +} // namespace firestore +} // namespace firebase + +#endif // FIREBASE_FIRESTORE_CLIENT_UNITY_SRC_SWIG_FIRESTORE_INSTANCE_MANAGEMENT_H_ diff --git a/firestore/src/swig/load_bundle_task_progress_callback.cc b/firestore/src/swig/load_bundle_task_progress_callback.cc new file mode 100644 index 000000000..1b24ab732 --- /dev/null +++ b/firestore/src/swig/load_bundle_task_progress_callback.cc @@ -0,0 +1,56 @@ +#include "firestore/src/swig/load_bundle_task_progress_callback.h" + +#include +#include + +#include "app/src/callback.h" + +namespace firebase { +namespace firestore { +namespace csharp { + +namespace { + +class ProgressCallback { + public: + ProgressCallback(LoadBundleTaskProgressCallback callback, int32_t callback_id, + std::unique_ptr progress) + : callback_(callback), + callback_id_(callback_id), + progress_(std::move(progress)) {} + + static void Run(ProgressCallback* callback) { callback->Run(); } + + private: + void Run() { + // Ownership of the progress pointer is passed to C#. + callback_(callback_id_, progress_.release()); + } + + LoadBundleTaskProgressCallback callback_ = nullptr; + int32_t callback_id_ = -1; + std::unique_ptr progress_; +}; + +} // namespace + +void LoadBundleWithCallback(Firestore* firestore, + const std::string& bundle_data, int32_t callback_id, + LoadBundleTaskProgressCallback callback) { + auto progress_listener = + [callback, callback_id](const LoadBundleTaskProgress& progress) { + // NOLINTNEXTLINE(modernize-make-unique) + std::unique_ptr progress_ptr( + new LoadBundleTaskProgress(progress)); + ProgressCallback progress_callback(callback, callback_id, + std::move(progress_ptr)); + auto* callback = new callback::CallbackMoveValue1( + std::move(progress_callback), ProgressCallback::Run); + callback::AddCallback(callback); + }; + firestore->LoadBundle(bundle_data, progress_listener); +} + +} // namespace csharp +} // namespace firestore +} // namespace firebase diff --git a/firestore/src/swig/load_bundle_task_progress_callback.h b/firestore/src/swig/load_bundle_task_progress_callback.h new file mode 100644 index 000000000..0202f11a8 --- /dev/null +++ b/firestore/src/swig/load_bundle_task_progress_callback.h @@ -0,0 +1,42 @@ +#ifndef FIREBASE_FIRESTORE_CLIENT_UNITY_SRC_SWIG_LOAD_BUNDLE_TASK_PROGRESS_CALLBACK_H_ +#define FIREBASE_FIRESTORE_CLIENT_UNITY_SRC_SWIG_LOAD_BUNDLE_TASK_PROGRESS_CALLBACK_H_ + +#include + +#include + +#include "firestore/src/include/firebase/firestore.h" +#include "firestore/src/include/firebase/firestore/load_bundle_task_progress.h" + +namespace firebase { +namespace firestore { +namespace csharp { + +// Add this to make this header compile when SWIG is not involved. +#ifndef SWIGSTDCALL +#if !defined(SWIG) && \ + (defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)) +#define SWIGSTDCALL __stdcall +#else +#define SWIGSTDCALL +#endif +#endif + +// The callbacks that are used by the listener, that need to reach back to C# +// callbacks. +typedef void(SWIGSTDCALL* LoadBundleTaskProgressCallback)( + int32_t callback_id, LoadBundleTaskProgress* progress); + +// This method is a proxy to Firestore::LoadBundle() +// that can be easily called from C#. It allows our C# wrapper to +// track user callbacks in a dictionary keyed off of a unique int +// for each user callback and then raise the correct one later. +void LoadBundleWithCallback(Firestore* firestore, + const std::string& bundle_data, int32_t callback_id, + LoadBundleTaskProgressCallback callback); + +} // namespace csharp +} // namespace firestore +} // namespace firebase + +#endif // FIREBASE_FIRESTORE_CLIENT_UNITY_SRC_SWIG_LOAD_BUNDLE_TASK_PROGRESS_CALLBACK_H_ diff --git a/firestore/src/swig/map.h b/firestore/src/swig/map.h new file mode 100644 index 000000000..66d415bf7 --- /dev/null +++ b/firestore/src/swig/map.h @@ -0,0 +1,224 @@ +#ifndef FIREBASE_FIRESTORE_CLIENT_UNITY_SRC_SWIG_MAP_H_ +#define FIREBASE_FIRESTORE_CLIENT_UNITY_SRC_SWIG_MAP_H_ + +#include +#include + +#include "app/meta/move.h" +#include "firestore/src/common/futures.h" +#include "firestore/src/include/firebase/firestore/document_reference.h" +#include "firestore/src/include/firebase/firestore/document_snapshot.h" +#include "firestore/src/include/firebase/firestore/field_path.h" +#include "firestore/src/include/firebase/firestore/field_value.h" +#include "firestore/src/include/firebase/firestore/query.h" +#include "firestore/src/include/firebase/firestore/set_options.h" +#include "firestore/src/include/firebase/firestore/write_batch.h" + +namespace firebase { +namespace firestore { +namespace csharp { + +// Simple wrappers to avoid exposing C++ standard library containers to SWIG. +// +// While it's normally possible to work with standard library containers in SWIG +// (by instantiating them for each template type used via the `%template` +// directive), issues in the build environment make that approach too +// complicated to be worth it. Instead, use simple wrappers and make sure the +// underlying containers are never exposed to C#. +// +// Note: most of the time, these classes should be declared with a `using` +// statement to ensure predictable lifetime of the object when dealing with +// iterators or unsafe views. + +// Wraps `std::unordered_map` for use in C# code. +// Note: `V` has to be default-constructible with a sensible default value. +template +class Map { +#ifdef STLPORT +#define FIRESTORE_STD_NS std::tr1 +#else +#define FIRESTORE_STD_NS std +#endif + using ContainerT = FIRESTORE_STD_NS::unordered_map; + using IterT = typename ContainerT::const_iterator; +#undef FIRESTORE_STD_NS + + public: + Map() = default; + + std::size_t Size() const { return container_.size(); } + + // The returned reference is only valid as long as this `Map` is + // valid. In C#, declare the map with a `using` statement to ensure its + // lifetime exceeds the lifetime of the reference. + const V& GetUnsafeView(const K& key) const { + auto found = container_.find(key); + if (found != container_.end()) { + return found->second; + } + + return InvalidValue(); + } + + V GetCopy(const K& key) const { + // Note: this is safe because the reference returned by `GetUnsafeView` is + // copied into the return value. + return GetUnsafeView(key); + } + + void Insert(const K& key, const V& value) { container_[key] = value; } + + class MapIterator { + public: + bool HasMore() const { return cur_ != end_; } + + void Advance() { ++cur_; } + + const K& UnsafeKeyView() const { return cur_->first; } + const V& UnsafeValueView() const { return cur_->second; } + + K KeyCopy() const { return cur_->first; } + V ValueCopy() const { return cur_->second; } + + private: + friend class Map; + explicit MapIterator(const Map& wrapper) + : cur_{wrapper.Unwrap().begin()}, end_{wrapper.Unwrap().end()} {} + + Map::IterT cur_, end_; + }; + + MapIterator Iterator() const { return MapIterator(*this); } + + // Note: this is a named function and not a constructor to make it easier to + // ignore in SWIG. + static Map Wrap(const std::unordered_map& container) { + return Map(container); + } + + const std::unordered_map& Unwrap() const { return container_; } + + private: + explicit Map(const std::unordered_map& container) + : container_(container) {} + + static const V& InvalidValue() { + static V value; + return value; + } + + ContainerT container_; +}; + +inline Map ConvertFieldValueToMap( + const FieldValue& field_value) { + return Map::Wrap(field_value.map_value()); +} + +inline FieldValue ConvertMapToFieldValue( + const Map& wrapper) { + return FieldValue::Map(wrapper.Unwrap()); +} + +inline FieldValue ConvertSnapshotToFieldValue( + const DocumentSnapshot& snapshot, + DocumentSnapshot::ServerTimestampBehavior stb) { + return FieldValue::Map(snapshot.GetData(stb)); +} + +inline void WriteBatchUpdate(WriteBatch* batch, + const DocumentReference& doc, + const FieldValue& field_value) { + batch->Update(doc, field_value.map_value()); +} + +inline void WriteBatchUpdate( + WriteBatch* batch, const DocumentReference& doc, + const Map& wrapper) { + batch->Update(doc, wrapper.Unwrap()); +} + +inline void WriteBatchUpdate( + WriteBatch* batch, const DocumentReference& doc, + const Map& wrapper) { + batch->Update(doc, wrapper.Unwrap()); +} + +inline Future DocumentReferenceSet(DocumentReference& doc, + const FieldValue& field_value, + const SetOptions& options) { + return doc.Set(field_value.map_value(), options); +} + +inline Future DocumentReferenceUpdate( + DocumentReference& doc, const FieldValue& field_value) { + return doc.Update(field_value.map_value()); +} + +inline Future DocumentReferenceUpdate( + DocumentReference& doc, const Map& wrapper) { + return doc.Update(wrapper.Unwrap()); +} + +inline Query QueryWhereArrayContainsAny(Query& query, + const std::string& field, + const FieldValue& values) { + // TODO(b/158342776): prevent an avoidable copy. SWIG would allocate a new + // `Query` on the heap and initialize it with a copy of this return value. + return query.WhereArrayContainsAny(field, values.array_value()); +} + +inline Query QueryWhereArrayContainsAny(Query& query, + const FieldPath& field, + const FieldValue& values) { + return query.WhereArrayContainsAny(field, values.array_value()); +} + +inline Query QueryWhereIn(Query& query, const std::string& field, + const FieldValue& values) { + return query.WhereIn(field, values.array_value()); +} + +inline Query QueryWhereIn(Query& query, const FieldPath& field, + const FieldValue& values) { + return query.WhereIn(field, values.array_value()); +} + +inline Query QueryWhereNotIn(Query& query, const std::string& field, + const FieldValue& values) { + return query.WhereNotIn(field, values.array_value()); +} + +inline Query QueryWhereNotIn(Query& query, const FieldPath& field, + const FieldValue& values) { + return query.WhereNotIn(field, values.array_value()); +} + +inline Query QueryStartAt(Query& query, const FieldValue& values) { + return query.StartAt(values.array_value()); +} + +inline Query QueryStartAfter(Query& query, const FieldValue& values) { + return query.StartAfter(values.array_value()); +} + +inline Query QueryEndBefore(Query& query, const FieldValue& values) { + return query.EndBefore(values.array_value()); +} + +inline Query QueryEndAt(Query& query, const FieldValue& values) { + return query.EndAt(values.array_value()); +} + +inline void WriteBatchSet(WriteBatch& write_batch, + const DocumentReference& document, + const FieldValue& data, + const SetOptions& options) { + write_batch.Set(document, data.map_value(), options); +} + +} // namespace csharp +} // namespace firestore +} // namespace firebase + +#endif // FIREBASE_FIRESTORE_CLIENT_UNITY_SRC_SWIG_MAP_H_ diff --git a/firestore/src/swig/proxy_helpers.i b/firestore/src/swig/proxy_helpers.i new file mode 100644 index 000000000..3889c8bcb --- /dev/null +++ b/firestore/src/swig/proxy_helpers.i @@ -0,0 +1,35 @@ +// Copyright 2020 Google LLC +// + +// This file contains macros to deal with the generated C# proxy classes in +// a uniform way. + + + +// Begins a new mapping declaration for a public Firestore class. This mapping +// appends `Proxy` suffix to the given `classname` and ignores all its members +// (except the destructor). After calling this macro, list out the class members +// that should be kept in the generated code explicitly, e.g. +// +// SWIG_CREATE_PROXY(firebase::firestore::Foo) +// %rename("%s") firebase::firestore::Foo::Bar; +// %rename("%s") firebase::firestore::Foo::Baz; +%define SWIG_CREATE_PROXY(classname) + +%rename("%sProxy") #classname ; + +// The regular expression means "ignore all members that don't start with `~`", +// i.e. ignore everything except the destructor. Ignoring the destructor would +// make the resulting class leak memory (see +// https://docs.google.com/document/d/1qqYXGzbB-01l00Mv-dGbGRXZn9XCAHjGtwstgj31R1Q/edit#heading=h.zgrg0ghm4bhl +// ). +%rename("$ignore", regextarget=1, fullname=1) #classname "::(?!~).*"; + +// Makes sure enumeration members are not ignored (the alternative is to list +// each one explicitly, which is tedious). The enumeration itself still has to +// be unignored manually. +%rename("%s", %$isenumitem) ""; + +%enddef + +// # LINT.ThenChange(//depot/google3/firebase/firestore/client/unity/generated/src/last-updated.txt) diff --git a/firestore/src/swig/query_event_listener.cc b/firestore/src/swig/query_event_listener.cc new file mode 100644 index 000000000..dff5542d9 --- /dev/null +++ b/firestore/src/swig/query_event_listener.cc @@ -0,0 +1,67 @@ +#include "firestore/src/swig/query_event_listener.h" + +#include +#include +#include + +#include "app/src/callback.h" +#include "firestore/src/include/firebase/firestore/query.h" + +namespace firebase { +namespace firestore { +namespace csharp { + +namespace { + +class ListenerCallback { + public: + ListenerCallback(QueryEventListenerCallback callback, int32_t callback_id, + std::unique_ptr snapshot, Error error_code, + std::string error_message) + : callback_(callback), + callback_id_(callback_id), + snapshot_(std::move(snapshot)), + error_code_(error_code), + error_message_(std::move(error_message)) {} + + static void Run(ListenerCallback* listener_callback) { + listener_callback->Run(); + } + + private: + void Run() { + // Ownership of the QuerySnapshot pointer is passed to C#. + callback_(callback_id_, snapshot_.release(), error_code_, + error_message_.c_str()); + } + + QueryEventListenerCallback callback_ = nullptr; + int32_t callback_id_ = -1; + std::unique_ptr snapshot_; + Error error_code_ = Error::kErrorUnknown; + std::string error_message_; +}; + +} // namespace + +ListenerRegistration AddQuerySnapshotListener( + Query* query, MetadataChanges metadata_changes, int32_t callback_id, + QueryEventListenerCallback callback) { + auto snapshot_listener = [callback, callback_id]( + const QuerySnapshot& snapshot, Error error_code, + const std::string& error_message) { + // NOLINTNEXTLINE(modernize-make-unique) + std::unique_ptr snapshot_ptr(new QuerySnapshot(snapshot)); + ListenerCallback listener_callback(callback, callback_id, + std::move(snapshot_ptr), error_code, + error_message); + auto* callback = new callback::CallbackMoveValue1( + std::move(listener_callback), ListenerCallback::Run); + callback::AddCallback(callback); + }; + return query->AddSnapshotListener(metadata_changes, snapshot_listener); +} + +} // namespace csharp +} // namespace firestore +} // namespace firebase diff --git a/firestore/src/swig/query_event_listener.h b/firestore/src/swig/query_event_listener.h new file mode 100644 index 000000000..1cba58392 --- /dev/null +++ b/firestore/src/swig/query_event_listener.h @@ -0,0 +1,40 @@ +#ifndef FIREBASE_FIRESTORE_CLIENT_UNITY_SRC_SWIG_QUERY_EVENT_LISTENER_H_ +#define FIREBASE_FIRESTORE_CLIENT_UNITY_SRC_SWIG_QUERY_EVENT_LISTENER_H_ + +#include "firebase/firestore/firestore_errors.h" +#include "firestore/src/include/firebase/firestore/listener_registration.h" +#include "firestore/src/include/firebase/firestore/query_snapshot.h" + +namespace firebase { +namespace firestore { +namespace csharp { + +// Add this to make this header compile when SWIG is not involved. +#ifndef SWIGSTDCALL +#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +#define SWIGSTDCALL __stdcall +#else +#define SWIGSTDCALL +#endif +#endif + +// The callbacks that are used by the listener, that need to reach back to C# +// callbacks. The error_message pointer is only valid for the duration of the +// callback. +typedef void(SWIGSTDCALL* QueryEventListenerCallback)( + int32_t callback_id, QuerySnapshot* snapshot, Error error_code, + const char* error_message); + +// This method is a proxy to Query::AddSnapshotsListener() +// that can be easily called from C#. It allows our C# wrapper to +// track user callbacks in a dictionary keyed off of a unique int +// for each user callback and then raise the correct one later. +ListenerRegistration AddQuerySnapshotListener( + Query* query, MetadataChanges metadata_changes, int32_t callback_id, + QueryEventListenerCallback callback); + +} // namespace csharp +} // namespace firestore +} // namespace firebase + +#endif // FIREBASE_FIRESTORE_CLIENT_UNITY_SRC_SWIG_QUERY_EVENT_LISTENER_H_ diff --git a/firestore/src/swig/snapshots_in_sync_listener.cc b/firestore/src/swig/snapshots_in_sync_listener.cc new file mode 100644 index 000000000..d1131f70f --- /dev/null +++ b/firestore/src/swig/snapshots_in_sync_listener.cc @@ -0,0 +1,43 @@ +#include "firestore/src/swig/snapshots_in_sync_listener.h" + +#include "app/src/callback.h" + +namespace firebase { +namespace firestore { +namespace csharp { + +namespace { + +class ListenerCallback { + public: + ListenerCallback(SnapshotsInSyncCallback callback, int32_t callback_id) + : callback_(callback), callback_id_(callback_id) {} + + static void Run(ListenerCallback* listener_callback) { + listener_callback->Run(); + } + + private: + void Run() { callback_(callback_id_); } + + SnapshotsInSyncCallback callback_ = nullptr; + int32_t callback_id_ = -1; +}; + +} // namespace + +ListenerRegistration AddSnapshotsInSyncListener( + Firestore* firestore, int32_t callback_id, + SnapshotsInSyncCallback callback) { + auto snapshots_in_sync_listener = [callback, callback_id] { + ListenerCallback listener_callback(callback, callback_id); + auto* callback = new callback::CallbackMoveValue1( + std::move(listener_callback), ListenerCallback::Run); + callback::AddCallback(callback); + }; + return firestore->AddSnapshotsInSyncListener(snapshots_in_sync_listener); +} + +} // namespace csharp +} // namespace firestore +} // namespace firebase diff --git a/firestore/src/swig/snapshots_in_sync_listener.h b/firestore/src/swig/snapshots_in_sync_listener.h new file mode 100644 index 000000000..ad4cda7f0 --- /dev/null +++ b/firestore/src/swig/snapshots_in_sync_listener.h @@ -0,0 +1,36 @@ +#ifndef FIREBASE_FIRESTORE_CLIENT_UNITY_SRC_SWIG_SNAPSHOTS_IN_SYNC_LISTENER_H_ +#define FIREBASE_FIRESTORE_CLIENT_UNITY_SRC_SWIG_SNAPSHOTS_IN_SYNC_LISTENER_H_ + +#include "firestore/src/include/firebase/firestore.h" + +namespace firebase { +namespace firestore { +namespace csharp { + +// Add this to make this header compile when SWIG is not involved. +#ifndef SWIGSTDCALL +#if !defined(SWIG) && \ + (defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)) +#define SWIGSTDCALL __stdcall +#else +#define SWIGSTDCALL +#endif +#endif + +// The callbacks that are used by the listener, that need to reach back to C# +// callbacks. +typedef void(SWIGSTDCALL* SnapshotsInSyncCallback)(int callback_id); + +// This method is a proxy to Firestore::AddSnapshotsInSyncListener() +// that can be easily called from C#. It allows our C# wrapper to +// track user callbacks in a dictionary keyed off of a unique int +// for each user callback and then raise the correct one later. +ListenerRegistration AddSnapshotsInSyncListener( + Firestore* firestore, int32_t callback_id, + SnapshotsInSyncCallback callback); + +} // namespace csharp +} // namespace firestore +} // namespace firebase + +#endif // FIREBASE_FIRESTORE_CLIENT_UNITY_SRC_SWIG_SNAPSHOTS_IN_SYNC_LISTENER_H_ diff --git a/firestore/src/swig/transaction_manager.cc b/firestore/src/swig/transaction_manager.cc new file mode 100644 index 000000000..3fccdb994 --- /dev/null +++ b/firestore/src/swig/transaction_manager.cc @@ -0,0 +1,303 @@ +#include "firestore/src/swig/transaction_manager.h" + +#include // NOLINT(build/c++11) +#include + +#include "app/src/assert.h" +#include "app/src/callback.h" +#include "firestore/src/include/firebase/firestore/document_reference.h" +#include "firestore/src/include/firebase/firestore/field_path.h" +#include "firestore/src/include/firebase/firestore/field_value.h" +#include "firestore/src/include/firebase/firestore/set_options.h" +#include "firestore/src/include/firebase/firestore/transaction.h" + +#if defined(__ANDROID__) +#include "firestore/src/android/firestore_android.h" +#elif defined(FIRESTORE_STUB_BUILD) +#include "firestore/src/stub/firestore_stub.h" +#else +#include "firestore/src/main/firestore_main.h" +#endif // defined(__ANDROID__) + +namespace firebase { +namespace firestore { +namespace csharp { + +class TransactionCallbackInternal { + public: + explicit TransactionCallbackInternal(Transaction& transaction) + : transaction_(transaction) {} + + void OnCompletion(bool callback_successful) { + std::lock_guard lock(completion_mutex_); + if (is_completed_) { + return; + } + is_completed_ = true; + result_ = callback_successful; + completion_condition_.notify_all(); + } + + // Waits for `OnCompletion()` to be invoked. + // + // If `OnCompletion()` has already been invoked then this method returns + // immediately; otherwise, it blocks waiting for it to be invoked. + // + // Returns the value that was specified to `OnCompletion()` for its argument. + bool AwaitCompletion() { + std::unique_lock lock(completion_mutex_); + completion_condition_.wait(lock, [&] { return is_completed_; }); + return result_; + } + + // Marks the `Transaction` reference that was given to the constructor as + // "invalid". + // + // After this method is invoked, all transaction-related methods in this class + // (i.e. `Get()`, `Set()`, `Update()`, and `Delete()`) will simply return a + // "failed" value and will not actually invoke methods on the encapsulated + // `Transaction` reference. + // + // This method will block until all in-flight transaction-related methods + // at the time of invocation have completed. + void InvalidateTransaction() { + std::lock_guard transaction_lock(transaction_mutex_); + is_transaction_valid_ = false; + } + + TransactionResultOfGet Get(const DocumentReference& doc) { + std::lock_guard transaction_lock(transaction_mutex_); + if (!is_transaction_valid_) { + return {}; + } + Error error_code = Error::kErrorUnknown; + std::string error_message; + DocumentSnapshot snapshot = + transaction_.Get(doc, &error_code, &error_message); + return {std::move(snapshot), error_code, std::move(error_message)}; + } + + bool Update(const DocumentReference& doc, const FieldValue& field_value) { + std::lock_guard transaction_lock(transaction_mutex_); + if (!is_transaction_valid_) { + return false; + } + transaction_.Update(doc, field_value.map_value()); + return true; + } + + bool Update(const DocumentReference& doc, + const Map& wrapper) { + std::lock_guard transaction_lock(transaction_mutex_); + if (!is_transaction_valid_) { + return false; + } + transaction_.Update(doc, wrapper.Unwrap()); + return true; + } + + bool Update(const DocumentReference& doc, + const Map& wrapper) { + std::lock_guard transaction_lock(transaction_mutex_); + if (!is_transaction_valid_) { + return false; + } + transaction_.Update(doc, wrapper.Unwrap()); + return true; + } + + bool Set(const DocumentReference& doc, const FieldValue& data, + const SetOptions& options) { + std::lock_guard transaction_lock(transaction_mutex_); + if (!is_transaction_valid_) { + return false; + } + transaction_.Set(doc, data.map_value(), options); + return true; + } + + bool Delete(const DocumentReference& doc) { + std::lock_guard transaction_lock(transaction_mutex_); + if (!is_transaction_valid_) { + return false; + } + transaction_.Delete(doc); + return true; + } + + private: + // TODO(b/172565676) Change `transaction_mutex_` from an exclusive mutex to a + // shared mutex to enable concurrent method invocations on `transaction_`. + std::mutex transaction_mutex_; + Transaction& transaction_; + bool is_transaction_valid_ = true; + + std::mutex completion_mutex_; + std::condition_variable completion_condition_; + bool is_completed_ = false; + bool result_ = false; +}; + +class TransactionManagerInternal + : public std::enable_shared_from_this { + public: + explicit TransactionManagerInternal(Firestore* firestore) + : firestore_(firestore) { + FIREBASE_ASSERT(firestore); + } + + ~TransactionManagerInternal() { + std::lock_guard lock(mutex_); + FIREBASE_ASSERT(is_disposed_); + FIREBASE_ASSERT(running_callbacks_.empty()); + } + + void Dispose() { + std::lock_guard lock(mutex_); + is_disposed_ = true; + for (TransactionCallbackInternal* running_callback : running_callbacks_) { + running_callback->OnCompletion(false); + } + } + + Future RunTransaction(int32_t callback_id, + TransactionCallbackFn callback_fn) { + std::lock_guard lock(mutex_); + if (is_disposed_) { + return {}; + } + + auto shared_this = shared_from_this(); + return firestore_->RunTransaction([shared_this, callback_id, callback_fn]( + Transaction& transaction, + std::string& error_message) { + if (shared_this->ExecuteCallback(callback_id, callback_fn, transaction)) { + return Error::kErrorOk; + } else { + // Return a non-retryable error code. + return Error::kErrorInvalidArgument; + } + }); + } + + private: + bool ExecuteCallback(int32_t callback_id, TransactionCallbackFn callback_fn, + Transaction& transaction) { + auto transaction_callback_internal = + std::make_shared(transaction); + + { + std::lock_guard lock(mutex_); + if (is_disposed_) { + return false; + } + running_callbacks_.insert(transaction_callback_internal.get()); + } + + auto transaction_callback = + // NOLINTNEXTLINE(modernize-make-unique) + std::unique_ptr(new TransactionCallback( + transaction_callback_internal, callback_id, callback_fn)); + callback::AddCallback( + new callback::CallbackMoveValue1>( + std::move(transaction_callback), ExecuteCallbackFromMainThread)); + bool result = transaction_callback_internal->AwaitCompletion(); + transaction_callback_internal->InvalidateTransaction(); + + { + std::lock_guard lock(mutex_); + running_callbacks_.erase(transaction_callback_internal.get()); + } + + return result; + } + + static void ExecuteCallbackFromMainThread( + std::unique_ptr* transaction_callback) { + TransactionCallbackFn callback_fn = (*transaction_callback)->callback(); + std::shared_ptr transaction_callback_internal = + (*transaction_callback)->internal(); + bool successful = callback_fn(transaction_callback->release()); + if (!successful) { + transaction_callback_internal->OnCompletion(false); + } + } + + std::mutex mutex_; + Firestore* firestore_ = nullptr; + bool is_disposed_ = false; + // NOLINTNEXTLINE(google3-runtime-unneeded-pointer-stability-check) + std::unordered_set running_callbacks_; +}; + +TransactionManager::TransactionManager(Firestore* firestore) + : internal_(std::make_shared(firestore)), + cleanup_notifier_(firestore->internal_->cleanup()) { + cleanup_notifier_.RegisterObject(this, CleanUp); +} + +TransactionManager::~TransactionManager() { Dispose(); } + +void TransactionManager::CleanUp(void* object) { + static_cast(object)->Dispose(); +} + +void TransactionManager::Dispose() { + std::lock_guard lock(dispose_mutex_); + if (!internal_) { + return; + } + + internal_->Dispose(); + internal_.reset(); + + cleanup_notifier_.UnregisterObject(this); +} + +Future TransactionManager::RunTransaction( + int32_t callback_id, TransactionCallbackFn callback_fn) { + // Make a local copy of `internal_` since it could be reset asynchronously + // by a call to `Dispose()`. + std::shared_ptr internal_local = internal_; + if (!internal_local) { + return {}; + } + return internal_local->RunTransaction(callback_id, callback_fn); +} + +void TransactionCallback::OnCompletion(bool callback_successful) { + internal_->OnCompletion(callback_successful); +} + +bool TransactionCallback::Update(const DocumentReference& doc, + const FieldValue& field_value) { + return internal_->Update(doc, field_value); +} + +bool TransactionCallback::Update(const DocumentReference& doc, + const Map& wrapper) { + return internal_->Update(doc, wrapper); +} + +bool TransactionCallback::Update(const DocumentReference& doc, + const Map& wrapper) { + return internal_->Update(doc, wrapper); +} + +bool TransactionCallback::Set(const DocumentReference& doc, + const FieldValue& data, + const SetOptions& options) { + return internal_->Set(doc, data, options); +} + +bool TransactionCallback::Delete(const DocumentReference& doc) { + return internal_->Delete(doc); +} + +TransactionResultOfGet TransactionCallback::Get(const DocumentReference& doc) { + return internal_->Get(doc); +} + +} // namespace csharp +} // namespace firestore +} // namespace firebase diff --git a/firestore/src/swig/transaction_manager.h b/firestore/src/swig/transaction_manager.h new file mode 100644 index 000000000..8690047d7 --- /dev/null +++ b/firestore/src/swig/transaction_manager.h @@ -0,0 +1,199 @@ +#ifndef FIREBASE_FIRESTORE_CLIENT_UNITY_SRC_SWIG_TRANSACTION_MANAGER_H_ +#define FIREBASE_FIRESTORE_CLIENT_UNITY_SRC_SWIG_TRANSACTION_MANAGER_H_ + +#include +#include +#include // NOLINT(build/c++11) +#include +#include + +#include "firestore/src/swig/map.h" +#include "firebase/firestore/firestore_errors.h" +#include "app/src/cleanup_notifier.h" +#include "app/src/include/firebase/future.h" +#include "firestore/src/include/firebase/firestore.h" +#include "firestore/src/include/firebase/firestore/document_snapshot.h" + +// Add this to make this header compile when SWIG is not involved. +#ifndef SWIGSTDCALL +#if !defined(SWIG) && \ + (defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)) +#define SWIGSTDCALL __stdcall +#else +#define SWIGSTDCALL +#endif +#endif + +namespace firebase { +namespace firestore { +namespace csharp { + +class TransactionCallback; +class TransactionCallbackInternal; +class TransactionManagerInternal; + +// The type of the callback function to be specified to +// `TransactionManager::RunTransaction()`. The `TransactionCallback` argument +// contains all information required for C# to execute the callback. Ownership +// of the `TransactionCallback` is transferred to the function. +// +// Returns `true` if the callback was successful or `false` otherwise. If +// successful, then the `OnCompletion()` must have been invoked or must be +// invoked at some point in the future when the callback completes. If +// unsuccessful, then it is not required that `OnCompletion()` be invoked, and +// the transaction will complete in a failed state. +// NOLINTNEXTLINE(readability/casting) +typedef bool(SWIGSTDCALL* TransactionCallbackFn)(TransactionCallback*); + +// Stores the result of calling `Transaction::Get()` in a manner that is +// convenient for exposure to C# via SWIG. +// +// This class is not thread safe. +class TransactionResultOfGet { + public: + // Creates a new "invalid" instance of this class. + TransactionResultOfGet() = default; + + // Creates a new "valid" instance of this class with the given information. + TransactionResultOfGet(DocumentSnapshot&& snapshot, Error error_code, + std::string&& error_message) + : valid_(true), + snapshot_(std::move(snapshot)), + error_code_(error_code), + error_message_(std::move(error_message)) {} + + // Returns whether or not this object is "valid". + // + // If this object is "valid" then the other methods in this class have well- + // defined return values and behaviors; otherwise, the other methods in this + // class have undefined return values and behaviors and should not be invoked. + bool is_valid() const { return valid_; } + + // Returns the `DocumentSnapshot` result of the `Transaction::Get()` call. + // + // This method consumes the `DocumentSnapshot` upon its first invocation; + // subsequent invocations will return an invalid snapshot. + DocumentSnapshot TakeSnapshot() { return std::move(snapshot_); } + + // Returns the error code result of the `Transaction::Get()` call. + Error error_code() const { return error_code_; } + + // Returns the error message result of the `Transaction::Get()` call. + const std::string& error_message() const { return error_message_; } + + private: + // TODO(b/172570071) Replace `valid_` with `DocumentSnapshot::is_valid()`. + bool valid_ = false; + DocumentSnapshot snapshot_; + Error error_code_ = Error::kErrorUnknown; + std::string error_message_; +}; + +// Provides all information and machinery required to perform a transaction +// callback. This includes the callback ID that was specified to +// `RunTransaction()`, an `OnCompletion()` method to signal the success or +// failure of the callback, and indirect access to the `Transaction` object +// associated with the callback. +// +// This class is thread safe. +class TransactionCallback { + public: + TransactionCallback(std::shared_ptr internal, + int32_t callback_id, TransactionCallbackFn callback) + : internal_(internal), callback_id_(callback_id), callback_(callback) {} + + // Returns the internal `shared_ptr` that was specified to + // the constructor. + std::shared_ptr internal() const { + return internal_; + } + + // Returns the callback ID that was specified to + // `TransactionManager::RunTransaction()`. + int32_t callback_id() const { return callback_id_; } + + // Returns the callback function that was specified to + // `TransactionManager::RunTransaction()`. + TransactionCallbackFn callback() const { return callback_; } + + // Calls `Get()` on the encapsulated `Transaction` object with the given + // arguments. Returns a "valid" result object if the call succeeded or an + // "invalid" result object if it failed because the callback has completed. + TransactionResultOfGet Get(const DocumentReference& doc); + + // Calls `Update()`, `Set()` or `Delete()`, respectively, on the encapsulated + // `Transaction` object with the given arguments. Returns `true` if the call + // succeeded or `false` if it failed because the callback has completed. + bool Update(const DocumentReference& doc, const FieldValue& field_value); + bool Update(const DocumentReference& doc, + const Map& wrapper); + bool Update(const DocumentReference& doc, + const Map& wrapper); + bool Set(const DocumentReference& doc, const FieldValue& data, + const SetOptions& options); + bool Delete(const DocumentReference& doc); + + // Notifies the `TransactionManager` that the callback has completed. + // + // The `callback_successful` argument is `true` if the callback succeeded or + // `false` otherwise. + // + // This method must be invoked at least once to wake up the blocked + // transaction thread and complete the callback. Subsequent invocations, + // although allowed, have no effect. + void OnCompletion(bool callback_successful); + + private: + std::shared_ptr internal_; + int32_t callback_id_ = -1; + TransactionCallbackFn callback_ = nullptr; +}; + +// Bridges the C++ transaction API to the C# transaction API. +// +// This class is thread safe. +class TransactionManager { + public: + explicit TransactionManager(Firestore* firestore); + + TransactionManager(const TransactionManager&) = delete; + TransactionManager& operator=(const TransactionManager&) = delete; + + ~TransactionManager(); + + // Shuts down this object. + // + // This method will cause any in-flight transactions to immediately fail and + // unblock any C++ transaction callback threads that are awaiting the + // completion of the transactions. + // + // This method is idempotent and may be safely called multiple times. + void Dispose(); + + // Runs a transaction. + // + // The `callback` function will be invoked to perform the transaction, and the + // `callback_id()` method of the `TransactionCallback` object specified to it + // will contain the given `callback_id`. + // + // This method uses the `RunTransaction()` method of the `Firestore` instance + // that was specified to the constructor to actually run the transaction. + // + // If `Dispose()` has been invoked, or the `Firestore` instance has been + // destroyed, then this method will immediately return an invalid `Future`. + Future RunTransaction(int32_t callback_id, + TransactionCallbackFn callback); + + private: + static void CleanUp(void* object); + + std::shared_ptr internal_; + CleanupNotifier& cleanup_notifier_; + std::mutex dispose_mutex_; +}; + +} // namespace csharp +} // namespace firestore +} // namespace firebase + +#endif // FIREBASE_FIRESTORE_CLIENT_UNITY_SRC_SWIG_TRANSACTION_MANAGER_H_ diff --git a/firestore/src/swig/types.i b/firestore/src/swig/types.i new file mode 100644 index 000000000..52a9f1557 --- /dev/null +++ b/firestore/src/swig/types.i @@ -0,0 +1,35 @@ +// Copyright 2019 Google Inc. All Rights Reserved. +// +// The SWIG interface to wrap Firestore types that come from `third_party`. + + + +%include "stdint.i" +%include "std_string.i" + +%import "firestore/src/swig/proxy_helpers.i" +%include "app/src/swig/null_check_this.i" + +// Generate a C# wrapper for GeoPoint. +SWIG_CREATE_PROXY(firebase::firestore::GeoPoint) +%rename("%s") firebase::firestore::GeoPoint::GeoPoint(double, double); +%rename("%s") firebase::firestore::GeoPoint::latitude; +%rename("%s") firebase::firestore::GeoPoint::longitude; +%include \firebase/firestore/geo_point.h" + +// Generate a C# wrapper for Timestamp. +SWIG_CREATE_PROXY(firebase::Timestamp) +%rename("%s") firebase::Timestamp::Timestamp; +%rename("%s") firebase::Timestamp::Now; +%rename("%s") firebase::Timestamp::seconds; +%rename("%s") firebase::Timestamp::nanoseconds; +%rename("%s") firebase::Timestamp::ToString; +%csmethodmodifiers ToString "public override"; +%include \firebase/firestore/timestamp.h" + +// Generate Error enum. +%rename("FirestoreError") firebase::firestore::Error; +%rename("%(regex:/Error(.*)/\\1/)s", %$isenumitem) ""; +%include \firebase/firestore/firestore_errors.h" + +// # LINT.ThenChange(//depot/google3/firebase/firestore/client/unity/generated/src/last-updated.txt) diff --git a/firestore/src/swig/vector.h b/firestore/src/swig/vector.h new file mode 100644 index 000000000..7e61cc693 --- /dev/null +++ b/firestore/src/swig/vector.h @@ -0,0 +1,94 @@ +#ifndef FIREBASE_FIRESTORE_CLIENT_UNITY_SRC_SWIG_VECTOR_H_ +#define FIREBASE_FIRESTORE_CLIENT_UNITY_SRC_SWIG_VECTOR_H_ + +#include "firestore/src/include/firebase/firestore/document_change.h" +#include "firestore/src/include/firebase/firestore/document_snapshot.h" +#include "firestore/src/include/firebase/firestore/field_path.h" +#include "firestore/src/include/firebase/firestore/field_value.h" +#include "firestore/src/include/firebase/firestore/metadata_changes.h" +#include "firestore/src/include/firebase/firestore/query_snapshot.h" +#include "firestore/src/include/firebase/firestore/set_options.h" + +namespace firebase { +namespace firestore { +namespace csharp { + +// Simple wrappers to avoid exposing C++ standard library containers to SWIG. +// +// While it's normally possible to work with standard library containers in SWIG +// (by instantiating them for each template type used via the `%template` +// directive), issues in the build environment make that approach too +// complicated to be worth it. Instead, use simple wrappers and make sure the +// underlying containers are never exposed to C#. +// +// Note: most of the time, these classes should be declared with a `using` +// statement to ensure predictable lifetime of the object when dealing with +// iterators or unsafe views. + +// Wraps `std::vector` for use in C# code. +template +class Vector { + public: + Vector() = default; + + std::size_t Size() const { return container_.size(); } + + // The returned reference is only valid as long as this `Vector` is + // valid. In C#, declare the vector with a `using` statement to ensure its + // lifetime exceeds the lifetime of the reference. + const T& GetUnsafeView(std::size_t i) const { return container_[i]; } + + T GetCopy(std::size_t i) const { return container_[i]; } + + void PushBack(const T& value) { container_.push_back(value); } + + // Note: this is a named function and not a constructor to make it easier to + // ignore in SWIG. + static Vector Wrap(const std::vector& container) { + return Vector(container); + } + + const std::vector& Unwrap() const { return container_; } + + private: + explicit Vector(const std::vector& container) : container_(container) {} + + std::vector container_; +}; + +Vector ConvertFieldValueToVector(const FieldValue& value) { + return Vector::Wrap(value.array_value()); +} + +inline FieldValue ConvertVectorToFieldValue(const Vector& wrapper) { + return FieldValue::Array(wrapper.Unwrap()); +} + +inline FieldValue FieldValueArrayUnion(const Vector& wrapper) { + return FieldValue::ArrayUnion(wrapper.Unwrap()); +} + +inline FieldValue FieldValueArrayRemove(const Vector& wrapper) { + return FieldValue::ArrayRemove(wrapper.Unwrap()); +} + +inline Vector QuerySnapshotDocuments( + const QuerySnapshot& snapshot) { + return Vector::Wrap(snapshot.documents()); +} + +inline Vector QuerySnapshotDocumentChanges( + const QuerySnapshot& snapshot, MetadataChanges metadata_changes) { + return Vector::Wrap( + snapshot.DocumentChanges(metadata_changes)); +} + +inline SetOptions SetOptionsMergeFieldPaths(const Vector& fields) { + return SetOptions::MergeFieldPaths(fields.Unwrap()); +} + +} // namespace csharp +} // namespace firestore +} // namespace firebase + +#endif // FIREBASE_FIRESTORE_CLIENT_UNITY_SRC_SWIG_VECTOR_H_ diff --git a/firestore/testapp/Assets/Firebase/Editor/Builder.cs b/firestore/testapp/Assets/Firebase/Editor/Builder.cs new file mode 100644 index 000000000..566cf3239 --- /dev/null +++ b/firestore/testapp/Assets/Firebase/Editor/Builder.cs @@ -0,0 +1,27 @@ +using UnityEditor; +using UnityEngine; + +// Allows doing builds from the command line. +// +// For more information, see: +// https://docs.unity3d.com/Manual/CommandLineArguments.html +// https://docs.unity3d.com/ScriptReference/BuildOptions.html +// https://docs.unity3d.com/ScriptReference/BuildPipeline.BuildPlayer.html +public class Builder { + + public static void BuildIos() { + var options = new BuildPlayerOptions(); + + options.scenes = new string[] { "Assets/Firebase/Sample/Firestore/MainSceneAutomated.unity" }; + options.locationPathName = "ios-build"; + options.target = BuildTarget.iOS; + // AcceptExternalModificationsToPlayer corresponds to "Append" in the Unity + // UI -- it allows doing incremental iOS build. + options.options = BuildOptions.AcceptExternalModificationsToPlayer; + // Firebase Unity plugins don't seem to work on a simulator. + PlayerSettings.iOS.sdkVersion = iOSSdkVersion.DeviceSDK; + + BuildPipeline.BuildPlayer(options); + } + +} diff --git a/firestore/testapp/Assets/Firebase/Sample/Firestore/EventAccumulator.cs b/firestore/testapp/Assets/Firebase/Sample/Firestore/EventAccumulator.cs new file mode 100644 index 000000000..2b961619a --- /dev/null +++ b/firestore/testapp/Assets/Firebase/Sample/Firestore/EventAccumulator.cs @@ -0,0 +1,92 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using UnityEngine; + +namespace Firebase.Sample.Firestore { + class EventAccumulator { + private TaskCompletionSource completion; + private readonly List events = new List(); + private int maxEvents = 0; + private bool assertOnAnyEvent = false; + private int mainThreadId = -1; + + public EventAccumulator() { } + public EventAccumulator(int mainThreadId) { + this.mainThreadId = mainThreadId; + } + + /// + /// Returns a listener callback suitable for passing to Listen(). + /// + public Action Listener { + get { + return (value) => { + lock (this) { + HardAssert(!assertOnAnyEvent, "Received unexpected event: " + value); + if (mainThreadId > 0) { + HardAssert(1 == Thread.CurrentThread.ManagedThreadId, "Listener callback from non-main thread."); + } + events.Add(value); + CheckFulfilled(); + } + }; + } + } + + /// + /// Waits for the specified number of events and returns them. + /// + public List Await(int numEvents) { + lock (this) { + HardAssert(completion == null, "calling await while another await is running"); + completion = new TaskCompletionSource(); + maxEvents = maxEvents + numEvents; + CheckFulfilled(); + } + + completion.Task.Wait(); + + lock (this) { + completion = null; + return events.GetRange(maxEvents - numEvents, numEvents); + } + } + + /// + /// Waits for an event and returns it. + /// + public T Await() { + return Await(1)[0]; + } + + /// + /// Throw an exception if any more events are received. + /// + public void ThrowOnAnyEvent() { + lock (this) { + HardAssert(events.Count == maxEvents, "Received unexpected event: " + events.Last()); + assertOnAnyEvent = true; + } + } + + private void CheckFulfilled() { + lock (this) { + if (completion != null && events.Count >= maxEvents) { + completion.SetResult(null); + } + } + } + + private void HardAssert(bool condition, string message) { + if (!condition) { + string text = "Assertion Failure: " + message; + UnityEngine.Debug.Log(text); + throw new Exception(text); + } + } + } +} diff --git a/firestore/testapp/Assets/Firebase/Sample/Firestore/MainScene.unity b/firestore/testapp/Assets/Firebase/Sample/Firestore/MainScene.unity new file mode 100644 index 000000000..c41c61066 --- /dev/null +++ b/firestore/testapp/Assets/Firebase/Sample/Firestore/MainScene.unity @@ -0,0 +1,212 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +SceneSettings: + m_ObjectHideFlags: 0 + m_PVSData: + m_PVSObjectsArray: [] + m_PVSPortalsArray: [] + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 7 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 7 + m_GIWorkflowMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_TemporalCoherenceThreshold: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_LightmapEditorSettings: + serializedVersion: 4 + m_Resolution: 2 + m_BakeResolution: 40 + m_TextureWidth: 1024 + m_TextureHeight: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_DirectLightInLightProbes: 1 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 256 + m_ReflectionCompression: 2 + m_LightingDataAsset: {fileID: 0} + m_RuntimeCPUUsage: 25 +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + accuratePlacement: 0 + minRegionArea: 2 + cellSize: 0.16666667 + manualCellSize: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &767379076 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 767379081} + - 20: {fileID: 767379080} + - 124: {fileID: 767379078} + - 81: {fileID: 767379077} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &767379077 +AudioListener: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 767379076} + m_Enabled: 1 +--- !u!124 &767379078 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 767379076} + m_Enabled: 1 +--- !u!20 &767379080 +Camera: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 767379076} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 2 + m_BackGroundColor: {r: 0.9063581, g: 0.93133646, b: 0.9705882, a: 0.019607844} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 1 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 + m_StereoMirrorMode: 0 +--- !u!4 &767379081 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 767379076} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!1 &1468353535 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 1468353536} + - 114: {fileID: 1468353537} + m_Layer: 0 + m_Name: UIHandler + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1468353536 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1468353535} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 +--- !u!114 &1468353537 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1468353535} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 98edf81534a5c9d4ba6267fc6572ee1c, type: 3} + m_Name: + m_EditorClassIdentifier: + fb_GUISkin: {fileID: 11400000, guid: 14ab14e9b97f743dca62b51e1e369f07, type: 2} diff --git a/firestore/testapp/Assets/Firebase/Sample/Firestore/MainScene.unity.meta b/firestore/testapp/Assets/Firebase/Sample/Firestore/MainScene.unity.meta new file mode 100644 index 000000000..f1efb9a55 --- /dev/null +++ b/firestore/testapp/Assets/Firebase/Sample/Firestore/MainScene.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9c1bd6589d0a79442bac83b00229d4e2 +timeCreated: 1534896708 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/firestore/testapp/Assets/Firebase/Sample/Firestore/MainSceneAutomated.unity b/firestore/testapp/Assets/Firebase/Sample/Firestore/MainSceneAutomated.unity new file mode 100644 index 000000000..0e1334833 --- /dev/null +++ b/firestore/testapp/Assets/Firebase/Sample/Firestore/MainSceneAutomated.unity @@ -0,0 +1,212 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +SceneSettings: + m_ObjectHideFlags: 0 + m_PVSData: + m_PVSObjectsArray: [] + m_PVSPortalsArray: [] + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 7 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 7 + m_GIWorkflowMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_TemporalCoherenceThreshold: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_LightmapEditorSettings: + serializedVersion: 4 + m_Resolution: 2 + m_BakeResolution: 40 + m_TextureWidth: 1024 + m_TextureHeight: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_DirectLightInLightProbes: 1 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 256 + m_ReflectionCompression: 2 + m_LightingDataAsset: {fileID: 0} + m_RuntimeCPUUsage: 25 +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + accuratePlacement: 0 + minRegionArea: 2 + cellSize: 0.16666667 + manualCellSize: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &393832514 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 393832516} + - 114: {fileID: 393832515} + m_Layer: 0 + m_Name: UIHandlerAutomated + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &393832515 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 393832514} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 861f3c4bb5ca00c4e80208e581d262ca, type: 3} + m_Name: + m_EditorClassIdentifier: + fb_GUISkin: {fileID: 11400000, guid: 14ab14e9b97f743dca62b51e1e369f07, type: 2} +--- !u!4 &393832516 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 393832514} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 +--- !u!1 &771383568 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 771383573} + - 20: {fileID: 771383572} + - 124: {fileID: 771383570} + - 81: {fileID: 771383569} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &771383569 +AudioListener: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 771383568} + m_Enabled: 1 +--- !u!124 &771383570 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 771383568} + m_Enabled: 1 +--- !u!20 &771383572 +Camera: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 771383568} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 2 + m_BackGroundColor: {r: 0.6903655, g: 0.8076244, b: 0.8308824, a: 0.019607844} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 1 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 + m_StereoMirrorMode: 0 +--- !u!4 &771383573 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 771383568} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 diff --git a/firestore/testapp/Assets/Firebase/Sample/Firestore/MainSceneAutomated.unity.meta b/firestore/testapp/Assets/Firebase/Sample/Firestore/MainSceneAutomated.unity.meta new file mode 100644 index 000000000..3f154e44f --- /dev/null +++ b/firestore/testapp/Assets/Firebase/Sample/Firestore/MainSceneAutomated.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 893124b811910a543949343a0ecec563 +timeCreated: 1534896718 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/firestore/testapp/Assets/Firebase/Sample/Firestore/SerializationTestData.cs b/firestore/testapp/Assets/Firebase/Sample/Firestore/SerializationTestData.cs new file mode 100644 index 000000000..6e980e05c --- /dev/null +++ b/firestore/testapp/Assets/Firebase/Sample/Firestore/SerializationTestData.cs @@ -0,0 +1,667 @@ +// Copyright 2017, Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +// NOTE: This file based on +// http://github.com/googleapis/google-cloud-dotnet/blob/c4439e0099d9e4c414afbe666f0d2bb28f95b297/apis/Google.Cloud.Firestore/Google.Cloud.Firestore.Tests/SerializationTestData.cs +// This file has been modified from its original version. It has been adapted to use raw C# types +// instead of protos and to work in .Net 3.5. + + +using System; +using System.Collections.Generic; +using System.Linq; +using Firebase.Firestore; + +namespace Firebase.Sample.Firestore { + internal static class SerializationTestData { + private static DateTime dateTime = new DateTime(1990, 1, 2, 3, 4, 5, DateTimeKind.Utc); + private static DateTimeOffset dateTimeOffset = new DateTimeOffset(1990, 1, 2, 3, 4, 5, TimeSpan.FromHours(1)); + + internal class TestCase { + internal enum TestOutcome { + Success, + // Given input type can be write to Firestore, can be read into Firestore raw types, but not + // the input type. + ReadToInputTypesNotSupported, + // Given input type cannot be write to Firestore, nor can any data be read into the input + // type. + Unsupported + } + + private TestOutcome _result = TestOutcome.Success; + + /// + /// Expected outcome of this test. + /// + internal TestOutcome Result { + get { return _result; } + private + set { _result = value; } + } + + /// + /// The object to serialize into Firestore document. + /// + internal object Input { get; private set; } + + /// + /// The expected output from the Firestore document deserialized to raw + /// Firestore type (Dictionary<string, object>, or primitive types). + /// + internal object ExpectedRawOutput { get; private set; } + + public TestCase(object input, object expectedRawOutput) { + Input = input; + ExpectedRawOutput = expectedRawOutput; + } + + public TestCase(object input, object expectedRawOutput, TestOutcome result) { + Input = input; + ExpectedRawOutput = expectedRawOutput; + Result = result; + } + } + + public static IEnumerable TestData(FirebaseFirestore database) { + return new List { + // Simple types + { new TestCase(null, null) }, + { new TestCase(true, true) }, + { new TestCase(false, false) }, + { new TestCase("test", "test") }, + { new TestCase((byte)1, 1L) }, + { new TestCase((sbyte)1, 1L) }, + { new TestCase((short)1, 1L) }, + { new TestCase((ushort)1, 1L) }, + { new TestCase(1, 1L) }, + { new TestCase(1U, 1L) }, + { new TestCase(1L, 1L) }, + { new TestCase(1UL, 1L) }, + { new TestCase(1.5F, 1.5D) }, + { new TestCase(float.PositiveInfinity, double.PositiveInfinity) }, + { new TestCase(float.NegativeInfinity, double.NegativeInfinity) }, + { new TestCase(float.NaN, double.NaN) }, + { new TestCase(1.5D, 1.5D) }, + { new TestCase(double.PositiveInfinity, double.PositiveInfinity) }, + { new TestCase(double.NegativeInfinity, double.NegativeInfinity) }, + { new TestCase(double.NaN, double.NaN) }, + + // Min/max values of each integer type + { new TestCase(byte.MinValue, (long)byte.MinValue) }, + { new TestCase(byte.MaxValue, (long)byte.MaxValue) }, + { new TestCase(sbyte.MinValue, (long)sbyte.MinValue) }, + { new TestCase(sbyte.MaxValue, (long)sbyte.MaxValue) }, + { new TestCase(short.MinValue, (long)short.MinValue) }, + { new TestCase(short.MaxValue, (long)short.MaxValue) }, + { new TestCase(ushort.MinValue, (long)ushort.MinValue) }, + { new TestCase(ushort.MaxValue, (long)ushort.MaxValue) }, + { new TestCase(int.MinValue, (long)int.MinValue) }, + { new TestCase(int.MaxValue, (long)int.MaxValue) }, + { new TestCase(uint.MinValue, (long)uint.MinValue) }, + { new TestCase(uint.MaxValue, (long)uint.MaxValue) }, + { new TestCase(long.MinValue, long.MinValue) }, + { new TestCase(long.MaxValue, long.MaxValue) }, + // We don't cover the whole range of ulong + { new TestCase((ulong)0, 0L) }, + { new TestCase((ulong) long.MaxValue, long.MaxValue) }, + + // Enum types + { new TestCase(ByteEnum.MinValue, (long)byte.MinValue) }, + { new TestCase(ByteEnum.MaxValue, (long)byte.MaxValue) }, + { new TestCase(SByteEnum.MinValue, (long)sbyte.MinValue) }, + { new TestCase(SByteEnum.MaxValue, (long)sbyte.MaxValue) }, + { new TestCase(Int16Enum.MinValue, (long)short.MinValue) }, + { new TestCase(Int16Enum.MaxValue, (long)short.MaxValue) }, + { new TestCase(UInt16Enum.MinValue, (long)ushort.MinValue) }, + { new TestCase(UInt16Enum.MaxValue, (long)ushort.MaxValue) }, + { new TestCase(Int32Enum.MinValue, (long)int.MinValue) }, + { new TestCase(Int32Enum.MaxValue, (long)int.MaxValue) }, + { new TestCase(UInt32Enum.MinValue, (long)uint.MinValue) }, + { new TestCase(UInt32Enum.MaxValue, (long)uint.MaxValue) }, + { new TestCase(Int64Enum.MinValue, (long)long.MinValue) }, + { new TestCase(Int64Enum.MaxValue, (long)long.MaxValue) }, + // We don't cover the whole range of ulong + { new TestCase(UInt64Enum.MinValue, (long)0) }, + { new TestCase(UInt64Enum.MaxRepresentableValue, (long)long.MaxValue) }, + { new TestCase(CustomConversionEnum.Foo, "Foo") }, + { new TestCase(CustomConversionEnum.Bar, "Bar") }, + + // Timestamps + { new TestCase(Timestamp.FromDateTime(dateTime), Timestamp.FromDateTime(dateTime)) }, + { new TestCase(dateTime, Timestamp.FromDateTime(dateTime)) }, + { new TestCase(dateTimeOffset, Timestamp.FromDateTimeOffset(dateTimeOffset)) }, + + // Blobs + { new TestCase(new byte[] { 1, 2, 3, 4 }, Blob.CopyFrom(new byte[] { 1, 2, 3, 4 })) }, + { new TestCase(Blob.CopyFrom(new byte[] { 1, 2, 3, 4 }), + Blob.CopyFrom(new byte[] { 1, 2, 3, 4 })) }, + + // GeoPoints + { new TestCase(new GeoPoint(1.5, 2.5), new GeoPoint(1.5, 2.5)) }, + + // Array values + { new TestCase(new string[] { "x", "y" }, new List { "x", "y" }) }, + { new TestCase(new List { "x", "y" }, new List { "x", "y" }) }, + { new TestCase(new int[] { 3, 4 }, new List { 3L, 4L }) }, + + // Deliberately DateTime rather than Timestamp here - we need to be able to detect the + // element type to perform the per-element deserialization correctly + { new TestCase(new List { dateTime, dateTime }, + new List { Timestamp.FromDateTime(dateTime), + Timestamp.FromDateTime(dateTime) }) }, + + // Map values (that can be deserialized again): dictionaries, attributed types, expandos + // (which are just dictionaries), custom serialized map-like values + + // Dictionaries + { new TestCase(new Dictionary { { "A", 10 }, { "B", 20 } }, + new Dictionary { { "A", 10L }, { "B", 20L } }) }, + { new TestCase(new Dictionary { { "A", 10 }, { "B", 20 } }, + new Dictionary { { "A", 10L }, { "B", 20L } }) }, + { new TestCase(new Dictionary { { "name", "Jon" }, { "score", 10L } }, + new Dictionary { { "name", "Jon" }, { "score", 10L } }) }, + // Attributed type (each property has an attribute) + { new TestCase(new GameResult { Name = "Jon", Score = 10 }, + new Dictionary { { "name", "Jon" }, { "Score", 10L } }) }, + // Attributed type contained in a dictionary + { new TestCase( + new Dictionary { { "result", + new GameResult { Name = "Jon", Score = 10 } } }, + new Dictionary { + { "result", new Dictionary { { "name", "Jon" }, { "Score", 10L } } } + }) }, + // Attributed type containing a dictionary + { new TestCase( + new DictionaryInterfaceContainer { + Integers = new Dictionary { { "A", 10 }, { "B", 20 } } + }, + new Dictionary { + { "Integers", new Dictionary { { "A", 10L }, { "B", 20L } } } + }) }, + // Attributed type serialized and deserialized by CustomPlayerConverter + { new TestCase(new CustomPlayer { Name = "Amanda", Score = 15 }, + new Dictionary { { "PlayerName", "Amanda" }, + { "PlayerScore", 15L } }) }, + + // Attributed value type serialized and deserialized by CustomValueTypeConverter + { new TestCase(new CustomValueType("xyz", 10), + new Dictionary { { "Name", "xyz" }, { "Value", 10L } }) }, + + // Attributed type with enums (name and number) + { new TestCase(new ModelWithEnums { EnumDefaultByName = CustomConversionEnum.Foo, + EnumAttributedByName = Int32Enum.MinValue, + EnumByNumber = Int32Enum.MaxValue }, + new Dictionary { { "EnumDefaultByName", "Foo" }, + { "EnumAttributedByName", "MinValue" }, + { "EnumByNumber", (long)int.MaxValue } }) }, + + // Attributed type with List field + { new TestCase(new CustomUser { Name = "Jon", HighScore = 10, + Emails = new List { "jon@example.com" } }, + new Dictionary { + { "Name", "Jon" }, + { "HighScore", 10L }, + { "Emails", new List { "jon@example.com" } } + }) }, + + // Attributed type with IEnumerable field + { new TestCase( + new CustomUserEnumerableEmails() { Name = "Jon", HighScore = 10, + Emails = new List { "jon@example.com" } }, + new Dictionary { { "Name", "Jon" }, + { "HighScore", 10L }, + { "Emails", + new List { "jon@example.com" } } }) }, + + // Attributed type with Set field and custom converter. + { new TestCase( + new CustomUserSetEmailsWithConverter() { + Name = "Jon", HighScore = 10, Emails = new HashSet { "jon@example.com" } + }, + new Dictionary { { "Name", "Jon" }, + { "HighScore", 10L }, + { "Emails", + new List { "jon@example.com" } } }) }, + + // Attributed struct + { new TestCase(new StructModel { Name = "xyz", Value = 10 }, + new Dictionary { { "Name", "xyz" }, { "Value", 10L } }) }, + + // Document references + { new TestCase(database.Document("a/b"), database.Document("a/b")) }, + }; + } + + public static IEnumerable UnsupportedTestData() { + return new List { + // Nullable type handling + { new TestCase(new NullableContainer { NullableValue = 10 }, + new Dictionary { { "NullableValue", 10L } }, + TestCase.TestOutcome.Unsupported) }, + { new TestCase(new NullableEnumContainer { NullableValue = (Int32Enum)10 }, + new Dictionary { { "NullableValue", 10L } }, + TestCase.TestOutcome.Unsupported) }, + // This one fails because the `NullableContainer` it gets back has a random value + // while it should be null. + { new TestCase(new NullableContainer { NullableValue = null }, + new Dictionary { { "NullableValue", null } }, + TestCase.TestOutcome.Unsupported) }, + { new TestCase(new NullableEnumContainer { NullableValue = null }, + new Dictionary { { "NullableValue", null } }, + TestCase.TestOutcome.Unsupported) }, + + // IEnumerable values cannot be assigned from a List. + // TODO(b/173894435): there should be a way to specify if it is serialization or + // deserialization failure. + { new TestCase(Enumerable.Range(3, 2).Select(i => (long)i), + Enumerable.Range(3, 2).Select(i => (long)i), + TestCase.TestOutcome.ReadToInputTypesNotSupported) }, + { new TestCase( + new CustomUserSetEmails { Name = "Jon", HighScore = 10, + Emails = new HashSet { "jon@example.com" } }, + new Dictionary { { "Name", "Jon" }, + { "HighScore", 10L }, + { "Emails", new List { "jon@example.com" } } }, + TestCase.TestOutcome.ReadToInputTypesNotSupported) }, + }; + } + + // Only equatable for the sake of testing; that's not a requirement of the serialization code. + [FirestoreData] + internal class GameResult : IEquatable { + [FirestoreProperty("name")] + public string Name { get; set; } + [FirestoreProperty] // No property name specified, so field will be Score + public int Score { get; set; } + + public override int GetHashCode() { return Name.GetHashCode() ^ Score; } + + public override bool Equals(object obj) { return Equals(obj as GameResult); } + + public bool Equals(GameResult other) { return other != null && other.Name == Name && other.Score == Score; } + } + + [FirestoreData] + internal class NullableContainer : IEquatable { + [FirestoreProperty] + public long? NullableValue { get; set; } + + public override int GetHashCode() { return (int)NullableValue.GetValueOrDefault().GetHashCode(); } + + public override bool Equals(object obj) { return Equals(obj as NullableContainer); } + + public bool Equals(NullableContainer other) { return other != null && other.NullableValue == NullableValue; } + public override string ToString() { return String.Format("NullableContainer: {0}", NullableValue.GetValueOrDefault()); } + } + + [FirestoreData] + internal class NullableEnumContainer : IEquatable { + [FirestoreProperty] + public Int32Enum? NullableValue { get; set; } + + public override int GetHashCode() { return (int)NullableValue.GetValueOrDefault().GetHashCode(); } + + public override bool Equals(object obj) { return Equals(obj as NullableEnumContainer); } + + public bool Equals(NullableEnumContainer other) { return other != null && other.NullableValue == NullableValue; } + } + + [FirestoreData] + internal class DictionaryInterfaceContainer : IEquatable { + [FirestoreProperty] + public IDictionary Integers { get; set; } + + public override int GetHashCode() { return Integers.Sum(pair => pair.Key.GetHashCode() + pair.Value); } + + public override bool Equals(object obj) { return Equals(obj as DictionaryInterfaceContainer); } + + public bool Equals(DictionaryInterfaceContainer other) { + if (other == null) { + return false; + } + if (Integers == other.Integers) { + return true; + } + if (Integers == null || other.Integers == null) { + return false; + } + if (Integers.Count != other.Integers.Count) { + return false; + } + int otherValue; + return Integers.All(pair => other.Integers.TryGetValue(pair.Key, out otherValue) && pair.Value == otherValue); + } + } + + internal enum SByteEnum : sbyte { + MinValue = sbyte.MinValue, + MaxValue = sbyte.MaxValue + } + + internal enum Int16Enum : short { + MinValue = short.MinValue, + MaxValue = short.MaxValue + } + + internal enum Int32Enum : int { + MinValue = int.MinValue, + MaxValue = int.MaxValue + } + + internal enum Int64Enum : long { + MinValue = long.MinValue, + MaxValue = long.MaxValue + } + + internal enum ByteEnum : byte { + MinValue = byte.MinValue, + MaxValue = byte.MaxValue + } + + internal enum UInt16Enum : ushort { + MinValue = ushort.MinValue, + MaxValue = ushort.MaxValue + } + + internal enum UInt32Enum : uint { + MinValue = uint.MinValue, + MaxValue = uint.MaxValue + } + + internal enum UInt64Enum : ulong { + MinValue = ulong.MinValue, + MaxRepresentableValue = long.MaxValue + } + + [FirestoreData(ConverterType = typeof(FirestoreEnumNameConverter))] + internal enum CustomConversionEnum { + Foo = 1, + Bar = 2 + } + + [FirestoreData] + public sealed class ModelWithEnums { + [FirestoreProperty] + public CustomConversionEnum EnumDefaultByName { get; set; } + + [FirestoreProperty(ConverterType = typeof(FirestoreEnumNameConverter))] + public Int32Enum EnumAttributedByName { get; set; } + + [FirestoreProperty] + public Int32Enum EnumByNumber { get; set; } + + public override bool Equals(object obj) { + if (!(obj is ModelWithEnums)) { + return false; + } + ModelWithEnums other = obj as ModelWithEnums; + return EnumDefaultByName == other.EnumDefaultByName && + EnumAttributedByName == other.EnumAttributedByName && + EnumByNumber == other.EnumByNumber; + } + + public override int GetHashCode() { return 0; } + } + + [FirestoreData] + public sealed class CustomUser { + [FirestoreProperty] + public int HighScore { get; set; } + [FirestoreProperty] + public string Name { get; set; } + [FirestoreProperty] public List Emails { get; set; } + + public override bool Equals(object obj) { + if (!(obj is CustomUser)) { + return false; + } + + CustomUser other = (CustomUser)obj; + return HighScore == other.HighScore && Name == other.Name && + Emails.SequenceEqual(other.Emails); + } + + public override int GetHashCode() { + return 0; + } + } + + [FirestoreData] + public sealed class CustomUserEnumerableEmails { + [FirestoreProperty] + public int HighScore { get; set; } + [FirestoreProperty] public string Name { get; set; } + [FirestoreProperty] public IEnumerable Emails { get; set; } + + public override bool Equals(object obj) { + if (!(obj is CustomUserEnumerableEmails)) { + return false; + } + + CustomUserEnumerableEmails other = (CustomUserEnumerableEmails)obj; + return HighScore == other.HighScore && Name == other.Name && + Emails.SequenceEqual(other.Emails); + } + + public override int GetHashCode() { + return 0; + } + } + + [FirestoreData] + public sealed class CustomUserSetEmails { + [FirestoreProperty] + public int HighScore { get; set; } + [FirestoreProperty] public string Name { get; set; } + [FirestoreProperty] public HashSet Emails { get; set; } + + public override bool Equals(object obj) { + if (!(obj is CustomUserSetEmails)) { + return false; + } + + CustomUserSetEmails other = (CustomUserSetEmails)obj; + return HighScore == other.HighScore && Name == other.Name && + Emails.SequenceEqual(other.Emails); + } + + public override int GetHashCode() { + return 0; + } + } + + [FirestoreData(ConverterType = typeof(CustomUserSetEmailsConverter))] + public sealed class CustomUserSetEmailsWithConverter { + [FirestoreProperty] + public int HighScore { get; set; } + [FirestoreProperty] public string Name { get; set; } + [FirestoreProperty] public HashSet Emails { get; set; } + + public override bool Equals(object obj) { + if (!(obj is CustomUserSetEmailsWithConverter)) { + return false; + } + + var other = (CustomUserSetEmailsWithConverter)obj; + return HighScore == other.HighScore && Name == other.Name && + Emails.SequenceEqual(other.Emails); + } + + public override int GetHashCode() { + return 0; + } + } + + public class CustomUserSetEmailsConverter + : FirestoreConverter { + public override CustomUserSetEmailsWithConverter FromFirestore(object value) { + if (value == null) { + throw new ArgumentNullException("value"); // Shouldn't happen + } + + var map = (Dictionary)value; + var emails = (List)map["Emails"]; + var emailSet = new HashSet(emails.Select(o => o.ToString())); + return new CustomUserSetEmailsWithConverter { Name = (string)map["Name"], + HighScore = Convert.ToInt32(map["HighScore"]), + Emails = emailSet }; + } + + public override object ToFirestore(CustomUserSetEmailsWithConverter value) { + return new Dictionary { + { "Name", value.Name }, + { "HighScore", value.HighScore }, + { "Emails", value.Emails }, + }; + } + } + + [FirestoreData(ConverterType = typeof(EmailConverter))] + public sealed class Email { + public readonly string Address; + public Email(string address) { Address = address; } + } + + public class EmailConverter : FirestoreConverter { + public override Email FromFirestore(object value) { + if (value == null) { + throw new ArgumentNullException("value"); // Shouldn't happen + } else if (value is string) { + return new Email(value as string); + } else { + throw new ArgumentException(String.Format("Unexpected data: {}", value.GetType())); + } + } + public override object ToFirestore(Email value) { return value == null ? null : value.Address; } + } + + [FirestoreData] + public class GuidPair { + [FirestoreProperty] + public string Name { get; set; } + + [FirestoreProperty(ConverterType = typeof(GuidConverter))] + public Guid Guid { get; set; } + + [FirestoreProperty(ConverterType = typeof(GuidConverter))] + public Guid? GuidOrNull { get; set; } + } + + // Like GuidPair, but without the converter specified - it has to come + // from a converter registry instead. + [FirestoreData] + public class GuidPair2 { + [FirestoreProperty] + public string Name { get; set; } + + [FirestoreProperty] + public Guid Guid { get; set; } + + [FirestoreProperty] + public Guid? GuidOrNull { get; set; } + } + + public class GuidConverter : FirestoreConverter { + public override Guid FromFirestore(object value) { + if (value == null) { + throw new ArgumentNullException("value"); // Shouldn't happen + } else if (value is string) { + return new Guid(value as string); + } else { + throw new ArgumentException(String.Format("Unexpected data: {0}", value.GetType())); + } + } + public override object ToFirestore(Guid value) { return value.ToString("N"); } + } + + // Only equatable for the sake of testing; that's not a requirement of the serialization code. + [FirestoreData(ConverterType = typeof(CustomPlayerConverter))] + public class CustomPlayer : IEquatable { + public string Name { get; set; } + public int Score { get; set; } + + public override int GetHashCode() { return Name.GetHashCode() ^ Score; } + public override bool Equals(object obj) { return Equals(obj as CustomPlayer); } + public bool Equals(CustomPlayer other) { return other != null && other.Name == Name && other.Score == Score; } + } + + public class CustomPlayerConverter : FirestoreConverter { + public override CustomPlayer FromFirestore(object value) { + var map = (IDictionary)value; + return new CustomPlayer { + Name = (string)map["PlayerName"], + // Unbox to long, then convert to int. + Score = (int)(long)map["PlayerScore"] + }; + } + + public override object ToFirestore(CustomPlayer value) { + return new Dictionary + { + { "PlayerName", value.Name }, + { "PlayerScore", value.Score } + }; + } + } + + [FirestoreData(ConverterType = typeof(CustomValueTypeConverter))] + internal struct CustomValueType : IEquatable { + public readonly string Name; + public readonly int Value; + + public CustomValueType(string name, int value) { + Name = name; + Value = value; + } + + public override int GetHashCode() { return Name.GetHashCode() + Value; } + public override bool Equals(object obj) { return obj is CustomValueType && Equals((CustomValueType)obj); } + public bool Equals(CustomValueType other) { return Name == other.Name && Value == other.Value; } + public override string ToString() { return String.Format("CustomValueType: {0}", new { Name, Value }); } + } + + internal class CustomValueTypeConverter : FirestoreConverter { + public override CustomValueType FromFirestore(object value) { + var dictionary = (IDictionary)value; + return new CustomValueType( + (string)dictionary["Name"], + (int)(long)dictionary["Value"] + ); + } + + public override object ToFirestore(CustomValueType value) { + return new Dictionary + { + { "Name", value.Name }, + { "Value", value.Value } + }; + } + } + + [FirestoreData] + internal struct StructModel : IEquatable { + [FirestoreProperty] + public string Name { get; set; } + [FirestoreProperty] + public int Value { get; set; } + + public override int GetHashCode() { return Name.GetHashCode() + Value; } + public override bool Equals(object obj) { return obj is StructModel && Equals((StructModel)obj); } + public bool Equals(StructModel other) { return Name == other.Name && Value == other.Value; } + + public override string ToString() { return String.Format("StructModel: {0}", new { Name, Value }); } + } + } +} diff --git a/firestore/testapp/Assets/Firebase/Sample/Firestore/SerializationTestData.cs.meta b/firestore/testapp/Assets/Firebase/Sample/Firestore/SerializationTestData.cs.meta new file mode 100644 index 000000000..19319fd9c --- /dev/null +++ b/firestore/testapp/Assets/Firebase/Sample/Firestore/SerializationTestData.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 430f853680699467dadaf1e0c9e295f3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/firestore/testapp/Assets/Firebase/Sample/Firestore/UIHandler.cs b/firestore/testapp/Assets/Firebase/Sample/Firestore/UIHandler.cs new file mode 100644 index 000000000..6ef031d25 --- /dev/null +++ b/firestore/testapp/Assets/Firebase/Sample/Firestore/UIHandler.cs @@ -0,0 +1,372 @@ +// Copyright 2019 Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Firebase.Sample.Firestore { + using Firebase; + using Firebase.Extensions; + using Firebase.Firestore; + using System; + using System.Collections; + using System.Collections.Generic; + using System.IO; + using System.Linq; + using System.Threading; + using System.Threading.Tasks; + using System.Text; + using UnityEngine; + + // Handler for UI buttons on the scene. Also performs some + // necessary setup (initializing the firebase app, etc) on + // startup. + public class UIHandler : MonoBehaviour { + private const int kMaxLogSize = 16382; + + public GUISkin fb_GUISkin; + private Vector2 controlsScrollViewVector = Vector2.zero; + private string logText = ""; + private Vector2 scrollViewVector = Vector2.zero; + protected bool UIEnabled = false; + private GUIStyle disabledButtonStyle; + + // Path to the collection to query on. + protected string collectionPath = "col1"; + // DocumentID within the collection. Set to empty to use an autoid (which + // obviously only works for writing new documents.) + protected string documentId = ""; + protected string fieldContents; + private DependencyStatus dependencyStatus = DependencyStatus.UnavailableOther; + protected bool isFirebaseInitialized = false; + + // Currently enabled logging verbosity. + protected Firebase.LogLevel logLevel = Firebase.LogLevel.Info; + // Whether an operation is in progress. + protected bool operationInProgress; + // Cancellation token source for the current operation. + protected CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(); + + // Previously completed task. + protected Task previousTask; + + // When the app starts, check to make sure that we have + // the required dependencies to use Firebase, and if not, + // add them if possible. + protected virtual void Start() { + FirebaseApp.CheckAndFixDependenciesAsync().ContinueWithOnMainThread(task => { + dependencyStatus = task.Result; + if (dependencyStatus == DependencyStatus.Available) { + InitializeFirebase(); + } else { + Debug.LogError( + "Could not resolve all Firebase dependencies: " + dependencyStatus); + } + }); + } + + protected virtual void InitializeFirebase() { + // TODO(rgowman): Enable logging here... once the plumbing is setup to + // make this possible. + UIEnabled = true; + isFirebaseInitialized = true; + } + + // Exit if escape (or back, on mobile) is pressed. + protected virtual void Update() { + if (Input.GetKeyDown(KeyCode.Escape)) { + Application.Quit(); + } + } + + // Output text to the debug log text field, as well as the console. + public void DebugLog(string s) { + Debug.Log(s); + logText += s + "\n"; + + while (logText.Length > kMaxLogSize) { + int index = logText.IndexOf("\n"); + logText = logText.Substring(index + 1); + } + + scrollViewVector.y = int.MaxValue; + } + + // Render the log output in a scroll view. + void GUIDisplayLog() { + scrollViewVector = GUILayout.BeginScrollView(scrollViewVector); + GUILayout.Label(logText); + GUILayout.EndScrollView(); + } + + // Wait for task completion, throwing an exception if the task fails. + // This could be typically implemented using + // yield return new WaitUntil(() => task.IsCompleted); + // however, since many procedures in this sample nest coroutines and we want any task exceptions + // to be thrown from the top level coroutine (e.g GetKnownValue) we provide this + // CustomYieldInstruction implementation wait for a task in the context of the coroutine using + // common setup and tear down code. + class WaitForTaskCompletion : CustomYieldInstruction { + Task task; + UIHandler uiHandler; + + // Create an enumerator that waits for the specified task to complete. + public WaitForTaskCompletion(UIHandler uiHandler, Task task) { + uiHandler.previousTask = task; + uiHandler.operationInProgress = true; + this.uiHandler = uiHandler; + this.task = task; + } + + // Wait for the task to complete. + public override bool keepWaiting { + get { + if (task.IsCompleted) { + uiHandler.operationInProgress = false; + uiHandler.cancellationTokenSource = new CancellationTokenSource(); + if (task.IsFaulted) { + string s = task.Exception.ToString(); + uiHandler.DebugLog(s); + } + return false; + } + return true; + } + } + } + + protected FirebaseFirestore db { + get { + return FirebaseFirestore.DefaultInstance; + } + } + + // Cancel the currently running operation. + protected void CancelOperation() { + if (operationInProgress && cancellationTokenSource != null) { + DebugLog("*** Cancelling operation *** ..."); + cancellationTokenSource.Cancel(); + cancellationTokenSource = null; + } + } + + /** + * Tests a *very* basic trip through the Firestore API. + */ + protected IEnumerator GetKnownValue() { + DocumentReference doc1 = db.Collection("col1").Document("doc1"); + var task = doc1.GetSnapshotAsync(); + yield return new WaitForTaskCompletion(this, task); + if (!(task.IsFaulted || task.IsCanceled)) { + DocumentSnapshot snap = task.Result; + IDictionary dict = snap.ToDictionary(); + if (dict.ContainsKey("field1")) { + fieldContents = dict["field1"].ToString(); + } else { + DebugLog("ERROR: Successfully retrieved col1/doc1, but it doesn't contain 'field1' key"); + } + } + } + + private static string DictToString(IDictionary d) { + return "{ " + d + .Select(kv => "(" + kv.Key + ", " + kv.Value + ")") + .Aggregate("", (current, next) => current + next + ", ") + + "}"; + } + + private CollectionReference GetCollectionReference() { + return db.Collection(collectionPath); + } + + private DocumentReference GetDocumentReference() { + if (documentId == "") { + return GetCollectionReference().Document(); + } + return GetCollectionReference().Document(documentId); + } + + private IEnumerator WriteDoc(DocumentReference doc, IDictionary data) { + Task setTask = doc.SetAsync(data); + yield return new WaitForTaskCompletion(this, setTask); + if (!(setTask.IsFaulted || setTask.IsCanceled)) { + // Update the collectionPath/documentId because: + // 1) If the documentId field was empty, this will fill it in with the autoid. This allows + // you to manually test via a trivial 'click set', 'click get'. + // 2) In the automated test, the caller might pass in an explicit docRef rather than pulling + // the value from the UI. This keeps the UI up-to-date. (Though unclear if that's useful + // for the automated tests.) + collectionPath = doc.Parent.Id; + documentId = doc.Id; + + fieldContents = "Ok"; + } else { + fieldContents = "Error"; + } + } + + private IEnumerator UpdateDoc(DocumentReference doc, IDictionary data) { + Task updateTask = doc.UpdateAsync(data); + yield return new WaitForTaskCompletion(this, updateTask); + if (!(updateTask.IsFaulted || updateTask.IsCanceled)) { + // Update the collectionPath/documentId because: + // 1) In the automated test, the caller might pass in an explicit docRef rather than pulling + // the value from the UI. This keeps the UI up-to-date. (Though unclear if that's useful + // for the automated tests.) + collectionPath = doc.Parent.Id; + documentId = doc.Id; + + fieldContents = "Ok"; + } else { + fieldContents = "Error"; + } + } + + private IEnumerator ReadDoc(DocumentReference doc) { + Task getTask = doc.GetSnapshotAsync(); + yield return new WaitForTaskCompletion(this, getTask); + if (!(getTask.IsFaulted || getTask.IsCanceled)) { + DocumentSnapshot snap = getTask.Result; + // TODO(rgowman): Handle `!snap.exists()` case. + IDictionary resultData = snap.ToDictionary(); + fieldContents = "Ok: " + DictToString(resultData); + } else { + fieldContents = "Error"; + } + } + + // Button that can be optionally disabled. + bool Button(string buttonText, bool enabled) { + if (disabledButtonStyle == null) { + disabledButtonStyle = new GUIStyle(fb_GUISkin.button); + disabledButtonStyle.normal.textColor = Color.grey; + disabledButtonStyle.active = disabledButtonStyle.normal; + } + var style = enabled ? fb_GUISkin.button : disabledButtonStyle; + return GUILayout.Button(buttonText, style) && enabled; + } + + // Render the buttons and other controls. + void GUIDisplayControls() { + if (UIEnabled) { + controlsScrollViewVector = GUILayout.BeginScrollView(controlsScrollViewVector); + + GUILayout.BeginVertical(); + + GUILayout.Label("CollectionPath:"); + collectionPath = GUILayout.TextField(collectionPath); + + GUILayout.Label("DocumentId (set to empty for autoid):"); + documentId = GUILayout.TextField(documentId); + + GUILayout.Label("Text:"); + if (fieldContents == null) { + // TODO(rgowman): Provide instructions on how to set document contents here. + fieldContents = "Sample text... (type here)"; + } + fieldContents = GUILayout.TextField(fieldContents); + + GUILayout.Space(10); + + GUILayout.BeginVertical(); + + if (Button("GetKnownValue", !operationInProgress)) { + StartCoroutine(GetKnownValue()); + } + + if (Button("WriteDoc", !operationInProgress)) { + // TODO(rgowman): allow these values to be set by the user via the UI. + var data = new Dictionary{ + {"f1", "v1"}, + {"f2", 2}, + {"f3", true}, + // TODO(rgowman): Add other types here too. + }; + StartCoroutine(WriteDoc(GetDocumentReference(), data)); + } + + if (Button("UpdateDoc", !operationInProgress)) { + // TODO(rgowman): allow these values to be set by the user via the UI. + var data = new Dictionary{ + {"f1", "v1b"}, + {"f4", "v4"}, + // TODO(rgowman): Add other types here too. + }; + StartCoroutine(UpdateDoc(GetDocumentReference(), data)); + } + + if (Button("ReadDoc", !operationInProgress)) { + StartCoroutine(ReadDoc(GetDocumentReference())); + } + + GUILayout.EndVertical(); + + GUILayout.EndVertical(); + GUILayout.EndScrollView(); + } + } + + // Render the GUI: + void OnGUI() { + GUI.skin = fb_GUISkin; + if (dependencyStatus != Firebase.DependencyStatus.Available) { + GUILayout.Label("One or more Firebase dependencies are not present."); + GUILayout.Label("Current dependency status: " + dependencyStatus.ToString()); + return; + } + + // TODO(rgowman): Fix sizing on desktop. Possibly using something like the following. + // Sizing in unity is a little weird; fonts that look ok on desktop + // become really small on mobile, so they need to be adjusted. But we + // don't support desktop just yet, so we'll skip this step for now. + /* + GUI.skin.textArea.fontSize = GUI.skin.textField.fontSize; + // Reduce the text size on the desktop. + if (UnityEngine.Application.platform != RuntimePlatform.Android && + UnityEngine.Application.platform != RuntimePlatform.IPhonePlayer) { + var fontSize = GUI.skin.textArea.fontSize / 4; + GUI.skin.textArea.fontSize = fontSize; + GUI.skin.button.fontSize = fontSize; + GUI.skin.label.fontSize = fontSize; + GUI.skin.textField.fontSize = fontSize; + } + GUI.skin.textArea.stretchHeight = true; + // Calculate the height of line of text in a text area. + if (textAreaLineHeight == 0.0f) { + textAreaLineHeight = GUI.skin.textArea.CalcSize(new GUIContent("Hello World")).y; + } + */ + + Rect logArea, controlArea; + + if (Screen.width < Screen.height) { + // Portrait mode + controlArea = new Rect(0.0f, 0.0f, Screen.width, Screen.height * 0.5f); + logArea = new Rect(0.0f, Screen.height * 0.5f, Screen.width, Screen.height * 0.5f); + } else { + // Landscape mode + controlArea = new Rect(0.0f, 0.0f, Screen.width * 0.5f, Screen.height); + logArea = new Rect(Screen.width * 0.5f, 0.0f, Screen.width * 0.5f, Screen.height); + } + + GUILayout.BeginArea(logArea); + GUIDisplayLog(); + if (Button("Cancel Operation", operationInProgress)) { + CancelOperation(); + } + GUILayout.EndArea(); + + GUILayout.BeginArea(controlArea); + GUIDisplayControls(); + GUILayout.EndArea(); + } + } +} diff --git a/firestore/testapp/Assets/Firebase/Sample/Firestore/UIHandler.cs.meta b/firestore/testapp/Assets/Firebase/Sample/Firestore/UIHandler.cs.meta new file mode 100644 index 000000000..18221a874 --- /dev/null +++ b/firestore/testapp/Assets/Firebase/Sample/Firestore/UIHandler.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 98edf81534a5c9d4ba6267fc6572ee1c +timeCreated: 1534896493 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/firestore/testapp/Assets/Firebase/Sample/Firestore/UIHandlerAutomated.cs b/firestore/testapp/Assets/Firebase/Sample/Firestore/UIHandlerAutomated.cs new file mode 100644 index 000000000..adc90d5e9 --- /dev/null +++ b/firestore/testapp/Assets/Firebase/Sample/Firestore/UIHandlerAutomated.cs @@ -0,0 +1,2872 @@ +namespace Firebase.Sample.Firestore { + using Firebase; + using Firebase.Extensions; + using Firebase.Firestore; + using System; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Reflection; + using System.Text; + using System.Text.RegularExpressions; + using System.Threading; + using System.Threading.Tasks; + using UnityEngine; + + // An automated version of the UIHandler that runs tests on Firebase Firestore. + public class UIHandlerAutomated : UIHandler { + private Firebase.Sample.AutomatedTestRunner testRunner; + + // Class for forcing code to run on the main thread. + private MainThreadDispatcher mainThreadDispatcher; + private int mainThreadId; + + // Number of characters that UnityEngine.Debug.Log will output to Android's logcat before + // truncating the rest. (See LogInBatches docstring for further discussion.) + private const int UnityAndroidLogLimit = 1000; + + private IEnumerable SplitIntoBatches(string s) { + // Process the string in chunks of "UnityAndroidLogLimit" characters (except the last chunk, + // which is likely to be shorter): find the last newline within the current chunk, split at + // that point, start a new chunk right after the split point, repeat until the string is + // exhausted. + int begin = 0; + + while (begin < s.Length) { + int count = Math.Min(s.Length - begin, UnityAndroidLogLimit); + int lastNewLineIndex = s.LastIndexOf("\n", begin + count, count); + if (lastNewLineIndex != -1) { + count = lastNewLineIndex - begin + 1; + } + + yield return s.Substring(begin, count).TrimEnd(); + + begin += count; + } + } + + /// + /// Log the given message, split into "batches" of up to 1000 characters. + /// + /// + /// Unity's Debug.Log truncates logs to 1000 characters on Android. (Undocumented by Unity, + /// but otherwise well known on the Unity forums.) This is particularly egregious when + /// outputting stacktraces. This method will try to break on newlines. + /// + /// Note that Unity will add stacktraces to the logs in certain circumstances. These are added + /// inside the Debug.Log call, and therefore, we can't prevent Unity from truncating them, so + /// these seem to never be useful on Android. (See call to Application.SetStackTraceLogType.) + /// + private void LogInBatches(string s) { + foreach (string batch in SplitIntoBatches(s)) { + DebugLog(batch); + } + } + + protected override void Start() { + // Set the list of tests to run, note this is done at Start since they are + // non-static. + Func[] tests = { + TestGetKnownValue, + TestDeleteDocument, + TestWriteDocument, + TestWriteDocumentViaCollection, + TestWriteDocumentWithIntegers, + TestUpdateDocument, + TestListenForSnapshotsInSync, + TestMultiInstanceDocumentReferenceListeners, + TestMultiInstanceQueryListeners, + TestMultiInstanceSnapshotsInSyncListeners, + TestUpdateFieldInDocument, + TestArrayUnionAndRemove, + TestUpdateFieldPath, + TestWriteBatches, + TestTransaction, + TestTransactionWithNonGenericTask, + TestTransactionAbort, + TestTransactionTaskFailures, + TestTransactionPermanentError, + // Waiting for all retries is slow, so we usually leave this test disabled. + //TestTransactionMaxRetryFailure, + TestSetOptions, + TestCanTraverseCollectionsAndDocuments, + TestCanTraverseCollectionAndDocumentParents, + TestDocumentSnapshot, + TestDocumentSnapshotIntegerIncrementBehavior, + TestDocumentSnapshotDoubleIncrementBehavior, + TestDocumentSnapshotServerTimestampBehavior, + TestAuthIntegration, + TestDocumentListen, + TestDocumentListenWithMetadataChanges, + TestQueryListen, + TestQueryListenWithMetadataChanges, + TestQuerySnapshotChanges, + TestQueries, + TestLimitToLast, + TestArrayContains, + TestArrayContainsAny, + TestInQueries, + TestDefaultInstanceStable, + TestGetAsyncSource, + TestWaitForPendingWrites, + TestTerminate, + TestClearPersistence, + TestObjectMappingSmokeTest, + TestObjectMapping, + TestNotSupportedObjectMapping, + TestFirestoreSingleton, + TestFirestoreSettings, + TestDocumentReferenceTaskFailures, + TestCollectionReferenceTaskFailures, + TestAssertTaskFaults, + TestInternalExceptions, + TestListenerRegistrationDispose, + }; + + // Unity "helpfully" adds stack traces whenever you call Debug.Log. Unfortunately, these stack + // traces are basically useless, since the good parts are always truncated. (See comments on + // LogInBatches.) So just disable them. + Application.SetStackTraceLogType(LogType.Log, StackTraceLogType.None); + + mainThreadDispatcher = gameObject.AddComponent(); + if (mainThreadDispatcher == null) { + Debug.LogError("Could not create MainThreadDispatcher component!"); + return; + } + mainThreadDispatcher.RunOnMainThread(() => { + mainThreadId = Thread.CurrentThread.ManagedThreadId; + }); + + testRunner = AutomatedTestRunner.CreateTestRunner( + testsToRun: tests, + logFunc: LogInBatches + ); + + Debug.Log("NOTE: Some API calls report failures using UnityEngine.Debug.LogError which will " + + "pause execution in the editor when 'Error Pause' in the console window is " + + "enabled. `Error Pause` should be disabled to execute this test."); + + UIEnabled = false; + base.Start(); + } + + // Passes along the update call to automated test runner. + protected override void Update() { + base.Update(); + if (testRunner != null && isFirebaseInitialized) { + testRunner.Update(); + } + } + + // Throw when condition is false. + private void Assert(string message, bool condition) { + if (!condition) + throw new Exception(String.Format("Assertion failed ({0}): {1}", + testRunner.CurrentTestDescription, message)); + } + + // Throw when value1 != value2 (using direct .Equals() check). + private void AssertEq(string message, T value1, T value2) { + if (!(object.Equals(value1, value2))) { + throw new Exception(String.Format("Assertion failed ({0}): {1} != {2} ({3})", + testRunner.CurrentTestDescription, value1, value2, + message)); + } + } + + // Throw when value1 != value2 (using direct .Equals() check). + private void AssertEq(T value1, T value2) { + AssertEq("Values not equal", value1, value2); + } + + // Throw when value1 != value2 (traversing the values recursively, including arrays and maps). + private void AssertDeepEq(string message, T value1, T value2) { + if (!ObjectDeepEquals(value1, value2)) { + throw new Exception(String.Format("Assertion failed ({0}): {1} != {2} ({3})", + testRunner.CurrentTestDescription, + ObjectToString(value1), + ObjectToString(value2), + message)); + } + } + + // Throw when value1 != value2 (traversing the values recursively, including arrays and maps). + private void AssertDeepEq(T value1, T value2) { + AssertDeepEq("Values not equal", value1, value2); + } + + private void AssertIsType(object obj, Type expectedType) { + if (!expectedType.IsInstanceOfType(obj)) { + throw new Exception("object has type " + obj.GetType() + " but expected " + + expectedType + " (" + obj + ")"); + } + } + + private void AssertException(Type exceptionType, Action a) { + AssertException("", exceptionType, a); + } + + private void AssertException(String context, Type exceptionType, Action a) { + try { + a(); + } catch (Exception e) { + if (e is TargetInvocationException) { + e = e.InnerException; + } + if (!exceptionType.IsAssignableFrom(e.GetType())) { + throw new Exception( + String.Format("{0}\nException of wrong type was thrown. Expected {1} but got: {2}", + context, exceptionType, e)); + } + return; + } + throw new Exception(String.Format("{0}\nExpected exception was not thrown ({1})", context, + testRunner.CurrentTestDescription)); + } + + private void AssertTaskProperties(Task t, bool isCompleted, bool isFaulted, bool isCanceled) { + // Save the properties of the Task to local variables (instead of always accessing them on + // the Task object) to ensure that the values reported in the message exactly match those used + // in the assertion check. + var actualIsCompleted = t.IsCompleted; + var actualIsFaulted = t.IsFaulted; + var actualIsCanceled = t.IsCanceled; + + var message = String.Format("IsCompleted={0} (expected {1}), IsFaulted={2} (expected {3}), " + + "IsCanceled={4} (expected {5})", + actualIsCompleted, isCompleted, + actualIsFaulted, isFaulted, + actualIsCanceled, isCanceled); + + Assert(message, + isCompleted == actualIsCompleted + && isFaulted == actualIsFaulted + && isCanceled == actualIsCanceled); + } + + private void AssertTaskSucceeds(Task t) { + t.Wait(); + AssertTaskProperties(t, isCompleted: true, isFaulted: false, isCanceled: false); + } + + private Exception AssertTaskFaults(Task t) { + var exception = AwaitException(t); + AssertTaskProperties(t, isCompleted: true, isFaulted: true, isCanceled: false); + return exception; + } + + private FirestoreException AssertTaskFaults(Task t, FirestoreError expectedError, + string expectedMessageRegex = null) { + var exception = AssertTaskFaults(t); + AssertEq( + String.Format("The task faulted (as expected); however, its exception was expected to " + + "be FirestoreException with ErrorCode={0} but the actual exception was " + + "{1}: {2}", expectedError, exception.GetType(), exception), + exception.GetType(), typeof(FirestoreException)); + + var firestoreException = (FirestoreException)exception; + AssertEq( + String.Format("The task faulted with FirestoreException (as expected); however, its " + + "ErrorCode was expected to be {0} but the actual ErrorCode was {1}: {2}", + expectedError, firestoreException.ErrorCode, firestoreException), + firestoreException.ErrorCode, expectedError); + + if (expectedMessageRegex != null) { + Assert(String.Format("The task faulted with FirestoreException with ErrorCode={0} " + + "(as expected); however, its message did not match the regular " + + "expression {1}: {2}", + expectedError, expectedMessageRegex, firestoreException.Message), + Regex.IsMatch(firestoreException.Message, expectedMessageRegex, + RegexOptions.Singleline)); + } + + return firestoreException; + } + + private void AssertTaskIsPending(Task t) { + AssertTaskProperties(t, isCompleted: false, isFaulted: false, isCanceled: false); + } + + // Wait for the Task to complete, then assert that it's Completed. + private void Await(Task t) { + t.Wait(); + Assert("Task completed successfully", t.IsCompleted); + } + + private T Await(Task t) { + Await((Task)t); + return t.Result; + } + + private Exception AwaitException(Task t) { + try { + t.Wait(); + } catch (AggregateException e) { + AssertEq("AwaitException() task returned multiple exceptions", e.InnerExceptions.Count, 1); + return e.InnerExceptions[0]; + } + throw new Exception("AwaitException() task succeeded rather than throwing an exception."); + } + + /** + * Compares two objects for deep equality. + */ + private bool ObjectDeepEquals(object left, object right) { + if (left == right) { + return true; + } else if (left == null) { + return right == null; + } else if (left is IEnumerable && right is IEnumerable) { + if (left is IDictionary && right is IDictionary) { + return DictionaryDeepEquals(left as IDictionary, right as IDictionary); + } + return EnumerableDeepEquals(left as IEnumerable, right as IEnumerable); + } else if (!left.GetType().Equals(right.GetType())) { + return false; + } else { + return left.Equals(right); + } + } + + /** + * Compares two IEnumerable for deep equality. + */ + private bool EnumerableDeepEquals(IEnumerable left, IEnumerable right) { + var leftEnumerator = left.GetEnumerator(); + var rightEnumerator = right.GetEnumerator(); + var leftNext = leftEnumerator.MoveNext(); + var rightNext = rightEnumerator.MoveNext(); + while (leftNext && rightNext) { + if (!ObjectDeepEquals(leftEnumerator.Current, rightEnumerator.Current)) { + return false; + } + leftNext = leftEnumerator.MoveNext(); + rightNext = rightEnumerator.MoveNext(); + } + + if (leftNext == rightNext) { + return true; + } + + return false; + } + + /** + * Compares two dictionaries for deep equality. + */ + private bool DictionaryDeepEquals(IDictionary left, IDictionary right) { + if (left.Count != right.Count) return false; + + foreach (object key in left.Keys) { + if (!right.Contains(key)) return false; + + if (!ObjectDeepEquals(left[key], right[key])) { + return false; + } + } + + return true; + } + + private string ObjectToString(object item) { + if (item == null) { + return "null"; + } else if (item is IDictionary) { + return DictionaryToString(item as IDictionary); + } else if (item is IList) { + return ListToString(item as IList); + } else { + return item.ToString(); + } + } + + private string ListToString(IList list) { + StringBuilder sb = new StringBuilder(); + bool first = true; + sb.Append("[ "); + foreach (object item in list) { + if (!first) { + sb.Append(", "); + } + first = false; + sb.Append(ObjectToString(item)); + } + sb.Append(" ]"); + return sb.ToString(); + } + + private string DictionaryToString(IDictionary dict) { + StringBuilder sb = new StringBuilder(); + bool first = true; + sb.Append("{ "); + foreach (DictionaryEntry keyValue in dict) { + if (!first) { + sb.Append(", "); + } + first = false; + sb.Append(ObjectToString(keyValue.Key) + ": " + ObjectToString(keyValue.Value)); + } + sb.Append(" }"); + return sb.ToString(); + } + + private List AsList(params T[] elements) { + return elements.ToList(); + } + + private const int AUTO_ID_LENGTH = 20; + private const string AUTO_ID_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; + private static System.Random rand = new System.Random(); + private static string AutoId() { + + string result = ""; + for (int i = 0; i < AUTO_ID_LENGTH; i++) { + result += AUTO_ID_ALPHABET[rand.Next(0, AUTO_ID_ALPHABET.Length)]; + } + + return result; + } + + private CollectionReference TestCollection() { + return db.Collection("test-collection_" + AutoId()); + } + + private DocumentReference TestDocument() { + return TestCollection().Document(); + } + + /// Runs the given action in a task to avoid blocking the main thread. + private Task Async(Action action) { + return Task.Run(action); + } + + private List> QuerySnapshotToValues(QuerySnapshot snap) { + List> res = new List>(); + foreach (DocumentSnapshot doc in snap) { + res.Add(doc.ToDictionary()); + } + return res; + } + + private Dictionary TestData(long n = 1) { + return new Dictionary { + {"name", "room " + n}, + {"active", true}, + {"list", new List { "one", 2L, "three", 4L } }, + {"metadata", new Dictionary { + {"createdAt", n}, + {"deep", new Dictionary { + {"field", "deep-field-" + n}, + {"nested-list", new List { "a", "b", "c" }}, + }} + }} + // TODO(rgowman): Add other types here too. + }; + } + + /** + * Tests a *very* basic trip through the Firestore API. + */ + Task TestGetKnownValue() { + return ToTask(GetKnownValue()).ContinueWithOnMainThread((task) => { + DocumentSnapshot snap = (previousTask as Task).Result; + + var dict = snap.ToDictionary(); + Assert("Resulting document is missing 'field1' field.", dict.ContainsKey("field1")); + AssertEq("'field1' is not equal to 'value1'", dict["field1"].ToString(), "value1"); + + return task; + }).Unwrap(); + } + + Task TestDeleteDocument() { + return Async(() => { + DocumentReference doc = TestDocument(); + var data = new Dictionary{ + {"f1", "v1"}, + }; + + Await(doc.SetAsync(data)); + DocumentSnapshot snap = Await(doc.GetSnapshotAsync()); + Assert("Written document should exist", snap.Exists); + + Await(doc.DeleteAsync()); + snap = Await(doc.GetSnapshotAsync()); + Assert("Deleted document should not exist", !snap.Exists); + + AssertEq(snap.ToDictionary(), null); + }); + } + + Task TestWriteDocument() { + return Async(() => { + DocumentReference doc = TestDocument(); + var data = TestData(); + + Await(doc.SetAsync(data)); + var actual = Await(doc.GetSnapshotAsync()).ToDictionary(); + + AssertDeepEq("Resulting data does not match", data, actual); + }); + } + + Task TestWriteDocumentViaCollection() { + return Async(() => { + var data = TestData(); + DocumentReference doc = Await(TestCollection().AddAsync(data)); + + var actual = Await(doc.GetSnapshotAsync()).ToDictionary(); + + AssertDeepEq("Resulting data does not match", data, actual); + + // Verify that the task returned from AddAsync() faults correctly on error. + var collectionWithInvalidName = TestCollection().Document("__badpath__").Collection("sub"); + var expectedFaultAddAsyncTask = collectionWithInvalidName.AddAsync(data); + AssertTaskFaults(expectedFaultAddAsyncTask, FirestoreError.InvalidArgument); + }); + } + + Task TestWriteDocumentWithIntegers() { + return Async(() => { + DocumentReference doc = db.Collection("col2").Document(); + var data = new Dictionary{ + {"f1", 2}, + {"map", new Dictionary{ {"nested f3", 4}, } }, + }; + var expected = new Dictionary{ + {"f1", 2L}, + {"map", new Dictionary{ {"nested f3", 4L}, } }, + }; + + Await(doc.SetAsync(data)); + DocumentSnapshot snap = Await(doc.GetSnapshotAsync()); + + var actual = snap.ToDictionary(); + AssertDeepEq("Resulting data does not match", expected, actual); + }); + } + + Task TestUpdateDocument() { + return Async(() => { + { + DocumentReference doc = TestDocument(); + var data = TestData(); + var updateData = new Dictionary{ + {"name", "foo"}, + {"metadata.createdAt", 42L} + }; + var expected = TestData(); + expected["name"] = "foo"; + ((Dictionary)expected["metadata"])["createdAt"] = 42L; + + Await(doc.SetAsync(data)); + Await(doc.UpdateAsync(updateData)); + DocumentSnapshot snap = Await(doc.GetSnapshotAsync()); + + var actual = snap.ToDictionary(); + AssertDeepEq("Resulting data does not match", expected, actual); + } + + // Verify that multiple deletes in a single update call work. + // https://github.com/firebase/quickstart-unity/issues/882 + { + DocumentReference doc = TestDocument(); + AssertTaskSucceeds(doc.SetAsync(new Dictionary { + {"key1", "value1"}, + {"key2", "value2"}, + {"key3", "value3"}, + {"key4", "value4"}, + {"key5", "value5"}, + })); + AssertTaskSucceeds(doc.UpdateAsync(new Dictionary { + {"key1", FieldValue.Delete}, + {"key3", FieldValue.Delete}, + {"key5", FieldValue.Delete}, + })); + DocumentSnapshot snapshot = Await(doc.GetSnapshotAsync(Source.Cache)); + var expected = new Dictionary { + {"key2", "value2"}, + {"key4", "value4"}, + }; + AssertDeepEq("Resulting data does not match", expected, snapshot.ToDictionary()); + } + }); + } + + Task TestListenForSnapshotsInSync() { + return Async(() => { + var events = new List(); + + var doc = TestDocument(); + var docAccumulator = new EventAccumulator(mainThreadId); + var docListener = doc.Listen(snapshot => { + events.Add("doc"); + docAccumulator.Listener(snapshot); + }); + + Await(doc.SetAsync(TestData(1))); + + docAccumulator.Await(); + events.Clear(); + + var syncAccumulator = new EventAccumulator(); + var syncListener = doc.Firestore.ListenForSnapshotsInSync(() => { + events.Add("sync"); + syncAccumulator.Listener("sync"); + }); + + // Ensure that the Task from the ListenerRegistration is in the correct state. + AssertTaskIsPending(syncListener.ListenerTask); + + Await(doc.SetAsync(TestData(2))); + + docAccumulator.Await(); + syncAccumulator.Await(2); + + var expectedEvents = new List { + "sync", // Initial in-sync event + "doc", // From the Set() + "sync" // Another in-sync event + }; + + docListener.Stop(); + syncListener.Stop(); + AssertTaskSucceeds(syncListener.ListenerTask); + + AssertDeepEq("events", events, expectedEvents); + }); + } + + Task TestMultiInstanceSnapshotsInSyncListeners() { + return Async(() => { + var db1Doc = TestDocument(); + var db1 = db1Doc.Firestore; + var app1 = db1.App; + + var app2 = FirebaseApp.Create(app1.Options, "MultiInstanceSnapshotsInSyncTest"); + var db2 = FirebaseFirestore.GetInstance(app2); + var db2Doc = db2.Collection(db1Doc.Parent.Id).Document(db1Doc.Id); + + var db1SyncAccumulator = new EventAccumulator(); + var db1SyncListener = db1.ListenForSnapshotsInSync(() => { + db1SyncAccumulator.Listener("db1 in sync"); + }); + db1SyncAccumulator.Await(); + + var db2SyncAccumulator = new EventAccumulator(); + db2.ListenForSnapshotsInSync(() => { + db2SyncAccumulator.Listener("db2 in sync"); + }); + db2SyncAccumulator.Await(); + + db1Doc.Listen((snap) => { }); + db1SyncAccumulator.Await(); + + db2Doc.Listen((snap) => { }); + db2SyncAccumulator.Await(); + + // At this point we have two firestore instances and separate listeners + // attached to each one and all are in an idle state. Once the second + // instance is disposed the listeners on the first instance should + // continue to operate normally and the listeners on the second + // instance should not receive any more events. + + db2SyncAccumulator.ThrowOnAnyEvent(); + + app2.Dispose(); + + Await(db1Doc.SetAsync(TestData(2))); + + db1SyncAccumulator.Await(); + + // TODO(b/158580488): Remove this line once the null ref exception + // during snapshots-in-sync listener cleanup is fixed in C++. + db1SyncListener.Stop(); + }); + } + + Task TestMultiInstanceDocumentReferenceListeners() { + return Async(() => { + var db1Doc = TestDocument(); + var db1 = db1Doc.Firestore; + var app1 = db1.App; + + var app2 = FirebaseApp.Create(app1.Options, "MultiInstanceDocumentReferenceListenersTest"); + var db2 = FirebaseFirestore.GetInstance(app2); + var db2Doc = db2.Collection(db1Doc.Parent.Id).Document(db1Doc.Id); + + var db1DocAccumulator = new EventAccumulator(); + db1Doc.Listen(db1DocAccumulator.Listener); + db1DocAccumulator.Await(); + + var db2DocAccumulator = new EventAccumulator(); + db2Doc.Listen(db2DocAccumulator.Listener); + db2DocAccumulator.Await(); + + // At this point we have two firestore instances and separate listeners + // attached to each one and all are in an idle state. Once the second + // instance is disposed the listeners on the first instance should + // continue to operate normally and the listeners on the second + // instance should not receive any more events. + + db2DocAccumulator.ThrowOnAnyEvent(); + + app2.Dispose(); + + Await(db1Doc.SetAsync(TestData(2))); + + db1DocAccumulator.Await(); + }); + } + + Task TestMultiInstanceQueryListeners() { + return Async(() => { + var db1Coll = TestCollection(); + var db1 = db1Coll.Firestore; + var app1 = db1.App; + + var app2 = FirebaseApp.Create(app1.Options, "MultiInstanceQueryListenersTest"); + var db2 = FirebaseFirestore.GetInstance(app2); + var db2Coll = db2.Collection(db1Coll.Id); + + var db1CollAccumulator = new EventAccumulator(); + db1Coll.Listen(db1CollAccumulator.Listener); + db1CollAccumulator.Await(); + + var db2CollAccumulator = new EventAccumulator(); + db2Coll.Listen(db2CollAccumulator.Listener); + db2CollAccumulator.Await(); + + // At this point we have two firestore instances and separate listeners + // attached to each one and all are in an idle state. Once the second + // instance is disposed the listeners on the first instance should + // continue to operate normally and the listeners on the second + // instance should not receive any more events. + + db2CollAccumulator.ThrowOnAnyEvent(); + + app2.Dispose(); + + Await(db1Coll.Document().SetAsync(TestData(1))); + + db1CollAccumulator.Await(); + }); + } + + Task TestUpdateFieldInDocument() { + return Async(() => { + DocumentReference doc = TestDocument(); + var data = new Dictionary{ + {"f1", "v1"}, + {"f2", "v2"}, + }; + + Await(doc.SetAsync(data)); + Await(doc.UpdateAsync("f2", "v2b")); + + var actual = Await(doc.GetSnapshotAsync()).ToDictionary(); + var expected = new Dictionary{ + {"f1", "v1"}, + {"f2", "v2b"}, + }; + AssertDeepEq("Resulting data does not match", expected, actual); + }); + } + + Task TestArrayUnionAndRemove() { + return Async(() => { + DocumentReference doc = TestDocument(); + + // Create via ArrayUnion + var data = new Dictionary { { "array", FieldValue.ArrayUnion(1L, 2L) } }; + Await(doc.SetAsync(data)); + var actual = Await(doc.GetSnapshotAsync()).ToDictionary(); + var expected = new Dictionary { { "array", new List { 1L, 2L } } }; + AssertDeepEq("Create via ArrayUnion", expected, actual); + + // Append via Update with ArrayUnion + data = new Dictionary { { "array", FieldValue.ArrayUnion(1L, 4L) } }; + Await(doc.UpdateAsync(data)); + actual = Await(doc.GetSnapshotAsync()).ToDictionary(); + expected = new Dictionary {{ "array", + new List { 1L, 2L, 4L }}}; + AssertDeepEq("Append via Update with ArrayUnion", expected, actual); + + // Append via Set/Merge with ArrayUnion + data = new Dictionary { { "array", FieldValue.ArrayUnion(2L, 3L) } }; + Await(doc.SetAsync(data, SetOptions.MergeAll)); + actual = Await(doc.GetSnapshotAsync()).ToDictionary(); + expected = new Dictionary {{ "array", + new List { 1L, 2L, 4L, 3L }}}; + AssertDeepEq("Append via Set/Merge with ArrayUnion", expected, actual); + + // Append object via Update with ArrayUnion + data = new Dictionary { + { "array", + FieldValue.ArrayUnion(1L, new Dictionary{{"a", "value"}}) + }}; + Await(doc.UpdateAsync(data)); + actual = Await(doc.GetSnapshotAsync()).ToDictionary(); + expected = new Dictionary { + { "array", + new List { 1L, 2L, 4L, 3L, new Dictionary{{"a", "value"}}}}}; + AssertDeepEq("Append object via Update with ArrayUnion", expected, actual); + + // Remove via Update with ArrayRemove + data = new Dictionary { + { "array", + FieldValue.ArrayRemove(1L, 4L) + }}; + Await(doc.UpdateAsync(data)); + actual = Await(doc.GetSnapshotAsync()).ToDictionary(); + expected = new Dictionary { + { "array", + new List { 2L, 3L, new Dictionary{{"a", "value"}}}}}; + AssertDeepEq("Remove via Update with ArrayRemove", expected, actual); + + // Remove via Set/Merge with ArrayRemove + data = new Dictionary { + { "array", + FieldValue.ArrayRemove(1L, 3L) + }}; + Await(doc.SetAsync(data, SetOptions.MergeAll)); + actual = Await(doc.GetSnapshotAsync()).ToDictionary(); + expected = new Dictionary { + { "array", + new List { 2L, new Dictionary{{"a", "value"}}}}}; + AssertDeepEq("Remove via Set/Merge with ArrayRemove", expected, actual); + + // Remove object via Update with ArrayRemove + data = new Dictionary { + { "array", + FieldValue.ArrayRemove(new Dictionary{{"a", "value"}}) + }}; + Await(doc.UpdateAsync(data)); + actual = Await(doc.GetSnapshotAsync()).ToDictionary(); + expected = new Dictionary { + { "array", + new List { 2L }}}; + AssertDeepEq("Remove object via Update with ArrayRemove", expected, actual); + }); + } + + Task TestUpdateFieldPath() { + return Async(() => { + DocumentReference doc = TestDocument(); + var data = new Dictionary{ + { + "f1", "v1" + }, { + "f2", new Dictionary{ + { + "a", new Dictionary{ + { + "b", new Dictionary{ + {"c", "v2"}, + } + }, + } + }, + } + }, + }; + + var updateData = new Dictionary{ + { new FieldPath("f2", "a", "b", "c"), "v2b"}, + { new FieldPath("f2", "x", "y", "z"), "v3"}, + }; + + var expected = new Dictionary{ + { + "f1", "v1" + }, { + "f2", new Dictionary{ + { + "a", new Dictionary{ + { + "b", new Dictionary{ + {"c", "v2b"}, + } + }, + } + }, { + "x", new Dictionary{ + { + "y", new Dictionary{ + {"z", "v3"}, + } + }, + } + }, + } + }, + }; + + Await(doc.SetAsync(data)); + Await(doc.UpdateAsync(updateData)); + DocumentSnapshot snap = Await(doc.GetSnapshotAsync()); + + var actual = snap.ToDictionary(); + AssertDeepEq("Resulting data does not match", expected, actual); + }); + } + + Task TestWriteBatches() { + return Async(() => { + DocumentReference doc1 = TestDocument(); + DocumentReference doc2 = TestDocument(); + DocumentReference doc3 = TestDocument(); + + // Initialize doc1 and doc2 with some data. + var initialData = new Dictionary{ + {"field", "value"}, + }; + Await(doc1.SetAsync(initialData)); + Await(doc2.SetAsync(initialData)); + + // Perform batch that deletes doc1, updates doc2, and overwrites doc3. + Await(doc1.Firestore.StartBatch() + .Delete(doc1) + .Update(doc2, new Dictionary { { "field2", "value2" } }) + .Update(doc2, new Dictionary { { new FieldPath("field3"), "value3" } }) + .Update(doc2, "field4", "value4") + .Set(doc3, initialData) + .CommitAsync()); + + DocumentSnapshot snap1 = Await(doc1.GetSnapshotAsync()); + AssertEq("doc1 should have been deleted", snap1.Exists, false); + + DocumentSnapshot snap2 = Await(doc2.GetSnapshotAsync()); + AssertDeepEq("doc2 should have been updated", snap2.ToDictionary(), + new Dictionary { + { "field", "value" }, + { "field2", "value2" }, + { "field3", "value3" }, + { "field4", "value4" }, + }); + + DocumentSnapshot snap3 = Await(doc3.GetSnapshotAsync()); + AssertDeepEq("doc3 should have been set", snap3.ToDictionary(), initialData); + + // Verify that the Task returned from CommitAsync() correctly reports errors. + var docWithInvalidName = TestCollection().Document("__badpath__"); + Task commitWithInvalidDocTask = docWithInvalidName.Firestore.StartBatch() + .Set(docWithInvalidName, TestData(0)) + .CommitAsync(); + // TODO(b/193834769) Assert "__badpath__" is in the message once the message is fixed. + AssertTaskFaults(commitWithInvalidDocTask, FirestoreError.InvalidArgument, "invalid"); + }); + } + + Task TestTransaction() { + return Async(() => { + DocumentReference doc1 = TestDocument(); + DocumentReference doc2 = TestDocument(); + DocumentReference doc3 = TestDocument(); + + // Initialize doc1 and doc2 with some data. + var initialData = new Dictionary{ + {"field", "value"}, + }; + Await(doc1.SetAsync(initialData)); + Await(doc2.SetAsync(initialData)); + + // Perform transaction that reads doc1, deletes doc1, updates doc2, and overwrites doc3. + string result = Await(doc1.Firestore.RunTransactionAsync((transaction) => { + AssertEq(mainThreadId, Thread.CurrentThread.ManagedThreadId); + return transaction.GetSnapshotAsync(doc1).ContinueWith((getTask) => { + AssertDeepEq("doc1 value matches expected", getTask.Result.ToDictionary(), initialData); + transaction.Delete(doc1); + transaction.Update(doc2, new Dictionary { { "field2", "value2" } }); + transaction.Update(doc2, new Dictionary { { new FieldPath("field3"), "value3" } }); + transaction.Update(doc2, "field4", "value4"); + transaction.Set(doc3, initialData); + return "txn result"; + }); + })); + AssertEq("Transaction result passed through", result, "txn result"); + + DocumentSnapshot snap1 = Await(doc1.GetSnapshotAsync()); + AssertEq("doc1 should have been deleted", snap1.Exists, false); + + DocumentSnapshot snap2 = Await(doc2.GetSnapshotAsync()); + AssertDeepEq("doc2 should have been updated", snap2.ToDictionary(), + new Dictionary { + { "field", "value" }, + { "field2", "value2" }, + { "field3", "value3" }, + { "field4", "value4" }, + }); + + DocumentSnapshot snap3 = Await(doc3.GetSnapshotAsync()); + AssertDeepEq("doc3 should have been set", snap3.ToDictionary(), initialData); + }); + } + + // Tests the overload of RunTransactionAsync() where the update function returns a non-generic + // Task object. + Task TestTransactionWithNonGenericTask() { + return Async(() => { + DocumentReference doc = TestDocument(); + Await(db.RunTransactionAsync((transaction) => { + transaction.Set(doc, TestData(1)); + // Create a plain (non-generic) `Task` result. + return Task.Run(() => { }); + })); + DocumentSnapshot snap = Await(doc.GetSnapshotAsync()); + AssertDeepEq(snap.ToDictionary(), TestData(1)); + }); + } + + Task TestTransactionAbort() { + return Async(() => { + // Returning a failed task should abort the transaction. + int retries = 0; + Task txnTask = db.RunTransactionAsync((transaction) => { + retries++; + TaskCompletionSource tcs = new TaskCompletionSource(); + tcs.SetException(new InvalidOperationException("Failed Task")); + return tcs.Task; + }); + Exception e = AwaitException(txnTask); + AssertEq(retries, 1); + AssertEq(e.GetType(), typeof(InvalidOperationException)); + AssertEq(e.Message, "Failed Task"); + + // Throwing an exception should also abort the transaction. + retries = 0; + txnTask = db.RunTransactionAsync((transaction) => { + retries++; + throw new InvalidOperationException("Failed Exception"); + }); + e = AwaitException(txnTask); + AssertEq(retries, 1); + AssertEq(e.GetType(), typeof(InvalidOperationException)); + AssertEq(e.Message, "Failed Exception"); + }); + } + + Task TestTransactionTaskFailures() { + return Async(() => { + Task txnTask = db.RunTransactionAsync((transaction) => { + var docWithInvalidName = TestCollection().Document("__badpath__"); + return transaction.GetSnapshotAsync(docWithInvalidName); + }); + AssertTaskFaults(txnTask, FirestoreError.InvalidArgument, "__badpath__"); + }); + } + + Task TestTransactionPermanentError() { + return Async(() => { + int retries = 0; + DocumentReference doc = TestDocument(); + // Try to update a document that doesn't exist. Should fail permanently (no retries) + // with a "Not Found" error. + Task txnTask = db.RunTransactionAsync((transaction) => { + retries++; + transaction.Update(doc, TestData(0)); + return Task.FromResult(null); + }); + AssertTaskFaults(txnTask, FirestoreError.NotFound, doc.Id); + AssertEq(retries, 1); + }); + } + + Task TestTransactionMaxRetryFailure() { + return Async(() => { + int retries = 0; + DocumentReference doc = TestDocument(); + FirebaseFirestore.LogLevel = LogLevel.Debug; + Task txnTask = db.RunTransactionAsync((transaction) => { + retries++; + return transaction.GetSnapshotAsync(doc).ContinueWith((snapshot) => { + // Queue a write via the transaction. + transaction.Set(doc, TestData(0)); + // But also write the document (out-of-band) so the transaction is retried. + return doc.SetAsync(TestData(retries)); + }).Unwrap(); + }); + AssertTaskFaults(txnTask, FirestoreError.FailedPrecondition); + // The transaction API will retry 6 times before giving up. + AssertEq(retries, 6); + }); + } + + Task TestSetOptions() { + return Async(() => { + DocumentReference doc = TestDocument(); + var initialData = new Dictionary { + { "field1", "value1" }, + }; + + var set1 = new Dictionary { + { "field2", "value2" } + }; + var setOptions1 = SetOptions.MergeAll; + + var set2 = new Dictionary { + { "field3", "value3" }, + { "not-field4", "not-value4" } + }; + var setOptions2 = SetOptions.MergeFields("field3"); + + var set3 = new Dictionary { + { "field4", "value4" }, + { "not-field5", "not-value5" } + }; + var setOptions3 = SetOptions.MergeFields(new FieldPath("field4")); + + var expected = new Dictionary { + { "field1", "value1" }, + { "field2", "value2" }, + { "field3", "value3" }, + { "field4", "value4" }, + }; + + Await(doc.SetAsync(initialData)); + Await(doc.SetAsync(set1, setOptions1)); + Await(doc.Firestore.StartBatch().Set(doc, set2, setOptions2).CommitAsync()); + // TODO(b/139355404): Switch the following SetAsync() to use a transaction instead once + // transactions are implemented. + Await(doc.SetAsync(set3, setOptions3)); + + DocumentSnapshot snap = Await(doc.GetSnapshotAsync()); + AssertDeepEq(snap.ToDictionary(), expected); + }); + } + + Task TestCanTraverseCollectionsAndDocuments() { + return Async(() => { + // doc path from root Firestore. + AssertEq("a/b/c/d", db.Document("a/b/c/d").Path); + + // collection path from root Firestore. + AssertEq("a/b/c/d", db.Collection("a/b/c").Document("d").Path); + + // doc path from CollectionReference. + AssertEq("a/b/c/d", db.Collection("a").Document("b/c/d").Path); + + // collection path from DocumentReference. + AssertEq("a/b/c/d/e", db.Document("a/b").Collection("c/d/e").Path); + }); + } + + Task TestCanTraverseCollectionAndDocumentParents() { + return Async(() => { + CollectionReference collection = db.Collection("a/b/c"); + AssertEq("a/b/c", collection.Path); + + DocumentReference doc = collection.Parent; + AssertEq("a/b", doc.Path); + + collection = doc.Parent; + AssertEq("a", collection.Path); + + DocumentReference invalidDoc = collection.Parent; + AssertEq(null, invalidDoc); + }); + } + + Task TestDocumentSnapshot() { + return Async(() => { + DocumentReference doc = db.Collection("col2").Document(); + var data = TestData(); + + Await(doc.SetAsync(data)); + DocumentSnapshot snap = Await(doc.GetSnapshotAsync()); + + TestDocumentSnapshotGetValue(snap, data); + TestDocumentSnapshotTryGetValue(snap, data); + TestDocumentSnapshotContainsField(snap, data); + }); + } + + Task TestDocumentSnapshotServerTimestampBehavior() { + return Async(() => { + DocumentReference doc = db.Collection("col2").Document(); + + bool cleanup = true; + try { + // Disable network so we can test unresolved server timestamp behavior. + Await(doc.Firestore.DisableNetworkAsync()); + + doc.SetAsync(new Dictionary { { "timestamp", "prev" } }); + doc.SetAsync(new Dictionary { { "timestamp", FieldValue.ServerTimestamp } }); + + DocumentSnapshot snap = Await(doc.GetSnapshotAsync()); + + // Default / None should return null. + AssertEq(snap.ToDictionary()["timestamp"], null); + AssertEq(snap.GetValue("timestamp"), null); + AssertEq(snap.ToDictionary(ServerTimestampBehavior.None)["timestamp"], null); + AssertEq(snap.GetValue("timestamp", ServerTimestampBehavior.None), null); + + // Previous should be "prev" + AssertEq(snap.ToDictionary(ServerTimestampBehavior.Previous)["timestamp"], "prev"); + AssertEq(snap.GetValue("timestamp", ServerTimestampBehavior.Previous), "prev"); + + // Estimate should be a timestamp. + Assert("Estimate should be a Timestamp", + snap.ToDictionary(ServerTimestampBehavior.Estimate)["timestamp"] is Timestamp); + Assert("Estimate should be a Timestamp", + snap.GetValue("timestamp", ServerTimestampBehavior.Estimate) is Timestamp); + } catch (ThreadAbortException) { + // Don't try to do anything else on this thread if it was aborted, or else it will hang. + cleanup = false; + } finally { + if (cleanup) { + Await(doc.Firestore.EnableNetworkAsync()); + } + } + }); + } + + Task TestDocumentSnapshotIntegerIncrementBehavior() { + return Async(() => { + DocumentReference doc = TestDocument(); + + var data = TestData(); + Await(doc.SetAsync(data)); + + var incrementValue = FieldValue.Increment(1L); + + var updateData = new Dictionary{ + {"metadata.createdAt", incrementValue } + }; + + Await(doc.UpdateAsync(updateData)); + DocumentSnapshot snap = Await(doc.GetSnapshotAsync()); + + var expected = TestData(); + ((Dictionary)expected["metadata"])["createdAt"] = 2L; + + var actual = snap.ToDictionary(); + AssertDeepEq("Resulting data does not match", expected, actual); + }); + } + + Task TestDocumentSnapshotDoubleIncrementBehavior() { + return Async(() => { + DocumentReference doc = TestDocument(); + + var data = TestData(); + Await(doc.SetAsync(data)); + + var incrementValue = FieldValue.Increment(1.5); + + var updateData = new Dictionary{ + {"metadata.createdAt", incrementValue } + }; + + Await(doc.UpdateAsync(updateData)); + DocumentSnapshot snap = Await(doc.GetSnapshotAsync()); + + var expected = TestData(); + ((Dictionary)expected["metadata"])["createdAt"] = 2.5; + + var actual = snap.ToDictionary(); + AssertDeepEq("Resulting data does not match", expected, actual); + }); + } + + private void TestDocumentSnapshotGetValue(DocumentSnapshot snap, Dictionary data) { + AssertEq(data["name"], snap.GetValue("name")); + AssertDeepEq("Resulting data.metadata does not match.", + data["metadata"], + snap.GetValue>("metadata")); + AssertEq("deep-field-1", snap.GetValue("metadata.deep.field")); + AssertEq("deep-field-1", snap.GetValue(new FieldPath("metadata", "deep", "field"))); + // Nonexistent field. + AssertException(typeof(InvalidOperationException), + () => snap.GetValue("nonexistent")); + // Existent field deserialized to wrong type. + AssertException(typeof(ArgumentException), + () => snap.GetValue("name")); + } + + private void TestDocumentSnapshotTryGetValue(DocumentSnapshot snap, Dictionary data) { + // Existent field. + String name; + Assert("Got value", snap.TryGetValue("name", out name)); + AssertEq(data["name"], name); + + // Nonexistent field. + Assert("Should not have got value", !snap.TryGetValue("namex", out name)); + AssertEq(null, name); + + // Existent field deserialized to wrong type. + AssertException(typeof(ArgumentException), + () => { + long l; + snap.TryGetValue("name", out l); + }); + } + + private void TestDocumentSnapshotContainsField(DocumentSnapshot snap, Dictionary data) { + // Existent fields. + Assert("Field should exist", snap.ContainsField("name")); + Assert("Field should exist", snap.ContainsField("metadata.deep.field")); + Assert("Field should exist", snap.ContainsField(new FieldPath("metadata", "deep", "field"))); + + // Nonexistent field. + Assert("Field should not exist", !snap.ContainsField("namex")); + } + + Task TestAuthIntegration() { + return Async(() => { + var firebaseAuth = Firebase.Auth.FirebaseAuth.DefaultInstance; + var data = TestData(); + + firebaseAuth.SignOut(); + + DocumentReference doc = db.Collection("private").Document(); + // TODO(mikelehen): Check for permission_denied once we plumb errors through somehow. + AssertException(typeof(Exception), () => Await(doc.SetAsync(data))); + + Await(firebaseAuth.SignInAnonymouslyAsync()); + + // Write should now succeed. + Await(doc.SetAsync(data)); + + firebaseAuth.SignOut(); + + // TODO(b/138616555): We shouldn't need this sleep and extra SignOut(), but it seems like + // Auth sometimes sends us an extra event. + System.Threading.Thread.Sleep(1000); + firebaseAuth.SignOut(); + }); + } + + Task TestDocumentListen() { + return Async(() => { + var doc = TestDocument(); + var initialData = TestData(1); + var newData = TestData(2); + + Await(doc.SetAsync(initialData)); + + var accumulator = new EventAccumulator(mainThreadId); + var registration = doc.Listen(accumulator.Listener); + + // Ensure that the Task from the ListenerRegistration is in the correct state. + AssertTaskIsPending(registration.ListenerTask); + + // Wait for the first snapshot. + DocumentSnapshot snapshot = accumulator.Await(); + AssertDeepEq("Initial snapshot matches", snapshot.ToDictionary(), initialData); + AssertEq(snapshot.Metadata.IsFromCache, true); + AssertEq(snapshot.Metadata.HasPendingWrites, false); + + // Write new data and wait for the resulting snapshot. + doc.SetAsync(newData); + snapshot = accumulator.Await(); + AssertDeepEq("Second snapshot matches written data", + snapshot.ToDictionary(), newData); + AssertEq(snapshot.Metadata.HasPendingWrites, true); + + // Remove the listener and make sure we don't get events anymore. + accumulator.ThrowOnAnyEvent(); + registration.Stop(); + AssertTaskSucceeds(registration.ListenerTask); + Await(doc.SetAsync(TestData(3))); + + // Ensure that the Task from the ListenerRegistration correctly fails with an error. + var docWithInvalidName = TestCollection().Document("__badpath__"); + var callbackInvoked = false; + var registration2 = docWithInvalidName.Listen(snap => { callbackInvoked = true; }); + AssertTaskFaults(registration2.ListenerTask, FirestoreError.InvalidArgument, "__badpath__"); + registration2.Stop(); + System.Threading.Thread.Sleep(50); + Assert("The callback should not have been invoked", !callbackInvoked); + }); + } + + Task TestDocumentListenWithMetadataChanges() { + return Async(() => { + var doc = TestDocument(); + var initialData = TestData(1); + var newData = TestData(2); + + Await(doc.SetAsync(initialData)); + + var accumulator = new EventAccumulator(); + var registration = doc.Listen(MetadataChanges.Include, accumulator.Listener); + + // Ensure that the Task from the ListenerRegistration is in the correct state. + AssertTaskIsPending(registration.ListenerTask); + + // Wait for the first snapshot. + DocumentSnapshot snapshot = accumulator.Await(); + AssertDeepEq("Initial snapshot matches", snapshot.ToDictionary(), initialData); + AssertEq(snapshot.Metadata.IsFromCache, true); + AssertEq(snapshot.Metadata.HasPendingWrites, false); + + // Wait for new snapshot once we're synced with the backend. + snapshot = accumulator.Await(); + AssertEq(snapshot.Metadata.IsFromCache, false); + + // Write new data and wait for the resulting snapshot. + doc.SetAsync(newData); + snapshot = accumulator.Await(); + AssertDeepEq("Second snapshot matches written data", + snapshot.ToDictionary(), newData); + AssertEq(snapshot.Metadata.HasPendingWrites, true); + + // Wait for new snapshot once write completes. + snapshot = accumulator.Await(); + AssertEq(snapshot.Metadata.HasPendingWrites, false); + + // Remove the listener and make sure we don't get events anymore. + accumulator.ThrowOnAnyEvent(); + registration.Stop(); + AssertTaskSucceeds(registration.ListenerTask); + Await(doc.SetAsync(TestData(3))); + + // Ensure that the Task from the ListenerRegistration correctly fails with an error. + var docWithInvalidName = TestCollection().Document("__badpath__"); + var callbackInvoked = false; + var registration2 = + docWithInvalidName.Listen(MetadataChanges.Include, snap => { callbackInvoked = true; }); + AssertTaskFaults(registration2.ListenerTask, FirestoreError.InvalidArgument, "__badpath__"); + registration2.Stop(); + System.Threading.Thread.Sleep(50); + Assert("The callback should not have been invoked", !callbackInvoked); + }); + } + + Task TestQueryListen() { + return Async(() => { + var collection = TestCollection(); + var firstDoc = TestData(1); + var secondDoc = TestData(2); + + Await(collection.Document("a").SetAsync(firstDoc)); + + var accumulator = new EventAccumulator(mainThreadId); + var registration = collection.Listen(accumulator.Listener); + + // Ensure that the Task from the ListenerRegistration is in the correct state. + AssertTaskIsPending(registration.ListenerTask); + + // Wait for the first snapshot. + QuerySnapshot snapshot = accumulator.Await(); + AssertEq("Expected one document", 1, snapshot.Count); + AssertDeepEq("First doc matches", snapshot[0].ToDictionary(), firstDoc); + AssertEq(snapshot.Metadata.IsFromCache, true); + AssertEq(snapshot.Metadata.HasPendingWrites, false); + + // Write a new document and wait for the resulting snapshot. + collection.Document("b").SetAsync(secondDoc); + snapshot = accumulator.Await(); + AssertEq("Expected two documents.", 2, snapshot.Count); + AssertDeepEq("First doc matches", snapshot[0].ToDictionary(), firstDoc); + AssertDeepEq("Second doc matches", snapshot[1].ToDictionary(), secondDoc); + AssertEq(snapshot.Metadata.HasPendingWrites, true); + + // Remove the listener and make sure we don't get events anymore. + accumulator.ThrowOnAnyEvent(); + registration.Stop(); + AssertTaskSucceeds(registration.ListenerTask); + Await(collection.Document("c").SetAsync(TestData(3))); + + // Ensure that the Task from the ListenerRegistration correctly fails with an error. + var collectionWithInvalidName = TestCollection().Document("__badpath__").Collection("sub"); + var callbackInvoked = false; + var registration2 = collectionWithInvalidName.Listen(snap => { callbackInvoked = true; }); + AssertTaskFaults(registration2.ListenerTask, FirestoreError.InvalidArgument, "__badpath__"); + registration2.Stop(); + System.Threading.Thread.Sleep(50); + Assert("The callback should not have been invoked", !callbackInvoked); + }); + } + + Task TestQueryListenWithMetadataChanges() { + return Async(() => { + var collection = TestCollection(); + + var firstDoc = TestData(1); + var secondDoc = TestData(2); + + Await(collection.Document("a").SetAsync(firstDoc)); + + var accumulator = new EventAccumulator(); + var registration = collection.Listen(MetadataChanges.Include, accumulator.Listener); + + // Ensure that the Task from the ListenerRegistration is in the correct state. + AssertTaskIsPending(registration.ListenerTask); + + // Wait for the first snapshot. + QuerySnapshot snapshot = accumulator.Await(); + AssertEq("Expected one document", 1, snapshot.Count); + AssertDeepEq("First doc matches", snapshot[0].ToDictionary(), firstDoc); + AssertEq(snapshot.Metadata.IsFromCache, true); + AssertEq(snapshot.Metadata.HasPendingWrites, false); + + // Wait for new snapshot once we're synced with the backend. + snapshot = accumulator.Await(); + AssertEq(snapshot.Metadata.IsFromCache, false); + + // Write a new document and wait for the resulting snapshot. + collection.Document("b").SetAsync(secondDoc); + snapshot = accumulator.Await(); + AssertEq("Expected two documents.", 2, snapshot.Count); + AssertDeepEq("First doc matches", snapshot[0].ToDictionary(), firstDoc); + AssertDeepEq("Second doc matches", snapshot[1].ToDictionary(), secondDoc); + AssertEq(snapshot.Metadata.HasPendingWrites, true); + + // Wait for new snapshot once write completes. + snapshot = accumulator.Await(); + AssertEq(snapshot.Metadata.HasPendingWrites, false); + + // Remove the listener and make sure we don't get events anymore. + accumulator.ThrowOnAnyEvent(); + registration.Stop(); + AssertTaskSucceeds(registration.ListenerTask); + Await(collection.Document("c").SetAsync(TestData(3))); + + // Ensure that the Task from the ListenerRegistration correctly fails with an error. + var collectionWithInvalidName = TestCollection().Document("__badpath__").Collection("sub"); + var callbackInvoked = false; + var registration2 = collectionWithInvalidName.Listen(MetadataChanges.Include, + snap => { callbackInvoked = true; }); + AssertTaskFaults(registration2.ListenerTask, FirestoreError.InvalidArgument, "__badpath__"); + registration2.Stop(); + System.Threading.Thread.Sleep(50); + Assert("The callback should not have been invoked", !callbackInvoked); + }); + } + + Task TestQuerySnapshotChanges() { + return Async(() => { + var collection = TestCollection(); + + var initialData = TestData(1); + var updatedData = TestData(2); + + Await(collection.Document("a").SetAsync(initialData)); + + var accumulator = new EventAccumulator(); + var registration = collection.Listen(MetadataChanges.Include, accumulator.Listener); + + // Wait for the first snapshot. + QuerySnapshot snapshot = accumulator.Await(); + AssertEq("Expected one document", 1, snapshot.Count); + AssertDeepEq("First snapshot matches initial data", snapshot[0].ToDictionary(), initialData); + AssertDeepEq("Can be converted to an array", snapshot.ToArray()[0].ToDictionary(), initialData); + AssertEq(snapshot.Metadata.IsFromCache, true); + AssertEq(snapshot.Metadata.HasPendingWrites, false); + + // Wait for new snapshot once we're synced with the backend. + snapshot = accumulator.Await(); + AssertEq(snapshot.Metadata.IsFromCache, false); + + // Update the document and wait for the resulting snapshot. + collection.Document("a").SetAsync(updatedData); + snapshot = accumulator.Await(); + AssertDeepEq("New snapshot contains updated data", snapshot[0].ToDictionary(), updatedData); + AssertEq(snapshot.Metadata.HasPendingWrites, true); + + // Wait for snapshot indicating the write has completed. + snapshot = accumulator.Await(); + AssertEq(snapshot.Metadata.HasPendingWrites, false); + + var changes = snapshot.GetChanges(); + AssertEq("Expected zero documents.", 0, changes.Count()); + + var changesIncludingMetadata = snapshot.GetChanges(MetadataChanges.Include); + AssertEq("Expected one document.", 1, changesIncludingMetadata.Count()); + + var changedDocument = changesIncludingMetadata.First().Document; + AssertEq(changedDocument.Metadata.HasPendingWrites, false); + + // Remove the listener and make sure we don't get events anymore. + accumulator.ThrowOnAnyEvent(); + registration.Stop(); + Await(collection.Document("c").SetAsync(TestData(3))); + }); + } + + Task TestQueries() { + return Async(() => { + // Initialize collection with a few test documents to query against. + var c = TestCollection(); + Await(c.Document("a").SetAsync(new Dictionary { + { "num", 1 }, + { "state", "created" }, + { "active", true }, + { "nullable", "value" }, + })); + Await(c.Document("b").SetAsync(new Dictionary { + { "num", 2 }, + { "state", "done" }, + { "active", false }, + { "nullable", null }, + })); + Await(c.Document("c").SetAsync(new Dictionary { + { "num", 3 }, + { "state", "done" }, + { "active", true }, + { "nullable", null }, + })); + // Put in a nested collection (with same ID) for testing collection group queries. + Await(c.Document("d") + .Collection(c.Id) + .Document("d-nested") + .SetAsync(new Dictionary { + { "num", 4 }, + { "state", "created" }, + { "active", false }, + { "nullable", null }, + })); + + AssertQueryResults( + desc: "EqualTo", + query: c.WhereEqualTo("num", 1), + docIds: AsList("a")); + AssertQueryResults( + desc: "EqualTo (FieldPath)", + query: c.WhereEqualTo(new FieldPath("num"), 1), + docIds: AsList("a")); + + AssertQueryResults(desc: "NotEqualTo", query: c.WhereNotEqualTo("num", 1), + docIds: AsList("b", "c")); + AssertQueryResults(desc: "NotEqualTo (FieldPath)", + query: c.WhereNotEqualTo(new FieldPath("num"), 1), + docIds: AsList("b", "c")); + AssertQueryResults(desc: "NotEqualTo (FieldPath) on nullable", + query: c.WhereNotEqualTo(new FieldPath("nullable"), null), + docIds: AsList("a")); + + AssertQueryResults(desc: "LessThanOrEqualTo", query: c.WhereLessThanOrEqualTo("num", 2), + docIds: AsList("a", "b")); + AssertQueryResults( + desc: "LessThanOrEqualTo (FieldPath)", + query: c.WhereLessThanOrEqualTo(new FieldPath("num"), 2), + docIds: AsList("a", "b")); + + AssertQueryResults( + desc: "LessThan", + query: c.WhereLessThan("num", 2), + docIds: AsList("a")); + AssertQueryResults( + desc: "LessThan (FieldPath)", + query: c.WhereLessThan(new FieldPath("num"), 2), + docIds: AsList("a")); + + AssertQueryResults( + desc: "GreaterThanOrEqualTo", + query: c.WhereGreaterThanOrEqualTo("num", 2), + docIds: AsList("b", "c")); + AssertQueryResults( + desc: "GreaterThanOrEqualTo (FieldPath)", + query: c.WhereGreaterThanOrEqualTo(new FieldPath("num"), 2), + docIds: AsList("b", "c")); + + AssertQueryResults( + desc: "GreaterThan", + query: c.WhereGreaterThan("num", 2), + docIds: AsList("c")); + AssertQueryResults( + desc: "GreaterThan (FieldPath)", + query: c.WhereGreaterThan(new FieldPath("num"), 2), + docIds: AsList("c")); + + AssertQueryResults( + desc: "two EqualTos", + query: c.WhereEqualTo("state", "done").WhereEqualTo("active", false), + docIds: AsList("b")); + + AssertQueryResults( + desc: "OrderBy, Limit", + query: c.OrderBy("num").Limit(2), + docIds: AsList("a", "b")); + AssertQueryResults( + desc: "OrderBy, Limit (FieldPath)", + query: c.OrderBy(new FieldPath("num")).Limit(2), + docIds: AsList("a", "b")); + + AssertQueryResults( + desc: "OrderByDescending, Limit", + query: c.OrderByDescending("num").Limit(2), + docIds: AsList("c", "b")); + AssertQueryResults( + desc: "OrderByDescending, Limit (FieldPath)", + query: c.OrderByDescending(new FieldPath("num")).Limit(2), + docIds: AsList("c", "b")); + + AssertQueryResults( + desc: "StartAfter", + query: c.OrderBy("num").StartAfter(2), + docIds: AsList("c")); + AssertQueryResults( + desc: "EndBefore", + query: c.OrderBy("num").EndBefore(2), + docIds: AsList("a")); + AssertQueryResults( + desc: "StartAt, EndAt", + query: c.OrderBy("num").StartAt(2).EndAt(2), + docIds: AsList("b")); + + // Collection Group Query + AssertQueryResults( + desc: "CollectionGroup", + query: db.CollectionGroup(c.Id), + docIds: AsList("a", "b", "c", "d-nested") + ); + }); + } + + Task TestLimitToLast() { + return Async(() => { + var c = TestCollection(); + // TODO(b/149105903): Uncomment this line when exception can be raised from SWIG and below. + // AssertException(typeof(Exception), () => Await(c.LimitToLast(2).GetSnapshotAsync())); + + // Initialize data with a few test documents to query against. + Await(c.Document("a").SetAsync(new Dictionary { + {"k", "a"}, + {"sort", 0}, + })); + Await(c.Document("b").SetAsync(new Dictionary { + {"k", "b"}, + {"sort", 1}, + })); + Await(c.Document("c").SetAsync(new Dictionary { + {"k", "c"}, + {"sort", 1}, + })); + Await(c.Document("d").SetAsync(new Dictionary { + {"k", "d"}, + {"sort", 2}, + })); + + // Setup `limit` query. + var limit = c.Limit(2).OrderBy("sort"); + var limitAccumulator = new EventAccumulator(); + var limitReg = limit.Listen(limitAccumulator.Listener); + + // Setup mirroring `limitToLast` query. + var limitToLast = c.LimitToLast(2).OrderByDescending("sort"); + var limitToLastAccumulator = new EventAccumulator(); + var limitToLastReg = limitToLast.Listen(limitToLastAccumulator.Listener); + + // Verify both query get expected result. + var data = QuerySnapshotToValues(limitAccumulator.Await()); + AssertDeepEq(data, new List> + { new Dictionary{ {"k", "a"}, { "sort", 0L}}, + new Dictionary{ {"k", "b"}, { "sort", 1L}} + }); + data = QuerySnapshotToValues(limitToLastAccumulator.Await()); + AssertDeepEq(data, new List> + { new Dictionary{ {"k", "b"}, { "sort", 1L}}, + new Dictionary{ {"k", "a"}, { "sort", 0L}} + }); + + // Unlisten then re-listen limit query. + limitReg.Stop(); + limit.Listen(limitAccumulator.Listener); + + // Verify `limit` query still works. + data = QuerySnapshotToValues(limitAccumulator.Await()); + AssertDeepEq(data, new List> + { new Dictionary{ {"k", "a"}, { "sort", 0L}}, + new Dictionary{ {"k", "b"}, { "sort", 1L}} + }); + + // Add a document that would change the result set. + Await(c.Document("d").SetAsync(new Dictionary { + {"k", "e"}, + {"sort", -1}, + })); + + // Verify both query get expected result. + data = QuerySnapshotToValues(limitAccumulator.Await()); + AssertDeepEq(data, new List> + { new Dictionary{ {"k", "e"}, { "sort", -1L}}, + new Dictionary{ {"k", "a"}, { "sort", 0L}} + }); + data = QuerySnapshotToValues(limitToLastAccumulator.Await()); + AssertDeepEq(data, new List> + { new Dictionary{ {"k", "a"}, { "sort", 0L}}, + new Dictionary{ {"k", "e"}, { "sort", -1L}} + }); + + // Unlisten to limitToLast, update a doc, then relisten to limitToLast + limitToLastReg.Stop(); + Await(c.Document("a").UpdateAsync("sort", -2)); + limitToLast.Listen(limitToLastAccumulator.Listener); + + // Verify both query get expected result. + data = QuerySnapshotToValues(limitAccumulator.Await()); + AssertDeepEq(data, new List> + { new Dictionary{ {"k", "a"}, { "sort", -2L}}, + new Dictionary{ {"k", "e"}, { "sort", -1L}} + }); + data = QuerySnapshotToValues(limitToLastAccumulator.Await()); + AssertDeepEq(data, new List> + { new Dictionary{ {"k", "e"}, { "sort", -1L}}, + new Dictionary{ {"k", "a"}, { "sort", -2L}} + }); + }); + } + + Task TestArrayContains() { + return Async(() => { + // Initialize collection with a few test documents to query against. + var c = TestCollection(); + Await(c.Document("a").SetAsync(new Dictionary { + {"array", new List { 42 }}, + })); + + Await(c.Document("b").SetAsync(new Dictionary { + {"array", new List {"a", 42, "c"}}, + })); + + Await(c.Document("c").SetAsync(new Dictionary { + {"array", new List { + 41.999, + "42", + new Dictionary { + {"array", new List { 42 }}}}}})); + + Await(c.Document("d").SetAsync(new Dictionary { + {"array", new List {42}}, + {"array2", new List {"bingo"}}, + })); + + AssertQueryResults( + desc: "ArrayContains", + query: c.WhereArrayContains(new FieldPath("array"), 42), + docIds: AsList("a", "b", "d")); + AssertQueryResults( + desc: "ArrayContains", + query: c.WhereArrayContains("array", 42), + docIds: AsList("a", "b", "d")); + }); + } + + Task TestArrayContainsAny() { + return Async(() => { + // Initialize collection with a few test documents to query against. + var c = TestCollection(); + Await(c.Document("a").SetAsync(new Dictionary { + {"array", new List { 42 }}, + })); + + Await(c.Document("b").SetAsync(new Dictionary { + {"array", new List {"a", 42, "c"}}, + })); + + Await(c.Document("c").SetAsync(new Dictionary { + {"array", new List { + 41.999, + "42", + new Dictionary { + {"array", new List { 42 }}}}}})); + + Await(c.Document("d").SetAsync(new Dictionary { + {"array", new List {42}}, + {"array2", new List {"bingo"}}, + })); + + Await(c.Document("e").SetAsync(new Dictionary { + {"array", new List {43}} + })); + + Await(c.Document("f").SetAsync(new Dictionary { + {"array", + new List { + new Dictionary { + {"a", 42}}}}})); + + Await(c.Document("g").SetAsync(new Dictionary { + {"array", 42}, + })); + + AssertQueryResults( + desc: "ArrayContainsAny", + query: c.WhereArrayContainsAny("array", new List { 42, 43 }), + docIds: AsList("a", "b", "d", "e")); + + AssertQueryResults( + desc: "ArrayContainsAnyObject", + query: c.WhereArrayContainsAny( + new FieldPath("array"), + new List { + new Dictionary { + {"a", 42}} }), + docIds: AsList("f")); + }); + } + + Task TestInQueries() { + return Async(() => { + // Initialize collection with a few test documents to query against. + var c = TestCollection(); + Await(c.Document("a").SetAsync(new Dictionary { + { "zip", 98101 }, + { "nullable", null }, + })); + Await(c.Document("b").SetAsync(new Dictionary { + { "zip", 98102 }, + { "nullable", "value" }, + })); + Await(c.Document("c").SetAsync(new Dictionary { + { "zip", 98103 }, + { "nullable", null }, + })); + Await(c.Document("d").SetAsync(new Dictionary { + {"zip", new List{98101} } + })); + Await(c.Document("e").SetAsync(new Dictionary { + {"zip", new List{"98101", new Dictionary {{"zip", 98101} } } } + })); + Await(c.Document("f").SetAsync(new Dictionary { + { "zip", new Dictionary { { "code", 500 } } }, + { "nullable", 123 }, + })); + Await(c.Document("g").SetAsync(new Dictionary { + { "zip", new List { 98101, 98102 } }, + { "nullable", null }, + })); + + AssertQueryResults( + desc: "InQuery", + query: c.WhereIn("zip", + new List { 98101, 98103, new List { 98101, 98102 } }), + docIds: AsList("a", "c", "g")); + + AssertQueryResults( + desc: "InQueryWithObject", + query: c.WhereIn(new FieldPath("zip"), + new List { new Dictionary { { "code", 500 } } }), + docIds: AsList("f")); + + AssertQueryResults( + desc: "InQueryWithDocIds", + query: c.WhereIn(FieldPath.DocumentId, + new List { "c", "e" }), + docIds: AsList("c", "e")); + + AssertQueryResults( + desc: "NotInQuery", + query: c.WhereNotIn( + "zip", new List { 98101, 98103, new List { 98101, 98102 } }), + docIds: AsList("b", "d", "e", "f")); + + AssertQueryResults( + desc: "NotInQueryWithObject", + query: c.WhereNotIn( + new FieldPath("zip"), + new List { new List { 98101, 98102 }, + new Dictionary { { "code", 500 } } }), + docIds: AsList("a", "b", "c", "d", "e")); + + AssertQueryResults( + desc: "NotInQueryWithDocIds", + query: c.WhereNotIn(FieldPath.DocumentId, new List { "a", "c", "e" }), + docIds: AsList("b", "d", "f", "g")); + + AssertQueryResults( + desc: "NotInQueryWithNulls", + query: c.WhereNotIn(new FieldPath("nullable"), new List { null }), + docIds: new List {}); + }); + } + + Task TestDefaultInstanceStable() { + return Async(() => { + FirebaseFirestore db1 = FirebaseFirestore.DefaultInstance; + FirebaseFirestore db2 = FirebaseFirestore.DefaultInstance; + AssertEq("FirebaseFirestore.DefaultInstance's not stable", db1, db2); + }); + } + + // Tests that DocumentReference and Query respect the Source parameter passed to + // GetSnapshotAsync(). We don't exhaustively test the behavior. We just do enough + // checks to verify that cache, default, and server produce distinct results. + Task TestGetAsyncSource() { + return Async(() => { + DocumentReference doc = TestDocument(); + + Await(doc.SetAsync(TestData())); + + // Verify FromCache gives us cached results even when online. + DocumentSnapshot docSnap = Await(doc.GetSnapshotAsync(Source.Cache)); + AssertEq(docSnap.Metadata.IsFromCache, true); + QuerySnapshot querySnap = Await(doc.Parent.GetSnapshotAsync(Source.Cache)); + AssertEq(querySnap.Metadata.IsFromCache, true); + + // Verify Default gives us non-cached results when online. + docSnap = Await(doc.GetSnapshotAsync(Source.Default)); + AssertEq(docSnap.Metadata.IsFromCache, false); + querySnap = Await(doc.Parent.GetSnapshotAsync(Source.Default)); + AssertEq(querySnap.Metadata.IsFromCache, false); + + bool cleanup = true; + try { + // Disable network so we can test offline behavior. + Await(doc.Firestore.DisableNetworkAsync()); + + // Verify Default gives us cached results when offline. + docSnap = Await(doc.GetSnapshotAsync(Source.Default)); + AssertEq(docSnap.Metadata.IsFromCache, true); + querySnap = Await(doc.Parent.GetSnapshotAsync(Source.Default)); + AssertEq(querySnap.Metadata.IsFromCache, true); + + // Verify Server gives us an error when offline even if there's data in cache.. + // TODO(mikelehen): Check for unavailable error once we plumb errors through somehow. + AssertException(typeof(Exception), () => Await(doc.GetSnapshotAsync(Source.Server))); + AssertException(typeof(Exception), () => Await(doc.Parent.GetSnapshotAsync( + Source.Server))); + } catch (ThreadAbortException) { + // Don't try to do anything else on this thread if it was aborted, or else it will hang. + cleanup = false; + } finally { + if (cleanup) { + Await(doc.Firestore.EnableNetworkAsync()); + } + } + }); + } + + Task TestWaitForPendingWrites() { + return Async(() => { + DocumentReference doc = TestDocument(); + + Await(doc.Firestore.DisableNetworkAsync()); + + // Returns immediately because there is no pending writes. + var pendingWrites1 = doc.Firestore.WaitForPendingWritesAsync(); + doc.SetAsync(new Dictionary { + {"zip", 98101} + }); + var pendingWrites2 = doc.Firestore.WaitForPendingWritesAsync(); + + // `pendingWrites1` completes immediately because there are no pending writes at + // the time it is created. + AssertTaskSucceeds(pendingWrites1); + AssertTaskIsPending(pendingWrites2); + + Await(doc.Firestore.EnableNetworkAsync()); + AssertTaskSucceeds(pendingWrites2); + }); + } + + // TODO(wuandy): Add a test to verify WaitForPendingWritesAsync task fails in user change. + // It requires to create underlying firestore instance with + // a MockCredentialProvider first. + + Task TestTerminate() { + return Async(() => { + var db1 = NonDefaultFirestore("TestTerminate"); + FirebaseApp app = db1.App; + var doc = db1.Document("abc/123"); + var accumulator = new EventAccumulator(); + var registration = doc.Listen(accumulator.Listener); + + // Multiple calls to terminate should go through. + Await(db1.TerminateAsync()); + Await(db1.TerminateAsync()); + + // Can call registration.Stop multiple times even after termination. + registration.Stop(); + registration.Stop(); + + // TODO(b/149105903) Uncomment this line when a C# exception can be thrown here. + // AssertException(typeof(Exception), () => Await(db2.DisableNetworkAsync())); + + // Create a new functional instance. + var db2 = FirebaseFirestore.GetInstance(app); + Assert("Should create a new instance.", db1 != db2); + Await(db2.DisableNetworkAsync()); + Await(db2.EnableNetworkAsync()); + + app.Dispose(); + // TODO(wuandy): App.Dispose really should leads to Firestore terminated, a NRE here is + // not ideal, but serves the purpose for now. Ideally, it should throw an exception + // telling user it is terminated. + AssertException(typeof(NullReferenceException), () => Await(db2.DisableNetworkAsync())); + }); + } + + Task TestClearPersistence() { + return Async(() => { + var defaultOptions = TestCollection().Firestore.App.Options; + string path; + + // Verify that ClearPersistenceAsync() succeeds when invoked on a newly-created + // FirebaseFirestore instance. + { + var app = FirebaseApp.Create(defaultOptions, "TestClearPersistenceApp"); + var db = FirebaseFirestore.GetInstance(app); + AssertTaskSucceeds(db.ClearPersistenceAsync()); + app.Dispose(); + } + + // Create a document to use to verify the behavior of ClearPersistenceAsync(). + { + var app = FirebaseApp.Create(defaultOptions, "TestClearPersistenceApp"); + var db = FirebaseFirestore.GetInstance(app); + var docContents = new Dictionary { { "foo", 42 } }; + + var doc = db.Collection("TestCollection").Document(); + path = doc.Path; + // It is not necessary to Await on the Task returned from SetAsync() below. This is + // because the document has already been written to persistence by the time that + // SetAsync() returns. + doc.SetAsync(docContents); + AssertTaskSucceeds(db.TerminateAsync()); + app.Dispose(); + } + + // As a sanity check, verify that the document created in the previous block exists. + { + var app = FirebaseApp.Create(defaultOptions, "TestClearPersistenceApp"); + var db = FirebaseFirestore.GetInstance(app); + var doc = db.Document(path); + AssertTaskSucceeds(doc.GetSnapshotAsync(Source.Cache)); + app.Dispose(); + } + + // Call ClearPersistenceAsync() after TerminateAsync(). + { + var app = FirebaseApp.Create(defaultOptions, "TestClearPersistenceApp"); + var db = FirebaseFirestore.GetInstance(app); + AssertTaskSucceeds(db.TerminateAsync()); + AssertTaskSucceeds(db.ClearPersistenceAsync()); + app.Dispose(); + } + + // Verify that ClearPersistenceAsync() deleted the document that was created above. + { + var app = FirebaseApp.Create(defaultOptions, "TestClearPersistenceApp"); + var db = FirebaseFirestore.GetInstance(app); + var doc = db.Document(path); + AssertTaskFaults(doc.GetSnapshotAsync(Source.Cache), FirestoreError.Unavailable); + AssertTaskSucceeds(db.TerminateAsync()); + app.Dispose(); + } + + // Verify that ClearPersistenceAsync() fails if invoked after the first operation and + // before a call to TerminateAsync(). + { + var app = FirebaseApp.Create(defaultOptions, "TestClearPersistenceApp"); + var db = FirebaseFirestore.GetInstance(app); + Await(db.EnableNetworkAsync()); + AssertTaskFaults(db.ClearPersistenceAsync(), FirestoreError.FailedPrecondition); + AssertTaskSucceeds(db.TerminateAsync()); + app.Dispose(); + } + + }); + } + + Task TestDocumentReferenceTaskFailures() { + return Async(() => { + var docWithInvalidName = TestCollection().Document("__badpath__"); + var fieldPathData = new Dictionary{ { new FieldPath("key"), 42} }; + + { + Task task = docWithInvalidName.DeleteAsync(); + // TODO(b/193834769) Assert "__badpath__" is in the message once the message is fixed. + AssertTaskFaults(task, FirestoreError.InvalidArgument, "invalid"); + } + { + Task task = docWithInvalidName.UpdateAsync(TestData(0)); + // TODO(b/193834769) Assert "__badpath__" is in the message once the message is fixed. + AssertTaskFaults(task, FirestoreError.InvalidArgument, "invalid"); + } + { + Task task = docWithInvalidName.UpdateAsync("fieldName", 42); + // TODO(b/193834769) Assert "__badpath__" is in the message once the message is fixed. + AssertTaskFaults(task, FirestoreError.InvalidArgument, "invalid"); + } + { + Task task = docWithInvalidName.UpdateAsync(fieldPathData); + // TODO(b/193834769) Assert "__badpath__" is in the message once the message is fixed. + AssertTaskFaults(task, FirestoreError.InvalidArgument, "invalid"); + } + { + Task task = docWithInvalidName.SetAsync(TestData(), SetOptions.MergeAll); + // TODO(b/193834769) Assert "__badpath__" is in the message once the message is fixed. + AssertTaskFaults(task, FirestoreError.InvalidArgument, "invalid"); + } + { + Task task = docWithInvalidName.GetSnapshotAsync(); + AssertTaskFaults(task, FirestoreError.InvalidArgument, "__badpath__"); + } + { + Task task = docWithInvalidName.GetSnapshotAsync(Source.Default); + AssertTaskFaults(task, FirestoreError.InvalidArgument, "__badpath__"); + } + { + ListenerRegistration listenerRegistration = docWithInvalidName.Listen(snap => { }); + AssertTaskFaults(listenerRegistration.ListenerTask, FirestoreError.InvalidArgument, + "__badpath__"); + listenerRegistration.Stop(); + } + }); + } + + Task TestCollectionReferenceTaskFailures() { + return Async(() => { + var collectionWithInvalidName = TestCollection().Document("__badpath__").Collection("sub"); + { + Task task = collectionWithInvalidName.GetSnapshotAsync(); + AssertTaskFaults(task, FirestoreError.InvalidArgument, "__badpath__"); + } + { + Task task = collectionWithInvalidName.GetSnapshotAsync(Source.Default); + AssertTaskFaults(task, FirestoreError.InvalidArgument, "__badpath__"); + } + { + Task task = collectionWithInvalidName.AddAsync(TestData(0)); + // TODO(b/193834769) Assert "__badpath__" is in the message once the message is fixed. + AssertTaskFaults(task, FirestoreError.InvalidArgument, "invalid"); + } + { + ListenerRegistration listenerRegistration = collectionWithInvalidName.Listen(snap => { }); + AssertTaskFaults(listenerRegistration.ListenerTask, FirestoreError.InvalidArgument, + "__badpath__"); + listenerRegistration.Stop(); + } + { + ListenerRegistration listenerRegistration = collectionWithInvalidName.Listen( + MetadataChanges.Include, snap => { }); + // TODO(b/193834769) Assert "__badpath__" is in the message once the message is fixed. + AssertTaskFaults(listenerRegistration.ListenerTask, FirestoreError.InvalidArgument, + "invalid"); + listenerRegistration.Stop(); + } + }); + } + + // Performs a smoke test using a custom class with (nested) [DocumentId] and [ServerTimestamp] + // attributes. + Task TestObjectMappingSmokeTest() { + return Async(() => { + DocumentReference doc = TestDocument(); + var data = new SampleDataWithNestedDocumentId() { + OuterName = "outer", + Nested = new SampleDataWithDocumentId() { + Name = "name", + Value = 10 + }, + }; + + Await(doc.SetAsync(data)); + DocumentSnapshot snap = Await(doc.GetSnapshotAsync()); + + var result = snap.ConvertTo(); + AssertEq(result.OuterName, "outer"); + AssertEq(result.Nested.Name, "name"); + AssertEq(result.Nested.Value, 10); + AssertEq(result.Nested.DocumentId, doc.Id); + AssertEq(result.DocumentId, doc.Id); + + // Verify a valid timestamp (within 1hr of now) was written for the server timestamp. + TimeSpan duration = result.ServerTimestamp - DateTime.Now.ToUniversalTime(); + Assert("ServerTimestamp is within 1hr of now", Math.Abs(duration.TotalHours) < 1); + }); + } + + // Verify Firestore instances are singletons. + Task TestFirestoreSingleton() { + return Async(() => { + FirebaseFirestore db2 = FirebaseFirestore.DefaultInstance; + Assert("FirebaseFirestore.DefaultInstance returns a singleton", db == db2); + Assert("Query.Firestore returns the same instance", + db == db.Collection("a").WhereEqualTo("x", 1).Firestore); + Assert("DocumentReference.Firestore returns the same instance", + db == db.Document("a/b").Firestore); + }); + } + + Task TestFirestoreSettings() { + return Async(() => { + FirebaseFirestore db = FirebaseFirestore.DefaultInstance; + DocumentReference doc = db.Collection("coll").Document(); + var data = new Dictionary{ + {"f1", "v1"}, + }; + Await(doc.SetAsync(data)); + + // Verify it can get snapshot from cache, this is the behavior when + // persistence is set to true in settings, which is the default setting. + Await(doc.GetSnapshotAsync(Source.Cache)); + + // Terminate the current instance and create a new one (via DefaultInstance) such that + // we can apply a new FirebaseFirestoreSettings. + Await(db.TerminateAsync()); + db = FirebaseFirestore.DefaultInstance; + db.Settings = new FirebaseFirestoreSettings { PersistenceEnabled = false }; + + doc = db.Collection("coll").Document(); + Await(doc.SetAsync(data)); + + // Verify it cannot get snapshot from cache, this behavior only exists with memory + // persistence. + AssertException(typeof(Exception), () => Await(doc.GetSnapshotAsync(Source.Cache))); + + // Restart SDK again to test mutating existing settings. + Await(db.TerminateAsync()); + db = FirebaseFirestore.DefaultInstance; + db.Settings.PersistenceEnabled = false; + + doc = db.Collection("coll").Document(); + data = new Dictionary{ + {"f1", "v1"}, + }; + Await(doc.SetAsync(data)); + + // Verify it cannot get snapshot from cache, this behavior only exists with memory + // persistence. + AssertException(typeof(Exception), () => Await(doc.GetSnapshotAsync(Source.Cache))); + + Await(db.TerminateAsync()); + db = FirebaseFirestore.DefaultInstance; + long fiveMb = 5 * 1024 * 1024; + db.Settings = new FirebaseFirestoreSettings { CacheSizeBytes = fiveMb }; + AssertEq(db.Settings.CacheSizeBytes, fiveMb); + }); + } + + // Runs a bunch of serialization test cases (borrowed from google-cloud-dotnet). + // We first write the (custom) object to Firestore and verify that reading it back out as native + // C# types returns the correct value. Then we read it out again as the original (custom) object + // type and verify it equals the original input object. + Task TestObjectMapping() { + return Async(() => { + DocumentReference doc = TestDocument(); + bool cleanup = true; + + try { + Await(doc.Firestore.DisableNetworkAsync()); + + foreach (SerializationTestData.TestCase test in SerializationTestData.TestData( + doc.Firestore)) { + AssertEq(SerializationTestData.TestCase.TestOutcome.Success, test.Result); + var input = test.Input; + var expectedOutputWithRawFirestoreTypes = test.ExpectedRawOutput; + + object actualOutputWithRawFirestoreTypes, actualOutputWithInputTypes; + RoundtripValue(doc, input, out actualOutputWithRawFirestoreTypes, + out actualOutputWithInputTypes); + + // This logging can be handy for debugging. + // if (input != null) { + // DebugLog("input: " + input + " [" + input.GetType() + "]"); + // DebugLog("native types: " + actualOutputWithRawFirestoreTypes + " [" + + // actualOutputWithRawFirestoreTypes.GetType() + "]"); DebugLog("converted to original + // type: " + actualOutputWithInputTypes + " [" + actualOutputWithInputTypes.GetType() + // + "]"); + // } + + AssertDeepEq("Deserialized value with Firestore Raw types does not match expected", + actualOutputWithRawFirestoreTypes, expectedOutputWithRawFirestoreTypes); + AssertDeepEq("Deserialized value with input types does not match the input", + actualOutputWithInputTypes, input); + } + + } catch (ThreadAbortException) { + // Don't try to do anything else on this thread if it was aborted, or else it will hang. + cleanup = false; + + } finally { + if (cleanup) { + // TODO(mikelehen): Ideally we would use Terminate() or something to avoid actually + // writing all of our mutations (doesn't really matter, but it takes some time). + Await(doc.Firestore.EnableNetworkAsync()); + } + } + }); + } + + // Tests NotSupportedException is thrown for the type of object mapping + // we cannot support (yet). + Task TestNotSupportedObjectMapping() { + return Async(() => { + DocumentReference doc = TestDocument(); + bool cleanup = true; + + try { + Await(doc.Firestore.DisableNetworkAsync()); + + foreach (SerializationTestData.TestCase test in SerializationTestData + .UnsupportedTestData()) { + var input = test.Input; + var expectedWithFirestoreRawTypes = test.ExpectedRawOutput; + + object actualWithFirestoreRawTypes, actualWithInputTypes; + switch (test.Result) { + case SerializationTestData.TestCase.TestOutcome.Unsupported: + AssertException("When serializing: ", typeof(NotSupportedException), + () => SerializeToDoc(doc, input)); + + // Write the doc with expected output, then deserialize it back to input type. + SerializeToDoc(doc, expectedWithFirestoreRawTypes); + AssertException( + "When deserializing to input types: ", typeof(NotSupportedException), + () => { DeserializeWithInputTypes(doc, input, out actualWithInputTypes); }); + break; + case SerializationTestData.TestCase.TestOutcome.ReadToInputTypesNotSupported: + SerializeToDoc(doc, input); + + DeserializeWithRawFirestoreTypes(doc, out actualWithFirestoreRawTypes); + AssertDeepEq("Deserialized value with Firestore Raw types does not match expected", + actualWithFirestoreRawTypes, expectedWithFirestoreRawTypes); + + AssertException( + "When deserializing to input types: ", typeof(NotSupportedException), + () => { DeserializeWithInputTypes(doc, input, out actualWithInputTypes); }); + + break; + case SerializationTestData.TestCase.TestOutcome.Success: + throw new Exception( + "Expecting a failing outcome with the test case, got 'Success'"); + } + } + } catch (ThreadAbortException) { + // Don't try to do anything else on this thread if it was aborted, or else it will hang. + cleanup = false; + } finally { + if (cleanup) { + Await(doc.Firestore.EnableNetworkAsync()); + } + } + }); + } + + Task TestAssertTaskFaults() { + return Async(() => { + // Verify that AssertTaskFaults() passes if the Task faults with a FirestoreException with + // the expected error code. + { + var tcs = new TaskCompletionSource(); + tcs.SetException(new FirestoreException(FirestoreError.Unavailable)); + AssertTaskFaults(tcs.Task, FirestoreError.Unavailable); + } + + // Verify that AssertTaskFaults() fails if the Task faults with an AggregateException that, + // when flattened, resolves to a FirestoreException with the expected error code. + { + var tcs = new TaskCompletionSource(); + var firestoreException = new FirestoreException(FirestoreError.Unavailable); + var aggregateException1 = new AggregateException(new[] { firestoreException }); + var aggregateException2 = new AggregateException(new[] { aggregateException1 }); + tcs.SetException(aggregateException2); + Exception thrownException = null; + try { + AssertTaskFaults(tcs.Task, FirestoreError.Unavailable); + } catch (Exception e) { + thrownException = e; + } + if (thrownException == null) { + throw new Exception( + "AssertTaskFaults() should have thrown an exception because the AggregateException" + + "has multiple nested AggregateException instances."); + } + } + + // Verify that AssertTaskFaults() fails if the Task faults with a FirestoreException with + // an unexpected error code. + { + var tcs = new TaskCompletionSource(); + tcs.SetResult(new FirestoreException(FirestoreError.Unavailable)); + Exception thrownException = null; + try { + AssertTaskFaults(tcs.Task, FirestoreError.Ok); + } catch (Exception e) { + thrownException = e; + } + if (thrownException == null) { + throw new Exception( + "AssertTaskFaults() should have thrown an exception because the task faulted " + + "with an incorrect error code."); + } + } + + // Verify that AssertTaskFaults() fails if the Task completes successfully. + { + var tcs = new TaskCompletionSource(); + tcs.SetResult(null); + Exception thrownException = null; + try { + AssertTaskFaults(tcs.Task, FirestoreError.Ok); + } catch (Exception e) { + thrownException = e; + } + if (thrownException == null) { + throw new Exception( + "AssertTaskFaults() should have thrown an exception because the task completed " + + "successfully."); + } + } + + // Verify that AssertTaskFaults() fails if the Task fails with an exception other than + // FirestoreException. + { + var tcs = new TaskCompletionSource(); + tcs.SetException(new InvalidOperationException()); + Exception thrownException = null; + try { + AssertTaskFaults(tcs.Task, FirestoreError.Ok); + } catch (Exception e) { + thrownException = e; + } + if (thrownException == null) { + throw new Exception( + "AssertTaskFaults() should have thrown an exception because the task faulted " + + "with an incorrect exception type."); + } + } + + // Verify that AssertTaskFaults() fails if the Task fails with an AggregateException + // that, when flattened, resolves to an unexpected exception. + { + var tcs = new TaskCompletionSource(); + var exception1 = new InvalidOperationException(); + var exception2 = new AggregateException(new[] { exception1 }); + var exception3 = new AggregateException(new[] { exception2 }); + tcs.SetException(exception3); + Exception thrownException = null; + try { + AssertTaskFaults(tcs.Task, FirestoreError.Ok); + } catch (Exception e) { + thrownException = e; + } + if (thrownException == null) { + throw new Exception( + "AssertTaskFaults() should have thrown an exception because the task faulted " + + "with an AggregateException that flattened to an unexpected exception."); + } + } + + // Verify that AssertTaskFaults() fails if the Task fails with an AggregateException that + // has more than one InnerException. + { + var tcs = new TaskCompletionSource(); + var exception1 = new InvalidOperationException(); + var exception2 = new InvalidOperationException(); + var exception3 = new AggregateException(new[] { exception1, exception2 }); + tcs.SetException(exception3); + Exception thrownException = null; + try { + AssertTaskFaults(tcs.Task, FirestoreError.Ok); + } catch (Exception e) { + thrownException = e; + } + if (thrownException == null) { + throw new Exception( + "AssertTaskFaults() should have thrown an exception because the task faulted " + + "with an AggregateException that could not be fully flattened."); + } + } + + // Verify that AssertTaskFaults() fails if the Task faults with a FirestoreException with + // no message but a regular expression for the message is specified. + { + var tcs = new TaskCompletionSource(); + tcs.SetException(new FirestoreException(FirestoreError.Ok)); + Exception thrownException = null; + try { + AssertTaskFaults(tcs.Task, FirestoreError.Ok, "SomeMessageRegex"); + } catch (Exception e) { + thrownException = e; + } + if (thrownException == null) { + throw new Exception( + "AssertTaskFaults() should have thrown an exception because the task faulted " + + "with an exception that does not have a message."); + } else if (!thrownException.Message.Contains("SomeMessageRegex")) { + throw new Exception( + "AssertTaskFaults() threw an exception (as expected); however, its message was " + + "incorrect: " + thrownException.Message); + } + } + + // Verify that AssertTaskFaults() fails if the Task faults with a FirestoreException with + // a message that does not match the given regular expression. + { + var tcs = new TaskCompletionSource(); + tcs.SetException(new FirestoreException(FirestoreError.Ok, "TheActualMessage")); + Exception thrownException = null; + try { + AssertTaskFaults(tcs.Task, FirestoreError.Ok, "The.*MeaningOfLife"); + } catch (Exception e) { + thrownException = e; + } + if (thrownException == null) { + throw new Exception( + "AssertTaskFaults() should have thrown an exception because the task faulted " + + "with an exception that does not have a message."); + } else if (!(thrownException.Message.Contains("TheActualMessage") && + thrownException.Message.Contains("The.*MeaningOfLife"))) { + throw new Exception( + "AssertTaskFaults() threw an exception (as expected); however, its message was " + + "incorrect: " + thrownException.Message); + } + } + + // Verify that AssertTaskFaults() passes if the Task faults with a FirestoreException with + // a message that matches the given regular expression. + { + var tcs = new TaskCompletionSource(); + tcs.SetException(new FirestoreException(FirestoreError.Ok, "TheActualMessage")); + AssertTaskFaults(tcs.Task, FirestoreError.Ok, "The.*Message"); + } + }); + } + + // Intentionally misuse the API to trigger internal assertions and make sure they are thrown as + // C# exceptions of the expected type. + Task TestInternalExceptions() { + return Async(() => { + Exception exception = null; + + // Invalid argument. + try { + var db1 = FirebaseFirestore.DefaultInstance; + var db2 = NonDefaultFirestore("InvalidArgument"); + + var batch = db1.StartBatch(); + var doc = db2.Collection("foo").Document("bar"); + batch.Delete(doc); + + } catch (Exception e) { + exception = e; + + } finally { + Assert("Expected an exception to be thrown", exception != null); + Assert("Expected an ArgumentException, but received " + + exception, exception is ArgumentException); + } + + // Illegal state. + exception = null; + try { + var db = NonDefaultFirestore("IllegalState"); + db.Settings = new FirebaseFirestoreSettings{SslEnabled = false}; + // Make sure the Firestore client is initialized. + db.Collection("foo").Document("bar"); + + } catch (Exception e) { + exception = e; + + } finally { + Assert("Expected an exception to be thrown", exception != null); + Assert("Expected an InvalidOperationException, but received " + + exception, exception is InvalidOperationException); + } + + // Exception in an async method. + exception = null; + + { + var db1 = FirebaseFirestore.DefaultInstance; + var db2 = NonDefaultFirestore("InternalAssertion"); + + DocumentReference doc1 = db1.Collection("foo").Document("bar"); + DocumentReference doc2 = db2.Collection("x").Document("y"); + var data = new Dictionary{ + {"f1", doc2}, + }; + exception = AssertTaskFaults(doc1.SetAsync(data)); + + Assert("Expected an exception to be thrown", exception != null); + Assert("Expected an ArgumentException, but received " + + exception, exception is ArgumentException); + } + }); + } + + Task TestListenerRegistrationDispose() { + return Async(() => { + var doc = TestDocument(); + var initialData = TestData(1); + AssertTaskSucceeds(doc.SetAsync(initialData)); + var registration = doc.Listen((snap) => { }); + AssertTaskIsPending(registration.ListenerTask); + registration.Dispose(); + // The task should have transitioned to TaskStatus.RanToCompletion after + // Dispose() is called on ListenerRegistration. + AssertTaskSucceeds(registration.ListenerTask); + + // The callback should not be called after Dispose() is called on + // ListenerRegistration. + var doc2 = TestDocument(); + var callbackInvoked = false; + var registration2 = doc2.Listen(snap => { callbackInvoked = true; }); + registration2.Dispose(); + Await(doc2.SetAsync(initialData)); + System.Threading.Thread.Sleep(50); + Assert("The callback should not have been invoked", !callbackInvoked); + }); + } + + private void RoundtripValue(DocumentReference doc, object input, out object nativeOutput, out object convertedOutput) { + SerializeToDoc(doc, input); + + DeserializeWithRawFirestoreTypes(doc, out nativeOutput); + + DeserializeWithInputTypes(doc, input, out convertedOutput); + } + + private void SerializeToDoc(DocumentReference doc, object input) { + // Wrap in a dictionary so we can write it as a document even if input is a primitive type. + var docData = new Dictionary { { "field", input } }; + + // Write doc and read the field back out as native types. + doc.SetAsync(docData); + } + + private void DeserializeWithRawFirestoreTypes(DocumentReference doc, out object rawOutput) { + var docSnap = Await(doc.GetSnapshotAsync(Source.Cache)); + rawOutput = docSnap.GetValue("field"); + } + + private void DeserializeWithInputTypes(DocumentReference doc, object input, + out object outputWithInputTypes) { + var docSnap = Await(doc.GetSnapshotAsync(Source.Cache)); + // To get the converted value out, we have to use reflection to call GetValue<> with + // input.GetType() as the generic parameter. + MethodInfo method = typeof(DocumentSnapshot).GetMethod("GetValue", new Type[] { typeof(string), typeof(ServerTimestampBehavior) }); + MethodInfo genericMethod = method.MakeGenericMethod(input != null ? input.GetType() : typeof(object)); + outputWithInputTypes = + genericMethod.Invoke(docSnap, new object[] { "field", ServerTimestampBehavior.None }); + } + + // Unity on iOS can't JIT compile code, which breaks some usages of + // reflection such as the way RoundtripValue() calls the + // DocumentSnapshot.GetValue<>() method with dynamic generic types. As a + // workaround, we have to enumerate all the different versions that we need. + // Normal users won't have to do this. + // See https://docs.unity3d.com/Manual/ScriptingRestrictions.html for more details. + private void UnityCompileHack() { + // NOTE: This never actually runs. It just forces the compiler to generate + // the code we need. + DocumentSnapshot x = null; + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue>(""); + } + + private void AssertQueryResults(string desc, Query query, List docIds) { + var snapshot = Await(query.GetSnapshotAsync()); + + AssertEq(desc + ": Query result count", snapshot.Count, docIds.Count); + for (int i = 0; i < snapshot.Count; i++) { + AssertEq(desc + ": Document ID " + i, docIds[i], snapshot[i].Id); + } + } + + private FirebaseFirestore NonDefaultFirestore(string appName) { + var appOptions = new AppOptions(); + // Setting a ProjectId is required (b/158838266). + appOptions.ProjectId = appName; + var app = FirebaseApp.Create(appOptions, appName); + return FirebaseFirestore.GetInstance(app); + } + + /// Wraps IEnumerator in an exception handling Task. + Task ToTask(IEnumerator ienum) { + TaskCompletionSource tcs = new TaskCompletionSource(); + mainThreadDispatcher.RunOnMainThread(() => { + StartThrowingCoroutine(ienum, ex => { + if (ex == null) { + if (previousTask.IsFaulted) { + tcs.TrySetException(previousTask.Exception); + } else if (previousTask.IsCanceled) { + tcs.TrySetCanceled(); + } else { + tcs.TrySetResult(true); + } + } else { + tcs.TrySetException(ex); + } + }); + }); + return tcs.Task; + } + + /// Start a coroutine that might throw an exception. Call the callback with the exception if it + /// does or null if it finishes without throwing an exception. + public Coroutine StartThrowingCoroutine(IEnumerator enumerator, Action done) { + return StartCoroutine(RunThrowingIterator(enumerator, done)); + } + + /// Run an iterator function that might throw an exception. Call the callback with the exception + /// if it does or null if it finishes without throwing an exception. + public static IEnumerator RunThrowingIterator(IEnumerator enumerator, Action done) { + while (true) { + object current; + try { + if (enumerator.MoveNext() == false) { + break; + } + current = enumerator.Current; + } catch (Exception ex) { + done(ex); + yield break; + } + yield return current; + } + done(null); + } + + [FirestoreData] + private class SampleDataWithDocumentId { + [FirestoreDocumentId] + public string DocumentId { get; set; } + + [FirestoreProperty] + public string Name { get; set; } + + [FirestoreProperty] + public int Value { get; set; } + } + + [FirestoreData] + private class SampleDataWithNestedDocumentId { + [FirestoreDocumentId] + public string DocumentId { get; set; } + + [FirestoreProperty] + public string OuterName { get; set; } + + [FirestoreProperty] + public SampleDataWithDocumentId Nested { get; set; } + + [FirestoreProperty] + [ServerTimestamp] + public DateTime ServerTimestamp { get; set; } + } + } +} diff --git a/firestore/testapp/Assets/Firebase/Sample/Firestore/UIHandlerAutomated.cs.meta b/firestore/testapp/Assets/Firebase/Sample/Firestore/UIHandlerAutomated.cs.meta new file mode 100644 index 000000000..3de9ea5ed --- /dev/null +++ b/firestore/testapp/Assets/Firebase/Sample/Firestore/UIHandlerAutomated.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 861f3c4bb5ca00c4e80208e581d262ca +timeCreated: 1534896493 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/firestore/testapp/Assets/Firebase/Sample/GuiSkin.guiskin b/firestore/testapp/Assets/Firebase/Sample/GuiSkin.guiskin new file mode 100644 index 000000000..cdde0ea99 --- /dev/null +++ b/firestore/testapp/Assets/Firebase/Sample/GuiSkin.guiskin @@ -0,0 +1,1427 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 1 + m_Script: {fileID: 12001, guid: 0000000000000000e000000000000000, type: 0} + m_Name: GuiSkin + m_EditorClassIdentifier: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_box: + m_Name: box + m_Normal: + m_Background: {fileID: 11001, guid: 0000000000000000e000000000000000, type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0.79999995, g: 0.79999995, b: 0.79999995, a: 1} + m_Hover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Active: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Focused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnNormal: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnHover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnActive: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnFocused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Border: + m_Left: 6 + m_Right: 6 + m_Top: 6 + m_Bottom: 6 + m_Margin: + m_Left: 4 + m_Right: 4 + m_Top: 4 + m_Bottom: 4 + m_Padding: + m_Left: 4 + m_Right: 4 + m_Top: 4 + m_Bottom: 4 + m_Overflow: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Font: {fileID: 0} + m_FontSize: 0 + m_FontStyle: 0 + m_Alignment: 1 + m_WordWrap: 0 + m_RichText: 1 + m_TextClipping: 1 + m_ImagePosition: 0 + m_ContentOffset: {x: 0, y: 0} + m_FixedWidth: 0 + m_FixedHeight: 0 + m_StretchWidth: 1 + m_StretchHeight: 0 + m_button: + m_Name: button + m_Normal: + m_Background: {fileID: 11006, guid: 0000000000000000e000000000000000, type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0.9, g: 0.9, b: 0.9, a: 1} + m_Hover: + m_Background: {fileID: 11003, guid: 0000000000000000e000000000000000, type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 1, g: 1, b: 1, a: 1} + m_Active: + m_Background: {fileID: 11002, guid: 0000000000000000e000000000000000, type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0.9, g: 0.9, b: 0.9, a: 1} + m_Focused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 1, g: 1, b: 1, a: 1} + m_OnNormal: + m_Background: {fileID: 11005, guid: 0000000000000000e000000000000000, type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0.9019608, g: 0.9019608, b: 0.9019608, a: 1} + m_OnHover: + m_Background: {fileID: 11004, guid: 0000000000000000e000000000000000, type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 1, g: 1, b: 1, a: 1} + m_OnActive: + m_Background: {fileID: 11002, guid: 0000000000000000e000000000000000, type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0.9, g: 0.9, b: 0.9, a: 1} + m_OnFocused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Border: + m_Left: 6 + m_Right: 6 + m_Top: 6 + m_Bottom: 4 + m_Margin: + m_Left: 15 + m_Right: 15 + m_Top: 15 + m_Bottom: 15 + m_Padding: + m_Left: 6 + m_Right: 6 + m_Top: 30 + m_Bottom: 30 + m_Overflow: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Font: {fileID: 0} + m_FontSize: 45 + m_FontStyle: 0 + m_Alignment: 4 + m_WordWrap: 0 + m_RichText: 1 + m_TextClipping: 1 + m_ImagePosition: 0 + m_ContentOffset: {x: 0, y: 0} + m_FixedWidth: 0 + m_FixedHeight: 0 + m_StretchWidth: 1 + m_StretchHeight: 0 + m_toggle: + m_Name: toggle + m_Normal: + m_Background: {fileID: 11018, guid: 0000000000000000e000000000000000, type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0.89112896, g: 0.89112896, b: 0.89112896, a: 1} + m_Hover: + m_Background: {fileID: 11014, guid: 0000000000000000e000000000000000, type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 1, g: 1, b: 1, a: 1} + m_Active: + m_Background: {fileID: 11013, guid: 0000000000000000e000000000000000, type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 1, g: 1, b: 1, a: 1} + m_Focused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnNormal: + m_Background: {fileID: 11016, guid: 0000000000000000e000000000000000, type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0.8901961, g: 0.8901961, b: 0.8901961, a: 1} + m_OnHover: + m_Background: {fileID: 11015, guid: 0000000000000000e000000000000000, type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 1, g: 1, b: 1, a: 1} + m_OnActive: + m_Background: {fileID: 11017, guid: 0000000000000000e000000000000000, type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 1, g: 1, b: 1, a: 1} + m_OnFocused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Border: + m_Left: 14 + m_Right: 0 + m_Top: 14 + m_Bottom: 0 + m_Margin: + m_Left: 4 + m_Right: 4 + m_Top: 4 + m_Bottom: 4 + m_Padding: + m_Left: 15 + m_Right: 0 + m_Top: 3 + m_Bottom: 0 + m_Overflow: + m_Left: -1 + m_Right: 0 + m_Top: -4 + m_Bottom: 0 + m_Font: {fileID: 0} + m_FontSize: 0 + m_FontStyle: 0 + m_Alignment: 0 + m_WordWrap: 0 + m_RichText: 1 + m_TextClipping: 1 + m_ImagePosition: 0 + m_ContentOffset: {x: 0, y: 0} + m_FixedWidth: 0 + m_FixedHeight: 0 + m_StretchWidth: 1 + m_StretchHeight: 0 + m_label: + m_Name: label + m_Normal: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Hover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Active: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Focused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnNormal: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnHover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnActive: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnFocused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Border: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Margin: + m_Left: 4 + m_Right: 4 + m_Top: 4 + m_Bottom: 4 + m_Padding: + m_Left: 0 + m_Right: 0 + m_Top: 3 + m_Bottom: 3 + m_Overflow: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Font: {fileID: 0} + m_FontSize: 45 + m_FontStyle: 0 + m_Alignment: 0 + m_WordWrap: 1 + m_RichText: 1 + m_TextClipping: 1 + m_ImagePosition: 0 + m_ContentOffset: {x: 0, y: 0} + m_FixedWidth: 0 + m_FixedHeight: 0 + m_StretchWidth: 1 + m_StretchHeight: 0 + m_textField: + m_Name: textfield + m_Normal: + m_Background: {fileID: 11024, guid: 0000000000000000e000000000000000, type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0.79999995, g: 0.79999995, b: 0.79999995, a: 1} + m_Hover: + m_Background: {fileID: 11026, guid: 0000000000000000e000000000000000, type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0.9, g: 0.9, b: 0.9, a: 1} + m_Active: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Focused: + m_Background: {fileID: 11026, guid: 0000000000000000e000000000000000, type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 1, g: 1, b: 1, a: 1} + m_OnNormal: + m_Background: {fileID: 11025, guid: 0000000000000000e000000000000000, type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 1, g: 1, b: 1, a: 1} + m_OnHover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnActive: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnFocused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Border: + m_Left: 4 + m_Right: 4 + m_Top: 4 + m_Bottom: 4 + m_Margin: + m_Left: 3 + m_Right: 3 + m_Top: 3 + m_Bottom: 3 + m_Padding: + m_Left: 10 + m_Right: 10 + m_Top: 10 + m_Bottom: 10 + m_Overflow: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Font: {fileID: 0} + m_FontSize: 60 + m_FontStyle: 0 + m_Alignment: 0 + m_WordWrap: 0 + m_RichText: 0 + m_TextClipping: 1 + m_ImagePosition: 3 + m_ContentOffset: {x: 0, y: 0} + m_FixedWidth: 0 + m_FixedHeight: 0 + m_StretchWidth: 1 + m_StretchHeight: 0 + m_textArea: + m_Name: textarea + m_Normal: + m_Background: {fileID: 11024, guid: 0000000000000000e000000000000000, type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0.9019608, g: 0.9019608, b: 0.9019608, a: 1} + m_Hover: + m_Background: {fileID: 11026, guid: 0000000000000000e000000000000000, type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0.79999995, g: 0.79999995, b: 0.79999995, a: 1} + m_Active: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Focused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnNormal: + m_Background: {fileID: 11025, guid: 0000000000000000e000000000000000, type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 1, g: 1, b: 1, a: 1} + m_OnHover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnActive: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnFocused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Border: + m_Left: 4 + m_Right: 4 + m_Top: 4 + m_Bottom: 4 + m_Margin: + m_Left: 4 + m_Right: 4 + m_Top: 4 + m_Bottom: 4 + m_Padding: + m_Left: 3 + m_Right: 3 + m_Top: 3 + m_Bottom: 3 + m_Overflow: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Font: {fileID: 0} + m_FontSize: 0 + m_FontStyle: 0 + m_Alignment: 0 + m_WordWrap: 1 + m_RichText: 0 + m_TextClipping: 1 + m_ImagePosition: 0 + m_ContentOffset: {x: 0, y: 0} + m_FixedWidth: 0 + m_FixedHeight: 0 + m_StretchWidth: 1 + m_StretchHeight: 0 + m_window: + m_Name: window + m_Normal: + m_Background: {fileID: 11023, guid: 0000000000000000e000000000000000, type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 1, g: 1, b: 1, a: 1} + m_Hover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Active: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Focused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnNormal: + m_Background: {fileID: 11022, guid: 0000000000000000e000000000000000, type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 1, g: 1, b: 1, a: 1} + m_OnHover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnActive: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnFocused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Border: + m_Left: 8 + m_Right: 8 + m_Top: 18 + m_Bottom: 8 + m_Margin: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Padding: + m_Left: 10 + m_Right: 10 + m_Top: 20 + m_Bottom: 10 + m_Overflow: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Font: {fileID: 0} + m_FontSize: 0 + m_FontStyle: 0 + m_Alignment: 1 + m_WordWrap: 0 + m_RichText: 1 + m_TextClipping: 1 + m_ImagePosition: 0 + m_ContentOffset: {x: 0, y: -18} + m_FixedWidth: 0 + m_FixedHeight: 0 + m_StretchWidth: 1 + m_StretchHeight: 0 + m_horizontalSlider: + m_Name: horizontalslider + m_Normal: + m_Background: {fileID: 11009, guid: 0000000000000000e000000000000000, type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Hover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Active: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Focused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnNormal: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnHover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnActive: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnFocused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Border: + m_Left: 3 + m_Right: 3 + m_Top: 0 + m_Bottom: 0 + m_Margin: + m_Left: 4 + m_Right: 4 + m_Top: 4 + m_Bottom: 4 + m_Padding: + m_Left: -1 + m_Right: -1 + m_Top: 0 + m_Bottom: 0 + m_Overflow: + m_Left: 0 + m_Right: 0 + m_Top: -2 + m_Bottom: -3 + m_Font: {fileID: 0} + m_FontSize: 0 + m_FontStyle: 0 + m_Alignment: 0 + m_WordWrap: 0 + m_RichText: 1 + m_TextClipping: 1 + m_ImagePosition: 2 + m_ContentOffset: {x: 0, y: 0} + m_FixedWidth: 0 + m_FixedHeight: 12 + m_StretchWidth: 1 + m_StretchHeight: 0 + m_horizontalSliderThumb: + m_Name: horizontalsliderthumb + m_Normal: + m_Background: {fileID: 11011, guid: 0000000000000000e000000000000000, type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Hover: + m_Background: {fileID: 11012, guid: 0000000000000000e000000000000000, type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Active: + m_Background: {fileID: 11010, guid: 0000000000000000e000000000000000, type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Focused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnNormal: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnHover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnActive: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnFocused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Border: + m_Left: 4 + m_Right: 4 + m_Top: 0 + m_Bottom: 0 + m_Margin: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Padding: + m_Left: 7 + m_Right: 7 + m_Top: 0 + m_Bottom: 0 + m_Overflow: + m_Left: -1 + m_Right: -1 + m_Top: 0 + m_Bottom: 0 + m_Font: {fileID: 0} + m_FontSize: 0 + m_FontStyle: 0 + m_Alignment: 0 + m_WordWrap: 0 + m_RichText: 1 + m_TextClipping: 1 + m_ImagePosition: 2 + m_ContentOffset: {x: 0, y: 0} + m_FixedWidth: 0 + m_FixedHeight: 12 + m_StretchWidth: 1 + m_StretchHeight: 0 + m_verticalSlider: + m_Name: verticalslider + m_Normal: + m_Background: {fileID: 11021, guid: 0000000000000000e000000000000000, type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Hover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Active: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Focused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnNormal: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnHover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnActive: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnFocused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Border: + m_Left: 0 + m_Right: 0 + m_Top: 3 + m_Bottom: 3 + m_Margin: + m_Left: 4 + m_Right: 4 + m_Top: 4 + m_Bottom: 4 + m_Padding: + m_Left: 0 + m_Right: 0 + m_Top: -1 + m_Bottom: -1 + m_Overflow: + m_Left: -2 + m_Right: -3 + m_Top: 0 + m_Bottom: 0 + m_Font: {fileID: 0} + m_FontSize: 0 + m_FontStyle: 0 + m_Alignment: 0 + m_WordWrap: 0 + m_RichText: 1 + m_TextClipping: 0 + m_ImagePosition: 0 + m_ContentOffset: {x: 0, y: 0} + m_FixedWidth: 12 + m_FixedHeight: 0 + m_StretchWidth: 0 + m_StretchHeight: 1 + m_verticalSliderThumb: + m_Name: verticalsliderthumb + m_Normal: + m_Background: {fileID: 11011, guid: 0000000000000000e000000000000000, type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Hover: + m_Background: {fileID: 11012, guid: 0000000000000000e000000000000000, type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Active: + m_Background: {fileID: 11010, guid: 0000000000000000e000000000000000, type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Focused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnNormal: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnHover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnActive: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnFocused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Border: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Margin: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Padding: + m_Left: 0 + m_Right: 0 + m_Top: 7 + m_Bottom: 7 + m_Overflow: + m_Left: 0 + m_Right: 0 + m_Top: -1 + m_Bottom: -1 + m_Font: {fileID: 0} + m_FontSize: 0 + m_FontStyle: 0 + m_Alignment: 0 + m_WordWrap: 0 + m_RichText: 1 + m_TextClipping: 1 + m_ImagePosition: 0 + m_ContentOffset: {x: 0, y: 0} + m_FixedWidth: 12 + m_FixedHeight: 0 + m_StretchWidth: 0 + m_StretchHeight: 1 + m_horizontalScrollbar: + m_Name: horizontalscrollbar + m_Normal: + m_Background: {fileID: 11008, guid: 0000000000000000e000000000000000, type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Hover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Active: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Focused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnNormal: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnHover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnActive: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnFocused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Border: + m_Left: 9 + m_Right: 9 + m_Top: 0 + m_Bottom: 0 + m_Margin: + m_Left: 4 + m_Right: 4 + m_Top: 1 + m_Bottom: 4 + m_Padding: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Overflow: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Font: {fileID: 0} + m_FontSize: 0 + m_FontStyle: 0 + m_Alignment: 0 + m_WordWrap: 0 + m_RichText: 1 + m_TextClipping: 1 + m_ImagePosition: 2 + m_ContentOffset: {x: 0, y: 0} + m_FixedWidth: 0 + m_FixedHeight: 60 + m_StretchWidth: 1 + m_StretchHeight: 0 + m_horizontalScrollbarThumb: + m_Name: horizontalscrollbarthumb + m_Normal: + m_Background: {fileID: 11007, guid: 0000000000000000e000000000000000, type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Hover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Active: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Focused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnNormal: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnHover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnActive: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnFocused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Border: + m_Left: 6 + m_Right: 6 + m_Top: 6 + m_Bottom: 6 + m_Margin: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Padding: + m_Left: 6 + m_Right: 6 + m_Top: 0 + m_Bottom: 0 + m_Overflow: + m_Left: 0 + m_Right: 0 + m_Top: -1 + m_Bottom: 1 + m_Font: {fileID: 0} + m_FontSize: 0 + m_FontStyle: 0 + m_Alignment: 0 + m_WordWrap: 0 + m_RichText: 1 + m_TextClipping: 1 + m_ImagePosition: 0 + m_ContentOffset: {x: 0, y: 0} + m_FixedWidth: 0 + m_FixedHeight: 0 + m_StretchWidth: 1 + m_StretchHeight: 0 + m_horizontalScrollbarLeftButton: + m_Name: horizontalscrollbarleftbutton + m_Normal: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Hover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Active: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Focused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnNormal: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnHover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnActive: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnFocused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Border: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Margin: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Padding: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Overflow: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Font: {fileID: 0} + m_FontSize: 0 + m_FontStyle: 0 + m_Alignment: 0 + m_WordWrap: 0 + m_RichText: 1 + m_TextClipping: 1 + m_ImagePosition: 0 + m_ContentOffset: {x: 0, y: 0} + m_FixedWidth: 0 + m_FixedHeight: 0 + m_StretchWidth: 1 + m_StretchHeight: 0 + m_horizontalScrollbarRightButton: + m_Name: horizontalscrollbarrightbutton + m_Normal: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Hover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Active: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Focused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnNormal: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnHover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnActive: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnFocused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Border: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Margin: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Padding: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Overflow: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Font: {fileID: 0} + m_FontSize: 0 + m_FontStyle: 0 + m_Alignment: 0 + m_WordWrap: 0 + m_RichText: 1 + m_TextClipping: 1 + m_ImagePosition: 0 + m_ContentOffset: {x: 0, y: 0} + m_FixedWidth: 0 + m_FixedHeight: 0 + m_StretchWidth: 1 + m_StretchHeight: 0 + m_verticalScrollbar: + m_Name: verticalscrollbar + m_Normal: + m_Background: {fileID: 11020, guid: 0000000000000000e000000000000000, type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Hover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Active: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Focused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnNormal: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnHover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnActive: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnFocused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Border: + m_Left: 0 + m_Right: 0 + m_Top: 9 + m_Bottom: 9 + m_Margin: + m_Left: 1 + m_Right: 4 + m_Top: 4 + m_Bottom: 4 + m_Padding: + m_Left: 0 + m_Right: 0 + m_Top: 1 + m_Bottom: 1 + m_Overflow: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Font: {fileID: 0} + m_FontSize: 0 + m_FontStyle: 0 + m_Alignment: 0 + m_WordWrap: 0 + m_RichText: 1 + m_TextClipping: 1 + m_ImagePosition: 0 + m_ContentOffset: {x: 0, y: 0} + m_FixedWidth: 60 + m_FixedHeight: 0 + m_StretchWidth: 1 + m_StretchHeight: 0 + m_verticalScrollbarThumb: + m_Name: verticalscrollbarthumb + m_Normal: + m_Background: {fileID: 11019, guid: 0000000000000000e000000000000000, type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Hover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Active: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Focused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnNormal: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnHover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnActive: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnFocused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Border: + m_Left: 6 + m_Right: 6 + m_Top: 6 + m_Bottom: 6 + m_Margin: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Padding: + m_Left: 0 + m_Right: 0 + m_Top: 6 + m_Bottom: 6 + m_Overflow: + m_Left: -1 + m_Right: -1 + m_Top: 0 + m_Bottom: 0 + m_Font: {fileID: 0} + m_FontSize: 0 + m_FontStyle: 0 + m_Alignment: 0 + m_WordWrap: 0 + m_RichText: 1 + m_TextClipping: 1 + m_ImagePosition: 2 + m_ContentOffset: {x: 0, y: 0} + m_FixedWidth: 0 + m_FixedHeight: 0 + m_StretchWidth: 0 + m_StretchHeight: 1 + m_verticalScrollbarUpButton: + m_Name: verticalscrollbarupbutton + m_Normal: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Hover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Active: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Focused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnNormal: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnHover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnActive: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnFocused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Border: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Margin: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Padding: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Overflow: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Font: {fileID: 0} + m_FontSize: 0 + m_FontStyle: 0 + m_Alignment: 0 + m_WordWrap: 0 + m_RichText: 1 + m_TextClipping: 1 + m_ImagePosition: 0 + m_ContentOffset: {x: 0, y: 0} + m_FixedWidth: 0 + m_FixedHeight: 0 + m_StretchWidth: 1 + m_StretchHeight: 0 + m_verticalScrollbarDownButton: + m_Name: verticalscrollbardownbutton + m_Normal: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Hover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Active: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Focused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnNormal: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnHover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnActive: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnFocused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Border: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Margin: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Padding: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Overflow: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Font: {fileID: 0} + m_FontSize: 0 + m_FontStyle: 0 + m_Alignment: 0 + m_WordWrap: 0 + m_RichText: 1 + m_TextClipping: 1 + m_ImagePosition: 0 + m_ContentOffset: {x: 0, y: 0} + m_FixedWidth: 0 + m_FixedHeight: 0 + m_StretchWidth: 1 + m_StretchHeight: 0 + m_ScrollView: + m_Name: scrollview + m_Normal: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Hover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Active: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Focused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnNormal: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnHover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnActive: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnFocused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Border: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Margin: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Padding: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Overflow: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Font: {fileID: 0} + m_FontSize: 0 + m_FontStyle: 0 + m_Alignment: 0 + m_WordWrap: 0 + m_RichText: 1 + m_TextClipping: 1 + m_ImagePosition: 0 + m_ContentOffset: {x: 0, y: 0} + m_FixedWidth: 0 + m_FixedHeight: 0 + m_StretchWidth: 1 + m_StretchHeight: 0 + m_CustomStyles: + - m_Name: + m_Normal: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Hover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Active: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Focused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnNormal: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnHover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnActive: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnFocused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Border: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Margin: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Padding: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Overflow: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Font: {fileID: 0} + m_FontSize: 0 + m_FontStyle: 0 + m_Alignment: 0 + m_WordWrap: 0 + m_RichText: 1 + m_TextClipping: 0 + m_ImagePosition: 0 + m_ContentOffset: {x: 0, y: 0} + m_FixedWidth: 0 + m_FixedHeight: 0 + m_StretchWidth: 1 + m_StretchHeight: 0 + m_Settings: + m_DoubleClickSelectsWord: 1 + m_TripleClickSelectsLine: 1 + m_CursorColor: {r: 1, g: 1, b: 1, a: 1} + m_CursorFlashSpeed: -1 + m_SelectionColor: {r: 1, g: 0.38403907, b: 0, a: 0.7} diff --git a/firestore/testapp/Assets/Firebase/Sample/GuiSkin.guiskin.meta b/firestore/testapp/Assets/Firebase/Sample/GuiSkin.guiskin.meta new file mode 100644 index 000000000..520fae49d --- /dev/null +++ b/firestore/testapp/Assets/Firebase/Sample/GuiSkin.guiskin.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 14ab14e9b97f743dca62b51e1e369f07 +timeCreated: 1474935020 +licenseType: Pro +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/firestore/testapp/Assets/Plugins/Android/GameLoops.meta b/firestore/testapp/Assets/Plugins/Android/GameLoops.meta new file mode 100644 index 000000000..a81d8abaa --- /dev/null +++ b/firestore/testapp/Assets/Plugins/Android/GameLoops.meta @@ -0,0 +1,32 @@ +fileFormatVersion: 2 +guid: 8f32c13350abd4d54b16945b3e7e7353 +folderAsset: yes +timeCreated: 1563316955 +licenseType: Pro +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + Android: Android + second: + enabled: 1 + settings: {} + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/firestore/testapp/Assets/Plugins/Android/GameLoops/AndroidManifest.xml b/firestore/testapp/Assets/Plugins/Android/GameLoops/AndroidManifest.xml new file mode 100644 index 000000000..208d18614 --- /dev/null +++ b/firestore/testapp/Assets/Plugins/Android/GameLoops/AndroidManifest.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/firestore/testapp/Assets/Plugins/Android/GameLoops/AndroidManifest.xml.meta b/firestore/testapp/Assets/Plugins/Android/GameLoops/AndroidManifest.xml.meta new file mode 100644 index 000000000..5117d9082 --- /dev/null +++ b/firestore/testapp/Assets/Plugins/Android/GameLoops/AndroidManifest.xml.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: c3a073c1804774373aebe972e8ff946b +timeCreated: 1563317285 +licenseType: Pro +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/firestore/testapp/Assets/Plugins/Android/GameLoops/project.properties b/firestore/testapp/Assets/Plugins/Android/GameLoops/project.properties new file mode 100755 index 000000000..6a402b0cf --- /dev/null +++ b/firestore/testapp/Assets/Plugins/Android/GameLoops/project.properties @@ -0,0 +1,7 @@ +# Copyright (C) 2019 Google Inc. All Rights Reserved. +# +# Together with an AndroidManifest, placing this file into a directory tells Unity +# that the directory is an Android library. Unity will then merge the manifest into +# the main manifest. + +android.library=true diff --git a/firestore/testapp/Assets/Plugins/Android/GameLoops/project.properties.meta b/firestore/testapp/Assets/Plugins/Android/GameLoops/project.properties.meta new file mode 100644 index 000000000..362ca8cca --- /dev/null +++ b/firestore/testapp/Assets/Plugins/Android/GameLoops/project.properties.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 19dfa1d8b1a2a4cd1807217ae860a365 +labels: +- gvh +- gvh_version-6.2.1 +timeCreated: 1480838400 +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/firestore/testapp/Assets/Tests/BundlesTests.cs b/firestore/testapp/Assets/Tests/BundlesTests.cs new file mode 100644 index 000000000..b4da8e6bb --- /dev/null +++ b/firestore/testapp/Assets/Tests/BundlesTests.cs @@ -0,0 +1,481 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using Firebase; +using Firebase.Firestore; +using Firebase.Sample.Firestore; +using NUnit.Framework; +using UnityEngine; +using UnityEngine.TestTools; +using static Tests.TestAsserts; + +namespace Tests { + internal static class BundleBuilder { + private static List BundleTemplate() { + string metadata = + @"{ + ""metadata"":{ + ""id"":""test-bundle"", + ""createTime"":{ + ""seconds"":1001, + ""nanos"":9999 + }, + ""version"":1, + ""totalDocuments"":2, + ""totalBytes"":{totalBytes} + } + }"; + string namedQuery1 = + @"{ + ""namedQuery"":{ + ""name"":""limit"", + ""readTime"":{ + ""seconds"":1000, + ""nanos"":9999 + }, + ""bundledQuery"":{ + ""parent"":""projects/{projectId}/databases/(default)/documents"", + ""structuredQuery"":{ + ""from"":[ + { + ""collectionId"":""coll-1"" + } + ], + ""orderBy"":[ + { + ""field"":{ + ""fieldPath"":""bar"" + }, + ""direction"":""DESCENDING"" + }, + { + ""field"":{ + ""fieldPath"":""__name__"" + }, + ""direction"":""DESCENDING"" + } + ], + ""limit"":{ + ""value"":1 + } + }, + ""limitType"":""FIRST"" + } + } + }"; + string namedQuery2 = + @"{ + ""namedQuery"":{ + ""name"":""limit-to-last"", + ""readTime"":{ + ""seconds"":1000, + ""nanos"":9999 + }, + ""bundledQuery"":{ + ""parent"":""projects/{projectId}/databases/(default)/documents"", + ""structuredQuery"":{ + ""from"":[ + { + ""collectionId"":""coll-1"" + } + ], + ""orderBy"":[ + { + ""field"":{ + ""fieldPath"":""bar"" + }, + ""direction"":""DESCENDING"" + }, + { + ""field"":{ + ""fieldPath"":""__name__"" + }, + ""direction"":""DESCENDING"" + } + ], + ""limit"":{ + ""value"":1 + } + }, + ""limitType"":""LAST"" + } + } + }"; + string documentMetadata1 = + @"{ + ""documentMetadata"":{ + ""name"":""projects/{projectId}/databases/(default)/documents/coll-1/a"", + ""readTime"":{ + ""seconds"":1000, + ""nanos"":9999 + }, + ""exists"":true + } + }"; + + string document1 = + @"{ + ""document"":{ + ""name"":""projects/{projectId}/databases/(default)/documents/coll-1/a"", + ""createTime"":{ + ""seconds"":1, + ""nanos"":9 + }, + ""updateTime"":{ + ""seconds"":1, + ""nanos"":9 + }, + ""fields"":{ + ""k"":{ + ""stringValue"":""a"" + }, + ""bar"":{ + ""integerValue"":1 + } + } + } + }"; + + string documentMetadata2 = + @"{ + ""documentMetadata"":{ + ""name"":""projects/{projectId}/databases/(default)/documents/coll-1/b"", + ""readTime"":{ + ""seconds"":1000, + ""nanos"":9999 + }, + ""exists"":true + } + }"; + + string document2 = + @"{ + ""document"":{ + ""name"":""projects/{projectId}/databases/(default)/documents/coll-1/b"", + ""createTime"":{ + ""seconds"":1, + ""nanos"":9 + }, + ""updateTime"":{ + ""seconds"":1, + ""nanos"":9 + }, + ""fields"":{ + ""k"":{ + ""stringValue"":""b"" + }, + ""bar"":{ + ""integerValue"":2 + } + } + } + }"; + + return new List { metadata, namedQuery1, namedQuery2, documentMetadata1, + document1, documentMetadata2, document2 }; + } + + internal static string CreateBundle(string projectId) { + StringBuilder stringBuilder = new StringBuilder(); + + var template = BundleTemplate(); + for (int i = 1; i < template.Count; ++i) { + string element = template [i].Replace("{projectId}", projectId); + stringBuilder.Append(Encoding.UTF8.GetBytes(element).Length); + stringBuilder.Append(element); + } + + string content = stringBuilder.ToString(); + string metadata = + template [0].Replace("{totalBytes}", Encoding.UTF8.GetBytes(content).Length.ToString()); + return Encoding.UTF8.GetBytes(metadata).Length.ToString() + metadata + content; + } + } + + public class BundlesTests : FirestoreIntegrationTests { + private void VerifySuccessProgress(LoadBundleTaskProgress progress) { + Assert.That(progress.State, Is.EqualTo(LoadBundleTaskProgress.LoadBundleTaskState.Success)); + Assert.That(progress.BytesLoaded, Is.EqualTo(progress.TotalBytes)); + Assert.That(progress.DocumentsLoaded, Is.EqualTo(progress.TotalDocuments)); + } + + private void VerifyErrorProgress(LoadBundleTaskProgress progress) { + Assert.That(progress.State, Is.EqualTo(LoadBundleTaskProgress.LoadBundleTaskState.Error)); + Assert.That(progress.BytesLoaded, Is.EqualTo(0)); + Assert.That(progress.DocumentsLoaded, Is.EqualTo(0)); + } + + private void VerifyInProgressProgress(LoadBundleTaskProgress progress, int expectedDocuments) { + Assert.That(progress.State, + Is.EqualTo(LoadBundleTaskProgress.LoadBundleTaskState.InProgress)); + Assert.That(progress.DocumentsLoaded, Is.EqualTo(expectedDocuments)); + Assert.That(progress.BytesLoaded, Is.LessThanOrEqualTo(progress.TotalBytes)); + Assert.That(progress.DocumentsLoaded, Is.LessThanOrEqualTo(progress.TotalDocuments)); + } + + private IEnumerator VerifyQueryResults() { + { + var snapshotTask = db.Collection("coll-1").GetSnapshotAsync(Source.Cache); + yield return AwaitCompletion(snapshotTask); + Assert.That(QuerySnapshotToValues(snapshotTask.Result), + Is.EquivalentTo(new List> { + new Dictionary { { "k", "a" }, { "bar", 1L } }, + new Dictionary { { "k", "b" }, { "bar", 2L } } + })); + } + + { + var limitQueryTask = db.GetNamedQueryAsync("limit"); + yield return AwaitSuccess(limitQueryTask); + var querySnapshotTask = limitQueryTask.Result.GetSnapshotAsync(Source.Cache); + yield return AwaitSuccess(querySnapshotTask); + Assert.That(QuerySnapshotToValues(querySnapshotTask.Result), + Is.EquivalentTo(new List> { + new Dictionary { { "k", "b" }, { "bar", 2L } } + })); + } + + { + var limitToLastQueryTask = db.GetNamedQueryAsync("limit-to-last"); + yield return AwaitSuccess(limitToLastQueryTask); + var querySnapshotTask = limitToLastQueryTask.Result.GetSnapshotAsync(Source.Cache); + yield return AwaitSuccess(querySnapshotTask); + Assert.That(QuerySnapshotToValues(querySnapshotTask.Result), + Is.EquivalentTo(new List> { + new Dictionary { { "k", "a" }, { "bar", 1L } } + })); + } + } + + protected new FirebaseFirestore db { get; + set; + } + = FirebaseFirestore.DefaultInstance; + + [UnitySetUp] + private IEnumerator ClearPersistenceAndRestart() { + // Clear local persistence cache to make sure bundles loaded previously do not + // interfere with current test case. + yield return AwaitSuccess(db.TerminateAsync()); + yield return AwaitSuccess(db.ClearPersistenceAsync()); + db = FirebaseFirestore.GetInstance(FirebaseApp.DefaultInstance); + } + + [UnityTest] + public IEnumerator LoadBundleWithoutProgressUpdate_ShouldSucceed() { + string bundle = BundleBuilder.CreateBundle(db.App.Options.ProjectId); + var loadTask = db.LoadBundleAsync(bundle); + yield return AwaitSuccess(loadTask); + + VerifySuccessProgress(loadTask.Result); + yield return VerifyQueryResults(); + } + + [UnityTest] + public IEnumerator LoadBundleWithProgressUpdate_ShouldSucceed() { + string bundle = BundleBuilder.CreateBundle(db.App.Options.ProjectId); + var progresses = new List(); + object eventSender = null; + var loadTask = db.LoadBundleAsync(Encoding.UTF8.GetBytes(bundle), (sender, progress) => { + eventSender = sender; + progresses.Add(progress); + }); + + yield return AwaitSuccess(loadTask); + Assert.That(eventSender, Is.SameAs(db)); + VerifySuccessProgress(loadTask.Result); + + Assert.That(progresses.Count, Is.EqualTo(4)); + VerifyInProgressProgress(progresses[0], 0); + VerifyInProgressProgress(progresses[1], 1); + VerifyInProgressProgress(progresses[2], 2); + Assert.That(progresses[3], Is.EqualTo(loadTask.Result)); + + yield return VerifyQueryResults(); + } + + [UnityTest] + public IEnumerator LoadBundle_CanDeleteFirestoreFromProgressUpdate() { + string bundle = BundleBuilder.CreateBundle(db.App.Options.ProjectId); + var progresses = new List(); + + var source = new TaskCompletionSource(); + try { + var loadTask = db.LoadBundleAsync(bundle, (sender, progress) => { + progresses.Add(progress); + + // Delete firestore before the final progress. + if (progresses.Count == 3) { + source.SetResult(true); + db.App.Dispose(); + } + }); + + yield return AwaitSuccess(source.Task); + + Assert.That(progresses.Count, Is.EqualTo(3)); + VerifyInProgressProgress(progresses[0], 0); + VerifyInProgressProgress(progresses[1], 1); + VerifyInProgressProgress(progresses[2], 2); + + } finally { + // Recreate DB such that other tests can run. + db = FirebaseFirestore.GetInstance(FirebaseApp.DefaultInstance); + } + } + + [UnityTest] + public IEnumerator LoadBundleASecondTime_Skips() { + string bundle = BundleBuilder.CreateBundle(db.App.Options.ProjectId); + var firstLoadTask = db.LoadBundleAsync(bundle); + yield return AwaitSuccess(firstLoadTask); + VerifySuccessProgress(firstLoadTask.Result); + + var progresses = new List(); + var secondLoadTask = + db.LoadBundleAsync(bundle, (sender, progress) => { progresses.Add(progress); }); + + yield return AwaitSuccess(secondLoadTask); + VerifySuccessProgress(secondLoadTask.Result); + + Assert.That(progresses.Count, Is.EqualTo(1)); + Assert.That(progresses[0], Is.EqualTo(firstLoadTask.Result)); + + yield return VerifyQueryResults(); + } + + [UnityTest] + public IEnumerator LoadInvalidBundle_ReportsErrorProgress() { + var invalidBundles = new List { "invalid bundle obviously", "\"(╯°□°)╯︵ ┻━┻\"", + Encoding.UTF8.GetString(new byte[] { 0xc3, 0x28 }) }; + + foreach (var bundle in invalidBundles) { + var progresses = new List(); + var loadTask = + db.LoadBundleAsync(bundle, (sender, progress) => { progresses.Add(progress); }); + + yield return AwaitFaults(loadTask); + + Assert.That(progresses.Count, Is.EqualTo(1)); + VerifyErrorProgress(progresses[0]); + } + } + + [UnityTest] + public IEnumerator LoadedDocumentsAlreadyPulledFromBackend_ShouldNotOverwriteNewerVersion() { + var collection = db.Collection("coll-1"); + collection.Document("a").SetAsync(new Dictionary { + { "k", "a" }, + { "bar", "newValueA" }, + }); + var writeTask = collection.Document("b").SetAsync(new Dictionary { + { "k", "b" }, + { "bar", "newValueB" }, + }); + yield return AwaitSuccess(writeTask); + + var accumulator = new EventAccumulator(); + collection.Listen(accumulator.Listener); + yield return AwaitSuccess(accumulator.LastEventAsync()); + + // The test bundle is holding ancient documents, so no events are generated as + // a result. The case where a bundle has newer doc than cache can only be + // tested in spec tests. + accumulator.ThrowOnAnyEvent(); + + string bundle = BundleBuilder.CreateBundle(db.App.Options.ProjectId); + var loadTask = db.LoadBundleAsync(bundle); + yield return AwaitSuccess(loadTask); + + VerifySuccessProgress(loadTask.Result); + { + var snapshotTask = collection.GetSnapshotAsync(Source.Cache); + yield return AwaitCompletion(snapshotTask); + Assert.That(QuerySnapshotToValues(snapshotTask.Result), + Is.EquivalentTo(new List> { + new Dictionary { { "k", "a" }, { "bar", "newValueA" } }, + new Dictionary { { "k", "b" }, { "bar", "newValueB" } } + })); + } + + { + var limitQueryTask = db.GetNamedQueryAsync("limit"); + yield return AwaitSuccess(limitQueryTask); + var querySnapshotTask = limitQueryTask.Result.GetSnapshotAsync(Source.Cache); + yield return AwaitSuccess(querySnapshotTask); + Assert.That(QuerySnapshotToValues(querySnapshotTask.Result), + Is.EquivalentTo(new List> { + new Dictionary { { "k", "b" }, { "bar", "newValueB" } } + })); + } + + { + var limitToLastQueryTask = db.GetNamedQueryAsync("limit-to-last"); + yield return AwaitSuccess(limitToLastQueryTask); + var querySnapshotTask = limitToLastQueryTask.Result.GetSnapshotAsync(Source.Cache); + yield return AwaitSuccess(querySnapshotTask); + Assert.That(QuerySnapshotToValues(querySnapshotTask.Result), + Is.EquivalentTo(new List> { + new Dictionary { { "k", "a" }, { "bar", "newValueA" } } + })); + } + } + + [UnityTest] + public IEnumerator LoadedDocuments_ShouldNotBeGarbageCollectedRightAway() { + var newSettings = db.Settings; + newSettings.PersistenceEnabled = false; + db.Settings = newSettings; + + string bundle = BundleBuilder.CreateBundle(db.App.Options.ProjectId); + var loadTask = db.LoadBundleAsync(bundle); + yield return AwaitSuccess(loadTask); + VerifySuccessProgress(loadTask.Result); + + // Read a different collection. This will trigger GC. + yield return AwaitSuccess(db.Collection("coll-other").GetSnapshotAsync()); + + // Read the loaded documents, expecting them to exist in cache. With memory + // GC, the documents would get GC-ed if we did not hold the document keys in + // an "umbrella" target. See LocalStore for details. + yield return VerifyQueryResults(); + } + + [UnityTest] + public IEnumerator LoadBundleFromOtherProject_ShouldFail() { + string bundle = BundleBuilder.CreateBundle("other-project"); + + var progresses = new List(); + var loadTask = db.LoadBundleAsync(bundle, (sender, progress) => { progresses.Add(progress); }); + yield return AwaitFaults(loadTask); + + Assert.That(progresses.Count, Is.EqualTo(2)); + VerifyInProgressProgress(progresses[0], 0); + VerifyErrorProgress(progresses[1]); + } + + [UnityTest] + public IEnumerator GetInvalideNamedQuery_ShouldReturnNull() { + { + var task = db.GetNamedQueryAsync("DOES_NOT_EXIST"); + yield return AwaitSuccess(task); + Assert.That(task.Result, Is.Null); + } + { + var task = db.GetNamedQueryAsync(""); + yield return AwaitSuccess(task); + Assert.That(task.Result, Is.Null); + } + { + var task = db.GetNamedQueryAsync("\xc3\x28"); + yield return AwaitSuccess(task); + Assert.That(task.Result, Is.Null); + } + } + +} +} diff --git a/firestore/testapp/Assets/Tests/EventAccumulator.cs b/firestore/testapp/Assets/Tests/EventAccumulator.cs new file mode 100644 index 000000000..15d6fb490 --- /dev/null +++ b/firestore/testapp/Assets/Tests/EventAccumulator.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using NUnit.Framework; +using UnityEngine; + +namespace Firebase.Sample.Firestore { + class EventAccumulator { + private readonly BlockingCollection queue = new BlockingCollection(); + private int mainThreadId = -1; + + public EventAccumulator() {} + public EventAccumulator(int mainThreadId) { + this.mainThreadId = mainThreadId; + } + + /// + /// Returns a listener callback suitable for passing to Listen(). + /// + public Action Listener { + get { + return (value) => { + if (mainThreadId > 0) { + Assert.That(Thread.CurrentThread.ManagedThreadId, Is.EqualTo(mainThreadId), + "Listener callback from non-main thread."); + } + + queue.Add(value); + }; + } + } + + /// + /// Waits for the specified number of events. + /// + public Task> LastEventsAsync(int numEvents) { + return Task.Run(() => { + List result = new List(); + while (numEvents-- > 0) { + result.Add(queue.Take()); + } + + return result; + }); + } + + /// + /// Waits for an event and returns it. + /// + public Task LastEventAsync() { + return Task.Run(queue.Take); + } + + /// + /// Throw an exception if any more events are received. + /// + public void ThrowOnAnyEvent() { + queue.CompleteAdding(); + Assert.That(queue, Is.Empty); + } + } +} diff --git a/firestore/testapp/Assets/Tests/FirestoreInstanceTests.cs b/firestore/testapp/Assets/Tests/FirestoreInstanceTests.cs new file mode 100644 index 000000000..44566fa55 --- /dev/null +++ b/firestore/testapp/Assets/Tests/FirestoreInstanceTests.cs @@ -0,0 +1,226 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using Firebase; +using Firebase.Firestore; +using Firebase.Sample.Firestore; +using NUnit.Framework; +using UnityEngine.TestTools; +using static Tests.TestAsserts; + +namespace Tests { + // Tests against features offered from the root Firestore instance. + public class FirestoreInstanceTests : FirestoreIntegrationTests { + [UnityTest] + public IEnumerator Firestore_ShouldIntegrateWithAuth() { + var firebaseAuth = Firebase.Auth.FirebaseAuth.DefaultInstance; + var data = TestData(); + + firebaseAuth.SignOut(); + DocumentReference doc = db.Collection("private").Document(); + var setTask = doc.SetAsync(data); + yield return AwaitFaults(setTask); + AssertTaskFaulted(setTask, FirestoreError.PermissionDenied); + + try { + yield return AwaitSuccess(firebaseAuth.SignInAnonymouslyAsync()); + + // Write should now succeed. + yield return AwaitSuccess(doc.SetAsync(data)); + + } finally { + // Make sure we signed out at the end of the test. + firebaseAuth.SignOut(); + } + } + + [UnityTest] + public IEnumerator WaitForPendingWrites_ShouldWork() { + DocumentReference doc = TestDocument(); + + yield return AwaitSuccess(doc.Firestore.DisableNetworkAsync()); + + // `pendingWrites1` completes without network because there are no pending writes at + // the time it is created. + var pendingWrites1 = doc.Firestore.WaitForPendingWritesAsync(); + yield return AwaitSuccess(pendingWrites1); + + doc.SetAsync(new Dictionary { { "zip", 98101 } }); + // `pendingWrites2` will be pending because the SetAsync above is not acknowledged by the + // backend yet. + var pendingWrites2 = doc.Firestore.WaitForPendingWritesAsync(); + AssertTaskIsPending(pendingWrites2); + + yield return AwaitSuccess(doc.Firestore.EnableNetworkAsync()); + yield return AwaitSuccess(pendingWrites2); + } + + // TODO(b/183603381): Add a test to verify WaitForPendingWritesAsync task fails in user change. + // It requires to create underlying firestore instance with + // a MockCredentialProvider first. + + [UnityTest] + public IEnumerator Terminate_ShouldWork() { + var appOptions = new AppOptions(); + appOptions.ProjectId = "test-terminate"; // Setting a ProjectId is required (b/158838266). + FirebaseApp app = FirebaseApp.Create(appOptions, "App1"); + var db1 = FirebaseFirestore.GetInstance(app); + var doc = db1.Document("abc/123"); + var accumulator = new EventAccumulator(); + var registration = doc.Listen(accumulator.Listener); + + // Multiple calls to terminate should go through. + yield return AwaitSuccess(db1.TerminateAsync()); + yield return AwaitSuccess(db1.TerminateAsync()); + + // Make sure calling registration.Stop multiple times after termination works. + registration.Stop(); + registration.Stop(); + + // TODO(b/149105903) Uncomment this line when a C# exception can be thrown here. + // Assert.Throws(() => db1.DisableNetworkAsync()); + + // Create a new functional instance. + var db2 = FirebaseFirestore.GetInstance(app); + Assert.That(db2, Is.Not.SameAs(db1)); + yield return AwaitSuccess(db2.DisableNetworkAsync()); + yield return AwaitSuccess(db2.EnableNetworkAsync()); + + app.Dispose(); + // TODO(b/183604785): App.Dispose really should leads to Firestore terminated, a NRE here is + // not ideal, but serves the purpose for now. Ideally, it should throw an exception + // telling user it is terminated. + Assert.Throws(() => db2.DisableNetworkAsync()); + } + + [UnityTest] + public IEnumerator ClearPersistence_ShouldWork() { + var defaultOptions = db.App.Options; + string path; + + // Verify that ClearPersistenceAsync() succeeds when invoked on a newly-created + // FirebaseFirestore instance. + { + var app = FirebaseApp.Create(defaultOptions, "TestClearPersistenceApp"); + var db = FirebaseFirestore.GetInstance(app); + yield return AwaitSuccess(db.ClearPersistenceAsync()); + app.Dispose(); + } + + // Create a document to use to verify the behavior of ClearPersistenceAsync(). + { + var app = FirebaseApp.Create(defaultOptions, "TestClearPersistenceApp"); + var db = FirebaseFirestore.GetInstance(app); + var docContents = new Dictionary { { "foo", 42 } }; + + var doc = db.Collection("TestCollection").Document(); + path = doc.Path; + // It is not necessary to Await on the Task returned from SetAsync() below. This is + // because the document has already been written to persistence by the time that + // SetAsync() returns. + doc.SetAsync(docContents); + yield return AwaitSuccess(db.TerminateAsync()); + app.Dispose(); + } + + // As a sanity check, verify that the document created in the previous block exists. + { + var app = FirebaseApp.Create(defaultOptions, "TestClearPersistenceApp"); + var db = FirebaseFirestore.GetInstance(app); + var doc = db.Document(path); + yield return AwaitSuccess(doc.GetSnapshotAsync(Source.Cache)); + app.Dispose(); + } + + // Call ClearPersistenceAsync() after TerminateAsync(). + { + var app = FirebaseApp.Create(defaultOptions, "TestClearPersistenceApp"); + var db = FirebaseFirestore.GetInstance(app); + yield return AwaitSuccess(db.TerminateAsync()); + yield return AwaitSuccess(db.ClearPersistenceAsync()); + app.Dispose(); + } + + // Verify that ClearPersistenceAsync() deleted the document that was created above. + { + var app = FirebaseApp.Create(defaultOptions, "TestClearPersistenceApp"); + var db = FirebaseFirestore.GetInstance(app); + var doc = db.Document(path); + var getTask = doc.GetSnapshotAsync(Source.Cache); + yield return AwaitCompletion(getTask); + AssertTaskFaulted(getTask, FirestoreError.Unavailable); + yield return AwaitSuccess(db.TerminateAsync()); + app.Dispose(); + } + + // Verify that ClearPersistenceAsync() fails if invoked after the first operation and + // before a call to TerminateAsync(). + { + var app = FirebaseApp.Create(defaultOptions, "TestClearPersistenceApp"); + var db = FirebaseFirestore.GetInstance(app); + yield return AwaitSuccess(db.EnableNetworkAsync()); + var clearTask = db.ClearPersistenceAsync(); + yield return AwaitCompletion(clearTask); + AssertTaskFaulted(clearTask, FirestoreError.FailedPrecondition); + yield return AwaitSuccess(db.TerminateAsync()); + app.Dispose(); + } + } + + [UnityTest] + public IEnumerator FirestoreSettings_ShouldWork() { + FirebaseFirestore db = FirebaseFirestore.DefaultInstance; + DocumentReference doc = db.Collection("coll").Document(); + var data = new Dictionary { + { "f1", "v1" }, + }; + yield return AwaitSuccess(doc.SetAsync(data)); + + // Verify it can get snapshot from cache. This is the behavior when + // persistence is set to true in settings, which is the default setting. + yield return AwaitSuccess(doc.GetSnapshotAsync(Source.Cache)); + + // Terminate the current instance and create a new one (via DefaultInstance) such that + // we can apply a new FirebaseFirestoreSettings. + yield return AwaitSuccess(db.TerminateAsync()); + db = FirebaseFirestore.DefaultInstance; + db.Settings = new FirebaseFirestoreSettings { PersistenceEnabled = false }; + + doc = db.Collection("coll").Document(); + yield return AwaitSuccess(doc.SetAsync(data)); + + // Verify it cannot get snapshot from cache. This behavior only exists with memory + // persistence. + var getTask = doc.GetSnapshotAsync(Source.Cache); + yield return AwaitCompletion(getTask); + AssertTaskFaulted(getTask, FirestoreError.Unavailable); + + // Restart SDK again to test mutating existing settings. + yield return AwaitSuccess(db.TerminateAsync()); + db = FirebaseFirestore.DefaultInstance; + Assert.That(db.Settings.PersistenceEnabled, Is.True); + db.Settings.PersistenceEnabled = false; + + doc = db.Collection("coll").Document(); + data = new Dictionary { + { "f1", "v1" }, + }; + yield return AwaitSuccess(doc.SetAsync(data)); + + // Verify it cannot get snapshot from cache. This behavior only exists with memory + // persistence. + getTask = doc.GetSnapshotAsync(Source.Cache); + yield return AwaitCompletion(getTask); + AssertTaskFaulted(getTask, FirestoreError.Unavailable); + + yield return AwaitSuccess(db.TerminateAsync()); + db = FirebaseFirestore.DefaultInstance; + + // There is no way to actually verify the cache size is applied, we simply + // verify the size is set properly in the settings object. + long fiveMb = 5 * 1024 * 1024; + db.Settings = new FirebaseFirestoreSettings { CacheSizeBytes = fiveMb }; + Assert.That(db.Settings.CacheSizeBytes, Is.EqualTo(fiveMb)); + } + } +} \ No newline at end of file diff --git a/firestore/testapp/Assets/Tests/FirestoreIntegrationTests.cs b/firestore/testapp/Assets/Tests/FirestoreIntegrationTests.cs new file mode 100644 index 000000000..4a36ff8e7 --- /dev/null +++ b/firestore/testapp/Assets/Tests/FirestoreIntegrationTests.cs @@ -0,0 +1,75 @@ +using System.Collections; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Firebase.Extensions; +using Firebase.Firestore; +using NUnit.Framework; +using UnityEngine.TestTools; + +using static Tests.TestAsserts; + +namespace Tests { + + public abstract class FirestoreIntegrationTests { + private const int AUTO_ID_LENGTH = 20; + private const string AUTO_ID_ALPHABET = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; + private static System.Random random = new System.Random(); + private static string AutoId() { + string result = ""; + for (int i = 0; i < AUTO_ID_LENGTH; i++) { + result += AUTO_ID_ALPHABET[random.Next(0, AUTO_ID_ALPHABET.Length)]; + } + + return result; + } + + protected int mainThreadId = -1; + [UnitySetUp] + protected IEnumerator CheckAndFixDependencies() { + yield return AwaitSuccess(Firebase.FirebaseApp.CheckAndFixDependenciesAsync()); + } + + [UnitySetUp] + protected IEnumerator InitializeMainThreadId() { + yield return AwaitSuccess(Task.Run((() => {})).ContinueWithOnMainThread((task => { + mainThreadId = Thread.CurrentThread.ManagedThreadId; + }))); + } + + protected FirebaseFirestore db => FirebaseFirestore.DefaultInstance; + + protected CollectionReference TestCollection() { + return db.Collection("test-collection_" + AutoId()); + } + + protected DocumentReference TestDocument() { + return TestCollection().Document(); + } + + protected Dictionary TestData(long n = 1) { + return new Dictionary { + { "name", "room " + n }, + { "active", true }, + { "list", new List { "one", 2L, "three", 4L } }, + { "metadata", new Dictionary { { "createdAt", n }, + { "deep", + new Dictionary { + { "field", "deep-field-" + n }, + { "nested-list", + new List { "a", "b", "c" } }, + } } } } + // TODO(b/181775697): Add other types here too. + }; + } + + protected static List> QuerySnapshotToValues(QuerySnapshot snap) { + List> result = new List>(); + foreach (DocumentSnapshot doc in snap) { + result.Add(doc.ToDictionary()); + } + return result; + } + } +} diff --git a/firestore/testapp/Assets/Tests/InvalidArgumentsTest.cs b/firestore/testapp/Assets/Tests/InvalidArgumentsTest.cs new file mode 100644 index 000000000..dd21fffd3 --- /dev/null +++ b/firestore/testapp/Assets/Tests/InvalidArgumentsTest.cs @@ -0,0 +1,1015 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Firebase; +using Firebase.Firestore; +using NUnit.Framework; +using UnityEngine.TestTools; +using static Tests.TestAsserts; + +namespace Tests { + // Tests that passing invalid input to SWIG-wrapped functions results in a C# exception instead + // of a crash. + public class InvalidArgumentsTest : FirestoreIntegrationTests { + [Test] + public void CollectionReference_AddAsync_NullDocumentData() { + CollectionReference collection = db.Collection("a"); + Assert.Throws(() => collection.AddAsync(null)); + } + + [UnityTest] + public IEnumerator CollectionReference_AddAsync_DocumentDataWithEmptyKey() { + CollectionReference collection = db.Collection("a"); + yield return AwaitFaults(collection.AddAsync(new Dictionary { { "", 42 } })); + } + + [UnityTest] + public IEnumerator CollectionReference_AddAsync_InvalidDocumentDataType() { + CollectionReference collection = db.Collection("a"); + yield return AwaitFaults(collection.AddAsync(42)); + } + + [Test] + public void CollectionReference_Document_NullStringPath() { + CollectionReference collection = TestCollection(); + Assert.Throws(() => collection.Document(null)); + } + + [Test] + public void CollectionReference_Document_EmptyStringPath() { + CollectionReference collection = TestCollection(); + Assert.Throws(() => collection.Document("")); + } + + [Test] + public void CollectionReference_Document_EvenNumberOfPathSegments() { + CollectionReference collection = TestCollection(); + Assert.Throws(() => collection.Document("b/c")); + } + + [Test] + public void DocumentReference_Collection_NullStringPath() { + DocumentReference doc = TestDocument(); + Assert.Throws(() => doc.Collection(null)); + } + + [Test] + public void DocumentReference_Collection_EmptyStringPath() { + DocumentReference doc = TestDocument(); + Assert.Throws(() => doc.Collection("")); + } + + [Test] + public void DocumentReference_Collection_EvenNumberOfPathSegments() { + DocumentReference doc = TestDocument(); + Assert.Throws(() => doc.Collection("a/b")); + } + + [Test] + public void DocumentReference_Listen_1Arg_NullCallback() { + DocumentReference doc = TestDocument(); + Assert.Throws(() => doc.Listen(null)); + } + + [Test] + public void DocumentReference_Listen_2Args_NullCallback() { + DocumentReference doc = TestDocument(); + Assert.Throws(() => doc.Listen(MetadataChanges.Include, null)); + } + + [Test] + public void DocumentReference_SetAsync_NullDocumentData() { + DocumentReference doc = TestDocument(); + Assert.Throws(() => doc.SetAsync(null, null)); + } + + [UnityTest] + public IEnumerator DocumentReference_SetAsync_DocumentDataWithEmptyKey() { + DocumentReference doc = TestDocument(); + yield return AwaitFaults(doc.SetAsync(new Dictionary { { "", 42 } }, null)); + } + + [UnityTest] + public IEnumerator DocumentReference_SetAsync_InvalidDocumentDataType() { + DocumentReference doc = TestDocument(); + yield return AwaitFaults(doc.SetAsync(42, null)); + } + + [Test] + public void DocumentReference_UpdateAsync_NullStringKeyedDictionary() { + DocumentReference doc = TestDocument(); + Assert.Throws(() => + doc.UpdateAsync((IDictionary)null)); + } + + [UnityTest] + public IEnumerator DocumentReference_UpdateAsync_EmptyStringKeyedDictionary() { + DocumentReference doc = TestDocument(); + yield return AwaitSuccess(doc.SetAsync(TestData(), null)); + yield return AwaitSuccess(doc.UpdateAsync(new Dictionary())); + } + + [UnityTest] + public IEnumerator DocumentReference_UpdateAsync_StringKeyedDictionaryWithEmptyKey() { + DocumentReference doc = TestDocument(); + yield return AwaitSuccess(doc.SetAsync(TestData(), null)); + yield return AwaitFaults(doc.UpdateAsync(new Dictionary { { "", 42 } })); + } + + [Test] + public void DocumentReference_UpdateAsync_NullStringField() { + DocumentReference doc = TestDocument(); + Assert.Throws(() => doc.UpdateAsync(null, 42)); + } + + [UnityTest] + public IEnumerator DocumentReference_UpdateAsync_EmptyStringField() { + DocumentReference doc = TestDocument(); + yield return AwaitSuccess(doc.SetAsync(TestData(), null)); + yield return AwaitFaults(doc.UpdateAsync("", 42)); + } + + [Test] + public void DocumentReference_UpdateAsync_NullFieldPathKeyedDictionary() { + DocumentReference doc = TestDocument(); + Assert.Throws( + () => doc.UpdateAsync((IDictionary)null)); + } + + [UnityTest] + public IEnumerator DocumentReference_UpdateAsync_EmptyFieldPathKeyedDictionary() { + DocumentReference doc = TestDocument(); + yield return AwaitSuccess(doc.SetAsync(TestData(), null)); + yield return AwaitSuccess(doc.UpdateAsync(new Dictionary())); + } + + [UnityTest] + public IEnumerator DocumentSnapshot_ContainsField_NullStringPath() { + var steps = RunWithTestDocumentSnapshot(snapshot => { + Assert.Throws(() => snapshot.ContainsField((string)null)); + }); + foreach (var step in steps) yield return step; + } + + [UnityTest] + public IEnumerator DocumentSnapshot_ContainsField_EmptyStringPath() { + var steps = RunWithTestDocumentSnapshot( + snapshot => { Assert.Throws(() => snapshot.ContainsField("")); }); + foreach (var step in steps) yield return step; + } + + [UnityTest] + public IEnumerator DocumentSnapshot_ContainsField_NullFieldPath() { + var steps = RunWithTestDocumentSnapshot(snapshot => { + Assert.Throws(() => snapshot.ContainsField((FieldPath)null)); + }); + foreach (var step in steps) yield return step; + } + + [UnityTest] + public IEnumerator DocumentSnapshot_GetValue_NullStringPath() { + var steps = RunWithTestDocumentSnapshot(snapshot => { + Assert.Throws( + () => snapshot.GetValue((string)null, ServerTimestampBehavior.None)); + }); + foreach (var step in steps) yield return step; + } + + [UnityTest] + public IEnumerator DocumentSnapshot_GetValue_EmptyStringPath() { + var steps = RunWithTestDocumentSnapshot(snapshot => { + Assert.Throws( + () => snapshot.GetValue("", ServerTimestampBehavior.None)); + }); + foreach (var step in steps) yield return step; + } + + [UnityTest] + public IEnumerator DocumentSnapshot_GetValue_NullFieldPath() { + var steps = RunWithTestDocumentSnapshot(snapshot => { + Assert.Throws( + () => snapshot.GetValue((FieldPath)null, ServerTimestampBehavior.None)); + }); + foreach (var step in steps) yield return step; + } + + [UnityTest] + public IEnumerator DocumentSnapshot_TryGetValue_NullStringPath() { + var steps = RunWithTestDocumentSnapshot(snapshot => { + object value = null; + Assert.Throws( + () => snapshot.TryGetValue((string)null, out value, ServerTimestampBehavior.None)); + }); + foreach (var step in steps) yield return step; + } + + [UnityTest] + public IEnumerator DocumentSnapshot_TryGetValue_EmptyStringPath() { + var steps = RunWithTestDocumentSnapshot(snapshot => { + object value = null; + Assert.Throws( + () => snapshot.TryGetValue("", out value, ServerTimestampBehavior.None)); + }); + foreach (var step in steps) yield return step; + } + + [UnityTest] + public IEnumerator DocumentSnapshot_TryGetValue_NullFieldPath() { + var steps = RunWithTestDocumentSnapshot(snapshot => { + object value = null; + Assert.Throws( + () => snapshot.TryGetValue((FieldPath)null, out value, ServerTimestampBehavior.None)); + }); + foreach (var step in steps) yield return step; + } + + /** + * Creates a `DocumentSnapshot` then invokes the given action with it synchronously in the + * calling thread. This enables the caller to use standard asserts since any exceptions + * they throw will be thrown in the calling thread's context and bubble up to the test runner. + */ + private IEnumerable RunWithTestDocumentSnapshot(Action action) { + DocumentReference doc = TestDocument(); + doc.SetAsync(TestData()); + Task task = doc.GetSnapshotAsync(Source.Cache); + yield return AwaitSuccess(task); + DocumentSnapshot snapshot = task.Result; + action(snapshot); + } + + [Test] + public void FieldPath_Constructor_NullStringArray() { + Assert.Throws(() => new FieldPath(null)); + } + + [Test] + public void FieldPath_Constructor_StringArrayWithNullElement() { + Assert.Throws(() => new FieldPath(new string[] { null })); + } + + [Test] + public void FieldPath_Constructor_EmptyStringArray() { + Assert.Throws(() => new FieldPath(new string[0])); + } + + [Test] + public void FieldPath_Constructor_StringArrayWithEmptyString() { + Assert.Throws(() => new FieldPath(new string[] { "" })); + } + + [Test] + public void FieldValue_ArrayRemove_NullArray() { + Assert.Throws(() => FieldValue.ArrayRemove(null)); + } + + [Test] + public void FieldValue_ArrayUnion_NullArray() { + Assert.Throws(() => FieldValue.ArrayUnion(null)); + } + + [Test] + public void FirebaseFirestore_GetInstance_Null() { + Assert.Throws(() => FirebaseFirestore.GetInstance(null)); + } + + [Test] + [Ignore("TODO(b/190063255) This test crashes the Unity Editor; fix it")] + public void FirebaseFirestore_GetInstance_DisposedApp() { + FirebaseApp disposedApp = FirebaseApp.Create(db.App.Options, "test-getinstance-disposedapp"); + disposedApp.Dispose(); + FirebaseFirestore.GetInstance(disposedApp); + } + + [Test] + public void FirebaseFirestore_Collection_NullStringPath() { + Assert.Throws(() => db.Collection(null)); + } + + [Test] + public void FirebaseFirestore_Collection_EmptyStringPath() { + Assert.Throws(() => db.Collection("")); + } + + [Test] + public void FirebaseFirestore_Collection_EvenNumberOfPathSegments() { + Assert.Throws(() => db.Collection("a/b")); + } + + [Test] + public void FirebaseFirestore_CollectionGroup_NullCollectionId() { + Assert.Throws(() => db.CollectionGroup(null)); + } + + [Test] + public void FirebaseFirestore_CollectionGroup_EmptyCollectionId() { + Assert.Throws(() => db.CollectionGroup("")); + } + + [UnityTest] + public IEnumerator FirebaseFirestore_CollectionGroup_CollectionIdContainsSlash() { + Query query = db.CollectionGroup("a/b"); + // TODO(b/190041743) The `collectionId` argument to CollectionGroup() is documented that + // it "must not contain a slash"; however, this does not appear to be validated because + // getting the snapshot completes successfully. This test may need to be updated if the + // behavior is changed. In either case, leave this test here to ensure that specifying a + // slash does not crash the app. + yield return AwaitSuccess(query.GetSnapshotAsync(Source.Cache)); + } + + [Test] + public void FirebaseFirestore_Document_NullStringPath() { + Assert.Throws(() => db.Document(null)); + } + + [Test] + public void FirebaseFirestore_Document_EmptyStringPath() { + Assert.Throws(() => db.Document("")); + } + + [Test] + public void FirebaseFirestore_Document_OddNumberOfPathSegments() { + Assert.Throws(() => db.Document("a/b/c")); + } + + [Test] + public void FirebaseFirestore_ListenForSnapshotsInSync_NullCallback() { + Assert.Throws(() => db.ListenForSnapshotsInSync(null)); + } + + [Test] + public void FirebaseFirestore_RunTransactionAsync_WithoutTypeParameter_NullCallback() { + Assert.Throws(() => db.RunTransactionAsync(null)); + } + + [Test] + public void FirebaseFirestore_RunTransactionAsync_WithTypeParameter_NullCallback() { + Assert.Throws(() => db.RunTransactionAsync(null)); + } + + [Test] + public void FirebaseFirestoreSettings_Host_Null() { + FirebaseFirestoreSettings settings = db.Settings; + Assert.Throws(() => settings.Host = null); + } + + [Test] + public void FirebaseFirestoreSettings_Host_EmptyString() { + FirebaseFirestoreSettings settings = db.Settings; + Assert.Throws(() => settings.Host = ""); + } + + [Test] + public void Query_EndAt_NullDocumentSnapshot() { + Query query = TestCollection(); + Assert.Throws(() => query.EndAt((DocumentSnapshot)null)); + } + + [Test] + public void Query_EndAt_NullArray() { + Query query = TestCollection(); + Assert.Throws(() => query.EndAt((object[])null)); + } + + [Test] + public void Query_EndAt_ArrayWithNullElement() { + Query query = TestCollection(); + Assert.Throws(() => query.EndAt(new object[] { null })); + } + + [Test] + public void Query_EndBefore_NullDocumentSnapshot() { + Query query = TestCollection(); + Assert.Throws(() => query.EndBefore((DocumentSnapshot)null)); + } + + [Test] + public void Query_EndBefore_NullArray() { + Query query = TestCollection(); + Assert.Throws(() => query.EndBefore((object[])null)); + } + + [Test] + public void Query_Limit_0() { + Query query = TestCollection(); + Assert.Throws(() => query.Limit(0)); + } + + [Test] + public void Query_Limit_Negative1() { + Query query = TestCollection(); + Assert.Throws(() => query.Limit(-1)); + } + + [Test] + public void Query_LimitToLast_0() { + Query query = TestCollection(); + Assert.Throws(() => query.LimitToLast(0)); + } + + [Test] + public void Query_LimitToLast_Negative1() { + Query query = TestCollection(); + Assert.Throws(() => query.LimitToLast(-1)); + } + + [Test] + public void Query_OrderBy_NullPathString() { + Query query = TestCollection(); + Assert.Throws(() => query.OrderBy((string)null)); + } + + [Test] + public void Query_OrderBy_EmptyPathString() { + Query query = TestCollection(); + Assert.Throws(() => query.OrderBy("")); + } + + [Test] + public void Query_OrderBy_NullFieldPath() { + Query query = TestCollection(); + Assert.Throws(() => query.OrderBy((FieldPath)null)); + } + + [Test] + public void Query_OrderByDescending_NullPathString() { + Query query = TestCollection(); + Assert.Throws(() => query.OrderByDescending((string)null)); + } + + [Test] + public void Query_OrderByDescending_EmptyPathString() { + Query query = TestCollection(); + Assert.Throws(() => query.OrderByDescending("")); + } + + [Test] + public void Query_OrderByDescending_NullFieldPath() { + Query query = TestCollection(); + Assert.Throws(() => query.OrderByDescending((FieldPath)null)); + } + + [Test] + public void Query_StartAfter_NullDocumentSnapshot() { + Query query = TestCollection(); + Assert.Throws(() => query.StartAfter((DocumentSnapshot)null)); + } + + [Test] + public void Query_StartAfter_NullArray() { + Query query = TestCollection(); + Assert.Throws(() => query.StartAfter((object[])null)); + } + + [Test] + public void Query_StartAt_NullDocumentSnapshot() { + Query query = TestCollection(); + Assert.Throws(() => query.StartAt((DocumentSnapshot)null)); + } + + [Test] + public void Query_StartAt_NullArray() { + Query query = TestCollection(); + Assert.Throws(() => query.StartAt((object[])null)); + } + + [Test] + public void Query_StartAt_ArrayWithNullElement() { + Query query = TestCollection(); + Assert.Throws(() => query.StartAt(new object[] { null })); + } + + [Test] + public void Query_WhereArrayContains_NullFieldPath() { + Query query = TestCollection(); + Assert.Throws(() => query.WhereArrayContains((FieldPath)null, "")); + } + + [Test] + public void Query_WhereArrayContains_NullPathString() { + Query query = TestCollection(); + Assert.Throws(() => query.WhereArrayContains((string)null, "")); + } + + [Test] + public void Query_WhereArrayContains_EmptyPathString() { + Query query = TestCollection(); + Assert.Throws(() => query.WhereArrayContains("", 42)); + } + + [Test] + public void Query_WhereArrayContainsAny_NullFieldPath() { + Query query = TestCollection(); + List values = new List { "" }; + Assert.Throws( + () => query.WhereArrayContainsAny((FieldPath)null, values)); + } + + [Test] + public void Query_WhereArrayContainsAny_NonNullFieldPath_NullValues() { + Query query = TestCollection(); + FieldPath fieldPath = new FieldPath(new string[] { "a", "b" }); + Assert.Throws(() => query.WhereArrayContainsAny(fieldPath, null)); + } + + [Test] + public void Query_WhereArrayContainsAny_NullPathString() { + Query query = TestCollection(); + List values = new List { "" }; + Assert.Throws(() => query.WhereArrayContainsAny((string)null, values)); + } + + [Test] + public void Query_WhereArrayContainsAny_EmptyPathString() { + Query query = TestCollection(); + List values = new List { "" }; + Assert.Throws(() => query.WhereArrayContainsAny("", values)); + } + + [Test] + public void Query_WhereArrayContainsAny_NonNullPathString_NullValues() { + Query query = TestCollection(); + string pathString = "a/b"; + Assert.Throws(() => query.WhereArrayContainsAny(pathString, null)); + } + + [Test] + public void Query_WhereEqualTo_NullPathString() { + Query query = TestCollection(); + Assert.Throws(() => query.WhereEqualTo((string)null, 42)); + } + + [Test] + public void Query_WhereEqualTo_EmptyPathString() { + Query query = TestCollection(); + Assert.Throws(() => query.WhereEqualTo("", 42)); + } + + [Test] + public void Query_WhereEqualTo_NullFieldPath() { + Query query = TestCollection(); + Assert.Throws(() => query.WhereEqualTo((FieldPath)null, 42)); + } + + [Test] + public void Query_WhereGreaterThan_NullPathString() { + Query query = TestCollection(); + Assert.Throws(() => query.WhereGreaterThan((string)null, 42)); + } + + [Test] + public void Query_WhereGreaterThan_EmptyPathString() { + Query query = TestCollection(); + Assert.Throws(() => query.WhereGreaterThan("", 42)); + } + + [Test] + public void Query_WhereGreaterThan_NullFieldPath() { + Query query = TestCollection(); + Assert.Throws(() => query.WhereGreaterThan((FieldPath)null, 42)); + } + + [Test] + public void Query_WhereGreaterThanOrEqualTo_NullPathString() { + Query query = TestCollection(); + Assert.Throws(() => query.WhereGreaterThanOrEqualTo((string)null, 42)); + } + + [Test] + public void Query_WhereGreaterThanOrEqualTo_EmptyPathString() { + Query query = TestCollection(); + Assert.Throws(() => query.WhereGreaterThanOrEqualTo("", 42)); + } + + [Test] + public void Query_WhereGreaterThanOrEqualTo_NullFieldPath() { + Query query = TestCollection(); + Assert.Throws( + () => query.WhereGreaterThanOrEqualTo((FieldPath)null, 42)); + } + + [Test] + public void Query_WhereIn_NullFieldPath() { + Query query = TestCollection(); + List values = new List { 42 }; + Assert.Throws(() => query.WhereIn((FieldPath)null, values)); + } + + [Test] + public void Query_WhereIn_NonNullFieldPath_NullValues() { + Query query = TestCollection(); + FieldPath fieldPath = new FieldPath(new string[] { "a", "b" }); + Assert.Throws(() => query.WhereIn(fieldPath, null)); + } + + [Test] + public void Query_WhereIn_NullPathString() { + Query query = TestCollection(); + List values = new List { 42 }; + Assert.Throws(() => query.WhereIn((string)null, values)); + } + + [Test] + public void Query_WhereIn_EmptyPathString() { + Query query = TestCollection(); + List values = new List { 42 }; + Assert.Throws(() => query.WhereIn("", values)); + } + + [Test] + public void Query_WhereIn_NonNullPathString_NullValues() { + Query query = TestCollection(); + string fieldPath = "a/b"; + Assert.Throws(() => query.WhereIn(fieldPath, null)); + } + + [Test] + public void Query_WhereLessThan_NullPathString() { + Query query = TestCollection(); + Assert.Throws(() => query.WhereLessThan((string)null, 42)); + } + + [Test] + public void Query_WhereLessThan_EmptyPathString() { + Query query = TestCollection(); + Assert.Throws(() => query.WhereLessThan("", 42)); + } + + [Test] + public void Query_WhereLessThan_NullFieldPath() { + Query query = TestCollection(); + Assert.Throws(() => query.WhereLessThan((FieldPath)null, 42)); + } + + [Test] + public void Query_WhereLessThanOrEqualTo_NullPathString() { + Query query = TestCollection(); + Assert.Throws(() => query.WhereLessThanOrEqualTo((string)null, 42)); + } + + [Test] + public void Query_WhereLessThanOrEqualTo_EmptyPathString() { + Query query = TestCollection(); + Assert.Throws(() => query.WhereLessThanOrEqualTo("", 42)); + } + + [Test] + public void Query_WhereLessThanOrEqualTo_NullFieldPath() { + Query query = TestCollection(); + Assert.Throws(() => query.WhereLessThanOrEqualTo((FieldPath)null, 42)); + } + + [Test] + public void Query_WhereNotEqualTo_NullPathString() { + Query query = TestCollection(); + Assert.Throws(() => query.WhereNotEqualTo((string)null, 42)); + } + + [Test] + public void Query_WhereNotEqualTo_EmptyPathString() { + Query query = TestCollection(); + Assert.Throws(() => query.WhereNotEqualTo("", 42)); + } + + [Test] + public void Query_WhereNotEqualTo_NullFieldPath() { + Query query = TestCollection(); + Assert.Throws(() => query.WhereNotEqualTo((FieldPath)null, 42)); + } + + [Test] + public void Query_WhereNotIn_NullFieldPath() { + Query query = TestCollection(); + List values = new List { 42 }; + Assert.Throws(() => query.WhereNotIn((FieldPath)null, values)); + } + + [Test] + public void Query_WhereNotIn_NonNullFieldPath_NullValues() { + Query query = TestCollection(); + FieldPath fieldPath = new FieldPath(new string[] { "a", "b" }); + Assert.Throws(() => query.WhereNotIn(fieldPath, null)); + } + + [Test] + public void Query_WhereNotIn_NullPathString() { + Query query = TestCollection(); + List values = new List { 42 }; + Assert.Throws(() => query.WhereNotIn((string)null, values)); + } + + [Test] + public void Query_WhereNotIn_EmptyPathString() { + Query query = TestCollection(); + List values = new List { 42 }; + Assert.Throws(() => query.WhereNotIn("", values)); + } + + [Test] + public void Query_WhereNotIn_NonNullPathString_NullValues() { + Query query = TestCollection(); + string fieldPath = "a/b"; + Assert.Throws(() => query.WhereNotIn(fieldPath, null)); + } + + [UnityTest] + public IEnumerator Transaction_Delete_NullDocumentReference() { + IEnumerable steps = RunWithTransaction( + transaction => { Assert.Throws(() => transaction.Delete(null)); }); + foreach (var step in steps) yield return step; + } + + [UnityTest] + public IEnumerator Transaction_GetSnapshotAsync_NullDocumentReference() { + IEnumerable steps = RunWithTransaction(transaction => { + Assert.Throws(() => transaction.GetSnapshotAsync(null)); + }); + foreach (var step in steps) yield return step; + } + + [UnityTest] + public IEnumerator Transaction_Set_NullDocumentReference() { + object documentData = TestData(); + IEnumerable steps = RunWithTransaction(transaction => { + Assert.Throws(() => transaction.Set(null, documentData, null)); + }); + foreach (var step in steps) yield return step; + } + + [UnityTest] + public IEnumerator Transaction_Set_NullDocumentData() { + DocumentReference doc = TestDocument(); + IEnumerable steps = RunWithTransaction(transaction => { + Assert.Throws(() => transaction.Set(doc, null, null)); + }); + foreach (var step in steps) yield return step; + } + + [UnityTest] + public IEnumerator Transaction_Set_DocumentDataWithEmptyKey() { + DocumentReference doc = TestDocument(); + IEnumerable steps = RunWithTransaction(transaction => { + Assert.Throws( + () => transaction.Set(doc, new Dictionary { { "", 42 } }, null)); + }); + foreach (var step in steps) yield return step; + } + + [UnityTest] + public IEnumerator Transaction_Set_InvalidDocumentDataType() { + DocumentReference doc = TestDocument(); + IEnumerable steps = RunWithTransaction(transaction => { + Assert.Throws(() => transaction.Set(doc, 42, null)); + }); + foreach (var step in steps) yield return step; + } + + [UnityTest] + public IEnumerator Transaction_Update_NullDocumentReference_NonNullStringKeyDictionary() { + IEnumerable steps = RunWithTransaction(transaction => { + Assert.Throws( + () => transaction.Update(null, new Dictionary { { "key", 42 } })); + }); + foreach (var step in steps) yield return step; + } + + [UnityTest] + public IEnumerator Transaction_Update_NonNullDocumentReference_NullStringKeyDictionary() { + DocumentReference doc = TestDocument(); + IEnumerable steps = RunWithTransaction(transaction => { + Assert.Throws( + () => transaction.Update(doc, (IDictionary)null)); + }); + foreach (var step in steps) yield return step; + } + + [UnityTest] + public IEnumerator Transaction_Update_NonNullDocumentReference_EmptyStringKeyDictionary() { + DocumentReference doc = TestDocument(); + yield return AwaitSuccess(doc.SetAsync(TestData(), null)); + yield return AwaitSuccess(db.RunTransactionAsync(transaction => { + return transaction.GetSnapshotAsync(doc).ContinueWith( + snapshot => { transaction.Update(doc, new Dictionary()); }); + })); + } + + [UnityTest] + public IEnumerator + Transaction_Update_NonNullDocumentReference_StringKeyDictionaryWithEmptyKey() { + DocumentReference doc = TestDocument(); + IEnumerable steps = RunWithTransaction(transaction => { + Assert.Throws( + () => transaction.Update(doc, new Dictionary { { "", 42 } })); + }); + foreach (var step in steps) yield return step; + } + + [UnityTest] + public IEnumerator Transaction_Update_NullDocumentReference_NonNullFieldString() { + IEnumerable steps = RunWithTransaction(transaction => { + Assert.Throws(() => transaction.Update(null, "fieldName", 42)); + }); + foreach (var step in steps) yield return step; + } + + [UnityTest] + public IEnumerator Transaction_Update_NonNullDocumentReference_NullFieldString() { + DocumentReference doc = TestDocument(); + IEnumerable steps = RunWithTransaction(transaction => { + Assert.Throws(() => transaction.Update(doc, (string)null, 42)); + }); + foreach (var step in steps) yield return step; + } + + [UnityTest] + public IEnumerator Transaction_Update_NullDocumentReference_NonNullFieldPathKeyDictionary() { + var nonNullFieldPathKeyDictionary = + new Dictionary { { new FieldPath(new string[] { "a", "b" }), 42 } }; + IEnumerable steps = RunWithTransaction(transaction => { + Assert.Throws( + () => transaction.Update(null, nonNullFieldPathKeyDictionary)); + }); + foreach (var step in steps) yield return step; + } + + [UnityTest] + public IEnumerator Transaction_Update_NonNullDocumentReference_NullFieldPathKeyDictionary() { + DocumentReference doc = TestDocument(); + IEnumerable steps = RunWithTransaction(transaction => { + Assert.Throws( + () => transaction.Update(doc, (IDictionary)null)); + }); + foreach (var step in steps) yield return step; + } + + [UnityTest] + public IEnumerator Transaction_Update_NonNullDocumentReference_EmptyFieldPathKeyDictionary() { + DocumentReference doc = TestDocument(); + yield return AwaitSuccess(doc.SetAsync(TestData(), null)); + yield return AwaitSuccess(db.RunTransactionAsync(transaction => { + return transaction.GetSnapshotAsync(doc).ContinueWith( + snapshot => { transaction.Update(doc, new Dictionary()); }); + })); + } + + /** + * Starts a transaction and invokes the given action with the `Transaction` object synchronously + * in the calling thread. This enables the caller to use standard asserts since any exceptions + * they throw will be thrown in the calling thread's context and bubble up to the test runner. + */ + private IEnumerable RunWithTransaction(Action action) { + DocumentReference doc = TestDocument(); + var taskCompletionSource = new TaskCompletionSource(); + Transaction capturedTransaction = null; + + Task transactionTask = db.RunTransactionAsync(lambdaTransaction => { + Interlocked.Exchange(ref capturedTransaction, lambdaTransaction); + return taskCompletionSource.Task; + }); + + try { + Transaction transaction = null; + while (true) { + transaction = Interlocked.Exchange(ref capturedTransaction, null); + if (transaction != null) { + break; + } + yield return null; + } + action(transaction); + } finally { + taskCompletionSource.SetResult(null); + } + + yield return AwaitSuccess(transactionTask); + } + + [Test] + public void WriteBatch_Delete_NullDocumentReference() { + WriteBatch writeBatch = db.StartBatch(); + Assert.Throws(() => writeBatch.Delete(null)); + } + + [Test] + public void WriteBatch_Set_NullDocumentReference() { + WriteBatch writeBatch = db.StartBatch(); + var nonNullDocumentData = TestData(); + Assert.Throws(() => writeBatch.Set(null, nonNullDocumentData, null)); + } + + [Test] + public void WriteBatch_Set_NullDocumentData() { + WriteBatch writeBatch = db.StartBatch(); + DocumentReference doc = TestDocument(); + Assert.Throws(() => writeBatch.Set(doc, null, null)); + } + + [Test] + public void WriteBatch_Set_DocumentDataWithEmptyKey() { + WriteBatch writeBatch = db.StartBatch(); + DocumentReference doc = TestDocument(); + Assert.Throws( + () => writeBatch.Set(doc, new Dictionary { { "", 42 } }, null)); + } + + [Test] + public void WriteBatch_Set_InvalidDocumentDataType() { + WriteBatch writeBatch = db.StartBatch(); + DocumentReference doc = TestDocument(); + Assert.Throws(() => writeBatch.Set(doc, 42, null)); + } + + [Test] + public void WriteBatch_Update_NullDocumentReference_NonNullStringKeyDictionary() { + WriteBatch writeBatch = db.StartBatch(); + Assert.Throws( + () => writeBatch.Update(null, new Dictionary { { "key", 42 } })); + } + + [Test] + public void WriteBatch_Update_NonNullDocumentReference_NullStringKeyDictionary() { + WriteBatch writeBatch = db.StartBatch(); + DocumentReference doc = TestDocument(); + Assert.Throws( + () => writeBatch.Update(doc, (IDictionary)null)); + } + + [UnityTest] + public IEnumerator WriteBatch_Update_NonNullDocumentReference_EmptyStringKeyDictionary() { + WriteBatch writeBatch = db.StartBatch(); + DocumentReference doc = TestDocument(); + yield return AwaitSuccess(doc.SetAsync(TestData(), null)); + writeBatch.Update(doc, new Dictionary()); + yield return AwaitSuccess(writeBatch.CommitAsync()); + } + + [Test] + public void WriteBatch_Update_NonNullDocumentReference_StringKeyDictionaryWithEmptyKey() { + WriteBatch writeBatch = db.StartBatch(); + DocumentReference doc = TestDocument(); + Assert.Throws( + () => writeBatch.Update(doc, new Dictionary { { "", 42 } })); + } + + [Test] + public void WriteBatch_Update_NullDocumentReference_NonNullFieldString() { + WriteBatch writeBatch = db.StartBatch(); + Assert.Throws(() => writeBatch.Update(null, "fieldName", 42)); + } + + [Test] + public void WriteBatch_Update_NonNullDocumentReference_NullFieldString() { + WriteBatch writeBatch = db.StartBatch(); + DocumentReference doc = TestDocument(); + Assert.Throws(() => writeBatch.Update(doc, (string)null, 42)); + } + + [Test] + public void WriteBatch_Update_NullDocumentReference_NonNullFieldPathKeyDictionary() { + WriteBatch writeBatch = db.StartBatch(); + var nonNullFieldPathKeyDictionary = + new Dictionary { { new FieldPath(new string[] { "a", "b" }), 42 } }; + Assert.Throws( + () => writeBatch.Update(null, nonNullFieldPathKeyDictionary)); + } + + [Test] + public void WriteBatch_Update_NonNullDocumentReference_NullFieldPathKeyDictionary() { + WriteBatch writeBatch = db.StartBatch(); + DocumentReference doc = TestDocument(); + Assert.Throws( + () => writeBatch.Update(doc, (IDictionary)null)); + } + + [UnityTest] + public IEnumerator WriteBatch_Update_NonNullDocumentReference_EmptyFieldPathKeyDictionary() { + WriteBatch writeBatch = db.StartBatch(); + DocumentReference doc = TestDocument(); + yield return AwaitSuccess(doc.SetAsync(TestData(), null)); + writeBatch.Update(doc, new Dictionary()); + yield return AwaitSuccess(writeBatch.CommitAsync()); + } + + [Test] + public void FirebaseFirestore_LoadBundleAsync_NullBundle() { + Assert.Throws(() => db.LoadBundleAsync(null as string)); + Assert.Throws( + () => db.LoadBundleAsync(null as string, (sender, progress) => {})); + Assert.Throws(() => db.LoadBundleAsync(null as byte[])); + Assert.Throws( + () => db.LoadBundleAsync(null as byte[], (sender, progress) => {})); + } + + [Test] + public void FirebaseFirestore_LoadBundleAsync_NonNullBundle_NullHandler() { + Assert.Throws(() => db.LoadBundleAsync("", null)); + Assert.Throws(() => db.LoadBundleAsync(new byte[] {}, null)); + } + + [Test] + public void FirebaseFirestore_GetNamedQueryAsync_NullQueryName() { + Assert.Throws(() => db.GetNamedQueryAsync(null)); + } + } +} diff --git a/firestore/testapp/Assets/Tests/MiscellaneousTests.cs b/firestore/testapp/Assets/Tests/MiscellaneousTests.cs new file mode 100644 index 000000000..3521d82ad --- /dev/null +++ b/firestore/testapp/Assets/Tests/MiscellaneousTests.cs @@ -0,0 +1,134 @@ +using System.Collections; +using System.Collections.Generic; +using System.Threading.Tasks; +using Firebase.Firestore; +using UnityEngine.TestTools; +using NUnit.Framework; +using static Tests.TestAsserts; + +namespace Tests { + // Tests that do not belong to other well categorized testing classes. + public class MiscellaneousTests : FirestoreIntegrationTests { + [Test] + public void TestCanTraverseCollectionsAndDocuments() { + // doc path from root Firestore. + Assert.That(db.Document("a/b/c/d").Path, Is.EqualTo("a/b/c/d")); + + // collection path from root Firestore. + Assert.That(db.Collection("a/b/c").Document("d").Path, Is.EqualTo("a/b/c/d")); + + // doc path from CollectionReference. + Assert.That(db.Collection("a").Document("b/c/d").Path, Is.EqualTo("a/b/c/d")); + + // collection path from DocumentReference. + Assert.That(db.Document("a/b").Collection("c/d/e").Path, Is.EqualTo("a/b/c/d/e")); + } + + [Test] + public void TestCanTraverseCollectionAndDocumentParents() { + CollectionReference collection = db.Collection("a/b/c"); + Assert.That(collection.Path, Is.EqualTo("a/b/c")); + + DocumentReference doc = collection.Parent; + Assert.That(doc.Path, Is.EqualTo("a/b")); + + collection = doc.Parent; + Assert.That(collection.Path, Is.EqualTo("a")); + + DocumentReference invalidDoc = collection.Parent; + Assert.That(invalidDoc, Is.Null); + } + + [Test] + public void Firestore_DefaultInstanceShouldBeStable() { + FirebaseFirestore db1 = FirebaseFirestore.DefaultInstance; + FirebaseFirestore db2 = FirebaseFirestore.DefaultInstance; + Assert.That(db1, Is.SameAs(db2)); + Assert.That(db1, Is.SameAs(db1.Collection("a").WhereEqualTo("x", 1).Firestore)); + Assert.That(db2, Is.SameAs(db2.Document("a/b").Firestore)); + } + + [UnityTest] + public IEnumerator DocumentReference_TasksFailProperly() { + var docWithInvalidName = TestCollection().Document("__badpath__"); + var fieldPathData = new Dictionary { { new FieldPath("key"), 42 } }; + + { + Task task = docWithInvalidName.DeleteAsync(); + yield return AwaitCompletion(task); + AssertTaskFaulted(task, FirestoreError.InvalidArgument); + } + { + Task task = docWithInvalidName.UpdateAsync(TestData(0)); + yield return AwaitCompletion(task); + AssertTaskFaulted(task, FirestoreError.InvalidArgument); + } + { + Task task = docWithInvalidName.UpdateAsync("fieldName", 42); + yield return AwaitCompletion(task); + AssertTaskFaulted(task, FirestoreError.InvalidArgument); + } + { + Task task = docWithInvalidName.UpdateAsync(fieldPathData); + yield return AwaitCompletion(task); + AssertTaskFaulted(task, FirestoreError.InvalidArgument); + } + { + Task task = docWithInvalidName.SetAsync(TestData(), SetOptions.MergeAll); + yield return AwaitCompletion(task); + AssertTaskFaulted(task, FirestoreError.InvalidArgument); + } + { + Task task = docWithInvalidName.GetSnapshotAsync(); + yield return AwaitCompletion(task); + AssertTaskFaulted(task, FirestoreError.InvalidArgument); + } + { + Task task = docWithInvalidName.GetSnapshotAsync(Source.Default); + yield return AwaitCompletion(task); + AssertTaskFaulted(task, FirestoreError.InvalidArgument); + } + { + ListenerRegistration listenerRegistration = docWithInvalidName.Listen(snap => {}); + yield return AwaitCompletion(listenerRegistration.ListenerTask); + AssertTaskFaulted(listenerRegistration.ListenerTask, FirestoreError.InvalidArgument); + listenerRegistration.Stop(); + } + } + + [UnityTest] + public IEnumerator CollectionReference_TasksFailProperly() { + var collectionWithInvalidName = TestCollection().Document("__badpath__").Collection("sub"); + { + Task task = collectionWithInvalidName.GetSnapshotAsync(); + yield return AwaitCompletion(task); + AssertTaskFaulted(task, FirestoreError.InvalidArgument, "__badpath__"); + } + { + Task task = collectionWithInvalidName.GetSnapshotAsync(Source.Default); + yield return AwaitCompletion(task); + AssertTaskFaulted(task, FirestoreError.InvalidArgument, "__badpath__"); + } + { + Task task = collectionWithInvalidName.AddAsync(TestData(0)); + yield return AwaitCompletion(task); + AssertTaskFaulted(task, FirestoreError.InvalidArgument); + } + { + ListenerRegistration listenerRegistration = collectionWithInvalidName.Listen(snap => {}); + yield return AwaitCompletion(listenerRegistration.ListenerTask); + AssertTaskFaulted(listenerRegistration.ListenerTask, FirestoreError.InvalidArgument, + "__badpath__"); + listenerRegistration.Stop(); + } + { + ListenerRegistration listenerRegistration = + collectionWithInvalidName.Listen(MetadataChanges.Include, snap => {}); + yield return AwaitCompletion(listenerRegistration.ListenerTask); + AssertTaskFaulted(listenerRegistration.ListenerTask, FirestoreError.InvalidArgument, + "__badpath__"); + listenerRegistration.Stop(); + } + } + } +} \ No newline at end of file diff --git a/firestore/testapp/Assets/Tests/MutationTests.cs b/firestore/testapp/Assets/Tests/MutationTests.cs new file mode 100644 index 000000000..dc1d1e0bc --- /dev/null +++ b/firestore/testapp/Assets/Tests/MutationTests.cs @@ -0,0 +1,349 @@ +using System.Collections; +using System.Collections.Generic; +using System.Threading.Tasks; +using NUnit.Framework; +using UnityEngine.TestTools; +using Firebase.Firestore; +using static Tests.TestAsserts; + +namespace Tests { + + // Tests for mutation operations of Firestore: set, update, mutating fieldValue, etc. + public class MutationTests : FirestoreIntegrationTests { + [UnityTest] + public IEnumerator TestDeleteDocument() { + DocumentReference doc = TestDocument(); + var data = new Dictionary { + { "f1", "v1" }, + }; + + yield return AwaitSuccess(doc.SetAsync(data)); + + var getTask = doc.GetSnapshotAsync(); + yield return AwaitSuccess(getTask); + + DocumentSnapshot snap = getTask.Result; + Assert.That(snap.Exists, "Written document should exist"); + + var deleteTask = doc.DeleteAsync(); + yield return AwaitSuccess(deleteTask); + + getTask = doc.GetSnapshotAsync(); + yield return AwaitSuccess(getTask); + + snap = getTask.Result; + Assert.That(!snap.Exists, "Deleted document should not exist"); + Assert.That(snap.ToDictionary(), Is.Null); + } + + [UnityTest] + public IEnumerator TestWriteDocument() { + DocumentReference doc = TestDocument(); + Dictionary data = TestData(); + + yield return AwaitSuccess(doc.SetAsync(data)); + var getTask = doc.GetSnapshotAsync(); + yield return AwaitSuccess(getTask); + + DocumentSnapshot snap = getTask.Result; + Assert.That(snap.ToDictionary(), Is.EquivalentTo(data)); + } + + [UnityTest] + public IEnumerator TestWriteDocumentViaCollection() { + var addTask = TestCollection().AddAsync(TestData()); + yield return AwaitSuccess(addTask); + + var getTask = addTask.Result.GetSnapshotAsync(); + yield return AwaitSuccess(getTask); + + DocumentSnapshot snap = getTask.Result; + Assert.That(snap.ToDictionary(), Is.EquivalentTo(TestData())); + } + + [UnityTest] + public IEnumerator TestWriteInvalidDocumentFails() { + var collectionWithInvalidName = TestCollection().Document("__badpath__").Collection("sub"); + var addTask = collectionWithInvalidName.AddAsync(TestData()); + yield return AwaitFaults(addTask); + } + + [UnityTest] + public IEnumerator TestWriteDocumentWithIntegersSaveAsLongs() { + DocumentReference doc = db.Collection("col2").Document(); + var data = new Dictionary { + { "f1", 2 }, + { "map", + new Dictionary { + { "nested f3", 4 }, + } }, + }; + var expected = new Dictionary { + { "f1", 2L }, + { "map", + new Dictionary { + { "nested f3", 4L }, + } }, + }; + + yield return AwaitSuccess(doc.SetAsync(data)); + var getTask = doc.GetSnapshotAsync(); + yield return AwaitSuccess(getTask); + + var actual = getTask.Result.ToDictionary(); + Assert.That(actual, Is.EquivalentTo(expected)); + } + + [UnityTest] + public IEnumerator TestUpdateDocument() { + DocumentReference doc = TestDocument(); + var data = TestData(); + var updateData = + new Dictionary { { "name", "foo" }, { "metadata.createdAt", 42L } }; + var expected = TestData(); + expected["name"] = "foo"; + ((Dictionary)expected["metadata"])["createdAt"] = 42L; + + yield return AwaitSuccess(doc.SetAsync(data)); + yield return AwaitSuccess(doc.UpdateAsync(updateData)); + var getTask = doc.GetSnapshotAsync(); + yield return AwaitSuccess(getTask); + DocumentSnapshot snap = getTask.Result; + + var actual = snap.ToDictionary(); + Assert.That(actual, Is.EquivalentTo(expected)); + } + + [UnityTest] + // See b/174676322 for why this test is added. + public IEnumerator TestMultipleDeletesInOneUpdate() { + DocumentReference doc = TestDocument(); + var setTask = doc.SetAsync(new Dictionary { + { "key1", "value1" }, + { "key2", "value2" }, + { "key3", "value3" }, + { "key4", "value4" }, + { "key5", "value5" }, + }); + yield return AwaitSuccess(setTask); + + var updateTask = doc.UpdateAsync(new Dictionary { + { "key1", FieldValue.Delete }, + { "key3", FieldValue.Delete }, + { "key5", FieldValue.Delete }, + }); + yield return AwaitSuccess(updateTask); + + var getTask = doc.GetSnapshotAsync(Source.Cache); + yield return AwaitSuccess(getTask); + DocumentSnapshot snapshot = getTask.Result; + var expected = new Dictionary { + { "key2", "value2" }, + { "key4", "value4" }, + }; + Assert.That(snapshot.ToDictionary(), Is.EquivalentTo(expected)); + } + + [UnityTest] + public IEnumerator TestUpdateFieldInDocument() { + DocumentReference doc = TestDocument(); + var data = new Dictionary { + { "f1", "v1" }, + { "f2", "v2" }, + }; + + yield return AwaitSuccess(doc.SetAsync(data)); + yield return AwaitSuccess(doc.UpdateAsync("f2", "v2b")); + + var getTask = doc.GetSnapshotAsync(); + yield return AwaitSuccess(getTask); + var actual = getTask.Result.ToDictionary(); + var expected = new Dictionary { + { "f1", "v1" }, + { "f2", "v2b" }, + }; + Assert.That(actual, Is.EquivalentTo(expected)); + } + + [UnityTest] + public IEnumerator TestCreateViaArrayUnion() { + DocumentReference doc = TestDocument(); + var data = new Dictionary { { "array", FieldValue.ArrayUnion(1L, 2L) } }; + yield return AwaitSuccess(doc.SetAsync(data)); + yield return AssertExpectedDocument( + doc, new Dictionary { { "array", new List { 1L, 2L } } }); + } + + [UnityTest] + public IEnumerator TestAppendViaUpdateArrayUnion() { + DocumentReference doc = TestDocument(); + var data = new Dictionary { { "array", FieldValue.ArrayUnion(1L, 2L) } }; + yield return AwaitSuccess(doc.SetAsync(data)); + + data = new Dictionary { { "array", FieldValue.ArrayUnion(1L, 4L) } }; + yield return AwaitSuccess(doc.UpdateAsync(data)); + yield return AssertExpectedDocument( + doc, new Dictionary { { "array", new List { 1L, 2L, 4L } } }); + } + + [UnityTest] + public IEnumerator TestAppendViaSetMergeArrayUnion() { + DocumentReference doc = TestDocument(); + var data = new Dictionary { { "array", FieldValue.ArrayUnion(1L, 2L) } }; + yield return AwaitSuccess(doc.SetAsync(data)); + + data = new Dictionary { { "array", FieldValue.ArrayUnion(2L, 3L) } }; + yield return AwaitSuccess(doc.SetAsync(data, SetOptions.MergeAll)); + yield return AssertExpectedDocument( + doc, new Dictionary { { "array", new List { 1L, 2L, 3L } } }); + } + + [UnityTest] + public IEnumerator TestAppendObjectViaUpdateArrayUnion() { + DocumentReference doc = TestDocument(); + var data = new Dictionary { { "array", FieldValue.ArrayUnion(1L, 2L) } }; + yield return AwaitSuccess(doc.SetAsync(data)); + + data = new Dictionary { + { "array", FieldValue.ArrayUnion(1L, new Dictionary { { "a", "value" } }) } + }; + AwaitSuccess(doc.UpdateAsync(data)); + yield return AssertExpectedDocument(doc, new Dictionary { + { "array", + new List { 1L, 2L, new Dictionary { { "a", "value" } } } } + }); + } + + [UnityTest] + public IEnumerator TestRemoveViaUpdateArrayRemove() { + DocumentReference doc = TestDocument(); + var data = new Dictionary { { "array", FieldValue.ArrayUnion(1L, 2L) } }; + yield return AwaitSuccess(doc.SetAsync(data)); + + data = new Dictionary { { "array", FieldValue.ArrayRemove(1L, 4L) } }; + AwaitSuccess(doc.UpdateAsync(data)); + yield return AssertExpectedDocument( + doc, new Dictionary { { "array", new List { 2L } } }); + } + + [UnityTest] + public IEnumerator TestRemoveViaSetMergeArrayRemove() { + DocumentReference doc = TestDocument(); + var data = new Dictionary { { "array", FieldValue.ArrayUnion(1L, 2L, 3L) } }; + yield return AwaitSuccess(doc.SetAsync(data)); + + data = new Dictionary { { "array", FieldValue.ArrayRemove(1L, 3L) } }; + AwaitSuccess(doc.SetAsync(data, SetOptions.MergeAll)); + yield return AssertExpectedDocument( + doc, new Dictionary { { "array", new List { 2L } } }); + } + + [UnityTest] + public IEnumerator TestRemoveObjectsViaUpdateArrayRemove() { + DocumentReference doc = TestDocument(); + var data = new Dictionary { + { "array", + FieldValue.ArrayUnion(1L, new Dictionary { { "a", "value" } }, 3L) } + }; + yield return AwaitSuccess(doc.SetAsync(data)); + + data = new Dictionary { + { "array", FieldValue.ArrayRemove(new Dictionary { { "a", "value" } }) } + }; + AwaitSuccess(doc.UpdateAsync(data)); + yield return AssertExpectedDocument( + doc, new Dictionary { { "array", new List { 1L, 3L } } }); + } + + [UnityTest] + public IEnumerator TestUpdateFieldPath() { + DocumentReference doc = TestDocument(); + var data = new Dictionary { + { "f1", "v1" }, + { "f2", + new Dictionary { + { "a", + new Dictionary { + { "b", + new Dictionary { + { "c", "v2" }, + } }, + } }, + } }, + }; + + var updateData = new Dictionary { + { new FieldPath("f2", "a", "b", "c"), "v2b" }, + { new FieldPath("f2", "x", "y", "z"), "v3" }, + }; + + var expected = new Dictionary { + { "f1", "v1" }, + { "f2", + new Dictionary { + { "a", + new Dictionary { + { "b", + new Dictionary { + { "c", "v2b" }, + } }, + } }, + { "x", + new Dictionary { + { "y", + new Dictionary { + { "z", "v3" }, + } }, + } }, + } }, + }; + + yield return AwaitSuccess(doc.SetAsync(data)); + yield return AwaitSuccess(doc.UpdateAsync(updateData)); + var getTask = doc.GetSnapshotAsync(); + yield return AwaitSuccess(getTask); + + var actual = getTask.Result.ToDictionary(); + Assert.That(actual, Is.EquivalentTo(expected)); + } + + [UnityTest] + public IEnumerator TestSetOptions() { + DocumentReference doc = TestDocument(); + var initialData = new Dictionary { + { "field1", "value1" }, + }; + + var set1 = new Dictionary { { "field2", "value2" } }; + var setOptions1 = SetOptions.MergeAll; + + var set2 = + new Dictionary { { "field3", "value3" }, { "not-field4", "not-value4" } }; + var setOptions2 = SetOptions.MergeFields("field3"); + + var set3 = + new Dictionary { { "field4", "value4" }, { "not-field5", "not-value5" } }; + var setOptions3 = SetOptions.MergeFields(new FieldPath("field4")); + + var expected = new Dictionary { + { "field1", "value1" }, + { "field2", "value2" }, + { "field3", "value3" }, + { "field4", "value4" }, + }; + + yield return AwaitSuccess(doc.SetAsync(initialData)); + yield return AwaitSuccess(doc.SetAsync(set1, setOptions1)); + yield return AwaitSuccess( + doc.Firestore.StartBatch().Set(doc, set2, setOptions2).CommitAsync()); + yield return AwaitSuccess(db.RunTransactionAsync(transaction => { + transaction.Set(doc, set3, setOptions3); + return Task.CompletedTask; + })); + + var getTask = doc.GetSnapshotAsync(); + yield return AwaitSuccess(getTask); + Assert.That(getTask.Result.ToDictionary(), Is.EquivalentTo(expected)); + } + } +} diff --git a/firestore/testapp/Assets/Tests/ObjectMappingTests.cs b/firestore/testapp/Assets/Tests/ObjectMappingTests.cs new file mode 100644 index 000000000..5fa7bba7b --- /dev/null +++ b/firestore/testapp/Assets/Tests/ObjectMappingTests.cs @@ -0,0 +1,167 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; +using System.Threading; +using System.Threading.Tasks; +using Firebase.Firestore; +using NUnit.Framework; +using UnityEngine.TestTools; +using static Tests.TestAsserts; + +namespace Tests { + public class ObjectMappingTests : FirestoreIntegrationTests { + [UnitySetUp] + public IEnumerator DisableNetworkBeforeRunningTests() { + // All tests verify features that do not rely on network/backend, disabling it + // to make the tests run faster. + yield return AwaitSuccess(db.DisableNetworkAsync()); + } + + [UnityTearDown] + public IEnumerator ReEnableNetworkAfterRunningTests() { + yield return AwaitSuccess(db.EnableNetworkAsync()); + } + + [UnityTest] + public IEnumerator ObjectMapping_ShouldWork() { + DocumentReference doc = TestDocument(); + + foreach (SerializationTestData.TestCase test in SerializationTestData.TestData( + doc.Firestore)) { + // Write input to `doc` via serialization + SerializeToDoc(doc, test.Input); + var getTask = doc.GetSnapshotAsync(Source.Cache); + yield return AwaitSuccess(getTask); + DocumentSnapshot docSnap = getTask.Result; + + // Read `doc` back via deserialization with both Firestore Types and input types + object actualOutputWithRawFirestoreTypes, actualOutputWithInputTypes; + DeserializeDoc(docSnap, test.Input, out actualOutputWithRawFirestoreTypes, + out actualOutputWithInputTypes); + + Assert.That(actualOutputWithRawFirestoreTypes, Is.EqualTo(test.ExpectedRawOutput), + "Deserialized value with Firestore Raw types does not match expected"); + Assert.That(actualOutputWithInputTypes, Is.EqualTo(test.Input), + "Deserialized value with input types does not match the input"); + } + } + + [UnityTest] + public IEnumerator ObjectMapping_ShouldThrowForUnsupportedData() { + DocumentReference doc = TestDocument(); + + foreach (SerializationTestData.TestCase test in SerializationTestData.UnsupportedTestData()) { + object actualWithInputTypes; + Assert.Throws(typeof(NotSupportedException), () => SerializeToDoc(doc, test.Input)); + + // Write the doc with expected output, then deserialize it back to input type. + SerializeToDoc(doc, test.ExpectedRawOutput); + Task getTask = doc.GetSnapshotAsync(Source.Cache); + yield return AwaitSuccess(getTask); + var exception = Assert.Throws(() => { + DeserializeWithInputTypes(getTask.Result, test.Input, out actualWithInputTypes); + }); + Assert.That(exception.InnerException, Is.TypeOf()); + } + } + + [UnityTest] + public IEnumerator ObjectMapping_ShouldThrowForUnsupportedReadToInputTypesData() { + DocumentReference doc = TestDocument(); + + foreach (SerializationTestData.TestCase test in SerializationTestData + .UnsupportedReadToInputTypesTestData()) { + object actualWithFirestoreRawTypes, actualWithInputTypes; + + SerializeToDoc(doc, test.Input); + + Task getTask = doc.GetSnapshotAsync(Source.Cache); + yield return AwaitSuccess(getTask); + DeserializeWithRawFirestoreTypes(getTask.Result, out actualWithFirestoreRawTypes); + Assert.That(actualWithFirestoreRawTypes, Is.EqualTo(test.ExpectedRawOutput), + "Deserialized value with Firestore Raw types does not match expected"); + + var exception = Assert.Throws(() => { + DeserializeWithInputTypes(getTask.Result, test.Input, out actualWithInputTypes); + }); + Assert.That(exception.InnerException, Is.TypeOf()); + } + } + + private void DeserializeDoc(DocumentSnapshot snapshot, object input, out object nativeOutput, + out object convertedOutput) { + DeserializeWithRawFirestoreTypes(snapshot, out nativeOutput); + + DeserializeWithInputTypes(snapshot, input, out convertedOutput); + } + + private static void SerializeToDoc(DocumentReference doc, object input) { + // Wrap in a dictionary so we can write it as a document even if input is a primitive type. + var docData = new Dictionary { { "field", input } }; + // The returning task completes when receiving backend acknowledgement, we need to ignore this + // because we are offline. + doc.SetAsync(docData); + } + + private static void DeserializeWithRawFirestoreTypes(DocumentSnapshot snapshot, + out object rawOutput) { + rawOutput = snapshot.GetValue("field"); + } + + private static void DeserializeWithInputTypes(DocumentSnapshot snapshot, object input, + out object outputWithInputTypes) { + // To get the converted value out, we have to use reflection to call GetValue<> with + // input.GetType() as the generic parameter. + MethodInfo method = + typeof(DocumentSnapshot) + .GetMethod("GetValue", + new Type[] { typeof(string), typeof(ServerTimestampBehavior) }); + MethodInfo genericMethod = + method.MakeGenericMethod(input != null ? input.GetType() : typeof(object)); + outputWithInputTypes = + genericMethod.Invoke(snapshot, new object[] { "field", ServerTimestampBehavior.None }); + } + + // Unity on iOS can't JIT compile code, which breaks some usages of + // reflection such as the way DeserializeWithInputTypes method calls the + // DocumentSnapshot.GetValue<>() method with dynamic generic types. As a + // workaround, we have to enumerate all the different versions that we need. + // Normal users won't have to do this. + // See https://docs.unity3d.com/Manual/ScriptingRestrictions.html for more details. + private void UnityCompileHack() { + // NOTE: This never actually runs. It just forces the compiler to generate + // the code we need. + DocumentSnapshot x = null; + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue(""); + x.GetValue>(""); + } + } +} \ No newline at end of file diff --git a/firestore/testapp/Assets/Tests/QueryAndListenerTests.cs b/firestore/testapp/Assets/Tests/QueryAndListenerTests.cs new file mode 100644 index 000000000..f2f98212f --- /dev/null +++ b/firestore/testapp/Assets/Tests/QueryAndListenerTests.cs @@ -0,0 +1,1064 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Firebase; +using Firebase.Extensions; +using Firebase.Firestore; +using UnityEngine.TestTools; +using Firebase.Sample.Firestore; +using NUnit.Framework; +using UnityEngine; +using static Tests.TestAsserts; + +namespace Tests { + public class QueryAndListenerTests : FirestoreIntegrationTests { + [UnityTest] + public IEnumerator TestListenForSnapshotsInSync() { + var events = new List(); + + var doc = TestDocument(); + var docAccumulator = new EventAccumulator(mainThreadId); + var docListener = doc.Listen(snapshot => { + events.Add("doc"); + docAccumulator.Listener(snapshot); + }); + + yield return AwaitSuccess(doc.SetAsync(TestData(1))); + + yield return AwaitSuccess(docAccumulator.LastEventAsync()); + events.Clear(); + + var syncAccumulator = new EventAccumulator(); + var syncListener = doc.Firestore.ListenForSnapshotsInSync(() => { + events.Add("sync"); + syncAccumulator.Listener("sync"); + }); + + // Ensure that the Task from the ListenerRegistration is in the correct state. + AssertTaskIsPending(syncListener.ListenerTask); + + yield return AwaitSuccess(doc.SetAsync(TestData(2))); + + yield return AwaitSuccess(docAccumulator.LastEventAsync()); + yield return AwaitSuccess(syncAccumulator.LastEventsAsync(2)); + + var expectedEvents = new List { + "sync", // Initial in-sync event + "doc", // From the Set() + "sync" // Another in-sync event + }; + + docListener.Stop(); + syncListener.Stop(); + yield return AwaitSuccess(syncListener.ListenerTask); + Assert.That(events, Is.EquivalentTo(expectedEvents)); + } + + [UnityTest] + public IEnumerator TestMultiInstanceDocumentReferenceListeners() { + var db1Doc = TestDocument(); + var db1 = db1Doc.Firestore; + var app1 = db1.App; + + var app2 = FirebaseApp.Create(app1.Options, "MultiInstanceDocumentReferenceListenersTest"); + var db2 = FirebaseFirestore.GetInstance(app2); + var db2Doc = db2.Collection(db1Doc.Parent.Id).Document(db1Doc.Id); + + var db1DocAccumulator = new EventAccumulator(); + db1Doc.Listen(db1DocAccumulator.Listener); + yield return AwaitSuccess(db1DocAccumulator.LastEventAsync()); + + var db2DocAccumulator = new EventAccumulator(); + db2Doc.Listen(db2DocAccumulator.Listener); + yield return AwaitSuccess(db2DocAccumulator.LastEventAsync()); + + // At this point we have two firestore instances and separate listeners attached to each one + // and all are in an idle state. Once the second instance is disposed the listeners on the + // first instance should continue to operate normally and the listeners on the second instance + // should not receive any more events. + db2DocAccumulator.ThrowOnAnyEvent(); + + app2.Dispose(); + yield return AwaitFaults(db2Doc.SetAsync(TestData(3))); + + yield return AwaitSuccess(db1Doc.SetAsync(TestData(3))); + yield return AwaitSuccess(db1DocAccumulator.LastEventAsync()); + } + + [UnityTest] + public IEnumerator TestMultiInstanceQueryListeners() { + var db1Collection = TestCollection(); + var db1 = db1Collection.Firestore; + var app1 = db1.App; + + var app2 = FirebaseApp.Create(app1.Options, "MultiInstanceQueryListenersTest"); + var db2 = FirebaseFirestore.GetInstance(app2); + var db2Collection = db2.Collection(db1Collection.Id); + + var db1CollectionAccumulator = new EventAccumulator(); + db1Collection.Listen(db1CollectionAccumulator.Listener); + yield return AwaitSuccess(db1CollectionAccumulator.LastEventAsync()); + + var db2CollectionAccumulator = new EventAccumulator(); + db2Collection.Listen(db2CollectionAccumulator.Listener); + yield return AwaitSuccess(db2CollectionAccumulator.LastEventAsync()); + + // At this point we have two firestore instances and separate listeners + // attached to each one and all are in an idle state. Once the second + // instance is disposed the listeners on the first instance should + // continue to operate normally and the listeners on the second + // instance should not receive any more events. + + db2CollectionAccumulator.ThrowOnAnyEvent(); + + app2.Dispose(); + yield return AwaitFaults(db2Collection.Document().SetAsync(TestData(1))); + + yield return AwaitSuccess(db1Collection.Document().SetAsync(TestData(1))); + yield return AwaitSuccess(db1CollectionAccumulator.LastEventAsync()); + } + + [UnityTest] + public IEnumerator TestMultiInstanceSnapshotsInSyncListeners() { + var db1Doc = TestDocument(); + var db1 = db1Doc.Firestore; + var app1 = db1.App; + + var app2 = FirebaseApp.Create(app1.Options, "MultiInstanceSnapshotsInSyncTest"); + var db2 = FirebaseFirestore.GetInstance(app2); + var db2Doc = db2.Collection(db1Doc.Parent.Id).Document(db1Doc.Id); + + var db1SyncAccumulator = new EventAccumulator(); + var db1SyncListener = + db1.ListenForSnapshotsInSync(() => { db1SyncAccumulator.Listener("db1 in sync"); }); + yield return AwaitSuccess(db1SyncAccumulator.LastEventAsync()); + + var db2SyncAccumulator = new EventAccumulator(); + db2.ListenForSnapshotsInSync(() => { db2SyncAccumulator.Listener("db2 in sync"); }); + yield return AwaitSuccess(db2SyncAccumulator.LastEventAsync()); + + db1Doc.Listen((snap) => {}); + yield return AwaitSuccess(db1SyncAccumulator.LastEventAsync()); + + db2Doc.Listen((snap) => {}); + yield return AwaitSuccess(db2SyncAccumulator.LastEventAsync()); + + // At this point we have two firestore instances and separate listeners + // attached to each one and all are in an idle state. Once the second + // instance is disposed the listeners on the first instance should + // continue to operate normally and the listeners on the second + // instance should not receive any more events. + + db2SyncAccumulator.ThrowOnAnyEvent(); + + app2.Dispose(); + yield return AwaitFaults(db2Doc.SetAsync(TestData(2))); + + yield return AwaitSuccess(db1Doc.SetAsync(TestData(2))); + yield return AwaitSuccess(db1SyncAccumulator.LastEventAsync()); + } + + [UnityTest] + public IEnumerator TestDocumentSnapshot() { + DocumentReference doc = db.Collection("col2").Document(); + var data = TestData(); + + yield return AwaitSuccess(doc.SetAsync(data)); + var task = doc.GetSnapshotAsync(); + yield return AwaitSuccess(task); + var snap = task.Result; + + VerifyDocumentSnapshotGetValueWorks(snap, data); + VerifyDocumentSnapshotTryGetValueWorks(snap, data); + VerifyDocumentSnapshotContainsFieldWorks(snap, data); + } + + private void VerifyDocumentSnapshotGetValueWorks(DocumentSnapshot snap, + Dictionary data) { + Assert.That(snap.GetValue("name"), Is.EqualTo(data["name"])); + Assert.That(snap.GetValue>("metadata"), + Is.EquivalentTo(data["metadata"] as IEnumerable), + "Resulting data.metadata does not match."); + Assert.That(snap.GetValue("metadata.deep.field"), Is.EqualTo("deep-field-1")); + Assert.That(snap.GetValue(new FieldPath("metadata", "deep", "field")), + Is.EqualTo("deep-field-1")); + // Nonexistent field. + Assert.Throws(typeof(InvalidOperationException), () => snap.GetValue("nonexistent")); + // Existent field deserialized to wrong type. + Assert.Throws(typeof(ArgumentException), () => snap.GetValue("name")); + } + + private void VerifyDocumentSnapshotTryGetValueWorks(DocumentSnapshot snap, + Dictionary data) { + // Existent field. + String name; + Assert.That(snap.TryGetValue("name", out name), Is.True); + Assert.That(name, Is.EqualTo(data["name"])); + + // Nonexistent field. + Assert.That(snap.TryGetValue("namex", out name), Is.False); + Assert.That(name, Is.Null); + + // Existent field deserialized to wrong type. + Assert.Throws(typeof(ArgumentException), () => { + long l; + snap.TryGetValue("name", out l); + }); + } + + private void VerifyDocumentSnapshotContainsFieldWorks(DocumentSnapshot snap, + Dictionary data) { + // Existent fields. + Assert.That(snap.ContainsField("name"), Is.True); + Assert.That(snap.ContainsField("metadata.deep.field"), Is.True); + Assert.That(snap.ContainsField(new FieldPath("metadata", "deep", "field")), Is.True); + + // Nonexistent field. + Assert.That(snap.ContainsField("namex"), Is.False); + } + + [UnityTest] + public IEnumerator TestDocumentSnapshotServerTimestampBehavior() { + DocumentReference doc = db.Collection("col2").Document(); + + // Disable network so we can test unresolved server timestamp behavior. + yield return AwaitSuccess(doc.Firestore.DisableNetworkAsync()); + + doc.SetAsync(new Dictionary { { "timestamp", "prev" } }); + doc.SetAsync(new Dictionary { { "timestamp", FieldValue.ServerTimestamp } }); + + Task task = doc.GetSnapshotAsync(); + yield return AwaitSuccess(task); + var snap = task.Result; + + // Default / None should return null. + Assert.That(snap.ToDictionary()["timestamp"], Is.Null); + Assert.That(snap.GetValue("timestamp"), Is.Null); + Assert.That(snap.ToDictionary(ServerTimestampBehavior.None)["timestamp"], Is.Null); + Assert.That(snap.GetValue("timestamp", ServerTimestampBehavior.None), Is.Null); + + // Previous should be "prev" + Assert.That(snap.ToDictionary(ServerTimestampBehavior.Previous)["timestamp"], + Is.EqualTo("prev")); + Assert.That(snap.GetValue("timestamp", ServerTimestampBehavior.Previous), + Is.EqualTo("prev")); + + // Estimate should be a timestamp. + Assert.That(snap.ToDictionary(ServerTimestampBehavior.Estimate)["timestamp"], + Is.TypeOf(typeof(Timestamp)), "Estimate should be a Timestamp"); + Assert.That(snap.GetValue("timestamp", ServerTimestampBehavior.Estimate), + Is.TypeOf(typeof(Timestamp)), "Estimate should be a Timestamp"); + + yield return AwaitSuccess(doc.Firestore.EnableNetworkAsync()); + } + + [UnityTest] + public IEnumerator TestDocumentSnapshotIntegerIncrementBehavior() { + DocumentReference doc = TestDocument(); + + var data = TestData(); + yield return AwaitSuccess(doc.SetAsync(data)); + + var incrementValue = FieldValue.Increment(1L); + + var updateData = new Dictionary { { "metadata.createdAt", incrementValue } }; + + yield return AwaitSuccess(doc.UpdateAsync(updateData)); + var t = doc.GetSnapshotAsync(); + yield return AwaitSuccess(t); + DocumentSnapshot snap = t.Result; + + var expected = TestData(); + ((Dictionary)expected["metadata"])["createdAt"] = 2L; + + Assert.That(snap.ToDictionary(), Is.EquivalentTo(expected)); + } + + [UnityTest] + public IEnumerator TestDocumentSnapshotDoubleIncrementBehavior() { + DocumentReference doc = TestDocument(); + + var data = TestData(); + yield return AwaitSuccess(doc.SetAsync(data)); + + var incrementValue = FieldValue.Increment(1.5); + + var updateData = new Dictionary { { "metadata.createdAt", incrementValue } }; + + yield return AwaitSuccess(doc.UpdateAsync(updateData)); + var t = doc.GetSnapshotAsync(); + yield return AwaitSuccess(t); + DocumentSnapshot snap = t.Result; + + var expected = TestData(); + ((Dictionary)expected["metadata"])["createdAt"] = 2.5; + + Assert.That(snap.ToDictionary(), Is.EquivalentTo(expected)); + } + + [UnityTest] + public IEnumerator TestDocumentListen() { + var doc = TestDocument(); + var initialData = TestData(1); + var newData = TestData(2); + + yield return AwaitSuccess(doc.SetAsync(initialData)); + + var accumulator = new EventAccumulator(mainThreadId); + var registration = doc.Listen(accumulator.Listener); + + // Ensure that the Task from the ListenerRegistration is in the correct state. + AssertTaskIsPending(registration.ListenerTask); + + // Wait for the first snapshot. + { + var lastEventTask = accumulator.LastEventAsync(); + yield return AwaitSuccess(lastEventTask); + DocumentSnapshot snapshot = lastEventTask.Result; + Assert.That(snapshot.ToDictionary(), Is.EquivalentTo(initialData)); + Assert.That(snapshot.Metadata.IsFromCache, Is.True); + Assert.That(snapshot.Metadata.HasPendingWrites, Is.False); + } + + // Write new data and wait for the resulting snapshot. + { + doc.SetAsync(newData); + var lastEventTask = accumulator.LastEventAsync(); + yield return AwaitSuccess(lastEventTask); + DocumentSnapshot snapshot = lastEventTask.Result; + Assert.That(snapshot.ToDictionary(), Is.EquivalentTo(newData)); + Assert.That(snapshot.Metadata.HasPendingWrites, Is.True); + } + + { + // Remove the listener and make sure we don't get events anymore. + accumulator.ThrowOnAnyEvent(); + registration.Stop(); + AssertTaskSucceeded(registration.ListenerTask); + yield return AwaitSuccess(doc.SetAsync(TestData(3))); + + // Ensure that the Task from the ListenerRegistration correctly fails with an error. + var docWithInvalidName = TestCollection().Document("__badpath__"); + var callbackInvoked = false; + var registration2 = docWithInvalidName.Listen(snap => { callbackInvoked = true; }); + yield return AwaitCompletion(registration2.ListenerTask); + AssertTaskFaulted(registration2.ListenerTask, FirestoreError.InvalidArgument, + "__badpath__"); + registration2.Stop(); + Thread.Sleep(50); + Assert.That(callbackInvoked, Is.False); + } + } + + [UnityTest] + public IEnumerator DocumentSnapshot_ShouldReturnCorrectMetadataChanges() { + var doc = TestDocument(); + var initialData = TestData(1); + var newData = TestData(2); + + yield return AwaitSuccess(doc.SetAsync(initialData)); + + var accumulator = new EventAccumulator(); + var registration = doc.Listen(MetadataChanges.Include, accumulator.Listener); + + // Ensure that the Task from the ListenerRegistration is in the correct state. + AssertTaskIsPending(registration.ListenerTask); + + // Wait for the first snapshot. + { + var lastEventTask = accumulator.LastEventAsync(); + yield return AwaitSuccess(lastEventTask); + DocumentSnapshot snapshot = lastEventTask.Result; + Assert.That(snapshot.ToDictionary(), Is.EquivalentTo(initialData)); + Assert.That(snapshot.Metadata.IsFromCache, Is.True); + Assert.That(snapshot.Metadata.HasPendingWrites, Is.False); + } + + // Wait for new snapshot once we're synced with the backend. + { + var lastEventTask = accumulator.LastEventAsync(); + yield return AwaitSuccess(lastEventTask); + DocumentSnapshot snapshot = lastEventTask.Result; + Assert.That(snapshot.ToDictionary(), Is.EquivalentTo(initialData)); + Assert.That(snapshot.Metadata.IsFromCache, Is.False); + Assert.That(snapshot.Metadata.HasPendingWrites, Is.False); + } + + // Write new data and wait for the resulting snapshot. + { + doc.SetAsync(newData); + var lastEventTask = accumulator.LastEventAsync(); + yield return AwaitSuccess(lastEventTask); + DocumentSnapshot snapshot = lastEventTask.Result; + Assert.That(snapshot.ToDictionary(), Is.EquivalentTo(newData)); + Assert.That(snapshot.Metadata.IsFromCache, Is.False); + Assert.That(snapshot.Metadata.HasPendingWrites, Is.True); + } + + // Wait for new snapshot once write completes. + { + var lastEventTask = accumulator.LastEventAsync(); + yield return AwaitSuccess(lastEventTask); + DocumentSnapshot snapshot = lastEventTask.Result; + Assert.That(snapshot.Metadata.HasPendingWrites, Is.False); + } + + { + // Remove the listener and make sure we don't get events anymore. + accumulator.ThrowOnAnyEvent(); + registration.Stop(); + AssertTaskSucceeded(registration.ListenerTask); + yield return AwaitSuccess(doc.SetAsync(TestData(3))); + + // Ensure that the Task from the ListenerRegistration correctly fails with an error. + var docWithInvalidName = TestCollection().Document("__badpath__"); + var callbackInvoked = false; + var registration2 = + docWithInvalidName.Listen(MetadataChanges.Include, snap => { callbackInvoked = true; }); + yield return AwaitCompletion(registration2.ListenerTask); + AssertTaskFaulted(registration2.ListenerTask, FirestoreError.InvalidArgument, + "__badpath__"); + registration2.Stop(); + Thread.Sleep(50); + Assert.That(callbackInvoked, Is.False); + } + } + + [UnityTest] + public IEnumerator QuerySnapshot_ShouldReturnCorrectData() { + var collection = TestCollection(); + var data1 = TestData(1); + var data2 = TestData(2); + + yield return AwaitSuccess(collection.Document("a").SetAsync(data1)); + + var accumulator = new EventAccumulator(mainThreadId); + var registration = collection.Listen(accumulator.Listener); + + // Ensure that the Task from the ListenerRegistration is in the correct state. + AssertTaskIsPending(registration.ListenerTask); + + // Wait for the first snapshot. + { + var lastEventTask = accumulator.LastEventAsync(); + yield return AwaitSuccess(lastEventTask); + QuerySnapshot snapshot = lastEventTask.Result; + Assert.That(snapshot.Count, Is.EqualTo(1)); + Assert.That(snapshot[0].ToDictionary(), Is.EquivalentTo(data1)); + Assert.That(snapshot.Metadata.IsFromCache, Is.True); + Assert.That(snapshot.Metadata.HasPendingWrites, Is.False); + } + + // Write a new document and wait for the resulting snapshot. + { + collection.Document("b").SetAsync(data2); + var lastEventTask = accumulator.LastEventAsync(); + yield return AwaitSuccess(lastEventTask); + QuerySnapshot snapshot = lastEventTask.Result; + Assert.That(snapshot.Count, Is.EqualTo(2)); + Assert.That(snapshot[0].ToDictionary(), Is.EquivalentTo(data1)); + Assert.That(snapshot[1].ToDictionary(), Is.EquivalentTo(data2)); + Assert.That(snapshot.Metadata.HasPendingWrites, Is.True); + } + + { + // Remove the listener and make sure we don't get events anymore + accumulator.ThrowOnAnyEvent(); + registration.Stop(); + AssertTaskSucceeded(registration.ListenerTask); + yield return AwaitSuccess(collection.Document("c").SetAsync(TestData(3))); + + // Ensure that the Task from the ListenerRegistration correctly fails with an error. + var collectionWithInvalidName = TestCollection().Document("__badpath__").Collection("sub"); + var callbackInvoked = false; + var registration2 = collectionWithInvalidName.Listen(snap => { callbackInvoked = true; }); + yield return AwaitCompletion(registration2.ListenerTask); + AssertTaskFaulted(registration2.ListenerTask, FirestoreError.InvalidArgument, + "__badpath__"); + registration2.Stop(); + Thread.Sleep(50); + Assert.That(callbackInvoked, Is.False); + } + } + + [UnityTest] + public IEnumerator QuerySnapshot_ShouldReturnCorrectMetadata() { + var collection = TestCollection(); + + var data1 = TestData(1); + var data2 = TestData(2); + + yield return AwaitSuccess(collection.Document("a").SetAsync(data1)); + + var accumulator = new EventAccumulator(); + var registration = collection.Listen(MetadataChanges.Include, accumulator.Listener); + + // Ensure that the Task from the ListenerRegistration is in the correct state. + AssertTaskIsPending(registration.ListenerTask); + + // Wait for the first snapshot. + { + var lastEventTask = accumulator.LastEventAsync(); + yield return AwaitSuccess(lastEventTask); + QuerySnapshot snapshot = lastEventTask.Result; + Assert.That(snapshot.Count, Is.EqualTo(1)); + Assert.That(snapshot[0].ToDictionary(), Is.EquivalentTo(data1)); + Assert.That(snapshot.Metadata.IsFromCache, Is.True); + Assert.That(snapshot.Metadata.HasPendingWrites, Is.False); + } + + // Wait for new snapshot once we're synced with the backend. + { + var lastEventTask = accumulator.LastEventAsync(); + yield return AwaitSuccess(lastEventTask); + QuerySnapshot snapshot = lastEventTask.Result; + Assert.That(snapshot.Metadata.IsFromCache, Is.False); + } + + // Write a new document and wait for the resulting snapshot. + { + collection.Document("b").SetAsync(data2); + var lastEventTask = accumulator.LastEventAsync(); + yield return AwaitSuccess(lastEventTask); + QuerySnapshot snapshot = lastEventTask.Result; + Assert.That(snapshot.Count, Is.EqualTo(2)); + Assert.That(snapshot[0].ToDictionary(), Is.EquivalentTo(data1)); + Assert.That(snapshot[1].ToDictionary(), Is.EquivalentTo(data2)); + Assert.That(snapshot.Metadata.HasPendingWrites, Is.True); + } + + // Wait for new snapshot once write completes. + { + var lastEventTask = accumulator.LastEventAsync(); + yield return AwaitSuccess(lastEventTask); + QuerySnapshot snapshot = lastEventTask.Result; + Assert.That(snapshot.Metadata.HasPendingWrites, Is.False); + } + + { + // Remove the listener and make sure we don't get events anymore. + accumulator.ThrowOnAnyEvent(); + registration.Stop(); + AssertTaskSucceeded(registration.ListenerTask); + yield return AwaitSuccess(collection.Document("c").SetAsync(TestData(3))); + + // Ensure that the Task from the ListenerRegistration correctly fails with an error. + var collectionWithInvalidName = TestCollection().Document("__badpath__").Collection("sub"); + var callbackInvoked = false; + var registration2 = collectionWithInvalidName.Listen(MetadataChanges.Include, + snap => { callbackInvoked = true; }); + yield return AwaitCompletion(registration2.ListenerTask); + AssertTaskFaulted(registration2.ListenerTask, FirestoreError.InvalidArgument, + "__badpath__"); + registration2.Stop(); + Thread.Sleep(50); + Assert.That(callbackInvoked, Is.False); + } + } + + [UnityTest] + public IEnumerator QuerySnapshot_ShouldChangeCorrectly() { + var collection = TestCollection(); + + var initialData = TestData(1); + var updatedData = TestData(2); + + yield return AwaitSuccess(collection.Document("a").SetAsync(initialData)); + + var accumulator = new EventAccumulator(); + var registration = collection.Listen(MetadataChanges.Include, accumulator.Listener); + + // Wait for the first snapshot. + yield return AwaitSuccess(accumulator.LastEventAsync()); + + // Wait for new snapshot once we're synced with the backend. + yield return AwaitSuccess(accumulator.LastEventAsync()); + + // Update the document and wait for the latency compensated snapshot. + { + collection.Document("a").SetAsync(updatedData); + var lastEventTask = accumulator.LastEventAsync(); + yield return AwaitSuccess(lastEventTask); + QuerySnapshot snapshot = lastEventTask.Result; + Assert.That(snapshot[0].ToDictionary(), Is.EquivalentTo(updatedData)); + Assert.That(snapshot.Metadata.HasPendingWrites, Is.True); + } + + // Wait for backend acknowledged snapshot. + { + var lastEventTask = accumulator.LastEventAsync(); + yield return AwaitSuccess(lastEventTask); + QuerySnapshot snapshot = lastEventTask.Result; + Assert.That(snapshot.Metadata.HasPendingWrites, Is.False); + + var changes = snapshot.GetChanges(); + Assert.That(changes, Is.Empty); + var changesIncludingMetadata = snapshot.GetChanges(MetadataChanges.Include); + var changeList = changesIncludingMetadata.ToList(); + Assert.That(changeList.Count(), Is.EqualTo(1)); + + var changedDocument = changeList.First().Document; + Assert.That(changedDocument.Metadata.HasPendingWrites, Is.False); + } + + { + // Remove the listener and make sure we don't get events anymore. + accumulator.ThrowOnAnyEvent(); + registration.Stop(); + yield return AwaitSuccess(collection.Document("c").SetAsync(TestData(3))); + } + } + + [UnityTest] + public IEnumerator CommonQueries_ShouldWork() { + // Initialize collection with a few test documents to query against. + var collection = TestCollection(); + collection.Document("a").SetAsync(new Dictionary { + { "num", 1 }, + { "state", "created" }, + { "active", true }, + { "nullable", "value" }, + }); + collection.Document("b").SetAsync(new Dictionary { + { "num", 2 }, + { "state", "done" }, + { "active", false }, + { "nullable", null }, + }); + collection.Document("c").SetAsync(new Dictionary { + { "num", 3 }, + { "state", "done" }, + { "active", true }, + { "nullable", null }, + }); + // Put in a nested collection (with same ID) for testing collection group queries. + collection.Document("d") + .Collection(collection.Id) + .Document("d-nested") + .SetAsync(new Dictionary { + { "num", 4 }, + { "state", "created" }, + { "active", false }, + { "nullable", null }, + }); + yield return AwaitSuccess(db.WaitForPendingWritesAsync()); + + yield return AssertQueryResults(desc: "EqualTo", query: collection.WhereEqualTo("num", 1), + docIds: AsList("a")); + yield return AssertQueryResults(desc: "EqualTo (FieldPath)", + query: collection.WhereEqualTo(new FieldPath("num"), 1), + docIds: AsList("a")); + + yield return AssertQueryResults(desc: "NotEqualTo", + query: collection.WhereNotEqualTo("num", 1), + docIds: AsList("b", "c")); + yield return AssertQueryResults(desc: "NotEqualTo (FieldPath)", + query: collection.WhereNotEqualTo(new FieldPath("num"), 1), + docIds: AsList("b", "c")); + yield return AssertQueryResults( + desc: "NotEqualTo (FieldPath) on nullable", + query: collection.WhereNotEqualTo(new FieldPath("nullable"), null), docIds: AsList("a")); + + yield return AssertQueryResults(desc: "LessThanOrEqualTo", + query: collection.WhereLessThanOrEqualTo("num", 2), + docIds: AsList("a", "b")); + yield return AssertQueryResults( + desc: "LessThanOrEqualTo (FieldPath)", + query: collection.WhereLessThanOrEqualTo(new FieldPath("num"), 2), + docIds: AsList("a", "b")); + + yield return AssertQueryResults(desc: "LessThan", query: collection.WhereLessThan("num", 2), + docIds: AsList("a")); + yield return AssertQueryResults(desc: "LessThan (FieldPath)", + query: collection.WhereLessThan(new FieldPath("num"), 2), + docIds: AsList("a")); + + yield return AssertQueryResults(desc: "GreaterThanOrEqualTo", + query: collection.WhereGreaterThanOrEqualTo("num", 2), + docIds: AsList("b", "c")); + yield return AssertQueryResults( + desc: "GreaterThanOrEqualTo (FieldPath)", + query: collection.WhereGreaterThanOrEqualTo(new FieldPath("num"), 2), + docIds: AsList("b", "c")); + + yield return AssertQueryResults( + desc: "GreaterThan", query: collection.WhereGreaterThan("num", 2), docIds: AsList("c")); + yield return AssertQueryResults(desc: "GreaterThan (FieldPath)", + query: collection.WhereGreaterThan(new FieldPath("num"), 2), + docIds: AsList("c")); + + yield return AssertQueryResults( + desc: "two EqualTos", + query: collection.WhereEqualTo("state", "done").WhereEqualTo("active", false), + docIds: AsList("b")); + + yield return AssertQueryResults(desc: "OrderBy, Limit", + query: collection.OrderBy("num").Limit(2), + docIds: AsList("a", "b")); + yield return AssertQueryResults(desc: "OrderBy, Limit (FieldPath)", + query: collection.OrderBy(new FieldPath("num")).Limit(2), + docIds: AsList("a", "b")); + + yield return AssertQueryResults(desc: "OrderByDescending, Limit", + query: collection.OrderByDescending("num").Limit(2), + docIds: AsList("c", "b")); + yield return AssertQueryResults( + desc: "OrderByDescending, Limit (FieldPath)", + query: collection.OrderByDescending(new FieldPath("num")).Limit(2), + docIds: AsList("c", "b")); + + yield return AssertQueryResults( + desc: "StartAfter", query: collection.OrderBy("num").StartAfter(2), docIds: AsList("c")); + yield return AssertQueryResults( + desc: "EndBefore", query: collection.OrderBy("num").EndBefore(2), docIds: AsList("a")); + yield return AssertQueryResults(desc: "StartAt, EndAt", + query: collection.OrderBy("num").StartAt(2).EndAt(2), + docIds: AsList("b")); + + // Collection Group Query + yield return AssertQueryResults(desc: "CollectionGroup", + query: db.CollectionGroup(collection.Id), + docIds: AsList("a", "b", "c", "d-nested")); + } + + private static List AsList(params T[] elements) { + return elements.ToList(); + } + + private IEnumerator AssertQueryResults(string desc, Query query, List docIds) { + var getTask = query.GetSnapshotAsync(); + yield return AwaitSuccess(getTask); + var snapshot = getTask.Result; + + Assert.That(snapshot.AsEnumerable().Select(d => d.Id), Is.EquivalentTo(docIds), + desc + ": Query results"); + } + + [UnityTest] + public IEnumerator LimitToLastWithMirrorQuery_ShouldWork() { + var collection = TestCollection(); + // TODO(b/149105903): Uncomment this line when exception can be raised from SWIG and below. + // Assert.Throws(typeof(InvalidOperationException), () => + // Await(c.LimitToLast(2).GetSnapshotAsync()) + + // Initialize data with a few test documents to query against. + collection.Document("a").SetAsync(new Dictionary { + { "k", "a" }, + { "sort", 0 }, + }); + collection.Document("b").SetAsync(new Dictionary { + { "k", "b" }, + { "sort", 1 }, + }); + collection.Document("c").SetAsync(new Dictionary { + { "k", "c" }, + { "sort", 1 }, + }); + collection.Document("d").SetAsync(new Dictionary { + { "k", "d" }, + { "sort", 2 }, + }); + yield return AwaitSuccess(db.WaitForPendingWritesAsync()); + + // Setup `limit` query. + var limit = collection.Limit(2).OrderBy("sort"); + var limitAccumulator = new EventAccumulator(); + var limitRegistration = limit.Listen(limitAccumulator.Listener); + + // Setup mirroring `limitToLast` query. + var limitToLast = collection.LimitToLast(2).OrderByDescending("sort"); + var limitToLastAccumulator = new EventAccumulator(); + var limitToLastRegistration = limitToLast.Listen(limitToLastAccumulator.Listener); + + // Verify both query get expected result. + var lastEventTask = limitAccumulator.LastEventAsync(); + yield return AwaitSuccess(lastEventTask); + var data = QuerySnapshotToValues(lastEventTask.Result); + Assert.That(data, Is.EquivalentTo(new List> { + new Dictionary { { "k", "a" }, { "sort", 0L } }, + new Dictionary { { "k", "b" }, { "sort", 1L } } + })); + lastEventTask = limitToLastAccumulator.LastEventAsync(); + yield return AwaitSuccess(lastEventTask); + data = QuerySnapshotToValues(lastEventTask.Result); + Assert.That(data, Is.EquivalentTo(new List> { + new Dictionary { { "k", "b" }, { "sort", 1L } }, + new Dictionary { { "k", "a" }, { "sort", 0L } } + })); + + // Unlisten then re-listen limit query. + limitRegistration.Stop(); + limit.Listen(limitAccumulator.Listener); + + // Verify `limit` query still works. + lastEventTask = limitAccumulator.LastEventAsync(); + yield return AwaitSuccess(lastEventTask); + data = QuerySnapshotToValues(lastEventTask.Result); + Assert.That(data, Is.EquivalentTo(new List> { + new Dictionary { { "k", "a" }, { "sort", 0L } }, + new Dictionary { { "k", "b" }, { "sort", 1L } } + })); + + // Add a document that would change the result set. + yield return AwaitSuccess(collection.Document("d").SetAsync(new Dictionary { + { "k", "e" }, + { "sort", -1 }, + })); + + // Verify both query get expected result. + lastEventTask = limitAccumulator.LastEventAsync(); + yield return AwaitSuccess(lastEventTask); + data = QuerySnapshotToValues(lastEventTask.Result); + Assert.That(data, Is.EquivalentTo(new List> { + new Dictionary { { "k", "e" }, { "sort", -1L } }, + new Dictionary { { "k", "a" }, { "sort", 0L } } + })); + lastEventTask = limitToLastAccumulator.LastEventAsync(); + yield return AwaitSuccess(lastEventTask); + data = QuerySnapshotToValues(lastEventTask.Result); + Assert.That(data, Is.EquivalentTo(new List> { + new Dictionary { { "k", "a" }, { "sort", 0L } }, + new Dictionary { { "k", "e" }, { "sort", -1L } } + })); + + // Unlisten to limitToLast, update a doc, then relisten to limitToLast + limitToLastRegistration.Stop(); + yield return AwaitSuccess(collection.Document("a").UpdateAsync("sort", -2)); + limitToLast.Listen(limitToLastAccumulator.Listener); + + // Verify both query get expected result. + lastEventTask = limitAccumulator.LastEventAsync(); + yield return AwaitSuccess(lastEventTask); + data = QuerySnapshotToValues(lastEventTask.Result); + Assert.That(data, Is.EquivalentTo(new List> { + new Dictionary { { "k", "a" }, { "sort", -2L } }, + new Dictionary { { "k", "e" }, { "sort", -1L } } + })); + lastEventTask = limitToLastAccumulator.LastEventAsync(); + yield return AwaitSuccess(lastEventTask); + data = QuerySnapshotToValues(lastEventTask.Result); + Assert.That(data, Is.EquivalentTo(new List> { + new Dictionary { { "k", "e" }, { "sort", -1L } }, + new Dictionary { { "k", "a" }, { "sort", -2L } } + })); + } + + [UnityTest] + public IEnumerator ArrayContainsQuery_ShouldReturnCorrectDocuments() { + // Initialize collection with a few test documents to query against. + var collection = TestCollection(); + collection.Document("a").SetAsync(new Dictionary { + { "array", new List { 42 } }, + }); + + collection.Document("b").SetAsync(new Dictionary { + { "array", new List { "a", 42, "c" } }, + }); + + collection.Document("c").SetAsync(new Dictionary { + { "array", + new List { + 41.999, "42", new Dictionary { { "array", new List { 42 } } } + } } + }); + + collection.Document("d").SetAsync(new Dictionary { + { "array", new List { 42 } }, + { "array2", new List { "bingo" } }, + }); + yield return AwaitSuccess(db.WaitForPendingWritesAsync()); + + yield return AssertQueryResults( + desc: "ArrayContains", query: collection.WhereArrayContains(new FieldPath("array"), 42), + docIds: AsList("a", "b", "d")); + yield return AssertQueryResults(desc: "ArrayContains", + query: collection.WhereArrayContains("array", 42), + docIds: AsList("a", "b", "d")); + } + + [UnityTest] + public IEnumerator ArrayContainsAnyQuery_ShouldReturnCorrectDocuments() { + // Initialize collection with a few test documents to query against. + var collection = TestCollection(); + collection.Document("a").SetAsync(new Dictionary { + { "array", new List { 42 } }, + }); + + collection.Document("b").SetAsync(new Dictionary { + { "array", new List { "a", 42, "c" } }, + }); + + collection.Document("c").SetAsync(new Dictionary { + { "array", + new List { + 41.999, "42", new Dictionary { { "array", new List { 42 } } } + } } + }); + + collection.Document("d").SetAsync(new Dictionary { + { "array", new List { 42 } }, + { "array2", new List { "bingo" } }, + }); + + collection.Document("e").SetAsync( + new Dictionary { { "array", new List { 43 } } }); + + collection.Document("f").SetAsync(new Dictionary { + { "array", new List { new Dictionary { { "a", 42 } } } } + }); + + collection.Document("g").SetAsync(new Dictionary { + { "array", 42 }, + }); + + yield return AwaitSuccess(db.WaitForPendingWritesAsync()); + + yield return AssertQueryResults( + desc: "ArrayContainsAny", + query: collection.WhereArrayContainsAny("array", new List { 42, 43 }), + docIds: AsList("a", "b", "d", "e")); + + yield return AssertQueryResults( + desc: "ArrayContainsAnyObject", + query: collection.WhereArrayContainsAny( + new FieldPath("array"), + new List { new Dictionary { { "a", 42 } } }), + docIds: AsList("f")); + } + + [UnityTest] + public IEnumerator InQuery_ShouldReturnCorrectDocuments() { + // Initialize collection with a few test documents to query against. + var collection = TestCollection(); + collection.Document("a").SetAsync(new Dictionary { + { "zip", 98101 }, + { "nullable", null }, + }); + collection.Document("b").SetAsync(new Dictionary { + { "zip", 98102 }, + { "nullable", "value" }, + }); + collection.Document("c").SetAsync(new Dictionary { + { "zip", 98103 }, + { "nullable", null }, + }); + collection.Document("d").SetAsync( + new Dictionary { { "zip", new List { 98101 } } }); + collection.Document("e").SetAsync(new Dictionary { + { "zip", new List { "98101", new Dictionary { { "zip", 98101 } } } } + }); + collection.Document("f").SetAsync(new Dictionary { + { "zip", new Dictionary { { "code", 500 } } }, + { "nullable", 123 }, + }); + collection.Document("g").SetAsync(new Dictionary { + { "zip", new List { 98101, 98102 } }, + { "nullable", null }, + }); + yield return AwaitSuccess(db.WaitForPendingWritesAsync()); + + yield return AssertQueryResults( + desc: "InQuery", + query: collection.WhereIn( + "zip", new List { 98101, 98103, new List { 98101, 98102 } }), + docIds: AsList("a", "c", "g")); + + yield return AssertQueryResults( + desc: "InQueryWithObject", + query: collection.WhereIn( + new FieldPath("zip"), + new List { new Dictionary { { "code", 500 } } }), + docIds: AsList("f")); + + yield return AssertQueryResults( + desc: "InQueryWithDocIds", + query: collection.WhereIn(FieldPath.DocumentId, new List { "c", "e" }), + docIds: AsList("c", "e")); + + yield return AssertQueryResults( + desc: "NotInQuery", + query: collection.WhereNotIn( + "zip", new List { 98101, 98103, new List { 98101, 98102 } }), + docIds: AsList("b", "d", "e", "f")); + + yield return AssertQueryResults( + desc: "NotInQueryWithObject", + query: collection.WhereNotIn( + new FieldPath("zip"), + new List { new List { 98101, 98102 }, + new Dictionary { { "code", 500 } } }), + docIds: AsList("a", "b", "c", "d", "e")); + + yield return AssertQueryResults( + desc: "NotInQueryWithDocIds", + query: collection.WhereNotIn(FieldPath.DocumentId, new List { "a", "c", "e" }), + docIds: AsList("b", "d", "f", "g")); + + yield return AssertQueryResults( + desc: "NotInQueryWithNulls", + query: collection.WhereNotIn(new FieldPath("nullable"), new List { null }), + docIds: new List {}); + } + + [UnityTest] + // Tests that DocumentReference and Query respect the Source parameter passed to + // GetSnapshotAsync(). We don't exhaustively test the behavior. We just do enough + // checks to verify that cache, default, and server produce distinct results. + public IEnumerator GetBySource_ShouldWork() { + DocumentReference doc = TestDocument(); + + yield return AwaitSuccess(doc.SetAsync(TestData())); + + // Verify FromCache gives us cached results even when online. + { + var getByCache = doc.GetSnapshotAsync(Source.Cache); + yield return AwaitSuccess(getByCache); + DocumentSnapshot docSnap = getByCache.Result; + Assert.That(docSnap.Metadata.IsFromCache, Is.True); + var getParentByCache = doc.Parent.GetSnapshotAsync(Source.Cache); + yield return AwaitSuccess(getParentByCache); + QuerySnapshot querySnap = getParentByCache.Result; + Assert.That(querySnap.Metadata.IsFromCache, Is.True); + } + + // Verify Default gives us non-cached results when online. + { + var getByDefault = doc.GetSnapshotAsync(Source.Default); + yield return AwaitSuccess(getByDefault); + DocumentSnapshot docSnap = getByDefault.Result; + Assert.That(docSnap.Metadata.IsFromCache, Is.False); + var getParentByDefault = doc.Parent.GetSnapshotAsync(Source.Default); + yield return AwaitSuccess(getParentByDefault); + QuerySnapshot querySnap = getParentByDefault.Result; + Assert.That(querySnap.Metadata.IsFromCache, Is.False); + } + + { + // Disable network so we can test offline behavior. + yield return AwaitSuccess(doc.Firestore.DisableNetworkAsync()); + + // Verify Default gives us cached results when offline. + var getByDefault = doc.GetSnapshotAsync(Source.Default); + yield return AwaitSuccess(getByDefault); + DocumentSnapshot docSnap = getByDefault.Result; + Assert.That(docSnap.Metadata.IsFromCache, Is.True); + var getParentByDefault = doc.Parent.GetSnapshotAsync(Source.Default); + yield return AwaitSuccess(getParentByDefault); + QuerySnapshot querySnap = getParentByDefault.Result; + Assert.That(querySnap.Metadata.IsFromCache, Is.True); + + var getByServer = doc.GetSnapshotAsync(Source.Server); + yield return AwaitCompletion(getByServer); + AssertTaskFaulted(getByServer, FirestoreError.Unavailable); + var getParentByServer = doc.Parent.GetSnapshotAsync(Source.Server); + yield return AwaitCompletion(getParentByServer); + AssertTaskFaulted(getParentByServer, FirestoreError.Unavailable); + + yield return AwaitSuccess(doc.Firestore.EnableNetworkAsync()); + } + } + } +} \ No newline at end of file diff --git a/firestore/testapp/Assets/Tests/SerializationTestData.cs b/firestore/testapp/Assets/Tests/SerializationTestData.cs new file mode 100644 index 000000000..dae187e03 --- /dev/null +++ b/firestore/testapp/Assets/Tests/SerializationTestData.cs @@ -0,0 +1,656 @@ +// Copyright 2017, Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// NOTE: This file based on +// http://github.com/googleapis/google-cloud-dotnet/blob/c4439e0099d9e4c414afbe666f0d2bb28f95b297/apis/Google.Cloud.Firestore/Google.Cloud.Firestore.Tests/SerializationTestData.cs +// This file has been modified from its original version. It has been adapted to use raw C# types +// instead of protos and to work in .Net 3.5. + +using System; +using System.Collections.Generic; +using System.Linq; +using Firebase.Firestore; + +namespace Tests { + internal static class SerializationTestData { + private static DateTime dateTime = new DateTime(1990, 1, 2, 3, 4, 5, DateTimeKind.Utc); + private static DateTimeOffset dateTimeOffset = + new DateTimeOffset(1990, 1, 2, 3, 4, 5, TimeSpan.FromHours(1)); + + internal class TestCase { + /// + /// The object to serialize into Firestore document. + /// + internal object Input { get; private set; } + + /// + /// The expected output from the Firestore document deserialized to raw + /// Firestore type (Dictionary<string, object>, or primitive types). + /// + internal object ExpectedRawOutput { get; private set; } + + public TestCase(object input, object expectedRawOutput) { + Input = input; + ExpectedRawOutput = expectedRawOutput; + } + } + + public static IEnumerable TestData(FirebaseFirestore database) { + return new List { + // Simple types + { new TestCase(null, null) }, + { new TestCase(true, true) }, + { new TestCase(false, false) }, + { new TestCase("test", "test") }, + { new TestCase((byte)1, 1L) }, + { new TestCase((sbyte)1, 1L) }, + { new TestCase((short)1, 1L) }, + { new TestCase((ushort)1, 1L) }, + { new TestCase(1, 1L) }, + { new TestCase(1U, 1L) }, + { new TestCase(1L, 1L) }, + { new TestCase(1UL, 1L) }, + { new TestCase(1.5F, 1.5D) }, + { new TestCase(float.PositiveInfinity, double.PositiveInfinity) }, + { new TestCase(float.NegativeInfinity, double.NegativeInfinity) }, + { new TestCase(float.NaN, double.NaN) }, + { new TestCase(1.5D, 1.5D) }, + { new TestCase(double.PositiveInfinity, double.PositiveInfinity) }, + { new TestCase(double.NegativeInfinity, double.NegativeInfinity) }, + { new TestCase(double.NaN, double.NaN) }, + + // Min/max values of each integer type + { new TestCase(byte.MinValue, (long)byte.MinValue) }, + { new TestCase(byte.MaxValue, (long)byte.MaxValue) }, + { new TestCase(sbyte.MinValue, (long)sbyte.MinValue) }, + { new TestCase(sbyte.MaxValue, (long)sbyte.MaxValue) }, + { new TestCase(short.MinValue, (long)short.MinValue) }, + { new TestCase(short.MaxValue, (long)short.MaxValue) }, + { new TestCase(ushort.MinValue, (long)ushort.MinValue) }, + { new TestCase(ushort.MaxValue, (long)ushort.MaxValue) }, + { new TestCase(int.MinValue, (long)int.MinValue) }, + { new TestCase(int.MaxValue, (long)int.MaxValue) }, + { new TestCase(uint.MinValue, (long)uint.MinValue) }, + { new TestCase(uint.MaxValue, (long)uint.MaxValue) }, + { new TestCase(long.MinValue, long.MinValue) }, + { new TestCase(long.MaxValue, long.MaxValue) }, + // We don't cover the whole range of ulong + { new TestCase((ulong)0, 0L) }, + { new TestCase((ulong) long.MaxValue, long.MaxValue) }, + + // Enum types + { new TestCase(ByteEnum.MinValue, (long)byte.MinValue) }, + { new TestCase(ByteEnum.MaxValue, (long)byte.MaxValue) }, + { new TestCase(SByteEnum.MinValue, (long)sbyte.MinValue) }, + { new TestCase(SByteEnum.MaxValue, (long)sbyte.MaxValue) }, + { new TestCase(Int16Enum.MinValue, (long)short.MinValue) }, + { new TestCase(Int16Enum.MaxValue, (long)short.MaxValue) }, + { new TestCase(UInt16Enum.MinValue, (long)ushort.MinValue) }, + { new TestCase(UInt16Enum.MaxValue, (long)ushort.MaxValue) }, + { new TestCase(Int32Enum.MinValue, (long)int.MinValue) }, + { new TestCase(Int32Enum.MaxValue, (long)int.MaxValue) }, + { new TestCase(UInt32Enum.MinValue, (long)uint.MinValue) }, + { new TestCase(UInt32Enum.MaxValue, (long)uint.MaxValue) }, + { new TestCase(Int64Enum.MinValue, (long)long.MinValue) }, + { new TestCase(Int64Enum.MaxValue, (long)long.MaxValue) }, + // We don't cover the whole range of ulong + { new TestCase(UInt64Enum.MinValue, (long)0) }, + { new TestCase(UInt64Enum.MaxRepresentableValue, (long)long.MaxValue) }, + { new TestCase(CustomConversionEnum.Foo, "Foo") }, + { new TestCase(CustomConversionEnum.Bar, "Bar") }, + + // Timestamps + { new TestCase(Timestamp.FromDateTime(dateTime), Timestamp.FromDateTime(dateTime)) }, + { new TestCase(dateTime, Timestamp.FromDateTime(dateTime)) }, + { new TestCase(dateTimeOffset, Timestamp.FromDateTimeOffset(dateTimeOffset)) }, + + // Blobs + { new TestCase(new byte[] { 1, 2, 3, 4 }, Blob.CopyFrom(new byte[] { 1, 2, 3, 4 })) }, + { new TestCase(Blob.CopyFrom(new byte[] { 1, 2, 3, 4 }), + Blob.CopyFrom(new byte[] { 1, 2, 3, 4 })) }, + + // GeoPoints + { new TestCase(new GeoPoint(1.5, 2.5), new GeoPoint(1.5, 2.5)) }, + + // Array values + { new TestCase(new string[] { "x", "y" }, new List { "x", "y" }) }, + { new TestCase(new List { "x", "y" }, new List { "x", "y" }) }, + { new TestCase(new int[] { 3, 4 }, new List { 3L, 4L }) }, + + // Deliberately DateTime rather than Timestamp here - we need to be able to detect the + // element type to perform the per-element deserialization correctly + { new TestCase(new List { dateTime, dateTime }, + new List { Timestamp.FromDateTime(dateTime), + Timestamp.FromDateTime(dateTime) }) }, + + // Map values (that can be deserialized again): dictionaries, attributed types, expandos + // (which are just dictionaries), custom serialized map-like values + + // Dictionaries + { new TestCase(new Dictionary { { "A", 10 }, { "B", 20 } }, + new Dictionary { { "A", 10L }, { "B", 20L } }) }, + { new TestCase(new Dictionary { { "A", 10 }, { "B", 20 } }, + new Dictionary { { "A", 10L }, { "B", 20L } }) }, + { new TestCase(new Dictionary { { "name", "Jon" }, { "score", 10L } }, + new Dictionary { { "name", "Jon" }, { "score", 10L } }) }, + // Attributed type (each property has an attribute) + { new TestCase(new GameResult { Name = "Jon", Score = 10 }, + new Dictionary { { "name", "Jon" }, { "Score", 10L } }) }, + // Attributed type contained in a dictionary + { new TestCase( + new Dictionary { { "result", + new GameResult { Name = "Jon", Score = 10 } } }, + new Dictionary { + { "result", new Dictionary { { "name", "Jon" }, { "Score", 10L } } } + }) }, + // Attributed type containing a dictionary + { new TestCase( + new DictionaryInterfaceContainer { + Integers = new Dictionary { { "A", 10 }, { "B", 20 } } + }, + new Dictionary { + { "Integers", new Dictionary { { "A", 10L }, { "B", 20L } } } + }) }, + // Attributed type serialized and deserialized by CustomPlayerConverter + { new TestCase(new CustomPlayer { Name = "Amanda", Score = 15 }, + new Dictionary { { "PlayerName", "Amanda" }, + { "PlayerScore", 15L } }) }, + + // Attributed value type serialized and deserialized by CustomValueTypeConverter + { new TestCase(new CustomValueType("xyz", 10), + new Dictionary { { "Name", "xyz" }, { "Value", 10L } }) }, + + // Attributed type with enums (name and number) + { new TestCase(new ModelWithEnums { EnumDefaultByName = CustomConversionEnum.Foo, + EnumAttributedByName = Int32Enum.MinValue, + EnumByNumber = Int32Enum.MaxValue }, + new Dictionary { { "EnumDefaultByName", "Foo" }, + { "EnumAttributedByName", "MinValue" }, + { "EnumByNumber", (long)int.MaxValue } }) }, + + // Attributed type with List field + { new TestCase(new CustomUser { Name = "Jon", HighScore = 10, + Emails = new List { "jon@example.com" } }, + new Dictionary { + { "Name", "Jon" }, + { "HighScore", 10L }, + { "Emails", new List { "jon@example.com" } } + }) }, + + // Attributed type with IEnumerable field + { new TestCase( + new CustomUserEnumerableEmails() { Name = "Jon", HighScore = 10, + Emails = new List { "jon@example.com" } }, + new Dictionary { { "Name", "Jon" }, + { "HighScore", 10L }, + { "Emails", + new List { "jon@example.com" } } }) }, + + // Attributed type with Set field and custom converter. + { new TestCase( + new CustomUserSetEmailsWithConverter() { + Name = "Jon", HighScore = 10, Emails = new HashSet { "jon@example.com" } + }, + new Dictionary { { "Name", "Jon" }, + { "HighScore", 10L }, + { "Emails", + new List { "jon@example.com" } } }) }, + + // Attributed struct + { new TestCase(new StructModel { Name = "xyz", Value = 10 }, + new Dictionary { { "Name", "xyz" }, { "Value", 10L } }) }, + + // Document references + { new TestCase(database.Document("a/b"), database.Document("a/b")) }, + }; + } + + public static IEnumerable UnsupportedTestData() { + return new List { + // Nullable type handling + { new TestCase(new NullableContainer { NullableValue = 10 }, + new Dictionary { { "NullableValue", 10L } }) }, + { new TestCase(new NullableEnumContainer { NullableValue = (Int32Enum)10 }, + new Dictionary { { "NullableValue", 10L } }) }, + // This one fails because the `NullableContainer` it gets back has a random value + // while it should be null. + { new TestCase(new NullableContainer { NullableValue = null }, + new Dictionary { { "NullableValue", null } }) }, + { new TestCase(new NullableEnumContainer { NullableValue = null }, + new Dictionary { { "NullableValue", null } }) }, + + }; + } + + // Test data that is serializable, but cannot be deserialized into the original types. + public static IEnumerable UnsupportedReadToInputTypesTestData() { + return new List { + // IEnumerable values cannot be assigned from a List. + // TODO(b/173894435): there should be a way to specify if it is serialization or + // deserialization failure. + { new TestCase(Enumerable.Range(3, 2).Select(i => (long)i), + Enumerable.Range(3, 2).Select(i => (long)i)) }, + { new TestCase( + new CustomUserSetEmails { Name = "Jon", HighScore = 10, + Emails = new HashSet { "jon@example.com" } }, + new Dictionary { { "Name", "Jon" }, + { "HighScore", 10L }, + { "Emails", + new List { "jon@example.com" } } }) } + }; + } + + // Only equatable for the sake of testing; that's not a requirement of the serialization code. + [FirestoreData] + internal class GameResult : IEquatable { + [FirestoreProperty("name")] + public string Name { get; set; } + [FirestoreProperty] // No property name specified, so field will be Score + public int Score { + get; set; + } + + public override int GetHashCode() { + return Name.GetHashCode() ^ Score; + } + + public override bool Equals(object obj) { + return Equals(obj as GameResult); + } + + public bool Equals(GameResult other) { + return other != null && other.Name == Name && other.Score == Score; + } + } + + [FirestoreData] + internal class NullableContainer : IEquatable { + [FirestoreProperty] + public long? NullableValue { get; set; } + + public override int GetHashCode() { + return (int)NullableValue.GetValueOrDefault().GetHashCode(); + } + + public override bool Equals(object obj) { + return Equals(obj as NullableContainer); + } + + public bool Equals(NullableContainer other) { + return other != null && other.NullableValue == NullableValue; + } + public override string ToString() { + return String.Format("NullableContainer: {0}", NullableValue.GetValueOrDefault()); + } + } + + [FirestoreData] + internal class NullableEnumContainer : IEquatable { + [FirestoreProperty] + public Int32Enum? NullableValue { get; set; } + + public override int GetHashCode() { + return (int)NullableValue.GetValueOrDefault().GetHashCode(); + } + + public override bool Equals(object obj) { + return Equals(obj as NullableEnumContainer); + } + + public bool Equals(NullableEnumContainer other) { + return other != null && other.NullableValue == NullableValue; + } + } + + [FirestoreData] + internal class DictionaryInterfaceContainer : IEquatable { + [FirestoreProperty] + public IDictionary Integers { get; set; } + + public override int GetHashCode() { + return Integers.Sum(pair => pair.Key.GetHashCode() + pair.Value); + } + + public override bool Equals(object obj) { + return Equals(obj as DictionaryInterfaceContainer); + } + + public bool Equals(DictionaryInterfaceContainer other) { + if (other == null) { + return false; + } + if (Integers == other.Integers) { + return true; + } + if (Integers == null || other.Integers == null) { + return false; + } + if (Integers.Count != other.Integers.Count) { + return false; + } + int otherValue; + return Integers.All(pair => other.Integers.TryGetValue(pair.Key, out otherValue) && + pair.Value == otherValue); + } + } + + internal enum SByteEnum : sbyte { MinValue = sbyte.MinValue, MaxValue = sbyte.MaxValue } + + internal enum Int16Enum : short { MinValue = short.MinValue, MaxValue = short.MaxValue } + + internal enum Int32Enum : int { MinValue = int.MinValue, MaxValue = int.MaxValue } + + internal enum Int64Enum : long { MinValue = long.MinValue, MaxValue = long.MaxValue } + + internal enum ByteEnum : byte { MinValue = byte.MinValue, MaxValue = byte.MaxValue } + + internal enum UInt16Enum : ushort { MinValue = ushort.MinValue, MaxValue = ushort.MaxValue } + + internal enum UInt32Enum : uint { MinValue = uint.MinValue, MaxValue = uint.MaxValue } + + internal enum UInt64Enum : ulong { + MinValue = ulong.MinValue, + MaxRepresentableValue = long.MaxValue + } + + [FirestoreData(ConverterType = typeof(FirestoreEnumNameConverter))] + internal enum CustomConversionEnum { Foo = 1, Bar = 2 } + + [FirestoreData] + public sealed class ModelWithEnums { + [FirestoreProperty] + public CustomConversionEnum EnumDefaultByName { get; set; } + + [FirestoreProperty(ConverterType = + typeof(FirestoreEnumNameConverter))] public Int32Enum + EnumAttributedByName { get; set; } + + [FirestoreProperty] public Int32Enum EnumByNumber { get; set; } + + public override bool Equals(object obj) { + if (!(obj is ModelWithEnums)) { + return false; + } + ModelWithEnums other = obj as ModelWithEnums; + return EnumDefaultByName == other.EnumDefaultByName && + EnumAttributedByName == other.EnumAttributedByName && + EnumByNumber == other.EnumByNumber; + } + + public override int GetHashCode() { + return 0; + } + } + + [FirestoreData] + public sealed class CustomUser { + [FirestoreProperty] + public int HighScore { get; set; } + [FirestoreProperty] public string Name { get; set; } + [FirestoreProperty] public List Emails { get; set; } + + public override bool Equals(object obj) { + if (!(obj is CustomUser)) { + return false; + } + + CustomUser other = (CustomUser)obj; + return HighScore == other.HighScore && Name == other.Name && + Emails.SequenceEqual(other.Emails); + } + + public override int GetHashCode() { + return 0; + } + } + + [FirestoreData] + public sealed class CustomUserEnumerableEmails { + [FirestoreProperty] + public int HighScore { get; set; } + [FirestoreProperty] public string Name { get; set; } + [FirestoreProperty] public IEnumerable Emails { get; set; } + + public override bool Equals(object obj) { + if (!(obj is CustomUserEnumerableEmails)) { + return false; + } + + CustomUserEnumerableEmails other = (CustomUserEnumerableEmails)obj; + return HighScore == other.HighScore && Name == other.Name && + Emails.SequenceEqual(other.Emails); + } + + public override int GetHashCode() { + return 0; + } + } + + [FirestoreData] + public sealed class CustomUserSetEmails { + [FirestoreProperty] + public int HighScore { get; set; } + [FirestoreProperty] public string Name { get; set; } + [FirestoreProperty] public HashSet Emails { get; set; } + + public override bool Equals(object obj) { + if (!(obj is CustomUserSetEmails)) { + return false; + } + + CustomUserSetEmails other = (CustomUserSetEmails)obj; + return HighScore == other.HighScore && Name == other.Name && + Emails.SequenceEqual(other.Emails); + } + + public override int GetHashCode() { + return 0; + } + } + + [FirestoreData(ConverterType = typeof(CustomUserSetEmailsConverter))] + public sealed class CustomUserSetEmailsWithConverter { + [FirestoreProperty] + public int HighScore { get; set; } + [FirestoreProperty] public string Name { get; set; } + [FirestoreProperty] public HashSet Emails { get; set; } + + public override bool Equals(object obj) { + if (!(obj is CustomUserSetEmailsWithConverter)) { + return false; + } + + var other = (CustomUserSetEmailsWithConverter)obj; + return HighScore == other.HighScore && Name == other.Name && + Emails.SequenceEqual(other.Emails); + } + + public override int GetHashCode() { + return 0; + } + } + + public class CustomUserSetEmailsConverter + : FirestoreConverter { + public override CustomUserSetEmailsWithConverter FromFirestore(object value) { + if (value == null) { + throw new ArgumentNullException("value"); // Shouldn't happen + } + + var map = (Dictionary)value; + var emails = (List)map["Emails"]; + var emailSet = new HashSet(emails.Select(o => o.ToString())); + return new CustomUserSetEmailsWithConverter { Name = (string)map["Name"], + HighScore = Convert.ToInt32(map["HighScore"]), + Emails = emailSet }; + } + + public override object ToFirestore(CustomUserSetEmailsWithConverter value) { + return new Dictionary { + { "Name", value.Name }, + { "HighScore", value.HighScore }, + { "Emails", value.Emails }, + }; + } + } + + [FirestoreData(ConverterType = typeof(EmailConverter))] + public sealed class Email { + public readonly string Address; + public Email(string address) { + Address = address; + } + } + + public class EmailConverter : FirestoreConverter { + public override Email FromFirestore(object value) { + if (value == null) { + throw new ArgumentNullException("value"); // Shouldn't happen + } else if (value is string) { + return new Email(value as string); + } else { + throw new ArgumentException(String.Format("Unexpected data: {}", value.GetType())); + } + } + public override object ToFirestore(Email value) { + return value == null ? null : value.Address; + } + } + + [FirestoreData] + public class GuidPair { + [FirestoreProperty] + public string Name { get; set; } + + [FirestoreProperty(ConverterType = typeof(GuidConverter))] public Guid Guid { get; set; } + + [FirestoreProperty(ConverterType = typeof(GuidConverter))] public Guid + ? GuidOrNull { get; set; } + } + + // Like GuidPair, but without the converter specified - it has to come + // from a converter registry instead. + [FirestoreData] + public class GuidPair2 { + [FirestoreProperty] + public string Name { get; set; } + + [FirestoreProperty] public Guid Guid { get; set; } + + [FirestoreProperty] public Guid? GuidOrNull { get; set; } + } + + public class GuidConverter : FirestoreConverter { + public override Guid FromFirestore(object value) { + if (value == null) { + throw new ArgumentNullException("value"); // Shouldn't happen + } else if (value is string) { + return new Guid(value as string); + } else { + throw new ArgumentException(String.Format("Unexpected data: {0}", value.GetType())); + } + } + public override object ToFirestore(Guid value) { + return value.ToString("N"); + } + } + + // Only equatable for the sake of testing; that's not a requirement of the serialization code. + [FirestoreData(ConverterType = typeof(CustomPlayerConverter))] + public class CustomPlayer : IEquatable { + public string Name { get; set; } + public int Score { get; set; } + + public override int GetHashCode() { + return Name.GetHashCode() ^ Score; + } + public override bool Equals(object obj) { + return Equals(obj as CustomPlayer); + } + public bool Equals(CustomPlayer other) { + return other != null && other.Name == Name && other.Score == Score; + } + } + + public class CustomPlayerConverter : FirestoreConverter { + public override CustomPlayer FromFirestore(object value) { + var map = (IDictionary)value; + return new CustomPlayer { Name = (string)map["PlayerName"], + // Unbox to long, then convert to int. + Score = (int)(long)map["PlayerScore"] }; + } + + public override object ToFirestore(CustomPlayer value) { + return new Dictionary { { "PlayerName", value.Name }, + { "PlayerScore", value.Score } }; + } + } + + [FirestoreData(ConverterType = typeof(CustomValueTypeConverter))] + internal struct CustomValueType : IEquatable { + public readonly string Name; + public readonly int Value; + + public CustomValueType(string name, int value) { + Name = name; + Value = value; + } + + public override int GetHashCode() { + return Name.GetHashCode() + Value; + } + public override bool Equals(object obj) { + return obj is CustomValueType && Equals((CustomValueType)obj); + } + public bool Equals(CustomValueType other) { + return Name == other.Name && Value == other.Value; + } + public override string ToString() { + return String.Format("CustomValueType: {0}", new { Name, Value }); + } + } + + internal class CustomValueTypeConverter : FirestoreConverter { + public override CustomValueType FromFirestore(object value) { + var dictionary = (IDictionary)value; + return new CustomValueType((string)dictionary["Name"], (int)(long)dictionary["Value"]); + } + + public override object ToFirestore(CustomValueType value) { + return new Dictionary { { "Name", value.Name }, { "Value", value.Value } }; + } + } + + [FirestoreData] + internal struct StructModel : IEquatable { + [FirestoreProperty] + public string Name { get; set; } + [FirestoreProperty] public int Value { get; set; } + + public override int GetHashCode() { + return Name.GetHashCode() + Value; + } + public override bool Equals(object obj) { + return obj is StructModel && Equals((StructModel)obj); + } + public bool Equals(StructModel other) { + return Name == other.Name && Value == other.Value; + } + + public override string ToString() { + return String.Format("StructModel: {0}", new { Name, Value }); + } + } + } +} diff --git a/firestore/testapp/Assets/Tests/TestAsserts.cs b/firestore/testapp/Assets/Tests/TestAsserts.cs new file mode 100644 index 000000000..0d44248ec --- /dev/null +++ b/firestore/testapp/Assets/Tests/TestAsserts.cs @@ -0,0 +1,216 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using Firebase.Firestore; +using NUnit.Framework; +using UnityEngine; +using UnityEngine.TestTools; + +namespace Tests { + + public class FirestoreAssertionFailure : Exception { + public FirestoreAssertionFailure(string message) : base(message) {} + } + + public static class TestAsserts { + public static IEnumerator AwaitCompletion(Task t) { + yield return new WaitUntil((() => t.IsCompleted)); + } + + public static IEnumerator AwaitSuccess(Task t) { + yield return AwaitCompletion(t); + AssertTaskSucceeded(t); + } + + public static IEnumerator AwaitFaults(Task t) { + yield return AwaitCompletion(t); + AssertTaskFaulted(t); + } + + private static void AssertTaskProperties(Task t, bool isCompleted, bool isFaulted, + bool isCanceled) { + Assert.That(t.IsCompleted, Is.EqualTo(isCompleted)); + Assert.That(t.IsFaulted, Is.EqualTo(isFaulted)); + Assert.That(t.IsCanceled, Is.EqualTo(isCanceled)); + } + + public static void AssertTaskSucceeded(Task t) { + AssertTaskProperties(t, isCompleted: true, isFaulted: false, isCanceled: false); + } + + public static void AssertTaskIsPending(Task t) { + AssertTaskProperties(t, isCompleted: false, isFaulted: false, isCanceled: false); + } + + public static Exception AssertTaskFaulted(Task t) { + Assert.That(t.Exception, Is.Not.Null, + "Task is supposed to fail with exception, yet it succeeds."); + + AggregateException e = t.Exception; + Assert.That(e.InnerExceptions.Count, Is.EqualTo(1), "Task faulted with multiple exceptions"); + AssertTaskProperties(t, isCompleted: true, isFaulted: true, isCanceled: false); + return e.InnerExceptions[0]; + } + + public static FirestoreException AssertTaskFaulted(Task t, FirestoreError expectedError, + string expectedMessageRegex = null) { + var exception = AssertTaskFaulted(t); + Assert.That( + exception, Is.TypeOf(), + "The task faulted (as expected); however, its exception was expected to " + + $"be FirestoreException with ErrorCode={expectedError} but the actual exception " + + $"was {exception.GetType()}: {exception}"); + + var firestoreException = (FirestoreException)exception; + Assert.That(firestoreException.ErrorCode, Is.EqualTo(expectedError), + "The task faulted with FirestoreException (as expected); however, its " + + $"ErrorCode was expected to be {expectedError} but the actual ErrorCode was" + + $" {firestoreException.ErrorCode}: {firestoreException}"); + + if (expectedMessageRegex != null) { + Assert.That(Regex.IsMatch(firestoreException.Message, expectedMessageRegex, + RegexOptions.Singleline), + $"The task faulted with FirestoreException with ErrorCode={expectedError} " + + "(as expected); however, its message did not match the regular " + + $"expression {expectedMessageRegex}: {firestoreException.Message}"); + } + + return firestoreException; + } + + public static async Task AssertExpectedDocument(DocumentReference doc, + Dictionary expected) { + var snap = await doc.GetSnapshotAsync(); + Assert.That(snap.ToDictionary(), Is.EquivalentTo(expected)); + } + } + + // Tests for `TestAsserts` itself. + public class TestAssertsTests { + [UnityTest] + public IEnumerator AssertTaskFaulted_ShouldWork_WithFirestoreException() { + var tcs = new TaskCompletionSource(); + tcs.SetException(new FirestoreException(FirestoreError.Unavailable)); + yield return tcs.Task; + Assert.That(() => { TestAsserts.AssertTaskFaulted(tcs.Task, FirestoreError.Unavailable); }, + Throws.Nothing); + } + + [UnityTest] + public IEnumerator AssertTaskFaulted_ShouldWork_WithMatchingMessage() { + var tcs = new TaskCompletionSource(); + tcs.SetException(new FirestoreException(FirestoreError.Ok, "TheActualMessage")); + yield return tcs.Task; + Assert.That(() => { + TestAsserts.AssertTaskFaulted(tcs.Task, FirestoreError.Ok, "The.*Message"); + }, Throws.Nothing); + } + + // Verify that AssertTaskFaults() fails if the Task faults with an AggregateException that, + // when flattened, resolves to a FirestoreException with the expected error code. + [UnityTest] + public IEnumerator AssertTaskFaulted_ShouldThrow_IfFaultedWithAggregateException() { + var tcs = new TaskCompletionSource(); + var firestoreException = new FirestoreException(FirestoreError.Unavailable); + var aggregateException1 = new AggregateException(new[] { firestoreException }); + var aggregateException2 = new AggregateException(new[] { aggregateException1 }); + tcs.SetException(aggregateException2); + yield return tcs.Task; + + Assert.That( + () => { TestAsserts.AssertTaskFaulted(tcs.Task, FirestoreError.Unavailable); }, + Throws.Exception, + "AssertTaskFaults() should have thrown an exception because the AggregateException" + + "has multiple nested AggregateException instances."); + } + + [UnityTest] + public IEnumerator AssertTaskFaulted_ShouldThrow_IfFaultedWithUnexpectedErrorCode() { + var tcs = new TaskCompletionSource(); + tcs.SetResult(new FirestoreException(FirestoreError.Unavailable)); + yield return tcs.Task; + Assert.That(() => { TestAsserts.AssertTaskFaulted(tcs.Task, FirestoreError.Ok); }, + Throws.Exception, + "AssertTaskFaults() should have thrown an exception because the task faulted " + + "with an incorrect error code."); + } + + [UnityTest] + public IEnumerator AssertTaskFaulted_ShouldThrow_WhenTaskCompletes() { + var tcs = new TaskCompletionSource(); + tcs.SetResult(null); + yield return tcs.Task; + Assert.That(() => { TestAsserts.AssertTaskFaulted(tcs.Task, FirestoreError.Ok); }, + Throws.Exception, + "AssertTaskFaults() should have thrown an exception because the task faulted " + + "with an incorrect error code."); + } + + [UnityTest] + public IEnumerator AssertTaskFaulted_ShouldThrow_IfFaultedWithNonFirestoreException() { + var tcs = new TaskCompletionSource(); + tcs.SetException(new InvalidOperationException()); + yield return tcs.Task; + Assert.That(() => { TestAsserts.AssertTaskFaulted(tcs.Task, FirestoreError.Ok); }, + Throws.Exception, + "AssertTaskFaults() should have thrown an exception because the task faulted " + + "with an incorrect exception type."); + } + + [UnityTest] + public IEnumerator AssertTaskFaulted_ShouldThrow_IfFaultedWithUnexpectedAggregateException() { + var tcs = new TaskCompletionSource(); + var exception1 = new InvalidOperationException(); + var exception2 = new AggregateException(new[] { exception1 }); + var exception3 = new AggregateException(new[] { exception2 }); + tcs.SetException(exception3); + yield return tcs.Task; + Assert.That(() => { TestAsserts.AssertTaskFaulted(tcs.Task, FirestoreError.Ok); }, + Throws.Exception, + "AssertTaskFaults() should have thrown an exception because the task faulted " + + "with an AggregateException that flattened to an unexpected exception."); + } + + [UnityTest] + public IEnumerator AssertTaskFaulted_ShouldThrow_IfFaultedWithMoreThanOneInnerExceptions() { + var tcs = new TaskCompletionSource(); + var exception1 = new InvalidOperationException(); + var exception2 = new InvalidOperationException(); + var exception3 = new AggregateException(new[] { exception1, exception2 }); + tcs.SetException(exception3); + yield return tcs.Task; + Assert.That(() => { TestAsserts.AssertTaskFaulted(tcs.Task, FirestoreError.Ok); }, + Throws.Exception, + "AssertTaskFaults() should have thrown an exception because the task faulted " + + "with an AggregateException that could not be fully flattened."); + } + + [UnityTest] + public IEnumerator AssertTaskFaulted_ShouldThrow_IfFaultedWithMissingMessages() { + var tcs = new TaskCompletionSource(); + tcs.SetException(new FirestoreException(FirestoreError.Ok)); + yield return tcs.Task; + Exception thrownException = Assert.Throws( + () => TestAsserts.AssertTaskFaulted(tcs.Task, FirestoreError.Ok, "SomeMessageRegex")); + Assert.That(thrownException.Message, Contains.Substring("SomeMessageRegex"), + "AssertTaskFaults() threw an exception (as expected); however, its message was " + + "incorrect: " + thrownException.Message); + } + + [UnityTest] + public IEnumerator AssertTaskFaulted_ShouldThrow_IfFaultedWithMismatchMessages() { + var tcs = new TaskCompletionSource(); + tcs.SetException(new FirestoreException(FirestoreError.Ok, "TheActualMessage")); + yield return tcs.Task; + Exception thrownException = Assert.Throws( + () => TestAsserts.AssertTaskFaulted(tcs.Task, FirestoreError.Ok, "The.*MeaningOfLife")); + + Assert.That(thrownException.Message, Contains.Substring("TheActualMessage")); + Assert.That(thrownException.Message, Contains.Substring("The.*MeaningOfLife"), + "AssertTaskFaults() threw an exception (as expected); however, its message was " + + thrownException.Message); + } + } +} diff --git a/firestore/testapp/Assets/Tests/Tests.asmdef b/firestore/testapp/Assets/Tests/Tests.asmdef new file mode 100644 index 000000000..3af6074c4 --- /dev/null +++ b/firestore/testapp/Assets/Tests/Tests.asmdef @@ -0,0 +1,27 @@ +{ + "name": "Tests", + "references": [ + "UnityEngine.TestRunner", + "UnityEditor.TestRunner" + ], + "includePlatforms": [], + "excludePlatforms": [ + "CloudRendering" + ], + "allowUnsafeCode": false, + "overrideReferences": true, + "precompiledReferences": [ + "nunit.framework.dll", + "Firebase.App.dll", + "Firebase.Auth.dll", + "Firebase.Firestore.dll", + "Firebase.TaskExtension.dll", + "Unity.Tasks.dll" + ], + "autoReferenced": false, + "defineConstraints": [ + "UNITY_INCLUDE_TESTS" + ], + "versionDefines": [], + "noEngineReferences": false +} diff --git a/firestore/testapp/Assets/Tests/TransactionAndBatchTests.cs b/firestore/testapp/Assets/Tests/TransactionAndBatchTests.cs new file mode 100644 index 000000000..75e6450a3 --- /dev/null +++ b/firestore/testapp/Assets/Tests/TransactionAndBatchTests.cs @@ -0,0 +1,253 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Firebase; +using Firebase.Firestore; +using NUnit.Framework; +using UnityEngine.TestTools; +using static Tests.TestAsserts; + +namespace Tests { + public class TransactionAndBatchTests : FirestoreIntegrationTests { + [UnityTest] + public IEnumerator WriteBatch_ShouldWork() { + DocumentReference doc1 = TestDocument(); + DocumentReference doc2 = TestDocument(); + DocumentReference doc3 = TestDocument(); + + // Initialize doc1 and doc2 with some data. + var initialData = new Dictionary { + { "field", "value" }, + }; + yield return AwaitSuccess(doc1.SetAsync(initialData)); + yield return AwaitSuccess(doc2.SetAsync(initialData)); + + // Perform batch that deletes doc1, updates doc2, and overwrites doc3. + yield return AwaitSuccess( + doc1.Firestore.StartBatch() + .Delete(doc1) + .Update(doc2, new Dictionary { { "field2", "value2" } }) + .Update(doc2, + new Dictionary { { new FieldPath("field3"), "value3" } }) + .Update(doc2, "field4", "value4") + .Set(doc3, initialData) + .CommitAsync()); + + { + var getDoc1Task = doc1.GetSnapshotAsync(); + yield return AwaitSuccess(getDoc1Task); + DocumentSnapshot snap = getDoc1Task.Result; + Assert.That(snap.Exists, Is.False); + } + + { + var getDoc2Task = doc2.GetSnapshotAsync(); + yield return AwaitSuccess(getDoc2Task); + DocumentSnapshot snap = getDoc2Task.Result; + Assert.That(snap.ToDictionary(), Is.EquivalentTo(new Dictionary { + { "field", "value" }, + { "field2", "value2" }, + { "field3", "value3" }, + { "field4", "value4" }, + })); + } + + { + var getDoc3Task = doc3.GetSnapshotAsync(); + yield return AwaitSuccess(getDoc3Task); + DocumentSnapshot snap = getDoc3Task.Result; + Assert.That(snap.ToDictionary(), Is.EquivalentTo(initialData)); + } + } + + [UnityTest] + public IEnumerator WriteBatch_ShouldReportErrorOnInvalidDocument() { + var docWithInvalidName = TestCollection().Document("__badpath__"); + Task commitWithInvalidDocTask = docWithInvalidName.Firestore.StartBatch() + .Set(docWithInvalidName, TestData(0)) + .CommitAsync(); + yield return AwaitCompletion(commitWithInvalidDocTask); + AssertTaskFaulted(commitWithInvalidDocTask, FirestoreError.InvalidArgument); + } + + [UnityTest] + public IEnumerator Transaction_ShouldWork() { + DocumentReference doc1 = TestDocument(); + DocumentReference doc2 = TestDocument(); + DocumentReference doc3 = TestDocument(); + + // Initialize doc1 and doc2 with some data. + var initialData = new Dictionary { + { "field", "value" }, + }; + yield return AwaitSuccess(doc1.SetAsync(initialData)); + yield return AwaitSuccess(doc2.SetAsync(initialData)); + + // Perform transaction that reads doc1, deletes doc1, updates doc2, and overwrites doc3. + var transactionTask = doc1.Firestore.RunTransactionAsync((transaction) => { + Assert.That(mainThreadId, Is.EqualTo(Thread.CurrentThread.ManagedThreadId)); + return transaction.GetSnapshotAsync(doc1).ContinueWith((getTask) => { + Assert.That(getTask.Result.ToDictionary(), Is.EquivalentTo(initialData)); + transaction.Delete(doc1); + transaction.Update(doc2, new Dictionary { { "field2", "value2" } }); + transaction.Update( + doc2, new Dictionary { { new FieldPath("field3"), "value3" } }); + transaction.Update(doc2, "field4", "value4"); + transaction.Set(doc3, initialData); + return "txn result"; + }); + }); + + yield return AwaitSuccess(transactionTask); + string result = transactionTask.Result; + Assert.That(result, Is.EqualTo("txn result")); + + { + var getTask = doc1.GetSnapshotAsync(); + yield return AwaitSuccess(getTask); + DocumentSnapshot snap = getTask.Result; + Assert.That(snap.Exists, Is.False); + } + + { + var getTask = doc2.GetSnapshotAsync(); + yield return AwaitSuccess(getTask); + DocumentSnapshot snap = getTask.Result; + Assert.That(snap.ToDictionary(), Is.EquivalentTo(new Dictionary { + { "field", "value" }, + { "field2", "value2" }, + { "field3", "value3" }, + { "field4", "value4" }, + })); + } + + { + var getTask = doc3.GetSnapshotAsync(); + yield return AwaitSuccess(getTask); + DocumentSnapshot snap = getTask.Result; + Assert.That(snap.ToDictionary(), Is.EquivalentTo(initialData)); + } + } + + [UnityTest] + public IEnumerator TransactionWithNonGenericTask_ShouldWork() { + DocumentReference doc = TestDocument(); + yield return AwaitSuccess(db.RunTransactionAsync((transaction) => { + transaction.Set(doc, TestData(1)); + // Create a plain (non-generic) `Task` result. + return Task.CompletedTask; + })); + var getTask = doc.GetSnapshotAsync(); + yield return AwaitSuccess(getTask); + DocumentSnapshot snap = getTask.Result; + Assert.That(snap.ToDictionary(), Is.EquivalentTo(TestData(1))); + } + + [UnityTest] + public IEnumerator Transaction_CanAbortOnFailedTask() { + int retries = 0; + Task txnTask = db.RunTransactionAsync((transaction) => { + retries++; + TaskCompletionSource tcs = new TaskCompletionSource(); + tcs.SetException(new InvalidOperationException("Failed Task")); + return tcs.Task; + // TODO(183714287): Why below makes txnTask succeed? + // return Task.FromException(new InvalidOperationException("Failed Task")); + }); + yield return AwaitCompletion(txnTask); + Exception e = AssertTaskFaulted(txnTask); + Assert.That(retries, Is.EqualTo(1)); + Assert.That(e, Is.TypeOf()); + Assert.That(e.Message, Is.EqualTo("Failed Task")); + } + + [UnityTest] + public IEnumerator Transaction_CanAbortOnException() { + int retries = 0; + Task txnTask = db.RunTransactionAsync((transaction) => { + retries++; + throw new InvalidOperationException("Failed Exception"); + }); + yield return AwaitCompletion(txnTask); + Exception e = AssertTaskFaulted(txnTask); + Assert.That(retries, Is.EqualTo(1)); + Assert.That(e, Is.TypeOf()); + Assert.That(e.Message, Is.EqualTo("Failed Exception")); + } + + [UnityTest] + public IEnumerator Transaction_AbortOnInvalidDocuments() { + Task txnTask = db.RunTransactionAsync((transaction) => { + var docWithInvalidName = TestCollection().Document("__badpath__"); + return transaction.GetSnapshotAsync(docWithInvalidName); + }); + yield return AwaitCompletion(txnTask); + AssertTaskFaulted(txnTask, FirestoreError.InvalidArgument, "__badpath__"); + } + + [UnityTest] + public IEnumerator Transaction_AbortWithoutRetryOnPermanentError() { + int retries = 0; + DocumentReference doc = TestDocument(); + // Try to update a document that doesn't exist. Should fail permanently (no retries) + // with a "Not Found" error. + Task txnTask = db.RunTransactionAsync((transaction) => { + retries++; + transaction.Update(doc, TestData(0)); + return Task.CompletedTask; + }); + yield return AwaitCompletion(txnTask); + AssertTaskFaulted(txnTask, FirestoreError.NotFound, doc.Id); + Assert.That(retries, Is.EqualTo(1)); + } + + [UnityTest] + public IEnumerator Transaction_RetriesWithOutOfBandWrites() { + int retries = 0; + DocumentReference doc = TestDocument(); + Task txnTask = db.RunTransactionAsync((transaction) => { + retries++; + return transaction.GetSnapshotAsync(doc) + .ContinueWith((snapshot) => { + // Queue a write via the transaction. + transaction.Set(doc, TestData(0)); + // But also write the document (out-of-band) so the transaction is retried. + return doc.SetAsync(TestData(retries)); + }) + .Unwrap(); + }); + yield return AwaitCompletion(txnTask); + AssertTaskFaulted(txnTask, FirestoreError.FailedPrecondition); + // The transaction API will retry 6 times before giving up. + Assert.That(retries, Is.EqualTo(6)); + } + + [UnityTest] + public IEnumerator Transaction_RollsBackIfExceptionIsThrown() { + // This test covers this bug: https://github.com/firebase/quickstart-unity/issues/1042 + DocumentReference doc = TestDocument(); + Task txnTask = db.RunTransactionAsync(transaction => { + return transaction.GetSnapshotAsync(doc).ContinueWith(snapshotTask => { + transaction.Set(doc, new Dictionary { { "key", 42 } }, null); + throw new TestException(); + }); + }); + + yield return AwaitCompletion(txnTask); + Exception exception = AssertTaskFaulted(txnTask); + Assert.That(exception, Is.TypeOf()); + + // Verify that the transaction was rolled back. + var getTask = doc.GetSnapshotAsync(); + yield return AwaitSuccess(getTask); + DocumentSnapshot snap = getTask.Result; + Assert.That(snap.Exists, Is.False); + } + + private class TestException : Exception { + public TestException() {} + } + } +} \ No newline at end of file diff --git a/firestore/testapp/ProjectSettings/AudioManager.asset b/firestore/testapp/ProjectSettings/AudioManager.asset new file mode 100644 index 000000000..faf901c3e --- /dev/null +++ b/firestore/testapp/ProjectSettings/AudioManager.asset @@ -0,0 +1,15 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!11 &1 +AudioManager: + m_ObjectHideFlags: 0 + m_Volume: 1 + Rolloff Scale: 1 + Doppler Factor: 1 + Default Speaker Mode: 2 + m_SampleRate: 0 + m_DSPBufferSize: 0 + m_VirtualVoiceCount: 512 + m_RealVoiceCount: 32 + m_SpatializerPlugin: + m_DisableAudio: 0 diff --git a/firestore/testapp/ProjectSettings/ClusterInputManager.asset b/firestore/testapp/ProjectSettings/ClusterInputManager.asset new file mode 100644 index 000000000..e7886b266 --- /dev/null +++ b/firestore/testapp/ProjectSettings/ClusterInputManager.asset @@ -0,0 +1,6 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!236 &1 +ClusterInputManager: + m_ObjectHideFlags: 0 + m_Inputs: [] diff --git a/firestore/testapp/ProjectSettings/DynamicsManager.asset b/firestore/testapp/ProjectSettings/DynamicsManager.asset new file mode 100644 index 000000000..3534236e5 --- /dev/null +++ b/firestore/testapp/ProjectSettings/DynamicsManager.asset @@ -0,0 +1,15 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!55 &1 +PhysicsManager: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Gravity: {x: 0, y: -9.81, z: 0} + m_DefaultMaterial: {fileID: 0} + m_BounceThreshold: 2 + m_SleepThreshold: 0.005 + m_DefaultContactOffset: 0.01 + m_SolverIterationCount: 6 + m_QueriesHitTriggers: 1 + m_EnableAdaptiveForce: 0 + m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff diff --git a/firestore/testapp/ProjectSettings/EditorBuildSettings.asset b/firestore/testapp/ProjectSettings/EditorBuildSettings.asset new file mode 100644 index 000000000..6dc24f7df --- /dev/null +++ b/firestore/testapp/ProjectSettings/EditorBuildSettings.asset @@ -0,0 +1,7 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1045 &1 +EditorBuildSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Scenes: [] diff --git a/firestore/testapp/ProjectSettings/EditorSettings.asset b/firestore/testapp/ProjectSettings/EditorSettings.asset new file mode 100644 index 000000000..529a05c41 --- /dev/null +++ b/firestore/testapp/ProjectSettings/EditorSettings.asset @@ -0,0 +1,15 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!159 &1 +EditorSettings: + m_ObjectHideFlags: 0 + serializedVersion: 3 + m_ExternalVersionControlSupport: Visible Meta Files + m_SerializationMode: 2 + m_WebSecurityEmulationEnabled: 0 + m_WebSecurityEmulationHostUrl: http://www.mydomain.com/mygame.unity3d + m_DefaultBehaviorMode: 0 + m_SpritePackerMode: 2 + m_SpritePackerPaddingPower: 1 + m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd + m_ProjectGenerationRootNamespace: diff --git a/firestore/testapp/ProjectSettings/GraphicsSettings.asset b/firestore/testapp/ProjectSettings/GraphicsSettings.asset new file mode 100644 index 000000000..127711209 --- /dev/null +++ b/firestore/testapp/ProjectSettings/GraphicsSettings.asset @@ -0,0 +1,67 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!30 &1 +GraphicsSettings: + m_ObjectHideFlags: 0 + serializedVersion: 7 + m_Deferred: + m_Mode: 1 + m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} + m_DeferredReflections: + m_Mode: 1 + m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0} + m_ScreenSpaceShadows: + m_Mode: 1 + m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0} + m_LegacyDeferred: + m_Mode: 1 + m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} + m_DepthNormals: + m_Mode: 1 + m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0} + m_MotionVectors: + m_Mode: 1 + m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0} + m_LightHalo: + m_Mode: 1 + m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0} + m_LensFlare: + m_Mode: 1 + m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0} + m_AlwaysIncludedShaders: + - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 10782, guid: 0000000000000000f000000000000000, type: 0} + m_PreloadedShaders: [] + m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, + type: 0} + m_ShaderSettings_Tier1: + useCascadedShadowMaps: 0 + standardShaderQuality: 0 + useReflectionProbeBoxProjection: 0 + useReflectionProbeBlending: 0 + m_ShaderSettings_Tier2: + useCascadedShadowMaps: 0 + standardShaderQuality: 1 + useReflectionProbeBoxProjection: 0 + useReflectionProbeBlending: 0 + m_ShaderSettings_Tier3: + useCascadedShadowMaps: 0 + standardShaderQuality: 1 + useReflectionProbeBoxProjection: 0 + useReflectionProbeBlending: 0 + m_BuildTargetShaderSettings: [] + m_LightmapStripping: 0 + m_FogStripping: 0 + m_LightmapKeepPlain: 1 + m_LightmapKeepDirCombined: 1 + m_LightmapKeepDirSeparate: 1 + m_LightmapKeepDynamicPlain: 1 + m_LightmapKeepDynamicDirCombined: 1 + m_LightmapKeepDynamicDirSeparate: 1 + m_FogKeepLinear: 1 + m_FogKeepExp: 1 + m_FogKeepExp2: 1 diff --git a/firestore/testapp/ProjectSettings/InputManager.asset b/firestore/testapp/ProjectSettings/InputManager.asset new file mode 100644 index 000000000..17c8f538e --- /dev/null +++ b/firestore/testapp/ProjectSettings/InputManager.asset @@ -0,0 +1,295 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: 0.001 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: 0.001 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left shift + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: 0.1 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: 0.1 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: 0.1 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0.19 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0.19 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Submit + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: return + altNegativeButton: + altPositiveButton: joystick button 0 + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Submit + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: enter + altNegativeButton: + altPositiveButton: space + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Cancel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: escape + altNegativeButton: + altPositiveButton: joystick button 1 + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 diff --git a/firestore/testapp/ProjectSettings/NavMeshAreas.asset b/firestore/testapp/ProjectSettings/NavMeshAreas.asset new file mode 100644 index 000000000..a04f35c79 --- /dev/null +++ b/firestore/testapp/ProjectSettings/NavMeshAreas.asset @@ -0,0 +1,71 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!126 &1 +NavMeshAreas: + m_ObjectHideFlags: 0 + serializedVersion: 2 + areas: + - name: Walkable + cost: 1 + - name: Not Walkable + cost: 1 + - name: Jump + cost: 2 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 diff --git a/firestore/testapp/ProjectSettings/NetworkManager.asset b/firestore/testapp/ProjectSettings/NetworkManager.asset new file mode 100644 index 000000000..5dc6a831d --- /dev/null +++ b/firestore/testapp/ProjectSettings/NetworkManager.asset @@ -0,0 +1,8 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!149 &1 +NetworkManager: + m_ObjectHideFlags: 0 + m_DebugLevel: 0 + m_Sendrate: 15 + m_AssetToPrefab: {} diff --git a/firestore/testapp/ProjectSettings/Physics2DSettings.asset b/firestore/testapp/ProjectSettings/Physics2DSettings.asset new file mode 100644 index 000000000..7e9e664f2 --- /dev/null +++ b/firestore/testapp/ProjectSettings/Physics2DSettings.asset @@ -0,0 +1,25 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!19 &1 +Physics2DSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Gravity: {x: 0, y: -9.81} + m_DefaultMaterial: {fileID: 0} + m_VelocityIterations: 8 + m_PositionIterations: 3 + m_VelocityThreshold: 1 + m_MaxLinearCorrection: 0.2 + m_MaxAngularCorrection: 8 + m_MaxTranslationSpeed: 100 + m_MaxRotationSpeed: 360 + m_MinPenetrationForPenalty: 0.01 + m_BaumgarteScale: 0.2 + m_BaumgarteTimeOfImpactScale: 0.75 + m_TimeToSleep: 0.5 + m_LinearSleepTolerance: 0.01 + m_AngularSleepTolerance: 2 + m_QueriesHitTriggers: 1 + m_QueriesStartInColliders: 1 + m_ChangeStopsCallbacks: 0 + m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff diff --git a/firestore/testapp/ProjectSettings/ProjectSettings.asset b/firestore/testapp/ProjectSettings/ProjectSettings.asset new file mode 100644 index 000000000..31eb3409b --- /dev/null +++ b/firestore/testapp/ProjectSettings/ProjectSettings.asset @@ -0,0 +1,763 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!129 &1 +PlayerSettings: + m_ObjectHideFlags: 0 + serializedVersion: 14 + productGUID: 8b7d5e9f5e7e04e6c980d1a5558268b4 + AndroidProfiler: 0 + AndroidFilterTouchesWhenObscured: 0 + defaultScreenOrientation: 4 + targetDevice: 2 + useOnDemandResources: 0 + accelerometerFrequency: 60 + companyName: Google + productName: Cloud Firestore for Firebase Unity Testapp + defaultCursor: {fileID: 0} + cursorHotspot: {x: 0, y: 0} + m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1} + m_ShowUnitySplashScreen: 1 + m_ShowUnitySplashLogo: 1 + m_SplashScreenOverlayOpacity: 1 + m_SplashScreenAnimation: 1 + m_SplashScreenLogoStyle: 1 + m_SplashScreenDrawMode: 0 + m_SplashScreenBackgroundAnimationZoom: 1 + m_SplashScreenLogoAnimationZoom: 1 + m_SplashScreenBackgroundLandscapeAspect: 1 + m_SplashScreenBackgroundPortraitAspect: 1 + m_SplashScreenBackgroundLandscapeUvs: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + m_SplashScreenBackgroundPortraitUvs: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + m_SplashScreenLogos: [] + m_VirtualRealitySplashScreen: {fileID: 0} + m_HolographicTrackingLossScreen: {fileID: 0} + defaultScreenWidth: 1024 + defaultScreenHeight: 768 + defaultScreenWidthWeb: 960 + defaultScreenHeightWeb: 600 + m_StereoRenderingPath: 0 + m_ActiveColorSpace: 0 + m_MTRendering: 1 + m_StackTraceTypes: 010000000100000001000000010000000100000001000000 + iosShowActivityIndicatorOnLoading: -1 + androidShowActivityIndicatorOnLoading: -1 + tizenShowActivityIndicatorOnLoading: -1 + iosAppInBackgroundBehavior: 0 + displayResolutionDialog: 1 + iosAllowHTTPDownload: 0 + allowedAutorotateToPortrait: 1 + allowedAutorotateToPortraitUpsideDown: 1 + allowedAutorotateToLandscapeRight: 1 + allowedAutorotateToLandscapeLeft: 1 + useOSAutorotation: 1 + use32BitDisplayBuffer: 1 + preserveFramebufferAlpha: 0 + disableDepthAndStencilBuffers: 0 + androidBlitType: 0 + defaultIsFullScreen: 1 + defaultIsNativeResolution: 1 + macRetinaSupport: 1 + runInBackground: 1 + captureSingleScreen: 0 + muteOtherAudioSources: 0 + Prepare IOS For Recording: 0 + Force IOS Speakers When Recording: 0 + deferSystemGesturesMode: 0 + hideHomeButton: 0 + submitAnalytics: 1 + usePlayerLog: 1 + bakeCollisionMeshes: 0 + forceSingleInstance: 0 + resizableWindow: 0 + useMacAppStoreValidation: 0 + macAppStoreCategory: public.app-category.games + gpuSkinning: 0 + graphicsJobs: 0 + xboxPIXTextureCapture: 0 + xboxEnableAvatar: 0 + xboxEnableKinect: 0 + xboxEnableKinectAutoTracking: 0 + xboxEnableFitness: 0 + visibleInBackground: 0 + allowFullscreenSwitch: 1 + graphicsJobMode: 0 + macFullscreenMode: 2 + d3d11FullscreenMode: 1 + xboxSpeechDB: 0 + xboxEnableHeadOrientation: 0 + xboxEnableGuest: 0 + xboxEnablePIXSampling: 0 + metalFramebufferOnly: 0 + n3dsDisableStereoscopicView: 0 + n3dsEnableSharedListOpt: 1 + n3dsEnableVSync: 0 + xboxOneResolution: 0 + xboxOneSResolution: 0 + xboxOneXResolution: 3 + xboxOneMonoLoggingLevel: 0 + xboxOneLoggingLevel: 1 + xboxOneDisableEsram: 0 + xboxOnePresentImmediateThreshold: 0 + videoMemoryForVertexBuffers: 0 + psp2PowerMode: 0 + psp2AcquireBGM: 1 + wiiUTVResolution: 0 + wiiUGamePadMSAA: 1 + wiiUSupportsNunchuk: 0 + wiiUSupportsClassicController: 0 + wiiUSupportsBalanceBoard: 0 + wiiUSupportsMotionPlus: 0 + wiiUSupportsProController: 0 + wiiUAllowScreenCapture: 1 + wiiUControllerCount: 0 + m_SupportedAspectRatios: + 4:3: 1 + 5:4: 1 + 16:10: 1 + 16:9: 1 + Others: 1 + bundleVersion: 1.0 + preloadedAssets: [] + metroInputSource: 0 + wsaTransparentSwapchain: 0 + m_HolographicPauseOnTrackingLoss: 1 + xboxOneDisableKinectGpuReservation: 0 + xboxOneEnable7thCore: 0 + vrSettings: + cardboard: + depthFormat: 0 + enableTransitionView: 0 + daydream: + depthFormat: 0 + useSustainedPerformanceMode: 0 + enableVideoLayer: 0 + useProtectedVideoMemory: 0 + minimumSupportedHeadTracking: 0 + maximumSupportedHeadTracking: 1 + hololens: + depthFormat: 1 + depthBufferSharingEnabled: 0 + oculus: + sharedDepthBuffer: 0 + dashSupport: 0 + protectGraphicsMemory: 0 + useHDRDisplay: 0 + m_ColorGamuts: 00000000 + targetPixelDensity: 30 + resolutionScalingMode: 0 + androidSupportedAspectRatio: 1 + androidMaxAspectRatio: 2.1 + applicationIdentifier: + Android: com.google.firebase.firestore.unity.testapp + Standalone: unity.Google.Cloud Firestore for Firebase Unity Testapp + Tizen: com.google.firebase.firestore.unity.testapp + iOS: com.google.firebase.firestore.unity.testapp + tvOS: com.google.firebase.firestore.unity.testapp + buildNumber: + iOS: 0 + AndroidBundleVersionCode: 1 + AndroidMinSdkVersion: 16 + AndroidTargetSdkVersion: 0 + AndroidPreferredInstallLocation: 1 + aotOptions: + stripEngineCode: 1 + iPhoneStrippingLevel: 0 + iPhoneScriptCallOptimization: 0 + ForceInternetPermission: 0 + ForceSDCardPermission: 0 + CreateWallpaper: 0 + APKExpansionFiles: 0 + keepLoadedShadersAlive: 0 + StripUnusedMeshComponents: 0 + VertexChannelCompressionMask: + serializedVersion: 2 + m_Bits: 238 + iPhoneSdkVersion: 988 + iOSTargetOSVersionString: 10.0 + tvOSSdkVersion: 0 + tvOSRequireExtendedGameController: 0 + tvOSTargetOSVersionString: 9.0 + uIPrerenderedIcon: 0 + uIRequiresPersistentWiFi: 0 + uIRequiresFullScreen: 1 + uIStatusBarHidden: 1 + uIExitOnSuspend: 0 + uIStatusBarStyle: 0 + iPhoneSplashScreen: {fileID: 0} + iPhoneHighResSplashScreen: {fileID: 0} + iPhoneTallHighResSplashScreen: {fileID: 0} + iPhone47inSplashScreen: {fileID: 0} + iPhone55inPortraitSplashScreen: {fileID: 0} + iPhone55inLandscapeSplashScreen: {fileID: 0} + iPhone58inPortraitSplashScreen: {fileID: 0} + iPhone58inLandscapeSplashScreen: {fileID: 0} + iPadPortraitSplashScreen: {fileID: 0} + iPadHighResPortraitSplashScreen: {fileID: 0} + iPadLandscapeSplashScreen: {fileID: 0} + iPadHighResLandscapeSplashScreen: {fileID: 0} + appleTVSplashScreen: {fileID: 0} + appleTVSplashScreen2x: {fileID: 0} + tvOSSmallIconLayers: [] + tvOSSmallIconLayers2x: [] + tvOSLargeIconLayers: [] + tvOSTopShelfImageLayers: [] + tvOSTopShelfImageLayers2x: [] + tvOSTopShelfImageWideLayers: [] + tvOSTopShelfImageWideLayers2x: [] + iOSLaunchScreenType: 0 + iOSLaunchScreenPortrait: {fileID: 0} + iOSLaunchScreenLandscape: {fileID: 0} + iOSLaunchScreenBackgroundColor: + serializedVersion: 2 + rgba: 0 + iOSLaunchScreenFillPct: 100 + iOSLaunchScreenSize: 100 + iOSLaunchScreenCustomXibPath: + iOSLaunchScreeniPadType: 0 + iOSLaunchScreeniPadImage: {fileID: 0} + iOSLaunchScreeniPadBackgroundColor: + serializedVersion: 2 + rgba: 0 + iOSLaunchScreeniPadFillPct: 100 + iOSLaunchScreeniPadSize: 100 + iOSLaunchScreeniPadCustomXibPath: + iOSUseLaunchScreenStoryboard: 0 + iOSLaunchScreenCustomStoryboardPath: + iOSDeviceRequirements: [] + iOSURLSchemes: + - firebase-game-loop + iOSBackgroundModes: 0 + iOSMetalForceHardShadows: 0 + metalEditorSupport: 0 + metalAPIValidation: 1 + iOSRenderExtraFrameOnPause: 1 + appleDeveloperTeamID: + iOSManualSigningProvisioningProfileID: + tvOSManualSigningProvisioningProfileID: + appleEnableAutomaticSigning: 0 + clonedFromGUID: 00000000000000000000000000000000 + AndroidTargetDevice: 0 + AndroidSplashScreenScale: 0 + androidSplashScreen: {fileID: 0} + AndroidKeystoreName: + AndroidKeyaliasName: + AndroidTVCompatibility: 1 + AndroidIsGame: 1 + AndroidEnableTango: 0 + androidEnableBanner: 0 + androidUseLowAccuracyLocation: 0 + m_AndroidBanners: + - width: 320 + height: 180 + banner: {fileID: 0} + androidGamepadSupportLevel: 0 + resolutionDialogBanner: {fileID: 0} + m_BuildTargetIcons: + - m_BuildTarget: + m_Icons: + - serializedVersion: 2 + m_Icon: {fileID: 0} + m_Width: 128 + m_Height: 128 + m_Kind: 0 + - m_BuildTarget: Android + m_Icons: + - serializedVersion: 2 + m_Icon: {fileID: 2800000, guid: 35f8a50c66c0747188f03b077b16626b, type: 3} + m_Width: 192 + m_Height: 192 + m_Kind: 0 + - serializedVersion: 2 + m_Icon: {fileID: 0} + m_Width: 144 + m_Height: 144 + m_Kind: 0 + - serializedVersion: 2 + m_Icon: {fileID: 0} + m_Width: 96 + m_Height: 96 + m_Kind: 0 + - serializedVersion: 2 + m_Icon: {fileID: 0} + m_Width: 72 + m_Height: 72 + m_Kind: 0 + - serializedVersion: 2 + m_Icon: {fileID: 0} + m_Width: 48 + m_Height: 48 + m_Kind: 0 + - serializedVersion: 2 + m_Icon: {fileID: 0} + m_Width: 36 + m_Height: 36 + m_Kind: 0 + m_BuildTargetBatching: [] + m_BuildTargetGraphicsAPIs: [] + m_BuildTargetVRSettings: + - m_BuildTarget: Android + m_Enabled: 0 + m_Devices: + - Oculus + - m_BuildTarget: Metro + m_Enabled: 0 + m_Devices: [] + - m_BuildTarget: N3DS + m_Enabled: 0 + m_Devices: [] + - m_BuildTarget: PS3 + m_Enabled: 0 + m_Devices: [] + - m_BuildTarget: PS4 + m_Enabled: 0 + m_Devices: + - PlayStationVR + - m_BuildTarget: PSM + m_Enabled: 0 + m_Devices: [] + - m_BuildTarget: PSP2 + m_Enabled: 0 + m_Devices: [] + - m_BuildTarget: SamsungTV + m_Enabled: 0 + m_Devices: [] + - m_BuildTarget: Standalone + m_Enabled: 0 + m_Devices: + - Oculus + - m_BuildTarget: Tizen + m_Enabled: 0 + m_Devices: [] + - m_BuildTarget: WebGL + m_Enabled: 0 + m_Devices: [] + - m_BuildTarget: WebPlayer + m_Enabled: 0 + m_Devices: [] + - m_BuildTarget: WiiU + m_Enabled: 0 + m_Devices: [] + - m_BuildTarget: Xbox360 + m_Enabled: 0 + m_Devices: [] + - m_BuildTarget: XboxOne + m_Enabled: 0 + m_Devices: [] + - m_BuildTarget: iOS + m_Enabled: 0 + m_Devices: [] + - m_BuildTarget: tvOS + m_Enabled: 0 + m_Devices: [] + m_BuildTargetEnableVuforiaSettings: [] + openGLRequireES31: 0 + openGLRequireES31AEP: 0 + m_TemplateCustomTags: {} + mobileMTRendering: + iPhone: 1 + tvOS: 1 + m_BuildTargetGroupLightmapEncodingQuality: + - m_BuildTarget: Standalone + m_EncodingQuality: 1 + - m_BuildTarget: XboxOne + m_EncodingQuality: 1 + - m_BuildTarget: PS4 + m_EncodingQuality: 1 + wiiUTitleID: 0005000011000000 + wiiUGroupID: 00010000 + wiiUCommonSaveSize: 4096 + wiiUAccountSaveSize: 2048 + wiiUOlvAccessKey: 0 + wiiUTinCode: 0 + wiiUJoinGameId: 0 + wiiUJoinGameModeMask: 0000000000000000 + wiiUCommonBossSize: 0 + wiiUAccountBossSize: 0 + wiiUAddOnUniqueIDs: [] + wiiUMainThreadStackSize: 3072 + wiiULoaderThreadStackSize: 1024 + wiiUSystemHeapSize: 128 + wiiUTVStartupScreen: {fileID: 0} + wiiUGamePadStartupScreen: {fileID: 0} + wiiUDrcBufferDisabled: 0 + wiiUProfilerLibPath: + playModeTestRunnerEnabled: 0 + actionOnDotNetUnhandledException: 1 + enableInternalProfiler: 0 + logObjCUncaughtExceptions: 1 + enableCrashReportAPI: 0 + cameraUsageDescription: + locationUsageDescription: + microphoneUsageDescription: + switchNetLibKey: + switchSocketMemoryPoolSize: 6144 + switchSocketAllocatorPoolSize: 128 + switchSocketConcurrencyLimit: 14 + switchScreenResolutionBehavior: 2 + switchUseCPUProfiler: 0 + switchApplicationID: 0x01004b9000490000 + switchNSODependencies: + switchTitleNames_0: + switchTitleNames_1: + switchTitleNames_2: + switchTitleNames_3: + switchTitleNames_4: + switchTitleNames_5: + switchTitleNames_6: + switchTitleNames_7: + switchTitleNames_8: + switchTitleNames_9: + switchTitleNames_10: + switchTitleNames_11: + switchTitleNames_12: + switchTitleNames_13: + switchTitleNames_14: + switchPublisherNames_0: + switchPublisherNames_1: + switchPublisherNames_2: + switchPublisherNames_3: + switchPublisherNames_4: + switchPublisherNames_5: + switchPublisherNames_6: + switchPublisherNames_7: + switchPublisherNames_8: + switchPublisherNames_9: + switchPublisherNames_10: + switchPublisherNames_11: + switchPublisherNames_12: + switchPublisherNames_13: + switchPublisherNames_14: + switchIcons_0: {fileID: 0} + switchIcons_1: {fileID: 0} + switchIcons_2: {fileID: 0} + switchIcons_3: {fileID: 0} + switchIcons_4: {fileID: 0} + switchIcons_5: {fileID: 0} + switchIcons_6: {fileID: 0} + switchIcons_7: {fileID: 0} + switchIcons_8: {fileID: 0} + switchIcons_9: {fileID: 0} + switchIcons_10: {fileID: 0} + switchIcons_11: {fileID: 0} + switchIcons_12: {fileID: 0} + switchIcons_13: {fileID: 0} + switchIcons_14: {fileID: 0} + switchSmallIcons_0: {fileID: 0} + switchSmallIcons_1: {fileID: 0} + switchSmallIcons_2: {fileID: 0} + switchSmallIcons_3: {fileID: 0} + switchSmallIcons_4: {fileID: 0} + switchSmallIcons_5: {fileID: 0} + switchSmallIcons_6: {fileID: 0} + switchSmallIcons_7: {fileID: 0} + switchSmallIcons_8: {fileID: 0} + switchSmallIcons_9: {fileID: 0} + switchSmallIcons_10: {fileID: 0} + switchSmallIcons_11: {fileID: 0} + switchSmallIcons_12: {fileID: 0} + switchSmallIcons_13: {fileID: 0} + switchSmallIcons_14: {fileID: 0} + switchManualHTML: + switchAccessibleURLs: + switchLegalInformation: + switchMainThreadStackSize: 1048576 + switchPresenceGroupId: + switchLogoHandling: 0 + switchReleaseVersion: 0 + switchDisplayVersion: 1.0.0 + switchStartupUserAccount: 0 + switchTouchScreenUsage: 0 + switchSupportedLanguagesMask: 0 + switchLogoType: 0 + switchApplicationErrorCodeCategory: + switchUserAccountSaveDataSize: 0 + switchUserAccountSaveDataJournalSize: 0 + switchApplicationAttribute: 0 + switchCardSpecSize: -1 + switchCardSpecClock: -1 + switchRatingsMask: 0 + switchRatingsInt_0: 0 + switchRatingsInt_1: 0 + switchRatingsInt_2: 0 + switchRatingsInt_3: 0 + switchRatingsInt_4: 0 + switchRatingsInt_5: 0 + switchRatingsInt_6: 0 + switchRatingsInt_7: 0 + switchRatingsInt_8: 0 + switchRatingsInt_9: 0 + switchRatingsInt_10: 0 + switchRatingsInt_11: 0 + switchLocalCommunicationIds_0: + switchLocalCommunicationIds_1: + switchLocalCommunicationIds_2: + switchLocalCommunicationIds_3: + switchLocalCommunicationIds_4: + switchLocalCommunicationIds_5: + switchLocalCommunicationIds_6: + switchLocalCommunicationIds_7: + switchParentalControl: 0 + switchAllowsScreenshot: 1 + switchAllowsVideoCapturing: 1 + switchAllowsRuntimeAddOnContentInstall: 0 + switchDataLossConfirmation: 0 + switchSupportedNpadStyles: 3 + switchSocketConfigEnabled: 0 + switchTcpInitialSendBufferSize: 32 + switchTcpInitialReceiveBufferSize: 64 + switchTcpAutoSendBufferSizeMax: 256 + switchTcpAutoReceiveBufferSizeMax: 256 + switchUdpSendBufferSize: 9 + switchUdpReceiveBufferSize: 42 + switchSocketBufferEfficiency: 4 + switchSocketInitializeEnabled: 1 + switchNetworkInterfaceManagerInitializeEnabled: 1 + switchPlayerConnectionEnabled: 1 + ps4NPAgeRating: 12 + ps4NPTitleSecret: + ps4NPTrophyPackPath: + ps4ParentalLevel: 1 + ps4ContentID: ED1633-NPXX51362_00-0000000000000000 + ps4Category: 0 + ps4MasterVersion: 01.00 + ps4AppVersion: 01.00 + ps4AppType: 0 + ps4ParamSfxPath: + ps4VideoOutPixelFormat: 0 + ps4VideoOutInitialWidth: 1920 + ps4VideoOutBaseModeInitialWidth: 1920 + ps4VideoOutReprojectionRate: 60 + ps4PronunciationXMLPath: + ps4PronunciationSIGPath: + ps4BackgroundImagePath: + ps4StartupImagePath: + ps4StartupImagesFolder: + ps4IconImagesFolder: + ps4SaveDataImagePath: + ps4SdkOverride: + ps4BGMPath: + ps4ShareFilePath: + ps4ShareOverlayImagePath: + ps4PrivacyGuardImagePath: + ps4NPtitleDatPath: + ps4RemotePlayKeyAssignment: -1 + ps4RemotePlayKeyMappingDir: + ps4PlayTogetherPlayerCount: 0 + ps4EnterButtonAssignment: 1 + ps4ApplicationParam1: 0 + ps4ApplicationParam2: 0 + ps4ApplicationParam3: 0 + ps4ApplicationParam4: 0 + ps4DownloadDataSize: 0 + ps4GarlicHeapSize: 2048 + ps4ProGarlicHeapSize: 2560 + ps4Passcode: N2qmWqBlQ9wQj99nsQzldVI5ZuGXbEWR + ps4pnSessions: 1 + ps4pnPresence: 1 + ps4pnFriends: 1 + ps4pnGameCustomData: 1 + playerPrefsSupport: 0 + restrictedAudioUsageRights: 0 + ps4UseResolutionFallback: 0 + ps4ReprojectionSupport: 0 + ps4UseAudio3dBackend: 0 + ps4SocialScreenEnabled: 0 + ps4ScriptOptimizationLevel: 0 + ps4Audio3dVirtualSpeakerCount: 14 + ps4attribCpuUsage: 0 + ps4PatchPkgPath: + ps4PatchLatestPkgPath: + ps4PatchChangeinfoPath: + ps4PatchDayOne: 0 + ps4attribUserManagement: 0 + ps4attribMoveSupport: 0 + ps4attrib3DSupport: 0 + ps4attribShareSupport: 0 + ps4attribExclusiveVR: 0 + ps4disableAutoHideSplash: 0 + ps4videoRecordingFeaturesUsed: 0 + ps4contentSearchFeaturesUsed: 0 + ps4attribEyeToEyeDistanceSettingVR: 0 + ps4IncludedModules: [] + monoEnv: + psp2Splashimage: {fileID: 0} + psp2NPTrophyPackPath: + psp2NPSupportGBMorGJP: 0 + psp2NPAgeRating: 12 + psp2NPTitleDatPath: + psp2NPCommsID: + psp2NPCommunicationsID: + psp2NPCommsPassphrase: + psp2NPCommsSig: + psp2ParamSfxPath: + psp2ManualPath: + psp2LiveAreaGatePath: + psp2LiveAreaBackroundPath: + psp2LiveAreaPath: + psp2LiveAreaTrialPath: + psp2PatchChangeInfoPath: + psp2PatchOriginalPackage: + psp2PackagePassword: K5RhRXdCdG5nG5azdNMK66MuCV6GXi5x + psp2KeystoneFile: + psp2MemoryExpansionMode: 0 + psp2DRMType: 0 + psp2StorageType: 0 + psp2MediaCapacity: 0 + psp2DLCConfigPath: + psp2ThumbnailPath: + psp2BackgroundPath: + psp2SoundPath: + psp2TrophyCommId: + psp2TrophyPackagePath: + psp2PackagedResourcesPath: + psp2SaveDataQuota: 10240 + psp2ParentalLevel: 1 + psp2ShortTitle: Not Set + psp2ContentID: IV0000-ABCD12345_00-0123456789ABCDEF + psp2Category: 0 + psp2MasterVersion: 01.00 + psp2AppVersion: 01.00 + psp2TVBootMode: 0 + psp2EnterButtonAssignment: 2 + psp2TVDisableEmu: 0 + psp2AllowTwitterDialog: 1 + psp2Upgradable: 0 + psp2HealthWarning: 0 + psp2UseLibLocation: 0 + psp2InfoBarOnStartup: 0 + psp2InfoBarColor: 0 + psp2ScriptOptimizationLevel: 0 + psmSplashimage: {fileID: 0} + splashScreenBackgroundSourceLandscape: {fileID: 0} + splashScreenBackgroundSourcePortrait: {fileID: 0} + spritePackerPolicy: + webGLMemorySize: 256 + webGLExceptionSupport: 1 + webGLNameFilesAsHashes: 0 + webGLDataCaching: 0 + webGLDebugSymbols: 0 + webGLEmscriptenArgs: + webGLModulesDirectory: + webGLTemplate: APPLICATION:Default + webGLAnalyzeBuildSize: 0 + webGLUseEmbeddedResources: 0 + webGLUseWasm: 0 + webGLCompressionFormat: 1 + scriptingDefineSymbols: {} + platformArchitecture: + iOS: 2 + scriptingBackend: + Android: 0 + Standalone: 0 + WebGL: 1 + WebPlayer: 0 + iOS: 1 + incrementalIl2cppBuild: + iOS: 1 + additionalIl2CppArgs: + scriptingRuntimeVersion: 0 + apiCompatibilityLevelPerPlatform: {} + m_RenderingPath: 1 + m_MobileRenderingPath: 1 + metroPackageName: FirebaseSample + metroPackageVersion: + metroCertificatePath: + metroCertificatePassword: + metroCertificateSubject: + metroCertificateIssuer: + metroCertificateNotAfter: 0000000000000000 + metroApplicationDescription: FirebaseSample + wsaImages: {} + metroTileShortName: + metroCommandLineArgsFile: + metroTileShowName: 0 + metroMediumTileShowName: 0 + metroLargeTileShowName: 0 + metroWideTileShowName: 0 + metroDefaultTileSize: 1 + metroTileForegroundText: 1 + metroTileBackgroundColor: {r: 0.13333334, g: 0.17254902, b: 0.21568628, a: 0} + metroSplashScreenBackgroundColor: {r: 0.13333334, g: 0.17254902, b: 0.21568628, + a: 1} + metroSplashScreenUseBackgroundColor: 1 + platformCapabilities: {} + metroFTAName: + metroFTAFileTypes: [] + metroProtocolName: + metroCompilationOverrides: 1 + tizenProductDescription: + tizenProductURL: + tizenSigningProfileName: + tizenGPSPermissions: 0 + tizenMicrophonePermissions: 0 + tizenDeploymentTarget: + tizenDeploymentTargetType: -1 + tizenMinOSVersion: 1 + n3dsUseExtSaveData: 0 + n3dsCompressStaticMem: 1 + n3dsExtSaveDataNumber: 0x12345 + n3dsStackSize: 131072 + n3dsTargetPlatform: 2 + n3dsRegion: 7 + n3dsMediaSize: 0 + n3dsLogoStyle: 3 + n3dsTitle: GameName + n3dsProductCode: + n3dsApplicationId: 0xFF3FF + XboxOneProductId: + XboxOneUpdateKey: + XboxOneSandboxId: + XboxOneContentId: + XboxOneTitleId: + XboxOneSCId: + XboxOneGameOsOverridePath: + XboxOnePackagingOverridePath: + XboxOneAppManifestOverridePath: + XboxOnePackageEncryption: 0 + XboxOnePackageUpdateGranularity: 2 + XboxOneDescription: + XboxOneLanguage: + - enus + XboxOneCapability: [] + XboxOneGameRating: {} + XboxOneIsContentPackage: 0 + XboxOneEnableGPUVariability: 0 + XboxOneSockets: {} + XboxOneSplashScreen: {fileID: 0} + XboxOneAllowedProductIds: [] + XboxOnePersistentLocalStorageSize: 0 + XboxOneXTitleMemory: 8 + xboxOneScriptCompiler: 0 + vrEditorSettings: + daydream: + daydreamIconForeground: {fileID: 0} + daydreamIconBackground: {fileID: 0} + cloudServicesEnabled: + Analytics: 0 + Build: 0 + Collab: 0 + ErrorHub: 0 + Game_Performance: 0 + Hub: 0 + Purchasing: 0 + UNet: 0 + Unity_Ads: 0 + facebookSdkVersion: 7.9.4 + apiCompatibilityLevel: 2 + cloudProjectId: + projectName: + organizationId: + cloudEnabled: 0 + enableNativePlatformBackendsForNewInputSystem: 0 + disableOldInputManagerSupport: 0 + \ No newline at end of file diff --git a/firestore/testapp/ProjectSettings/ProjectVersion.txt b/firestore/testapp/ProjectSettings/ProjectVersion.txt new file mode 100644 index 000000000..e3618f13e --- /dev/null +++ b/firestore/testapp/ProjectSettings/ProjectVersion.txt @@ -0,0 +1 @@ +m_EditorVersion: 2017.4.1f1 diff --git a/firestore/testapp/ProjectSettings/QualitySettings.asset b/firestore/testapp/ProjectSettings/QualitySettings.asset new file mode 100644 index 000000000..90962e56b --- /dev/null +++ b/firestore/testapp/ProjectSettings/QualitySettings.asset @@ -0,0 +1,185 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!47 &1 +QualitySettings: + m_ObjectHideFlags: 0 + serializedVersion: 5 + m_CurrentQuality: 5 + m_QualitySettings: + - serializedVersion: 2 + name: Fastest + pixelLightCount: 0 + shadows: 0 + shadowResolution: 0 + shadowProjection: 1 + shadowCascades: 1 + shadowDistance: 15 + shadowNearPlaneOffset: 2 + shadowCascade2Split: 0.33333334 + shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} + blendWeights: 1 + textureQuality: 1 + anisotropicTextures: 0 + antiAliasing: 0 + softParticles: 0 + softVegetation: 0 + realtimeReflectionProbes: 0 + billboardsFaceCameraPosition: 0 + vSyncCount: 0 + lodBias: 0.3 + maximumLODLevel: 0 + particleRaycastBudget: 4 + asyncUploadTimeSlice: 2 + asyncUploadBufferSize: 4 + excludedTargetPlatforms: [] + - serializedVersion: 2 + name: Fast + pixelLightCount: 0 + shadows: 0 + shadowResolution: 0 + shadowProjection: 1 + shadowCascades: 1 + shadowDistance: 20 + shadowNearPlaneOffset: 2 + shadowCascade2Split: 0.33333334 + shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} + blendWeights: 2 + textureQuality: 0 + anisotropicTextures: 0 + antiAliasing: 0 + softParticles: 0 + softVegetation: 0 + realtimeReflectionProbes: 0 + billboardsFaceCameraPosition: 0 + vSyncCount: 0 + lodBias: 0.4 + maximumLODLevel: 0 + particleRaycastBudget: 16 + asyncUploadTimeSlice: 2 + asyncUploadBufferSize: 4 + excludedTargetPlatforms: [] + - serializedVersion: 2 + name: Simple + pixelLightCount: 1 + shadows: 1 + shadowResolution: 0 + shadowProjection: 1 + shadowCascades: 1 + shadowDistance: 20 + shadowNearPlaneOffset: 2 + shadowCascade2Split: 0.33333334 + shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} + blendWeights: 2 + textureQuality: 0 + anisotropicTextures: 1 + antiAliasing: 0 + softParticles: 0 + softVegetation: 0 + realtimeReflectionProbes: 0 + billboardsFaceCameraPosition: 0 + vSyncCount: 0 + lodBias: 0.7 + maximumLODLevel: 0 + particleRaycastBudget: 64 + asyncUploadTimeSlice: 2 + asyncUploadBufferSize: 4 + excludedTargetPlatforms: [] + - serializedVersion: 2 + name: Good + pixelLightCount: 2 + shadows: 2 + shadowResolution: 1 + shadowProjection: 1 + shadowCascades: 2 + shadowDistance: 40 + shadowNearPlaneOffset: 2 + shadowCascade2Split: 0.33333334 + shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} + blendWeights: 2 + textureQuality: 0 + anisotropicTextures: 1 + antiAliasing: 0 + softParticles: 0 + softVegetation: 1 + realtimeReflectionProbes: 1 + billboardsFaceCameraPosition: 1 + vSyncCount: 1 + lodBias: 1 + maximumLODLevel: 0 + particleRaycastBudget: 256 + asyncUploadTimeSlice: 2 + asyncUploadBufferSize: 4 + excludedTargetPlatforms: [] + - serializedVersion: 2 + name: Beautiful + pixelLightCount: 3 + shadows: 2 + shadowResolution: 2 + shadowProjection: 1 + shadowCascades: 2 + shadowDistance: 70 + shadowNearPlaneOffset: 2 + shadowCascade2Split: 0.33333334 + shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} + blendWeights: 4 + textureQuality: 0 + anisotropicTextures: 2 + antiAliasing: 2 + softParticles: 1 + softVegetation: 1 + realtimeReflectionProbes: 1 + billboardsFaceCameraPosition: 1 + vSyncCount: 1 + lodBias: 1.5 + maximumLODLevel: 0 + particleRaycastBudget: 1024 + asyncUploadTimeSlice: 2 + asyncUploadBufferSize: 4 + excludedTargetPlatforms: [] + - serializedVersion: 2 + name: Fantastic + pixelLightCount: 4 + shadows: 2 + shadowResolution: 2 + shadowProjection: 1 + shadowCascades: 4 + shadowDistance: 150 + shadowNearPlaneOffset: 2 + shadowCascade2Split: 0.33333334 + shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} + blendWeights: 4 + textureQuality: 0 + anisotropicTextures: 2 + antiAliasing: 2 + softParticles: 1 + softVegetation: 1 + realtimeReflectionProbes: 1 + billboardsFaceCameraPosition: 1 + vSyncCount: 1 + lodBias: 2 + maximumLODLevel: 0 + particleRaycastBudget: 4096 + asyncUploadTimeSlice: 2 + asyncUploadBufferSize: 4 + excludedTargetPlatforms: [] + m_PerPlatformDefaultQuality: + Android: 2 + BlackBerry: 2 + GLES Emulation: 5 + Nintendo 3DS: 5 + PS3: 5 + PS4: 5 + PSM: 5 + PSP2: 2 + Samsung TV: 2 + Standalone: 5 + Tizen: 2 + WP8: 5 + Web: 5 + WebGL: 3 + WiiU: 5 + Windows Store Apps: 5 + XBOX360: 5 + XboxOne: 5 + iPhone: 2 + tvOS: 5 diff --git a/firestore/testapp/ProjectSettings/TagManager.asset b/firestore/testapp/ProjectSettings/TagManager.asset new file mode 100644 index 000000000..1c92a7840 --- /dev/null +++ b/firestore/testapp/ProjectSettings/TagManager.asset @@ -0,0 +1,43 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!78 &1 +TagManager: + serializedVersion: 2 + tags: [] + layers: + - Default + - TransparentFX + - Ignore Raycast + - + - Water + - UI + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + m_SortingLayers: + - name: Default + uniqueID: 0 + locked: 0 diff --git a/firestore/testapp/ProjectSettings/TimeManager.asset b/firestore/testapp/ProjectSettings/TimeManager.asset new file mode 100644 index 000000000..a2dc235c6 --- /dev/null +++ b/firestore/testapp/ProjectSettings/TimeManager.asset @@ -0,0 +1,8 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!5 &1 +TimeManager: + m_ObjectHideFlags: 0 + Fixed Timestep: 0.02 + Maximum Allowed Timestep: 0.33333334 + m_TimeScale: 1 diff --git a/firestore/testapp/ProjectSettings/UnityConnectSettings.asset b/firestore/testapp/ProjectSettings/UnityConnectSettings.asset new file mode 100644 index 000000000..d269ea1e4 --- /dev/null +++ b/firestore/testapp/ProjectSettings/UnityConnectSettings.asset @@ -0,0 +1,35 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!310 &1 +UnityConnectSettings: + m_ObjectHideFlags: 0 + m_Enabled: 0 + m_TestMode: 0 + m_TestEventUrl: + m_TestConfigUrl: + m_TestInitMode: 0 + CrashReportingSettings: + m_EventUrl: https://perf-events.cloud.unity3d.com/api/events/crashes + m_NativeEventUrl: https://perf-events.cloud.unity3d.com/symbolicate + m_Enabled: 0 + m_CaptureEditorExceptions: 1 + UnityPurchasingSettings: + m_Enabled: 0 + m_TestMode: 0 + UnityAnalyticsSettings: + m_Enabled: 0 + m_InitializeOnStartup: 1 + m_TestMode: 0 + m_TestEventUrl: + m_TestConfigUrl: + UnityAdsSettings: + m_Enabled: 0 + m_InitializeOnStartup: 1 + m_TestMode: 0 + m_IosGameId: + m_AndroidGameId: + m_GameIds: {} + m_GameId: + PerformanceReportingSettings: + m_Enabled: 0 + \ No newline at end of file