public void SetUp() { WebFormMetricContext metricContext = new WebFormMetricContext(); _classConverterFactory = new ClassConverterFactory(string.Empty, new LifecycleManagerService(), new TaskManagerService(), metricContext); _workspaceManager = new WorkspaceManagerService(); _workspaceManager.CreateSolutionFile(); _workspaceManager.NotifyNewExpectedProject(); _primaryProjectId = _workspaceManager.CreateProjectFile("TestProjectName", metadataReferences: _metadataReferences); }
private void InitializeFactories() { _classConverterFactory = new ClassConverterFactory( _inputProjectPath, _lifecycleManager, _taskManager, _metricsContext); _fileConverterFactory = new FileConverterFactory( _inputProjectPath, _blazorWorkspaceManager, _webFormsProjectAnalyzer, _viewImportService, _classConverterFactory, _hostPageService, _taskManager, _metricsContext); }
public CodeFileConverter( string sourceProjectPath, string fullPath, WorkspaceManagerService blazorWorkspaceManager, ProjectAnalyzer webFormsProjectAnalyzer, ClassConverterFactory classConverterFactory, TaskManagerService taskManagerService, WebFormMetricContext metricsContext) : base(sourceProjectPath, fullPath, taskManagerService) { // May not need this anymore but not sure yet _blazorWorkspaceBuilder = blazorWorkspaceManager; _webFormsProjectAnaylzer = webFormsProjectAnalyzer; _classConverterFactory = classConverterFactory; _metricsContext = metricsContext; try { _fileModel = _webFormsProjectAnaylzer.AnalyzerResult.ProjectBuildResult?.SourceFileBuildResults? .Single(r => r.SourceFileFullPath.Equals(fullPath, StringComparison.OrdinalIgnoreCase))?.SemanticModel; } catch (Exception e) { LogHelper.LogError(e, $"{Rules.Config.Constants.WebFormsErrorTag}Exception occurred when trying to retrieve semantic model for the file {FullPath}. " + "Semantic Model will default to null."); } if (_fileModel != null) { _classConverters = _classConverterFactory.BuildMany(RelativePath, _fileModel); } else { _classConverters = new List <ClassConverter>(); LogHelper.LogWarning($"Semantic model was not found so class conversion cannot take place. Returning zero class converters for file: {FullPath}"); } }