コード例 #1
0
ファイル: AttributeHelpers.cs プロジェクト: belav/roslyn
        internal static DkmClrCustomTypeInfo GetCustomTypeInfo(
            this IList <CustomAttributeData> attributes
            )
        {
            ReadOnlyCollection <byte>   dynamicFlags      = null;
            ReadOnlyCollection <string> tupleElementNames = null;

            foreach (var attribute in attributes)
            {
                var attributeType = attribute.Constructor.DeclaringType;
                if (attributeType.IsType("System.Runtime.CompilerServices", "DynamicAttribute"))
                {
                    dynamicFlags = GetDynamicFlags(attribute);
                }
                else if (
                    attributeType.IsType(
                        "System.Runtime.CompilerServices",
                        "TupleElementNamesAttribute"
                        )
                    )
                {
                    tupleElementNames = GetTupleElementNames(attribute);
                }
            }
            return(CustomTypeInfo.Create(dynamicFlags, tupleElementNames));
        }
コード例 #2
0
        internal DkmClrCustomTypeInfo SubstituteCustomTypeInfo(
            Type type,
            DkmClrCustomTypeInfo customInfo
            )
        {
            if (_typeDefinition == null)
            {
                return(customInfo);
            }

            ReadOnlyCollection <byte>   dynamicFlags      = null;
            ReadOnlyCollection <string> tupleElementNames = null;

            if (customInfo != null)
            {
                CustomTypeInfo.Decode(
                    customInfo.PayloadTypeId,
                    customInfo.Payload,
                    out dynamicFlags,
                    out tupleElementNames
                    );
            }

            var substitutedFlags = SubstituteDynamicFlags(type, dynamicFlags);
            var substitutedNames = SubstituteTupleElementNames(type, tupleElementNames);

            return(CustomTypeInfo.Create(substitutedFlags, substitutedNames));
        }
コード例 #3
0
        internal static DkmClrCustomTypeInfo MakeCustomTypeInfo(params bool[] dynamicFlags)
        {
            if (dynamicFlags == null || dynamicFlags.Length == 0)
            {
                return(null);
            }

            var builder = ArrayBuilder <bool> .GetInstance(dynamicFlags.Length);

            builder.AddRange(dynamicFlags);
            var result = CustomTypeInfo.Create(DynamicFlagsCustomTypeInfo.ToBytes(builder), tupleElementNames: null);

            builder.Free();
            return(result);
        }