public async Task UpdateHomePageAsync()
        {
            // Default configuration: SplitView, MvvmToolkit, Blank page
            var stylesProviders = new UITestStyleValuesProvider();
            var viewModel       = new MainViewModel(null, stylesProviders);
            var context         = new UserSelectionContext(GenContext.CurrentLanguage, Platforms.Uwp);

            viewModel.Initialize(context);
            await viewModel.OnTemplatesAvailableAsync();

            await AddTemplateAsync(viewModel, GetTemplate(viewModel.StepsViewModels[TemplateType.Page].Groups, PageBlank));

            var userSelection = viewModel.UserSelection.GetUserSelection();

            Assert.True(userSelection.Pages[0].Name == "Main");
            Assert.True(userSelection.Pages[1].Name == "Blank");
            Assert.True(userSelection.HomeName == "Main");
            var pages = viewModel.UserSelection.Groups.First(g => g.TemplateType == TemplateType.Page);

            pages.EnableOrdering(null);
            pages.SelectedItem = pages.Items[1]; // Select Blank
            pages.MoveUpCommand.Execute(null);
            userSelection = viewModel.UserSelection.GetUserSelection();
            viewModel.UnsubscribeEventHandlers();

            Assert.True(userSelection.Pages[0].Name == "Blank");
            Assert.True(userSelection.Pages[1].Name == "Main");
            Assert.True(userSelection.HomeName == "Blank");
        }
        public async Task RemoveHiddenFeaturesAsync()
        {
            // Default configuration: SplitView, MvvmToolkit, Blank page
            var stylesProviders = new UITestStyleValuesProvider();
            var viewModel       = new MainViewModel(null, stylesProviders);
            var context         = new UserSelectionContext(GenContext.CurrentLanguage, Platforms.Uwp);

            viewModel.Initialize(context);
            await viewModel.OnTemplatesAvailableAsync();

            var chartTemplate     = GetTemplate(viewModel.StepsViewModels[TemplateType.Page].Groups, PageChart);
            var gridTemplate      = GetTemplate(viewModel.StepsViewModels[TemplateType.Page].Groups, PageGrid);
            var numOfDependencies = chartTemplate.Dependencies?.Count();

            await AddTemplateAsync(viewModel, chartTemplate);
            await AddTemplateAsync(viewModel, gridTemplate);

            var userSelection = viewModel.UserSelection.GetUserSelection();

            Assert.Equal(3, userSelection.Pages.Count);
            Assert.Equal(numOfDependencies, userSelection.Services.Count);

            DeleteTemplate(TemplateType.Page, viewModel.UserSelection, 2);
            userSelection = viewModel.UserSelection.GetUserSelection();
            Assert.Equal(2, userSelection.Pages.Count);
            Assert.Equal(numOfDependencies, userSelection.Services.Count);

            DeleteTemplate(TemplateType.Page, viewModel.UserSelection, 1);
            userSelection = viewModel.UserSelection.GetUserSelection();
            viewModel.UnsubscribeEventHandlers();

            Assert.Single(userSelection.Pages);
            Assert.Equal(numOfDependencies, userSelection.Services.Count + 1);
        }
        public async Task ProjectInitUpdatedConfigurationAsync()
        {
            // Default configuration: SplitView, MvvmToolkit, Blank page
            var stylesProviders = new UITestStyleValuesProvider();
            var viewModel       = new MainViewModel(null, stylesProviders);
            var context         = new UserSelectionContext(GenContext.CurrentLanguage, Platforms.Uwp);

            viewModel.Initialize(context);
            await viewModel.OnTemplatesAvailableAsync();

            var userSelection = viewModel.UserSelection.GetUserSelection();

            Assert.Equal(SplitView, userSelection.Context.ProjectType);
            Assert.Equal(MvvmToolkit, userSelection.Context.FrontEndFramework);
            Assert.Equal(PageBlank, userSelection.Pages.First().TemplateId);
            await SetProjectTypeAsync(viewModel, Blank);
            await SetFrameworkAsync(viewModel, MVVMLight);

            userSelection = viewModel.UserSelection.GetUserSelection();
            viewModel.UnsubscribeEventHandlers();

            Assert.Equal(Blank, userSelection.Context.ProjectType);
            Assert.Equal(MVVMLight, userSelection.Context.FrontEndFramework);
            Assert.Equal(PageBlank, userSelection.Pages.First().TemplateId);
        }
        public async Task CanNotRemoveTemplateWithDependencyAsync()
        {
            // Default configuration: SplitView, MvvmToolkit, Blank page
            var stylesProviders = new UITestStyleValuesProvider();
            var viewModel       = new MainViewModel(null, stylesProviders);

            viewModel.UserSelection.ResetUserSelection();
            var context = new UserSelectionContext(GenContext.CurrentLanguage, Platforms.Uwp);

            viewModel.Initialize(context);
            await viewModel.OnTemplatesAvailableAsync();

            var settingsTemplate  = GetTemplate(viewModel.StepsViewModels[TemplateType.Page].Groups, PageSettings);
            var numOfDependencies = settingsTemplate.Dependencies?.Count();

            await AddTemplateAsync(viewModel, settingsTemplate);

            var userSelection = viewModel.UserSelection.GetUserSelection();

            Assert.Equal(numOfDependencies, userSelection.Features.Count);
            DeleteTemplate(TemplateType.Feature, viewModel.UserSelection, 0);
            userSelection = viewModel.UserSelection.GetUserSelection();
            viewModel.UnsubscribeEventHandlers();

            Assert.Equal(numOfDependencies, userSelection.Features.Count);
        }
