Handle keywords in field names for custom types

このコミットが含まれているのは:
Sergio Pedri committed 2022-06-05 13:37:22 +02:00
1 親 9e07f66d0b
コミット 94b40e5d61
2ファイル変更
+20 -8

検索条件に一致するファイルはありません

@@ -337,15 +337,21 @@ partial class ID2D1ShaderGenerator
INamedTypeSymbol fieldType = (INamedTypeSymbol)field.Type;
// Convert the name to the fully qualified HLSL version
if (!HlslKnownTypes.TryGetMappedName(fieldType.GetFullMetadataName(), out string? mapped))
if (!HlslKnownTypes.TryGetMappedName(fieldType.GetFullMetadataName(), out string? mappedType))
{
mapped = fieldType.GetFullMetadataName().ToHlslIdentifierName();
mappedType = fieldType.GetFullMetadataName().ToHlslIdentifierName();
}
// Get the field name as a valid HLSL identifier
if (!HlslKnownKeywords.TryGetMappedName(field.Name, out string? mappedName))
{
mappedName = field.Name;
}
structDeclaration = structDeclaration.AddMembers(
FieldDeclaration(VariableDeclaration(
IdentifierName(mapped!)).AddVariables(
VariableDeclarator(Identifier(field.Name)))));
IdentifierName(mappedType!)).AddVariables(
VariableDeclarator(Identifier(mappedName!)))));
}
// Insert the trailing ; right after the closing bracket (after normalization)
+10 -4
ファイルの表示
@@ -465,15 +465,21 @@ partial class IShaderGenerator
INamedTypeSymbol fieldType = (INamedTypeSymbol)field.Type;
// Convert the name to the fully qualified HLSL version
if (!HlslKnownTypes.TryGetMappedName(fieldType.GetFullMetadataName(), out string? mapped))
if (!HlslKnownTypes.TryGetMappedName(fieldType.GetFullMetadataName(), out string? mappedType))
{
mapped = fieldType.GetFullMetadataName().ToHlslIdentifierName();
mappedType = fieldType.GetFullMetadataName().ToHlslIdentifierName();
}
// Get the field name as a valid HLSL identifier
if (!HlslKnownKeywords.TryGetMappedName(field.Name, out string? mappedName))
{
mappedName = field.Name;
}
structDeclaration = structDeclaration.AddMembers(
FieldDeclaration(VariableDeclaration(
IdentifierName(mapped!)).AddVariables(
VariableDeclarator(Identifier(field.Name)))));
IdentifierName(mappedType!)).AddVariables(
VariableDeclarator(Identifier(mappedName!)))));
}
// Insert the trailing ; right after the closing bracket (after normalization)