public override bool Execute() { var generateFeatureFileCodeBehindTaskContainerBuilder = new GenerateFeatureFileCodeBehindTaskContainerBuilder(); var generatorPlugins = GeneratorPlugins?.Select(gp => gp.ItemSpec).Select(p => new GeneratorPluginInfo(p)).ToArray() ?? Array.Empty <GeneratorPluginInfo>(); var featureFiles = FeatureFiles?.Select(i => i.ItemSpec).ToArray() ?? Array.Empty <string>(); var msbuildInformationProvider = new MSBuildInformationProvider(MSBuildVersion); var generateFeatureFileCodeBehindTaskConfiguration = new GenerateFeatureFileCodeBehindTaskConfiguration(AnalyticsTransmitter, CodeBehindGenerator); var generateFeatureFileCodeBehindTaskInfo = new SpecFlowProjectInfo(generatorPlugins, featureFiles, ProjectPath, ProjectFolder, ProjectGuid, AssemblyName, OutputPath, RootNamespace, TargetFrameworks, TargetFramework); using (var taskRootContainer = generateFeatureFileCodeBehindTaskContainerBuilder.BuildRootContainer(Log, generateFeatureFileCodeBehindTaskInfo, msbuildInformationProvider, generateFeatureFileCodeBehindTaskConfiguration)) { var assemblyResolveLoggerFactory = taskRootContainer.Resolve <IAssemblyResolveLoggerFactory>(); using (assemblyResolveLoggerFactory.Build()) { var taskExecutor = taskRootContainer.Resolve <IGenerateFeatureFileCodeBehindTaskExecutor>(); var executeResult = taskExecutor.Execute(); if (!(executeResult is ISuccess <IReadOnlyCollection <ITaskItem> > success)) { return(false); } GeneratedFiles = success.Result.ToArray(); return(true); } } }
public IObjectContainer BuildRootContainer( TaskLoggingHelper taskLoggingHelper, SpecFlowProjectInfo specFlowProjectInfo, IMSBuildInformationProvider msbuildInformationProvider, GenerateFeatureFileCodeBehindTaskConfiguration generateFeatureFileCodeBehindTaskConfiguration) { var objectContainer = new ObjectContainer(); // singletons objectContainer.RegisterInstanceAs(taskLoggingHelper); objectContainer.RegisterInstanceAs(specFlowProjectInfo); objectContainer.RegisterInstanceAs(msbuildInformationProvider); objectContainer.RegisterInstanceAs(generateFeatureFileCodeBehindTaskConfiguration); // types objectContainer.RegisterTypeAs <TaskLoggingHelperWithNameTagWrapper, ITaskLoggingWrapper>(); objectContainer.RegisterTypeAs <SpecFlowProjectProvider, ISpecFlowProjectProvider>(); objectContainer.RegisterTypeAs <MSBuildProjectReader, IMSBuildProjectReader>(); objectContainer.RegisterTypeAs <ProcessInfoDumper, IProcessInfoDumper>(); objectContainer.RegisterTypeAs <AssemblyResolveLoggerFactory, IAssemblyResolveLoggerFactory>(); objectContainer.RegisterTypeAs <GenerateFeatureFileCodeBehindTaskExecutor, IGenerateFeatureFileCodeBehindTaskExecutor>(); objectContainer.RegisterTypeAs <MSBuildTaskAnalyticsTransmitter, IMSBuildTaskAnalyticsTransmitter>(); objectContainer.RegisterTypeAs <ExceptionTaskLogger, IExceptionTaskLogger>(); objectContainer.RegisterTypeAs <FileUserIdStore, IUserUniqueIdStore>(); objectContainer.RegisterTypeAs <FileService, IFileService>(); objectContainer.RegisterTypeAs <DirectoryService, IDirectoryService>(); objectContainer.RegisterTypeAs <EnvironmentWrapper, IEnvironmentWrapper>(); objectContainer.RegisterTypeAs <EnvironmentSpecFlowTelemetryChecker, IEnvironmentSpecFlowTelemetryChecker>(); objectContainer.RegisterTypeAs <AnalyticsTransmitter, IAnalyticsTransmitter>(); objectContainer.RegisterTypeAs <HttpClientAnalyticsTransmitterSink, IAnalyticsTransmitterSink>(); objectContainer.RegisterTypeAs <AppInsightsEventSerializer, IAppInsightsEventSerializer>(); objectContainer.RegisterTypeAs <HttpClientWrapper, HttpClientWrapper>(); objectContainer.RegisterTypeAs <AnalyticsEventProvider, IAnalyticsEventProvider>(); objectContainer.RegisterTypeAs <ConfigurationLoader, IConfigurationLoader>(); objectContainer.RegisterTypeAs <GeneratorConfigurationProvider, IGeneratorConfigurationProvider>(); objectContainer.RegisterTypeAs <ProjectReader, ISpecFlowProjectReader>(); objectContainer.RegisterTypeAs <SpecFlowJsonLocator, ISpecFlowJsonLocator>(); if (generateFeatureFileCodeBehindTaskConfiguration.OverrideAnalyticsTransmitter is null) { objectContainer.RegisterTypeAs <AnalyticsTransmitter, IAnalyticsTransmitter>(); } else { objectContainer.RegisterInstanceAs(generateFeatureFileCodeBehindTaskConfiguration.OverrideAnalyticsTransmitter); } return(objectContainer); }
public WrappedGeneratorContainerBuilder(GeneratorContainerBuilder generatorContainerBuilder, GenerateFeatureFileCodeBehindTaskConfiguration generateFeatureFileCodeBehindTaskConfiguration) { _generatorContainerBuilder = generatorContainerBuilder; _generateFeatureFileCodeBehindTaskConfiguration = generateFeatureFileCodeBehindTaskConfiguration; }