@@ -44,22 +44,28 @@ internal static void Init()
44
44
45
45
// We shouldn't create too many tasks.
46
46
#if ! UNIX
47
- // Amsi initialize can be a little slow
47
+ // Amsi initialize can be a little slow.
48
48
Task . Run ( ( ) => AmsiUtils . WinScanContent ( content : string . Empty , sourceMetadata : string . Empty , warmUp : true ) ) ;
49
49
#endif
50
+ // Initialize the types 'Compiler', 'CachedReflectionInfo', and 'ExpressionCache'.
51
+ // Their type initializers do a lot of reflection operations.
52
+ // We will access 'Compiler' members when creating the first session state.
53
+ Task . Run ( ( ) => _ = Compiler . DottedLocalsTupleType ) ;
50
54
51
55
// One other task for other stuff that's faster, but still a little slow.
52
56
Task . Run ( ( ) =>
53
57
{
54
- // Loading the resources for System.Management.Automation can be expensive, so force that to
55
- // happen early on a background thread.
58
+ // Loading the resources for System.Management.Automation can be expensive,
59
+ // so force that to happen early on a background thread.
56
60
_ = RunspaceInit . OutputEncodingDescription ;
57
61
58
62
// This will init some tables and could load some assemblies.
59
- _ = TypeAccelerators . builtinTypeAccelerators ;
63
+ // We will access 'LanguagePrimitives' when binding built-in variables for the Runspace.
64
+ LanguagePrimitives . GetEnumerator ( null ) ;
60
65
61
66
// This will init some tables and could load some assemblies.
62
- LanguagePrimitives . GetEnumerator ( null ) ;
67
+ // We will access 'TypeAccelerators' when auto-loading the PSReadLine module, which happens last.
68
+ _ = TypeAccelerators . builtinTypeAccelerators ;
63
69
} ) ;
64
70
}
65
71
}
0 commit comments