示例#5
0
        public async Task ResolveDependenciesAndLicensesAsync()
        {
            var stylesProviders = new UITestStyleValuesProvider();
            var viewModel       = new MainViewModel(null, stylesProviders);
            var context         = new UserSelectionContext(GenContext.CurrentLanguage, TestPlatform);

            viewModel.Initialize(context);
            await viewModel.OnTemplatesAvailableAsync();

            var userSelection = viewModel.UserSelection.GetUserSelection();

            Assert.Single(userSelection.Pages);
            Assert.Empty(userSelection.Features);
            Assert.Equal(2, viewModel.UserSelection.Licenses.Count);

            var pageWithDependenciesTemplate = GetTemplate(viewModel.StepsViewModels[TemplateType.Page].Groups, TestPageWithDependencies);
            var numOfDependencies            = pageWithDependenciesTemplate.Dependencies?.Count();

            await AddTemplateAsync(viewModel, pageWithDependenciesTemplate);

            userSelection = viewModel.UserSelection.GetUserSelection();
            viewModel.UnsubscribeEventHandlers();

            Assert.Equal(2, userSelection.Pages.Count);
            Assert.Equal(numOfDependencies, userSelection.Features.Count);
            Assert.Equal(3, viewModel.UserSelection.Licenses.Count);
        }
示例#6
0
        protected async Task AddRightClickTemplatesAsync(string destinationPath, IEnumerable <ITemplateInfo> rightClickTemplates, string projectName, string projectType, string framework, string platform, string language)
        {
            // Add new items
            foreach (var item in rightClickTemplates)
            {
                GenContext.Current = new FakeContextProvider
                {
                    ProjectName          = projectName,
                    DestinationPath      = destinationPath,
                    GenerationOutputPath = GenContext.GetTempGenerationPath(projectName),
                };

                var context = new UserSelectionContext(language, platform)
                {
                    ProjectType       = projectType,
                    FrontEndFramework = framework,
                };

                var newUserSelection = new UserSelection(context)
                {
                    HomeName           = string.Empty,
                    ItemGenerationType = ItemGenerationType.GenerateAndMerge,
                };

                var templateInfo = GenContext.ToolBox.Repo.GetTemplateInfo(item, context);

                _fixture.AddItem(newUserSelection, templateInfo, BaseGenAndBuildFixture.GetDefaultName);

                await NewItemGenController.Instance.UnsafeGenerateNewItemAsync(item.GetTemplateType(), newUserSelection);

                NewItemGenController.Instance.UnsafeFinishGeneration(newUserSelection);
            }
        }
示例#7
0
        public void Initialize(TemplateType templateType, UserSelectionContext context)
        {
            TemplateType       = templateType;
            WizardStatus.Title = GetNewItemTitle(templateType);

            Initialize(context);
        }
