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

◆ GetEquivalentType()

Type System.Linq.EnumerableRewriter.GetEquivalentType ( Type type)
inlineprivate

Definition at line 159 of file EnumerableRewriter.cs.

160 {
161 if (_equivalentTypeCache == null)
162 {
164 {
165 {
168 },
169 {
172 }
173 };
174 }
176 {
178 if (publicType.IsInterface && publicType.IsGenericType)
179 {
180 Type genericTypeDefinition = publicType.GetGenericTypeDefinition();
182 {
184 }
186 {
187 value = typeof(IOrderedEnumerable<>).MakeGenericType(publicType.GenericTypeArguments[0]);
188 }
190 {
192 }
194 {
195 value = typeof(IEnumerable<>).MakeGenericType(publicType.GenericTypeArguments[0]);
196 }
197 }
198 if (value == null)
199 {
201 }
203 }
204 return value;
205 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2070:UnrecognizedReflectionPattern", Justification = "The enumerable interface type (IOrderedQueryable<>, IOrderedEnumerable<>, IQueryable<> and 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 enumerable interface type if it was there before trimming, which is enough for thismethod to work.")]
207 {
208 Type[] interfaces = sourceType.GetInterfaces();
209 var source = (from i in interfaces
210 where i.IsGenericType && i.GenericTypeArguments.Length == 1
211 select new
212 {
213 Info = i,
214 GenType = i.GetGenericTypeDefinition()
215 }).ToArray();
217 where i.GenType == typeof(IOrderedQueryable<>) || i.GenType == typeof(IOrderedEnumerable<>)
218 select i.Info.GenericTypeArguments[0]).Distinct().SingleOrDefault();
219 if (type2 != null)
220 {
221 return typeof(IOrderedEnumerable<>).MakeGenericType(type2);
222 }
223 type2 = (from i in source
224 where i.GenType == typeof(IQueryable<>) || i.GenType == typeof(IEnumerable<>)
225 select i.Info.GenericTypeArguments[0]).Distinct().Single();
226 return typeof(IEnumerable<>).MakeGenericType(type2);
227 }
228 }
bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value)
void Add(TKey key, TValue value)
Dictionary< Type, Type > _equivalentTypeCache

References System.Linq.EnumerableRewriter._equivalentTypeCache, System.Collections.Generic.Dictionary< TKey, TValue >.Add(), System.Linq.EnumerableRewriter.GetPublicType(), System.Linq.source, System.Collections.Generic.Dictionary< TKey, TValue >.TryGetValue(), System.type, and System.value.

Referenced by System.Linq.EnumerableRewriter.VisitBlock(), System.Linq.EnumerableRewriter.VisitConditional(), System.Linq.EnumerableRewriter.VisitGoto(), and System.Linq.EnumerableRewriter.VisitLabelTarget().