Example #1
0
        public static bool ShouldTreatAsConditionalMethod(MethodDefinition method, out ICollection<string> conditions) {
            conditions = null;

            foreach (CustomAttribute attribute in method.CustomAttributes) {
                string typeName = attribute.Constructor.DeclaringType.FullName;
                if (String.CompareOrdinal(typeName, "System.Diagnostics.ConditionalAttribute") == 0) {
                    if (conditions == null) {
                        conditions = new List<string>();
                    }

                    conditions.Add(GetAttributeArgument(attribute));
                }
            }
            
            return (conditions != null);
        }
Example #2
0
		static Collection<ParameterDefinition> MirrorParameters (MethodDefinition method, int bound)
		{
			var parameters = new Collection<ParameterDefinition> ();
			if (!method.HasParameters)
				return parameters;

			var original_parameters = method.Parameters;
			var end = original_parameters.Count - bound;

			for (int i = 0; i < end; i++)
				parameters.Add (original_parameters [i]);

			return parameters;
		}
Example #3
0
		public void RemoveOverrideMapping (MethodDefinition method)
		{
			Overrides.Remove (method.token.RID);
		}
Example #4
0
		public bool TryGetOverrideMapping (MethodDefinition method, out MetadataToken [] mapping)
		{
			return Overrides.TryGetValue (method.token.RID, out mapping);
		}
Example #5
0
		public void AddMethodDefinition (MethodDefinition method)
		{
			Methods [method.token.RID - 1] = method;
		}
        private void ImportMemberDetails(MemberSymbol memberSymbol, MethodDefinition methodDefinition, ICustomAttributeProvider attributeProvider)
        {
            if (methodDefinition != null) {
                MemberVisibility visibility = MemberVisibility.PrivateInstance;
                if (methodDefinition.IsStatic) {
                    visibility |= MemberVisibility.Static;
                }
                if (methodDefinition.IsPublic) {
                    visibility |= MemberVisibility.Public;
                }
                else if (methodDefinition.IsFamily || methodDefinition.IsFamilyOrAssembly) {
                    visibility |= MemberVisibility.Protected;
                }

                memberSymbol.SetVisibility(visibility);
            }

            memberSymbol.SetNameCasing(MetadataHelpers.ShouldPreserveCase(attributeProvider));

            string scriptName = MetadataHelpers.GetScriptName(attributeProvider);
            if (scriptName != null) {
                memberSymbol.SetTransformedName(scriptName);
            }
        }