示例#8
0
        public static IEnumerable <object[]> GetProjectTemplates(string platform, string language)
        {
            List <object[]> result = new List <object[]>();

            Configuration.Current.CdnUrl = "https://wtsrepository.blob.core.windows.net/pro/";

            InitializeTemplates(new LegacyTemplatesSourceV2(platform, language), platform, language);

            var context = new UserSelectionContext(language, platform);

            var projectTypes = GenContext.ToolBox.Repo.GetProjectTypes(context)
                               .Where(m => !string.IsNullOrEmpty(m.Description))
                               .Select(m => m.Name);

            foreach (var projectType in projectTypes)
            {
                context.ProjectType = projectType;
                var targetFrameworks = GenContext.ToolBox.Repo.GetFrontEndFrameworks(context)
                                       .Select(m => m.Name).ToList();

                foreach (var framework in targetFrameworks)
                {
                    result.Add(new object[] { projectType, framework, platform, language });
                }
            }

            return(result);
        }
        public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            try
            {
                if (runKind == WizardRunKind.AsNewProject || runKind == WizardRunKind.AsMultiProject)
                {
                    _replacementsDictionary = replacementsDictionary;

                    GenContext.Current = this;

                    var context = new UserSelectionContext(_language, _platform);
                    if (!string.IsNullOrEmpty(_appModel))
                    {
                        context.PropertyBag.Add("appmodel", _appModel);
                    }

                    _userSelection = WizardLauncher.Instance.StartNewProject(context, _replacementsDictionary["$wts.requiredworkloads$"], new VSStyleValuesProvider());
                }
            }
            catch (WizardBackoutException)
            {
                var projectDirectory  = replacementsDictionary["$destinationdirectory$"];
                var solutionDirectory = replacementsDictionary["$solutiondirectory$"];

                if (GenContext.ToolBox.Repo.SyncInProgress)
                {
                    GenContext.ToolBox.Repo.CancelSynchronization();
                }

                CleanupDirectories(DestinationPath);

                throw;
            }
        }
示例#10
0
 private static void AddPropertiesFromPropertyBag(UserSelectionContext context, Dictionary <string, string> properties)
 {
     foreach (var property in context.PropertyBag)
     {
         properties.Add($"{TelemetryProperties.GenerationPropertiesPrefix}.{property.Key.ToLowerInvariant()}", property.Value);
     }
 }
示例#11
0
        protected static IEnumerable <object[]> GetVBProjectTemplates()
        {
            List <object[]> result = new List <object[]>();

            var platform = Platforms.Uwp;
            var context  = new UserSelectionContext(ProgrammingLanguages.VisualBasic, platform);

            var projectTemplates =
                GenContext.ToolBox.Repo.GetAll().Where(
                    t => t.GetTemplateType() == TemplateType.Project &&
                    t.GetLanguage() == ProgrammingLanguages.VisualBasic);

            foreach (var projectTemplate in projectTemplates)
            {
                var projectTypeList = projectTemplate.GetProjectTypeList();

                foreach (var projectType in projectTypeList)
                {
                    context.ProjectType = projectType;
                    var frameworks = GenContext.ToolBox.Repo.GetFrontEndFrameworks(context)
                                     .Select(m => m.Name).ToList();

                    foreach (var framework in frameworks)
                    {
                        result.Add(new object[] { projectType, framework, platform });
                    }
                }
            }

            return(result);
        }
示例#12
0
        protected static IEnumerable <object[]> GetAllProjectTemplates()
        {
            List <object[]> result = new List <object[]>();

            foreach (var language in ProgrammingLanguages.GetAllLanguages())
            {
                SetCurrentLanguage(language);

                foreach (var platform in Platforms.GetAllPlatforms())
                {
                    SetCurrentPlatform(platform);

                    var context = new UserSelectionContext(language, platform);

                    var projectTypes = GenContext.ToolBox.Repo.GetProjectTypes(context)
                                       .Where(m => !string.IsNullOrEmpty(m.Description))
                                       .Select(m => m.Name);

                    foreach (var projectType in projectTypes)
                    {
                        context.ProjectType = projectType;
                        var targetFrameworks = GenContext.ToolBox.Repo.GetFrontEndFrameworks(context)
                                               .Select(m => m.Name).ToList();

                        foreach (var framework in targetFrameworks)
                        {
                            result.Add(new object[] { projectType, framework, platform, language });
                        }
                    }
                }
            }

            return(result);
        }
        public IEnumerable <MetadataInfo> GetProjectTypes()
        {
            var context = new UserSelectionContext(GenContext.CurrentLanguage, GenContext.CurrentPlatform);
            var result  = GenContext.ToolBox.Repo.GetProjectTypes(context);

            return(result);
        }
