diff --git a/ICSharpCode.NRefactory/CSharp/Analysis/DefiniteAssignmentAnalysis.cs b/ICSharpCode.NRefactory/CSharp/Analysis/DefiniteAssignmentAnalysis.cs
index d4cc6e1c53..452ca686a5 100644
--- a/ICSharpCode.NRefactory/CSharp/Analysis/DefiniteAssignmentAnalysis.cs
+++ b/ICSharpCode.NRefactory/CSharp/Analysis/DefiniteAssignmentAnalysis.cs
@@ -167,12 +167,14 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis
/// This method can be used to restrict the analysis to only a part of the method.
/// Only the control flow paths that are fully contained within the selected part will be analyzed.
///
- /// Both 'start' and 'end' are inclusive.
- public void SetAnalyzedRange(Statement start, Statement end)
+ /// By default, both 'start' and 'end' are inclusive.
+ public void SetAnalyzedRange(Statement start, Statement end, bool startInclusive = true, bool endInclusive = true)
{
- Debug.Assert(beginNodeDict.ContainsKey(start) && endNodeDict.ContainsKey(end));
- int startIndex = beginNodeDict[start].Index;
- int endIndex = endNodeDict[end].Index;
+ var dictForStart = startInclusive ? beginNodeDict : endNodeDict;
+ var dictForEnd = endInclusive ? endNodeDict : beginNodeDict;
+ Debug.Assert(dictForStart.ContainsKey(start) && dictForEnd.ContainsKey(end));
+ int startIndex = dictForStart[start].Index;
+ int endIndex = dictForEnd[end].Index;
if (startIndex > endIndex)
throw new ArgumentException("The start statement must be lexically preceding the end statement");
this.analyzedRangeStart = startIndex;
diff --git a/ICSharpCode.NRefactory/CSharp/Ast/ComposedType.cs b/ICSharpCode.NRefactory/CSharp/Ast/ComposedType.cs
index b888cdea23..813f472137 100644
--- a/ICSharpCode.NRefactory/CSharp/Ast/ComposedType.cs
+++ b/ICSharpCode.NRefactory/CSharp/Ast/ComposedType.cs
@@ -52,7 +52,7 @@ namespace ICSharpCode.NRefactory.CSharp
public int PointerRank {
get {
- return GetChildrenByRole(PointerRole).Count();
+ return GetChildrenByRole(PointerRole).Count;
}
set {
if (value < 0)
@@ -141,7 +141,7 @@ namespace ICSharpCode.NRefactory.CSharp
}
public int Dimensions {
- get { return 1 + GetChildrenByRole(Roles.Comma).Count(); }
+ get { return 1 + GetChildrenByRole(Roles.Comma).Count; }
set {
int d = this.Dimensions;
while (d > value) {
diff --git a/ICSharpCode.NRefactory/CSharp/Ast/Identifier.cs b/ICSharpCode.NRefactory/CSharp/Ast/Identifier.cs
index 70f1ddca48..6db26e523a 100644
--- a/ICSharpCode.NRefactory/CSharp/Ast/Identifier.cs
+++ b/ICSharpCode.NRefactory/CSharp/Ast/Identifier.cs
@@ -96,7 +96,7 @@ namespace ICSharpCode.NRefactory.CSharp
{
if (name == null)
throw new ArgumentNullException("name");
- IsVerbatim = name.StartsWith ("@");
+ IsVerbatim = name.Length > 0 && name[0] == '@';
this.Name = IsVerbatim ? name.Substring (1) : name;
this.startLocation = location;
}
diff --git a/ICSharpCode.NRefactory/CSharp/OutputVisitor/OutputVisitor.cs b/ICSharpCode.NRefactory/CSharp/OutputVisitor/OutputVisitor.cs
index 1c770b634f..da524257d0 100644
--- a/ICSharpCode.NRefactory/CSharp/OutputVisitor/OutputVisitor.cs
+++ b/ICSharpCode.NRefactory/CSharp/OutputVisitor/OutputVisitor.cs
@@ -941,7 +941,11 @@ namespace ICSharpCode.NRefactory.CSharp
return ConvertChar(ch);
}
- static string ConvertChar(char ch)
+ ///
+ /// Gets the escape sequence for the specified character.
+ ///
+ /// This method does not convert ' or ".
+ public static string ConvertChar(char ch)
{
switch (ch) {
case '\\':
@@ -963,7 +967,9 @@ namespace ICSharpCode.NRefactory.CSharp
case '\v':
return "\\v";
default:
- if (char.IsControl(ch) || char.IsSurrogate(ch)) {
+ if (char.IsControl(ch) || char.IsSurrogate(ch) ||
+ // print all uncommon white spaces as numbers
+ (char.IsWhiteSpace(ch) && ch != ' ')) {
return "\\u" + ((int)ch).ToString("x4");
} else {
return ch.ToString();
@@ -971,7 +977,10 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
- static string ConvertString(string str)
+ ///
+ /// Converts special characters to escape sequences within the given string.
+ ///
+ public static string ConvertString(string str)
{
StringBuilder sb = new StringBuilder();
foreach (char ch in str) {
@@ -2145,7 +2154,9 @@ namespace ICSharpCode.NRefactory.CSharp
// "1.0 / /*comment*/a", then we need to insert a space in front of the comment.
formatter.Space();
}
+ formatter.StartNode(comment);
formatter.WriteComment(comment.CommentType, comment.Content);
+ formatter.EndNode(comment);
lastWritten = LastWritten.Whitespace;
return null;
}
diff --git a/ICSharpCode.NRefactory/CSharp/Parser/TypeSystemConvertVisitor.cs b/ICSharpCode.NRefactory/CSharp/Parser/TypeSystemConvertVisitor.cs
index 66865d53c8..756adce400 100644
--- a/ICSharpCode.NRefactory/CSharp/Parser/TypeSystemConvertVisitor.cs
+++ b/ICSharpCode.NRefactory/CSharp/Parser/TypeSystemConvertVisitor.cs
@@ -263,7 +263,7 @@ namespace ICSharpCode.NRefactory.CSharp
#region Fields
public override IEntity VisitFieldDeclaration(FieldDeclaration fieldDeclaration, object data)
{
- bool isSingleField = fieldDeclaration.Variables.Count() == 1;
+ bool isSingleField = fieldDeclaration.Variables.Count == 1;
Modifiers modifiers = fieldDeclaration.Modifiers;
DefaultField field = null;
foreach (VariableInitializer vi in fieldDeclaration.Variables) {
@@ -476,7 +476,7 @@ namespace ICSharpCode.NRefactory.CSharp
#region Events
public override IEntity VisitEventDeclaration(EventDeclaration eventDeclaration, object data)
{
- bool isSingleEvent = eventDeclaration.Variables.Count() == 1;
+ bool isSingleEvent = eventDeclaration.Variables.Count == 1;
Modifiers modifiers = eventDeclaration.Modifiers;
DefaultEvent ev = null;
foreach (VariableInitializer vi in eventDeclaration.Variables) {
diff --git a/ICSharpCode.NRefactory/CSharp/Resolver/ResolveVisitor.cs b/ICSharpCode.NRefactory/CSharp/Resolver/ResolveVisitor.cs
index 3bcea943b3..162f5c2bf3 100644
--- a/ICSharpCode.NRefactory/CSharp/Resolver/ResolveVisitor.cs
+++ b/ICSharpCode.NRefactory/CSharp/Resolver/ResolveVisitor.cs
@@ -241,7 +241,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
ResolveResult VisitFieldOrEventDeclaration(AttributedNode fieldOrEventDeclaration)
{
- int initializerCount = fieldOrEventDeclaration.GetChildrenByRole(FieldDeclaration.Roles.Variable).Count();
+ int initializerCount = fieldOrEventDeclaration.GetChildrenByRole(FieldDeclaration.Roles.Variable).Count;
ResolveResult result = null;
for (AstNode node = fieldOrEventDeclaration.FirstChild; node != null; node = node.NextSibling) {
if (node.Role == FieldDeclaration.Roles.Variable) {
@@ -939,7 +939,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
firstInitializer != null ? firstInitializer.Initializer : null,
false);
- int initializerCount = variableDeclarationStatement.Variables.Count();
+ int initializerCount = variableDeclarationStatement.Variables.Count;
ResolveResult result = null;
for (AstNode node = variableDeclarationStatement.FirstChild; node != null; node = node.NextSibling) {
if (node.Role == FieldDeclaration.Roles.Variable) {
diff --git a/ICSharpCode.NRefactory/Documentation/XmlDocumentationProvider.cs b/ICSharpCode.NRefactory/Documentation/XmlDocumentationProvider.cs
index 315f212ebd..70d88aa164 100644
--- a/ICSharpCode.NRefactory/Documentation/XmlDocumentationProvider.cs
+++ b/ICSharpCode.NRefactory/Documentation/XmlDocumentationProvider.cs
@@ -120,7 +120,7 @@ namespace ICSharpCode.NRefactory.Documentation
static string GetRedirectionTarget(string target)
{
- string programFilesDir = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
+ string programFilesDir = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86);
programFilesDir = AppendDirectorySeparator(programFilesDir);
string corSysDir = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory();