diff --git a/ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj b/ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj
index 42b9189b96..89d4a70d35 100644
--- a/ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj
+++ b/ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj
@@ -166,6 +166,7 @@
+
diff --git a/ICSharpCode.NRefactory/TypeSystem/CecilLoader.cs b/ICSharpCode.NRefactory/TypeSystem/CecilLoader.cs
index 55e1429c26..ff9c803bb6 100644
--- a/ICSharpCode.NRefactory/TypeSystem/CecilLoader.cs
+++ b/ICSharpCode.NRefactory/TypeSystem/CecilLoader.cs
@@ -522,7 +522,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
}
if (typeDefinition.HasFields) {
foreach (FieldDefinition field in typeDefinition.Fields) {
- if (loader.IsVisible(field.Attributes)) {
+ if (loader.IsVisible(field.Attributes) && !field.IsSpecialName) {
this.Fields.Add(loader.ReadField(field, this));
}
}
@@ -580,8 +580,6 @@ namespace ICSharpCode.NRefactory.TypeSystem
}
}
- AddExplicitInterfaceImplementations(method, m);
-
// mark as extension method is the attribute is set
if (method.IsStatic && method.HasCustomAttributes) {
foreach (var attr in method.CustomAttributes) {
@@ -634,6 +632,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
m.IsSealed = true;
else if (method.IsVirtual)
m.IsVirtual = true;
+ m.IsStatic = method.IsStatic;
}
}
#endregion
@@ -686,16 +685,47 @@ namespace ICSharpCode.NRefactory.TypeSystem
public IField ReadField(FieldDefinition field, ITypeDefinition parentType)
{
- throw new NotImplementedException();
+ if (field == null)
+ throw new ArgumentNullException("field");
+ if (parentType == null)
+ throw new ArgumentNullException("parentType");
+
+ DefaultField f = new DefaultField(parentType, field.Name);
+ f.Accessibility = GetAccessibility(field.Attributes);
+ f.IsReadOnly = field.IsInitOnly;
+ f.IsStatic = field.IsStatic;
+ if (field.HasConstant) {
+ f.ConstantValue = ReadConstantValue(new CustomAttributeArgument(field.FieldType, field.Constant));
+ }
+ if (field.HasCustomAttributes) {
+ AddAttributes(field, f.Attributes);
+ }
+ RequiredModifierType modreq = field.FieldType as RequiredModifierType;
+ if (modreq != null && modreq.ModifierType.FullName == typeof(IsVolatile).FullName) {
+ f.IsVolatile = true;
+ }
+
+ return f;
}
- #endregion
- void AddExplicitInterfaceImplementations(MethodDefinition method, AbstractMember targetMember)
+ static Accessibility GetAccessibility(FieldAttributes attr)
{
- if (method.HasOverrides) {
- throw new NotImplementedException();
+ switch (attr & FieldAttributes.FieldAccessMask) {
+ case FieldAttributes.Public:
+ return Accessibility.Public;
+ case FieldAttributes.FamANDAssem:
+ return Accessibility.ProtectedAndInternal;
+ case FieldAttributes.Assembly:
+ return Accessibility.Internal;
+ case FieldAttributes.Family:
+ return Accessibility.Protected;
+ case FieldAttributes.FamORAssem:
+ return Accessibility.ProtectedOrInternal;
+ default:
+ return Accessibility.Private;
}
}
+ #endregion
#region Type Parameter Constraints
void AddConstraints(DefaultTypeParameter tp, GenericParameter g)
diff --git a/ICSharpCode.NRefactory/TypeSystem/IField.cs b/ICSharpCode.NRefactory/TypeSystem/IField.cs
index db72702027..6256461484 100644
--- a/ICSharpCode.NRefactory/TypeSystem/IField.cs
+++ b/ICSharpCode.NRefactory/TypeSystem/IField.cs
@@ -27,6 +27,11 @@ namespace ICSharpCode.NRefactory.TypeSystem
///
bool IsReadOnly { get; }
+ ///
+ /// Gets whether this field is volatile.
+ ///
+ bool IsVolatile { get; }
+
///
/// If this field is a constant, retrieves the value.
///
@@ -55,6 +60,10 @@ namespace ICSharpCode.NRefactory.TypeSystem
get { return false; }
}
+ bool IField.IsVolatile {
+ get { return false; }
+ }
+
IConstantValue IField.ConstantValue {
get { return null; }
}
diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultEvent.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultEvent.cs
index fdd591aa9e..880a2695fb 100644
--- a/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultEvent.cs
+++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultEvent.cs
@@ -1,4 +1,6 @@
-
+// Copyright (c) 2010 AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
+
using System;
namespace ICSharpCode.NRefactory.TypeSystem.Implementation
diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultField.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultField.cs
new file mode 100644
index 0000000000..361f14f073
--- /dev/null
+++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultField.cs
@@ -0,0 +1,62 @@
+// Copyright (c) 2010 AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
+
+using System;
+
+namespace ICSharpCode.NRefactory.TypeSystem.Implementation
+{
+ ///
+ /// Default implementation of .
+ ///
+ public class DefaultField : AbstractMember, IField
+ {
+ IConstantValue constantValue;
+
+ const ushort FlagIsReadOnly = 0x1000;
+ const ushort FlagIsVolatile = 0x2000;
+
+ protected override void FreezeInternal()
+ {
+ if (constantValue != null)
+ constantValue.Freeze();
+ base.FreezeInternal();
+ }
+
+ public DefaultField(ITypeDefinition declaringTypeDefinition, string name)
+ : base(declaringTypeDefinition, name, EntityType.Field)
+ {
+ }
+
+ public bool IsConst {
+ get { return constantValue != null; }
+ }
+
+ public bool IsReadOnly {
+ get { return flags[FlagIsReadOnly]; }
+ set {
+ CheckBeforeMutation();
+ flags[FlagIsReadOnly] = value;
+ }
+ }
+
+ public bool IsVolatile {
+ get { return flags[FlagIsVolatile]; }
+ set {
+ CheckBeforeMutation();
+ flags[FlagIsVolatile] = value;
+ }
+ }
+
+ public IConstantValue ConstantValue {
+ get { return constantValue; }
+ set {
+ CheckBeforeMutation();
+ constantValue = value;
+ }
+ }
+
+ ITypeReference IVariable.Type {
+ get { return this.ReturnType; }
+ }
+ }
+}
diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultProperty.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultProperty.cs
index aab8216deb..855df24da4 100644
--- a/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultProperty.cs
+++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultProperty.cs
@@ -1,4 +1,6 @@
-
+// Copyright (c) 2010 AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
+
using System;
using System.Collections.Generic;