Skip to content
This repository was archived by the owner on Oct 16, 2020. It is now read-only.

Commit 00d2fd1

Browse files
fix #220: Cannot rename an identifier starting with an @
1 parent e51144a commit 00d2fd1

3 files changed

Lines changed: 13 additions & 2 deletions

File tree

src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/CSharpCodeGenerator.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,5 +211,10 @@ public override void MakeVirtual(IMember member)
211211
script.ChangeModifier(entityDeclaration, entityDeclaration.Modifiers | Modifiers.Virtual);
212212
}
213213
}
214+
215+
public override string EscapeIdentifier(string identifier)
216+
{
217+
return "@" + identifier;
218+
}
214219
}
215220
}

src/Main/Base/Project/Refactoring/CodeGenerator.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ public virtual string GetFieldName(string propertyName)
8383
return newName;
8484
}
8585

86+
public virtual string EscapeIdentifier(string identifier)
87+
{
88+
throw new NotSupportedException("Feature not supported!");
89+
}
90+
8691
public virtual void AddField(ITypeDefinition declaringType, Accessibility accessibility, IType fieldType, string name)
8792
{
8893
throw new NotSupportedException("Feature not supported!");

src/Main/Base/Project/Src/Editor/Commands/FindReferencesCommand.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,9 @@ static bool CheckName(string name, ILanguageBinding language)
125125
{
126126
if (string.IsNullOrEmpty(name))
127127
return false;
128-
129-
if ((language.CodeDomProvider == null) || !language.CodeDomProvider.IsValidIdentifier(name))
128+
129+
if ((language.CodeDomProvider == null) || (!language.CodeDomProvider.IsValidIdentifier(name) &&
130+
!language.CodeDomProvider.IsValidIdentifier(language.CodeGenerator.EscapeIdentifier(name))))
130131
return false;
131132

132133
return true;

0 commit comments

Comments
 (0)