コード例 #1
0
        /// <summary>
        /// Returns the set of DebuggerBrowsableAttribute state for the
        /// members of the type, indexed by member name, or null if there
        /// are no DebuggerBrowsableAttributes on members of the type.
        /// </summary>
        private static Dictionary <string, DkmClrDebuggerBrowsableAttributeState> GetDebuggerBrowsableAttributeState(this DkmClrType type)
        {
            Dictionary <string, DkmClrDebuggerBrowsableAttributeState> result = null;

            foreach (var attribute in type.GetEvalAttributes())
            {
                var browsableAttribute = attribute as DkmClrDebuggerBrowsableAttribute;
                if (browsableAttribute == null)
                {
                    continue;
                }
                if (result == null)
                {
                    result = new Dictionary <string, DkmClrDebuggerBrowsableAttributeState>();
                }

                // There can be multiple same attributes for derived classes.
                // Debugger provides attributes starting from derived classes and then up to base ones.
                // We should use derived attributes if there is more than one instance.
                if (!result.ContainsKey(browsableAttribute.TargetMember))
                {
                    result.Add(browsableAttribute.TargetMember, browsableAttribute.State);
                }
            }
            return(result);
        }
コード例 #2
0
ファイル: TypeHelpers.cs プロジェクト: tsasioglu/roslyn
        /// <summary>
        /// Get the first attribute from <see cref="DkmClrType.GetEvalAttributes"/> (including inherited attributes)
        /// that is of type T, as well as the type that it targeted.
        /// </summary>
        internal static bool TryGetEvalAttribute <T>(this DkmClrType type, out DkmClrType attributeTarget, out T evalAttribute)
            where T : DkmClrEvalAttribute
        {
            attributeTarget = null;
            evalAttribute   = null;

            var appDomain      = type.AppDomain;
            var underlyingType = type.GetLmrType();

            while ((underlyingType != null) && !underlyingType.IsObject())
            {
                foreach (var attribute in type.GetEvalAttributes())
                {
                    evalAttribute = attribute as T;
                    if (evalAttribute != null)
                    {
                        attributeTarget = type;
                        return(true);
                    }
                }

                underlyingType = underlyingType.GetBaseTypeOrNull(appDomain, out type);
            }

            return(false);
        }
コード例 #3
0
        internal static DkmCustomUIVisualizerInfo[] GetDebuggerCustomUIVisualizerInfo(
            this DkmClrType type
            )
        {
            var builder = ArrayBuilder <DkmCustomUIVisualizerInfo> .GetInstance();

            var appDomain      = type.AppDomain;
            var underlyingType = type.GetLmrType();

            while ((underlyingType != null) && !underlyingType.IsObject())
            {
                foreach (var attribute in type.GetEvalAttributes())
                {
                    var visualizerAttribute = attribute as DkmClrDebuggerVisualizerAttribute;
                    if (visualizerAttribute == null)
                    {
                        continue;
                    }

                    builder.Add(
                        DkmCustomUIVisualizerInfo.Create(
                            (uint)builder.Count,
                            visualizerAttribute.VisualizerDescription,
                            visualizerAttribute.VisualizerDescription,
                            // ClrCustomVisualizerVSHost is a registry entry that specifies the CLSID of the
                            // IDebugCustomViewer class that will be instantiated to display the custom visualizer.
                            "ClrCustomVisualizerVSHost",
                            visualizerAttribute.UISideVisualizerTypeName,
                            visualizerAttribute.UISideVisualizerAssemblyName,
                            visualizerAttribute.UISideVisualizerAssemblyLocation,
                            visualizerAttribute.DebuggeeSideVisualizerTypeName,
                            visualizerAttribute.DebuggeeSideVisualizerAssemblyName
                            )
                        );
                }

                underlyingType = underlyingType.GetBaseTypeOrNull(appDomain, out type);
            }

            var result = (builder.Count > 0) ? builder.ToArray() : null;

            builder.Free();
            return(result);
        }
コード例 #4
0
ファイル: TypeHelpers.cs プロジェクト: tsasioglu/roslyn
        /// <summary>
        /// Returns the set of DebuggerBrowsableAttribute state for the
        /// members of the type, indexed by member name, or null if there
        /// are no DebuggerBrowsableAttributes on members of the type.
        /// </summary>
        private static Dictionary <string, DkmClrDebuggerBrowsableAttributeState> GetDebuggerBrowsableAttributeState(this DkmClrType type)
        {
            Dictionary <string, DkmClrDebuggerBrowsableAttributeState> result = null;

            foreach (var attribute in type.GetEvalAttributes())
            {
                var browsableAttribute = attribute as DkmClrDebuggerBrowsableAttribute;
                if (browsableAttribute == null)
                {
                    continue;
                }
                if (result == null)
                {
                    result = new Dictionary <string, DkmClrDebuggerBrowsableAttributeState>();
                }
                result.Add(browsableAttribute.TargetMember, browsableAttribute.State);
            }
            return(result);
        }