Browse Source

Merge pull request #87550 from zaevi/fix_csharp_generic_reloading

C#: Fix sorting for generic types when reloading assemblies.
Rémi Verschelde 1 year ago
parent
commit
3bbf4abfaa
2 changed files with 9 additions and 2 deletions
  1. 8 2
      modules/mono/csharp_script.cpp
  2. 1 0
      modules/mono/csharp_script.h

+ 8 - 2
modules/mono/csharp_script.cpp

@@ -697,19 +697,25 @@ struct CSharpScriptDepSort {
 			// Shouldn't happen but just in case...
 			// Shouldn't happen but just in case...
 			return false;
 			return false;
 		}
 		}
-		const Script *I = B->get_base_script().ptr();
+		const CSharpScript *I = get_base_script(B.ptr()).ptr();
 		while (I) {
 		while (I) {
 			if (I == A.ptr()) {
 			if (I == A.ptr()) {
 				// A is a base of B
 				// A is a base of B
 				return true;
 				return true;
 			}
 			}
 
 
-			I = I->get_base_script().ptr();
+			I = get_base_script(I).ptr();
 		}
 		}
 
 
 		// A isn't a base of B
 		// A isn't a base of B
 		return false;
 		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() {
 void CSharpLanguage::reload_all_scripts() {

+ 1 - 0
modules/mono/csharp_script.h

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