PageRenderTime 21ms CodeModel.GetById 17ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/Mono.Cecil/IMethodSignature.cs

http://github.com/jbevain/cecil
C# | 57 lines | 35 code | 13 blank | 9 comment | 5 complexity | 06f3369b0da288e74160a91b57af91d0 MD5 | raw file
 1//
 2// Author:
 3//   Jb Evain (jbevain@gmail.com)
 4//
 5// Copyright (c) 2008 - 2015 Jb Evain
 6// Copyright (c) 2008 - 2011 Novell, Inc.
 7//
 8// Licensed under the MIT/X11 license.
 9//
10
11using System.Text;
12
13using Mono.Collections.Generic;
14
15namespace Mono.Cecil {
16
17	public interface IMethodSignature : IMetadataTokenProvider {
18
19		bool HasThis { get; set; }
20		bool ExplicitThis { get; set; }
21		MethodCallingConvention CallingConvention { get; set; }
22
23		bool HasParameters { get; }
24		Collection<ParameterDefinition> Parameters { get; }
25		TypeReference ReturnType { get; set; }
26		MethodReturnType MethodReturnType { get; }
27	}
28
29	static partial class Mixin {
30
31		public static bool HasImplicitThis (this IMethodSignature self)
32		{
33			return self.HasThis && !self.ExplicitThis;
34		}
35
36		public static void MethodSignatureFullName (this IMethodSignature self, StringBuilder builder)
37		{
38			builder.Append ("(");
39
40			if (self.HasParameters) {
41				var parameters = self.Parameters;
42				for (int i = 0; i < parameters.Count; i++) {
43					var parameter = parameters [i];
44					if (i > 0)
45						builder.Append (",");
46
47					if (parameter.ParameterType.IsSentinel)
48						builder.Append ("...,");
49
50					builder.Append (parameter.ParameterType.FullName);
51				}
52			}
53
54			builder.Append (")");
55		}
56	}
57}