示例#14
0
 public async Task LoadDataAsync(UserSelectionContext context)
 {
     if (DataService.LoadProjectTypes(Items, context))
     {
         await BaseMainViewModel.BaseInstance.ProcessItemAsync(Items.First());
     }
 }
示例#15
0
        public override void Initialize(UserSelectionContext context)
        {
            switch (context.Platform)
            {
            case Platforms.Uwp:
                WizardStatus.Title = $"{StringRes.NewProjectTitleUWP} ({GenContext.Current.ProjectName})";
                break;

            case Platforms.Wpf:
                WizardStatus.Title = $"{StringRes.NewProjectTitleWPF} ({GenContext.Current.ProjectName})";
                break;

            case Platforms.WinUI:
                context.PropertyBag.TryGetValue("appmodel", out var appModel);
                switch (appModel)
                {
                case AppModels.Desktop:
                    WizardStatus.Title = $"{StringRes.NewProjectTitleWinUIDesktop} ({GenContext.Current.ProjectName})";
                    break;

                case AppModels.Uwp:
                    WizardStatus.Title = $"{StringRes.NewProjectTitleWinUIUWP} ({GenContext.Current.ProjectName})";
                    break;
                }

                break;

            default:
                break;
            }

            base.Initialize(context);
        }
示例#16
0
        public async Task UpdateHomePageAsync()
        {
            var stylesProviders = new UITestStyleValuesProvider();
            var viewModel       = new MainViewModel(null, stylesProviders);
            var context         = new UserSelectionContext(GenContext.CurrentLanguage, TestPlatform);

            viewModel.Initialize(context);
            await viewModel.OnTemplatesAvailableAsync();

            await AddTemplateAsync(viewModel, GetTemplate(viewModel.StepsViewModels[TemplateType.Page].Groups, TestPage));

            var userSelection = viewModel.UserSelection.GetUserSelection();

            Assert.True(userSelection.Pages[0].Name == MainPageName);
            Assert.True(userSelection.Pages[1].Name == TestPageName);
            Assert.True(userSelection.HomeName == MainPageName);

            var pages = viewModel.UserSelection.Groups.First(g => g.TemplateType == TemplateType.Page);

            pages.EnableOrdering(null);
            pages.SelectedItem = pages.Items[1];
            pages.MoveUpCommand.Execute(null);
            userSelection = viewModel.UserSelection.GetUserSelection();
            viewModel.UnsubscribeEventHandlers();

            Assert.True(userSelection.Pages[0].Name == TestPageName);
            Assert.True(userSelection.Pages[1].Name == MainPageName);
            Assert.True(userSelection.HomeName == TestPageName);
        }
