diff --git a/ICSharpCode.Decompiler/Ast/TextTokenWriter.cs b/ICSharpCode.Decompiler/Ast/TextTokenWriter.cs index bd5c716980..2cfff7d969 100644 --- a/ICSharpCode.Decompiler/Ast/TextTokenWriter.cs +++ b/ICSharpCode.Decompiler/Ast/TextTokenWriter.cs @@ -53,6 +53,10 @@ public TextTokenWriter(ITextOutput output, DecompilerContext context) public override void WriteIdentifier(Identifier identifier) { + if (identifier.IsVerbatim || CSharpOutputVisitor.IsKeyword(identifier.Name, identifier)) { + output.Write('@'); + } + var definition = GetCurrentDefinition(); if (definition != null) { output.WriteDefinition(identifier.Name, definition, false); diff --git a/NRefactory/ICSharpCode.NRefactory.CSharp/OutputVisitor/CSharpOutputVisitor.cs b/NRefactory/ICSharpCode.NRefactory.CSharp/OutputVisitor/CSharpOutputVisitor.cs index 4fc5ed9f7f..dad86b3dab 100644 --- a/NRefactory/ICSharpCode.NRefactory.CSharp/OutputVisitor/CSharpOutputVisitor.cs +++ b/NRefactory/ICSharpCode.NRefactory.CSharp/OutputVisitor/CSharpOutputVisitor.cs @@ -1158,7 +1158,7 @@ public void VisitAttributeSection(AttributeSection attributeSection) StartNode(attributeSection); WriteToken(Roles.LBracket); if (!string.IsNullOrEmpty(attributeSection.AttributeTarget)) { - WriteIdentifier(attributeSection.AttributeTargetToken); + WriteKeyword(attributeSection.AttributeTarget, Roles.Identifier); WriteToken(Roles.Colon); Space(); }