Example #1
0
        public EventPropertyGetter GetGetter(String propertyName)
        {
            EventPropertyGetter cachedGetter = _propertyGetterCache.Get(propertyName);

            if (cachedGetter != null)
            {
                return(cachedGetter);
            }

            SimplePropertyInfo simpleProp = GetSimplePropertyInfo(propertyName);

            if ((simpleProp != null) && (simpleProp.Getter != null))
            {
                EventPropertyGetter propertyGetter = simpleProp.Getter;
                _propertyGetterCache.Put(propertyName, propertyGetter);
                return(propertyGetter);
            }

            Property prop = PropertyParser.ParseAndWalk(propertyName, false);

            if (prop is SimpleProperty)
            {
                // there is no such property since it wasn't in simplePropertyGetters
                return(null);
            }

            EventPropertyGetter getter = prop.GetGetter(this, _eventAdapterService);

            _propertyGetterCache.Put(propertyName, getter);
            return(getter);
        }
Example #2
0
        public FragmentEventType GetFragmentType(String propertyExpression)
        {
            SimplePropertyInfo simpleProp = GetSimplePropertyInfo(propertyExpression);

            if ((simpleProp != null) && (simpleProp.PropertyType != null))
            {
                GenericPropertyDesc genericProp = simpleProp.Descriptor.GetReturnTypeGeneric();
                return(EventBeanUtility.CreateNativeFragmentType(genericProp.PropertyType, genericProp.GenericType, _eventAdapterService));
            }

            Property prop = PropertyParser.ParseAndWalk(propertyExpression, false);

            if (prop is SimpleProperty)
            {
                // there is no such property since it wasn't in simplePropertyTypes
                return(null);
            }

            GenericPropertyDesc genericPropertyDesc = prop.GetPropertyTypeGeneric(this, _eventAdapterService);

            if (genericPropertyDesc == null)
            {
                return(null);
            }
            return(EventBeanUtility.CreateNativeFragmentType(genericPropertyDesc.PropertyType, genericPropertyDesc.GenericType, _eventAdapterService));
        }
Example #3
0
 /// <summary>
 ///     Looks up and returns a cached simple property's descriptor.
 /// </summary>
 /// <param name="propertyName">to look up</param>
 /// <returns>property descriptor</returns>
 public InternalEventPropDescriptor GetSimpleProperty(string propertyName)
 {
     SimplePropertyInfo simpleProp = GetSimplePropertyInfo(propertyName);
     if (simpleProp != null)
     {
         return simpleProp.Descriptor;
     }
     return null;
 }
Example #4
0
        internal void Initialize(PluginDiscoverer.Merger merger, Runner.ServiceInfo r)
        {
            _assemblyQualifiedName = r.AssemblyQualifiedName;
            _serviceFullName       = r.ServiceFullName;
            _isDynamicService      = r.IsDynamicService;

            Debug.Assert(!_isDynamicService || (r.HasError || r.AssemblyInfo != null), "If we are a DynamicService, we must have an assembly or be in error.");
            if (r.AssemblyInfo != null)
            {
                _assembly = merger.FindOrCreate(r.AssemblyInfo);
            }

            base.Initialize(r);

            _implCollection = new List <PluginInfo>();
            foreach (Runner.PluginInfo plugin in r.Implementations)
            {
                _implCollection.Add(merger.FindOrCreate(plugin));
            }

            _impl = new ReadOnlyListOnIList <PluginInfo>(_implCollection);

            _propertiesInfoCollection = new List <SimplePropertyInfo>();
            foreach (Runner.SimplePropertyInfo rP in r.PropertiesInfoCollection)
            {
                SimplePropertyInfo p = new SimplePropertyInfo();
                p.Initialize(rP);
                _propertiesInfoCollection.Add(p);
            }
            _propertiesInfoCollectionEx = new ReadOnlyListOnIList <SimplePropertyInfo>(_propertiesInfoCollection);

            _methodsInfoCollection = new List <SimpleMethodInfo>();
            foreach (Runner.SimpleMethodInfo rM in r.MethodsInfoCollection)
            {
                SimpleMethodInfo m = new SimpleMethodInfo();
                m.Initialize(rM);
                _methodsInfoCollection.Add(m);
            }

            _methodsInfoCollectionEx = new ReadOnlyListOnIList <SimpleMethodInfo>(_methodsInfoCollection);

            _eventsInfoCollection = new List <SimpleEventInfo>();
            foreach (Runner.SimpleEventInfo rE in r.EventsInfoCollection)
            {
                SimpleEventInfo e = new SimpleEventInfo();
                e.Initialize(rE);
                _eventsInfoCollection.Add(e);
            }

            _eventsInfoCollectionEx = new ReadOnlyListOnIList <SimpleEventInfo>(_eventsInfoCollection);
        }
