private ParameterWrapper(ParameterHandle handle, IHandleTypeNamedWrapper typeWrapper, AssemblyMetadata assemblyMetadata)
        {
            AssemblyMetadata = assemblyMetadata;
            ParameterHandle  = handle;
            Handle           = handle;
            Definition       = Resolve(handle, assemblyMetadata);

            _name       = new Lazy <string>(() => Definition.Name.GetName(assemblyMetadata).GetKeywordSafeName(), LazyThreadSafetyMode.PublicationOnly);
            _attributes = new Lazy <IReadOnlyList <AttributeWrapper> >(() => AttributeWrapper.CreateChecked(Definition.GetCustomAttributes(), assemblyMetadata), LazyThreadSafetyMode.PublicationOnly);

            ParameterType = typeWrapper;

            Optional        = (Definition.Attributes & ParameterAttributes.Optional) != 0;
            HasDefaultValue = (Definition.Attributes & ParameterAttributes.HasDefault) != 0;

            _defaultValue  = new Lazy <object?>(() => !HasDefaultValue ? null : Definition.GetDefaultValue().ReadConstant(assemblyMetadata), LazyThreadSafetyMode.PublicationOnly);
            _referenceKind = new Lazy <ParameterReferenceKind>(GetReferenceKind, LazyThreadSafetyMode.PublicationOnly);
        }
        public static string GetName(this StringHandle handle, AssemblyMetadata assemblyMetadata)
        {
            var map = _stringHandleNames.GetOrAdd(assemblyMetadata, _ => new ConcurrentDictionary <StringHandle, string>());

            return(map.GetOrAdd(handle, stringHandle => assemblyMetadata.MetadataReader.GetString(stringHandle)));
        }
        /// <summary>
        /// Creates a instance of the parameter, if there is already not an instance.
        /// </summary>
        /// <param name="handle">The handle to the instance.</param>
        /// <param name="typeWrapper">The type of the parameter.</param>
        /// <param name="assemblyMetadata">The module that contains the instance.</param>
        /// <returns>The wrapper.</returns>
        public static ParameterWrapper?Create(ParameterHandle handle, IHandleTypeNamedWrapper typeWrapper, AssemblyMetadata assemblyMetadata)
        {
            if (handle.IsNil)
            {
                return(null);
            }

            return(new ParameterWrapper(handle, typeWrapper, assemblyMetadata));
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="AssemblyWrapper"/> class.
 /// </summary>
 /// <param name="assemblyMetadata">The module containing the definition.</param>
 internal AssemblyWrapper(AssemblyMetadata assemblyMetadata)
     : this(assemblyMetadata.MetadataReader.GetAssemblyDefinition(), assemblyMetadata)
 {
 }