Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ GetPublicType()

static Type System.Linq.EnumerableRewriter.GetPublicType ( Type t)
inlinestaticprivate

Definition at line 118 of file EnumerableRewriter.cs.

119 {
120 if (t.IsGenericType && ImplementsIGrouping(t))
121 {
122 return typeof(IGrouping<, >).MakeGenericType(t.GetGenericArguments());
123 }
124 if (!t.IsNestedPrivate)
125 {
126 return t;
127 }
129 {
130 return interfaceType2;
131 }
132 if (typeof(IEnumerable).IsAssignableFrom(t))
133 {
134 return typeof(IEnumerable);
135 }
136 return t;
137 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2075:UnrecognizedReflectionPattern", Justification = "The IGrouping<,> is kept since it's directly referenced hereand so it will also be preserved in all places where it's implemented.The GetInterfaces may return less after trimming but it will includethe IGrouping<,> if it was there before trimming, which is enough for thismethod to work.")]
138 static bool ImplementsIGrouping(Type type)
139 {
140 return type.GetGenericTypeDefinition().GetInterfaces().Contains(typeof(IGrouping<, >));
141 }
142 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2070:UnrecognizedReflectionPattern", Justification = "The IEnumerable<> is kept since it's directly referenced hereand so it will also be preserved in all places where it's implemented.The GetInterfaces may return less after trimming but it will includethe IEnumerable<> if it was there before trimming, which is enough for thismethod to work.")]
144 {
145 Type[] interfaces = type.GetInterfaces();
146 foreach (Type type2 in interfaces)
147 {
148 if (type2.IsGenericType && type2.GetGenericTypeDefinition() == typeof(IEnumerable<>))
149 {
151 return true;
152 }
153 }
154 interfaceType = null;
155 return false;
156 }
157 }
bool ICollection< KeyValuePair< TKey, TValue > >. Contains(KeyValuePair< TKey, TValue > keyValuePair)

References System.Collections.Generic.Dictionary< TKey, TValue >.Contains(), System.Type.GetGenericArguments(), System.Type.GetInterfaces(), System.Type.IsGenericType, System.Type.IsNestedPrivate, and System.type.

Referenced by System.Linq.EnumerableRewriter.GetEquivalentType(), and System.Linq.EnumerableRewriter.VisitConstant().