Example #5
0
        public Type GetPropertyType(string propertyName)
        {
            SimplePropertyInfo simpleProp = GetSimplePropertyInfo(propertyName);
            if ((simpleProp != null) && (simpleProp.Clazz != null))
            {
                return simpleProp.Clazz;
            }

            Property prop = PropertyParser.ParseAndWalkLaxToSimple(propertyName);
            if (prop is SimpleProperty)
            {
                // there is no such property since it wasn't in simplePropertyTypes
                return null;
            }
            return prop.GetPropertyType(this, _eventAdapterService);
        }
Example #6
0
        /// <summary>
        ///  Called by the GenericMergeList method
        /// </summary>
        /// <param name="rP"></param>
        /// <returns></returns>
        SimplePropertyInfo FindOrCreate(Runner.SimplePropertyInfo rP)
        {
            SimplePropertyInfo foundProp = null;

            foreach (SimplePropertyInfo p in this._propertiesInfoCollection)
            {
                if (p.Name == rP.Name)
                {
                    foundProp = p;
                }
            }

            if (foundProp != null)
            {
                foundProp.Merge(rP);
            }
            else
            {
                foundProp = new SimplePropertyInfo();
                foundProp.Initialize(rP);
            }
            return(foundProp);
        }
 public void WriteParams(IndentedTextWriter writer, OperationAnalyzer analyzer, SimplePropertyInfo spi, Param paramCustomization)
 {
     // replace the enum type with a string param instead and convert to enum member on execution
     writer.WriteLine("/// <summary>");
     writer.WriteLine("/// Specifies the HTTP verb to be used. The allowable verbs are GET, PUT, HEAD and DELETE.");
     writer.WriteLine("/// Not all verbs may be accepted by the service operation; check service documentation for details.");
     writer.WriteLine("/// If not specified, the default verb is GET.");
     writer.WriteLine("/// </summary>");
     if (spi.IsRecursivelyRequired && spi.DefaultValue == null)
     {
         writer.WriteLine("#if !MODULAR");
         writer.WriteLine("[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]");
         writer.WriteLine("#else");
         writer.WriteLine("[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true, Mandatory = true)]");
         if (spi.PropertyType == typeof(string))
         {
             writer.WriteLine("[System.Management.Automation.AllowEmptyString]");
         }
         writer.WriteLine("#endif");
         writer.WriteLine("[Amazon.PowerShell.Common.AWSRequiredParameter]");
     }
     else
     {
         writer.WriteLine("[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]");
     }
     writer.WriteLine("public String {0} {{ get; set; }}", spi.CmdletParameterName);
 }
