diff --git a/src/Libraries/NRefactory/ICSharpCode.NRefactory.CSharp/OutputVisitor/InsertRequiredSpacesDecorator.cs b/src/Libraries/NRefactory/ICSharpCode.NRefactory.CSharp/OutputVisitor/InsertRequiredSpacesDecorator.cs index 8cb616df30..e9aca4bf56 100644 --- a/src/Libraries/NRefactory/ICSharpCode.NRefactory.CSharp/OutputVisitor/InsertRequiredSpacesDecorator.cs +++ b/src/Libraries/NRefactory/ICSharpCode.NRefactory.CSharp/OutputVisitor/InsertRequiredSpacesDecorator.cs @@ -56,7 +56,7 @@ namespace ICSharpCode.NRefactory.CSharp public override void WriteIdentifier(Identifier identifier) { - if (identifier.IsVerbatim) { + if (identifier.IsVerbatim || CSharpOutputVisitor.IsKeyword(identifier.Name, identifier)) { if (lastWritten == LastWritten.KeywordOrIdentifier) { // this space is not strictly required, so we call Space() Space(); diff --git a/src/Libraries/NRefactory/ICSharpCode.NRefactory.CSharp/OutputVisitor/TextWriterOutputFormatter.cs b/src/Libraries/NRefactory/ICSharpCode.NRefactory.CSharp/OutputVisitor/TextWriterOutputFormatter.cs index 4b9a262c69..67c93cdaed 100644 --- a/src/Libraries/NRefactory/ICSharpCode.NRefactory.CSharp/OutputVisitor/TextWriterOutputFormatter.cs +++ b/src/Libraries/NRefactory/ICSharpCode.NRefactory.CSharp/OutputVisitor/TextWriterOutputFormatter.cs @@ -58,7 +58,7 @@ namespace ICSharpCode.NRefactory.CSharp public override void WriteIdentifier(Identifier identifier) { WriteIndentation(); - if (identifier.IsVerbatim) { + if (identifier.IsVerbatim || CSharpOutputVisitor.IsKeyword(identifier.Name, identifier)) { textWriter.Write('@'); column++; } @@ -135,7 +135,7 @@ namespace ICSharpCode.NRefactory.CSharp textWriter.Write("/*"); textWriter.Write(content); textWriter.Write("*/"); - column += 2; + column += 2; UpdateEndLocation(content, ref line, ref column); column += 2; isAtStartOfLine = false; diff --git a/src/Libraries/NRefactory/ICSharpCode.NRefactory.CSharp/Refactoring/TypeSystemAstBuilder.cs b/src/Libraries/NRefactory/ICSharpCode.NRefactory.CSharp/Refactoring/TypeSystemAstBuilder.cs index 18ded3680b..eafac416bd 100644 --- a/src/Libraries/NRefactory/ICSharpCode.NRefactory.CSharp/Refactoring/TypeSystemAstBuilder.cs +++ b/src/Libraries/NRefactory/ICSharpCode.NRefactory.CSharp/Refactoring/TypeSystemAstBuilder.cs @@ -806,6 +806,8 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring { MethodDeclaration decl = new MethodDeclaration(); decl.Modifiers = GetMemberModifiers(method); + if (method.IsAsync) + decl.Modifiers |= Modifiers.Async; decl.ReturnType = ConvertType(method.ReturnType); decl.Name = method.Name;