diff --git a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/CecilReader.cs b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/CecilReader.cs index 1a4b477240..4a84570cf8 100644 --- a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/CecilReader.cs +++ b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/CecilReader.cs @@ -340,6 +340,7 @@ namespace ICSharpCode.SharpDevelop.Dom } AddParameters(m, method.Parameters); AddExplicitInterfaceImplementations(method.Overrides, m); + ReflectionLayer.ReflectionMethod.ApplySpecialsFromAttributes(m); Methods.Add(m); } } diff --git a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ReflectionLayer/DomPersistence.cs b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ReflectionLayer/DomPersistence.cs index f5c1aa44c6..405fa4975b 100644 --- a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ReflectionLayer/DomPersistence.cs +++ b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ReflectionLayer/DomPersistence.cs @@ -20,7 +20,7 @@ namespace ICSharpCode.SharpDevelop.Dom { public const long FileMagic = 0x11635233ED2F428C; public const long IndexFileMagic = 0x11635233ED2F427D; - public const short FileVersion = 10; + public const short FileVersion = 11; ProjectContentRegistry registry; string cacheDirectory; diff --git a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ReflectionLayer/ReflectionClass.cs b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ReflectionLayer/ReflectionClass.cs index 4815aae6e8..dcf7afda77 100644 --- a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ReflectionLayer/ReflectionClass.cs +++ b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ReflectionLayer/ReflectionClass.cs @@ -28,7 +28,7 @@ namespace ICSharpCode.SharpDevelop.Dom.ReflectionLayer } foreach (FieldInfo field in type.GetFields(flags)) { - if (!field.IsPublic && !field.IsFamily) continue; + if (!field.IsPublic && !field.IsFamily && !field.IsFamilyOrAssembly) continue; if (!field.IsSpecialName) { Fields.Add(new ReflectionField(field, this)); } @@ -41,12 +41,12 @@ namespace ICSharpCode.SharpDevelop.Dom.ReflectionLayer } foreach (ConstructorInfo constructorInfo in type.GetConstructors(flags)) { - if (!constructorInfo.IsPublic && !constructorInfo.IsFamily) continue; + if (!constructorInfo.IsPublic && !constructorInfo.IsFamily && !constructorInfo.IsFamilyOrAssembly) continue; Methods.Add(new ReflectionMethod(constructorInfo, this)); } foreach (MethodInfo methodInfo in type.GetMethods(flags)) { - if (!methodInfo.IsPublic && !methodInfo.IsFamily) continue; + if (!methodInfo.IsPublic && !methodInfo.IsFamily && !methodInfo.IsFamilyOrAssembly) continue; if (!methodInfo.IsSpecialName) { Methods.Add(new ReflectionMethod(methodInfo, this)); } @@ -62,7 +62,7 @@ namespace ICSharpCode.SharpDevelop.Dom.ReflectionLayer return type.IsSubclassOf(typeof(Delegate)) && type != typeof(MulticastDelegate); } - static void AddAttributes(IProjectContent pc, IList list, IList attributes) + internal static void AddAttributes(IProjectContent pc, IList list, IList attributes) { foreach (CustomAttributeData att in attributes) { DefaultAttribute a = new DefaultAttribute(att.Constructor.DeclaringType.FullName); @@ -82,7 +82,7 @@ namespace ICSharpCode.SharpDevelop.Dom.ReflectionLayer { foreach (IAttribute att in c.Attributes) { if (att.Name == "Microsoft.VisualBasic.CompilerServices.StandardModuleAttribute" - || att.Name == "Boo.Lang.ModuleAttribute") + || att.Name == "System.Runtime.CompilerServices.CompilerGlobalScopeAttribute") { c.ClassType = ClassType.Module; break; diff --git a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ReflectionLayer/ReflectionMethod.cs b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ReflectionLayer/ReflectionMethod.cs index 5e91e63780..0bb58e0b17 100644 --- a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ReflectionLayer/ReflectionMethod.cs +++ b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ReflectionLayer/ReflectionMethod.cs @@ -12,6 +12,20 @@ namespace ICSharpCode.SharpDevelop.Dom.ReflectionLayer { internal class ReflectionMethod : DefaultMethod { + internal static void ApplySpecialsFromAttributes(DefaultMethod m) + { + if (m.IsStatic) { + foreach (IAttribute a in m.Attributes) { + string attributeName = a.Name; + if (attributeName == "System.Runtime.CompilerServices.ExtensionAttribute" + || attributeName == "Boo.Lang.ExtensionAttribute") + { + m.IsExtensionMethod = true; + } + } + } + } + public ReflectionMethod(MethodBase methodBase, ReflectionClass declaringType) : base(declaringType, methodBase is ConstructorInfo ? "#ctor" : methodBase.Name) { @@ -35,16 +49,6 @@ namespace ICSharpCode.SharpDevelop.Dom.ReflectionLayer } } - if (methodBase.IsStatic) { - foreach (CustomAttributeData data in CustomAttributeData.GetCustomAttributes(methodBase)) { - string attributeName = data.Constructor.DeclaringType.FullName; - if (attributeName == "System.Runtime.CompilerServices.ExtensionAttribute" - || attributeName == "Boo.Lang.ExtensionAttribute") - { - this.IsExtensionMethod = true; - } - } - } ModifierEnum modifiers = ModifierEnum.None; if (methodBase.IsStatic) { modifiers |= ModifierEnum.Static; @@ -69,6 +73,9 @@ namespace ICSharpCode.SharpDevelop.Dom.ReflectionLayer modifiers |= ModifierEnum.Sealed; } this.Modifiers = modifiers; + + ReflectionClass.AddAttributes(declaringType.ProjectContent, this.Attributes, CustomAttributeData.GetCustomAttributes(methodBase)); + ApplySpecialsFromAttributes(this); } } }