Skip to content

Commit

Permalink
slight adjustment for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
las-nsc committed Jun 7, 2022
1 parent 8f4769b commit efef426
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions XmlSchemaClassGenerator/CodeUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit efef426

Please sign in to comment.