Skip to content

Commit

Permalink
.NET: Add TypeDefinition::GetGenericArguments
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Apr 7, 2024
1 parent 3e619ff commit 4c67c3d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
23 changes: 23 additions & 0 deletions csharp-api/REFrameworkNET/TypeDefinition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,27 @@ namespace REFrameworkNET {

return (int)attributes->Call("GetLength", gcnew System::Int32(0)) > 0;
}

array<TypeDefinition^>^ TypeDefinition::GetGenericArguments() {
auto runtimeType = this->GetRuntimeType();

if (runtimeType == nullptr) {
return nullptr;
}

auto arguments = (ManagedObject^)runtimeType->Call("GetGenericArguments");

if (arguments == nullptr) {
return nullptr;
}

auto result = gcnew array<TypeDefinition^>((int)arguments->Call("get_Length", gcnew System::Int32(0)));

for (int i = 0; i < result->Length; i++) {
auto runtimeType = (ManagedObject^)arguments->Call("get_Item", gcnew System::Int32(i));
result[i] = (TypeDefinition^)runtimeType->Call("get_TypeHandle");
}

return result;
}
}
7 changes: 7 additions & 0 deletions csharp-api/REFrameworkNET/TypeDefinition.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,13 @@ public
}

bool HasAttribute(REFrameworkNET::ManagedObject^ runtimeAttribute, bool inherit);
array<TypeDefinition^>^ GetGenericArguments();

property array<TypeDefinition^>^ GenericArguments {
array<TypeDefinition^>^ get() {
return GetGenericArguments();
}
}

/*Void* GetInstance()
{
Expand Down

0 comments on commit 4c67c3d

Please sign in to comment.