@@ -54,183 +54,90 @@ private static void Setup()
5454 . Root < Root > ( nameof ( Root ) )
5555
5656#if TOOL
57- . DefaultLifetime ( Transient )
58- . Bind ( ) . To ( _ => RunningMode . Tool )
59- . Bind ( "RuntimePathTag" ) . To ( _ => Path . GetDirectoryName ( typeof ( object ) . Assembly . Location ) ?? string . Empty )
60- . Bind ( ) . To ( ctx =>
57+ // Transient
58+ . Transient ( ( ) => RunningMode . Tool )
59+ . Transient ( ( ) => Path . GetDirectoryName ( typeof ( object ) . Assembly . Location ) ?? string . Empty , "RuntimePathTag" )
60+ . Transient ( ctx =>
61+ {
62+ ctx . Inject < ISettings > ( out var settings ) ;
63+ if ( settings . InteractionMode == InteractionMode . Interactive )
6164 {
62- ctx . Inject < ISettings > ( out var settings ) ;
63- if ( settings . InteractionMode == InteractionMode . Interactive )
64- {
65- ctx . Inject < IScriptRunner > ( InteractiveTag , out var scriptRunner ) ;
66- return scriptRunner ;
67- }
68- else
69- {
70- ctx . Inject < IScriptRunner > ( NonInteractiveTag , out var scriptRunner ) ;
71- return scriptRunner ;
72- }
73- } )
74- // Default settings
75- . Bind ( ) . To ( _ => OptimizationLevel . Release )
76- . Bind ( ) . To ( _ => ( WarningLevel ) ScriptOptions . Default . WarningLevel )
77- . Bind ( ) . To ( _ => ScriptOptions . Default . CheckOverflow ? CheckOverflow . On : CheckOverflow . Off )
78- . Bind ( ) . To ( _ => ScriptOptions . Default . AllowUnsafe ? AllowUnsafe . On : AllowUnsafe . Off )
79- . Bind ( ) . To < ScriptCommandFactory > ( )
80- . Bind ( ) . To < SourceResolver > ( )
81- . Bind ( ) . To < MetadataResolver > ( )
82- . Bind ( ) . To < AssembliesProvider > ( )
83- . Bind ( Unique ) . To < ConfigurableScriptOptionsFactory > ( )
84- . Bind ( ) . To < ScriptSubmissionAnalyzer > ( )
85- . Bind ( Unique ) . To < HelpCommandFactory > ( )
86- . Bind ( Unique ) . To < HelpCommandRunner > ( )
87- . Bind ( "LineCodeTag" ) . To < LineCodeSource > ( )
88-
89- . DefaultLifetime ( Singleton )
90- . Bind ( Unique ) . To < ExitManager > ( )
91- . Bind ( Unique ) . To < Debugger > ( )
92- . Bind ( InteractiveTag ) . To < InteractiveRunner > ( )
93- . Bind ( NonInteractiveTag ) . To < ScriptRunner > ( )
94- . Bind ( ) . To < CommandSource > ( )
95- . Bind ( ) . To < Setting < TTE > > ( )
96- . Bind ( Unique ) . Bind < IReferenceRegistry > ( ) . To < ReferencesScriptOptionsFactory > ( )
97- . Bind ( Unique ) . To < CSharpScriptCommandRunner > ( )
98- . Bind ( Unique ) . To < SettingCommandFactory < VerbosityLevel > > ( )
99- . Bind ( Unique ) . To < SettingCommandRunner < VerbosityLevel > > ( )
100- . Bind ( Unique ) . To < AddNuGetReferenceCommandFactory > ( )
101- . Bind ( Unique ) . To < AddNuGetReferenceCommandRunner > ( )
102- . Bind ( ) . To < CommandsRunner > ( )
103- . Bind ( ) . To < CodeSourceCommandFactory > ( )
104- . Bind ( ) . To < CSharpScriptRunner > ( )
105- . Bind ( ) . To < NuGetReferenceResolver > ( )
106- . Bind ( ) . To < ScriptContentReplacer > ( )
107- . Bind ( Unique ) . To < AssembliesScriptOptionsProvider > ( )
108- . Bind ( Unique ) . To < SourceFileScriptOptionsFactory > ( )
109- . Bind ( Unique ) . To < MetadataResolverOptionsFactory > ( )
110- . Bind ( Unique ) . To < ImportsOptionsFactory > ( )
111- . Bind ( Unique ) . To < SettingCommandFactory < LanguageVersion > > ( )
112- . Bind ( Unique ) . To < SettingCommandRunner < LanguageVersion > > ( )
113- . Bind ( Unique ) . To < SettingCommandFactory < OptimizationLevel > > ( )
114- . Bind ( Unique ) . To < SettingCommandRunner < OptimizationLevel > > ( )
115- . Bind ( Unique ) . To < SettingCommandFactory < WarningLevel > > ( )
116- . Bind ( Unique ) . To < SettingCommandRunner < WarningLevel > > ( )
117- . Bind ( Unique ) . To < SettingCommandFactory < CheckOverflow > > ( )
118- . Bind ( Unique ) . To < SettingCommandRunner < CheckOverflow > > ( )
119- . Bind ( Unique ) . To < SettingCommandFactory < AllowUnsafe > > ( )
120- . Bind ( Unique ) . To < SettingCommandRunner < AllowUnsafe > > ( )
121- . Bind ( Unique ) . To < SettingCommandFactory < NuGetRestoreSetting > > ( )
122- . Bind ( Unique ) . To < SettingCommandRunner < NuGetRestoreSetting > > ( )
65+ ctx . Inject < IScriptRunner > ( InteractiveTag , out var scriptRunner ) ;
66+ return scriptRunner ;
67+ }
68+ else
69+ {
70+ ctx . Inject < IScriptRunner > ( NonInteractiveTag , out var scriptRunner ) ;
71+ return scriptRunner ;
72+ }
73+ } )
74+ // Default settings
75+ . Transient ( ( ) => OptimizationLevel . Release )
76+ . Transient ( ( ) => ( WarningLevel ) ScriptOptions . Default . WarningLevel )
77+ . Transient ( ( ) => ScriptOptions . Default . CheckOverflow ? CheckOverflow . On : CheckOverflow . Off )
78+ . Transient ( ( ) => ScriptOptions . Default . AllowUnsafe ? AllowUnsafe . On : AllowUnsafe . Off )
79+
80+ . Transient < LineCodeSource > ( "LineCodeTag" )
81+ . Transient < ConfigurableScriptOptionsFactory , HelpCommandFactory , HelpCommandRunner > ( Unique )
82+ . Transient < ScriptCommandFactory , SourceResolver , MetadataResolver , AssembliesProvider , ScriptSubmissionAnalyzer > ( )
12383
124- . DefaultLifetime ( PerBlock )
125- . Bind ( ) . To < TextReplacer > ( )
126- . Bind ( ) . To < RuntimeExplorer > ( )
127- . Bind ( ) . To < ExitCodeParser > ( )
128- . Bind ( ) . To < StringService > ( )
129- . Bind ( ) . To < DiagnosticsPresenter > ( )
130- . Bind ( ) . To < ScriptStatePresenter > ( )
84+ . Bind ( Unique ) . Bind < IReferenceRegistry > ( ) . As ( Singleton ) . To < ReferencesScriptOptionsFactory > ( )
85+ . Singleton < InteractiveRunner > ( InteractiveTag )
86+ . Singleton < ScriptRunner > ( NonInteractiveTag )
87+ . Singleton < ExitManager , Debugger , CSharpScriptCommandRunner , SettingCommandFactory < VerbosityLevel >
88+ , SettingCommandRunner < VerbosityLevel > , AddNuGetReferenceCommandFactory , AddNuGetReferenceCommandRunner
89+ , AssembliesScriptOptionsProvider , SourceFileScriptOptionsFactory , MetadataResolverOptionsFactory , ImportsOptionsFactory > ( Unique )
90+ . Singleton < SettingCommandFactory < LanguageVersion > , SettingCommandRunner < LanguageVersion > , SettingCommandFactory < OptimizationLevel >
91+ , SettingCommandRunner < OptimizationLevel > , SettingCommandFactory < WarningLevel > , SettingCommandRunner < WarningLevel >
92+ , SettingCommandFactory < CheckOverflow > , SettingCommandRunner < CheckOverflow > , SettingCommandFactory < AllowUnsafe >
93+ , SettingCommandRunner < AllowUnsafe > , SettingCommandFactory < NuGetRestoreSetting > , SettingCommandRunner < NuGetRestoreSetting > > ( Unique )
94+ . Singleton < CommandSource , Setting < TTE > , CommandsRunner , CodeSourceCommandFactory , CSharpScriptRunner , NuGetReferenceResolver , ScriptContentReplacer > ( )
95+ . PerBlock < TextReplacer , RuntimeExplorer , ExitCodeParser , StringService , DiagnosticsPresenter , ScriptStatePresenter > ( )
13196#endif
13297#if APPLICATION
133- . Bind ( ) . As ( Transient ) . To ( _ => RunningMode . Application )
98+ . Transient ( _ => RunningMode . Application )
13499#endif
135- . DefaultLifetime ( Transient )
136- . Bind ( ) . To ( _ => Now )
137- . Bind ( ) . To ( _ => typeof ( Composition ) . Assembly )
138- . Bind ( ) . To ( _ => new CSharpParseOptions ( ) . LanguageVersion )
139- . Bind ( ) . To ( ( CancellationTokenSource cancellationTokenSource ) => cancellationTokenSource . Token )
140- . Bind ( TargetFrameworkMonikerTag ) . To ( ( Assembly assembly ) => assembly . GetCustomAttribute < System . Runtime . Versioning . TargetFrameworkAttribute > ( ) ? . FrameworkName ?? string . Empty )
141- . Bind ( ) . To ( _ => Process . GetCurrentProcess ( ) )
142- . Bind ( ModuleFileTag ) . To ( ( Process process ) => process . MainModule ? . FileName ?? string . Empty )
143- . Bind ( ) . To < ReliableBuildContext > ( )
144- . Bind ( ) . To < ProcessMonitor > ( )
145- . Bind ( ) . To < ProcessManager > ( )
146- . Bind ( BaseTag ) . To < BuildContext > ( )
147- . Bind ( ) . To ( _ => MemoryPool < TT > . Shared )
148- . Bind ( ) . To < FilePathResolver > ( )
149- . Bind ( ) . To < StartInfoFactory > ( )
150- . Bind ( LoadFileCodeTag ) . To < LoadFileCodeSource > ( )
151-
152- . DefaultLifetime ( PerBlock )
153- . Bind ( ) . To < StartInfoDescription > ( )
154- . Bind ( ) . To < HostEnvironment > ( )
155- . Bind ( ) . To < ColorTheme > ( )
156- . Bind ( ) . To < TeamCityLineFormatter > ( )
157- . Bind ( ) . To < FileSystem > ( )
158- . Bind < IDotNetEnvironment > ( ) . Bind < ITraceSource > ( Unique ) . To < DotNetEnvironment > ( )
159- . Bind < IDockerEnvironment > ( ) . Bind < ITraceSource > ( Unique ) . To < DockerEnvironment > ( )
160- . Bind < INuGetEnvironment > ( ) . Bind < ITraceSource > ( Unique ) . To < NuGetEnvironment > ( )
161- . Bind ( typeof ( VerbosityLevel ) ) . To < VerbosityLevelSettingDescription > ( )
162- . Bind ( ) . To < MSBuildArgumentsTool > ( )
163- . Bind ( ) . To < CommandLineParser > ( )
164- . Bind ( ) . To < TracePresenter > ( )
165- . Bind ( ) . To < StatisticsPresenter > ( )
166- . Bind ( ) . To < BuildEngine > ( )
167- . Bind ( ) . To < NuGetRestoreService > ( )
168- . Bind ( ) . To < NuGetLogger > ( )
169- . Bind ( ) . To < UniqueNameGenerator > ( )
170- . Bind ( ) . To < NuGetAssetsReader > ( )
171- . Bind ( ) . To < Cleaner > ( )
172- . Bind ( ) . To < TextToColorStrings > ( )
173- . Bind ( ) . To < FileExplorer > ( )
174- . Bind ( ) . To < Utf8Encoding > ( )
175- . Bind ( ) . To < BuildOutputProcessor > ( )
176- . Bind ( BaseTag ) . To < DefaultBuildMessagesProcessor > ( )
177- . Bind ( CustomTag ) . To < CustomMessagesProcessor > ( )
178- . Bind ( ) . To < TeamCityContext > ( )
179- . Bind ( ) . To < SummaryPresenter > ( )
180- . Bind ( BaseTag ) . To < ProcessRunner > ( )
181- . Bind ( ) . To < ProcessResultHandler > ( )
182-
183- . DefaultLifetime ( Singleton )
184- . Bind ( ) . To < Root > ( )
185- . Bind ( ) . To ( _ => new CancellationTokenSource ( ) )
186- . Bind ( ) . To < CISpecific < TT > > ( )
187- . Bind ( BaseTag ) . To < ConsoleInOut > ( )
188- . Bind ( TeamCityTag ) . To < TeamCityInOut > ( )
189- . Bind ( AnsiTag ) . To < AnsiInOut > ( )
190- . Bind ( ) . To < Console > ( )
191- . Bind ( ) . To ( ( ICISpecific < IStdOut > stdOut ) => stdOut . Instance )
192- . Bind ( ) . To ( ( ICISpecific < IStdErr > stdErr ) => stdErr . Instance )
193- . Bind ( BaseTag , AnsiTag ) . To < Log < TT > > ( )
194- . Bind ( TeamCityTag ) . To < TeamCityLog < TT > > ( )
195- . Bind ( ) . To ( ( ICISpecific < ILog < TT > > log ) => log . Instance )
196- . Bind ( ) . To < CISettings > ( )
197- . Bind ( ) . To < ExitTracker > ( )
198- . Bind ( ) . Bind < ITraceSource > ( Unique ) . To < Environment > ( )
199- . Bind < IEnvironmentVariables > ( ) . Bind < ITraceSource > ( Unique ) . To < EnvironmentVariables > ( )
200- . Bind ( ) . To < Settings > ( )
201- . Bind ( ) . To < Info > ( )
202- . Bind ( ) . To < ConsoleSource > ( )
203- . Bind ( ) . To < Statistics > ( )
204- . Bind ( ) . To < TargetFrameworkMonikerParser > ( )
205- . Bind ( ) . To < DockerSettings > ( )
206- . Bind ( ) . To < ProcessOutputWriter > ( )
207- . Bind ( ) . To < BuildMessageLogWriter > ( )
208- . Bind ( ) . To < MessageIndicesReader > ( )
209- . Bind ( ) . To < MessagesReader > ( )
210- . Bind ( ) . To < PathResolverContext > ( )
211- . Bind ( ) . To < ProcessInFlowRunner > ( )
212- . Bind ( Unique ) . As ( PerBlock ) . To < LanguageVersionSettingDescription > ( )
213- . Bind ( Unique ) . As ( PerBlock ) . To < OptimizationLevelSettingDescription > ( )
214- . Bind ( Unique ) . As ( PerBlock ) . To < WarningLevelSettingDescription > ( )
215- . Bind ( Unique ) . As ( PerBlock ) . To < CheckOverflowSettingDescription > ( )
216- . Bind ( Unique ) . As ( PerBlock ) . To < AllowUnsafeSettingDescription > ( )
217- . Bind ( Unique ) . As ( PerBlock ) . To < NuGetRestoreSettingDescription > ( )
218- . Bind ( BaseTag , AnsiTag ) . To < Properties > ( )
219- . Bind ( TeamCityTag ) . To < TeamCityProperties > ( )
220- . Bind ( ) . To ( ( ICISpecific < IProperties > properties ) => properties . Instance )
221-
222- // Public services
223- . Bind ( ) . To < HostService > ( )
224- . Bind ( ) . To < NuGetService > ( )
225- . Bind ( ) . To < CommandLineRunner > ( )
226- . Bind ( ) . To < BuildRunner > ( )
227- . Bind ( ) . To < TeamCityServiceMessages > ( )
228- . Bind ( ) . To < ServiceMessageFormatter > ( )
229- . Bind ( ) . To < FlowIdGenerator > ( )
230- . Bind ( ) . To < TimestampUpdater > ( )
231- . Bind ( BaseTag ) . To ( ( ITeamCityServiceMessages teamCityServiceMessages , IConsole console )
232- => teamCityServiceMessages . CreateWriter ( str => console . WriteToOut ( ( null , str + "\n " ) ) ) )
233- . Bind ( ) . To < SafeTeamCityWriter > ( )
234- . Bind ( ) . To < ServiceMessageParser > ( ) ;
100+ . Transient ( ( ) => Now )
101+ . Transient ( ( ) => typeof ( Composition ) . Assembly )
102+ . Transient ( ( ) => new CSharpParseOptions ( ) . LanguageVersion )
103+ . Transient ( ( CancellationTokenSource cancellationTokenSource ) => cancellationTokenSource . Token )
104+ . Transient ( ( ) => MemoryPool < TT > . Shared )
105+ . Transient ( Process . GetCurrentProcess )
106+ . Transient ( ( Process process ) => process . MainModule ? . FileName ?? string . Empty , ModuleFileTag )
107+ . Transient ( ( Assembly assembly ) => assembly . GetCustomAttribute < System . Runtime . Versioning . TargetFrameworkAttribute > ( ) ? . FrameworkName ?? string . Empty , TargetFrameworkMonikerTag )
108+ . Transient < BuildContext > ( BaseTag )
109+ . Transient < LoadFileCodeSource > ( LoadFileCodeTag )
110+ . Transient < FilePathResolver , StartInfoFactory , ReliableBuildContext , ProcessMonitor , ProcessManager > ( )
111+ . Bind < IDotNetEnvironment > ( ) . Bind < ITraceSource > ( Unique ) . As ( PerBlock ) . To < DotNetEnvironment > ( )
112+ . Bind < IDockerEnvironment > ( ) . Bind < ITraceSource > ( Unique ) . As ( PerBlock ) . To < DockerEnvironment > ( )
113+ . Bind < INuGetEnvironment > ( ) . Bind < ITraceSource > ( Unique ) . As ( PerBlock ) . To < NuGetEnvironment > ( )
114+ . PerBlock < VerbosityLevelSettingDescription > ( typeof ( VerbosityLevel ) )
115+ . PerBlock < CustomMessagesProcessor > ( CustomTag )
116+ . PerBlock < DefaultBuildMessagesProcessor , ProcessRunner > ( BaseTag )
117+ . PerBlock < LanguageVersionSettingDescription , OptimizationLevelSettingDescription , WarningLevelSettingDescription
118+ , CheckOverflowSettingDescription , AllowUnsafeSettingDescription , NuGetRestoreSettingDescription > ( Unique )
119+ . PerBlock < StartInfoDescription , HostEnvironment , ColorTheme , TeamCityLineFormatter , FileSystem , MSBuildArgumentsTool
120+ , CommandLineParser , TracePresenter , StatisticsPresenter , BuildEngine , NuGetRestoreService , NuGetLogger
121+ , UniqueNameGenerator , NuGetAssetsReader , Cleaner , TextToColorStrings , FileExplorer , Utf8Encoding
122+ , BuildOutputProcessor , TeamCityContext , SummaryPresenter , ProcessResultHandler > ( )
123+ . Singleton ( ( ) => new CancellationTokenSource ( ) )
124+ . Singleton ( ( ICISpecific < IStdOut > stdOut ) => stdOut . Instance )
125+ . Singleton ( ( ICISpecific < IStdErr > stdErr ) => stdErr . Instance )
126+ . Singleton ( ( ICISpecific < ILog < TT > > log ) => log . Instance )
127+ . Singleton ( ( ICISpecific < IProperties > properties ) => properties . Instance )
128+ . Bind ( ) . Bind < ITraceSource > ( Unique ) . As ( Singleton ) . To < Environment > ( )
129+ . Bind < IEnvironmentVariables > ( ) . Bind < ITraceSource > ( Unique ) . As ( Singleton ) . To < EnvironmentVariables > ( )
130+ . Singleton < ConsoleInOut > ( BaseTag )
131+ . Singleton < AnsiInOut > ( AnsiTag )
132+ . Singleton < Log < TT > , Properties > ( BaseTag , AnsiTag )
133+ . Singleton < TeamCityLog < TT > , TeamCityProperties , TeamCityInOut > ( TeamCityTag )
134+ . Singleton < Root , Console , CISettings , ExitTracker , CISpecific < TT > , Settings , Info , ConsoleSource
135+ , Statistics , TargetFrameworkMonikerParser , DockerSettings , ProcessOutputWriter , BuildMessageLogWriter
136+ , MessageIndicesReader , MessagesReader , PathResolverContext , ProcessInFlowRunner > ( )
137+ // Public services
138+ . Singleton ( ( ITeamCityServiceMessages teamCityServiceMessages , IConsole console )
139+ => teamCityServiceMessages . CreateWriter ( str => console . WriteToOut ( ( null , str + "\n " ) ) ) , BaseTag )
140+ . Singleton < HostService , NuGetService , CommandLineRunner , BuildRunner , TeamCityServiceMessages , ServiceMessageFormatter
141+ , FlowIdGenerator , TimestampUpdater , SafeTeamCityWriter , ServiceMessageParser > ( ) ;
235142 }
236143}
0 commit comments