Example #8
0
        private void Initialize(bool isConfigured)
        {
            var propertyListBuilder = PropertyListBuilderFactory.CreateBuilder(OptionalLegacyDef);
            var properties          = propertyListBuilder.AssessProperties(UnderlyingType);

            _propertyDescriptors        = new EventPropertyDescriptor[properties.Count];
            _propertyDescriptorMap      = new Dictionary <String, EventPropertyDescriptor>();
            PropertyNames               = new String[properties.Count];
            _simpleProperties           = new Dictionary <String, SimplePropertyInfo>();
            _mappedPropertyDescriptors  = new Dictionary <String, InternalEventPropDescriptor>();
            _indexedPropertyDescriptors = new Dictionary <String, InternalEventPropDescriptor>();

            if (UsesSmartResolutionStyle)
            {
                _simpleSmartPropertyTable  = new Dictionary <String, IList <SimplePropertyInfo> >();
                _mappedSmartPropertyTable  = new Dictionary <String, IList <SimplePropertyInfo> >();
                _indexedSmartPropertyTable = new Dictionary <String, IList <SimplePropertyInfo> >();
            }

            if ((OptionalLegacyDef == null) ||
                (OptionalLegacyDef.CodeGeneration != CodeGenerationEnum.DISABLED))
            {
                // get CGLib fast class
                FastClass = null;
                try
                {
                    FastClass = FastClass.Create(UnderlyingType);
                }
                catch (Exception ex)
                {
                    Log.Warn(".initialize Unable to obtain CGLib fast class and/or method implementation for class " +
                             UnderlyingType.Name + ", error msg is " + ex.Message, ex);
                    FastClass = null;
                }
            }

            int count = 0;

            foreach (InternalEventPropDescriptor desc in properties)
            {
                String propertyName = desc.PropertyName;
                Type   underlyingType;
                Type   componentType;
                bool   isRequiresIndex;
                bool   isRequiresMapkey;
                bool   isIndexed;
                bool   isMapped;
                bool   isFragment;

                if (desc.PropertyType.GetValueOrDefault() == EventPropertyType.SIMPLE)
                {
                    EventPropertyGetter getter;
                    Type type;
                    if (desc.ReadMethod != null)
                    {
                        getter = PropertyHelper.GetGetter(desc.PropertyName, desc.ReadMethod, FastClass, _eventAdapterService);
                        type   = desc.ReadMethod.ReturnType;
                    }
                    else
                    {
                        if (desc.AccessorField == null)
                        {
                            // Ignore property
                            continue;
                        }
                        getter = new ReflectionPropFieldGetter(desc.AccessorField, _eventAdapterService);
                        type   = desc.AccessorField.FieldType;
                    }

                    underlyingType   = type;
                    componentType    = null;
                    isRequiresIndex  = false;
                    isRequiresMapkey = false;
                    isIndexed        = false;
                    isMapped         = false;

                    if (type.IsGenericDictionary())
                    {
                        isMapped = true;
                        // We do not yet allow to fragment maps entries.
                        // Class genericType = TypeHelper.GetGenericReturnTypeMap(desc.ReadMethod, desc.AccessorField);
                        isFragment = false;

                        if (desc.ReadMethod != null)
                        {
                            componentType = TypeHelper.GetGenericReturnTypeMap(desc.ReadMethod, false);
                        }
                        else if (desc.AccessorField != null)
                        {
                            componentType = TypeHelper.GetGenericFieldTypeMap(desc.AccessorField, false);
                        }
                        else
                        {
                            componentType = typeof(object);
                        }
                    }
                    else if (type.IsArray)
                    {
                        isIndexed     = true;
                        isFragment    = type.GetElementType().IsFragmentableType();
                        componentType = type.GetElementType();
                    }
                    else if (type.IsImplementsInterface(typeof(IEnumerable)))
                    {
                        isIndexed = true;
                        Type genericType = TypeHelper.GetGenericReturnType(desc.ReadMethod, desc.AccessorField, true);
                        isFragment = genericType.IsFragmentableType();
                        if (genericType != null)
                        {
                            componentType = genericType;
                        }
                        else
                        {
                            componentType = typeof(Object);
                        }
                    }
                    else
                    {
                        isMapped   = false;
                        isFragment = type.IsFragmentableType();
                    }
                    _simpleProperties.Put(propertyName, new SimplePropertyInfo(type, getter, desc));

                    // Recognize that there may be properties with overlapping case-insentitive names
                    if (UsesSmartResolutionStyle)
                    {
                        // Find the property in the smart property table
                        var smartPropertyName = propertyName.ToLower();
                        var propertyInfoList  = _simpleSmartPropertyTable.Get(smartPropertyName);
                        if (propertyInfoList == null)
                        {
                            propertyInfoList = new List <SimplePropertyInfo>();
                            _simpleSmartPropertyTable.Put(smartPropertyName, propertyInfoList);
                        }

                        // Enter the property into the smart property list
                        var propertyInfo = new SimplePropertyInfo(type, getter, desc);
                        propertyInfoList.Add(propertyInfo);
                    }
                }
                else if (desc.PropertyType.GetValueOrDefault() == EventPropertyType.MAPPED)
                {
                    _mappedPropertyDescriptors.Put(propertyName, desc);

                    underlyingType   = desc.ReturnType;
                    componentType    = typeof(object);
                    isRequiresIndex  = false;
                    isRequiresMapkey = desc.ReadMethod.GetParameterTypes().Length > 0;
                    isIndexed        = false;
                    isMapped         = true;
                    isFragment       = false;

                    // Recognize that there may be properties with overlapping case-insentitive names
                    if (UsesSmartResolutionStyle)
                    {
                        // Find the property in the smart property table
                        var smartPropertyName = propertyName.ToLower();
                        var propertyInfoList  = _mappedSmartPropertyTable.Get(smartPropertyName);
                        if (propertyInfoList == null)
                        {
                            propertyInfoList = new List <SimplePropertyInfo>();
                            _mappedSmartPropertyTable.Put(smartPropertyName, propertyInfoList);
                        }

                        // Enter the property into the smart property list
                        var propertyInfo = new SimplePropertyInfo(desc.ReturnType, null, desc);
                        propertyInfoList.Add(propertyInfo);
                    }
                }
                else if (desc.PropertyType.GetValueOrDefault() == EventPropertyType.INDEXED)
                {
                    _indexedPropertyDescriptors.Put(propertyName, desc);

                    underlyingType   = desc.ReturnType;
                    componentType    = null;
                    isRequiresIndex  = desc.ReadMethod.GetParameterTypes().Length > 0;
                    isRequiresMapkey = false;
                    isIndexed        = true;
                    isMapped         = false;
                    isFragment       = desc.ReturnType.IsFragmentableType();

                    if (UsesSmartResolutionStyle)
                    {
                        // Find the property in the smart property table
                        String smartPropertyName = propertyName.ToLower();
                        IList <SimplePropertyInfo> propertyInfoList = _indexedSmartPropertyTable.Get(smartPropertyName);
                        if (propertyInfoList == null)
                        {
                            propertyInfoList = new List <SimplePropertyInfo>();
                            _indexedSmartPropertyTable.Put(smartPropertyName, propertyInfoList);
                        }

                        // Enter the property into the smart property list
                        var propertyInfo = new SimplePropertyInfo(desc.ReturnType, null, desc);
                        propertyInfoList.Add(propertyInfo);
                    }
                }
                else
                {
                    continue;
                }

                PropertyNames[count] = desc.PropertyName;
                var descriptor = new EventPropertyDescriptor(desc.PropertyName,
                                                             underlyingType, componentType, isRequiresIndex, isRequiresMapkey, isIndexed, isMapped, isFragment);
                _propertyDescriptors[count++] = descriptor;
                _propertyDescriptorMap.Put(descriptor.PropertyName, descriptor);
            }

            // Determine event type super types
            SuperTypes = GetBaseTypes(UnderlyingType, _eventAdapterService.BeanEventTypeFactory);
            if (SuperTypes != null && SuperTypes.Length == 0)
            {
                SuperTypes = null;
            }

            if (Metadata != null && Metadata.TypeClass == TypeClass.NAMED_WINDOW)
            {
                SuperTypes = null;
            }

            // Determine deep supertypes
            // Get base types (superclasses and interfaces), deep get of all in the tree
            ICollection <Type> supers = new HashSet <Type>();

            GetSuper(UnderlyingType, supers);
            RemoveLibraryInterfaces(supers);    // Remove CLR library base types

            // Cache the supertypes of this event type for later use
            _deepSuperTypes = new HashSet <EventType>();
            foreach (Type superClass in supers)
            {
                EventType superType = _eventAdapterService.BeanEventTypeFactory.CreateBeanType(superClass.FullName, superClass, false, false, isConfigured);
                _deepSuperTypes.Add(superType);
            }

            DeepSuperTypes = _deepSuperTypes.ToArray();
        }
        public void WriteContextMembers(IndentedTextWriter writer, string contextVar, SimplePropertyInfo spi, Param paramCustomization)
        {
            string contextMember = string.Format("{0}.{1}", contextVar, spi.CmdletParameterName);

            writer.WriteLine("if (this.StandardStorage.IsPresent)");
            writer.OpenRegion();
            {
                writer.WriteLine("{0} = S3StorageClass.Standard;", contextMember);
            }
            writer.CloseRegion();
            writer.WriteLine("else if (this.ReducedRedundancyStorage.IsPresent)");
            writer.OpenRegion();
            {
                writer.WriteLine("{0} = S3StorageClass.ReducedRedundancy;", contextMember);
            }
            writer.CloseRegion();
            writer.WriteLine();
        }
