Merge pull request #87550 from zaevi/fix_csharp_generic_reloading

C#: Fix sorting for generic types when reloading assemblies.
This commit is contained in:
Rémi Verschelde 2024-01-26 11:48:18 +01:00
commit 3bbf4abfaa
No known key found for this signature in database
GPG Key ID: C3336907360768E1
2 changed files with 9 additions and 2 deletions

View File

@ -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() {

View File

@ -60,6 +60,7 @@ class CSharpScript : public Script {
friend class CSharpInstance;
friend class CSharpLanguage;
friend struct CSharpScriptDepSort;
bool tool = false;
bool global_class = false;