示例#17
0
        public async Task RemoveHiddenFeaturesAsync()
        {
            var stylesProviders = new UITestStyleValuesProvider();
            var viewModel       = new MainViewModel(null, stylesProviders);
            var context         = new UserSelectionContext(GenContext.CurrentLanguage, TestPlatform);

            viewModel.Initialize(context);
            await viewModel.OnTemplatesAvailableAsync();

            var firstPageTemplate  = GetTemplate(viewModel.StepsViewModels[TemplateType.Page].Groups, TestPageWithServiceDependencies);
            var secondPageTemplate = GetTemplate(viewModel.StepsViewModels[TemplateType.Page].Groups, TestSecondPageWithServiceDependencies);
            var numOfDependencies  = firstPageTemplate.Dependencies?.Count();

            await AddTemplateAsync(viewModel, firstPageTemplate);
            await AddTemplateAsync(viewModel, secondPageTemplate);

            var userSelection = viewModel.UserSelection.GetUserSelection();

            Assert.Equal(3, userSelection.Pages.Count);
            Assert.Equal(numOfDependencies, userSelection.Services.Count);

            DeleteTemplate(TemplateType.Page, viewModel.UserSelection, 2);
            userSelection = viewModel.UserSelection.GetUserSelection();

            Assert.Equal(2, userSelection.Pages.Count);
            Assert.Equal(numOfDependencies, userSelection.Services.Count);

            DeleteTemplate(TemplateType.Page, viewModel.UserSelection, 1);
            userSelection = viewModel.UserSelection.GetUserSelection();
            viewModel.UnsubscribeEventHandlers();

            Assert.Single(userSelection.Pages);
            Assert.Equal(numOfDependencies, userSelection.Services.Count + 1);
        }
        public void Compose_BasicGeneration()
        {
            GenContext.Current = new TestContextProvider()
            {
                DestinationPath = string.Empty,
                ProjectName     = "TestProject",
            };

            var context = new UserSelectionContext(ProgrammingLanguages.CSharp, "test")
            {
                ProjectType       = "pt1",
                FrontEndFramework = "fx1",
            };

            var userSelection = new UserSelection(context)
            {
                HomeName = "TestHome",
            };

            userSelection.Add(new UserSelectionItem()
            {
                Name = "Main", TemplateId = "Microsoft.Templates.Test.PageTemplate.CSharp"
            }, TemplateType.Page);

            var genQueue = GenComposer.Compose(userSelection);

            AssertBasicParameters(genQueue, context);
        }
        public void Compose_GenerationWithPropertyBag()
        {
            GenContext.Current = new TestContextProvider()
            {
                DestinationPath = string.Empty,
                ProjectName     = "TestProject",
            };

            var context = new UserSelectionContext(ProgrammingLanguages.CSharp, "test")
            {
                ProjectType       = "pt1",
                FrontEndFramework = "fx4",
            };

            context.PropertyBag.Add("pb1", "value1");

            var userSelection = new UserSelection(context)
            {
                HomeName = "TestHome",
            };

            userSelection.Add(new UserSelectionItem()
            {
                Name = "MainPage", TemplateId = "Microsoft.Templates.Test.PageTemplatePropertyBag.CSharp"
            }, TemplateType.Page);

            var genQueue = GenComposer.Compose(userSelection);

            AssertBasicParameters(genQueue, context);

            var property = new KeyValuePair <string, string>("wts.generation.pb1", "value1");

            Assert.True(genQueue.Where(g => g.Name == "ProjectTemplatePropertyBag").All(g => g.Parameters.Contains(property)));
        }
示例#20
0
        public async Task Build_All_CheckWithStyleCop_WinUIAsync(string projectType, string framework, string platform, string language, string appModel)
        {
            bool templateSelector(ITemplateInfo t) => t.GetTemplateType().IsItemTemplate() &&
            (t.GetProjectTypeList().Contains(projectType) || t.GetProjectTypeList().Contains(All)) &&
            (t.GetFrontEndFrameworkList().Contains(framework) || t.GetFrontEndFrameworkList().Contains(All)) &&
            t.GetPlatform() == platform &&
            t.GetPropertyBagValuesList("appmodel").Contains(appModel) &&
            !t.GetIsHidden() ||
            (t.Identity == "wts.WinUI.UWP.Feat.StyleCop" && appModel == "Uwp") ||
            (t.Identity == "wts.WinUI.Feat.StyleCop" && appModel == "Desktop");

            var projectName = $"{projectType}{framework}AllStyleCop";

            var context = new UserSelectionContext(language, platform)
            {
                ProjectType       = projectType,
                FrontEndFramework = framework,
            };

            context.AddAppModel(appModel);

            var projectPath = await AssertGenerateProjectAsync(projectName, context, templateSelector, BaseGenAndBuildFixture.GetDefaultName, true);

            AssertBuildProject(projectPath, projectName, platform);
        }
        public async Task Build_Empty_Legacy_AddRightClick_WpfAsync(string projectType, string framework, string platform, string language)
        {
            var fixture = _fixture as BuildRightClickWithLegacyWpfFixture;

            var projectName = $"{projectType}{framework}Legacy{ShortLanguageName(language)}";

            var context = new UserSelectionContext(language, platform)
            {
                ProjectType       = projectType,
                FrontEndFramework = framework
            };

            var projectPath = await AssertGenerateProjectAsync(projectName, context, null, null);

            await fixture.ChangeToLocalTemplatesSourceAsync();

            var rightClickTemplates = _fixture.Templates().Where(
                t => t.GetTemplateType().IsItemTemplate() &&
                t.GetFrontEndFrameworkList().Contains(framework) &&
                !excludedTemplates.Contains(t.GroupIdentity) &&
                t.GetPlatform() == platform &&
                !t.GetIsHidden() &&
                t.GetRightClickEnabled());

            await AddRightClickTemplatesAsync(GenContext.Current.DestinationPath, rightClickTemplates, projectName, projectType, framework, platform, language);

            AssertBuildProject(projectPath, projectName, platform);
        }
