Beispiel #1
0
        public void OneTimeSetup()
        {
            var workingDirectory = Environment.CurrentDirectory;

            TestProjectPath                       = Directory.GetParent(workingDirectory).Parent.Parent.FullName;
            TestFilesDirectoryPath                = Path.Combine(TestProjectPath, Path.Combine("TestingArea", "TestFiles"));
            TestCodeFilePath                      = Path.Combine(TestFilesDirectoryPath, "TestClassFile.cs");
            TestWebConfigFilePath                 = Path.Combine(TestFilesDirectoryPath, "web.config");
            TestStaticFilePath                    = Path.Combine(TestFilesDirectoryPath, "SampleStaticFile.csv");
            TestStaticResourceFilePath            = Path.Combine(TestFilesDirectoryPath, "SampleStaticResourceFile.png");
            TestViewFilePath                      = Path.Combine(TestFilesDirectoryPath, "SampleViewFile.aspx");
            TestHyperLinkControlFilePath          = Path.Combine(TestFilesDirectoryPath, "HyperLinkControlOnly.aspx");
            TestButtonControlFilePath             = Path.Combine(TestFilesDirectoryPath, "ButtonControlOnly.aspx");
            TestLabelControlFilePath              = Path.Combine(TestFilesDirectoryPath, "LabelControlOnly.aspx");
            TestListViewControlFilePath           = Path.Combine(TestFilesDirectoryPath, "ListViewControlOnly.aspx");
            TestGridViewControlFilePath           = Path.Combine(TestFilesDirectoryPath, "GridViewControlOnly.aspx");
            TestContentPlaceHolderControlFilePath =
                Path.Combine(TestFilesDirectoryPath, "ContentPlaceHolderControlOnly.aspx");
            TestContentControlFilePath = Path.Combine(TestFilesDirectoryPath, "ContentControlOnly.aspx");
            TestSiteMasterFilePath     = Path.Combine(TestFilesDirectoryPath, "SampleSiteMasterFile.Master");
            TestDirectiveFilePath      = Path.Combine(TestFilesDirectoryPath, "DirectiveOnly.aspx");
            TestAreaFullPath           = Path.Combine(TestProjectPath, TestFilesDirectoryPath);

            _blazorWorkspaceManager = new WorkspaceManagerService();
            Utils.DownloadFilesToFolder(Constants.S3TemplatesBucketUrl, Constants.ResourcesExtractedPath, Constants.TemplateFiles);
        }
