Exemple #1
0
        /// <inheritdoc/>
        internal override string GetDisplayName(bool fullyQualify, bool includeGenericInfo, GenericTypeArgumentCollection genericArguments)
        {
            if (_primitiveTypeNames.TryGetValue(FullName, out string primitiveTypeName))
            {
                return(primitiveTypeName);
            }

            var rootName  = Name;
            var tickIndex = rootName.LastIndexOf('`');

            if (0 <= tickIndex)
            {
                rootName = rootName.Substring(0, tickIndex);
            }

            if (includeGenericInfo)
            {
                var declaringTypeGenericArity = ContainingType == null ? 0 : ContainingType.GenericArity;

                if (genericArguments != null)
                {
                    rootName += genericArguments.GetGenericArgumentListDisplayText(includeGenericInfo, declaringTypeGenericArity, GenericParameters.Count - declaringTypeGenericArity);
                }
                else if (GenericParameters != null) // While initializing, this.GenericParameters could be null and we don't want this throwing an exception
                {
                    rootName += GenericParameters.GetParameterListText(skipCount: declaringTypeGenericArity);
                }
            }

            return(PostProcessUnqualifiedName(rootName, fullyQualify, includeGenericInfo, genericArguments));
        }