Example #10
0
        public void WriteContextMembers(IndentedTextWriter writer, string contextVar, SimplePropertyInfo spi, Param paramCustomization)
        {
            var contextMember = string.Format("{0}.{1}", contextVar, spi.CmdletParameterName);

            writer.WriteLine("if (this.{0} != null)", spi.CmdletParameterName);
            writer.OpenRegion();
            writer.WriteLine("{0} = AmazonEC2Helper.InstanceParamToIDs(this.{1});", contextMember, spi.CmdletParameterName);
            writer.CloseRegion();
            writer.WriteLine();
        }
Example #11
0
 public void WriteParams(IndentedTextWriter writer, OperationAnalyzer analyzer, SimplePropertyInfo spi, Param param)
 {
     writer.WriteLine(DocumentationUtils.CommentDocumentation(spi.MemberDocumentation /*FlattenedDocumentation*/));
     CmdletSourceWriter.WriteParamAttribute(writer, analyzer, spi, param);
     CmdletSourceWriter.WriteParamAliases(writer, analyzer, spi);
     writer.WriteLine("public object[] {0} {{ get; set; }}", spi.CmdletParameterName);
 }
        public void WriteParams(IndentedTextWriter writer, OperationAnalyzer analyzer, SimplePropertyInfo spi, ServiceConfig.Param param)
        {
            // for S3StorageClass, we replace the enum type with two string switches instead
            writer.WriteLine("/// <summary>");
            writer.WriteLine("/// Specifies the STANDARD storage class, which is the default storage class for S3 objects.");
            writer.WriteLine("/// Provides a 99.999999999% durability guarantee.");
            writer.WriteLine("/// </summary>");
            writer.WriteLine("[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]");
            writer.WriteLine("public SwitchParameter StandardStorage { get; set; }");
            writer.WriteLine();

            writer.WriteLine("/// <summary>");
            writer.WriteLine("/// Specifies S3 should use REDUCED_REDUNDANCY storage class for the object. This");
            writer.WriteLine("/// provides a reduced (99.99%) durability guarantee at a lower");
            writer.WriteLine("/// cost as compared to the STANDARD storage class. Use this");
            writer.WriteLine("/// storage class for non-mission critical data or for data");
            writer.WriteLine("/// that doesn’t require the higher level of durability that S3");
            writer.WriteLine("/// provides with the STANDARD storage class.");
            writer.WriteLine("/// </summary>");
            writer.WriteLine("[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]");
            writer.WriteLine("public SwitchParameter ReducedRedundancyStorage { get; set; }");
        }
 public AnalyzedResult(Type returnType, SimplePropertyInfo singleResultProperty)
 {
     ReturnType           = returnType;
     SingleResultProperty = singleResultProperty;
 }
        public void WriteContextMembers(IndentedTextWriter writer, string contextVar, SimplePropertyInfo spi, Param paramCustomization)
        {
            string contextMember = string.Format("{0}.{1}", contextVar, spi.CmdletParameterName);

            writer.WriteLine("if (!string.IsNullOrEmpty(this.{0}))", spi.CmdletParameterName);
            writer.OpenRegion();
            {
                writer.WriteLine("try");
                writer.OpenRegion();
                {
                    writer.WriteLine("{0} = (HttpVerb)Enum.Parse(typeof(HttpVerb), this.{1}, true);", contextMember, spi.CmdletParameterName);
                }
                writer.CloseRegion();
                writer.WriteLine("catch (ArgumentException e)");
                writer.OpenRegion();
                {
                    writer.WriteLine("string errMsg = \"Invalid parameter value; allowable values: \" + string.Join(\", \", Enum.GetNames(typeof(HttpVerb)));");
                    writer.WriteLine("this.ThrowArgumentError(errMsg, this.{0}, e);", spi.CmdletParameterName);
                }
                writer.CloseRegion();
            }
            writer.CloseRegion();
            writer.WriteLine();
        }
        /// <summary>
        /// Perform the scan on the source file. If we locate attributes marking use
        /// of ConstantClass-derived types, update the service model so that argument
        /// completers are generated and/or the cmdlet is added to the completer
        /// registration.
        /// </summary>
        public void Scan(string sourceFile, Dictionary <string, AdvancedCmdletInfo> advancedCmdlets, ArgumentCompleterDetails argumentCompleters = null)
        {
            var originalSource = File.ReadAllText(sourceFile);

            try
            {
                SyntaxTree            tree = CSharpSyntaxTree.ParseText(originalSource);
                CompilationUnitSyntax root = tree.GetCompilationUnitRoot();

                foreach (var ns in root.Members.OfType <NamespaceDeclarationSyntax>())
                {
                    foreach (var cls in ns.Members.OfType <ClassDeclarationSyntax>())
                    {
                        var attributes      = cls.AttributeLists.SelectMany(al => al.Attributes).ToArray();
                        var cmdletAttribute = attributes.FirstOrDefault(attr => GetAttributeName(attr) == "Cmdlet");
                        if (cmdletAttribute != null)
                        {
                            var cmdletVerb = (cmdletAttribute.ArgumentList.Arguments[0].Expression as LiteralExpressionSyntax).Token.ValueText;
                            var cmdletNoun = (cmdletAttribute.ArgumentList.Arguments[1].Expression as LiteralExpressionSyntax).Token.ValueText;
                            var cmdletName = $"{cmdletVerb}-{cmdletNoun}";
                            var cmdletInfo = new AdvancedCmdletInfo();
                            advancedCmdlets.Add(cmdletName, cmdletInfo);

                            var awsCmdletAttribute     = attributes.FirstOrDefault(attr => GetAttributeName(attr) == "AWSCmdlet");
                            var operationNameAttribute = awsCmdletAttribute?.ArgumentList.Arguments.Where(arg => arg.NameEquals?.Name.Identifier.ValueText == "Operation").FirstOrDefault() as AttributeArgumentSyntax;
                            var operationNames         = (operationNameAttribute?.Expression as ImplicitArrayCreationExpressionSyntax)?.Initializer.Expressions.OfType <LiteralExpressionSyntax>().Select(expr => expr.Token.ValueText);
                            if (operationNames != null)
                            {
                                cmdletInfo.OperationNames.AddRange(operationNames);
                            }

                            if (argumentCompleters != null)
                            {
                                foreach (var prop in cls.Members.OfType <PropertyDeclarationSyntax>())
                                {
                                    var propertyAttributes = prop.AttributeLists.SelectMany(al => al.Attributes).ToArray();
                                    if (propertyAttributes.Any(attr => GetAttributeName(attr) == "Parameter"))
                                    {
                                        var awsConstantClassSourceAttribute = propertyAttributes.FirstOrDefault(attr => GetAttributeName(attr) == "AWSConstantClassSource");
                                        if (awsConstantClassSourceAttribute != null)
                                        {
                                            var constantType = (awsConstantClassSourceAttribute.ArgumentList.Arguments[0].Expression as LiteralExpressionSyntax).Token.ValueText;
                                            var propertyName = prop.Identifier.ValueText;

                                            if (!argumentCompleters.IsConstantClassRegistered(constantType))
                                            {
                                                var propertyType = ServiceAssembly.GetType(constantType);
                                                var members      = SimplePropertyInfo.GetConstantClassMembers(propertyType);
                                                argumentCompleters.AddConstantClass(constantType, members);
                                            }
                                            argumentCompleters.AddConstantClassReference(constantType, propertyName, cmdletName);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                throw new InvalidDataException($"Error parsing advanced cmdlet file {sourceFile}", e);
            }
        }
Example #16
0
        public T Build()
        {
            var baseType = typeof(T).GetTypeInfo();

            var typeBuilder = baseType.IsInterface
                                        ? ModuleBuilder.DefineType(typeof(T).Name + "DynamicImpl", TypeAttributes.Class, null, new Type[] { baseType })
                                        : ModuleBuilder.DefineType(typeof(T).Name + "DynamicImpl", TypeAttributes.Class, baseType);

            foreach (var propertyInfo in baseType.DeclaredProperties)
            {
                var propertyGetMethod = propertyInfo.GetMethod;
                if (!propertyGetMethod.IsVirtual)
                {
                    continue;
                }

                var internalMethod = typeBuilder.DefineMethod(propertyGetMethod.Name + "Internal",
                                                              MethodAttributes.Private | MethodAttributes.Static, propertyGetMethod.ReturnType, null);

                var prop = typeBuilder.DefineProperty(propertyInfo.Name, PropertyAttributes.None, propertyInfo.PropertyType, null);

                var getter = typeBuilder.DefineMethod(propertyGetMethod.Name,
                                                      MethodAttributes.Public | MethodAttributes.SpecialName | MethodAttributes.HideBySig | MethodAttributes.Virtual,
                                                      propertyGetMethod.ReturnType, null);

                if (!_propertyImpl.TryGetValue(propertyInfo, out var impl))
                {
                    Delegate deleg;

                    if (!_delegates.TryGetValue(prop.PropertyType, out deleg))
                    {
                        throw new Exception($"Implementation for type '{prop.PropertyType}' has not found");
                    }


                    var simplePropInfo = new SimplePropertyInfo
                    {
                        Name = propertyInfo.Name,
                        Type = propertyInfo.PropertyType
                    };

                    impl = (LambdaExpression)deleg.DynamicInvoke(simplePropInfo);

                    var visitor = new InlinePropertyVisitor(simplePropInfo);

                    impl = (LambdaExpression)visitor.Visit(impl);
                }


                impl.CompileToMethod(internalMethod);

                var ilGenerator = getter.GetILGenerator();

                ilGenerator.Emit(OpCodes.Call, internalMethod);
                ilGenerator.Emit(OpCodes.Ret);

                prop.SetGetMethod(getter);

                typeBuilder.DefineMethodOverride(getter, propertyGetMethod);
            }
            var resultType = typeBuilder.CreateTypeInfo();

            var instance = Activator.CreateInstance(resultType.AsType());

            return((T)instance);
        }
 public void WriteParams(IndentedTextWriter writer, OperationAnalyzer analyzer, SimplePropertyInfo spi, Param paramCustomization)
 {
     // replace the enum type with a string param instead and convert to enum member on execution
     writer.WriteLine("/// <summary>");
     writer.WriteLine("/// Specifies the protocol that will be used. Allowable values are 'HTTP' and 'HTTPS'.");
     writer.WriteLine("/// </summary>");
     if (spi.IsRecursivelyRequired && spi.DefaultValue == null)
     {
         writer.WriteLine("#if !MODULAR");
         writer.WriteLine("[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]");
         writer.WriteLine("#else");
         writer.WriteLine("[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true, Mandatory = true)]");
         if (spi.PropertyType == typeof(string))
         {
             writer.WriteLine("[System.Management.Automation.AllowEmptyString]");
         }
         writer.WriteLine("#endif");
         writer.WriteLine("[Amazon.PowerShell.Common.AWSRequiredParameter]");
     }
     else
     {
         writer.WriteLine("[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]");
     }
     writer.WriteLine("public String {0} {{ get; set; }}", spi.CmdletParameterName);
 }