From efef426b1cfc43c64e5858f9096bdb64b84fd8e0 Mon Sep 17 00:00:00 2001 From: Lewis Smith Date: Tue, 7 Jun 2022 15:19:48 +0100 Subject: [PATCH] slight adjustment for consistency --- XmlSchemaClassGenerator/CodeUtilities.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/XmlSchemaClassGenerator/CodeUtilities.cs b/XmlSchemaClassGenerator/CodeUtilities.cs index 39e322bf..4719853f 100644 --- a/XmlSchemaClassGenerator/CodeUtilities.cs +++ b/XmlSchemaClassGenerator/CodeUtilities.cs @@ -174,8 +174,7 @@ public static string GetUniqueFieldName(this TypeModel typeModel, PropertyModel var classModel = typeModel as ClassModel; var propBackingFieldName = propertyModel.Name.ToBackingField(classModel?.Configuration.PrivateMemberPrefix); - if (!CSharp.IsValidIdentifier(propBackingFieldName.ToLower())) - propBackingFieldName = "@" + propBackingFieldName; + propBackingFieldName = CSharp.CreateEscapedIdentifier(propBackingFieldName); if (classModel == null) return propBackingFieldName; @@ -257,8 +256,8 @@ public static bool IsUsingNamespace(string namespaceName, GeneratorConfiguration public static CodeTypeReference CreateTypeReference(Type type, GeneratorConfiguration conf) { - // If the type is a keyword it will prefix it with an underscore to make it a valid identifier. - var isKeyword = CSharp.CreateValidIdentifier(CSharp.GetTypeOutput(new(type)))[0] == '_'; + // If the type is a keyword it will prefix it with an @ to make it a valid identifier. + var isKeyword = CSharp.CreateEscapedIdentifier(CSharp.GetTypeOutput(new(type)))[0] == '@'; if (!isKeyword && IsUsingNamespace(type.Namespace, conf)) { var typeRef = new CodeTypeReference(type.Name, conf.CodeTypeReferenceOptions);