From 2124a36b9b763beb131f3d74174d0f67a56122ee Mon Sep 17 00:00:00 2001 From: Elijah Date: Sun, 3 Nov 2024 12:15:16 -0800 Subject: [PATCH 1/2] Replace AddClassType->TryAddClassType --- src/UnrealPackage.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/UnrealPackage.cs b/src/UnrealPackage.cs index a55e504..d2c8631 100644 --- a/src/UnrealPackage.cs +++ b/src/UnrealPackage.cs @@ -2162,7 +2162,7 @@ private void RegisterExportedClassTypes() foreach (var exportedType in exportedTypes) { object[] attributes = exportedType.GetCustomAttributes(typeof(UnrealRegisterClassAttribute), false); - if (attributes.Length == 1) AddClassType(exportedType.Name.Substring(1), exportedType); + if (attributes.Length == 1) TryAddClassType(exportedType.Name.Substring(1), exportedType); } } @@ -2238,13 +2238,13 @@ public void WritePackageFlags() [Obsolete] public void RegisterClass(string className, Type classObject) { - AddClassType(className, classObject); + TryAddClassType(className, classObject); } [PublicAPI] - public void AddClassType(string className, Type classObject) + public bool TryAddClassType(string className, Type classObject) { - _ClassTypes.Add(className.ToLower(), classObject); + return _ClassTypes.TryAdd(className.ToLower(), classObject); } [PublicAPI] From 9f7ff0940706ade8bcffbcfd44f3d828dd23d64f Mon Sep 17 00:00:00 2001 From: Eliot Date: Mon, 4 Nov 2024 23:04:08 +0100 Subject: [PATCH 2/2] Update UnrealPackage.cs --- src/UnrealPackage.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/UnrealPackage.cs b/src/UnrealPackage.cs index d2c8631..789978e 100644 --- a/src/UnrealPackage.cs +++ b/src/UnrealPackage.cs @@ -2162,7 +2162,7 @@ private void RegisterExportedClassTypes() foreach (var exportedType in exportedTypes) { object[] attributes = exportedType.GetCustomAttributes(typeof(UnrealRegisterClassAttribute), false); - if (attributes.Length == 1) TryAddClassType(exportedType.Name.Substring(1), exportedType); + if (attributes.Length == 1) AddClassType(exportedType.Name.Substring(1), exportedType); } } @@ -2238,13 +2238,13 @@ public void WritePackageFlags() [Obsolete] public void RegisterClass(string className, Type classObject) { - TryAddClassType(className, classObject); + AddClassType(className, classObject); } [PublicAPI] - public bool TryAddClassType(string className, Type classObject) + public void AddClassType(string className, Type classObject) { - return _ClassTypes.TryAdd(className.ToLower(), classObject); + _ClassTypes[className.ToLower()] = classObject; } [PublicAPI]