Skip to content

Commit

Permalink
.NET: Fix some value types returning null
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Mar 25, 2024
1 parent 5ae4b40 commit 1140ef9
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions csharp-api/REFrameworkNET/Method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ bool Method::HandleInvokeMember_Internal(System::Object^ obj, System::String^ me
//auto methodName = binder->Name;
auto tempResult = this->Invoke(obj, args);

if (tempResult != nullptr && tempResult->QWord != 0) {
if (tempResult != nullptr) {
auto returnType = this->GetReturnType();

if (returnType == nullptr) {
Expand All @@ -120,22 +120,17 @@ bool Method::HandleInvokeMember_Internal(System::Object^ obj, System::String^ me

// Check the return type of the method and return it as a NativeObject if possible
if (!returnType->IsValueType()) {
if (returnType->GetVMObjType() == VMObjType::Object) {
if (tempResult->QWord == 0) {
result = nullptr;
return true;
}
if (tempResult->QWord == 0) {
result = nullptr;
return true;
}

if (returnType->GetVMObjType() == VMObjType::Object) {
result = gcnew REFrameworkNET::ManagedObject((::REFrameworkManagedObjectHandle)tempResult->QWord);
return true;
}

if (returnType->GetVMObjType() == VMObjType::String) {
if (tempResult->QWord == 0) {
result = nullptr;
return true;
}

// Maybe don't create the GC version and just use the native one?
auto strObject = gcnew REFrameworkNET::ManagedObject((::REFrameworkManagedObjectHandle)tempResult->QWord);
auto strType = strObject->GetTypeDefinition();
Expand Down

0 comments on commit 1140ef9

Please sign in to comment.