Skip to content

Commit 4d07108

Browse files
committed
fix: Fixed concrete classes of a different type added to type database after a generic unity-object class is removed
1 parent b3b0368 commit 4d07108

3 files changed

Lines changed: 4 additions & 20 deletions

File tree

Editor/GenericTypesAnalyzer/DictInitializer.cs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,21 +94,10 @@ private static Dictionary<Type[], Type> CreateConcreteClassesDict(GenericTypeInf
9494
if (!TryGetConcreteClassType(genericTypeInfo, concreteClass, out Type value))
9595
continue;
9696

97-
// BUG: This somehow happened once. It started throwing exception after I commented out a generic class not related to genericTypeInfo nor the concrete class in question.
98-
// Would be good to have the steps to reproduce.
99-
if (value.BaseType?.GetGenericTypeDefinition() != genericTypeInfo.Type)
100-
{
101-
Debug.LogWarning($"The concrete class for type {value.BaseType} was added to the generic type {genericTypeInfo.Type.Name}. " +
102-
"This shouldn't happen. If you have steps to reproduce the bug, please report it.");
103-
104-
GenerationDatabase<TObject>.RemoveConcreteClass(genericTypeInfo, concreteClass);
105-
continue;
106-
}
107-
10897
var key = GetConcreteClassArguments(concreteClass);
10998
concreteClassesDict.Add(key, value);
11099
}
111-
100+
112101
return concreteClassesDict;
113102
}
114103

Editor/GenericTypesAnalyzer/GenericTypesAnalyzer.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,8 @@ private static void AddMissingConcreteClassesToDatabase<TObject>()
8787

8888
// Have to use the extension method explicitly to avoid ambiguous reference error between SolidUtilities.ToHashSet and NetStandard 2.1 Enumerable.ToHashSet
8989
var registeredGuids = EnumerableExtensions.ToHashSet(GenerationDatabase<TObject>.GenericTypeArguments.Values
90-
.Aggregate((allConcreteClasses, thisClasses) =>
91-
{
92-
allConcreteClasses.AddRange(thisClasses);
93-
return allConcreteClasses;
94-
})
95-
.Select(concreteClass => concreteClass.AssemblyGUID));
90+
.SelectMany(classesList => classesList)
91+
.Select(concreteClass => concreteClass.AssemblyGUID));
9692

9793
// If there are assemblies that exist in the folder but are missing from the database, add them to the database.
9894
foreach (string guid in guids)
@@ -115,7 +111,7 @@ private static void AddMissingConcreteClassesToDatabase<TObject>()
115111

116112
// Happens when the generic script file was removed but the concrete class still exists.
117113
if (genericType == null)
118-
return;
114+
continue;
119115

120116
Type genericTypeWithoutArgs = genericType.GetGenericTypeDefinition();
121117
Type[] genericArgs = genericType.GenericTypeArguments;

Editor/OnScriptsReloadActionsRunner.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ private static void OnScriptsReload()
1717
return;
1818
}
1919

20-
2120
// 1. GenericTypesAnalyzer finds a new generic MonoBehaviour and generates a DLL.
2221
// 2. Scripts are recompiled because of the DLL addition.
2322
// 3. This event is fired before GenericTypesAnalyzer is called again, and sets the custom icon.

0 commit comments

Comments
 (0)