Exemplo n.º 1
0
        public string GenerateReflectionName()
        {
            string theReturn = GenerateReflectionNameWithoutGenericsAndArrays();

            if (IsGenericTypeDefinition)
            {
                if (GenericParameters.IsNullOrEmpty())
                {
#if DEBUG
                    if (System.Diagnostics.Debugger.IsAttached)
                    {
                        System.Diagnostics.Debugger.Break();
                    }
                    else
                    {
                        System.Diagnostics.Debugger.Launch();
                    }
#else
                    throw new InvalidOperationException($"the type {theReturn} is marked as IsGenericTypeDefinition but it's missing its GenericParameters types");
#endif
                }
                theReturn = $"{theReturn}`{GenericParameters.Length}";
            }
            else if (IsConstructedGenericType)
            {
                if (Wrapped.IsNullOrEmpty())
                {
#if DEBUG
                    if (System.Diagnostics.Debugger.IsAttached)
                    {
                        System.Diagnostics.Debugger.Break();
                    }
                    else
                    {
                        System.Diagnostics.Debugger.Launch();
                    }
#else
                    throw new InvalidOperationException($"the type {theReturn} is marked as IsConstructedGenericType but it's missing its Wrapped types ");
#endif
                }
                theReturn = $"{theReturn}`{Wrapped.Length}[{string.Join(",", Wrapped.Select(t => $"[{t.GenerateReflectionName()}]"))}]";
            }

            if (ArrayDimensions > 0)
            {
                return(theReturn + $"[{string.Join(",", Enumerable.Repeat(string.Empty, ArrayDimensions))}]");
            }
            else
            {
                return(theReturn);
            }
        }