Repository navigation
SDL: SetVertexAttributes works with NativeAOT, and the library checks itself for it - #38
Merged
Merged
Conversation
…g, and the library checks itself for NativeAOT SetVertexAttributes<TVertex> reads TVertex's fields with reflection, without telling the trimmer to keep them: a NativeAOT publish of a game that calls it failed with IL2104 (Ageborn's did), and could have trimmed the fields away. TVertex is now [DynamicallyAccessedMembers(PublicFields)]. SDL.csproj sets IsAotCompatible, so the trim and NativeAOT analyzers run when the library builds; this was their only finding. The game consumer calls SetVertexAttributes, and test.sh checks that its NativeAOT publish still finds both fields.
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.
A game's NativeAOT publishes failed with
IL2104: Assembly 'SDL' produced trim warnings. The warning behind it:SetVertexAttributesreads the vertex type's fields with reflection, but didn't tell the trimmer to keep them. It hadn't come up before, because no published game called it yet. Besides failing the publish, the fields could have been trimmed away, so a published game would fail at startup with "Vertex type has no fields".Changes
TVertexis[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields)].SDL.csprojsetsIsAotCompatible, so the trim and NativeAOT analyzers run when the library builds. The SDK's own projects don't get the analyzers games get, which is how this slipped through. With them on, this was the only finding in the library.SetVertexAttributeson a two-field vertex type and checks that it finds 2.test.shchecks that the NativeAOT-published game printsVertex attributes: 2, on every OS.Checked locally on macOS: with
IsAotCompatibleand without the annotation, the library build fails with IL2090. With it, the solution builds, andTEST_SCOPE=platform ./src/cs/tests/Consumers/test.shpasses, including the published game's vertex check.After this merges, a release lets games that call it publish again.