Fix duplicate types in generated assemblies on Unity 6.4+#266
Open
acan1980728690 wants to merge 2 commits into
Open
Fix duplicate types in generated assemblies on Unity 6.4+#266acan1980728690 wants to merge 2 commits into
acan1980728690 wants to merge 2 commits into
Conversation
- Use unified type name conversion (MakeValidInSource) for all unstripped types - Look up types by FullName consistently instead of simple name - Skip nested types when parent type is not in the output assembly - Add null guard for Resolve() in HasNonBlittableFields recursion
ds5678
requested changes
May 29, 2026
Comment on lines
+139
to
+144
| if (fieldDefinition.Signature.FieldType.Namespace?.StartsWith("System") ?? false) | ||
| { | ||
| var resolved = fieldDefinition.Signature.FieldType.Resolve(); | ||
| if (resolved != null && HasNonBlittableFields(resolved)) | ||
| return true; | ||
| } |
Collaborator
There was a problem hiding this comment.
This is cursed, but it's not your fault. I see no reason for:
- A System namespace check
- Resolving a TypeSignature to a TypeDefinition, which removes the type arguments if the signature is a generic instance type
I'm not asking you to change anything, except maybe returning true for null resolved; I'm just saying that the preexisting code is extremely flawed.
| var convertedTypeName = GetConvertedUnityTypeName(processedAssembly.GlobalContext, unityType); | ||
|
|
||
| // If the parent type does not exist in the rewritten assembly, this nested type cannot be emitted safely. | ||
| // Promoting it to a top-level type creates orphan compiler-generated types such as __O/__c. |
Collaborator
There was a problem hiding this comment.
That is so cursed that we were doing this before.
Collaborator
|
Note that this shouldn't be an issue in v2 (#238) |
Co-authored-by: Jeremy Pritts <49847914+ds5678@users.noreply.github.com>
3d32cf1 to
801a7ae
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The game crashed on version 6000.4.7. The content of ErrorLog.log is as follows
Cause
The real error was BadImageFormatException: Duplicate type with name '__O' — the FileNotFoundException was just the surface. Pass79UnstripTypes was producing a UnityEngine.CoreModule.dll with duplicate types, which CoreCLR refused to load. Three bugs in the pass caused this:
Fix