Skip to content

Commit

Permalink
Merge pull request #87550 from zaevi/fix_csharp_generic_reloading
Browse files Browse the repository at this point in the history
C#: Fix sorting for generic types when reloading assemblies.
  • Loading branch information
akien-mga committed Jan 26, 2024
2 parents 31baf46 + 18599c0 commit 3bbf4ab
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
10 changes: 8 additions & 2 deletions modules/mono/csharp_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -697,19 +697,25 @@ struct CSharpScriptDepSort {
// Shouldn't happen but just in case...
return false;
}
const Script *I = B->get_base_script().ptr();
const CSharpScript *I = get_base_script(B.ptr()).ptr();
while (I) {
if (I == A.ptr()) {
// A is a base of B
return true;
}

I = I->get_base_script().ptr();
I = get_base_script(I).ptr();
}

// A isn't a base of B
return false;
}

// Special fix for constructed generic types.
Ref<CSharpScript> get_base_script(const CSharpScript *p_script) const {
Ref<CSharpScript> base_script = p_script->base_script;
return base_script.is_valid() && !base_script->class_name.is_empty() ? base_script : nullptr;
}
};

void CSharpLanguage::reload_all_scripts() {
Expand Down
1 change: 1 addition & 0 deletions modules/mono/csharp_script.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class CSharpScript : public Script {

friend class CSharpInstance;
friend class CSharpLanguage;
friend struct CSharpScriptDepSort;

bool tool = false;
bool global_class = false;
Expand Down

0 comments on commit 3bbf4ab

Please sign in to comment.