diff --git a/ICSharpCode.NRefactory/CSharp/Dom/DomLocation.cs b/ICSharpCode.NRefactory/CSharp/Dom/DomLocation.cs
index 78ef3d3974..799e79a01d 100644
--- a/ICSharpCode.NRefactory/CSharp/Dom/DomLocation.cs
+++ b/ICSharpCode.NRefactory/CSharp/Dom/DomLocation.cs
@@ -45,7 +45,7 @@ namespace ICSharpCode.NRefactory.CSharp
public bool IsEmpty {
get {
- return Line <= 0;
+ return line <= 0;
}
}
diff --git a/ICSharpCode.NRefactory/CSharp/Parser/TypeSystemConvertVisitor.cs b/ICSharpCode.NRefactory/CSharp/Parser/TypeSystemConvertVisitor.cs
index ef62ffd1da..57b60d7eda 100644
--- a/ICSharpCode.NRefactory/CSharp/Parser/TypeSystemConvertVisitor.cs
+++ b/ICSharpCode.NRefactory/CSharp/Parser/TypeSystemConvertVisitor.cs
@@ -3,8 +3,8 @@
using System;
using System.Collections.Generic;
-using System.Diagnostics;
using System.Linq;
+
using ICSharpCode.NRefactory.CSharp.Resolver;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.NRefactory.TypeSystem.Implementation;
@@ -22,12 +22,36 @@ namespace ICSharpCode.NRefactory.CSharp
DefaultTypeDefinition currentTypeDefinition;
DefaultMethod currentMethod;
+ ///
+ /// Creates a new TypeSystemConvertVisitor.
+ ///
+ /// The parent project content (used as owner for the types being created).
+ /// The file name (used for DomRegions).
public TypeSystemConvertVisitor(IProjectContent pc, string fileName)
{
+ if (pc == null)
+ throw new ArgumentNullException("pc");
+ if (fileName == null)
+ throw new ArgumentNullException("fileName");
this.parsedFile = new ParsedFile(fileName, new UsingScope(pc));
this.usingScope = parsedFile.RootUsingScope;
}
+ ///
+ /// Creates a new TypeSystemConvertVisitor and initializes it with a given context.
+ ///
+ /// The parsed file to which members should be added.
+ /// The current using scope.
+ /// The current type definition.
+ public TypeSystemConvertVisitor(ParsedFile parsedFile, UsingScope currentUsingScope = null, DefaultTypeDefinition currentTypeDefinition = null)
+ {
+ if (parsedFile == null)
+ throw new ArgumentNullException("parsedFile");
+ this.parsedFile = parsedFile;
+ this.usingScope = currentUsingScope ?? parsedFile.RootUsingScope;
+ this.currentTypeDefinition = currentTypeDefinition;
+ }
+
public ParsedFile ParsedFile {
get { return parsedFile; }
}
@@ -241,6 +265,25 @@ namespace ICSharpCode.NRefactory.CSharp
}
return isSingleField ? field : null;
}
+
+ public override IEntity VisitEnumMemberDeclaration(EnumMemberDeclaration enumMemberDeclaration, object data)
+ {
+ DefaultField field = new DefaultField(currentTypeDefinition, enumMemberDeclaration.Name);
+ field.Region = field.BodyRegion = MakeRegion(enumMemberDeclaration);
+ ConvertAttributes(field.Attributes, enumMemberDeclaration.Attributes);
+
+ field.ReturnType = currentTypeDefinition;
+ field.Accessibility = Accessibility.Public;
+ field.IsStatic = true;
+ if (enumMemberDeclaration.Initializer != null) {
+ field.ConstantValue = ConvertConstantValue(currentTypeDefinition, enumMemberDeclaration.Initializer);
+ } else {
+ throw new NotImplementedException();
+ }
+
+ currentTypeDefinition.Fields.Add(field);
+ return field;
+ }
#endregion
#region Methods
diff --git a/ICSharpCode.NRefactory/Utils/CSharpPrimitiveCast.cs b/ICSharpCode.NRefactory/Utils/CSharpPrimitiveCast.cs
index e7cfbdb911..41d9f5bffe 100644
--- a/ICSharpCode.NRefactory/Utils/CSharpPrimitiveCast.cs
+++ b/ICSharpCode.NRefactory/Utils/CSharpPrimitiveCast.cs
@@ -407,7 +407,7 @@ namespace ICSharpCode.NRefactory.Utils
}
break;
}
- throw new InvalidCastException("Cast from " + sourceType + " to " + targetType + "not supported.");
+ throw new InvalidCastException("Cast from " + sourceType + " to " + targetType + " not supported.");
}
}
}