Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
RuntimeAssembly.cs
Go to the documentation of this file.
5using System.IO;
11
12namespace System.Reflection;
13
14internal class RuntimeAssembly : Assembly
15{
26
27 private string m_fullname;
28
29 private object m_syncRoot;
30
32
33 internal object SyncRoot
34 {
35 get
36 {
37 if (m_syncRoot == null)
38 {
39 Interlocked.CompareExchange<object>(ref m_syncRoot, new object(), (object)null);
40 }
41 return m_syncRoot;
42 }
43 }
44
45 [RequiresAssemblyFiles("This member throws an exception for assemblies embedded in a single-file app")]
46 public override string CodeBase
47 {
48 get
49 {
50 string codeBase = GetCodeBase();
51 if (codeBase == null)
52 {
54 }
55 return codeBase;
56 }
57 }
58
59 public override string FullName
60 {
61 get
62 {
63 if (m_fullname == null)
64 {
65 string s = null;
69 }
70 return m_fullname;
71 }
72 }
73
74 public override MethodInfo EntryPoint
75 {
76 get
77 {
78 IRuntimeMethodInfo o = null;
81 if (o == null)
82 {
83 return null;
84 }
86 }
87 }
88
90 {
91 [RequiresUnreferencedCode("Types might be removed")]
92 get
93 {
95 if (modulesInternal.Length == 1)
96 {
97 return modulesInternal[0].GetDefinedTypes();
98 }
100 for (int i = 0; i < modulesInternal.Length; i++)
101 {
102 list.AddRange(modulesInternal[i].GetDefinedTypes());
103 }
104 return list.ToArray();
105 }
106 }
107
108 public override bool IsCollectible
109 {
110 get
111 {
114 }
115 }
116
118
119 public override bool ReflectionOnly => false;
120
121 public override string Location
122 {
123 get
124 {
125 string s = null;
128 return s;
129 }
130 }
131
132 public override string ImageRuntimeVersion
133 {
134 get
135 {
136 string s = null;
139 return s;
140 }
141 }
142
143 [Obsolete("The Global Assembly Cache is not supported.", DiagnosticId = "SYSLIB0005", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
144 public override bool GlobalAssemblyCache => false;
145
146 public override long HostContext => 0L;
147
148 public override bool IsDynamic => FCallIsDynamic(GetNativeHandle());
149
151
153 {
154 add
155 {
157 }
158 remove
159 {
161 }
162 }
163
165 {
166 throw new NotSupportedException();
167 }
168
170 {
171 return m_assembly;
172 }
173
174 [DllImport("QCall", CharSet = CharSet.Unicode)]
176
177 internal string GetCodeBase()
178 {
179 string s = null;
182 {
183 return s;
184 }
185 return null;
186 }
187
189 {
190 return this;
191 }
192
193 public override AssemblyName GetName(bool copiedName)
194 {
195 string codeBase = GetCodeBase();
198 if (manifestModule.MDStreamVersion > 65536)
199 {
201 assemblyName.SetProcArchIndex(peKind, machine);
202 }
203 return assemblyName;
204 }
205
206 [DllImport("QCall", CharSet = CharSet.Unicode)]
208
209 [DllImport("QCall", CharSet = CharSet.Unicode)]
211
212 [DllImport("QCall", CharSet = CharSet.Unicode)]
214
215 [RequiresUnreferencedCode("Types might be removed")]
216 public override Type GetType(string name, bool throwOnError, bool ignoreCase)
217 {
218 if (name == null)
219 {
220 throw new ArgumentNullException("name");
221 }
222 RuntimeType o = null;
223 object o2 = null;
227 GC.KeepAlive(o2);
228 return o;
229 }
230
231 [DllImport("QCall", CharSet = CharSet.Unicode)]
233
234 [RequiresUnreferencedCode("Types might be removed")]
235 public override Type[] GetExportedTypes()
236 {
237 Type[] o = null;
240 return o;
241 }
242
243 [DllImport("QCall", CharSet = CharSet.Unicode)]
245
246 [DllImport("QCall", CharSet = CharSet.Unicode)]
247 private unsafe static extern byte* GetResource(QCallAssembly assembly, string resourceName, out uint length);
248
249 public override Stream GetManifestResourceStream(Type type, string name)
250 {
251 if (type == null && name == null)
252 {
253 throw new ArgumentNullException("type");
254 }
255 string text = type?.Namespace;
256 char ptr = Type.Delimiter;
257 string name2 = ((text != null && name != null) ? string.Concat(text, new ReadOnlySpan<char>(ref ptr, 1), name) : (text + name));
259 }
260
261 public unsafe override Stream GetManifestResourceStream(string name)
262 {
264 uint length;
266 if (resource != null)
267 {
268 return new ManifestResourceStream(this, resource, length, length, FileAccess.Read);
269 }
270 return null;
271 }
272
274 {
276 }
277
278 public override object[] GetCustomAttributes(bool inherit)
279 {
281 }
282
283 public override object[] GetCustomAttributes(Type attributeType, bool inherit)
284 {
285 if (attributeType == null)
286 {
287 throw new ArgumentNullException("attributeType");
288 }
290 if (runtimeType == null)
291 {
292 throw new ArgumentException(SR.Arg_MustBeType, "attributeType");
293 }
295 }
296
297 public override bool IsDefined(Type attributeType, bool inherit)
298 {
299 if (attributeType == null)
300 {
301 throw new ArgumentNullException("attributeType");
302 }
304 if (runtimeType == null)
305 {
306 throw new ArgumentException(SR.Arg_MustBeType, "attributeType");
307 }
309 }
310
315
320
325
332
333 [DllImport("QCall", CharSet = CharSet.Unicode)]
335
336 [DllImport("QCall", CharSet = CharSet.Unicode)]
337 private static extern void GetModule(QCallAssembly assembly, string name, ObjectHandleOnStack retModule);
338
339 public override Module GetModule(string name)
340 {
341 Module o = null;
344 return o;
345 }
346
347 [RequiresAssemblyFiles("This member throws an exception for assemblies embedded in a single-file app")]
348 public override FileStream GetFile(string name)
349 {
350 if (Location.Length == 0)
351 {
353 }
355 if (runtimeModule == null)
356 {
357 return null;
358 }
359 return new FileStream(runtimeModule.GetFullyQualifiedName(), FileMode.Open, FileAccess.Read, FileShare.Read, 4096, useAsync: false);
360 }
361
362 [RequiresAssemblyFiles("This member throws an exception for assemblies embedded in a single-file app")]
363 public override FileStream[] GetFiles(bool getResourceModules)
364 {
365 if (Location.Length == 0)
366 {
368 }
370 FileStream[] array = new FileStream[modules.Length];
371 for (int i = 0; i < array.Length; i++)
372 {
373 array[i] = new FileStream(((RuntimeModule)modules[i]).GetFullyQualifiedName(), FileMode.Open, FileAccess.Read, FileShare.Read, 4096, useAsync: false);
374 }
375 return array;
376 }
377
378 [MethodImpl(MethodImplOptions.InternalCall)]
379 private static extern string[] GetManifestResourceNames(RuntimeAssembly assembly);
380
381 public override string[] GetManifestResourceNames()
382 {
384 }
385
386 [MethodImpl(MethodImplOptions.InternalCall)]
388
389 [RequiresUnreferencedCode("Assembly references might be removed")]
391 {
393 }
394
395 [DllImport("QCall", CharSet = CharSet.Unicode)]
397
399 {
400 RuntimeAssembly o = null;
401 string s = null;
404 if (manifestResourceInfo == -1)
405 {
406 return null;
407 }
409 }
410
411 [DllImport("QCall", CharSet = CharSet.Unicode)]
413
414 [DllImport("QCall", CharSet = CharSet.Unicode)]
416
417 [DllImport("QCall", CharSet = CharSet.Unicode)]
418 private static extern void GetVersion(QCallAssembly assembly, out int majVer, out int minVer, out int buildNum, out int revNum);
419
426
427 [DllImport("QCall", CharSet = CharSet.Unicode)]
429
431 {
432 string s = null;
435 if (s == null)
436 {
438 }
440 }
441
442 [MethodImpl(MethodImplOptions.InternalCall)]
443 private static extern bool FCallIsDynamic(RuntimeAssembly assembly);
444
445 [DllImport("QCall", CharSet = CharSet.Unicode)]
447
448 internal string GetSimpleName()
449 {
451 string s = null;
453 return s;
454 }
455
456 [DllImport("QCall", CharSet = CharSet.Unicode)]
458
464
465 [DllImport("QCall", CharSet = CharSet.Unicode)]
467
469 {
471 return GetFlags(new QCallAssembly(ref assembly));
472 }
473
474 [DllImport("QCall", CharSet = CharSet.Unicode)]
476
477 internal byte[] GetPublicKey()
478 {
479 byte[] o = null;
482 return o;
483 }
484
486 {
487 return GetSatelliteAssembly(culture, null);
488 }
489
491 {
492 if (culture == null)
493 {
494 throw new ArgumentNullException("culture");
495 }
497 }
498
519
520 [DllImport("QCall", CharSet = CharSet.Unicode)]
522
530
531 public override Module[] GetModules(bool getResourceModules)
532 {
534 }
535
537 {
539 }
540
541 [MethodImpl(MethodImplOptions.InternalCall)]
543
544 [MethodImpl(MethodImplOptions.InternalCall)]
545 internal static extern int GetToken(RuntimeAssembly assembly);
546
547 [RequiresUnreferencedCode("Types might be removed")]
548 public sealed override Type[] GetForwardedTypes()
549 {
550 List<Type> list = new List<Type>();
552 GetManifestModule(GetNativeHandle()).MetadataImport.Enum(MetadataTokenType.ExportedType, 0, out var result);
555 for (int i = 0; i < result.Length; i++)
556 {
557 MetadataToken mdtExternalType = result[i];
558 Type o = null;
559 Exception item = null;
561 try
562 {
564 if (o == null)
565 {
566 continue;
567 }
568 }
569 catch (Exception ex)
570 {
571 o = null;
572 item = ex;
573 }
574 if (o != null)
575 {
576 list.Add(o);
578 }
579 else
580 {
581 list2.Add(item);
582 }
583 }
584 if (list2.Count != 0)
585 {
586 int count = list.Count;
587 int count2 = list2.Count;
588 list.AddRange(new Type[count2]);
589 list2.InsertRange(0, new Exception[count]);
590 throw new ReflectionTypeLoadException(list.ToArray(), list2.ToArray());
591 }
592 return list.ToArray();
593 }
594
595 [RequiresUnreferencedCode("Types might be removed because recursive nested types can't currently be annotated for dynamic access.")]
597 {
599 try
600 {
601 nestedTypes = type.GetNestedTypes(BindingFlags.Public);
602 }
603 catch (Exception item)
604 {
606 return;
607 }
609 foreach (Type type2 in array)
610 {
611 types.Add(type2);
613 }
614 }
615
616 [DllImport("QCall", CharSet = CharSet.Unicode)]
618}
void Add(TKey key, TValue value)
static void KeepAlive(object? obj)
Definition GC.cs:180
Definition GC.cs:8
static CultureInfo InvariantCulture
static CultureInfo GetCultureInfo(int culture)
static object[] GetCustomAttributes(RuntimeType type, RuntimeType caType, bool inherit)
static bool IsDefined(RuntimeType type, RuntimeType caType, bool inherit)
unsafe ManifestResourceStream(RuntimeAssembly manifestAssembly, byte *pointer, long length, long capacity, FileAccess access)
static void GetImageRuntimeVersion(QCallAssembly assembly, StringHandleOnStack retString)
static void GetExportedTypes(QCallAssembly assembly, ObjectHandleOnStack retTypes)
AssemblyHashAlgorithm GetHashAlgorithm()
override string[] GetManifestResourceNames()
static void GetEntryPoint(QCallAssembly assembly, ObjectHandleOnStack retMethod)
unsafe override Stream GetManifestResourceStream(string name)
override IEnumerable< TypeInfo > DefinedTypes
override ManifestResourceInfo GetManifestResourceInfo(string resourceName)
override object[] GetCustomAttributes(Type attributeType, bool inherit)
static AssemblyNameFlags GetFlags(QCallAssembly assembly)
static RuntimeAssembly InternalLoad(string assemblyName, ref StackCrawlMark stackMark, AssemblyLoadContext assemblyLoadContext=null)
static void AddPublicNestedTypes(Type type, List< Type > types, List< Exception > exceptions)
static Interop.BOOL GetIsCollectible(QCallAssembly assembly)
override Module GetModule(string name)
override void GetObjectData(SerializationInfo info, StreamingContext context)
static void GetModule(QCallAssembly assembly, string name, ObjectHandleOnStack retModule)
static RuntimeAssembly InternalLoad(AssemblyName assemblyName, RuntimeAssembly requestingAssembly, ref StackCrawlMark stackMark, bool throwOnFileNotFound, AssemblyLoadContext assemblyLoadContext=null)
static void GetForwardedType(QCallAssembly assembly, MetadataToken mdtExternalType, ObjectHandleOnStack type)
static RuntimeModule GetManifestModule(RuntimeAssembly assembly)
static string[] GetManifestResourceNames(RuntimeAssembly assembly)
static void GetVersion(QCallAssembly assembly, out int majVer, out int minVer, out int buildNum, out int revNum)
static bool GetCodeBase(QCallAssembly assembly, StringHandleOnStack retString)
ModuleResolveEventHandler _ModuleResolve
static RuntimeAssembly InternalLoad(AssemblyName assemblyName, ref StackCrawlMark stackMark, AssemblyLoadContext assemblyLoadContext=null)
static int GetManifestResourceInfo(QCallAssembly assembly, string resourceName, ObjectHandleOnStack assemblyRef, StringHandleOnStack retFileName)
Assembly InternalGetSatelliteAssembly(CultureInfo culture, Version version, bool throwOnFileNotFound)
override AssemblyName GetName(bool copiedName)
RuntimeModule[] GetModulesInternal(bool loadIfNotFound, bool getResourceModules)
override bool IsDefined(Type attributeType, bool inherit)
static void GetSimpleName(QCallAssembly assembly, StringHandleOnStack retSimpleName)
static void InternalLoad(ObjectHandleOnStack assemblyName, ObjectHandleOnStack requestingAssembly, StackCrawlMarkHandle stackMark, bool throwOnFileNotFound, ObjectHandleOnStack assemblyLoadContext, ObjectHandleOnStack retAssembly)
override FileStream GetFile(string name)
override Module[] GetLoadedModules(bool getResourceModules)
static bool FCallIsDynamic(RuntimeAssembly assembly)
override Assembly GetSatelliteAssembly(CultureInfo culture)
static unsafe byte * GetResource(QCallAssembly assembly, string resourceName, out uint length)
override Stream GetManifestResourceStream(Type type, string name)
static void GetFullName(QCallAssembly assembly, StringHandleOnStack retString)
static void GetModules(QCallAssembly assembly, bool loadIfNotFound, bool getResourceModules, ObjectHandleOnStack retModuleHandles)
override AssemblyName[] GetReferencedAssemblies()
static void GetLocale(QCallAssembly assembly, StringHandleOnStack retString)
static void GetPublicKey(QCallAssembly assembly, ObjectHandleOnStack retPublicKey)
override Module[] GetModules(bool getResourceModules)
override Type GetType(string name, bool throwOnError, bool ignoreCase)
override object[] GetCustomAttributes(bool inherit)
static void GetLocation(QCallAssembly assembly, StringHandleOnStack retString)
static AssemblyHashAlgorithm GetHashAlgorithm(QCallAssembly assembly)
override ModuleResolveEventHandler ModuleResolve
static int GetToken(RuntimeAssembly assembly)
override FileStream[] GetFiles(bool getResourceModules)
static void GetType(QCallAssembly assembly, string name, bool throwOnError, bool ignoreCase, ObjectHandleOnStack type, ObjectHandleOnStack keepAlive, ObjectHandleOnStack assemblyLoadContext)
override Assembly GetSatelliteAssembly(CultureInfo culture, Version version)
static AssemblyName[] GetReferencedAssemblies(RuntimeAssembly assembly)
override IList< CustomAttributeData > GetCustomAttributesData()
static IList< CustomAttributeData > GetCustomAttributesInternal(RuntimeType target)
static MethodBase GetMethodBase(RuntimeModule scope, int typeMetadataToken)
static ? AssemblyLoadContext CurrentContextualReflectionContext
static string Arg_MustBeType
Definition SR.cs:302
static string IO_NoFileTableInInMemoryAssemblies
Definition SR.cs:1542
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string NotSupported_CodeBase
Definition SR.cs:2182
static string IO_FileNotFound_FileName
Definition SR.cs:40
Definition SR.cs:7
static int CompareExchange(ref int location1, int value, int comparand)
static readonly char Delimiter
Definition Type.cs:17
delegate Module ModuleResolveEventHandler(object sender, ResolveEventArgs e)