Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
RuntimeTypeMetadataUpdateHandler.cs
Go to the documentation of this file.
1
using
System.Diagnostics.CodeAnalysis
;
2
3
namespace
System.Reflection.Metadata
;
4
5
internal
static
class
RuntimeTypeMetadataUpdateHandler
6
{
7
[UnconditionalSuppressMessage(
"ReflectionAnalysis"
,
"IL2026:RequiresUnreferencedCode"
, Justification =
"Clearing the caches on a Type isn't affected if a Type is trimmed, or has any of its members trimmed."
)]
8
public
static
void
ClearCache
(
Type
[] types)
9
{
10
if
(
RequiresClearingAllTypes
(types))
11
{
12
Assembly
[] assemblies =
AppDomain
.
CurrentDomain
.GetAssemblies();
13
foreach
(
Assembly
assembly
in
assemblies)
14
{
15
if
(
SkipAssembly
(assembly))
16
{
17
continue
;
18
}
19
try
20
{
21
Type
[] types2 = assembly.
GetTypes
();
22
foreach
(
Type
type
in
types2)
23
{
24
ClearCache
(
type
);
25
}
26
}
27
catch
(
ReflectionTypeLoadException
)
28
{
29
}
30
}
31
}
32
else
33
{
34
foreach
(
Type
type2
in
types)
35
{
36
ClearCache
(type2);
37
}
38
}
39
}
40
41
private
static
bool
SkipAssembly
(
Assembly
assembly)
42
{
43
return
typeof(
object
).Assembly == assembly;
44
}
45
46
private
static
void
ClearCache
(
Type
type
)
47
{
48
(
type
as
RuntimeType
)?.
ClearCache
();
49
}
50
51
private
static
bool
RequiresClearingAllTypes
([NotNullWhen(
false
)]
Type
[] types)
52
{
53
if
(types ==
null
)
54
{
55
return
true
;
56
}
57
foreach
(
Type
type
in
types)
58
{
59
if
(!
type
.IsSealed)
60
{
61
return
true
;
62
}
63
}
64
return
false
;
65
}
66
}
System.AppDomain.CurrentDomain
static AppDomain CurrentDomain
Definition
AppDomain.cs:28
System.AppDomain
Definition
AppDomain.cs:17
System.Reflection.Assembly.GetTypes
virtual Type[] GetTypes()
Definition
Assembly.cs:237
System.Reflection.Assembly
Definition
Assembly.cs:16
System.Reflection.Metadata.RuntimeTypeMetadataUpdateHandler.ClearCache
static void ClearCache(Type[] types)
Definition
RuntimeTypeMetadataUpdateHandler.cs:8
System.Reflection.Metadata.RuntimeTypeMetadataUpdateHandler.RequiresClearingAllTypes
static bool RequiresClearingAllTypes([NotNullWhen(false)] Type[] types)
Definition
RuntimeTypeMetadataUpdateHandler.cs:51
System.Reflection.Metadata.RuntimeTypeMetadataUpdateHandler.SkipAssembly
static bool SkipAssembly(Assembly assembly)
Definition
RuntimeTypeMetadataUpdateHandler.cs:41
System.Reflection.Metadata.RuntimeTypeMetadataUpdateHandler.ClearCache
static void ClearCache(Type type)
Definition
RuntimeTypeMetadataUpdateHandler.cs:46
System.Reflection.Metadata.RuntimeTypeMetadataUpdateHandler
Definition
RuntimeTypeMetadataUpdateHandler.cs:6
System.Reflection.ReflectionTypeLoadException
Definition
ReflectionTypeLoadException.cs:10
System.RuntimeType
Definition
RuntimeType.cs:16
System.Type
Definition
Type.cs:14
System.Diagnostics.CodeAnalysis
Definition
AllowNullAttribute.cs:1
System.Reflection.Metadata
Definition
AssemblyExtensions.cs:4
System.ExceptionArgument.type
@ type
source
System.Private.CoreLib
System.Reflection.Metadata
RuntimeTypeMetadataUpdateHandler.cs
Generated by
1.10.0