示例#22
0
        protected void EnsureCanInferConfigInfo(UserSelectionContext context, string projectPath)
        {
            RemoveProjectConfigInfoFromProject();

            AssertCorrectProjectConfigInfo(context);
            AssertProjectConfigInfoRecreated(context);

            Fs.SafeDeleteDirectory(projectPath);
        }
        private static string GetProperty(this UserSelectionContext context, string key)
        {
            if (context.PropertyBag.TryGetValue(key, out var value))
            {
                return value;
            }

            return string.Empty;
        }
 public WizardShell(UserSelectionContext context, BaseStyleValuesProvider provider)
 {
     _context    = context;
     Current     = this;
     ViewModel   = new MainViewModel(this, provider);
     DataContext = ViewModel;
     InitializeComponent();
     NavigationService.InitializeMainFrame(mainFrame, new MainPage());
 }
示例#25
0
        public async Task TrackNewItemAsync(TemplateType templateType, UserSelectionContext context, Guid vsProjectId, GenItemsTelemetryData genItemsTelemetryData = null, double?timeSpent = null, CreationResultStatus genStatus = CreationResultStatus.Success, string message = "")
        {
            var itemType       = templateType.GetNewItemType();
            var itemTypeString = itemType != null?itemType.ToString() : string.Empty;

            // TODO: Remove TelemetryProperties.Framework and use TelemetryProperties.FrontendFramework
            var properties = new Dictionary <string, string>()
            {
                { TelemetryProperties.ProjectType, context.ProjectType },
                { TelemetryProperties.Framework, context.FrontEndFramework },
                { TelemetryProperties.FrontendFramework, context.FrontEndFramework },
                { TelemetryProperties.BackendFramework, context.BackEndFramework },
                { TelemetryProperties.GenEngineStatus, genStatus.ToString() },
                { TelemetryProperties.GenEngineMessage, message },
                { TelemetryProperties.EventName, TelemetryEvents.NewItemGen },
                { TelemetryProperties.VisualStudioActiveProjectGuid, vsProjectId.ToString() },
                { TelemetryProperties.Language, context.Language },
                { TelemetryProperties.VsProjectCategory, context.Platform },
                { TelemetryProperties.NewItemType, itemTypeString },
            };

            AddPropertiesFromPropertyBag(context, properties);

            var metrics = new Dictionary <string, double>();

            if (genItemsTelemetryData.PagesCount.HasValue)
            {
                metrics.Add(TelemetryMetrics.PagesCount, genItemsTelemetryData.PagesCount.Value);
            }

            if (timeSpent.HasValue)
            {
                metrics.Add(TelemetryMetrics.TimeSpent, timeSpent.Value);
            }

            if (genItemsTelemetryData.FeaturesCount.HasValue)
            {
                metrics.Add(TelemetryMetrics.FeaturesCount, genItemsTelemetryData.FeaturesCount.Value);
            }

            if (genItemsTelemetryData.ServicesCount.HasValue)
            {
                metrics.Add(TelemetryMetrics.ServicesCount, genItemsTelemetryData.ServicesCount.Value);
            }

            if (genItemsTelemetryData.TestingCount.HasValue)
            {
                metrics.Add(TelemetryMetrics.TestingCount, genItemsTelemetryData.TestingCount.Value);
            }

            GenContext.ToolBox.Shell.SafeTrackNewItemVsTelemetry(properties, genItemsTelemetryData.PageIdentities, genItemsTelemetryData.FeatureIdentities, genItemsTelemetryData.ServiceIdentities, genItemsTelemetryData.TestingIdentities, metrics);

            await TelemetryService.Current.TrackEventAsync(TelemetryEvents.NewItemGen, properties, metrics).ConfigureAwait(false);
        }
