From 75dfa785d71c97c140f7911e2243c21614b2be54 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Sun, 12 Jul 2015 18:11:26 +0200 Subject: [PATCH] Fix #600: variable called int should be displayed as @int --- ICSharpCode.Decompiler/Ast/TextTokenWriter.cs | 4 ++++ .../OutputVisitor/CSharpOutputVisitor.cs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) 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(); }