[ https://issues.apache.org/jira/browse/GEODE-9559?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17408966#comment-17408966 ]
ASF GitHub Bot commented on GEODE-9559: --------------------------------------- mmartell commented on a change in pull request #862: URL: https://github.com/apache/geode-native/pull/862#discussion_r701247030 ########## File path: clicache/src/ExceptionTypes.hpp ########## @@ -266,417 +266,3411 @@ namespace Apache : Exception( info, context ) { } }; -/// Handle geode exceptions from native layer and convert to managed -/// exceptions. -#define _GF_MG_EXCEPTION_TRY2 \ - try { -#define _GF_MG_EXCEPTION_CATCH_ALL2 \ - } \ - catch (const apache::geode::client::Exception& ex) { \ - throw Apache::Geode::Client::GeodeException::Get(ex); \ - } \ - catch (System::AccessViolationException^ ex) { \ - throw ex; \ - } - - -/// Creates a class <c>x</c> named for each exception <c>y</c>. -#define _GF_MG_EXCEPTION_DEF4(x,y) \ - [Serializable] \ - public ref class x: public GeodeException \ - { \ - public: \ - \ - /** <summary>Default constructor</summary> */ \ - x( ) \ - : GeodeException( ) { } \ - \ - /** <summary> - * Constructor to create an exception object with the given message. - * </summary> - * <param name="message">The exception message.</param> - */ \ - x( String^ message ) \ - : GeodeException( message ) { } \ - \ - /** <summary> - * Constructor to create an exception object with the given message - * and with the given inner exception. - * </summary> - * <param name="message">The exception message.</param> - * <param name="innerException">The inner exception object.</param> - */ \ - x( String^ message, System::Exception^ innerException ) \ - : GeodeException( message, innerException ) { } \ - \ - protected: \ - \ - /** <summary> - * Initializes a new instance of the class with serialized data. - * This allows deserialization of this exception in .NET remoting. - * </summary> - * <param name="info"> - * holds the serialized object data about the exception being thrown - * </param> - * <param name="context"> - * contains contextual information about the source or destination - * </param> - */ \ - x( SerializationInfo^ info, StreamingContext context ) \ - : GeodeException( info, context ) { } \ - \ - internal: \ - x(const apache::geode::client::y& nativeEx) \ - : GeodeException(marshal_as<String^>(nativeEx.getMessage()), \ - gcnew GeodeException(GeodeException::GetStackTrace( \ - nativeEx))) { } \ - \ - x(const apache::geode::client::y& nativeEx, Exception^ innerException) \ - : GeodeException(marshal_as<String^>(nativeEx.getMessage()), \ - innerException) { } \ - \ - static GeodeException^ Create(const apache::geode::client::Exception& ex, \ - Exception^ innerException) \ - { \ - const apache::geode::client::y* nativeEx = dynamic_cast<const apache::geode::client::y*>( &ex ); \ - if (nativeEx != nullptr) { \ - if (innerException == nullptr) { \ - return gcnew x(*nativeEx); \ - } \ - else { \ - return gcnew x(*nativeEx, innerException); \ - } \ - } \ - return nullptr; \ - } \ - virtual std::shared_ptr<apache::geode::client::Exception> GetNative() override \ - { \ - auto message = marshal_as<std::string>(this->Message + ": " + this->StackTrace); \ - if (this->InnerException != nullptr) { \ - auto cause = GeodeException::GetNative(this->InnerException); \ - message += "Caused by: " + cause->getMessage(); \ - } \ - return std::make_shared<apache::geode::client::y>(message); \ - } \ - } - -/// Creates a class named for each exception <c>x</c>. -#define _GF_MG_EXCEPTION_DEF3(x) _GF_MG_EXCEPTION_DEF4(x,x) - - // For all the native Geode C++ exceptions, a corresponding definition - // should be added below *AND* it should also be added to the static array - // in ExceptionTypesMN.cpp using _GF_MG_EXCEPTION_ADD3( x ) - + // should be added below. /// <summary> /// A geode assertion exception. /// </summary> - _GF_MG_EXCEPTION_DEF3( AssertionException ); + [Serializable] public ref class AssertionException + : public GeodeException { + public: + AssertionException() : GeodeException() {} + AssertionException(String ^ message) : GeodeException(message) {} + AssertionException(String ^ message, System::Exception ^ innerException) + : GeodeException(message, innerException) {} + + protected: + AssertionException(SerializationInfo ^ info, StreamingContext context) + : GeodeException(info, context) {} + internal: + AssertionException( + const apache::geode::client::AssertionException &nativeEx) + : GeodeException(marshal_as<String ^>(nativeEx.getMessage()), + gcnew GeodeException( + GeodeException::GetStackTrace(nativeEx))) {} + AssertionException( + const apache::geode::client::AssertionException &nativeEx, + Exception ^ innerException) + : GeodeException(marshal_as<String ^>(nativeEx.getMessage()), + innerException) {} + static GeodeException ^ + Create(const apache::geode::client::Exception &ex, + Exception ^ innerException) { + const apache::geode::client::AssertionException *nativeEx = + dynamic_cast< + const apache::geode::client::AssertionException *>(&ex); + if (nativeEx != nullptr) { + if (innerException == nullptr) { + return gcnew AssertionException(*nativeEx); + } else { + return gcnew AssertionException(*nativeEx, innerException); + } + } + return nullptr; + } + virtual std::shared_ptr<apache::geode::client::Exception> GetNative() + override { + auto message = + marshal_as<std::string>(this->Message + ": " + this->StackTrace); + if (this->InnerException != nullptr) { + auto cause = GeodeException::GetNative(this->InnerException); + message += "Caused by: " + cause->getMessage(); + } + return std::make_shared<apache::geode::client::AssertionException>( + message); + } + }; /// <summary> /// Thrown when an argument to a method is illegal. /// </summary> - _GF_MG_EXCEPTION_DEF3( IllegalArgumentException ); + [Serializable] public ref class IllegalArgumentException + : public GeodeException { + public: + IllegalArgumentException() : GeodeException() {} + IllegalArgumentException(String ^ message) : GeodeException(message) {} + IllegalArgumentException(String ^ message, + System::Exception ^ innerException) + : GeodeException(message, innerException) {} + + protected: + IllegalArgumentException(SerializationInfo ^ info, + StreamingContext context) + : GeodeException(info, context) {} + internal: + IllegalArgumentException( + const apache::geode::client::IllegalArgumentException + &nativeEx) + : GeodeException(marshal_as<String ^>(nativeEx.getMessage()), + gcnew GeodeException( + GeodeException::GetStackTrace(nativeEx))) {} + IllegalArgumentException( + const apache::geode::client::IllegalArgumentException &nativeEx, + Exception ^ innerException) + : GeodeException(marshal_as<String ^>(nativeEx.getMessage()), + innerException) {} + static GeodeException ^ + Create(const apache::geode::client::Exception &ex, + Exception ^ innerException) { + const apache::geode::client::IllegalArgumentException *nativeEx = + dynamic_cast< + const apache::geode::client::IllegalArgumentException *>( + &ex); + if (nativeEx != nullptr) { + if (innerException == nullptr) { + return gcnew IllegalArgumentException(*nativeEx); + } else { + return gcnew IllegalArgumentException(*nativeEx, + innerException); + } + } + return nullptr; + } + virtual std::shared_ptr<apache::geode::client::Exception> GetNative() + override { + auto message = + marshal_as<std::string>(this->Message + ": " + this->StackTrace); + if (this->InnerException != nullptr) { + auto cause = GeodeException::GetNative(this->InnerException); + message += "Caused by: " + cause->getMessage(); + } + return std::make_shared< + apache::geode::client::IllegalArgumentException>(message); + } + }; /// <summary> /// Thrown when the state of cache is manipulated to be illegal. /// </summary> - _GF_MG_EXCEPTION_DEF3( IllegalStateException ); + [Serializable] public ref class IllegalStateException Review comment: I don't see a way to templatize the actual name of a class. Compiler gives this error: "class template and template parameter cannot have the same name" This is probably why our native exceptions are also not templated. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@geode.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Demacroize clicache > -------------------- > > Key: GEODE-9559 > URL: https://issues.apache.org/jira/browse/GEODE-9559 > Project: Geode > Issue Type: Improvement > Components: native client > Reporter: Michael Martell > Priority: Major > Labels: pull-request-available > > Macros in C++ complicate debug efforts and code maintenance and are generally > considered old school ([https://stroustrup.com/icsm-2012-demacro.pdf).] This > PR is to remove all the complicated macros in the .NET Framework client, e.g. > the clicache module. > In addition to improving the maintainability of the clicache module, removing > the macros will greatly assist the creation of the .NET Core client. [dotPeek > |http://jetbrains.com/decompiler/] is proving to be a valuable tool in the > .NET Core project, but is currently limited by the extensive use of macros in > the clicache code. -- This message was sent by Atlassian Jira (v8.3.4#803005)