示例#26
0
        private UserSelectionContext GetProjectConfigInfo(string language)
        {
            var projectConfigInfoService = new ProjectConfigInfoService(GenContext.ToolBox.Shell);
            var configInfo = projectConfigInfoService.ReadProjectConfiguration();

            if (string.IsNullOrEmpty(configInfo.ProjectType) || string.IsNullOrEmpty(configInfo.Framework) || string.IsNullOrEmpty(configInfo.Platform))
            {
                var vm            = new ProjectConfigurationViewModel(language);
                var projectConfig = new ProjectConfigurationDialog(vm);
                GenContext.ToolBox.Shell.ShowModal(projectConfig);

                if (vm.Result == DialogResult.Accept)
                {
                    configInfo.ProjectType = vm.SelectedProjectType.Name;
                    configInfo.Framework   = vm.SelectedFramework.Name;
                    configInfo.Platform    = vm.SelectedPlatform;
                    if (configInfo.Platform == Platforms.WinUI)
                    {
                        configInfo.AppModel = vm.SelectedAppModel;
                    }

                    ProjectMetadataService.SaveProjectMetadata(configInfo, GenContext.ToolBox.Shell.GetActiveProjectPath());
                    var userSeletion = new UserSelectionContext(language, configInfo.Platform)
                    {
                        ProjectType       = configInfo.ProjectType,
                        FrontEndFramework = configInfo.Framework,
                    };

                    if (!string.IsNullOrEmpty(configInfo.AppModel))
                    {
                        userSeletion.AddAppModel(configInfo.AppModel);
                    }

                    return(userSeletion);
                }

                return(null);
            }
            else
            {
                var userSeletion = new UserSelectionContext(language, configInfo.Platform)
                {
                    ProjectType       = configInfo.ProjectType,
                    FrontEndFramework = configInfo.Framework,
                };

                if (!string.IsNullOrEmpty(configInfo.AppModel))
                {
                    userSeletion.AddAppModel(configInfo.AppModel);
                }

                return(userSeletion);
            }
        }
示例#27
0
        public void Initialize(UserSelectionContext context)
        {
            _context = context;

            if (_isInitialized)
            {
                Groups.ToList().ForEach(g => g.Clear());
            }

            _isInitialized = true;
        }
示例#28
0
        public async Task Build_MVVMBasic_OneByOneItems_WpfAsync(string itemName, string projectType, string framework, string platform, string itemId, string language)
        {
            var context = new UserSelectionContext(language, platform)
            {
                ProjectType       = projectType,
                FrontEndFramework = framework
            };

            var(ProjectPath, ProjecName) = await AssertGenerationOneByOneAsync(itemName, context, itemId, false);

            AssertBuildProject(ProjectPath, ProjecName, platform);
        }
示例#29
0
        public UserSelection StartNewProject(UserSelectionContext context, string requiredWorkloads, BaseStyleValuesProvider provider)
        {
            _styleProvider = provider;

            CheckVSVersion(context.Platform);
            CheckForMissingWorkloads(context.Platform, requiredWorkloads);
            CheckForInvalidProjectName();

            var newProjectView = new Views.NewProject.WizardShell(context, provider);

            return(StartWizard(newProjectView, WizardTypeEnum.NewProject));
        }
示例#30
0
        public async Task Build_EmptyProject_WpfAsync(string projectType, string framework, string platform, string language)
        {
            var context = new UserSelectionContext(language, platform)
            {
                ProjectType       = projectType,
                FrontEndFramework = framework
            };

            var(projectName, projectPath) = await GenerateEmptyProjectAsync(context);

            AssertBuildProject(projectPath, projectName, platform, deleteAfterBuild: true);
        }