Remove redundant primitive-key constraint for old Mono compatibility - #63
Merged
SamboyCoding merged 1 commit intoAug 17, 2026
Merged
Conversation
Contributor
|
Why would you not simply remove the constraint? It isn't actually doing anything here and the method is already only used internally through reflection |
ObjectInSpace
force-pushed
the
lazy-reflection-lookups
branch
from
August 16, 2026 06:54
97f02fb to
342fa7d
Compare
Contributor
Author
|
Good point — the caller already restricts the key type before constructing this private method, and the body doesn't rely on either constraint. I've revised the PR to remove the constraint directly and reverted the lazy lookup changes. All targets build, including netframework3.5, and all 164 tests pass. |
Contributor
Author
|
tested with Unity 5.0.1f1's embedded Mono (x86, net35). mod initialized fully, and the complete log contained no Tomlet, TypeLoadException, or TypeInitializationException failures. |
SamboyCoding
approved these changes
Aug 17, 2026
Coverage Report for CI Build 31932571884Coverage remained the same at 91.24%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
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.
Problem
TomlSerializationMethodsresolves private generic methods using reflection during type initialization. One of those methods is declared with this constraint:The
unmanagedconstraint is emitted asSystem.ValueType modreq(System.Runtime.InteropServices.UnmanagedType). Mono versions predating the fix for mono/mono#6804 cannot resolve that metadata while enumerating the type's methods and throw:Because the lookup happens in the static constructor, this prevents any use of
TomlSerializationMethods. The constraint is also present in the non-MODERN_DOTNETbranch compiled for the declarednetframework3.5target.Change
Remove the redundant
unmanaged, IConvertibleconstraint fromPrimitiveKeyedDictionaryDeserializerFor.The method is private and is only constructed through reflection after
GetDeserializerhas restrictedTKeyto integer types,bool, orchar. Its body does not rely on either constraint. Removing it therefore preserves the accepted inputs while avoiding the incompatible metadata.Verification
netframework3.5.TypeLoadExceptionorTypeInitializationException.Notes
Found while modding a Unity 5.0.1 game, where MelonLoader bundles Tomlet for its config system. I haven't added a regression test because CI does not execute the net35 output on an affected old Mono runtime.
Investigated and drafted with AI assistance. Everything above was verified as described.