~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to contrib/ICSharpCode.Decompiler/CecilExtensions.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
133
133
                /// </summary>
134
134
                public static int GetEndOffset(this Instruction inst)
135
135
                {
 
136
                        if (inst == null)
 
137
                                throw new ArgumentNullException("inst");
136
138
                        return inst.Offset + inst.GetSize();
137
139
                }
138
140
                
215
217
                                return true;
216
218
                        return IsCompilerGeneratedOrIsInCompilerGeneratedClass(member.DeclaringType);
217
219
                }
 
220
 
 
221
                public static TypeReference GetEnumUnderlyingType(this TypeDefinition type)
 
222
                {
 
223
                        if (!type.IsEnum)
 
224
                                throw new ArgumentException("Type must be an enum", "type");
 
225
 
 
226
                        var fields = type.Fields;
 
227
 
 
228
                        for (int i = 0; i < fields.Count; i++)
 
229
                        {
 
230
                                var field = fields[i];
 
231
                                if (!field.IsStatic)
 
232
                                        return field.FieldType;
 
233
                        }
 
234
 
 
235
                        throw new NotSupportedException();
 
236
                }
218
237
                
219
238
                public static bool IsAnonymousType(this TypeReference type)
220
239
                {
221
240
                        if (type == null)
222
241
                                return false;
223
 
                        if (string.IsNullOrEmpty(type.Namespace) && type.Name.StartsWith("<>", StringComparison.Ordinal) && type.Name.Contains("AnonymousType")) {
 
242
                        if (string.IsNullOrEmpty(type.Namespace) && type.HasGeneratedName() && (type.Name.Contains("AnonType") || type.Name.Contains("AnonymousType"))) {
224
243
                                TypeDefinition td = type.Resolve();
225
244
                                return td != null && td.IsCompilerGenerated();
226
245
                        }
227
246
                        return false;
228
247
                }
 
248
 
 
249
                public static bool HasGeneratedName(this MemberReference member)
 
250
                {
 
251
                        return member.Name.StartsWith("<", StringComparison.Ordinal);
 
252
                }
229
253
                
230
254
                public static bool ContainsAnonymousType(this TypeReference type)
231
255
                {