[3.0] Apply MaybeBool transformation to fields/properties#2574
Conversation
…for simplicity The performance difference is negligible.
Not actually sure if this is ever going to be used, but I guess it will at least be consistent in behavior with BoolTransformer
|
Minimum allowed coverage is Generated by 🐒 cobertura-action against c47136e |
Exanite
left a comment
There was a problem hiding this comment.
Self review completed. Note that OpenAL/GL don't really have structs so no bindings changes there.
| /// Types to treat as boolean and their boolean schemes if different to default. | ||
| /// Types to treat as boolean and their boolean schemes if different from the default. | ||
| /// </summary> | ||
| public Dictionary<string, string?>? BoolTypes { get; init; } |
There was a problem hiding this comment.
Saving an allocation is not worth the complexity of null checking. Also, performance difference is negligible either way.
| node.AttributeLists.GetNativeTypeName() ?? node.Declaration.Type.ToString(); | ||
| if ( | ||
| config.BoolTypes.TryGetValue(nativeType, out var scheme) | ||
| || (nativeType == "bool" && node.Declaration.Type.ToString().Trim() != "bool") // stdbool.h, hopefully... |
There was a problem hiding this comment.
I'm not familiar enough with C library headers (specifically, where bool might be used) to say whether the bool handling here is important or not. This just copies the behavior from BoolTransformer.
| public override SyntaxNode? VisitPropertyDeclaration(PropertyDeclarationSyntax node) | ||
| { | ||
| // Transform bool-like properties to use MaybeBool | ||
| var nativeType = node.AttributeLists.GetNativeTypeName() ?? node.Type.ToString(); |
There was a problem hiding this comment.
On second thought, I should analyze whether this transformation is correct or not. There's some possible edge cases here.
Summary of the PR
This adds MaybeBool transformation to fields and properties in
TransformProperties, similar to howBoolTransformerforTransformFunctionscurrently works.Related issues, Discord discussions, or proposals
Discord thread: https://discord.com/channels/521092042781229087/1499733234714546286
Further Comments
Tasks: