Exemple #1
0
        public virtual void Visit(IParameterDefinition parameterDefinition)
        {
            var marshalling = parameterDefinition.MarshallingInformation;

            Debug.Assert((marshalling != null || !parameterDefinition.MarshallingDescriptor.IsDefaultOrEmpty) == parameterDefinition.IsMarshalledExplicitly);

            this.Visit(parameterDefinition.GetAttributes(Context));
            this.Visit(parameterDefinition.CustomModifiers);

            MetadataConstant defaultValue = parameterDefinition.GetDefaultValue(Context);

            if (defaultValue != null)
            {
                this.Visit((IMetadataExpression)defaultValue);
            }

            if (marshalling != null)
            {
                // Note, we are not visiting MarshallingDescriptor. It is used only for
                // NoPia embedded/local types and VB Dev11 simply copies the bits without
                // cracking them.
                this.Visit(marshalling);
            }

            this.Visit(parameterDefinition.GetType(Context));
        }
Exemple #2
0
            private ICustomAttribute CreateAttribute(string typeName, IAssembly seedCoreAssembly, string argument = null)
            {
                var type = seedCoreAssembly.GetAllTypes().FirstOrDefault(t => t.FullName() == typeName);

                if (type == null)
                {
                    throw new FacadeGenerationException(String.Format("Cannot find {0} type in seed core assembly.", typeName));
                }

                IEnumerable <IMethodDefinition> constructors = type.GetMembersNamed(_seedHost.NameTable.Ctor, false).OfType <IMethodDefinition>();

                IMethodDefinition constructor = null;

                if (argument != null)
                {
                    constructor = constructors.SingleOrDefault(m => m.ParameterCount == 1 && m.Parameters.First().Type.AreEquivalent("System.String"));
                }
                else
                {
                    constructor = constructors.SingleOrDefault(m => m.ParameterCount == 0);
                }

                if (constructor == null)
                {
                    throw new FacadeGenerationException(String.Format("Cannot find {0} constructor taking single string argument in seed core assembly.", typeName));
                }

                var attribute = new CustomAttribute();

                attribute.Constructor = constructor;

                if (argument != null)
                {
                    var argumentExpression = new MetadataConstant();
                    argumentExpression.Type  = _seedHost.PlatformType.SystemString;
                    argumentExpression.Value = argument;

                    attribute.Arguments = new List <IMetadataExpression>(1);
                    attribute.Arguments.Add(argumentExpression);
                }

                return(attribute);
            }
        public virtual void Visit(IFieldDefinition fieldDefinition)
        {
            MetadataConstant        constant    = fieldDefinition.GetCompileTimeValue(Context);
            IMarshallingInformation marshalling = fieldDefinition.MarshallingInformation;

            Debug.Assert((constant != null) == fieldDefinition.IsCompileTimeConstant);
            Debug.Assert((marshalling != null || !fieldDefinition.MarshallingDescriptor.IsDefaultOrEmpty) == fieldDefinition.IsMarshalledExplicitly);

            if (constant != null)
            {
                this.Visit((IMetadataExpression)constant);
            }

            if (marshalling != null)
            {
                // Note, we are not visiting MarshallingDescriptor. It is used only for
                // NoPia embedded/local types and VB Dev11 simply copies the bits without
                // cracking them.
                this.Visit(marshalling);
            }

            this.Visit(fieldDefinition.GetType(Context));
        }
Exemple #4
0
            private ICustomAttribute CreateAttribute(string typeName, IAssembly seedCoreAssembly, string argument = null)
            {
                var type = seedCoreAssembly.GetAllTypes().FirstOrDefault(t => t.FullName() == typeName);
                if (type == null)
                {
                    throw new FacadeGenerationException(String.Format("Cannot find {0} type in seed core assembly.", typeName));
                }

                IEnumerable<IMethodDefinition> constructors = type.GetMembersNamed(_seedHost.NameTable.Ctor, false).OfType<IMethodDefinition>();

                IMethodDefinition constructor = null;
                if (argument != null)
                {
                    constructor = constructors.SingleOrDefault(m => m.ParameterCount == 1 && m.Parameters.First().Type.AreEquivalent("System.String"));
                }
                else
                {
                    constructor = constructors.SingleOrDefault(m => m.ParameterCount == 0);
                }

                if (constructor == null)
                {
                    throw new FacadeGenerationException(String.Format("Cannot find {0} constructor taking single string argument in seed core assembly.", typeName));
                }

                var attribute = new CustomAttribute();
                attribute.Constructor = constructor;

                if (argument != null)
                {
                    var argumentExpression = new MetadataConstant();
                    argumentExpression.Type = _seedHost.PlatformType.SystemString;
                    argumentExpression.Value = argument;

                    attribute.Arguments = new List<IMetadataExpression>(1);
                    attribute.Arguments.Add(argumentExpression);
                }

                return attribute;
            }
Exemple #5
0
 public virtual void Visit(MetadataConstant constant)
 {
 }