Beispiel #2
0
        public void OneTimeSetup()
        {
            var workingDirectory = Environment.CurrentDirectory;

            _testProjectPath = Directory.GetParent(workingDirectory).Parent.Parent.FullName;

            var codeAnalyzer = CreateDefaultCodeAnalyzer();
            // Get analyzer results from codelyzer (syntax trees, semantic models, package references, project references, etc)
            var analyzerResult = codeAnalyzer.AnalyzeProject(DownloadTestProjectsFixture.EShopLegacyWebFormsProjectPath).Result;

            var ctaArgs = new[]
            {
                "-p", DownloadTestProjectsFixture.EShopLegacyWebFormsProjectPath, // can hardcode for local use
                "-v", "net5.0",                                                   // set the Target Framework version
                "-d", "true",                                                     // use the default rules files (these will get downloaded from S3 and will tell CTA which packages to add to the new .csproj file)
                "-m", "false",                                                    // this is the "mock run" flag. Setting it to false means rules will be applied if we do a full port.
            };

            // Handle argument assignment
            PortCoreRulesCli cli = new PortCoreRulesCli();

            cli.HandleCommand(ctaArgs);
            if (cli.DefaultRules)
            {
                // Since we're using default rules, we want to specify where to find those rules (once they are downloaded)
                cli.RulesDir = Constants.RulesDefaultPath;
            }

            var packageReferences = new Dictionary <string, Tuple <string, string> >
            {
                { "Autofac", new Tuple <string, string>("4.9.1.0", "4.9.3") },
                { "EntityFramework", new Tuple <string, string>("6.0.0.0", "6.4.4") },
                { "log4net", new Tuple <string, string>("2.0.8.0", "2.0.12") },
                { "Microsoft.Extensions.Logging.Log4Net.AspNetCore", new Tuple <string, string>("1.0.0", "2.2.12") }
            };

            // Create a configuration object using the CLI and other arbitrary values
            PortCoreConfiguration projectConfiguration = new PortCoreConfiguration()
            {
                ProjectPath       = cli.FilePath,
                RulesDir          = cli.RulesDir,
                IsMockRun         = cli.IsMockRun,
                UseDefaultRules   = cli.DefaultRules,
                PackageReferences = packageReferences,
                PortCode          = false,
                PortProject       = true,
                TargetVersions    = new List <string> {
                    cli.Version
                }
            };

            var           projectRewriter = new ProjectRewriter(analyzerResult, projectConfiguration);
            ProjectResult projectResult   = projectRewriter.Initialize();

            _webFormsProjectAnalyzer = new ProjectAnalyzer(_testProjectPath, analyzerResult, projectConfiguration, projectResult);
            _blazorWorkspaceManager  = new WorkspaceManagerService();
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        public ProjectFileConverter(
            string sourceProjectPath,
            string fullPath,
            WorkspaceManagerService blazorWorkspaceManager,
            ProjectAnalyzer projectAnalyzer,
            TaskManagerService taskManagerService,
            WebFormMetricContext metricsContext
            ) : base(sourceProjectPath, fullPath, taskManagerService)
        {
            _blazorWorkspaceManager = blazorWorkspaceManager;
            _projectAnalyzer        = projectAnalyzer;
            _metricsContext         = metricsContext;

            _blazorWorkspaceManager.NotifyNewExpectedProject();
        }
Beispiel #5
0
        public void Setup()
        {
            var webFormsProjectAnalyzer = new ProjectAnalyzer(_testProjectPath, new AnalyzerResult(), new PortCoreConfiguration(), new ProjectResult());
            var blazorWorkspaceManager  = new WorkspaceManagerService();
            var taskManagerService      = new TaskManagerService();

            blazorWorkspaceManager.CreateSolutionFile();
            WebFormMetricContext metricContext = new WebFormMetricContext();

            _fileConverterFactory = new FileConverterFactory(
                _testProjectPath,
                blazorWorkspaceManager,
                webFormsProjectAnalyzer,
                new ViewImportService(),
                new ClassConverterFactory(string.Empty, new LifecycleManagerService(), taskManagerService, metricContext),
                new HostPageService(),
                taskManagerService,
                metricContext);
        }
Beispiel #6
0
        private void InitializeServices()
        {
            _taskManager            = new TaskManagerService();
            _lifecycleManager       = new LifecycleManagerService();
            _viewImportService      = new ViewImportService();
            _programCsService       = new ProgramCsService();
            _appRazorService        = new AppRazorService();
            _hostPageService        = new HostPageService();
            _blazorWorkspaceManager = new WorkspaceManagerService();

            // By convention, we expect the root namespace to share a name with the project
            // root folder, we normalize the folder name before using it in case the folder name
            // is not a valid identifier
            var rootNamespace = Utilities.NormalizeNamespaceIdentifier(_analyzerResult.ProjectResult.ProjectName);

            _programCsService.ProgramCsNamespace = rootNamespace;
            _hostPageService.HostNamespace       = rootNamespace;
            _blazorWorkspaceManager.CreateSolutionFile();
        }
Beispiel #7
0
 public FileConverterFactory(
     string sourceProjectPath,
     WorkspaceManagerService blazorWorkspaceManager,
     ProjectAnalyzer webFormsProjectAnalyzer,
     ViewImportService viewImportService,
     ClassConverterFactory classConverterFactory,
     HostPageService hostPageService,
     TaskManagerService taskManagerService,
     WebFormMetricContext metricsContext)
 {
     _sourceProjectPath       = sourceProjectPath;
     _blazorWorkspaceManager  = blazorWorkspaceManager;
     _webFormsProjectAnalyzer = webFormsProjectAnalyzer;
     _viewImportService       = viewImportService;
     _classConverterFactory   = classConverterFactory;
     _hostPageService         = hostPageService;
     _taskManagerService      = taskManagerService;
     _metricsContext          = metricsContext;
 }
Beispiel #8
0
        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}");
            }
        }
Beispiel #9
0
 public void SetUp()
 {
     _workspaceManager = new WorkspaceManagerService();
     _workspaceManager.CreateSolutionFile();
 }
Beispiel #10
0
 public void SetUp()
 {
     _workspaceManager = new WorkspaceManagerService();
 }