Пример #1
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();
        }
Пример #2
0
 private void InitProjectRewriter(AnalyzerResult analyzerResult, PortCoreConfiguration projectConfiguration)
 {
     InitRules(projectConfiguration, analyzerResult);
     _projectRewriter = new ProjectRewriter(analyzerResult, projectConfiguration);
 }
Пример #3
0
        private void MigrateNugets(Project project, bool addMigrationNuget)
        {
            var rewriter = new ProjectRewriter(resolver, progress);

            rewriter.RewriteProject(project.FilePath, addMigrationNuget);
        }
Пример #4
0
 private void InitProjectRewriter(AnalyzerResult analyzerResult, PortCoreConfiguration projectConfiguration)
 {
     InitRules(projectConfiguration, analyzerResult);
     _projectRewriter = _projectRewriterFactory.GetInstance(analyzerResult, projectConfiguration);
 }