From 3eefdb227eb864c2154b1373a51fae3b965eab43 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Wed, 16 Feb 2011 22:44:13 +0100 Subject: [PATCH 1/2] Escape surrogates in string literals. --- .../CSharp/OutputVisitor/OutputVisitor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/OutputVisitor/OutputVisitor.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/OutputVisitor/OutputVisitor.cs index 8e2b94d0e..0abdd4fd5 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/OutputVisitor/OutputVisitor.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/OutputVisitor/OutputVisitor.cs @@ -837,7 +837,7 @@ namespace ICSharpCode.NRefactory.CSharp case '\v': return "\\v"; default: - if (char.IsControl(ch)) { + if (char.IsControl(ch) || char.IsSurrogate(ch)) { return "\\u" + ((int)ch).ToString("x4"); } else { return ch.ToString(); From dd9659f2cac41028e57964146e39c09393f0e9d0 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Wed, 16 Feb 2011 22:50:43 +0100 Subject: [PATCH 2/2] Fix missing dot in namespace declarations. --- .../CSharp/OutputVisitor/OutputVisitor.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/OutputVisitor/OutputVisitor.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/OutputVisitor/OutputVisitor.cs index 0abdd4fd5..88b8b0488 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/OutputVisitor/OutputVisitor.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/OutputVisitor/OutputVisitor.cs @@ -371,7 +371,8 @@ namespace ICSharpCode.NRefactory.CSharp formatter.Space(); } else { WriteSpecialsUpToRole(AstNode.Roles.Dot, ident); - + formatter.WriteToken("."); + lastWritten = LastWritten.Other; } WriteSpecialsUpToNode(ident); formatter.WriteIdentifier(ident.Name); @@ -1630,7 +1631,10 @@ namespace ICSharpCode.NRefactory.CSharp } Space(policy.BeforeConstructorDeclarationParentheses); WriteCommaSeparatedListInParenthesis(constructorDeclaration.Parameters, policy.WithinMethodDeclarationParentheses); - constructorDeclaration.Initializer.AcceptVisitor(this, data); + if (!constructorDeclaration.Initializer.IsNull) { + Space(); + constructorDeclaration.Initializer.AcceptVisitor(this, data); + } WriteMethodBody(constructorDeclaration.Body); return EndNode(constructorDeclaration); } @@ -1720,6 +1724,7 @@ namespace ICSharpCode.NRefactory.CSharp WriteAttributes(fieldDeclaration.Attributes); WriteModifiers(fieldDeclaration.ModifierTokens); fieldDeclaration.ReturnType.AcceptVisitor(this, data); + Space(); WriteCommaSeparatedList(fieldDeclaration.Variables); Semicolon(); return EndNode(fieldDeclaration);