From 567e6e4f7c25b3960f2ec33abe2ec071028d6f0e Mon Sep 17 00:00:00 2001 From: Susko3 Date: Wed, 17 Apr 2024 13:17:09 +0200 Subject: [PATCH] Use Utf8String directly in `fixed` statement --- SDL3-CS.SourceGeneration/FriendlyOverloadGenerator.cs | 5 +---- SDL3-CS.SourceGeneration/Helper.cs | 2 -- SDL3-CS/Utf8String.cs | 2 ++ 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/SDL3-CS.SourceGeneration/FriendlyOverloadGenerator.cs b/SDL3-CS.SourceGeneration/FriendlyOverloadGenerator.cs index c8a2935..263488c 100644 --- a/SDL3-CS.SourceGeneration/FriendlyOverloadGenerator.cs +++ b/SDL3-CS.SourceGeneration/FriendlyOverloadGenerator.cs @@ -112,10 +112,7 @@ using System; param.Identifier.ValueText + pointer_suffix) .WithInitializer( SyntaxFactory.EqualsValueClause( - SyntaxFactory.MemberAccessExpression( - SyntaxKind.SimpleMemberAccessExpression, - SyntaxFactory.IdentifierName(param.Identifier), - SyntaxFactory.IdentifierName(Helper.Utf8StringReadOnlySpanFieldName)))))), + SyntaxFactory.IdentifierName(param.Identifier))))), expr); } diff --git a/SDL3-CS.SourceGeneration/Helper.cs b/SDL3-CS.SourceGeneration/Helper.cs index 65d84f9..42e51d5 100644 --- a/SDL3-CS.SourceGeneration/Helper.cs +++ b/SDL3-CS.SourceGeneration/Helper.cs @@ -18,8 +18,6 @@ namespace SDL3.SourceGeneration public const string Utf8StringStructName = "Utf8String"; - public const string Utf8StringReadOnlySpanFieldName = "Raw"; - public static bool IsVoid(this TypeSyntax type) => type is PredefinedTypeSyntax predefined && predefined.Keyword.IsKind(SyntaxKind.VoidKeyword); diff --git a/SDL3-CS/Utf8String.cs b/SDL3-CS/Utf8String.cs index 56b8d74..253ee87 100644 --- a/SDL3-CS/Utf8String.cs +++ b/SDL3-CS/Utf8String.cs @@ -48,5 +48,7 @@ namespace SDL return new Utf8String(raw); } + + internal ref readonly byte GetPinnableReference() => ref Raw.GetPinnableReference(); } }